[PATCH] D69876: Allow output constraints on "asm goto"

2019-11-09 Thread Bill Wendling via Phabricator via cfe-commits
void updated this revision to Diff 228594.
void added a comment.

Emit asm goto fallthrough early so that any value extracts will show up in the
fallthrough block and not directly after the callbr.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69876

Files:
  clang/include/clang/AST/Stmt.h
  clang/lib/AST/Stmt.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/Parse/ParseStmtAsm.cpp
  clang/lib/Sema/SemaStmtAsm.cpp
  clang/test/CodeGen/asm-goto.c
  clang/test/Parser/asm-goto.c
  clang/test/Parser/asm-goto.cpp
  clang/test/Sema/asm-goto.cpp

Index: clang/test/Sema/asm-goto.cpp
===
--- clang/test/Sema/asm-goto.cpp
+++ clang/test/Sema/asm-goto.cpp
@@ -1,53 +1,51 @@
 // RUN: %clang_cc1 %s -triple i386-pc-linux-gnu -verify -fsyntax-only
 // RUN: %clang_cc1 %s -triple x86_64-pc-linux-gnu -verify -fsyntax-only
 
-struct NonTrivial {
-  ~NonTrivial();
+struct S {
+  ~S();
   int f(int);
 private:
   int k;
 };
-void JumpDiagnostics(int n) {
-// expected-error@+1 {{cannot jump from this goto statement to its label}}
+void test1(int n) {
+  // expected-error@+1 {{cannot jump from this goto statement to its label}}
   goto DirectJump;
-// expected-note@+1 {{jump bypasses variable with a non-trivial destructor}}
-  NonTrivial tnp1;
+  // expected-note@+1 {{jump bypasses variable with a non-trivial destructor}}
+  S s1;
 
 DirectJump:
-// expected-error@+1 {{cannot jump from this asm goto statement to one of its possible targets}}
+  // expected-error@+1 {{cannot jump from this asm goto statement to one of its possible targets}}
   asm goto("jmp %l0;" Later);
-// expected-note@+1 {{jump bypasses variable with a non-trivial destructor}}
-  NonTrivial tnp2;
-// expected-note@+1 {{possible target of asm goto statement}}
+  // expected-note@+1 {{jump bypasses variable with a non-trivial destructor}}
+  S s2;
+  // expected-note@+1 {{possible target of asm goto statement}}
 Later:
   return;
 }
 
-struct S { ~S(); };
-void foo(int a) {
+struct T { ~T(); };
+void test2(int a) {
   if (a) {
 FOO:
-// expected-note@+2 {{jump exits scope of variable with non-trivial destructor}}
-// expected-note@+1 {{jump exits scope of variable with non-trivial destructor}}
-S s;
-void *p = &&BAR;
-// expected-error@+1 {{cannot jump from this asm goto statement to one of its possible targets}}
-  asm goto("jmp %l0;" BAR);
-// expected-error@+1 {{cannot jump from this indirect goto statement to one of its possible targets}}
+// expected-note@+2 {{jump exits scope of variable with non-trivial destructor}}
+// expected-note@+1 {{jump exits scope of variable with non-trivial destructor}}
+T t;
+void *p = &&bar;
+  // expected-error@+1 {{cannot jump from this asm goto statement to one of its possible targets}}
+  asm goto("jmp %l0;" bar);
+// expected-error@+1 {{cannot jump from this indirect goto statement to one of its possible targets}}
 goto *p;
 p = &&FOO;
 goto *p;
 return;
   }
-// expected-note@+2 {{possible target of asm goto statement}}
-// expected-note@+1 {{possible target of indirect goto statement}}
-BAR:
+  // expected-note@+2 {{possible target of asm goto statement}}
+  // expected-note@+1 {{possible target of indirect goto statement}}
+bar:
   return;
 }
 
-
-//Asm goto:
-int test16(int n)
+int test3(int n)
 {
   // expected-error@+2 {{cannot jump from this asm goto statement to one of its possible targets}}
   // expected-error@+1 {{cannot jump from this asm goto statement to one of its possible targets}}
@@ -57,7 +55,7 @@
   return ({int a[n];label_true: 2;});
   // expected-note@+1 {{jump bypasses initialization of variable length array}}
   int b[n];
-// expected-note@+1 {{possible target of asm goto statement}}
+  // expected-note@+1 {{possible target of asm goto statement}}
 loop:
   return 0;
 }
Index: clang/test/Parser/asm-goto.cpp
===
--- clang/test/Parser/asm-goto.cpp
+++ clang/test/Parser/asm-goto.cpp
@@ -1,14 +1,54 @@
 // RUN: %clang_cc1 -triple i386-pc-linux-gnu -fsyntax-only -verify -std=c++11 %s
 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -verify -std=c++11 %s
 
-int zoo ()
-{
+int a, b, c, d, e, f, g, h, i, j, k, l;
+
+void test1(void) {
+  __asm__ volatile goto (""
+:: [a] "r" (a), [b] "r" (b), [c] "r" (c), [d] "r" (d),
+   [e] "r" (e), [f] "r" (f), [g] "r" (g), [h] "r" (h),
+   [i] "r" (i), [j] "r" (j), [k] "r" (k), [l] "r" (l)
+::lab1,lab2);
+lab1: return;
+lab2: return;
+}
+
+void test2(void) {
+  __asm__ volatile goto (""
+:: [a] "r,m" (a), [b] "r,m" (b), [c] "r,m" (c), [d] "r,m" (d),
+   [e] "r,m" (e), [f] "r,m" (f), [g] "r,m" (g), [h] "r,m" (h),
+   [i] "r,m" (i), [j] "r,m" (j), [k] "r,m" (k), [l] "r,m" (l)
+:: lab);
+  lab: return;
+

[PATCH] D69755: [LLD] Add NetBSD support as a new flavor of LLD (nb.lld)

2019-11-09 Thread Kamil Rytarowski via Phabricator via cfe-commits
krytarowski abandoned this revision.
krytarowski added a comment.

Better patch in https://reviews.llvm.org/D70048


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69755



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


[PATCH] D70048: [LLD] Add NetBSD support as a new flavor of LLD (nb.lld)

2019-11-09 Thread Kamil Rytarowski via Phabricator via cfe-commits
krytarowski updated this revision to Diff 228591.
krytarowski added a comment.

- fix a typo in a comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70048

Files:
  clang/lib/Driver/ToolChain.cpp
  lld/CMakeLists.txt
  lld/NetBSD/CMakeLists.txt
  lld/NetBSD/Driver.cpp
  lld/NetBSD/Options.td
  lld/include/lld/Common/Driver.h
  lld/tools/lld/CMakeLists.txt
  lld/tools/lld/lld.cpp

Index: lld/tools/lld/lld.cpp
===
--- lld/tools/lld/lld.cpp
+++ lld/tools/lld/lld.cpp
@@ -10,12 +10,13 @@
 // function is a thin wrapper which dispatches to the platform specific
 // driver.
 //
-// lld is a single executable that contains four different linkers for ELF,
-// COFF, WebAssembly and Mach-O. The main function dispatches according to
-// argv[0] (i.e. command name). The most common name for each target is shown
+// lld is a single executable that contains five different linkers for ELF,
+// NetBSD, COFF, WebAssembly and Mach-O. The main function dispatches according
+// to argv[0] (i.e. command name). The most common name for each target is shown
 // below:
 //
 //  - ld.lld:ELF (Unix)
+//  - nb.lld:ELF (NetBSD)
 //  - ld64:  Mach-O (macOS)
 //  - lld-link:  COFF (Windows)
 //  - ld-wasm:   WebAssembly
@@ -45,6 +46,7 @@
 enum Flavor {
   Invalid,
   Gnu, // -flavor gnu
+  NetBSD,  // -flavor netbsd
   WinLink, // -flavor link
   Darwin,  // -flavor darwin
   Wasm,// -flavor wasm
@@ -58,6 +60,7 @@
 static Flavor getFlavor(StringRef s) {
   return StringSwitch(s)
   .CasesLower("ld", "ld.lld", "gnu", Gnu)
+  .CasesLower("nb.lld", "netbsd", NetBSD)
   .CasesLower("wasm", "ld-wasm", Wasm)
   .CaseLower("link", WinLink)
   .CasesLower("ld64", "ld64.lld", "darwin", Darwin)
@@ -100,10 +103,15 @@
 #endif
 
 #if LLVM_ON_UNIX
-  // Use GNU driver for "ld" on other Unix-like system.
-  if (progname == "ld")
+  // Use GNU or NetBSD driver for "ld" on other Unix-like system.
+  if (progname == "ld") {
+#if defined(__NetBSD__)
+return NetBSD;
+#else
 return Gnu;
 #endif
+  }
+#endif
 
   // Progname may be something like "lld-gnu". Parse it.
   SmallVector v;
@@ -141,7 +149,7 @@
 // and we use it to detect whether we are running tests or not.
 static bool canExitEarly() { return StringRef(getenv("LLD_IN_TEST")) != "1"; }
 
-/// Universal linker main(). This linker emulates the gnu, darwin, or
+/// Universal linker main(). This linker emulates the gnu, netbsd, darwin, or
 /// windows linker based on the argv[0] or -flavor option.
 int main(int argc, const char **argv) {
   InitLLVM x(argc, argv);
@@ -152,6 +160,8 @@
 if (isPETarget(args))
   return !mingw::link(args);
 return !elf::link(args, canExitEarly());
+  case NetBSD:
+return !netbsd::link(args, canExitEarly());
   case WinLink:
 return !coff::link(args, canExitEarly());
   case Darwin:
@@ -160,7 +170,7 @@
 return !wasm::link(args, canExitEarly());
   default:
 die("lld is a generic driver.\n"
-"Invoke ld.lld (Unix), ld64.lld (macOS), lld-link (Windows), wasm-ld"
-" (WebAssembly) instead");
+"Invoke ld.lld (Unix), nb.lld (NetBSD), ld64.lld (macOS), lld-link "
+"(Windows), wasm-ld (WebAssembly) instead");
   }
 }
Index: lld/tools/lld/CMakeLists.txt
===
--- lld/tools/lld/CMakeLists.txt
+++ lld/tools/lld/CMakeLists.txt
@@ -12,6 +12,7 @@
   lldCOFF
   lldDriver
   lldELF
+  lldNetBSD
   lldMinGW
   lldWasm
   )
@@ -20,7 +21,7 @@
   RUNTIME DESTINATION bin)
 
 if(NOT LLD_SYMLINKS_TO_CREATE)
-  set(LLD_SYMLINKS_TO_CREATE lld-link ld.lld ld64.lld wasm-ld)
+  set(LLD_SYMLINKS_TO_CREATE lld-link ld.lld nb.lld ld64.lld wasm-ld)
 endif()
 
 foreach(link ${LLD_SYMLINKS_TO_CREATE})
Index: lld/include/lld/Common/Driver.h
===
--- lld/include/lld/Common/Driver.h
+++ lld/include/lld/Common/Driver.h
@@ -28,6 +28,11 @@
   llvm::raw_ostream &diag = llvm::errs());
 }
 
+namespace netbsd {
+bool link(llvm::ArrayRef args, bool canExitEarly,
+  llvm::raw_ostream &diag = llvm::errs());
+}
+
 namespace mach_o {
 bool link(llvm::ArrayRef args, bool canExitEarly,
   llvm::raw_ostream &diag = llvm::errs());
Index: lld/NetBSD/Options.td
===
--- /dev/null
+++ lld/NetBSD/Options.td
@@ -0,0 +1,7 @@
+include "llvm/Option/OptParser.td"
+
+class F: Flag<["--", "-"], name>;
+
+def version: F<"version">, HelpText<"Display the version number and exit">;
+def v: Flag<["-"], "v">, HelpText<"Display the version number">;
+def: Flag<["-"], "V">, Alias, HelpText<"Alias for --version">;
Index: lld/NetBSD/Driver.cpp
===
--- /dev/null
+++ lld/NetBSD/Driver.cpp
@@ -0,0 +1,187 @@
+//===- nb.ll

[PATCH] D70048: [LLD] Add NetBSD support as a new flavor of LLD (nb.lld)

2019-11-09 Thread Kamil Rytarowski via Phabricator via cfe-commits
krytarowski added a comment.

Another approach to achieve the same goal as previous attempts. It is already 
better as it avoids two forks.

Does this one look like fine for merging?

The previous one for the reference: https://reviews.llvm.org/D69755


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70048



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


[PATCH] D70048: [LLD] Add NetBSD support as a new flavor of LLD (nb.lld)

2019-11-09 Thread Kamil Rytarowski via Phabricator via cfe-commits
krytarowski created this revision.
krytarowski added reviewers: joerg, mgorny, ruiu, MaskRay.
krytarowski added a project: lld.
Herald added subscribers: llvm-commits, cfe-commits, mstorsjo, fedor.sergeev, 
aheejin, emaste, dschuff.
Herald added projects: clang, LLVM.

The NetBSD target wraps the default Linux/ELF target with OS
specific customization. It is implemented as a light netbsd::link()
module wrapper that mutates arguments in argv[] and calls
elf::link().

This flavor detects the native/current and target Triple based on
argv[0] parsing. This is prerequisite for cross-compilation, in
particular the NetBSD distribution is cross-built always.

The default configuration of the ELF target is tuned for Linux and
there is no way to costomize in-place for the NetBSD target in the
same way as FreeBSD/OpenBSD. FreeBSD whenever needed can check
emulation name ("*_fbsd") and OpenBSD calls its extensions
"PT_OPENBSD_*".

This distinct flavor is needed for NetBSD as:

- the linker MUST work in the standalone mode
- it must be useful with gcc/pcc/others out of the box
- clang NetBSD driver shall not hardcode LLD specific options
- the linker must have support for cross-building
- LLD shall be a drop-in replacement for (NetBSD-patched) GNU ld

There is no code-duplication between the NetBSD and ELF modules.
The NetBSD driver for debugging purposes prints the Target string
for the -v|-V|--version command line argument. There is no functional
or code maintenance change for other Operating Systems, especially
the ELF ones.

Equivalent customization is already done for the Darwin mode. For
instance there are hardcoded default search paths such as "/usr/lib"
and "/Library/Frameworks" in DarwinLdDriver.cpp. There is a prior
art with the MinGW target that similarly wraps coff:link().

This change is a starting point for development of NetBSD support
in LLD.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70048

Files:
  clang/lib/Driver/ToolChain.cpp
  lld/CMakeLists.txt
  lld/NetBSD/CMakeLists.txt
  lld/NetBSD/Driver.cpp
  lld/NetBSD/Options.td
  lld/include/lld/Common/Driver.h
  lld/tools/lld/CMakeLists.txt
  lld/tools/lld/lld.cpp

Index: lld/tools/lld/lld.cpp
===
--- lld/tools/lld/lld.cpp
+++ lld/tools/lld/lld.cpp
@@ -10,12 +10,13 @@
 // function is a thin wrapper which dispatches to the platform specific
 // driver.
 //
-// lld is a single executable that contains four different linkers for ELF,
-// COFF, WebAssembly and Mach-O. The main function dispatches according to
-// argv[0] (i.e. command name). The most common name for each target is shown
+// lld is a single executable that contains five different linkers for ELF,
+// NetBSD, COFF, WebAssembly and Mach-O. The main function dispatches according
+// to argv[0] (i.e. command name). The most common name for each target is shown
 // below:
 //
 //  - ld.lld:ELF (Unix)
+//  - nb.lld:ELF (NetBSD)
 //  - ld64:  Mach-O (macOS)
 //  - lld-link:  COFF (Windows)
 //  - ld-wasm:   WebAssembly
@@ -45,6 +46,7 @@
 enum Flavor {
   Invalid,
   Gnu, // -flavor gnu
+  NetBSD,  // -flavor netbsd
   WinLink, // -flavor link
   Darwin,  // -flavor darwin
   Wasm,// -flavor wasm
@@ -58,6 +60,7 @@
 static Flavor getFlavor(StringRef s) {
   return StringSwitch(s)
   .CasesLower("ld", "ld.lld", "gnu", Gnu)
+  .CasesLower("nb.lld", "netbsd", NetBSD)
   .CasesLower("wasm", "ld-wasm", Wasm)
   .CaseLower("link", WinLink)
   .CasesLower("ld64", "ld64.lld", "darwin", Darwin)
@@ -100,10 +103,15 @@
 #endif
 
 #if LLVM_ON_UNIX
-  // Use GNU driver for "ld" on other Unix-like system.
-  if (progname == "ld")
+  // Use GNU or NetBSD driver for "ld" on other Unix-like system.
+  if (progname == "ld") {
+#if defined(__NetBSD__)
+return NetBSD;
+#else
 return Gnu;
 #endif
+  }
+#endif
 
   // Progname may be something like "lld-gnu". Parse it.
   SmallVector v;
@@ -141,7 +149,7 @@
 // and we use it to detect whether we are running tests or not.
 static bool canExitEarly() { return StringRef(getenv("LLD_IN_TEST")) != "1"; }
 
-/// Universal linker main(). This linker emulates the gnu, darwin, or
+/// Universal linker main(). This linker emulates the gnu, netbsd, darwin, or
 /// windows linker based on the argv[0] or -flavor option.
 int main(int argc, const char **argv) {
   InitLLVM x(argc, argv);
@@ -152,6 +160,8 @@
 if (isPETarget(args))
   return !mingw::link(args);
 return !elf::link(args, canExitEarly());
+  case NetBSD:
+return !netbsd::link(args, canExitEarly());
   case WinLink:
 return !coff::link(args, canExitEarly());
   case Darwin:
@@ -160,7 +170,7 @@
 return !wasm::link(args, canExitEarly());
   default:
 die("lld is a generic driver.\n"
-"Invoke ld.lld (Unix), ld64.lld (macOS), lld-link (Windows), wasm-ld"
-" (WebAssembly) instead");
+"Invoke ld.lld (Unix), nb.lld (NetBSD), ld64.lld (macOS), lld-lin

[PATCH] D69360: [NFC] Refactor representation of materialized temporaries

2019-11-09 Thread Tyker via Phabricator via cfe-commits
Tyker added a comment.

@rsmith ping


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

https://reviews.llvm.org/D69360



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


[PATCH] D67787: Add 8548 CPU definition and attributes

2019-11-09 Thread Justin Hibbits via Phabricator via cfe-commits
jhibbits updated this revision to Diff 228589.
jhibbits added a comment.

Add clang-translation tests for e500 and 8548 CPU definitions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67787

Files:
  clang/lib/Basic/Targets/PPC.cpp
  clang/lib/Basic/Targets/PPC.h
  clang/lib/Driver/ToolChains/Arch/PPC.cpp
  clang/test/Driver/clang-translation.c
  clang/test/Misc/target-invalid-cpu-note.c
  clang/test/Preprocessor/init.c

Index: clang/test/Preprocessor/init.c
===
--- clang/test/Preprocessor/init.c
+++ clang/test/Preprocessor/init.c
@@ -7604,6 +7604,12 @@
 //
 // PPC32-SPE:#define __NO_FPRS__ 1
 // PPC32-SPE:#define __SPE__ 1
+// 
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-unknown-linux-gnu -target-cpu 8548 < /dev/null | FileCheck -match-full-lines -check-prefix PPC8548 %s
+//
+// PPC8548:#define __NO_FPRS__ 1
+// PPC8548:#define __NO_LWSYNC__ 1
+// PPC8548:#define __SPE__ 1
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-apple-darwin8 < /dev/null | FileCheck -match-full-lines -check-prefix PPC-DARWIN %s
 //
Index: clang/test/Misc/target-invalid-cpu-note.c
===
--- clang/test/Misc/target-invalid-cpu-note.c
+++ clang/test/Misc/target-invalid-cpu-note.c
@@ -79,10 +79,10 @@
 // PPC: error: unknown target CPU 'not-a-cpu'
 // PPC: note: valid target CPU values are: generic, 440, 450, 601, 602, 603,
 // PPC-SAME: 603e, 603ev, 604, 604e, 620, 630, g3, 7400, g4, 7450, g4+, 750,
-// PPC-SAME: 970, g5, a2, a2q, e500mc, e5500, power3, pwr3, power4, pwr4,
-// PPC-SAME: power5, pwr5, power5x, pwr5x, power6, pwr6, power6x, pwr6x, power7,
-// PPC-SAME: pwr7, power8, pwr8, power9, pwr9, powerpc, ppc, powerpc64, ppc64,
-// PPC-SAME: powerpc64le, ppc64le
+// PPC-SAME: 8548, 970, g5, a2, a2q, e500, e500mc, e5500, power3, pwr3, power4,
+// PPC-SAME: pwr4, power5, pwr5, power5x, pwr5x, power6, pwr6, power6x, pwr6x,
+// PPC-SAME: power7, pwr7, power8, pwr8, power9, pwr9, powerpc, ppc, powerpc64,
+// PPC-SAME: ppc64, powerpc64le, ppc64le
 
 // RUN: not %clang_cc1 -triple mips--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix MIPS
 // MIPS: error: unknown target CPU 'not-a-cpu'
Index: clang/test/Driver/clang-translation.c
===
--- clang/test/Driver/clang-translation.c
+++ clang/test/Driver/clang-translation.c
@@ -276,6 +276,18 @@
 // PPC64NS: "-cc1"
 // PPC64NS: "-target-cpu" "ppc64"
 
+// RUN: %clang -target powerpc-fsl-linux -### -S %s \
+// RUN: -mcpu=e500 2>&1 | FileCheck -check-prefix=PPCE500 %s
+// PPCE500: clang
+// PPCE500: "-cc1"
+// PPCE500: "-target-cpu" "e500"
+
+// RUN: %clang -target powerpc-fsl-linux -### -S %s \
+// RUN: -mcpu=8548 2>&1 | FileCheck -check-prefix=PPC8548 %s
+// PPC8548: clang
+// PPC8548: "-cc1"
+// PPC8548: "-target-cpu" "e500"
+
 // RUN: %clang -target powerpc-fsl-linux -### -S %s \
 // RUN: -mcpu=e500mc 2>&1 | FileCheck -check-prefix=PPCE500MC %s
 // PPCE500MC: clang
Index: clang/lib/Driver/ToolChains/Arch/PPC.cpp
===
--- clang/lib/Driver/ToolChains/Arch/PPC.cpp
+++ clang/lib/Driver/ToolChains/Arch/PPC.cpp
@@ -53,10 +53,12 @@
 .Case("7450", "7450")
 .Case("G4+", "g4+")
 .Case("750", "750")
+.Case("8548", "e500")
 .Case("970", "970")
 .Case("G5", "g5")
 .Case("a2", "a2")
 .Case("a2q", "a2q")
+.Case("e500", "e500")
 .Case("e500mc", "e500mc")
 .Case("e5500", "e5500")
 .Case("power3", "pwr3")
Index: clang/lib/Basic/Targets/PPC.h
===
--- clang/lib/Basic/Targets/PPC.h
+++ clang/lib/Basic/Targets/PPC.h
@@ -44,7 +44,8 @@
 ArchDefinePwr8 = 1 << 12,
 ArchDefinePwr9 = 1 << 13,
 ArchDefineA2 = 1 << 14,
-ArchDefineA2q = 1 << 15
+ArchDefineA2q = 1 << 15,
+ArchDefineE500 = 1 << 16
   } ArchDefineTypes;
 
 
@@ -145,6 +146,7 @@
  ArchDefinePwr9 | ArchDefinePwr8 | ArchDefinePwr7 |
  ArchDefinePwr6 | ArchDefinePwr5x | ArchDefinePwr5 |
  ArchDefinePwr4 | ArchDefinePpcgr | ArchDefinePpcsq)
+  .Cases("8548", "e500", ArchDefineE500)
   .Default(ArchDefineNone);
 }
 return CPUKnown;
Index: clang/lib/Basic/Targets/PPC.cpp
===
--- clang/lib/Basic/Targets/PPC.cpp
+++ clang/lib/Basic/Targets/PPC.cpp
@@ -157,6 +157,8 @@
 Builder.defineMacro("_ARCH_A2Q");
 Builder.defineMacro("_ARCH_QP");
   }
+  if (ArchDefs & ArchDefineE500)
+Builder.defineMacro("__NO_LWSYNC__");
 
   if (getTriple().getVendor() == llvm::Triple::BGQ) {
 Builder.defineMacro("__bg__");
@@ -312,6 +314,11 @@

[PATCH] D69759: [BPF] Add preserve_access_index attribute for record definition

2019-11-09 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song added a comment.

@aaron.ballman BTW, I indeed tested C-style inheritance. An attribute for the 
forward declaration successfully inherited by a later actual declaration.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69759



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


[PATCH] D69759: [BPF] Add preserve_access_index attribute for record definition

2019-11-09 Thread Alexei Starovoitov via Phabricator via cfe-commits
ast added a comment.

I've tested this patch on several kernel selftests/bpf/ and it works like 
magic. Very nice improvement.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69759



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


[PATCH] D69759: [BPF] Add preserve_access_index attribute for record definition

2019-11-09 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song added a comment.

Regarding to this one "This is missing a bunch of C++ tests that show what 
happens in the case of inheritance, template instantiations, etc."
Could you give me some example tests which I can take a look in order to add 
support. FYI, BPF backend publicly only supports C language,
(a restrict C for example __thread keyword is not supported). I guess template 
instantiations does not apply here? Or we can still test
template instantiation since we are at clang stage?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69759



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


[PATCH] D69759: [BPF] Add preserve_access_index attribute for record definition

2019-11-09 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song marked 2 inline comments as done.
yonghong-song added a comment.

Hi, @aaron.ballman I think I addressed all your comments, could you take a look 
again? I tested all failed tests as exposed by the buildbot here 
(http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/57856).
 They are all passing now. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69759



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


[PATCH] D69759: [BPF] Add preserve_access_index attribute for record definition

2019-11-09 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song updated this revision to Diff 228588.
yonghong-song added a comment.

use implicit attr to annotate records or fields not explicitly marked by users.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69759

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/bpf-attr-preserve-access-index-1.c
  clang/test/CodeGen/bpf-attr-preserve-access-index-2.c
  clang/test/CodeGen/bpf-attr-preserve-access-index-3.c
  clang/test/CodeGen/bpf-attr-preserve-access-index-4.c
  clang/test/CodeGen/bpf-attr-preserve-access-index-5.c
  clang/test/CodeGen/bpf-attr-preserve-access-index-6.c
  clang/test/CodeGen/bpf-attr-preserve-access-index-7.c
  clang/test/CodeGen/bpf-attr-preserve-access-index-8.c
  clang/test/Sema/bpf-attr-preserve-access-index.c

Index: clang/test/Sema/bpf-attr-preserve-access-index.c
===
--- /dev/null
+++ clang/test/Sema/bpf-attr-preserve-access-index.c
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -x c -triple bpf-pc-linux-gnu -dwarf-version=4 -fsyntax-only -verify %s
+
+#define __reloc__ __attribute__((preserve_access_index))
+#define __err_reloc__ __attribute__((preserve_access_index(0)))
+
+struct t1 {
+  int a;
+  int b[4];
+  int c:1;
+} __reloc__;
+
+union t2 {
+  int a;
+  int b[4];
+  int c:1;
+} __reloc__;
+
+struct t3 {
+  int a;
+} __err_reloc__; // expected-error {{'preserve_access_index' attribute takes no arguments}}
+
+struct t4 {
+  union {
+int a;
+char b[5];
+  };
+  struct {
+int c:1;
+  } __reloc__;
+  int d;
+} __reloc__;
+
+struct __reloc__ p;
+struct __reloc__ q;
+struct p {
+  int a;
+};
+
+int a __reloc__; // expected-error {{'preserve_access_index' attribute only applies to structs, unions, and classes}}
+struct s *p __reloc__; // expected-error {{'preserve_access_index' attribute only applies to structs, unions, and classes}}
+
+void invalid1(const int __reloc__ *arg) {} // expected-error {{'preserve_access_index' attribute only applies to structs, unions, and classes}}
+void invalid2() { const int __reloc__ *arg; } // expected-error {{'preserve_access_index' attribute only applies to structs, unions, and classes}}
+int valid3(struct t4 *arg) { return arg->a + arg->b[3] + arg->c + arg->d; }
+int valid4(void *arg) {
+  struct local_t { int a; int b; } __reloc__;
+  return ((struct local_t *)arg)->b;
+}
Index: clang/test/CodeGen/bpf-attr-preserve-access-index-8.c
===
--- /dev/null
+++ clang/test/CodeGen/bpf-attr-preserve-access-index-8.c
@@ -0,0 +1,36 @@
+// REQUIRES: bpf-registered-target
+// RUN: %clang -target bpf -emit-llvm -S -g %s -o - | FileCheck %s
+
+#define __reloc__ __attribute__((preserve_access_index))
+
+// chain of records, all with attributes
+struct s1;
+struct s2;
+struct s3;
+
+struct s1 {
+  int c;
+} __reloc__;
+typedef struct s1 __s1;
+
+struct s2 {
+  union {
+__s1 b[3];
+  };
+} __reloc__;
+typedef struct s2 __s2;
+
+struct s3 {
+  __s2 a;
+} __reloc__;
+typedef struct s3 __s3;
+
+int test(__s3 *arg) {
+  return arg->a.b[2].c;
+}
+
+// CHECK: call %struct.s2* @llvm.preserve.struct.access.index.p0s_struct.s2s.p0s_struct.s3s(%struct.s3* %{{[0-9a-z]+}}, i32 0, i32 0)
+// CHECK: call %union.anon* @llvm.preserve.struct.access.index.p0s_union.anons.p0s_struct.s2s(%struct.s2* %{{[0-9a-z]+}}, i32 0, i32 0)
+// CHECK: call %union.anon* @llvm.preserve.union.access.index.p0s_union.anons.p0s_union.anons(%union.anon* %{{[0-9a-z]+}}, i32 0)
+// CHECK: call %struct.s1* @llvm.preserve.array.access.index.p0s_struct.s1s.p0a3s_struct.s1s([3 x %struct.s1]* %{{[0-9a-z]+}}, i32 1, i32 2)
+// CHECK: call i32* @llvm.preserve.struct.access.index.p0i32.p0s_struct.s1s(%struct.s1* %{{[0-9a-z]+}}, i32 0, i32 0)
Index: clang/test/CodeGen/bpf-attr-preserve-access-index-7.c
===
--- /dev/null
+++ clang/test/CodeGen/bpf-attr-preserve-access-index-7.c
@@ -0,0 +1,36 @@
+// REQUIRES: bpf-registered-target
+// RUN: %clang -target bpf -emit-llvm -S -g %s -o - | FileCheck %s
+
+#define __reloc__ __attribute__((preserve_access_index))
+
+// chain of records, all with attributes
+struct __reloc__ s1;
+struct __reloc__ s2;
+struct __reloc__ s3;
+
+struct s1 {
+  int c;
+};
+typedef struct s1 __s1;
+
+struct s2 {
+  union {
+__s1 b[3];
+  };
+};
+typedef struct s2 __s2;
+
+struct s3 {
+  __s2 a;
+};
+typedef struct s3 __s3;
+
+int test(__s3 *arg) {
+  return arg->a.b[2].c;
+}
+
+// CHECK: call %struct.s2* @llvm.preserve.struct.access.index.p0s_struct.s2s.p0s_struct.s3s(%struct.s3* %{{[0-9a-z]+}}, i32 0, i32 0)
+// CHECK: call %union.anon* @llvm.preserve.struct.access.index.p0s_union.anons.p0s_struct.s2s(%struct.s2* %{{[0-9a-z]+}}, i32 0, i32 0)
+// CHECK: call %union.anon* @llvm.preserve.unio

[PATCH] D70046: [OpenMP] Use an explicit copy in a range-based for

2019-11-09 Thread Mark de Wever via Phabricator via cfe-commits
Mordante added a comment.

`OMPMappableExprListClause::const_component_lists_iterator::operator*()` 
returns an object and not a reference to an object. 
-Wrange-loop-analysis warns to make it more visible the object is a copy and 
not a reference.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70046



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


[PATCH] D69759: [BPF] Add preserve_access_index attribute for record definition

2019-11-09 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song updated this revision to Diff 228583.
yonghong-song added a comment.

The Decl "D" could be a nullptr in ProcessDeclAttributeDelayed, which will 
cause segfault. Handle this properly.
Also addressed most of Aaron's comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69759

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/bpf-attr-preserve-access-index-1.c
  clang/test/CodeGen/bpf-attr-preserve-access-index-2.c
  clang/test/CodeGen/bpf-attr-preserve-access-index-3.c
  clang/test/CodeGen/bpf-attr-preserve-access-index-4.c
  clang/test/CodeGen/bpf-attr-preserve-access-index-5.c
  clang/test/CodeGen/bpf-attr-preserve-access-index-6.c
  clang/test/CodeGen/bpf-attr-preserve-access-index-7.c
  clang/test/CodeGen/bpf-attr-preserve-access-index-8.c
  clang/test/Sema/bpf-attr-preserve-access-index.c

Index: clang/test/Sema/bpf-attr-preserve-access-index.c
===
--- /dev/null
+++ clang/test/Sema/bpf-attr-preserve-access-index.c
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -x c -triple bpf-pc-linux-gnu -dwarf-version=4 -fsyntax-only -verify %s
+
+#define __reloc__ __attribute__((preserve_access_index))
+#define __err_reloc__ __attribute__((preserve_access_index(0)))
+
+struct t1 {
+  int a;
+  int b[4];
+  int c:1;
+} __reloc__;
+
+union t2 {
+  int a;
+  int b[4];
+  int c:1;
+} __reloc__;
+
+struct t3 {
+  int a;
+} __err_reloc__; // expected-error {{'preserve_access_index' attribute takes no arguments}}
+
+struct t4 {
+  union {
+int a;
+char b[5];
+  };
+  struct {
+int c:1;
+  } __reloc__;
+  int d;
+} __reloc__;
+
+struct __reloc__ p;
+struct __reloc__ q;
+struct p {
+  int a;
+};
+
+int a __reloc__; // expected-error {{'preserve_access_index' attribute only applies to structs, unions, and classes}}
+struct s *p __reloc__; // expected-error {{'preserve_access_index' attribute only applies to structs, unions, and classes}}
+
+void invalid1(const int __reloc__ *arg) {} // expected-error {{'preserve_access_index' attribute only applies to structs, unions, and classes}}
+void invalid2() { const int __reloc__ *arg; } // expected-error {{'preserve_access_index' attribute only applies to structs, unions, and classes}}
+int valid3(struct t4 *arg) { return arg->a + arg->b[3] + arg->c + arg->d; }
+int valid4(void *arg) {
+  struct local_t { int a; int b; } __reloc__;
+  return ((struct local_t *)arg)->b;
+}
Index: clang/test/CodeGen/bpf-attr-preserve-access-index-8.c
===
--- /dev/null
+++ clang/test/CodeGen/bpf-attr-preserve-access-index-8.c
@@ -0,0 +1,36 @@
+// REQUIRES: bpf-registered-target
+// RUN: %clang -target bpf -emit-llvm -S -g %s -o - | FileCheck %s
+
+#define __reloc__ __attribute__((preserve_access_index))
+
+// chain of records, all with attributes
+struct s1;
+struct s2;
+struct s3;
+
+struct s1 {
+  int c;
+} __reloc__;
+typedef struct s1 __s1;
+
+struct s2 {
+  union {
+__s1 b[3];
+  };
+} __reloc__;
+typedef struct s2 __s2;
+
+struct s3 {
+  __s2 a;
+} __reloc__;
+typedef struct s3 __s3;
+
+int test(__s3 *arg) {
+  return arg->a.b[2].c;
+}
+
+// CHECK: call %struct.s2* @llvm.preserve.struct.access.index.p0s_struct.s2s.p0s_struct.s3s(%struct.s3* %{{[0-9a-z]+}}, i32 0, i32 0)
+// CHECK: call %union.anon* @llvm.preserve.struct.access.index.p0s_union.anons.p0s_struct.s2s(%struct.s2* %{{[0-9a-z]+}}, i32 0, i32 0)
+// CHECK: call %union.anon* @llvm.preserve.union.access.index.p0s_union.anons.p0s_union.anons(%union.anon* %{{[0-9a-z]+}}, i32 0)
+// CHECK: call %struct.s1* @llvm.preserve.array.access.index.p0s_struct.s1s.p0a3s_struct.s1s([3 x %struct.s1]* %{{[0-9a-z]+}}, i32 1, i32 2)
+// CHECK: call i32* @llvm.preserve.struct.access.index.p0i32.p0s_struct.s1s(%struct.s1* %{{[0-9a-z]+}}, i32 0, i32 0)
Index: clang/test/CodeGen/bpf-attr-preserve-access-index-7.c
===
--- /dev/null
+++ clang/test/CodeGen/bpf-attr-preserve-access-index-7.c
@@ -0,0 +1,36 @@
+// REQUIRES: bpf-registered-target
+// RUN: %clang -target bpf -emit-llvm -S -g %s -o - | FileCheck %s
+
+#define __reloc__ __attribute__((preserve_access_index))
+
+// chain of records, all with attributes
+struct __reloc__ s1;
+struct __reloc__ s2;
+struct __reloc__ s3;
+
+struct s1 {
+  int c;
+};
+typedef struct s1 __s1;
+
+struct s2 {
+  union {
+__s1 b[3];
+  };
+};
+typedef struct s2 __s2;
+
+struct s3 {
+  __s2 a;
+};
+typedef struct s3 __s3;
+
+int test(__s3 *arg) {
+  return arg->a.b[2].c;
+}
+
+// CHECK: call %struct.s2* @llvm.preserve.struct.access.index.p0s_struct.s2s.p0s_struct.s3s(%struct.s3* %{{[0-9a-z]+}}, i32 0, i32 0)
+// CHECK: call %union.anon* @llvm.preserve.struct.access.index.p0s_union.anons.p0s_struct.s2s(%struct.s2* %{{

[PATCH] D70046: [OpenMP] Use an explicit copy in a range-based for

2019-11-09 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

Why do we get the warnings with references?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70046



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


[PATCH] D70047: [Analyzer] Use a reference in a range-based for

2019-11-09 Thread Mark de Wever via Phabricator via cfe-commits
Mordante created this revision.
Mordante added reviewers: dcoughlin, aaron.ballman, xbolva00.
Mordante added a project: clang.
Herald added subscribers: Charusso, dkrupp, donat.nagy, Szelethus, 
mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun.

Let the checkers use a reference instead of a copy in a range-based for loop.

This avoids new warnings due to D68912  adds 
-Wrange-loop-analysis to -Wall.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70047

Files:
  clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
  clang/lib/StaticAnalyzer/Core/CheckerManager.cpp

Index: clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
+++ clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
@@ -91,7 +91,7 @@
   }
 
   assert(checkers);
-  for (const auto checker : *checkers)
+  for (const auto& checker : *checkers)
 checker(D, mgr, BR);
 }
 
@@ -99,7 +99,7 @@
   BugReporter &BR) {
   assert(D && D->hasBody());
 
-  for (const auto BodyChecker : BodyCheckers)
+  for (const auto& BodyChecker : BodyCheckers)
 BodyChecker(D, mgr, BR);
 }
 
@@ -402,7 +402,7 @@
 void CheckerManager::runCheckersForEndAnalysis(ExplodedGraph &G,
BugReporter &BR,
ExprEngine &Eng) {
-  for (const auto EndAnalysisChecker : EndAnalysisCheckers)
+  for (const auto& EndAnalysisChecker : EndAnalysisCheckers)
 EndAnalysisChecker(G, BR, Eng);
 }
 
@@ -455,7 +455,7 @@
   // creates a successor for Pred, we do not need to generate an
   // autotransition for it.
   NodeBuilder Bldr(Pred, Dst, BC);
-  for (const auto checkFn : EndFunctionCheckers) {
+  for (const auto& checkFn : EndFunctionCheckers) {
 const ProgramPoint &L =
 FunctionExitPoint(RS, Pred->getLocationContext(), checkFn.Checker);
 CheckerContext C(Bldr, Eng, Pred, L);
@@ -542,7 +542,7 @@
 /// Run checkers for live symbols.
 void CheckerManager::runCheckersForLiveSymbols(ProgramStateRef state,
SymbolReaper &SymReaper) {
-  for (const auto LiveSymbolsChecker : LiveSymbolsCheckers)
+  for (const auto& LiveSymbolsChecker : LiveSymbolsCheckers)
 LiveSymbolsChecker(state, SymReaper);
 }
 
@@ -599,7 +599,7 @@
 ArrayRef Regions,
 const LocationContext *LCtx,
 const CallEvent *Call) {
-  for (const auto RegionChangesChecker : RegionChangesCheckers) {
+  for (const auto& RegionChangesChecker : RegionChangesCheckers) {
 // If any checker declares the state infeasible (or if it starts that way),
 // bail out.
 if (!state)
@@ -621,7 +621,7 @@
   (Kind != PSK_DirectEscapeOnCall &&
Kind != PSK_IndirectEscapeOnCall)) &&
  "Call must not be NULL when escaping on call");
-  for (const auto PointerEscapeChecker : PointerEscapeCheckers) {
+  for (const auto& PointerEscapeChecker : PointerEscapeCheckers) {
 // If any checker declares the state infeasible (or if it starts that
 //  way), bail out.
 if (!State)
@@ -635,7 +635,7 @@
 ProgramStateRef
 CheckerManager::runCheckersForEvalAssume(ProgramStateRef state,
  SVal Cond, bool Assumption) {
-  for (const auto EvalAssumeChecker : EvalAssumeCheckers) {
+  for (const auto& EvalAssumeChecker : EvalAssumeCheckers) {
 // If any checker declares the state infeasible (or if it starts that way),
 // bail out.
 if (!state)
@@ -658,7 +658,7 @@
 NodeBuilder B(Pred, checkDst, Eng.getBuilderContext());
 
 // Check if any of the EvalCall callbacks can evaluate the call.
-for (const auto EvalCallChecker : EvalCallCheckers) {
+for (const auto& EvalCallChecker : EvalCallCheckers) {
   // TODO: Support the situation when the call doesn't correspond
   // to any Expr.
   ProgramPoint L = ProgramPoint::getProgramPoint(
@@ -697,7 +697,7 @@
   const TranslationUnitDecl *TU,
   AnalysisManager &mgr,
   BugReporter &BR) {
-  for (const auto EndOfTranslationUnitChecker : EndOfTranslationUnitCheckers)
+  for (const auto& EndOfTranslationUnitChecker : EndOfTranslationUnitCheckers)
 EndOfTranslationUnitChecker(TU, mgr, BR);
 }
 
@@ -904,6 +904,6 @@
 }
 
 CheckerManager::~CheckerManager() {
-  for (const auto CheckerDtor : CheckerDtors)
+  for (const auto& CheckerDtor : CheckerDtors)
 CheckerDtor();
 }
Index: clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
===
--- clang/include/clang/StaticAnalyzer/Core/CheckerManage

[PATCH] D70046: [OpenMP] Use an explicit copy in a range-based for

2019-11-09 Thread Mark de Wever via Phabricator via cfe-commits
Mordante created this revision.
Mordante added reviewers: ABataev, aaron.ballman, xbolva00.
Mordante added a project: clang.
Herald added a subscriber: guansong.
Herald added a reviewer: jdoerfert.

The `std::pair>`
type will be copied in a range-based for loop. Make the copy explicit to
avoid the -Wrange-loop-analysis warning.

This avoids new warnings due to D68912  adds 
-Wrange-loop-analysis to -Wall.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70046

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp


Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -7940,17 +7940,17 @@
"Expect a executable directive");
 const auto *CurExecDir = CurDir.get();
 for (const auto *C : CurExecDir->getClausesOfKind())
-  for (const auto &L : C->component_lists()) {
+  for (const auto L : C->component_lists()) {
 InfoGen(L.first, L.second, C->getMapType(), C->getMapTypeModifiers(),
 /*ReturnDevicePointer=*/false, C->isImplicit());
   }
 for (const auto *C : CurExecDir->getClausesOfKind())
-  for (const auto &L : C->component_lists()) {
+  for (const auto L : C->component_lists()) {
 InfoGen(L.first, L.second, OMPC_MAP_to, llvm::None,
 /*ReturnDevicePointer=*/false, C->isImplicit());
   }
 for (const auto *C : CurExecDir->getClausesOfKind())
-  for (const auto &L : C->component_lists()) {
+  for (const auto L : C->component_lists()) {
 InfoGen(L.first, L.second, OMPC_MAP_from, llvm::None,
 /*ReturnDevicePointer=*/false, C->isImplicit());
   }
@@ -7966,7 +7966,7 @@
 
 for (const auto *C :
  CurExecDir->getClausesOfKind()) {
-  for (const auto &L : C->component_lists()) {
+  for (const auto L : C->component_lists()) {
 assert(!L.second.empty() && "Not expecting empty list of components!");
 const ValueDecl *VD = L.second.back().getAssociatedDeclaration();
 VD = cast(VD->getCanonicalDecl());
@@ -8119,7 +8119,7 @@
 
 for (const auto *C : CurMapperDir->clauselists()) {
   const auto *MC = cast(C);
-  for (const auto &L : MC->component_lists()) {
+  for (const auto L : MC->component_lists()) {
 InfoGen(L.first, L.second, MC->getMapType(), MC->getMapTypeModifiers(),
 /*ReturnDevicePointer=*/false, MC->isImplicit());
   }
@@ -8288,7 +8288,7 @@
"Expect a executable directive");
 const auto *CurExecDir = CurDir.get();
 for (const auto *C : CurExecDir->getClausesOfKind()) {
-  for (const auto &L : C->decl_component_lists(VD)) {
+  for (const auto L : C->decl_component_lists(VD)) {
 assert(L.first == VD &&
"We got information for the wrong declaration??");
 assert(!L.second.empty() &&
@@ -8441,7 +8441,7 @@
 // Map other list items in the map clause which are not captured variables
 // but "declare target link" global variables.
 for (const auto *C : CurExecDir->getClausesOfKind()) {
-  for (const auto &L : C->component_lists()) {
+  for (const auto L : C->component_lists()) {
 if (!L.first)
   continue;
 const auto *VD = dyn_cast(L.first);


Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -7940,17 +7940,17 @@
"Expect a executable directive");
 const auto *CurExecDir = CurDir.get();
 for (const auto *C : CurExecDir->getClausesOfKind())
-  for (const auto &L : C->component_lists()) {
+  for (const auto L : C->component_lists()) {
 InfoGen(L.first, L.second, C->getMapType(), C->getMapTypeModifiers(),
 /*ReturnDevicePointer=*/false, C->isImplicit());
   }
 for (const auto *C : CurExecDir->getClausesOfKind())
-  for (const auto &L : C->component_lists()) {
+  for (const auto L : C->component_lists()) {
 InfoGen(L.first, L.second, OMPC_MAP_to, llvm::None,
 /*ReturnDevicePointer=*/false, C->isImplicit());
   }
 for (const auto *C : CurExecDir->getClausesOfKind())
-  for (const auto &L : C->component_lists()) {
+  for (const auto L : C->component_lists()) {
 InfoGen(L.first, L.second, OMPC_MAP_from, llvm::None,
 /*ReturnDevicePointer=*/false, C->isImplicit());
   }
@@ -7966,7 +7966,7 @@
 
 for (const auto *C :
  CurExecDir->getClausesOfKind()) {
-  for (const auto &L : C->component_lists()) {
+  for (const auto L : C->component_lists()) {
 assert(!L.second.empty() && "Not expecting empty list of components!");
 const ValueDecl *VD = L.second.back().getAssociatedDeclaration();
 VD = cast(VD->getCanonicalDecl());
@@ -8119,7

[PATCH] D70045: [AST] Use an explicit copy in a range-based for

2019-11-09 Thread Mark de Wever via Phabricator via cfe-commits
Mordante created this revision.
Mordante added reviewers: rsmith, aaron.ballman, xbolva00.
Mordante added a project: clang.

The AssociationIteratorTy type will be copied in a range-based for loop.
Make the copy explicit to avoid the -Wrange-loop-analysis warning.

This avoids new warnings due to D68912  adds 
-Wrange-loop-analysis to -Wall.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70045

Files:
  clang/include/clang/AST/ASTNodeTraverser.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/StmtDataCollectors.td
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/Sema/SemaExprObjC.cpp
  clang/lib/Sema/SemaPseudoObject.cpp
  clang/lib/Sema/TreeTransform.h

Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -9380,7 +9380,7 @@
 
   SmallVector AssocExprs;
   SmallVector AssocTypes;
-  for (const GenericSelectionExpr::Association &Assoc : E->associations()) {
+  for (const GenericSelectionExpr::Association Assoc : E->associations()) {
 TypeSourceInfo *TSI = Assoc.getTypeSourceInfo();
 if (TSI) {
   TypeSourceInfo *AssocType = getDerived().TransformType(TSI);
Index: clang/lib/Sema/SemaPseudoObject.cpp
===
--- clang/lib/Sema/SemaPseudoObject.cpp
+++ clang/lib/Sema/SemaPseudoObject.cpp
@@ -145,7 +145,7 @@
 assocExprs.reserve(numAssocs);
 assocTypes.reserve(numAssocs);
 
-for (const GenericSelectionExpr::Association &assoc :
+for (const GenericSelectionExpr::Association assoc :
  gse->associations()) {
   Expr *assocExpr = assoc.getAssociationExpr();
   if (assoc.isSelected())
Index: clang/lib/Sema/SemaExprObjC.cpp
===
--- clang/lib/Sema/SemaExprObjC.cpp
+++ clang/lib/Sema/SemaExprObjC.cpp
@@ -4358,7 +4358,7 @@
 SmallVector subTypes;
 subExprs.reserve(n);
 subTypes.reserve(n);
-for (const GenericSelectionExpr::Association &assoc : gse->associations()) {
+for (const GenericSelectionExpr::Association assoc : gse->associations()) {
   subTypes.push_back(assoc.getTypeSourceInfo());
   Expr *sub = assoc.getAssociationExpr();
   if (assoc.isSelected())
Index: clang/lib/AST/StmtProfile.cpp
===
--- clang/lib/AST/StmtProfile.cpp
+++ clang/lib/AST/StmtProfile.cpp
@@ -1296,7 +1296,7 @@
 
 void StmtProfiler::VisitGenericSelectionExpr(const GenericSelectionExpr *S) {
   VisitExpr(S);
-  for (const GenericSelectionExpr::ConstAssociation &Assoc :
+  for (const GenericSelectionExpr::ConstAssociation Assoc :
S->associations()) {
 QualType T = Assoc.getType();
 if (T.isNull())
Index: clang/lib/AST/StmtPrinter.cpp
===
--- clang/lib/AST/StmtPrinter.cpp
+++ clang/lib/AST/StmtPrinter.cpp
@@ -1304,7 +1304,7 @@
 void StmtPrinter::VisitGenericSelectionExpr(GenericSelectionExpr *Node) {
   OS << "_Generic(";
   PrintExpr(Node->getControllingExpr());
-  for (const GenericSelectionExpr::Association &Assoc : Node->associations()) {
+  for (const GenericSelectionExpr::Association Assoc : Node->associations()) {
 OS << ", ";
 QualType T = Assoc.getType();
 if (T.isNull())
Index: clang/include/clang/AST/StmtDataCollectors.td
===
--- clang/include/clang/AST/StmtDataCollectors.td
+++ clang/include/clang/AST/StmtDataCollectors.td
@@ -189,7 +189,7 @@
 }
 class GenericSelectionExpr {
   code Code = [{
-for (const GenericSelectionExpr::ConstAssociation &Assoc : S->associations()) {
+for (const GenericSelectionExpr::ConstAssociation Assoc : S->associations()) {
   addData(Assoc.getType());
 }
   }];
Index: clang/include/clang/AST/RecursiveASTVisitor.h
===
--- clang/include/clang/AST/RecursiveASTVisitor.h
+++ clang/include/clang/AST/RecursiveASTVisitor.h
@@ -2351,7 +2351,7 @@
 // generic associations).
 DEF_TRAVERSE_STMT(GenericSelectionExpr, {
   TRY_TO(TraverseStmt(S->getControllingExpr()));
-  for (const GenericSelectionExpr::Association &Assoc : S->associations()) {
+  for (const GenericSelectionExpr::Association Assoc : S->associations()) {
 if (TypeSourceInfo *TSI = Assoc.getTypeSourceInfo())
   TRY_TO(TraverseTypeLoc(TSI->getTypeLoc()));
 TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(Assoc.getAssociationExpr());
Index: clang/include/clang/AST/ASTNodeTraverser.h
===
--- clang/include/clang/AST/ASTNodeTraverser.h
+++ clang/include/clang/AST/ASTNodeTraverser.h
@@ -620,7 +620,7 @@
 Visit(E->getControllingExpr());
 Visit(E->getContr

[PATCH] D68912: Adds -Wrange-loop-analysis to -Wall

2019-11-09 Thread Mark de Wever via Phabricator via cfe-commits
Mordante added a comment.

In D68912#1737559 , @xbolva00 wrote:

> Formally unblocking this


Thanks. I'll first want to reduce the number of warnings before committing this 
patch.


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

https://reviews.llvm.org/D68912



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


[PATCH] D69762: [Diagnostics] Try to improve warning message for -Wreturn-type

2019-11-09 Thread Dávid Bolvanský via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1da13237a41a: [Diagnostics] Try to improve warning message 
for -Wreturn-type (authored by xbolva00).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69762

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/test/Analysis/const-method-call.cpp
  clang/test/Analysis/structured_bindings.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p7.cpp
  clang/test/Driver/cc-log-diagnostics.c
  clang/test/Frontend/absolute-paths.c
  clang/test/Index/warning-flags.c
  clang/test/Misc/serialized-diags-stable.c
  clang/test/Modules/redecl-merge.m
  clang/test/PCH/late-parsed-instantiations.cpp
  clang/test/Sema/block-return-1.c
  clang/test/Sema/block-return-3.c
  clang/test/Sema/freemain.c
  clang/test/Sema/return.c
  clang/test/SemaCXX/attr-noreturn.cpp
  clang/test/SemaCXX/coreturn.cpp
  clang/test/SemaCXX/return-noreturn.cpp
  clang/test/SemaCXX/warn-missing-noreturn.cpp
  clang/test/SemaTemplate/late-parsing-eager-instantiation.cpp

Index: clang/test/SemaTemplate/late-parsing-eager-instantiation.cpp
===
--- clang/test/SemaTemplate/late-parsing-eager-instantiation.cpp
+++ clang/test/SemaTemplate/late-parsing-eager-instantiation.cpp
@@ -15,8 +15,8 @@
   char data() {
 visit([](auto buffer) -> char { // expected-note {{in instantiation}}
   buffer->data();
-}); // expected-warning {{control reaches end of non-void lambda}}
-  } // expected-warning {{control reaches end of non-void function}}
+}); // expected-warning {{non-void lambda does not return a value}}
+  } // expected-warning {{non-void function does not return a value}}
 };
 
 // pr34185
Index: clang/test/SemaCXX/warn-missing-noreturn.cpp
===
--- clang/test/SemaCXX/warn-missing-noreturn.cpp
+++ clang/test/SemaCXX/warn-missing-noreturn.cpp
@@ -91,7 +91,7 @@
 
 int rdar8875247_test() {
   rdar8875247 f;
-} // expected-warning{{control reaches end of non-void function}}
+} // expected-warning{{non-void function does not return a value}}
 
 struct rdar8875247_B {
   rdar8875247_B();
Index: clang/test/SemaCXX/return-noreturn.cpp
===
--- clang/test/SemaCXX/return-noreturn.cpp
+++ clang/test/SemaCXX/return-noreturn.cpp
@@ -26,7 +26,7 @@
   }
   int f2_positive(int x) {
 switch (x) { default: ; }
-  } // expected-warning {{control reaches end of non-void function}}
+  } // expected-warning {{non-void function does not return a value}}
   int f3(int x) {
 switch (x) { default: { pr6884_abort_struct(); } }
   }
@@ -46,7 +46,7 @@
   pr6884_abort_struct *p = new pr6884_abort_struct();
   delete p;
 }
-  } // expected-warning {{control reaches end of non-void function}}
+  } // expected-warning {{non-void function does not return a value}}
 
   // Test that these constructs work even when extraneous blocks are created
   // before and after the switch due to implicit destructors.
@@ -61,7 +61,7 @@
   int g2_positive(int x) {
 other o;
 switch (x) { default: ; }
-  } // expected-warning {{control reaches end of non-void function}}
+  } // expected-warning {{non-void function does not return a value}}
   int g3(int x) {
 other o;
 switch (x) { default: { pr6884_abort_struct(); } }
@@ -140,7 +140,7 @@
 default:
 break;
   }
-} // expected-warning {{control reaches end of non-void function}}
+} // expected-warning {{non-void function does not return a value}}
 
 void PR9412_f() {
 PR9412_t(); // expected-note {{in instantiation of function template specialization 'PR9412_t' requested here}}
@@ -165,7 +165,7 @@
 
 int testTernaryStaticallyConditionalRetrunOnTrue() {
   true ? Return() : NoReturn();
-} // expected-warning {{control reaches end of non-void function}}
+} // expected-warning {{non-void function does not return a value}}
 
 int testTernaryStaticallyConditionalNoretrunOnFalse() {
   false ? Return() : NoReturn();
@@ -173,23 +173,23 @@
 
 int testTernaryStaticallyConditionalRetrunOnFalse() {
   false ? NoReturn() : Return();
-} // expected-warning {{control reaches end of non-void function}}
+} // expected-warning {{non-void function does not return a value}}
 
 int testTernaryConditionalNoreturnTrueBranch(bool value) {
   value ? (NoReturn() || NoReturn()) : Return();
-} // expected-warning {{control may reach end of non-void function}}
+} // expected-warning {{non-void function does not return a value in all control paths}}
 
 int testTernaryConditionalNoreturnFalseBranch(bool value) {
   value ? Return() : (NoReturn() || NoReturn());
-} // expected-warning {{control may reach end of non-void function}}
+} // expected-warning {{non-void function does not return a v

[PATCH] D69762: [Diagnostics] Try to improve warning message for -Wreturn-type

2019-11-09 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 updated this revision to Diff 228578.
xbolva00 added a comment.
Herald added a subscriber: arphaman.

Added FIXME.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69762

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/test/Analysis/const-method-call.cpp
  clang/test/Analysis/structured_bindings.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p7.cpp
  clang/test/Driver/cc-log-diagnostics.c
  clang/test/Frontend/absolute-paths.c
  clang/test/Index/warning-flags.c
  clang/test/Misc/serialized-diags-stable.c
  clang/test/Modules/redecl-merge.m
  clang/test/PCH/late-parsed-instantiations.cpp
  clang/test/Sema/block-return-1.c
  clang/test/Sema/block-return-3.c
  clang/test/Sema/freemain.c
  clang/test/Sema/return.c
  clang/test/SemaCXX/attr-noreturn.cpp
  clang/test/SemaCXX/coreturn.cpp
  clang/test/SemaCXX/return-noreturn.cpp
  clang/test/SemaCXX/warn-missing-noreturn.cpp
  clang/test/SemaTemplate/late-parsing-eager-instantiation.cpp

Index: clang/test/SemaTemplate/late-parsing-eager-instantiation.cpp
===
--- clang/test/SemaTemplate/late-parsing-eager-instantiation.cpp
+++ clang/test/SemaTemplate/late-parsing-eager-instantiation.cpp
@@ -15,8 +15,8 @@
   char data() {
 visit([](auto buffer) -> char { // expected-note {{in instantiation}}
   buffer->data();
-}); // expected-warning {{control reaches end of non-void lambda}}
-  } // expected-warning {{control reaches end of non-void function}}
+}); // expected-warning {{non-void lambda does not return a value}}
+  } // expected-warning {{non-void function does not return a value}}
 };
 
 // pr34185
Index: clang/test/SemaCXX/warn-missing-noreturn.cpp
===
--- clang/test/SemaCXX/warn-missing-noreturn.cpp
+++ clang/test/SemaCXX/warn-missing-noreturn.cpp
@@ -91,7 +91,7 @@
 
 int rdar8875247_test() {
   rdar8875247 f;
-} // expected-warning{{control reaches end of non-void function}}
+} // expected-warning{{non-void function does not return a value}}
 
 struct rdar8875247_B {
   rdar8875247_B();
Index: clang/test/SemaCXX/return-noreturn.cpp
===
--- clang/test/SemaCXX/return-noreturn.cpp
+++ clang/test/SemaCXX/return-noreturn.cpp
@@ -26,7 +26,7 @@
   }
   int f2_positive(int x) {
 switch (x) { default: ; }
-  } // expected-warning {{control reaches end of non-void function}}
+  } // expected-warning {{non-void function does not return a value}}
   int f3(int x) {
 switch (x) { default: { pr6884_abort_struct(); } }
   }
@@ -46,7 +46,7 @@
   pr6884_abort_struct *p = new pr6884_abort_struct();
   delete p;
 }
-  } // expected-warning {{control reaches end of non-void function}}
+  } // expected-warning {{non-void function does not return a value}}
 
   // Test that these constructs work even when extraneous blocks are created
   // before and after the switch due to implicit destructors.
@@ -61,7 +61,7 @@
   int g2_positive(int x) {
 other o;
 switch (x) { default: ; }
-  } // expected-warning {{control reaches end of non-void function}}
+  } // expected-warning {{non-void function does not return a value}}
   int g3(int x) {
 other o;
 switch (x) { default: { pr6884_abort_struct(); } }
@@ -140,7 +140,7 @@
 default:
 break;
   }
-} // expected-warning {{control reaches end of non-void function}}
+} // expected-warning {{non-void function does not return a value}}
 
 void PR9412_f() {
 PR9412_t(); // expected-note {{in instantiation of function template specialization 'PR9412_t' requested here}}
@@ -165,7 +165,7 @@
 
 int testTernaryStaticallyConditionalRetrunOnTrue() {
   true ? Return() : NoReturn();
-} // expected-warning {{control reaches end of non-void function}}
+} // expected-warning {{non-void function does not return a value}}
 
 int testTernaryStaticallyConditionalNoretrunOnFalse() {
   false ? Return() : NoReturn();
@@ -173,23 +173,23 @@
 
 int testTernaryStaticallyConditionalRetrunOnFalse() {
   false ? NoReturn() : Return();
-} // expected-warning {{control reaches end of non-void function}}
+} // expected-warning {{non-void function does not return a value}}
 
 int testTernaryConditionalNoreturnTrueBranch(bool value) {
   value ? (NoReturn() || NoReturn()) : Return();
-} // expected-warning {{control may reach end of non-void function}}
+} // expected-warning {{non-void function does not return a value in all control paths}}
 
 int testTernaryConditionalNoreturnFalseBranch(bool value) {
   value ? Return() : (NoReturn() || NoReturn());
-} // expected-warning {{control may reach end of non-void function}}
+} // expected-warning {{non-void function does not return a value in all control paths}}
 
 int testConditionallyExecutedComplexTer

[PATCH] D69935: [DeclCXX] Remove unknown external linkage specifications

2019-11-09 Thread Ehud Katz via Phabricator via cfe-commits
ekatz added a comment.

No problem.
For the source code:

  extern "C++11" int x;

In clang 9.0 the compilation fails with the message:

  :1:8: error: unknown linkage language
  extern "C++11" int x;
 ^~~
  1 error generated.

while on the trunk it just pass without any error.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69935



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


[PATCH] D69759: [BPF] Add preserve_access_index attribute for record definition

2019-11-09 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song added a comment.

Thanks, @aaron.ballman, I will fix the issue and address all you comments. I 
will re-open this commit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69759



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


[PATCH] D69759: [BPF] Add preserve_access_index attribute for record definition

2019-11-09 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

This is missing a bunch of C++ tests that show what happens in the case of 
inheritance, template instantiations, etc.




Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:10068
   "__builtin_preserve_field_info argument %0 not a constant">;
+def err_preserve_access_index_wrong_type: Error<"%0 attribute only applies to 
%1">;
 

This is unnecessary.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:5706
+  // Add preserve_access_index attribute to all fields and inner records.
+  for (DeclContext::decl_iterator D = RD->decls_begin(), DEnd = 
RD->decls_end();
+   D != DEnd; ++D) {

Any reason not to use a range-based for?



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:5712
+
+RecordDecl *Rec = dyn_cast(*D);
+if (Rec) {

Can use `auto` here



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:5713-5718
+if (Rec) {
+  Rec->addAttr(::new (S.Context) BPFPreserveAccessIndexAttr(S.Context, 
AL));
+  handleBPFPreserveAIRecord(S, Rec, AL);
+} else {
+  D->addAttr(::new (S.Context) BPFPreserveAccessIndexAttr(S.Context, AL));
+}

These should be implicit attributes, not explicit ones, right?



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:5725
+  // Add preserve_access_index attribute to all fields and inner records.
+  for (DeclContext::decl_iterator D = RD->decls_begin(), DEnd = 
RD->decls_end();
+   D != DEnd; ++D) {

Similar here.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:5727
+   D != DEnd; ++D) {
+RecordDecl *Rec = dyn_cast(*D);
+if (Rec) {

Can use `auto` here as well.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:5730-5736
+  if (!Rec->hasAttr()) {
+Rec->addAttr(::new (S.Context) BPFPreserveAccessIndexAttr(S.Context, 
AL));
+handleBPFPreserveAIRecord(S, Rec, AL);
+  }
+} else {
+  D->addAttr(::new (S.Context) BPFPreserveAccessIndexAttr(S.Context, AL));
+}

Implicit attributes?



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:5742-5747
+  RecordDecl *Rec = dyn_cast(D);
+  if (!Rec) {
+S.Diag(D->getLocation(), diag::err_preserve_access_index_wrong_type)
+<< "preserve_addess_index" << "struct or union type";
+return;
+  }

This should be handled in Attr.td with an explicit subject.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:5749
+
+  if (!checkAttributeNumArgs(S, AL, 0))
+return;

This is not needed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69759



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


Re: [clang] 9434360 - Revert "[BPF] Add preserve_access_index attribute for record definition"

2019-11-09 Thread Aaron Ballman via cfe-commits
On Sat, Nov 9, 2019 at 11:33 AM Yonghong Song via cfe-commits
 wrote:
>
>
> Author: Yonghong Song
> Date: 2019-11-09T08:32:44-08:00
> New Revision: 9434360401218ae02aaea1fbb53a42bc3af2bc76
>
> URL: 
> https://github.com/llvm/llvm-project/commit/9434360401218ae02aaea1fbb53a42bc3af2bc76
> DIFF: 
> https://github.com/llvm/llvm-project/commit/9434360401218ae02aaea1fbb53a42bc3af2bc76.diff
>
> LOG: Revert "[BPF] Add preserve_access_index attribute for record definition"
>
> This reverts commit 4a5aa1a7bf8b1714b817ede8e09cd28c0784228a.
>
> There are some other test failures. Investigate them first.

I also pointed out several other issues with the patch on the review
thread; sorry for not responding sooner (I've been at standards
meetings all week, so this landed before I could comment).

~Aaron

>
> Added:
>
>
> Modified:
> clang/include/clang/Basic/Attr.td
> clang/include/clang/Basic/AttrDocs.td
> clang/include/clang/Basic/DiagnosticSemaKinds.td
> clang/lib/CodeGen/CGExpr.cpp
> clang/lib/Sema/SemaDeclAttr.cpp
>
> Removed:
> clang/test/CodeGen/bpf-attr-preserve-access-index-1.c
> clang/test/CodeGen/bpf-attr-preserve-access-index-2.c
> clang/test/CodeGen/bpf-attr-preserve-access-index-3.c
> clang/test/CodeGen/bpf-attr-preserve-access-index-4.c
> clang/test/CodeGen/bpf-attr-preserve-access-index-5.c
> clang/test/CodeGen/bpf-attr-preserve-access-index-6.c
> clang/test/CodeGen/bpf-attr-preserve-access-index-7.c
> clang/test/CodeGen/bpf-attr-preserve-access-index-8.c
> clang/test/Sema/bpf-attr-preserve-access-index.c
>
>
> 
> diff  --git a/clang/include/clang/Basic/Attr.td 
> b/clang/include/clang/Basic/Attr.td
> index aef02b5a8e96..0d25e775e2af 100644
> --- a/clang/include/clang/Basic/Attr.td
> +++ b/clang/include/clang/Basic/Attr.td
> @@ -332,7 +332,6 @@ class TargetArch arches> : TargetSpec {
>  }
>  def TargetARM : TargetArch<["arm", "thumb", "armeb", "thumbeb"]>;
>  def TargetAVR : TargetArch<["avr"]>;
> -def TargetBPF : TargetArch<["bpfel", "bpfeb"]>;
>  def TargetMips32 : TargetArch<["mips", "mipsel"]>;
>  def TargetAnyMips : TargetArch<["mips", "mipsel", "mips64", "mips64el"]>;
>  def TargetMSP430 : TargetArch<["msp430"]>;
> @@ -1579,12 +1578,6 @@ def AMDGPUNumVGPR : InheritableAttr {
>let Subjects = SubjectList<[Function], ErrorDiag, "kernel functions">;
>  }
>
> -def BPFPreserveAccessIndex : InheritableAttr,
> - TargetSpecificAttr  {
> -  let Spellings = [Clang<"preserve_access_index">];
> -  let Documentation = [BPFPreserveAccessIndexDocs];
> -}
> -
>  def WebAssemblyImportModule : InheritableAttr,
>TargetSpecificAttr {
>let Spellings = [Clang<"import_module">];
>
> diff  --git a/clang/include/clang/Basic/AttrDocs.td 
> b/clang/include/clang/Basic/AttrDocs.td
> index 50e76bf080b4..3a9093124637 100644
> --- a/clang/include/clang/Basic/AttrDocs.td
> +++ b/clang/include/clang/Basic/AttrDocs.td
> @@ -1634,17 +1634,6 @@ The semantics are as follows:
>}];
>  }
>
> -def BPFPreserveAccessIndexDocs : Documentation {
> -  let Category = DocCatFunction;
> -  let Content = [{
> -Clang supports the ``__attribute__((preserve_access_index))``
> -attribute for the BPF target. This attribute may be attached to a
> -struct or union declaration, where if -g is specified, it enables
> -preserving struct or union member access debuginfo indicies of this
> -struct or union, similar to clang ``__builtin_preserve_acceess_index()``.
> -  }];
> -}
> -
>  def MipsInterruptDocs : Documentation {
>let Category = DocCatFunction;
>let Heading = "interrupt (MIPS)";
>
> diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
> b/clang/include/clang/Basic/DiagnosticSemaKinds.td
> index 33a0f9710856..88d73dc89b55 100644
> --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
> +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
> @@ -10065,7 +10065,6 @@ def err_preserve_field_info_not_field : Error<
>"__builtin_preserve_field_info argument %0 not a field access">;
>  def err_preserve_field_info_not_const: Error<
>"__builtin_preserve_field_info argument %0 not a constant">;
> -def err_preserve_access_index_wrong_type: Error<"%0 attribute only applies 
> to %1">;
>
>  def err_bit_cast_non_trivially_copyable : Error<
>"__builtin_bit_cast %select{source|destination}0 type must be trivially 
> copyable">;
>
> diff  --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
> index e32db8c56df9..99406715cbf8 100644
> --- a/clang/lib/CodeGen/CGExpr.cpp
> +++ b/clang/lib/CodeGen/CGExpr.cpp
> @@ -3402,67 +3402,11 @@ static QualType getFixedSizeElementType(const 
> ASTContext &ctx,
>return eltType;
>  }
>
> -/// Given an array base, check whether its member access belongs to a record
> -/// with preserve_access_index attribute or not.
> -static bool IsPreserveAIArrayBase(CodeGenFunction &CGF, const Exp

[clang] 9434360 - Revert "[BPF] Add preserve_access_index attribute for record definition"

2019-11-09 Thread Yonghong Song via cfe-commits

Author: Yonghong Song
Date: 2019-11-09T08:32:44-08:00
New Revision: 9434360401218ae02aaea1fbb53a42bc3af2bc76

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

LOG: Revert "[BPF] Add preserve_access_index attribute for record definition"

This reverts commit 4a5aa1a7bf8b1714b817ede8e09cd28c0784228a.

There are some other test failures. Investigate them first.

Added: 


Modified: 
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/AttrDocs.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/CodeGen/CGExpr.cpp
clang/lib/Sema/SemaDeclAttr.cpp

Removed: 
clang/test/CodeGen/bpf-attr-preserve-access-index-1.c
clang/test/CodeGen/bpf-attr-preserve-access-index-2.c
clang/test/CodeGen/bpf-attr-preserve-access-index-3.c
clang/test/CodeGen/bpf-attr-preserve-access-index-4.c
clang/test/CodeGen/bpf-attr-preserve-access-index-5.c
clang/test/CodeGen/bpf-attr-preserve-access-index-6.c
clang/test/CodeGen/bpf-attr-preserve-access-index-7.c
clang/test/CodeGen/bpf-attr-preserve-access-index-8.c
clang/test/Sema/bpf-attr-preserve-access-index.c



diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index aef02b5a8e96..0d25e775e2af 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -332,7 +332,6 @@ class TargetArch arches> : TargetSpec {
 }
 def TargetARM : TargetArch<["arm", "thumb", "armeb", "thumbeb"]>;
 def TargetAVR : TargetArch<["avr"]>;
-def TargetBPF : TargetArch<["bpfel", "bpfeb"]>;
 def TargetMips32 : TargetArch<["mips", "mipsel"]>;
 def TargetAnyMips : TargetArch<["mips", "mipsel", "mips64", "mips64el"]>;
 def TargetMSP430 : TargetArch<["msp430"]>;
@@ -1579,12 +1578,6 @@ def AMDGPUNumVGPR : InheritableAttr {
   let Subjects = SubjectList<[Function], ErrorDiag, "kernel functions">;
 }
 
-def BPFPreserveAccessIndex : InheritableAttr,
- TargetSpecificAttr  {
-  let Spellings = [Clang<"preserve_access_index">];
-  let Documentation = [BPFPreserveAccessIndexDocs];
-}
-
 def WebAssemblyImportModule : InheritableAttr,
   TargetSpecificAttr {
   let Spellings = [Clang<"import_module">];

diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 50e76bf080b4..3a9093124637 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -1634,17 +1634,6 @@ The semantics are as follows:
   }];
 }
 
-def BPFPreserveAccessIndexDocs : Documentation {
-  let Category = DocCatFunction;
-  let Content = [{
-Clang supports the ``__attribute__((preserve_access_index))``
-attribute for the BPF target. This attribute may be attached to a
-struct or union declaration, where if -g is specified, it enables
-preserving struct or union member access debuginfo indicies of this
-struct or union, similar to clang ``__builtin_preserve_acceess_index()``.
-  }];
-}
-
 def MipsInterruptDocs : Documentation {
   let Category = DocCatFunction;
   let Heading = "interrupt (MIPS)";

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 33a0f9710856..88d73dc89b55 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -10065,7 +10065,6 @@ def err_preserve_field_info_not_field : Error<
   "__builtin_preserve_field_info argument %0 not a field access">;
 def err_preserve_field_info_not_const: Error<
   "__builtin_preserve_field_info argument %0 not a constant">;
-def err_preserve_access_index_wrong_type: Error<"%0 attribute only applies to 
%1">;
 
 def err_bit_cast_non_trivially_copyable : Error<
   "__builtin_bit_cast %select{source|destination}0 type must be trivially 
copyable">;

diff  --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index e32db8c56df9..99406715cbf8 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -3402,67 +3402,11 @@ static QualType getFixedSizeElementType(const 
ASTContext &ctx,
   return eltType;
 }
 
-/// Given an array base, check whether its member access belongs to a record
-/// with preserve_access_index attribute or not.
-static bool IsPreserveAIArrayBase(CodeGenFunction &CGF, const Expr *ArrayBase) 
{
-  if (!ArrayBase || !CGF.getDebugInfo())
-return false;
-
-  const auto *ImplicitCast = dyn_cast(ArrayBase);
-  if (!ImplicitCast)
-return false;
-
-  // Only support base as either a MemberExpr or DeclRefExpr.
-  // DeclRefExpr to cover cases like:
-  //struct s { int a; int b[10]; };
-  //struct s *p;
-  //p[1].a
-  // p[1] will generate a DeclRefExpr and p[1].a is a MemberExpr.
-  // p->b[5] is a MemberExpr example.
-  const Expr *E = I

[PATCH] D69759: [BPF] Add preserve_access_index attribute for record definition

2019-11-09 Thread Yonghong Song via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4a5aa1a7bf8b: [BPF] Add preserve_access_index attribute for 
record definition (authored by yonghong-song).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69759

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/bpf-attr-preserve-access-index-1.c
  clang/test/CodeGen/bpf-attr-preserve-access-index-2.c
  clang/test/CodeGen/bpf-attr-preserve-access-index-3.c
  clang/test/CodeGen/bpf-attr-preserve-access-index-4.c
  clang/test/CodeGen/bpf-attr-preserve-access-index-5.c
  clang/test/CodeGen/bpf-attr-preserve-access-index-6.c
  clang/test/CodeGen/bpf-attr-preserve-access-index-7.c
  clang/test/CodeGen/bpf-attr-preserve-access-index-8.c
  clang/test/Sema/bpf-attr-preserve-access-index.c

Index: clang/test/Sema/bpf-attr-preserve-access-index.c
===
--- /dev/null
+++ clang/test/Sema/bpf-attr-preserve-access-index.c
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -x c -triple bpf-pc-linux-gnu -dwarf-version=4 -fsyntax-only -verify %s
+
+#define __reloc__ __attribute__((preserve_access_index))
+#define __err_reloc__ __attribute__((preserve_access_index(0)))
+
+struct t1 {
+  int a;
+  int b[4];
+  int c:1;
+} __reloc__;
+
+union t2 {
+  int a;
+  int b[4];
+  int c:1;
+} __reloc__;
+
+struct t3 {
+  int a;
+} __err_reloc__; // expected-error {{'preserve_access_index' attribute takes no arguments}}
+
+struct t4 {
+  union {
+int a;
+char b[5];
+  };
+  struct {
+int c:1;
+  } __reloc__;
+  int d;
+} __reloc__;
+
+struct __reloc__ p;
+struct __reloc__ q;
+struct p {
+  int a;
+};
+
+int a __reloc__; // expected-error {{preserve_addess_index attribute only applies to struct or union type}}
+struct s *p __reloc__; // expected-error {{preserve_addess_index attribute only applies to struct or union type}}
+
+void invalid1(const int __reloc__ *arg) {} // expected-error {{preserve_addess_index attribute only applies to struct or union type}}
+void invalid2() { const int __reloc__ *arg; } // expected-error {{preserve_addess_index attribute only applies to struct or union type}}
+int valid3(struct t4 *arg) { return arg->a + arg->b[3] + arg->c + arg->d; }
+int valid4(void *arg) {
+  struct local_t { int a; int b; } __reloc__;
+  return ((struct local_t *)arg)->b;
+}
Index: clang/test/CodeGen/bpf-attr-preserve-access-index-8.c
===
--- /dev/null
+++ clang/test/CodeGen/bpf-attr-preserve-access-index-8.c
@@ -0,0 +1,36 @@
+// REQUIRES: bpf-registered-target
+// RUN: %clang -target bpf -emit-llvm -S -g %s -o - | FileCheck %s
+
+#define __reloc__ __attribute__((preserve_access_index))
+
+// chain of records, all with attributes
+struct s1;
+struct s2;
+struct s3;
+
+struct s1 {
+  int c;
+} __reloc__;
+typedef struct s1 __s1;
+
+struct s2 {
+  union {
+__s1 b[3];
+  };
+} __reloc__;
+typedef struct s2 __s2;
+
+struct s3 {
+  __s2 a;
+} __reloc__;
+typedef struct s3 __s3;
+
+int test(__s3 *arg) {
+  return arg->a.b[2].c;
+}
+
+// CHECK: call %struct.s2* @llvm.preserve.struct.access.index.p0s_struct.s2s.p0s_struct.s3s(%struct.s3* %{{[0-9a-z]+}}, i32 0, i32 0)
+// CHECK: call %union.anon* @llvm.preserve.struct.access.index.p0s_union.anons.p0s_struct.s2s(%struct.s2* %{{[0-9a-z]+}}, i32 0, i32 0)
+// CHECK: call %union.anon* @llvm.preserve.union.access.index.p0s_union.anons.p0s_union.anons(%union.anon* %{{[0-9a-z]+}}, i32 0)
+// CHECK: call %struct.s1* @llvm.preserve.array.access.index.p0s_struct.s1s.p0a3s_struct.s1s([3 x %struct.s1]* %{{[0-9a-z]+}}, i32 1, i32 2)
+// CHECK: call i32* @llvm.preserve.struct.access.index.p0i32.p0s_struct.s1s(%struct.s1* %{{[0-9a-z]+}}, i32 0, i32 0)
Index: clang/test/CodeGen/bpf-attr-preserve-access-index-7.c
===
--- /dev/null
+++ clang/test/CodeGen/bpf-attr-preserve-access-index-7.c
@@ -0,0 +1,36 @@
+// REQUIRES: bpf-registered-target
+// RUN: %clang -target bpf -emit-llvm -S -g %s -o - | FileCheck %s
+
+#define __reloc__ __attribute__((preserve_access_index))
+
+// chain of records, all with attributes
+struct __reloc__ s1;
+struct __reloc__ s2;
+struct __reloc__ s3;
+
+struct s1 {
+  int c;
+};
+typedef struct s1 __s1;
+
+struct s2 {
+  union {
+__s1 b[3];
+  };
+};
+typedef struct s2 __s2;
+
+struct s3 {
+  __s2 a;
+};
+typedef struct s3 __s3;
+
+int test(__s3 *arg) {
+  return arg->a.b[2].c;
+}
+
+// CHECK: call %struct.s2* @llvm.preserve.struct.access.index.p0s_struct.s2s.p0s_struct.s3s(%struct.s3* %{{[0-9a-z]+}}, i32 0, i32 0)
+// CHECK: call %union.anon* @llvm.preserve.struct.access.index.p0s_union.anons.p0s_struct.s2s(%struct.s2* %{{[0-9a-z]+}}, i32 0, i32 0)
+

[clang] 4a5aa1a - [BPF] Add preserve_access_index attribute for record definition

2019-11-09 Thread Yonghong Song via cfe-commits

Author: Yonghong Song
Date: 2019-11-09T08:17:12-08:00
New Revision: 4a5aa1a7bf8b1714b817ede8e09cd28c0784228a

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

LOG: [BPF] Add preserve_access_index attribute for record definition

This patch introduced a new bpf specific attribute which can
be added to struct or union definition. For example,
  struct s { ... } __attribute__((preserve_access_index));
  union u { ... } __attribute__((preserve_access_index));
The goal is to simplify user codes for cases
where preserve access index happens for certain struct/union,
so user does not need to use clang __builtin_preserve_access_index
for every members.

The attribute has no effect if -g is not specified.

When the attribute is specified and -g is specified, any member
access defined by that structure or union, including array subscript
access and inner records, will be preserved through
  __builtin_preserve_{array,struct,union}_access_index()
IR intrinsics, which will enable relocation generation
in bpf backend.

The following is an example to illustrate the usage:
  -bash-4.4$ cat t.c
  #define __reloc__ __attribute__((preserve_access_index))
  struct s1 {
int c;
  } __reloc__;

  struct s2 {
union {
  struct s1 b[3];
};
  } __reloc__;

  struct s3 {
struct s2 a;
  } __reloc__;

  int test(struct s3 *arg) {
return arg->a.b[2].c;
  }
  -bash-4.4$ clang -target bpf -g -S -O2 t.c

A relocation with access string "0:0:0:0:2:0" will be generated
representing access offset of arg->a.b[2].c.

forward declaration with attribute is also handled properly such
that the attribute is copied and populated in real record definition.

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

Added: 
clang/test/CodeGen/bpf-attr-preserve-access-index-1.c
clang/test/CodeGen/bpf-attr-preserve-access-index-2.c
clang/test/CodeGen/bpf-attr-preserve-access-index-3.c
clang/test/CodeGen/bpf-attr-preserve-access-index-4.c
clang/test/CodeGen/bpf-attr-preserve-access-index-5.c
clang/test/CodeGen/bpf-attr-preserve-access-index-6.c
clang/test/CodeGen/bpf-attr-preserve-access-index-7.c
clang/test/CodeGen/bpf-attr-preserve-access-index-8.c
clang/test/Sema/bpf-attr-preserve-access-index.c

Modified: 
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/AttrDocs.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/CodeGen/CGExpr.cpp
clang/lib/Sema/SemaDeclAttr.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 0d25e775e2af..aef02b5a8e96 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -332,6 +332,7 @@ class TargetArch arches> : TargetSpec {
 }
 def TargetARM : TargetArch<["arm", "thumb", "armeb", "thumbeb"]>;
 def TargetAVR : TargetArch<["avr"]>;
+def TargetBPF : TargetArch<["bpfel", "bpfeb"]>;
 def TargetMips32 : TargetArch<["mips", "mipsel"]>;
 def TargetAnyMips : TargetArch<["mips", "mipsel", "mips64", "mips64el"]>;
 def TargetMSP430 : TargetArch<["msp430"]>;
@@ -1578,6 +1579,12 @@ def AMDGPUNumVGPR : InheritableAttr {
   let Subjects = SubjectList<[Function], ErrorDiag, "kernel functions">;
 }
 
+def BPFPreserveAccessIndex : InheritableAttr,
+ TargetSpecificAttr  {
+  let Spellings = [Clang<"preserve_access_index">];
+  let Documentation = [BPFPreserveAccessIndexDocs];
+}
+
 def WebAssemblyImportModule : InheritableAttr,
   TargetSpecificAttr {
   let Spellings = [Clang<"import_module">];

diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 3a9093124637..50e76bf080b4 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -1634,6 +1634,17 @@ The semantics are as follows:
   }];
 }
 
+def BPFPreserveAccessIndexDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+Clang supports the ``__attribute__((preserve_access_index))``
+attribute for the BPF target. This attribute may be attached to a
+struct or union declaration, where if -g is specified, it enables
+preserving struct or union member access debuginfo indicies of this
+struct or union, similar to clang ``__builtin_preserve_acceess_index()``.
+  }];
+}
+
 def MipsInterruptDocs : Documentation {
   let Category = DocCatFunction;
   let Heading = "interrupt (MIPS)";

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 88d73dc89b55..33a0f9710856 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -10065,6 +10065,7 @@ def err_preserve_field_info_not_field : Error<
   "__builtin_prese

[PATCH] D69762: [Diagnostics] Try to improve warning message for -Wreturn-type

2019-11-09 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:6860
 "lambda declared 'noreturn' should not return">;
   def warn_maybe_falloff_nonvoid_lambda : Warning<
+"non-void lambda does not return a value in all control paths">,

xbolva00 wrote:
> aaron.ballman wrote:
> > And maybe move these two up closer to the other duplicate-ish diagnostics.
> This is in
> "let CategoryName = "Lambda Issue" in {"
> 
> so I am not sure if should really move it.
I hadn't noticed that, let's leave it here. Good catch!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69762



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


[PATCH] D69762: [Diagnostics] Try to improve warning message for -Wreturn-type

2019-11-09 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 marked an inline comment as done.
xbolva00 added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:6860
 "lambda declared 'noreturn' should not return">;
   def warn_maybe_falloff_nonvoid_lambda : Warning<
+"non-void lambda does not return a value in all control paths">,

aaron.ballman wrote:
> And maybe move these two up closer to the other duplicate-ish diagnostics.
This is in
"let CategoryName = "Lambda Issue" in {"

so I am not sure if should really move it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69762



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


[PATCH] D63975: Warn when ScopeDepthOrObjCQuals overflows

2019-11-09 Thread Mark de Wever via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb9be5ce8f3e0: [Parser] Warn when ScopeDepthOrObjCQuals 
overflows (authored by Mordante).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63975

Files:
  clang/include/clang/AST/Decl.h
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/lib/Parse/ParseDecl.cpp
  clang/test/Parser/nested_blocks_overflow.cpp
  clang/test/Parser/nested_function_prototype_overflow.cpp
  clang/test/Parser/nested_lambda_overflow.cpp

Index: clang/test/Parser/nested_lambda_overflow.cpp
===
--- /dev/null
+++ clang/test/Parser/nested_lambda_overflow.cpp
@@ -0,0 +1,55 @@
+// RUN: %clang %s -fsyntax-only -fbracket-depth=512
+// RUN: not %clang %s -fsyntax-only -fbracket-depth=512 -DFAIL 2>&1 | FileCheck %s
+
+template  int foo(T &&t);
+
+void bar(int x = foo(
+
+[](int x = foo([](int x = foo([](int x = foo([](int x = foo([](int x = foo([](int x = foo([](int x = foo([](int x = foo(
+[](int x = foo([](int x = foo([](int x = foo([](int x = foo([](int x = foo([](int x = foo([](int x = foo([](int x = foo(
+[](int x = foo([](int x = foo([](int x = foo([](int x = foo([](int x = foo([](int x = foo([](int x = foo([](int x = foo(
+[](int x = foo([](int x = foo([](int x = foo([](int x = foo([](int x = foo([](int x = foo([](int x = foo([](int x = foo(
+[](int x = foo([](int x = foo([](int x = foo([](int x = foo([](int x = foo([](int x = foo([](int x = foo([](int x = foo(
+[](int x = foo([](int x = foo([](int x = foo([](int x = foo([](int x = foo([](int x = foo([](int x = foo([](int x = foo(
+[](int x = foo([](int x = foo([](int x = foo([](int x = foo([](int x = foo([](int x = foo([](int x = foo([](int x = foo(
+[](int x = foo([](int x = foo([](int x = foo([](int x = foo([](int x = foo([](int x = foo([](int x = foo([](int x = foo(
+[](int x = foo([](int x = foo([](int x = foo([](int x = foo([](int x = foo([](int x = foo([](int x = foo([](int x = foo(
+[](int x = foo([](int x = foo([](int x = foo([](int x = foo([](int x = foo([](int x = foo([](int x = foo([](int x = foo(
+[](int x = foo([](int x = foo([](int x = foo([](int x = foo([](int x = foo([](int x = foo([](int x = foo([](int x = foo(
+[](int x = foo([](int x = foo([](int x = foo([](int x = foo([](int x = foo([](int x = foo([](int x = foo([](int x = foo(
+[](int x = foo([](int x = foo([](int x = foo([](int x = foo([](int x = foo([](int x = foo([](int x = foo([](int x = foo(
+[](int x = foo([](int x = foo([](int x = foo([](int x = foo([](int x = foo([](int x = foo([](int x = foo([](int x = foo(
+[](int x = foo([](int x = foo([](int x = foo([](int x = foo([](int x = foo([](int x = foo([](int x = foo([](int x = foo(
+
+[](int x = foo([](int x = foo([](int x = foo([](int x = foo([](int x = foo([](int x = foo(
+
+#ifdef FAIL
+[](int x = foo(
+#endif
+
+[](int x = foo(1)){}
+
+#ifdef FAIL
+)){}
+#endif
+
+)){})){})){})){})){})){}
+
+)){})){})){})){})){})){})){})){}
+)){})){})){})){})){})){})){})){}
+)){})){})){})){})){})){})){})){}
+)){})){})){})){})){})){})){})){}
+)){})){})){})){})){})){})){})){}
+)){})){})){})){})){})){})){})){}
+)){})){})){})){})){})){})){})){}
+)){})){})){})){})){})){})){})){}
+)){})){})){})){})){})){})){})){}
+)){})){})){})){})){})){})){})){}
+)){})){})){})){})){})){})){})){}
+)){})){})){})){})){})){})){})){}
+)){})){})){})){})){})){})){})){}
+)){})){})){})){})){})){})){})){}
+)){})){})){})){})){})){})){})){}
+));
+
+// CHECK: fatal error: function scope depth exceeded maximum of 127
Index: clang/test/Parser/nested_function_prototype_overflow.cpp
===
--- /dev/null
+++ clang/test/Parser/nested_function_prototype_overflow.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s -fsyntax-only
+// RUN: not %clang_cc1 %s -fsyntax-only -DFAIL 2>&1 | FileCheck %s
+
+void foo(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(voi

[clang] b9be5ce - [Parser] Warn when ScopeDepthOrObjCQuals overflows

2019-11-09 Thread Mark de Wever via cfe-commits

Author: Mark de Wever
Date: 2019-11-09T15:33:01+01:00
New Revision: b9be5ce8f3e0e697a61ad16e2c669de6ea8f8739

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

LOG: [Parser] Warn when ScopeDepthOrObjCQuals overflows

Before when the overflow occured an assertion was triggered. Now check
whether the maximum has been reached and warn properly.

This patch fixes the original submission of PR19607.

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

Added: 
clang/test/Parser/nested_blocks_overflow.cpp
clang/test/Parser/nested_function_prototype_overflow.cpp
clang/test/Parser/nested_lambda_overflow.cpp

Modified: 
clang/include/clang/AST/Decl.h
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/lib/Parse/ParseDecl.cpp

Removed: 




diff  --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h
index 16094c0988fa..31adfc5c368a 100644
--- a/clang/include/clang/AST/Decl.h
+++ b/clang/include/clang/AST/Decl.h
@@ -921,11 +921,13 @@ class VarDecl : public DeclaratorDecl, public 
Redeclarable {
 /// Whether this parameter is an ObjC method parameter or not.
 unsigned IsObjCMethodParam : 1;
 
+enum { NumScopeDepthOrObjCQualsBits = 7 };
+
 /// If IsObjCMethodParam, a Decl::ObjCDeclQualifier.
 /// Otherwise, the number of function parameter scopes enclosing
 /// the function parameter scope in which this parameter was
 /// declared.
-unsigned ScopeDepthOrObjCQuals : 7;
+unsigned ScopeDepthOrObjCQuals : NumScopeDepthOrObjCQualsBits;
 
 /// The number of parameters preceding this parameter in the
 /// function parameter scope in which it was declared.
@@ -1650,6 +1652,10 @@ class ParmVarDecl : public VarDecl {
 return ParmVarDeclBits.ScopeDepthOrObjCQuals;
   }
 
+  static constexpr unsigned getMaxFunctionScopeDepth() {
+return (1u << ParmVarDeclBitfields::NumScopeDepthOrObjCQualsBits) - 1;
+  }
+
   /// Returns the index of this parameter in its prototype or method scope.
   unsigned getFunctionScopeIndex() const {
 return getParameterIndex();

diff  --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 7c9f4da778a6..dc9f677ec5b6 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -325,6 +325,8 @@ def err_for_range_expected_decl : Error<
 def err_argument_required_after_attribute : Error<
   "argument required after attribute">;
 def err_missing_param : Error<"expected parameter declarator">;
+def err_function_scope_depth_exceeded : Error<
+  "function scope depth exceeded maximum of %0">, DefaultFatal;
 def err_missing_comma_before_ellipsis : Error<
   "C requires a comma prior to the ellipsis in a variadic function type">;
 def err_unexpected_typedef_ident : Error<

diff  --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index c41eb74a9cf3..e5c17a3131ab 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -6566,6 +6566,19 @@ void Parser::ParseParameterDeclarationClause(
ParsedAttributes &FirstArgAttrs,
SmallVectorImpl &ParamInfo,
SourceLocation &EllipsisLoc) {
+
+  // Avoid exceeding the maximum function scope depth.
+  // See https://bugs.llvm.org/show_bug.cgi?id=19607
+  // Note Sema::ActOnParamDeclarator calls ParmVarDecl::setScopeInfo with
+  // getFunctionPrototypeDepth() - 1.
+  if (getCurScope()->getFunctionPrototypeDepth() - 1 >
+  ParmVarDecl::getMaxFunctionScopeDepth()) {
+Diag(Tok.getLocation(), diag::err_function_scope_depth_exceeded)
+<< ParmVarDecl::getMaxFunctionScopeDepth();
+cutOffParsing();
+return;
+  }
+
   do {
 // FIXME: Issue a diagnostic if we parsed an attribute-specifier-seq
 // before deciding this was a parameter-declaration-clause.

diff  --git a/clang/test/Parser/nested_blocks_overflow.cpp 
b/clang/test/Parser/nested_blocks_overflow.cpp
new file mode 100644
index ..e8366a8d56a2
--- /dev/null
+++ b/clang/test/Parser/nested_blocks_overflow.cpp
@@ -0,0 +1,54 @@
+// RUN: %clang %s -fsyntax-only -fblocks -fbracket-depth=512
+// RUN: not %clang %s -fsyntax-only -fblocks -fbracket-depth=512 -DFAIL 2>&1 | 
FileCheck %s
+
+template  int foo(T &&t);
+
+void bar(int x = foo(
+^(int x = foo(^(int x = foo(^(int x = foo(^(int x = foo(^(int x = foo(^(int x 
= foo(^(int x = foo(^(int x = foo(
+^(int x = foo(^(int x = foo(^(int x = foo(^(int x = foo(^(int x = foo(^(int x 
= foo(^(int x = foo(^(int x = foo(
+^(int x = foo(^(int x = foo(^(int x = foo(^(int x = foo(^(int x = foo(^(int x 
= foo(^(int x = foo(^(int x = foo(
+^(int x = foo(^(int x = foo(^(int x = foo(^(int x = foo(^(int x = foo(^(int x 
= foo(^(int x = foo(^(int x = foo(
+^(int

[PATCH] D69792: [NFC] Supress GCC "Bitfield too small to hold all values of enum" warning.

2019-11-09 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG56b5eab12970: [NFC] Supress GCC "Bitfield too small to 
hold all values of enum" warning. (authored by rsmith).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69792

Files:
  clang/include/clang/Sema/Overload.h
  clang/lib/Sema/SemaOverload.cpp


Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -9935,7 +9935,7 @@
 
   std::string FnDesc;
   std::pair FnKindPair =
-  ClassifyOverloadCandidate(S, Cand->FoundDecl, Fn, Cand->RewriteKind,
+  ClassifyOverloadCandidate(S, Cand->FoundDecl, Fn, Cand->getRewriteKind(),
 FnDesc);
 
   Expr *FromExpr = Conv.Bad.FromExpr;
@@ -10505,8 +10505,8 @@
 
   std::string FnDesc;
   std::pair FnKindPair =
-  ClassifyOverloadCandidate(S, Cand->FoundDecl, Callee, Cand->RewriteKind,
-FnDesc);
+  ClassifyOverloadCandidate(S, Cand->FoundDecl, Callee,
+Cand->getRewriteKind(), FnDesc);
 
   S.Diag(Callee->getLocation(), diag::note_ovl_candidate_bad_target)
   << (unsigned)FnKindPair.first << (unsigned)ocs_non_template
@@ -10624,8 +10624,8 @@
 if (Fn->isDeleted()) {
   std::string FnDesc;
   std::pair FnKindPair =
-  ClassifyOverloadCandidate(S, Cand->FoundDecl, Fn, Cand->RewriteKind,
-FnDesc);
+  ClassifyOverloadCandidate(S, Cand->FoundDecl, Fn,
+Cand->getRewriteKind(), FnDesc);
 
   S.Diag(Fn->getLocation(), diag::note_ovl_candidate_deleted)
   << (unsigned)FnKindPair.first << (unsigned)FnKindPair.second << 
FnDesc
@@ -10635,7 +10635,7 @@
 }
 
 // We don't really have anything else to say about viable candidates.
-S.NoteOverloadCandidate(Cand->FoundDecl, Fn, Cand->RewriteKind);
+S.NoteOverloadCandidate(Cand->FoundDecl, Fn, Cand->getRewriteKind());
 return;
   }
 
@@ -10668,7 +10668,7 @@
   case ovl_fail_trivial_conversion:
   case ovl_fail_bad_final_conversion:
   case ovl_fail_final_conversion_not_exact:
-return S.NoteOverloadCandidate(Cand->FoundDecl, Fn, Cand->RewriteKind);
+return S.NoteOverloadCandidate(Cand->FoundDecl, Fn, 
Cand->getRewriteKind());
 
   case ovl_fail_bad_conversion: {
 unsigned I = (Cand->IgnoreObjectArgument ? 1 : 0);
@@ -10679,7 +10679,7 @@
 // FIXME: this currently happens when we're called from SemaInit
 // when user-conversion overload fails.  Figure out how to handle
 // those conditions and diagnose them well.
-return S.NoteOverloadCandidate(Cand->FoundDecl, Fn, Cand->RewriteKind);
+return S.NoteOverloadCandidate(Cand->FoundDecl, Fn, 
Cand->getRewriteKind());
   }
 
   case ovl_fail_bad_target:
Index: clang/include/clang/Sema/Overload.h
===
--- clang/include/clang/Sema/Overload.h
+++ clang/include/clang/Sema/Overload.h
@@ -821,7 +821,7 @@
 CallExpr::ADLCallKind IsADLCandidate : 1;
 
 /// Whether this is a rewritten candidate, and if so, of what kind?
-OverloadCandidateRewriteKind RewriteKind : 2;
+unsigned RewriteKind : 2;
 
 /// FailureKind - The reason why this candidate is not viable.
 /// Actually an OverloadFailureKind.
@@ -841,6 +841,12 @@
   StandardConversionSequence FinalConversion;
 };
 
+/// Get RewriteKind value in OverloadCandidateRewriteKind type (This
+/// function is to workaround the spurious GCC bitfield enum warning)
+OverloadCandidateRewriteKind getRewriteKind() const {
+  return static_cast(RewriteKind);
+}
+
 /// hasAmbiguousConversion - Returns whether this overload
 /// candidate requires an ambiguous conversion or not.
 bool hasAmbiguousConversion() const {


Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -9935,7 +9935,7 @@
 
   std::string FnDesc;
   std::pair FnKindPair =
-  ClassifyOverloadCandidate(S, Cand->FoundDecl, Fn, Cand->RewriteKind,
+  ClassifyOverloadCandidate(S, Cand->FoundDecl, Fn, Cand->getRewriteKind(),
 FnDesc);
 
   Expr *FromExpr = Conv.Bad.FromExpr;
@@ -10505,8 +10505,8 @@
 
   std::string FnDesc;
   std::pair FnKindPair =
-  ClassifyOverloadCandidate(S, Cand->FoundDecl, Callee, Cand->RewriteKind,
-FnDesc);
+  ClassifyOverloadCandidate(S, Cand->FoundDecl, Callee,
+Cand->getRewriteKind(), FnDesc);
 
   S.Diag(Callee->getLocation(), diag::note_ovl_candidate_bad_target)
   << (unsigned)FnKindPair.first << (unsigned)ocs_non_template
@@ -10624,8 +10624,8 @@
 i

[clang] 56b5eab - [NFC] Supress GCC "Bitfield too small to hold all values of enum" warning.

2019-11-09 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2019-11-09T05:56:51-08:00
New Revision: 56b5eab12970e540c629e9b9a8a95256c116a547

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

LOG: [NFC] Supress GCC "Bitfield too small to hold all values of enum" warning.

Patch by Wang Tianqing!

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

Added: 


Modified: 
clang/include/clang/Sema/Overload.h
clang/lib/Sema/SemaOverload.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/Overload.h 
b/clang/include/clang/Sema/Overload.h
index 728a596a92f1..c6012d754db0 100644
--- a/clang/include/clang/Sema/Overload.h
+++ b/clang/include/clang/Sema/Overload.h
@@ -821,7 +821,7 @@ class Sema;
 CallExpr::ADLCallKind IsADLCandidate : 1;
 
 /// Whether this is a rewritten candidate, and if so, of what kind?
-OverloadCandidateRewriteKind RewriteKind : 2;
+unsigned RewriteKind : 2;
 
 /// FailureKind - The reason why this candidate is not viable.
 /// Actually an OverloadFailureKind.
@@ -841,6 +841,12 @@ class Sema;
   StandardConversionSequence FinalConversion;
 };
 
+/// Get RewriteKind value in OverloadCandidateRewriteKind type (This
+/// function is to workaround the spurious GCC bitfield enum warning)
+OverloadCandidateRewriteKind getRewriteKind() const {
+  return static_cast(RewriteKind);
+}
+
 /// hasAmbiguousConversion - Returns whether this overload
 /// candidate requires an ambiguous conversion or not.
 bool hasAmbiguousConversion() const {

diff  --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index bf520f66e3ae..a97847461e3e 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -9935,7 +9935,7 @@ static void DiagnoseBadConversion(Sema &S, 
OverloadCandidate *Cand,
 
   std::string FnDesc;
   std::pair FnKindPair =
-  ClassifyOverloadCandidate(S, Cand->FoundDecl, Fn, Cand->RewriteKind,
+  ClassifyOverloadCandidate(S, Cand->FoundDecl, Fn, Cand->getRewriteKind(),
 FnDesc);
 
   Expr *FromExpr = Conv.Bad.FromExpr;
@@ -10505,8 +10505,8 @@ static void DiagnoseBadTarget(Sema &S, 
OverloadCandidate *Cand) {
 
   std::string FnDesc;
   std::pair FnKindPair =
-  ClassifyOverloadCandidate(S, Cand->FoundDecl, Callee, Cand->RewriteKind,
-FnDesc);
+  ClassifyOverloadCandidate(S, Cand->FoundDecl, Callee,
+Cand->getRewriteKind(), FnDesc);
 
   S.Diag(Callee->getLocation(), diag::note_ovl_candidate_bad_target)
   << (unsigned)FnKindPair.first << (unsigned)ocs_non_template
@@ -10624,8 +10624,8 @@ static void NoteFunctionCandidate(Sema &S, 
OverloadCandidate *Cand,
 if (Fn->isDeleted()) {
   std::string FnDesc;
   std::pair FnKindPair =
-  ClassifyOverloadCandidate(S, Cand->FoundDecl, Fn, Cand->RewriteKind,
-FnDesc);
+  ClassifyOverloadCandidate(S, Cand->FoundDecl, Fn,
+Cand->getRewriteKind(), FnDesc);
 
   S.Diag(Fn->getLocation(), diag::note_ovl_candidate_deleted)
   << (unsigned)FnKindPair.first << (unsigned)FnKindPair.second << 
FnDesc
@@ -10635,7 +10635,7 @@ static void NoteFunctionCandidate(Sema &S, 
OverloadCandidate *Cand,
 }
 
 // We don't really have anything else to say about viable candidates.
-S.NoteOverloadCandidate(Cand->FoundDecl, Fn, Cand->RewriteKind);
+S.NoteOverloadCandidate(Cand->FoundDecl, Fn, Cand->getRewriteKind());
 return;
   }
 
@@ -10668,7 +10668,7 @@ static void NoteFunctionCandidate(Sema &S, 
OverloadCandidate *Cand,
   case ovl_fail_trivial_conversion:
   case ovl_fail_bad_final_conversion:
   case ovl_fail_final_conversion_not_exact:
-return S.NoteOverloadCandidate(Cand->FoundDecl, Fn, Cand->RewriteKind);
+return S.NoteOverloadCandidate(Cand->FoundDecl, Fn, 
Cand->getRewriteKind());
 
   case ovl_fail_bad_conversion: {
 unsigned I = (Cand->IgnoreObjectArgument ? 1 : 0);
@@ -10679,7 +10679,7 @@ static void NoteFunctionCandidate(Sema &S, 
OverloadCandidate *Cand,
 // FIXME: this currently happens when we're called from SemaInit
 // when user-conversion overload fails.  Figure out how to handle
 // those conditions and diagnose them well.
-return S.NoteOverloadCandidate(Cand->FoundDecl, Fn, Cand->RewriteKind);
+return S.NoteOverloadCandidate(Cand->FoundDecl, Fn, 
Cand->getRewriteKind());
   }
 
   case ovl_fail_bad_target:



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


[PATCH] D67460: clang-tidy: modernize-use-using work with multi-argument templates

2019-11-09 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D67460#1739062 , @poelmanc wrote:

> Thanks @aaron.ballman, I don't have commit access so will someone else commit 
> this?


I can commit it for you when I get back into the office mid-next week, unless 
someone else wants to commit it on your behalf first.

> To address the minor nit, should I upload a new patch with 
> post-increment/post-decrement changed to pre-increment/pre-decrement? (Does 
> uploading changes undo the "Ready to Land" status?)

Yes, please upload a new patch. It may change the review state in Phab, but 
unless it's a substantive change (which this is not), we do not require 
additional review/acceptance before landing (unless someone clicks the "Request 
Changes" option in the meantime).


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D67460



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


[PATCH] D69762: [Diagnostics] Try to improve warning message for -Wreturn-type

2019-11-09 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

In D69762#1739022 , @xbolva00 wrote:

> We cannot use it for block; it is a hard error. Corountine and function can 
> be merged as suggested.


We can use `.Text` to share diagnostic text between warnings and errors (we do 
this elsewhere), but I don't insist for this patch.

LGTM aside from a commenting request.




Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:578
 
 def warn_maybe_falloff_nonvoid_function : Warning<
+  "non-void function does not return a value in all control paths">,

A FIXME comment that we'd like to combine these diagnostics eventually would be 
appreciated.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:6860
 "lambda declared 'noreturn' should not return">;
   def warn_maybe_falloff_nonvoid_lambda : Warning<
+"non-void lambda does not return a value in all control paths">,

And maybe move these two up closer to the other duplicate-ish diagnostics.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69762



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


[clang] 092577e - [cxx_status] Update with Belfast motions.

2019-11-09 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2019-11-09T03:13:21-08:00
New Revision: 092577e317229df600539f678064f321737a761b

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

LOG: [cxx_status] Update with Belfast motions.

Added: 


Modified: 
clang/www/cxx_status.html

Removed: 




diff  --git a/clang/www/cxx_status.html b/clang/www/cxx_status.html
index b22ff4c4182e..2022402b6950 100755
--- a/clang/www/cxx_status.html
+++ b/clang/www/cxx_status.html
@@ -879,9 +879,9 @@ C++2a implementation status
   Clang 9
 
 
-  Concepts
+  Concepts
   https://wg21.link/p0734r0";>P0734R0
-  No
+  No
 

 https://wg21.link/p0857r0";>P0857R0
@@ -901,6 +901,12 @@ C++2a implementation status
   
 https://wg21.link/p1452r2";>P1452R2
   
+   
+https://wg21.link/p1972r0";>P1972R0
+  
+  
+https://wg21.link/p1980r0";>P1980R0
+  
 
 
   Range-based for statements with initializer
@@ -918,7 +924,7 @@ C++2a implementation status
   Clang 8
 
 
-  Consistent comparison (operator<=>)
+  Consistent comparison (operator<=>)
   https://wg21.link/p0515r3";>P0515R3
   Partial
 
@@ -941,6 +947,10 @@ C++2a implementation status
 https://wg21.link/p1630r1";>P1630R1
 Partial
   
+   
+https://wg21.link/p1946r0";>P1946R0
+No
+  
 
   Access checking on specializations
   https://wg21.link/p0692r1";>P0692R1
@@ -979,10 +989,13 @@ C++2a implementation status
 
 
 
-  Class types as non-type template parameters
+  Class types as non-type template parameters
   https://wg21.link/p0732r2";>P0732R2
-  No
+  No
 
+   
+https://wg21.link/p1907r1";>P1907R1
+  
 
   Destroying operator delete
   https://wg21.link/p0722r3";>P0722R3
@@ -1073,12 +1086,15 @@ C++2a implementation status
 https://wg21.link/p1139r2";>P1139R2
   
 
-  Parenthesized initialization of aggregates
+  Parenthesized initialization of aggregates
   https://wg21.link/p0960r3";>P0960R3
-  No
+  No
 
+   
+https://wg21.link/p1975r0";>P1975R0
+  
 
-  Modules
+  Modules
   https://wg21.link/p1103r3";>P1103R3
   Partial
 
@@ -1092,6 +1108,14 @@ C++2a implementation status
   
 https://wg21.link/p1703r1";>P1703R1
   
+   
+https://wg21.link/p1874r1";>P1874R1
+Partial
+  
+   
+https://wg21.link/p1979r0";>P1979R0
+No
+  
 
   Coroutines
   https://wg21.link/p0912r5";>P0912R5
@@ -1177,9 +1201,9 @@ Technical specifications and standing 
documents
 Available in Clang?
  
 
-  SD-6: SG10 feature test recommendations
-  https://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations";>SD-6
-  N/A
+  SD-6: SG10 feature test recommendations
+  https://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations";>SD-6
+  N/A
   
 Clang 3.4 (https://wg21.link/n3745";>N3745)
   
@@ -1209,6 +1233,11 @@ Technical specifications and standing 
documents
 WIP (https://wg21.link/p1353r0";>P1353R0)
   
 
+
+  
+No (https://wg21.link/p1902r1";>P1902R1)
+  
+