[clang] 037f856 - Itanium ABI: Pack non-pod members of packed types

2022-10-14 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2022-10-14T19:32:57Z
New Revision: 037f856681268c793c660389b4d6407367e68190

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

LOG: Itanium ABI: Pack non-pod members of packed types

Seems there's a narrow case - where a packed type doesn't pack its base
subobjects (only fields), but when packing a field of the derived type,
GCC does pack the resulting total object - effectively packing the base
subobject.

So ensure that this non-pod type (owing to it having a base class) that
is packed, gets packed when placed in /another/ type that is also
packed.

This is a (smallish?) ABI fix to a regression introduced by D117616 -
but that regression/ABI break hasn't been released in LLVM as-yet (it's
been reverted on the release branch from the last two LLVM releases - I
probably should've just reverted the whole patch while we hashed out
this and other issues) so this change isn't itself an ABI break, as far
as LLVM releases are concerned (for folks releasing their own copies of
LLVM from ToT/without the LLVM release branch, and didn't opt into the
clang-abi-compat 14 or below (soon to be 15 or below, I guess I should
say) then this would be an ABI break against clang from the last 9
months or so)

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

Added: 


Modified: 
clang/lib/AST/RecordLayoutBuilder.cpp
clang/test/SemaCXX/class-layout.cpp

Removed: 




diff  --git a/clang/lib/AST/RecordLayoutBuilder.cpp 
b/clang/lib/AST/RecordLayoutBuilder.cpp
index dea7450613cc3..a897d4c832300 100644
--- a/clang/lib/AST/RecordLayoutBuilder.cpp
+++ b/clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1891,6 +1891,7 @@ void ItaniumRecordLayoutBuilder::LayoutField(const 
FieldDecl *D,
 
   llvm::Triple Target = Context.getTargetInfo().getTriple();
   bool FieldPacked = (Packed && (!FieldClass || FieldClass->isPOD() ||
+ FieldClass->hasAttr() ||
  Context.getLangOpts().getClangABICompat() <=
  LangOptions::ClangABI::Ver15 ||
  Target.isPS() || Target.isOSDarwin())) ||

diff  --git a/clang/test/SemaCXX/class-layout.cpp 
b/clang/test/SemaCXX/class-layout.cpp
index df63141fc36dd..f3106ec422dff 100644
--- a/clang/test/SemaCXX/class-layout.cpp
+++ b/clang/test/SemaCXX/class-layout.cpp
@@ -642,3 +642,17 @@ struct t2 {
 _Static_assert(_Alignof(t1) == 1, "");
 _Static_assert(_Alignof(t2) == 1, "");
 } // namespace non_pod_packed
+
+namespace non_pod_packed_packed {
+struct B {
+  int b;
+};
+struct  FromB : B {
+} __attribute__((packed));
+struct C {
+  char a[3];
+  FromB b;
+} __attribute__((packed));
+_Static_assert(__builtin_offsetof(C, b) == 3, "");
+}
+



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


[clang] 9363071 - Move GCC-compatible pod-packing change to v16/old behavior available at v15 and below

2022-10-13 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2022-10-13T21:13:19Z
New Revision: 9363071303ec59bc9e0d9b989f08390b37e3f5e4

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

LOG: Move GCC-compatible pod-packing change to v16/old behavior available at 
v15 and below

Change matches D126334/e59f648d698e since this change got punted from
v15 too.

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/LangOptions.h
clang/lib/AST/RecordLayoutBuilder.cpp
clang/test/SemaCXX/class-layout.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index b036764803007..2a81877f27b71 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -524,6 +524,12 @@ OpenCL C Language Changes in Clang
 ABI Changes in Clang
 
 
+- GCC doesn't pack non-POD members in packed structs unless the packed
+  attribute is also specified on the member. Clang historically did perform
+  such packing. Clang now matches the gcc behavior (except on Darwin and PS4).
+  You can switch back to the old ABI behavior with the flag:
+  ``-fclang-abi-compat=15.0``.
+
 OpenMP Support in Clang
 ---
 

diff  --git a/clang/include/clang/Basic/LangOptions.h 
b/clang/include/clang/Basic/LangOptions.h
index 4cac4c221d8b5..cfa98329ce24a 100644
--- a/clang/include/clang/Basic/LangOptions.h
+++ b/clang/include/clang/Basic/LangOptions.h
@@ -220,7 +220,6 @@ class LangOptions : public LangOptionsBase {
 /// Attempt to be ABI-compatible with code generated by Clang 14.0.x.
 /// This causes clang to:
 ///   - mangle dependent nested names incorrectly.
-///   - pack non-POD members of packed structs.
 ///   - make trivial only those defaulted copy constructors with a
 /// parameter-type-list equivalent to the parameter-type-list of an
 /// implicit declaration.
@@ -229,6 +228,7 @@ class LangOptions : public LangOptionsBase {
 /// Attempt to be ABI-compatible with code generated by Clang 15.0.x.
 /// This causes clang to:
 ///   - Reverse the implementation for DR692, DR1395 and DR1432.
+///   - pack non-POD members of packed structs.
 Ver15,
 
 /// Conform to the underlying platform's C and C++ ABIs as closely

diff  --git a/clang/lib/AST/RecordLayoutBuilder.cpp 
b/clang/lib/AST/RecordLayoutBuilder.cpp
index 6f3ede2ce42a7..dea7450613cc3 100644
--- a/clang/lib/AST/RecordLayoutBuilder.cpp
+++ b/clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1892,7 +1892,7 @@ void ItaniumRecordLayoutBuilder::LayoutField(const 
FieldDecl *D,
   llvm::Triple Target = Context.getTargetInfo().getTriple();
   bool FieldPacked = (Packed && (!FieldClass || FieldClass->isPOD() ||
  Context.getLangOpts().getClangABICompat() <=
- LangOptions::ClangABI::Ver14 ||
+ LangOptions::ClangABI::Ver15 ||
  Target.isPS() || Target.isOSDarwin())) ||
  D->hasAttr();
 

diff  --git a/clang/test/SemaCXX/class-layout.cpp 
b/clang/test/SemaCXX/class-layout.cpp
index f81e526d0e2ad..df63141fc36dd 100644
--- a/clang/test/SemaCXX/class-layout.cpp
+++ b/clang/test/SemaCXX/class-layout.cpp
@@ -1,10 +1,10 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++98 -Wno-inaccessible-base
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base
-// RUN: %clang_cc1 -triple x86_64-apple-darwin%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=14
+// RUN: %clang_cc1 -triple x86_64-apple-darwin%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
 // RUN: %clang_cc1 -triple x86_64-scei-ps4%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=6
 // RUN: %clang_cc1 -triple x86_64-sie-ps5 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=6
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=6 -DCLANG_ABI_COMPAT=6
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=14 -DCLANG_ABI_COMPAT=14
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
 // expected-no-diagnostics
 
 #define SA(n, p) int a##n[(p) ? 1 : -1]
@@ -621,7 +621,7 @@ struct t2 {
   char c2;
   t1 v1;
 } __attribute__((packed));
-#if defined(CLANG_ABI_COMPAT) && CLANG_ABI_COMPAT <= 14
+#if defined(CLANG_ABI_COMPAT) && CLANG_ABI_COMPAT <= 15
 

Re: [clang-tools-extra] 5d2d527 - [clangd] Avoid scanning up to end of file on each comment!

2022-10-10 Thread David Blaikie via cfe-commits
On Mon, Oct 10, 2022 at 11:13 AM Sam McCall  wrote:
>
> On Mon, 10 Oct 2022, 19:57 David Blaikie,  wrote:
>>
>> Could the underlying API be made more robust to handle StringRefs
>> rather than null terminated char* in the first place? (like
>> SourceManager::getCharacterData could return StringRef? Presumably at
>> some layer it already knows how long the file is - the underlying
>> MemoryBuffer, in this case)
>
> Maybe...
>
> You could return a StringRef(Pos, EOF) efficiently.
> However it's not a great fit for many of the existing (>150) callers:
>  - that are looking for the *endpoint* of some text

Yeah, I figured that was more what the API was about for better/worse.
I guess it's not worth having two entry points, a lower-level one that
returns StringRef and then the existing one that calls that and
returns the data pointer from the StringRef...

>  - which want to run the lexer (the returned char* is implicitly 
> null-terminated, StringRef would obscure that guarantee)

I guess by implication the lexer needs something null terminated? Be
nice if that wasn't the case too...

>  - the function is marked as "this is very hot", though I doubt it matters 
> that much

*nod* At least something to be careful about.

> It also leads to some unnatural code at callsites such as this, because "from 
> the start of this entity until the end of the file" is an unnatural range to 
> have, it would probably be easy to mistake for "from the start to the end of 
> this entity".

Yeah. :/

> I think what this function does is too low-level to make safe and obvious, 
> and unfortunately it's hard to build high-level things on top of it.

Yeah :/

> (e.g. StringRef getTextRange(SourceRange) would be great to have, but 
> actually you it needs to run the lexer and assert nontrivial invariants due 
> to design decisions elsewhere in clang)
>
>>
>> On Thu, Oct 6, 2022 at 2:39 AM Sam McCall via cfe-commits
>>  wrote:
>> >
>> >
>> > Author: Sam McCall
>> > Date: 2022-10-06T11:38:55+02:00
>> > New Revision: 5d2d527c32da2081b814ef8b446bc3e037f74b0a
>> >
>> > URL: 
>> > https://github.com/llvm/llvm-project/commit/5d2d527c32da2081b814ef8b446bc3e037f74b0a
>> > DIFF: 
>> > https://github.com/llvm/llvm-project/commit/5d2d527c32da2081b814ef8b446bc3e037f74b0a.diff
>> >
>> > LOG: [clangd] Avoid scanning up to end of file on each comment!
>> >
>> > Assigning char* (pointing at comment start) to StringRef was causing us
>> > to scan the rest of the source file looking for the null terminator.
>> >
>> > This seems to be eating about 8% of our *total* CPU!
>> >
>> > While fixing this, factor out the common bits from the two places we're
>> > parsing IWYU pragmas.
>> >
>> > Differential Revision: https://reviews.llvm.org/D135314
>> >
>> > Added:
>> >
>> >
>> > Modified:
>> > clang-tools-extra/clangd/Headers.cpp
>> > clang-tools-extra/clangd/Headers.h
>> > clang-tools-extra/clangd/index/CanonicalIncludes.cpp
>> > clang-tools-extra/clangd/unittests/HeadersTests.cpp
>> >
>> > Removed:
>> >
>> >
>> >
>> > 
>> > diff  --git a/clang-tools-extra/clangd/Headers.cpp 
>> > b/clang-tools-extra/clangd/Headers.cpp
>> > index 5231a47487bc7..52b954e921620 100644
>> > --- a/clang-tools-extra/clangd/Headers.cpp
>> > +++ b/clang-tools-extra/clangd/Headers.cpp
>> > @@ -22,9 +22,17 @@
>> >  namespace clang {
>> >  namespace clangd {
>> >
>> > -const char IWYUPragmaKeep[] = "// IWYU pragma: keep";
>> > -const char IWYUPragmaExport[] = "// IWYU pragma: export";
>> > -const char IWYUPragmaBeginExports[] = "// IWYU pragma: begin_exports";
>> > +llvm::Optional parseIWYUPragma(const char *Text) {
>> > +  // This gets called for every comment seen in the preamble, so it's 
>> > quite hot.
>> > +  constexpr llvm::StringLiteral IWYUPragma = "// IWYU pragma: ";
>> > +  if (strncmp(Text, IWYUPragma.data(), IWYUPragma.size()))
>> > +return llvm::None;
>> > +  Text += IWYUPragma.size();
>> > +  const char *End = Text;
>> > +  while (*End != 0 && *End != '\n')
>> > +++End;
>> > +  return StringRef(Text, End - Text);
>> > +}
>> >
>> >  class IncludeStructure::RecordHeaders : public PPCallbacks,
>> >  public CommentHandler {
>> > @@ -129,10 +137,10 @@ class IncludeStructure::RecordHeaders : public 
>> > PPCallbacks,
>> >}
>> >
>> >bool HandleComment(Preprocessor , SourceRange Range) override {
>> > -bool Err = false;
>> > -llvm::StringRef Text = SM.getCharacterData(Range.getBegin(), );
>> > -if (Err)
>> > +auto Pragma = parseIWYUPragma(SM.getCharacterData(Range.getBegin()));
>> > +if (!Pragma)
>> >return false;
>> > +
>> >  if (inMainFile()) {
>> >// Given:
>> >//
>> > @@ -150,8 +158,7 @@ class IncludeStructure::RecordHeaders : public 
>> > PPCallbacks,
>> >// will know that the next inclusion is behind the IWYU pragma.
>> >// FIXME: Support "IWYU pragma: 

Re: [clang-tools-extra] 5d2d527 - [clangd] Avoid scanning up to end of file on each comment!

2022-10-10 Thread David Blaikie via cfe-commits
Could the underlying API be made more robust to handle StringRefs
rather than null terminated char* in the first place? (like
SourceManager::getCharacterData could return StringRef? Presumably at
some layer it already knows how long the file is - the underlying
MemoryBuffer, in this case)

On Thu, Oct 6, 2022 at 2:39 AM Sam McCall via cfe-commits
 wrote:
>
>
> Author: Sam McCall
> Date: 2022-10-06T11:38:55+02:00
> New Revision: 5d2d527c32da2081b814ef8b446bc3e037f74b0a
>
> URL: 
> https://github.com/llvm/llvm-project/commit/5d2d527c32da2081b814ef8b446bc3e037f74b0a
> DIFF: 
> https://github.com/llvm/llvm-project/commit/5d2d527c32da2081b814ef8b446bc3e037f74b0a.diff
>
> LOG: [clangd] Avoid scanning up to end of file on each comment!
>
> Assigning char* (pointing at comment start) to StringRef was causing us
> to scan the rest of the source file looking for the null terminator.
>
> This seems to be eating about 8% of our *total* CPU!
>
> While fixing this, factor out the common bits from the two places we're
> parsing IWYU pragmas.
>
> Differential Revision: https://reviews.llvm.org/D135314
>
> Added:
>
>
> Modified:
> clang-tools-extra/clangd/Headers.cpp
> clang-tools-extra/clangd/Headers.h
> clang-tools-extra/clangd/index/CanonicalIncludes.cpp
> clang-tools-extra/clangd/unittests/HeadersTests.cpp
>
> Removed:
>
>
>
> 
> diff  --git a/clang-tools-extra/clangd/Headers.cpp 
> b/clang-tools-extra/clangd/Headers.cpp
> index 5231a47487bc7..52b954e921620 100644
> --- a/clang-tools-extra/clangd/Headers.cpp
> +++ b/clang-tools-extra/clangd/Headers.cpp
> @@ -22,9 +22,17 @@
>  namespace clang {
>  namespace clangd {
>
> -const char IWYUPragmaKeep[] = "// IWYU pragma: keep";
> -const char IWYUPragmaExport[] = "// IWYU pragma: export";
> -const char IWYUPragmaBeginExports[] = "// IWYU pragma: begin_exports";
> +llvm::Optional parseIWYUPragma(const char *Text) {
> +  // This gets called for every comment seen in the preamble, so it's quite 
> hot.
> +  constexpr llvm::StringLiteral IWYUPragma = "// IWYU pragma: ";
> +  if (strncmp(Text, IWYUPragma.data(), IWYUPragma.size()))
> +return llvm::None;
> +  Text += IWYUPragma.size();
> +  const char *End = Text;
> +  while (*End != 0 && *End != '\n')
> +++End;
> +  return StringRef(Text, End - Text);
> +}
>
>  class IncludeStructure::RecordHeaders : public PPCallbacks,
>  public CommentHandler {
> @@ -129,10 +137,10 @@ class IncludeStructure::RecordHeaders : public 
> PPCallbacks,
>}
>
>bool HandleComment(Preprocessor , SourceRange Range) override {
> -bool Err = false;
> -llvm::StringRef Text = SM.getCharacterData(Range.getBegin(), );
> -if (Err)
> +auto Pragma = parseIWYUPragma(SM.getCharacterData(Range.getBegin()));
> +if (!Pragma)
>return false;
> +
>  if (inMainFile()) {
>// Given:
>//
> @@ -150,8 +158,7 @@ class IncludeStructure::RecordHeaders : public 
> PPCallbacks,
>// will know that the next inclusion is behind the IWYU pragma.
>// FIXME: Support "IWYU pragma: begin_exports" and "IWYU pragma:
>// end_exports".
> -  if (!Text.startswith(IWYUPragmaExport) &&
> -  !Text.startswith(IWYUPragmaKeep))
> +  if (!Pragma->startswith("export") && !Pragma->startswith("keep"))
>  return false;
>unsigned Offset = SM.getFileOffset(Range.getBegin());
>LastPragmaKeepInMainFileLine =
> @@ -161,8 +168,7 @@ class IncludeStructure::RecordHeaders : public 
> PPCallbacks,
>// does not support them properly yet, so they will be not marked as
>// unused.
>// FIXME: Once IncludeCleaner supports export pragmas, remove this.
> -  if (!Text.startswith(IWYUPragmaExport) &&
> -  !Text.startswith(IWYUPragmaBeginExports))
> +  if (!Pragma->startswith("export") && 
> !Pragma->startswith("begin_exports"))
>  return false;
>Out->HasIWYUExport.insert(
>*Out->getID(SM.getFileEntryForID(SM.getFileID(Range.getBegin();
>
> diff  --git a/clang-tools-extra/clangd/Headers.h 
> b/clang-tools-extra/clangd/Headers.h
> index ff3f063168325..ba72ad397bf8f 100644
> --- a/clang-tools-extra/clangd/Headers.h
> +++ b/clang-tools-extra/clangd/Headers.h
> @@ -35,6 +35,12 @@ namespace clangd {
>  /// Returns true if \p Include is literal include like "path" or .
>  bool isLiteralInclude(llvm::StringRef Include);
>
> +/// If Text begins an Include-What-You-Use directive, returns it.
> +/// Given "// IWYU pragma: keep", returns "keep".
> +/// Input is a null-terminated char* as provided by SM.getCharacterData().
> +/// (This should not be StringRef as we do *not* want to scan for its 
> length).
> +llvm::Optional parseIWYUPragma(const char *Text);
> +
>  /// Represents a header file to be #include'd.
>  struct HeaderFile {
>std::string File;
>
> diff  --git 

[clang] b61860e - Use inheriting ctors for OSTargetInfo

2022-10-05 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2022-10-05T20:22:19Z
New Revision: b61860e63e34d955a9841389583978af93c2b97a

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

LOG: Use inheriting ctors for OSTargetInfo

(& remove PSPTargetInfo because it's unused - it had the wrong ctor in
it anyway, so wouldn't've been able to be instantiated - must've
happened due to bitrot over the years)

Added: 


Modified: 
clang/lib/Basic/Targets/OSTargets.h

Removed: 




diff  --git a/clang/lib/Basic/Targets/OSTargets.h 
b/clang/lib/Basic/Targets/OSTargets.h
index c75f7d9fbafeb..2d1a33ad9c0bc 100644
--- a/clang/lib/Basic/Targets/OSTargets.h
+++ b/clang/lib/Basic/Targets/OSTargets.h
@@ -50,8 +50,7 @@ class LLVM_LIBRARY_VISIBILITY CloudABITargetInfo : public 
OSTargetInfo {
   }
 
 public:
-  CloudABITargetInfo(const llvm::Triple , const TargetOptions )
-  : OSTargetInfo(Triple, Opts) {}
+  using OSTargetInfo::OSTargetInfo;
 };
 
 // Ananas target
@@ -66,8 +65,7 @@ class LLVM_LIBRARY_VISIBILITY AnanasTargetInfo : public 
OSTargetInfo {
   }
 
 public:
-  AnanasTargetInfo(const llvm::Triple , const TargetOptions )
-  : OSTargetInfo(Triple, Opts) {}
+  using OSTargetInfo::OSTargetInfo;
 };
 
 void getDarwinDefines(MacroBuilder , const LangOptions ,
@@ -280,8 +278,7 @@ class LLVM_LIBRARY_VISIBILITY KFreeBSDTargetInfo : public 
OSTargetInfo {
   }
 
 public:
-  KFreeBSDTargetInfo(const llvm::Triple , const TargetOptions )
-  : OSTargetInfo(Triple, Opts) {}
+  using OSTargetInfo::OSTargetInfo;
 };
 
 // Haiku Target
@@ -336,8 +333,7 @@ class LLVM_LIBRARY_VISIBILITY HurdTargetInfo : public 
OSTargetInfo {
   Builder.defineMacro("_GNU_SOURCE");
   }
 public:
-  HurdTargetInfo(const llvm::Triple , const TargetOptions )
-  : OSTargetInfo(Triple, Opts) {}
+  using OSTargetInfo::OSTargetInfo;
 };
 
 // Minix Target
@@ -360,8 +356,7 @@ class LLVM_LIBRARY_VISIBILITY MinixTargetInfo : public 
OSTargetInfo {
   }
 
 public:
-  MinixTargetInfo(const llvm::Triple , const TargetOptions )
-  : OSTargetInfo(Triple, Opts) {}
+  using OSTargetInfo::OSTargetInfo;
 };
 
 // Linux target
@@ -499,23 +494,6 @@ class LLVM_LIBRARY_VISIBILITY OpenBSDTargetInfo : public 
OSTargetInfo {
   }
 };
 
-// PSP Target
-template 
-class LLVM_LIBRARY_VISIBILITY PSPTargetInfo : public OSTargetInfo {
-protected:
-  void getOSDefines(const LangOptions , const llvm::Triple ,
-MacroBuilder ) const override {
-// PSP defines; list based on the output of the pspdev gcc toolchain.
-Builder.defineMacro("PSP");
-Builder.defineMacro("_PSP");
-Builder.defineMacro("__psp__");
-Builder.defineMacro("__ELF__");
-  }
-
-public:
-  PSPTargetInfo(const llvm::Triple ) : OSTargetInfo(Triple) {}
-};
-
 // PS3 PPU Target
 template 
 class LLVM_LIBRARY_VISIBILITY PS3PPUTargetInfo : public OSTargetInfo {
@@ -595,8 +573,7 @@ class LLVM_LIBRARY_VISIBILITY PS4OSTargetInfo : public 
PSOSTargetInfo {
   }
 
 public:
-  PS4OSTargetInfo(const llvm::Triple , const TargetOptions )
-  : PSOSTargetInfo(Triple, Opts) {}
+  using PSOSTargetInfo::PSOSTargetInfo;
 };
 
 // PS5 Target
@@ -612,8 +589,7 @@ class LLVM_LIBRARY_VISIBILITY PS5OSTargetInfo : public 
PSOSTargetInfo {
   }
 
 public:
-  PS5OSTargetInfo(const llvm::Triple , const TargetOptions )
-  : PSOSTargetInfo(Triple, Opts) {}
+  using PSOSTargetInfo::PSOSTargetInfo;
 };
 
 // RTEMS Target
@@ -986,8 +962,7 @@ class LLVM_LIBRARY_VISIBILITY WASITargetInfo
   }
 
 public:
-  explicit WASITargetInfo(const llvm::Triple , const TargetOptions 
)
-  : WebAssemblyOSTargetInfo(Triple, Opts) {}
+  using WebAssemblyOSTargetInfo::WebAssemblyOSTargetInfo;
 };
 
 // Emscripten target



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


[clang] 4769976 - MSVC ABI: Looks like even non-aarch64 uses the MSVC/14 definition for pod/aggregate passing

2022-10-04 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2022-10-04T20:19:17Z
New Revision: 4769976c49be468d7629d513080e6959a25adcfe

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

LOG: MSVC ABI: Looks like even non-aarch64 uses the MSVC/14 definition for 
pod/aggregate passing

Details posted here: https://reviews.llvm.org/D119051#3747201

3 cases that were inconsistent with the MSABI without this patch applied:
  https://godbolt.org/z/GY48qxh3G - field with protected member
  https://godbolt.org/z/Mb1PYhjrP - non-static data member initializer
  https://godbolt.org/z/sGvxcEPjo - defaulted copy constructor

I'm not sure what's suitable/sufficient testing for this - I did verify
the three cases above. Though if it helps to add them as explicit tests,
I can do that too.

Also, I was wondering if the other use of isTrivialForAArch64MSVC in
isPermittedToBeHomogenousAggregate could be another source of bugs - I
tried changing the function to unconditionally call
isTrivialFor(AArch64)MSVC without testing AArch64 first, but no tests
fail, so it looks like this is undertested in any case. But I had
trouble figuring out how to exercise this functionality properly to add
test coverage and then compare that to MSVC itself... - I got very
confused/turned around trying to test this, so I've given up enough to
send what I have out for review, but happy to look further into this
with help.

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

Added: 


Modified: 
clang/lib/CodeGen/MicrosoftCXXABI.cpp
clang/test/CodeGenCXX/microsoft-abi-sret-and-byval.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/MicrosoftCXXABI.cpp 
b/clang/lib/CodeGen/MicrosoftCXXABI.cpp
index 76aeb7bb7b76..1034066b472e 100644
--- a/clang/lib/CodeGen/MicrosoftCXXABI.cpp
+++ b/clang/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -1086,8 +1086,8 @@ bool MicrosoftCXXABI::hasMostDerivedReturn(GlobalDecl GD) 
const {
   return isDeletingDtor(GD);
 }
 
-static bool isTrivialForAArch64MSVC(const CXXRecordDecl *RD) {
-  // For AArch64, we use the C++14 definition of an aggregate, so we also
+static bool isTrivialForMSVC(const CXXRecordDecl *RD) {
+  // We use the C++14 definition of an aggregate, so we also
   // check for:
   //   No private or protected non static data members.
   //   No base classes
@@ -1115,15 +1115,7 @@ bool MicrosoftCXXABI::classifyReturnType(CGFunctionInfo 
) const {
   if (!RD)
 return false;
 
-  // Normally, the C++ concept of "is trivially copyable" is used to determine
-  // if a struct can be returned directly. However, as MSVC and the language
-  // have evolved, the definition of "trivially copyable" has changed, while 
the
-  // ABI must remain stable. AArch64 uses the C++14 concept of an "aggregate",
-  // while other ISAs use the older concept of "plain old data".
-  bool isTrivialForABI = RD->isPOD();
-  bool isAArch64 = CGM.getTarget().getTriple().isAArch64();
-  if (isAArch64)
-isTrivialForABI = RD->canPassInRegisters() && isTrivialForAArch64MSVC(RD);
+  bool isTrivialForABI = RD->canPassInRegisters() && isTrivialForMSVC(RD);
 
   // MSVC always returns structs indirectly from C++ instance methods.
   bool isIndirectReturn = !isTrivialForABI || FI.isInstanceMethod();
@@ -1137,7 +1129,7 @@ bool MicrosoftCXXABI::classifyReturnType(CGFunctionInfo 
) const {
 
 // On AArch64, use the `inreg` attribute if the object is considered to not
 // be trivially copyable, or if this is an instance method struct return.
-FI.getReturnInfo().setInReg(isAArch64);
+FI.getReturnInfo().setInReg(CGM.getTarget().getTriple().isAArch64());
 
 return true;
   }

diff  --git a/clang/test/CodeGenCXX/microsoft-abi-sret-and-byval.cpp 
b/clang/test/CodeGenCXX/microsoft-abi-sret-and-byval.cpp
index d6ee0684e36f..08c9faf6fd77 100644
--- a/clang/test/CodeGenCXX/microsoft-abi-sret-and-byval.cpp
+++ b/clang/test/CodeGenCXX/microsoft-abi-sret-and-byval.cpp
@@ -1,8 +1,8 @@
 // RUN: %clang_cc1 -no-opaque-pointers -std=c++11 -emit-llvm %s -o - 
-triple=i386-pc-linux | FileCheck -check-prefix LINUX %s
-// RUN: %clang_cc1 -no-opaque-pointers -std=c++11 -emit-llvm %s -o - 
-triple=i386-pc-win32 -mconstructor-aliases -fno-rtti | FileCheck -check-prefix 
WIN32 %s
-// RUN: %clang_cc1 -no-opaque-pointers -std=c++11 -emit-llvm %s -o - 
-triple=thumb-pc-win32 -mconstructor-aliases -fno-rtti | FileCheck 
-check-prefix WOA %s
-// RUN: %clang_cc1 -no-opaque-pointers -std=c++11 -emit-llvm %s -o - 
-triple=x86_64-pc-win32 -mconstructor-aliases -fno-rtti | FileCheck 
-check-prefix WIN64 %s
-// RUN: %clang_cc1 -no-opaque-pointers -std=c++11 -emit-llvm %s -o - 
-triple=aarch64-windows-msvc -mconstructor-aliases -fno-rtti | FileCheck 
-check-prefix WOA64 %s
+// RUN: %clang_cc1 -no-opaque-pointers -std=c++11 -emit-llvm %s -o - 

[clang] 2e1c1d6 - MSVC AArch64 ABI: Homogeneous aggregates

2022-10-04 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2022-10-04T20:17:29Z
New Revision: 2e1c1d6d72879cafc339ad035b1b5a6d1c8cc130

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

LOG: MSVC AArch64 ABI: Homogeneous aggregates

Fixes:
Protected members, HFA: https://godbolt.org/z/zqdK7vdKc
Private members, HFA: https://godbolt.org/z/zqdK7vdKc
Non-empty base, HFA: https://godbolt.org/z/PKTz59Wev
User-provided ctor, HFA: https://godbolt.org/z/sfrTddcW6

Existing correct cases:
Empty base class, NonHFA: https://godbolt.org/z/4veY9MWP3
 - correct by accident of not allowing bases at all (see non-empty base
   case/fix above for counterexample)
Polymorphic: NonHFA: https://godbolt.org/z/4veY9MWP3
Trivial copy assignment, HFA: https://godbolt.org/z/Tdecj836P
Non-trivial copy assignment, NonHFA: https://godbolt.org/z/7c4bE9Whq
Non-trivial default ctor, NonHFA: https://godbolt.org/z/Tsq1EE7b7
 - correct by accident of disallowing all user-provided ctors (see
   user-provided non-default ctor example above for counterexample)
Trivial dtor, HFA: https://godbolt.org/z/nae999aqz
Non-trivial dtor, NonHFA: https://godbolt.org/z/69oMcshb1
Empty field, NonHFA: https://godbolt.org/z/8PTxsKKMK
 - true due to checking for the absence of padding (see comment in code)

After a bunch of testing, this fixes a bunch of cases that were
incorrect. Some of the tests verify the nuances of the existing
behavior/code checks that were already present.

This was mostly motivated by cleanup from/in D133817 which itself was
motivated by D119051.

By removing the incorrect use of isTrivialForAArch64MSVC here & adding
more nuance to the homogeneous testing we can more safely/confidently
make changes to the isTrivialFor(AArch64)MSVC to more properly align
with its usage anyway.

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

Added: 


Modified: 
clang/lib/CodeGen/MicrosoftCXXABI.cpp
clang/test/CodeGenCXX/homogeneous-aggregates.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/MicrosoftCXXABI.cpp 
b/clang/lib/CodeGen/MicrosoftCXXABI.cpp
index 539f0a6eb8cb8..76aeb7bb7b76f 100644
--- a/clang/lib/CodeGen/MicrosoftCXXABI.cpp
+++ b/clang/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -4476,10 +4476,45 @@ MicrosoftCXXABI::LoadVTablePtr(CodeGenFunction , 
Address This,
 }
 
 bool MicrosoftCXXABI::isPermittedToBeHomogeneousAggregate(
-const CXXRecordDecl *CXXRD) const {
-  // MSVC Windows on Arm64 considers a type not HFA if it is not an
-  // aggregate according to the C++14 spec. This is not consistent with the
-  // AAPCS64, but is defacto spec on that platform.
-  return !CGM.getTarget().getTriple().isAArch64() ||
- isTrivialForAArch64MSVC(CXXRD);
+const CXXRecordDecl *RD) const {
+  // All aggregates are permitted to be HFA on non-ARM platforms, which mostly
+  // affects vectorcall on x64/x86.
+  if (!CGM.getTarget().getTriple().isAArch64())
+return true;
+  // MSVC Windows on Arm64 has its own rules for determining if a type is HFA
+  // that are inconsistent with the AAPCS64 ABI. The following are our best
+  // determination of those rules so far, based on observation of MSVC's
+  // behavior.
+  if (RD->isEmpty())
+return false;
+  if (RD->isPolymorphic())
+return false;
+  if (RD->hasNonTrivialCopyAssignment())
+return false;
+  if (RD->hasNonTrivialDestructor())
+return false;
+  if (RD->hasNonTrivialDefaultConstructor())
+return false;
+  // These two are somewhat redundant given the caller
+  // (ABIInfo::isHomogeneousAggregate) checks the bases and fields, but that
+  // caller doesn't consider empty bases/fields to be non-homogenous, but it
+  // looks like Microsoft's AArch64 ABI does care about these empty types &
+  // anything containing/derived from one is non-homogeneous.
+  // Instead we could add another CXXABI entry point to query this property and
+  // have ABIInfo::isHomogeneousAggregate use that property.
+  // I don't think any other of the features listed above could be true of a
+  // base/field while not true of the outer struct. For example, if you have a
+  // base/field that has an non-trivial copy assignment/dtor/default ctor, then
+  // the outer struct's corresponding operation must be non-trivial.
+  for (const CXXBaseSpecifier  : RD->bases()) {
+if (const CXXRecordDecl *FRD = B.getType()->getAsCXXRecordDecl()) {
+  if (!isPermittedToBeHomogeneousAggregate(FRD))
+return false;
+}
+  }
+  // empty fields seem to be caught by the ABIInfo::isHomogeneousAggregate
+  // checking for padding - but maybe there are ways to end up with an empty
+  // field without padding? Not that I know of, so don't check fields here &
+  // rely on the padding check.
+  return true;
 }

diff  --git a/clang/test/CodeGenCXX/homogeneous-aggregates.cpp 

[clang] 1651289 - [clang] fix generation of .debug_aranges with LTO

2022-10-04 Thread David Blaikie via cfe-commits

Author: Azat Khuzhin
Date: 2022-10-04T20:03:36Z
New Revision: 16512898956857b13e566165ba9a195be81d325f

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

LOG: [clang] fix generation of .debug_aranges with LTO

Right now in case of LTO the section is not emited:

$ cat test.c
void __attribute__((optnone)) bar()
{
}
void __attribute__((optnone)) foo()
{
bar();
}
int main()
{
foo();
}

$ clang -flto=thin -gdwarf-aranges -g -O3 test.c
$ eu-readelf -waranges a.out  | fgrep -c -e foo -e bar
0

$ clang -gdwarf-aranges -g -O3 test.c
$ eu-readelf -waranges a.out  | fgrep -c -e foo -e bar
2

Fix this by passing explicitly --plugin-opt=-generate-arange-section.

Suggested-by: OCHyams 

Reviewed By: dblaikie, MaskRay

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

Added: 
clang/test/Driver/debug-options-aranges.c

Modified: 
clang/lib/Driver/ToolChains/CommonArgs.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 4bc16710e194..d81faa365228 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -509,6 +509,14 @@ void tools::addLTOOptions(const ToolChain , 
const ArgList ,
 CmdArgs.push_back(Args.MakeArgString(Plugin));
   }
 
+  // Note, this solution is far from perfect, better to encode it into IR
+  // metadata, but this may not be worth it, since it looks like aranges is on
+  // the way out.
+  if (Args.hasArg(options::OPT_gdwarf_aranges)) {
+CmdArgs.push_back(
+Args.MakeArgString("--plugin-opt=-generate-arange-section"));
+  }
+
   // Try to pass driver level flags relevant to LTO code generation down to
   // the plugin.
 

diff  --git a/clang/test/Driver/debug-options-aranges.c 
b/clang/test/Driver/debug-options-aranges.c
new file mode 100644
index ..4dc098b7d185
--- /dev/null
+++ b/clang/test/Driver/debug-options-aranges.c
@@ -0,0 +1,6 @@
+// REQUIRES: lld
+
+/// Check that the linker plugin will get -generate-arange-section.
+// RUN: %clang -### -g --target=x86_64-linux -flto  -gdwarf-aranges %s 
2>&1 | FileCheck %s
+// RUN: %clang -### -g --target=x86_64-linux -flto=thin -gdwarf-aranges %s 
2>&1 | FileCheck %s
+// CHECK: --plugin-opt=-generate-arange-section



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


[clang] 4cd7529 - [clang][DebugInfo] Emit access specifiers for typedefs

2022-09-22 Thread David Blaikie via cfe-commits

Author: Jonathan Camilleri
Date: 2022-09-22T17:08:41Z
New Revision: 4cd7529e4caa00fa7ba27d9de18adea3c702ad8f

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

LOG: [clang][DebugInfo] Emit access specifiers for typedefs

The accessibility level of a typedef or using declaration in a
struct or class was being lost when producing debug information.

Reviewed By: dblaikie

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

Added: 


Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp
clang/test/CodeGenCXX/debug-info-access.cpp
llvm/include/llvm/IR/DIBuilder.h
llvm/lib/IR/DIBuilder.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 73cb80816fae7..a5cc5930728aa 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1283,6 +1283,33 @@ llvm::DIType *CGDebugInfo::CreateType(const 
TemplateSpecializationType *Ty,
 getDeclContextDescriptor(AliasDecl));
 }
 
+/// Convert an AccessSpecifier into the corresponding DINode flag.
+/// As an optimization, return 0 if the access specifier equals the
+/// default for the containing type.
+static llvm::DINode::DIFlags getAccessFlag(AccessSpecifier Access,
+   const RecordDecl *RD) {
+  AccessSpecifier Default = clang::AS_none;
+  if (RD && RD->isClass())
+Default = clang::AS_private;
+  else if (RD && (RD->isStruct() || RD->isUnion()))
+Default = clang::AS_public;
+
+  if (Access == Default)
+return llvm::DINode::FlagZero;
+
+  switch (Access) {
+  case clang::AS_private:
+return llvm::DINode::FlagPrivate;
+  case clang::AS_protected:
+return llvm::DINode::FlagProtected;
+  case clang::AS_public:
+return llvm::DINode::FlagPublic;
+  case clang::AS_none:
+return llvm::DINode::FlagZero;
+  }
+  llvm_unreachable("unexpected access enumerator");
+}
+
 llvm::DIType *CGDebugInfo::CreateType(const TypedefType *Ty,
   llvm::DIFile *Unit) {
   llvm::DIType *Underlying =
@@ -1298,10 +1325,16 @@ llvm::DIType *CGDebugInfo::CreateType(const TypedefType 
*Ty,
   uint32_t Align = getDeclAlignIfRequired(Ty->getDecl(), CGM.getContext());
   // Typedefs are derived from some other type.
   llvm::DINodeArray Annotations = CollectBTFDeclTagAnnotations(Ty->getDecl());
+
+  llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero;
+  const DeclContext *DC = Ty->getDecl()->getDeclContext();
+  if (isa(DC))
+Flags = getAccessFlag(Ty->getDecl()->getAccess(), cast(DC));
+
   return DBuilder.createTypedef(Underlying, Ty->getDecl()->getName(),
 getOrCreateFile(Loc), getLineNumber(Loc),
 getDeclContextDescriptor(Ty->getDecl()), Align,
-Annotations);
+Flags, Annotations);
 }
 
 static unsigned getDwarfCC(CallingConv CC) {
@@ -1395,33 +1428,6 @@ llvm::DIType *CGDebugInfo::CreateType(const FunctionType 
*Ty,
   return F;
 }
 
-/// Convert an AccessSpecifier into the corresponding DINode flag.
-/// As an optimization, return 0 if the access specifier equals the
-/// default for the containing type.
-static llvm::DINode::DIFlags getAccessFlag(AccessSpecifier Access,
-   const RecordDecl *RD) {
-  AccessSpecifier Default = clang::AS_none;
-  if (RD && RD->isClass())
-Default = clang::AS_private;
-  else if (RD && (RD->isStruct() || RD->isUnion()))
-Default = clang::AS_public;
-
-  if (Access == Default)
-return llvm::DINode::FlagZero;
-
-  switch (Access) {
-  case clang::AS_private:
-return llvm::DINode::FlagPrivate;
-  case clang::AS_protected:
-return llvm::DINode::FlagProtected;
-  case clang::AS_public:
-return llvm::DINode::FlagPublic;
-  case clang::AS_none:
-return llvm::DINode::FlagZero;
-  }
-  llvm_unreachable("unexpected access enumerator");
-}
-
 llvm::DIType *CGDebugInfo::createBitFieldType(const FieldDecl *BitFieldDecl,
   llvm::DIScope *RecordTy,
   const RecordDecl *RD) {

diff  --git a/clang/test/CodeGenCXX/debug-info-access.cpp 
b/clang/test/CodeGenCXX/debug-info-access.cpp
index cd5328be0a85c..9f2c044843d0f 100644
--- a/clang/test/CodeGenCXX/debug-info-access.cpp
+++ b/clang/test/CodeGenCXX/debug-info-access.cpp
@@ -9,7 +9,6 @@ struct A {
   static int pub_default_static;
 };
 
-
 // CHECK: !DIDerivedType(tag: DW_TAG_inheritance,{{.*}} baseType: 
![[A]],{{.*}} flags: DIFlagPublic, extraData: i32 0)
 class B : public A {
 public:
@@ -17,9 +16,17 @@ class B : public A {
   void pub();
   // CHECK-DAG: !DIDerivedType(tag: DW_TAG_member, name: 

[clang] 6bf6730 - [clang] fix generation of .debug_aranges with LTO

2022-09-13 Thread David Blaikie via cfe-commits

Author: Azat Khuzhin
Date: 2022-09-13T22:33:56Z
New Revision: 6bf6730ac55e064edf46915ebba02e9c716f48e8

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

LOG: [clang] fix generation of .debug_aranges with LTO

Right now in case of LTO the section is not emited:

$ cat test.c
void __attribute__((optnone)) bar()
{
}
void __attribute__((optnone)) foo()
{
bar();
}
int main()
{
foo();
}

$ clang -flto=thin -gdwarf-aranges -g -O3 test.c
$ eu-readelf -waranges a.out  | fgrep -c -e foo -e bar
0

$ clang -gdwarf-aranges -g -O3 test.c
$ eu-readelf -waranges a.out  | fgrep -c -e foo -e bar
2

Fix this by passing explicitly -mllvm -generate-arange-section.

P.S. although this looks like a hack, since none of -mllvm was passed to
the lld before.

Signed-off-by: Azat Khuzhin 
Suggested-by: OCHyams 

Reviewed By: dblaikie

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/test/Driver/debug-options.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 22025d95e7c8f..c61fcfc946b89 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -506,6 +506,19 @@ void tools::addLTOOptions(const ToolChain , 
const ArgList ,
 Suffix,
 Plugin);
 CmdArgs.push_back(Args.MakeArgString(Plugin));
+  } else {
+// NOTE:
+// - it is not possible to use lld for PS4
+// - addLTOOptions() is not used for PS5
+// Hence no need to handle SCE (like in Clang.cpp::renderDebugOptions()).
+//
+// But note, this solution is far from perfect, better to encode it into IR
+// metadata, but this may not be worth it, since it looks like aranges is
+// on the way out.
+if (Args.hasArg(options::OPT_gdwarf_aranges)) {
+  CmdArgs.push_back(Args.MakeArgString("-mllvm"));
+  CmdArgs.push_back(Args.MakeArgString("-generate-arange-section"));
+}
   }
 
   // Try to pass driver level flags relevant to LTO code generation down to

diff  --git a/clang/test/Driver/debug-options.c 
b/clang/test/Driver/debug-options.c
index 04004716aa501..2da192d098e24 100644
--- a/clang/test/Driver/debug-options.c
+++ b/clang/test/Driver/debug-options.c
@@ -246,7 +246,11 @@
 // RUN: %clang -### -c -glldb %s 2>&1 | FileCheck -check-prefix=NOPUB %s
 // RUN: %clang -### -c -glldb -gno-pubnames %s 2>&1 | FileCheck 
-check-prefix=NOPUB %s
 //
-// RUN: %clang -### -c -gdwarf-aranges %s 2>&1 | FileCheck 
-check-prefix=GARANGE %s
+// RUN: %clang -### -target x86_64-unknown-linux -c -gdwarf-aranges %s 2>&1 | 
FileCheck -check-prefix=GARANGE %s
+// RUN: %clang -### -target x86_64-unknown-linux -flto -gdwarf-aranges %s 2>&1 
| FileCheck -check-prefix=LDGARANGE %s
+// RUN: %clang -### -target x86_64-unknown-linux -flto=thin -gdwarf-aranges %s 
2>&1 | FileCheck -check-prefix=LDGARANGE %s
+// RUN: %clang -### -target x86_64-unknown-linux -fuse-ld=lld -flto 
-gdwarf-aranges %s 2>&1 | FileCheck -check-prefix=LLDGARANGE %s
+// RUN: %clang -### -target x86_64-unknown-linux -fuse-ld=lld -flto=thin 
-gdwarf-aranges %s 2>&1 | FileCheck -check-prefix=LLDGARANGE %s
 //
 // RUN: %clang -### -fdebug-types-section -target x86_64-unknown-linux %s 2>&1 
\
 // RUN:| FileCheck -check-prefix=FDTS %s
@@ -371,6 +375,8 @@
 // NORNGBSE-NOT: -fdebug-ranges-base-address
 //
 // GARANGE-DAG: -generate-arange-section
+// LDGARANGE-NOT: {{".*lld.*"}} {{.*}} "-generate-arange-section"
+// LLDGARANGE: {{".*lld.*"}} {{.*}} "-generate-arange-section"
 //
 // FDTS: "-mllvm" "-generate-type-units"
 // FDTSE: error: unsupported option '-fdebug-types-section' for target 
'x86_64-apple-darwin'



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


Re: [clang] b7a7aee - [clang] Qualify auto in range-based for loops (NFC)

2022-09-12 Thread David Blaikie via cfe-commits
On Sat, Sep 10, 2022 at 3:01 PM Kazu Hirata  wrote:
>
> Thank you Aaron and David for your inputs.
>
> First and foremost, I apologize if I made your job harder by increasing the 
> number of commits you have to peel to get to the real author.
>
> I hear that we are moving toward github pull requests.  A casual search tells 
> me that there are some add-ons to integrate clang-tidy into the code review 
> platform, so I am hoping we can use something like that to get each patch 
> right first time.
>
> Going forward, I'll take git churn and the difficulty of backsliding as big 
> factors in doing future clenaups.  For example, it's probably a good idea to 
> delete a function that hasn't been used for many years (excluding dump 
> functions and such).  Library standardization (like the recent removal of 
> llvm::array_lengthof in favor of std::size) is less good in terms of git 
> churn, but it's very unlikely for somebody to re-introduce 
> llvm::array_lengthof.

I think API deprecations (where the API can be completely removed
eventually, and marked as deprecated/all in-tree usage removed within
O(weeks/months)) especially for cases like the core/support libraries
with relatively many uses, and relatively small APIs are great - if we
get into the territory of naming convention cleanup, that gets more
debatable because there's wide APIs with many naming violations and
then we need more community discussion about what direction we're
going (there are multiple lingering naming conventions, some
discussions about moving to different ones in the future, so maybe
churn to meet the current letter of the style guide would be better
spent after changing the style guide with those directions in mind,
etc).

For stylistic things like range-based-for conversion, const auto*, etc
- yeah, there's some wriggle room depending on how uncontentious the
conversion is, I think.

(there's also some way to mark certain changes as ignorable by git?
Maybe using that more frequently would help lower the cost of these
sort of changes - broader discussion on discourse about ways to
enable/lower the cost of these sort of changes would probably be good
- I think as much as we can make these sort of changes cheaper/less
problematic, to make them more encouraged, is a really good thing to
do)

>
> Thanks,
>
> Kazu Hirata
>
>
> On Fri, Sep 9, 2022 at 5:27 AM Aaron Ballman  wrote:
>>
>> On Thu, Sep 8, 2022 at 12:37 PM David Blaikie  wrote:
>> >
>> > Mixed feelings here - Kazu's made a lot of cleanup/stylistic changes
>> > across the LLVM project for a while now, most, at least I think, are
>> > quite welcome (things like switching to range-based-for, std
>> > algorithms over llvm ones, llvm algorithms over manually written
>> > loops, etc). But yeah, there's some threshold below which the churn
>> > might not be worth the benefit - especially if the change doesn't come
>> > along with tooling to enforce the invariant is maintained in the
>> > future (if it's easy to make mistakes like this one - we'll regress it
>> > and need to do cleanup again in the future)
>>
>> Thanks for speaking up, because I also waffled a bit on whether I
>> called this out or not. :-)
>>
>> > Also, for this particular one, I wonder if in some cases this sort of
>> > automatic transformation isn't ideal - if something is a pointer, but
>> > that's an implementation detail, rather than an intentional feature of
>> > an API (eg: the pointer-ness might be hidden behind a typedef and used
>> > as an opaque handle, without any dereferencing, etc)
>>
>> Agreed.
>>
>> > I think it'd be really good to have some discussion on discourse about
>> > if/how some of these cleanups could be formed into a way to
>> > enforce/encourage the invariant to be maintained going forward -
>> > clang-tidy (assuming that's the basis for the tooling Kazu's using to
>> > make these changes in the first place) integration into the LLVM build
>> > in some way, etc.
>>
>> I think that's a good idea! We want to encourage cleanups, but we
>> don't want to encourage churn, and I think it's somewhat subjective
>> where to draw that line. Having some more community awareness around
>> that would be beneficial. I'm especially interested in how we balance
>> between making incremental style improvements to the project and
>> keeping our git blame logs useful. I'm seeing a lot more git blames
>> that require several steps to get to an interesting commit because of
>> the number of NFCs and reverts/recommits. Unfortunately, the tooling
>> around viewing git blames of large files (like Clang tends to have)
>> makes these sorts of commits surprisingly painful when you do have to
>> dig to see where changes came from. (So I find myself having far less
>> concern when TransGCAttrs.cpp (~350LoC) gets a cleanup like this
>> compared to SemaExpr.cpp (~21kLoC), which suggests to me we should
>> maybe strongly consider splitting more of these massive files up so
>> that churn is less painful.)
>>
>> > & yeah, 

Re: [clang] 0e5813b - [clang][NFC] silences warnings

2022-09-08 Thread David Blaikie via cfe-commits
On Fri, Aug 26, 2022 at 2:10 PM Christopher Di Bella via cfe-commits
 wrote:
>
>
> Author: Abraham Corea Diaz
> Date: 2022-08-26T21:09:39Z
> New Revision: 0e5813b88e50576940070003e093d696390a6959
>
> URL: 
> https://github.com/llvm/llvm-project/commit/0e5813b88e50576940070003e093d696390a6959
> DIFF: 
> https://github.com/llvm/llvm-project/commit/0e5813b88e50576940070003e093d696390a6959.diff
>
> LOG: [clang][NFC] silences warnings
>
> * removes unused data member `OS` from `SARIFDiagnostic`
> * flags `Filename` variable as currently unused
>
> This is a follow-up to D131632.
>
> Added:
>
>
> Modified:
> clang/include/clang/Frontend/SARIFDiagnostic.h
> clang/lib/Frontend/SARIFDiagnostic.cpp
>
> Removed:
>
>
>
> 
> diff  --git a/clang/include/clang/Frontend/SARIFDiagnostic.h 
> b/clang/include/clang/Frontend/SARIFDiagnostic.h
> index bd0f1df9aa58..ec1d0b8e6a7c 100644
> --- a/clang/include/clang/Frontend/SARIFDiagnostic.h
> +++ b/clang/include/clang/Frontend/SARIFDiagnostic.h
> @@ -55,8 +55,6 @@ class SARIFDiagnostic : public DiagnosticRenderer {
>StringRef ModuleName) override;
>
>  private:
> -  raw_ostream 
> -
>// Shared between SARIFDiagnosticPrinter and this renderer.
>SarifDocumentWriter *Writer;
>
>
> diff  --git a/clang/lib/Frontend/SARIFDiagnostic.cpp 
> b/clang/lib/Frontend/SARIFDiagnostic.cpp
> index 2bcbd5cf34f2..f0f32a179825 100644
> --- a/clang/lib/Frontend/SARIFDiagnostic.cpp
> +++ b/clang/lib/Frontend/SARIFDiagnostic.cpp
> @@ -33,7 +33,7 @@ namespace clang {
>  SARIFDiagnostic::SARIFDiagnostic(raw_ostream , const LangOptions 
> ,
>   DiagnosticOptions *DiagOpts,
>   SarifDocumentWriter *Writer)
> -: DiagnosticRenderer(LangOpts, DiagOpts), OS(OS), Writer(Writer) {}
> +: DiagnosticRenderer(LangOpts, DiagOpts), Writer(Writer) {}
>
>  // FIXME(llvm-project/issues/57323): Refactor Diagnostic classes.
>  void SARIFDiagnostic::emitDiagnosticMessage(
> @@ -71,7 +71,8 @@ SarifResult SARIFDiagnostic::addLocationToResult(
>  FileID FID = Loc.getFileID();
>  if (FID.isValid()) {
>if (const FileEntry *FE = Loc.getFileEntry()) {
> -emitFilename(FE->getName(), Loc.getManager());
> +[[gnu::unused]] llvm::StringRef Filename =

Does this not cause warnings on an MSVC build for an unknown
attribute? (there's a whole issue with unknown attributes and how to
diagnose them)

I think it's probably best in general to leave the variable out until it's used.

> +emitFilename(FE->getName(), Loc.getManager());
>  // FIXME(llvm-project/issues/57366): File-only locations
>}
>  }
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [clang] b7a7aee - [clang] Qualify auto in range-based for loops (NFC)

2022-09-08 Thread David Blaikie via cfe-commits
Mixed feelings here - Kazu's made a lot of cleanup/stylistic changes
across the LLVM project for a while now, most, at least I think, are
quite welcome (things like switching to range-based-for, std
algorithms over llvm ones, llvm algorithms over manually written
loops, etc). But yeah, there's some threshold below which the churn
might not be worth the benefit - especially if the change doesn't come
along with tooling to enforce the invariant is maintained in the
future (if it's easy to make mistakes like this one - we'll regress it
and need to do cleanup again in the future)

Also, for this particular one, I wonder if in some cases this sort of
automatic transformation isn't ideal - if something is a pointer, but
that's an implementation detail, rather than an intentional feature of
an API (eg: the pointer-ness might be hidden behind a typedef and used
as an opaque handle, without any dereferencing, etc)

I think it'd be really good to have some discussion on discourse about
if/how some of these cleanups could be formed into a way to
enforce/encourage the invariant to be maintained going forward -
clang-tidy (assuming that's the basis for the tooling Kazu's using to
make these changes in the first place) integration into the LLVM build
in some way, etc.

& yeah, adding the `const` too if/when that's relevant would've
improved the quality/value/justification for a cleanup change like
this.

On Sun, Sep 4, 2022 at 5:58 AM Aaron Ballman via cfe-commits
 wrote:
>
> FWIW, sweeping NFC changes like this cause a fair amount of code churn
> (which makes tools like git blame a bit harder to use) for a
> relatively small improvement to code readability, which is why our
> developer policy asks that you "Avoid committing formatting- or
> whitespace-only changes outside of code you plan to make subsequent
> changes to." In the future, I'd caution against doing such large-scale
> sweeping NFC changes outside of areas you're actively working on
> unless there's some wider discussion with the community first. That
> said, all of your changes are all improvements, so thank you for them!
>
> Some of the changes you made would have ideally made it more clear
> when the deduced type is a pointer to a const object instead of hiding
> the qualifier behind the deduction. I've pointed out a couple such
> places below, but don't feel obligated to go back and change anything
> unless you're going to be touching other code in the area.
>
> ~Aaron
>
>
> On Sun, Sep 4, 2022 at 2:27 AM Kazu Hirata via cfe-commits
>  wrote:
> >
> >
> > Author: Kazu Hirata
> > Date: 2022-09-03T23:27:27-07:00
> > New Revision: b7a7aeee90cffefd0f73b8d9f44ab4d1d5123d05
> >
> > URL: 
> > https://github.com/llvm/llvm-project/commit/b7a7aeee90cffefd0f73b8d9f44ab4d1d5123d05
> > DIFF: 
> > https://github.com/llvm/llvm-project/commit/b7a7aeee90cffefd0f73b8d9f44ab4d1d5123d05.diff
> >
> > LOG: [clang] Qualify auto in range-based for loops (NFC)
> >
> > Added:
> >
> >
> > Modified:
> > clang/lib/ARCMigrate/ObjCMT.cpp
> > clang/lib/ARCMigrate/TransGCAttrs.cpp
> > clang/lib/AST/ASTContext.cpp
> > clang/lib/AST/ASTImporter.cpp
> > clang/lib/AST/Decl.cpp
> > clang/lib/AST/DeclObjC.cpp
> > clang/lib/AST/ODRHash.cpp
> > clang/lib/AST/OpenMPClause.cpp
> > clang/lib/AST/StmtProfile.cpp
> > clang/lib/AST/Type.cpp
> > clang/lib/Analysis/CFG.cpp
> > clang/lib/Analysis/ThreadSafetyCommon.cpp
> > clang/lib/CodeGen/CGBlocks.cpp
> > clang/lib/CodeGen/CGCall.cpp
> > clang/lib/CodeGen/CGClass.cpp
> > clang/lib/CodeGen/CGDebugInfo.cpp
> > clang/lib/CodeGen/CGDeclCXX.cpp
> > clang/lib/CodeGen/CGExpr.cpp
> > clang/lib/CodeGen/CGObjCGNU.cpp
> > clang/lib/CodeGen/CGObjCMac.cpp
> > clang/lib/CodeGen/CodeGenFunction.cpp
> > clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
> > clang/lib/CodeGen/SwiftCallingConv.cpp
> > clang/lib/Driver/Compilation.cpp
> > clang/lib/Driver/Driver.cpp
> > clang/lib/Driver/ToolChains/Clang.cpp
> > clang/lib/Driver/ToolChains/CommonArgs.cpp
> > clang/lib/Driver/ToolChains/Gnu.cpp
> > clang/lib/Driver/ToolChains/HIPAMD.cpp
> > clang/lib/Format/Format.cpp
> > clang/lib/Frontend/FrontendActions.cpp
> > clang/lib/Index/USRGeneration.cpp
> > clang/lib/Sema/IdentifierResolver.cpp
> > clang/lib/Sema/Sema.cpp
> > clang/lib/Sema/SemaCodeComplete.cpp
> > clang/lib/Sema/SemaDecl.cpp
> > clang/lib/Sema/SemaDeclAttr.cpp
> > clang/lib/Sema/SemaDeclCXX.cpp
> > clang/lib/Sema/SemaDeclObjC.cpp
> > clang/lib/Sema/SemaExpr.cpp
> > clang/lib/Sema/SemaExprCXX.cpp
> > clang/lib/Sema/SemaInit.cpp
> > clang/lib/Sema/SemaLambda.cpp
> > clang/lib/Sema/SemaLookup.cpp
> > clang/lib/Sema/SemaObjCProperty.cpp
> > clang/lib/Sema/SemaOpenMP.cpp
> > clang/lib/Sema/SemaOverload.cpp
> > clang/lib/Sema/SemaTemplateDeduction.cpp
> > clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
> > 

Re: [clang] acaf6b9 - [NFC] Add [[maybe_unused]] to avoid warning in gcc9

2022-08-23 Thread David Blaikie via cfe-commits
Thanks for the link - fair enough. We'll see how ubiquitous the
constexpr-creating-sort-of-unused-variables situation is. If it comes
up a lot we might want to disable the warning for GCC 9.

On Mon, Aug 22, 2022 at 7:58 PM chuanqi.xcq  wrote:
>
> Hi David,
>
>   This is the reproduce link from godbolt: https://godbolt.org/z/nEc7WYKnq. 
> It is weird that it requries `-Wunused-but-set-parameter` instead of 
> `-Wunused-parameter`. The bug exists in all versions of GCC9. And it gets 
> fixed in GCC10 and later. Personally, I feel it looks better to suppress the 
> warning for GCC9.
>
> Thanks,
> Chuanqi
>
> --
> From:David Blaikie 
> Send Time:2022年8月23日(星期二) 07:22
> To:Chuanqi Xu ; Chuanqi Xu 
> Cc:cfe-commits 
> Subject:Re: [clang] acaf6b9 - [NFC] Add [[maybe_unused]] to avoid warning in 
> gcc9
>
> Seems like a bug in the GCC9 warning - any chance we can disable it?
> (is it fixed in later versions of GCC?)
>
> I can't seem to reproduce this with godbolt at least with basic
> examples - it'd be good to know how bad the thing is we're working
> around so we know if we want to keep working around it, or suppress
> the warning for certainly compiler versions entirely.
>
> On Thu, Aug 18, 2022 at 11:43 PM Chuanqi Xu via cfe-commits
>  wrote:
> >
> >
> > Author: Chuanqi Xu
> > Date: 2022-08-19T14:43:22+08:00
> > New Revision: acaf6b9dc07de3c12c8a1a55fd8674bca547a917
> >
> > URL: 
> > https://github.com/llvm/llvm-project/commit/acaf6b9dc07de3c12c8a1a55fd8674bca547a917
> > DIFF: 
> > https://github.com/llvm/llvm-project/commit/acaf6b9dc07de3c12c8a1a55fd8674bca547a917.diff
> >
> > LOG: [NFC] Add [[maybe_unused]] to avoid warning in gcc9
> >
> > GCC9 may issue warning for the 'unused' parameters in if constexpr.
> > This commit try to fix it by adding the [[maybe_unused]] attribute.
> >
> > Added:
> >
> >
> > Modified:
> > clang/include/clang/AST/RecursiveASTVisitor.h
> >
> > Removed:
> >
> >
> >
> > 
> > diff  --git a/clang/include/clang/AST/RecursiveASTVisitor.h 
> > b/clang/include/clang/AST/RecursiveASTVisitor.h
> > index 91baad51b26e..bd7fadb87c5f 100644
> > --- a/clang/include/clang/AST/RecursiveASTVisitor.h
> > +++ b/clang/include/clang/AST/RecursiveASTVisitor.h
> > @@ -73,7 +73,8 @@ struct has_same_member_pointer_type > (U::*)(P...)>
> >  /// are pointers to the same non-static member function.
> >  template 
> >  LLVM_ATTRIBUTE_ALWAYS_INLINE LLVM_ATTRIBUTE_NODEBUG auto
> > -isSameMethod(FirstMethodPtrTy FirstMethodPtr, SecondMethodPtrTy 
> > SecondMethodPtr)
> > +isSameMethod([[maybe_unused]] FirstMethodPtrTy FirstMethodPtr,
> > + [[maybe_unused]] SecondMethodPtrTy SecondMethodPtr)
> >  -> bool {
> >if constexpr (has_same_member_pointer_type >   SecondMethodPtrTy>::value)
> >
> >
> >
> > ___
> > cfe-commits mailing list
> > cfe-commits@lists.llvm.org
> > https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [clang] acaf6b9 - [NFC] Add [[maybe_unused]] to avoid warning in gcc9

2022-08-22 Thread David Blaikie via cfe-commits
Seems like a bug in the GCC9 warning - any chance we can disable it?
(is it fixed in later versions of GCC?)

I can't seem to reproduce this with godbolt at least with basic
examples - it'd be good to know how bad the thing is we're working
around so we know if we want to keep working around it, or suppress
the warning for certainly compiler versions entirely.

On Thu, Aug 18, 2022 at 11:43 PM Chuanqi Xu via cfe-commits
 wrote:
>
>
> Author: Chuanqi Xu
> Date: 2022-08-19T14:43:22+08:00
> New Revision: acaf6b9dc07de3c12c8a1a55fd8674bca547a917
>
> URL: 
> https://github.com/llvm/llvm-project/commit/acaf6b9dc07de3c12c8a1a55fd8674bca547a917
> DIFF: 
> https://github.com/llvm/llvm-project/commit/acaf6b9dc07de3c12c8a1a55fd8674bca547a917.diff
>
> LOG: [NFC] Add [[maybe_unused]] to avoid warning in gcc9
>
> GCC9 may issue warning for the 'unused' parameters in if constexpr.
> This commit try to fix it by adding the [[maybe_unused]] attribute.
>
> Added:
>
>
> Modified:
> clang/include/clang/AST/RecursiveASTVisitor.h
>
> Removed:
>
>
>
> 
> diff  --git a/clang/include/clang/AST/RecursiveASTVisitor.h 
> b/clang/include/clang/AST/RecursiveASTVisitor.h
> index 91baad51b26e..bd7fadb87c5f 100644
> --- a/clang/include/clang/AST/RecursiveASTVisitor.h
> +++ b/clang/include/clang/AST/RecursiveASTVisitor.h
> @@ -73,7 +73,8 @@ struct has_same_member_pointer_type (U::*)(P...)>
>  /// are pointers to the same non-static member function.
>  template 
>  LLVM_ATTRIBUTE_ALWAYS_INLINE LLVM_ATTRIBUTE_NODEBUG auto
> -isSameMethod(FirstMethodPtrTy FirstMethodPtr, SecondMethodPtrTy 
> SecondMethodPtr)
> +isSameMethod([[maybe_unused]] FirstMethodPtrTy FirstMethodPtr,
> + [[maybe_unused]] SecondMethodPtrTy SecondMethodPtr)
>  -> bool {
>if constexpr (has_same_member_pointer_type   SecondMethodPtrTy>::value)
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] d4e0fe6 - Simplify RAV isSameMethod with constexpr if

2022-08-18 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2022-08-19T04:00:21Z
New Revision: d4e0fe62b1aa090527c0cc289cdf3eef0370f064

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

LOG: Simplify RAV isSameMethod with constexpr if

Owing to the large number of instantiations of this function, this small
change has a small but meaningful difference on the total size of
(especially a debug) build of clang at -O0:
```
FILE SIZEVM SIZE
 --  --
  +0.9% +96.9Ki  +0.9% +96.9Ki.data.rel.ro
  +0.7% +96.7Ki  +0.7% +96.7Ki.rela.dyn
  +0.0% +18.3Ki  +0.0% +18.3Ki.rodata
  +0.0%+324  [ = ]   0[2 Others]
  -0.2%-392  -0.2%-392.gnu.version
  -0.0%-441  [ = ]   0.debug_abbrev
  -0.1%-980  -0.1%-980.gnu.hash
  -0.2% -1.53Ki  -0.2% -1.53Ki.hash
  -0.2% -4.59Ki  -0.2% -4.59Ki.dynsym
  -0.1% -10.5Ki  [ = ]   0.debug_rnglists
  -0.6% -59.0Ki  -0.6% -59.0Ki.dynstr
  -0.2%  -191Ki  [ = ]   0.debug_str_offsets
  -3.0%  -233Ki  -3.0%  -233Ki.eh_frame_hdr
  -0.7%  -244Ki  [ = ]   0.debug_addr
  -2.9%  -699Ki  [ = ]   0.symtab
  -0.6%  -884Ki  [ = ]   0.debug_line
  -3.0%  -932Ki  -3.0%  -932Ki.eh_frame
  -1.0% -1.48Mi  -1.0% -1.48Mi.text
  -0.6% -2.75Mi  [ = ]   0.debug_info
  -7.3% -8.61Mi  [ = ]   0.strtab
  -7.3% -17.2Mi  [ = ]   0.debug_str
  -2.4% -33.0Mi  -0.9% -2.47MiTOTAL
```

If anyone's got other ideas for how to reduce this further - it's not
especially important, I just came across it while investigating a debug
info size regression, but thought it was interesting enough to poke
around at.

Added: 


Modified: 
clang/include/clang/AST/RecursiveASTVisitor.h

Removed: 




diff  --git a/clang/include/clang/AST/RecursiveASTVisitor.h 
b/clang/include/clang/AST/RecursiveASTVisitor.h
index 6c6d5402d5d12..91baad51b26ea 100644
--- a/clang/include/clang/AST/RecursiveASTVisitor.h
+++ b/clang/include/clang/AST/RecursiveASTVisitor.h
@@ -69,30 +69,16 @@ template 
 struct has_same_member_pointer_type
 : std::true_type {};
 
-template  struct is_same_method_impl {
-  template 
-  static bool isSameMethod(FirstMethodPtrTy FirstMethodPtr,
-   SecondMethodPtrTy SecondMethodPtr) {
-return false;
-  }
-};
-
-template <> struct is_same_method_impl {
-  template 
-  static bool isSameMethod(FirstMethodPtrTy FirstMethodPtr,
-   SecondMethodPtrTy SecondMethodPtr) {
-return FirstMethodPtr == SecondMethodPtr;
-  }
-};
-
 /// Returns true if and only if \p FirstMethodPtr and \p SecondMethodPtr
 /// are pointers to the same non-static member function.
 template 
-bool isSameMethod(FirstMethodPtrTy FirstMethodPtr,
-  SecondMethodPtrTy SecondMethodPtr) {
-  return is_same_method_impl::value>::isSameMethod(FirstMethodPtr, 
SecondMethodPtr);
+LLVM_ATTRIBUTE_ALWAYS_INLINE LLVM_ATTRIBUTE_NODEBUG auto
+isSameMethod(FirstMethodPtrTy FirstMethodPtr, SecondMethodPtrTy 
SecondMethodPtr)
+-> bool {
+  if constexpr (has_same_member_pointer_type::value)
+return FirstMethodPtr == SecondMethodPtr;
+  return false;
 }
 
 } // end namespace detail



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


[clang] 06c70e9 - DebugInfo: Remove auto return type representation support

2022-08-16 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2022-08-17T00:35:05Z
New Revision: 06c70e9b998ca289630ee1629ec09b6dd51b29b9

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

LOG: DebugInfo: Remove auto return type representation support

Seems this complicated lldb sufficiently for some cases that it hasn't
been worth supporting/fixing there - and it so far hasn't provided any
new use cases/value for debug info consumers, so let's remove it until
someone has a use case for it.

(side note: the original implementation of this still had a bug (I
should've caught it in review) that we still didn't produce
auto-returning function declarations in types where the function wasn't
instantiatied (that requires a fix to remove the `if
getContainedAutoType` condition in
`CGDebugInfo::CollectCXXMemberFunctions` - without that, auto returning
functions were still being handled the same as member function templates
and special member functions - never added to the member list, only
attached to the type via the declaration chain from the definition)

Further discussion about this in D123319

This reverts commit 5ff992bca208a0e37ca6338fc735aec6aa848b72: [DEBUG-INFO] 
Change how we handle auto return types for lambda operator() to be consistent 
with gcc

This reverts commit c83602fdf51b2692e3bacb06bf861f20f74e987f: [DWARF5][clang]: 
Added support for DebugInfo generation for auto return type for C++ member 
functions.

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

Added: 


Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/CGDebugInfo.h
clang/test/CodeGenCXX/debug-info-auto-return.cpp

Removed: 
clang/test/CodeGenCXX/no_auto_return_lambda.cpp



diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 0469de766d78c..3d78a13d30aa8 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -883,10 +883,6 @@ llvm::DIType *CGDebugInfo::CreateType(const BuiltinType 
*BT) {
   return DBuilder.createBasicType(BTName, Size, Encoding);
 }
 
-llvm::DIType *CGDebugInfo::CreateType(const AutoType *Ty) {
-  return DBuilder.createUnspecifiedType("auto");
-}
-
 llvm::DIType *CGDebugInfo::CreateType(const BitIntType *Ty) {
 
   StringRef Name = Ty->isUnsigned() ? "unsigned _BitInt" : "_BitInt";
@@ -1647,18 +1643,16 @@ void CGDebugInfo::CollectRecordFields(
 
 llvm::DISubroutineType *
 CGDebugInfo::getOrCreateMethodType(const CXXMethodDecl *Method,
-   llvm::DIFile *Unit, bool decl) {
-  const auto *Func = Method->getType()->castAs();
+   llvm::DIFile *Unit) {
+  const FunctionProtoType *Func = 
Method->getType()->getAs();
   if (Method->isStatic())
 return cast_or_null(
 getOrCreateType(QualType(Func, 0), Unit));
-  return getOrCreateInstanceMethodType(Method->getThisType(), Func, Unit, 
decl);
+  return getOrCreateInstanceMethodType(Method->getThisType(), Func, Unit);
 }
 
-llvm::DISubroutineType *
-CGDebugInfo::getOrCreateInstanceMethodType(QualType ThisPtr,
-   const FunctionProtoType *Func,
-   llvm::DIFile *Unit, bool decl) {
+llvm::DISubroutineType *CGDebugInfo::getOrCreateInstanceMethodType(
+QualType ThisPtr, const FunctionProtoType *Func, llvm::DIFile *Unit) {
   FunctionProtoType::ExtProtoInfo EPI = Func->getExtProtoInfo();
   Qualifiers  = EPI.TypeQuals;
   Qc.removeConst();
@@ -1681,20 +1675,9 @@ CGDebugInfo::getOrCreateInstanceMethodType(QualType 
ThisPtr,
   assert(Args.size() && "Invalid number of arguments!");
 
   SmallVector Elts;
+
   // First element is always return type. For 'void' functions it is NULL.
-  QualType temp = Func->getReturnType();
-  if (temp->getTypeClass() == Type::Auto && decl) {
-const AutoType *AT = cast(temp);
-
-// It may be tricky in some cases to link the specification back the lambda
-// call operator and so we skip emitting "auto" for lambdas. This is
-// consistent with gcc as well.
-if (AT->isDeduced() && ThisPtr->getPointeeCXXRecordDecl()->isLambda())
-  Elts.push_back(getOrCreateType(AT->getDeducedType(), Unit));
-else
-  Elts.push_back(CreateType(AT));
-  } else
-Elts.push_back(Args[0]);
+  Elts.push_back(Args[0]);
 
   // "this" pointer is always first argument.
   const CXXRecordDecl *RD = ThisPtr->getPointeeCXXRecordDecl();
@@ -1747,7 +1730,7 @@ llvm::DISubprogram *CGDebugInfo::CreateCXXMemberFunction(
   isa(Method) || isa(Method);
 
   StringRef MethodName = getFunctionName(Method);
-  llvm::DISubroutineType *MethodTy = getOrCreateMethodType(Method, Unit, true);
+  llvm::DISubroutineType *MethodTy = getOrCreateMethodType(Method, Unit);
 
   // Since a single ctor/dtor corresponds 

[clang] 4bb192b - DebugInfo: Test vtable homing overriding ctor homing only on itanium since msvc ABI doesn't home vtables

2022-07-27 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2022-07-28T00:45:00Z
New Revision: 4bb192b846854ab1dc49a2e4b2a2717a4e3a9b1e

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

LOG: DebugInfo: Test vtable homing overriding ctor homing only on itanium since 
msvc ABI doesn't home vtables

Added: 


Modified: 
clang/test/CodeGenCXX/debug-info-limited-ctor.cpp

Removed: 




diff  --git a/clang/test/CodeGenCXX/debug-info-limited-ctor.cpp 
b/clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
index d17e3a142ad7..ac53cace075c 100644
--- a/clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
+++ b/clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -debug-info-kind=constructor -emit-llvm %s -o - | FileCheck 
%s
+// RUN: %clang_cc1 -debug-info-kind=constructor -triple x86_64-linux-gnu 
-emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=ITANIUM %s
 
 // CHECK-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: 
"A"{{.*}}DIFlagTypePassByValue
 struct A {
@@ -87,4 +88,4 @@ struct VTableAndCtor {
 VTableAndCtor::VTableAndCtor() {
 }
 
-// CHECK-DAG: !DICompositeType({{.*}}name: "VTableAndCtor", {{.*}}flags: 
DIFlagFwdDecl
+// ITANIUM-DAG: !DICompositeType({{.*}}name: "VTableAndCtor", {{.*}}flags: 
DIFlagFwdDecl



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


Re: [clang] 4821508 - Revert "DebugInfo: Fully integrate ctor type homing into 'limited' debug info"

2022-07-27 Thread David Blaikie via cfe-commits
Excuse the delay - yeah, pulled out the fix in
4e719e0f16933a8945a4e85db39fdad5afbede36

On Fri, Jul 1, 2022 at 7:21 AM Robinson, Paul  wrote:
>
> Hi Dave,
>
> The original commit message included
> Also fix a bug I found along the way that was causing ctor type homing
> to kick in even when something could be vtable homed
>
> Is it reasonable to fix that without removing ctor homing in general?
> Or would that cause too much test churn, as you're planning to recommit
> this patch anyway?
> --paulr
>
> > -Original Message-
> > From: cfe-commits  On Behalf Of David
> > Blaikie via cfe-commits
> > Sent: Friday, June 24, 2022 1:08 PM
> > To: cfe-commits@lists.llvm.org
> > Subject: [clang] 4821508 - Revert "DebugInfo: Fully integrate ctor type
> > homing into 'limited' debug info"
> >
> >
> > Author: David Blaikie
> > Date: 2022-06-24T17:07:47Z
> > New Revision: 4821508d4db75a535d02b8938f81fac6de66cc26
> >
> > URL: https://urldefense.com/v3/__https://github.com/llvm/llvm-
> > project/commit/4821508d4db75a535d02b8938f81fac6de66cc26__;!!JmoZiZGBv3RvKR
> > Sx!7pmjZG0ponrxAVY0dOSOTgWfvxMgERh3TNpn2zRGr7NTuooxwQKHzTroRX39LtKaKCXGoQD
> > n3Ri4BOhJymrwDVc8Rzk$
> > DIFF: https://urldefense.com/v3/__https://github.com/llvm/llvm-
> > project/commit/4821508d4db75a535d02b8938f81fac6de66cc26.diff__;!!JmoZiZGBv
> > 3RvKRSx!7pmjZG0ponrxAVY0dOSOTgWfvxMgERh3TNpn2zRGr7NTuooxwQKHzTroRX39LtKaKC
> > XGoQDn3Ri4BOhJymrwKAIx5Rg$
> >
> > LOG: Revert "DebugInfo: Fully integrate ctor type homing into 'limited'
> > debug info"
> >
> > Reverting to simplify some Google-internal rollout issues. Will recommit
> > in a week or two.
> >
> > This reverts commit 517bbc64dbe493644eff8d55fd9566435e930520.
> >
> > Added:
> > clang/test/CodeGenCXX/debug-info-ctor-homing-flag.cpp
> >
> > Modified:
> > clang/docs/UsersManual.rst
> > clang/include/clang/Basic/CodeGenOptions.h
> > clang/include/clang/Basic/DebugInfoOptions.h
> > clang/include/clang/Driver/Options.td
> > clang/lib/CodeGen/CGDebugInfo.cpp
> > clang/lib/Driver/ToolChains/Clang.cpp
> > clang/lib/Frontend/CompilerInvocation.cpp
> > clang/test/CodeGen/attr-cpuspecific-renaming.cpp
> > clang/test/CodeGen/pr52782-stdcall-func-decl.cpp
> > clang/test/CodeGenCXX/debug-info-class.cpp
> > clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
> > clang/test/CodeGenCXX/debug-info-template-explicit-specialization.cpp
> > clang/test/CodeGenCXX/debug-lambda-this.cpp
> > clang/test/CodeGenCXX/ibm128-declarations.cpp
> > clang/test/CodeGenCXX/standalone-debug-attribute.cpp
> > clang/test/Driver/cl-options.c
> > clang/test/Driver/clang-g-opts.c
> > clang/test/Driver/cuda-dwarf-2.cu
> > clang/test/Driver/debug-options-as.c
> > clang/test/Driver/debug-options.c
> > clang/test/Driver/integrated-as.s
> > clang/test/Driver/myriad-toolchain.c
> > clang/test/Driver/openmp-offload-gpu.c
> > clang/test/Driver/split-debug.c
> > clang/test/OpenMP/debug_private.c
> > clang/test/OpenMP/debug_task_shared.c
> > clang/test/OpenMP/debug_threadprivate_copyin.c
> >
> > Removed:
> >
> >
> >
> > ##
> > ##
> > diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
> > index ccb5fed1cb370..e12dc72407b13 100644
> > --- a/clang/docs/UsersManual.rst
> > +++ b/clang/docs/UsersManual.rst
> > @@ -2672,6 +2672,19 @@ below. If multiple flags are present, the last one
> > is used.
> > **-fno-standalone-debug** option can be used to get to turn on the
> > vtable-based optimization described above.
> >
> > +.. option:: -fuse-ctor-homing
> > +
> > +   This optimization is similar to the optimizations that are enabled as
> > part
> > +   of -fno-standalone-debug. Here, Clang only emits type info for a
> > +   non-trivial, non-aggregate C++ class in the modules that contain a
> > +   definition of one of its constructors. This relies on the additional
> > +   assumption that all classes that are not trivially constructible have
> > a
> > +   non-trivial constructor that is used somewhere. The negation,
> > +   -fno-use-ctor-homing, ensures that constructor homing is not used.
> > +
> > +   This flag is not enabled by default, and needs to be used with -cc1 or
> > +   -Xclang.
> > +
> >  .. option:: -g
> >
>

[clang] 4e719e0 - DebugInfo: Prefer vtable homing over ctor homing.

2022-07-27 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2022-07-28T00:07:35Z
New Revision: 4e719e0f16933a8945a4e85db39fdad5afbede36

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

LOG: DebugInfo: Prefer vtable homing over ctor homing.

Vtables will be emitted in fewer places than ctors (every ctor
references the vtable, so at worst it's the same places - but at best
the type has a non-inline key function and the vtable is emitted in one
place)

Pulling this fix out of 517bbc64dbe493644eff8d55fd9566435e930520 which
was reverted in 4821508d4db75a535d02b8938f81fac6de66cc26

Added: 


Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp
clang/test/CodeGenCXX/debug-info-limited-ctor.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 94c48316add7..6821fc97e504 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -3351,7 +3351,7 @@ void CGDebugInfo::completeTemplateDefinition(
 }
 
 void CGDebugInfo::completeUnusedClass(const CXXRecordDecl ) {
-  if (DebugKind <= codegenoptions::DebugLineTablesOnly)
+  if (DebugKind <= codegenoptions::DebugLineTablesOnly || D.isDynamicClass())
 return;
 
   completeClassData();

diff  --git a/clang/test/CodeGenCXX/debug-info-limited-ctor.cpp 
b/clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
index 835e6d481622..d17e3a142ad7 100644
--- a/clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
+++ b/clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
@@ -77,3 +77,14 @@ void L() {
 // Check that types are being added to retained types list.
 // CHECK-DAG: !DICompileUnit{{.*}}retainedTypes: ![[RETAINED:[0-9]+]]
 // CHECK-DAG: ![[RETAINED]] = {{.*}}![[C]]
+
+
+struct VTableAndCtor {
+  virtual void f1();
+  VTableAndCtor();
+};
+
+VTableAndCtor::VTableAndCtor() {
+}
+
+// CHECK-DAG: !DICompositeType({{.*}}name: "VTableAndCtor", {{.*}}flags: 
DIFlagFwdDecl



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


[clang] 4821508 - Revert "DebugInfo: Fully integrate ctor type homing into 'limited' debug info"

2022-06-24 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2022-06-24T17:07:47Z
New Revision: 4821508d4db75a535d02b8938f81fac6de66cc26

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

LOG: Revert "DebugInfo: Fully integrate ctor type homing into 'limited' debug 
info"

Reverting to simplify some Google-internal rollout issues. Will recommit
in a week or two.

This reverts commit 517bbc64dbe493644eff8d55fd9566435e930520.

Added: 
clang/test/CodeGenCXX/debug-info-ctor-homing-flag.cpp

Modified: 
clang/docs/UsersManual.rst
clang/include/clang/Basic/CodeGenOptions.h
clang/include/clang/Basic/DebugInfoOptions.h
clang/include/clang/Driver/Options.td
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/CodeGen/attr-cpuspecific-renaming.cpp
clang/test/CodeGen/pr52782-stdcall-func-decl.cpp
clang/test/CodeGenCXX/debug-info-class.cpp
clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
clang/test/CodeGenCXX/debug-info-template-explicit-specialization.cpp
clang/test/CodeGenCXX/debug-lambda-this.cpp
clang/test/CodeGenCXX/ibm128-declarations.cpp
clang/test/CodeGenCXX/standalone-debug-attribute.cpp
clang/test/Driver/cl-options.c
clang/test/Driver/clang-g-opts.c
clang/test/Driver/cuda-dwarf-2.cu
clang/test/Driver/debug-options-as.c
clang/test/Driver/debug-options.c
clang/test/Driver/integrated-as.s
clang/test/Driver/myriad-toolchain.c
clang/test/Driver/openmp-offload-gpu.c
clang/test/Driver/split-debug.c
clang/test/OpenMP/debug_private.c
clang/test/OpenMP/debug_task_shared.c
clang/test/OpenMP/debug_threadprivate_copyin.c

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index ccb5fed1cb370..e12dc72407b13 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -2672,6 +2672,19 @@ below. If multiple flags are present, the last one is 
used.
**-fno-standalone-debug** option can be used to get to turn on the
vtable-based optimization described above.
 
+.. option:: -fuse-ctor-homing
+
+   This optimization is similar to the optimizations that are enabled as part
+   of -fno-standalone-debug. Here, Clang only emits type info for a
+   non-trivial, non-aggregate C++ class in the modules that contain a
+   definition of one of its constructors. This relies on the additional
+   assumption that all classes that are not trivially constructible have a
+   non-trivial constructor that is used somewhere. The negation,
+   -fno-use-ctor-homing, ensures that constructor homing is not used.
+
+   This flag is not enabled by default, and needs to be used with -cc1 or
+   -Xclang.
+
 .. option:: -g
 
   Generate complete debug info.

diff  --git a/clang/include/clang/Basic/CodeGenOptions.h 
b/clang/include/clang/Basic/CodeGenOptions.h
index 5f5218c87a605..23d76c308d847 100644
--- a/clang/include/clang/Basic/CodeGenOptions.h
+++ b/clang/include/clang/Basic/CodeGenOptions.h
@@ -468,7 +468,7 @@ class CodeGenOptions : public CodeGenOptionsBase {
 
   /// Check if type and variable info should be emitted.
   bool hasReducedDebugInfo() const {
-return getDebugInfo() >= codegenoptions::LimitedDebugInfo;
+return getDebugInfo() >= codegenoptions::DebugInfoConstructor;
   }
 
   /// Check if maybe unused type info should be emitted.

diff  --git a/clang/include/clang/Basic/DebugInfoOptions.h 
b/clang/include/clang/Basic/DebugInfoOptions.h
index 98210cc3cfa13..a99a2b5903d7e 100644
--- a/clang/include/clang/Basic/DebugInfoOptions.h
+++ b/clang/include/clang/Basic/DebugInfoOptions.h
@@ -34,6 +34,12 @@ enum DebugInfoKind {
   /// (-gline-tables-only).
   DebugLineTablesOnly,
 
+  /// Limit generated debug info for classes to reduce size. This emits class
+  /// type info only where the constructor is emitted, if it is a class that
+  /// has a constructor.
+  /// FIXME: Consider combining this with LimitedDebugInfo.
+  DebugInfoConstructor,
+
   /// Limit generated debug info to reduce size (-fno-standalone-debug). This
   /// emits forward decls for types that could be replaced with forward decls 
in
   /// the source code. For dynamic C++ classes type info is only emitted into

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index e998612d32e2e..81d1d53cea9b1 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5246,6 +5246,11 @@ def mrelocation_model : Separate<["-"], 
"mrelocation-model">,
 def fno_math_builtin : Flag<["-"], "fno-math-builtin">,
   HelpText<"Disable implicit builtin knowledge of math functions">,
   MarshallingInfoFlag>;
+def fno_use_ctor_homing: Flag<["-"], "fno-use-ctor-homing">,
+HelpText<"Don't 

[clang] 517bbc6 - DebugInfo: Fully integrate ctor type homing into 'limited' debug info

2022-06-23 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2022-06-23T20:15:00Z
New Revision: 517bbc64dbe493644eff8d55fd9566435e930520

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

LOG: DebugInfo: Fully integrate ctor type homing into 'limited' debug info

Simplify debug info back to just "limited" or "full" by rolling the ctor
type homing fully into the "limited" debug info.

Also fix a bug I found along the way that was causing ctor type homing
to kick in even when something could be vtable homed (where vtable
homing is stronger/more effective than ctor homing) - fixing at the same
time as it keeps the tests (that were testing only "limited non ctor"
homing and now test ctor homing) passing.

Added: 


Modified: 
clang/docs/UsersManual.rst
clang/include/clang/Basic/CodeGenOptions.h
clang/include/clang/Basic/DebugInfoOptions.h
clang/include/clang/Driver/Options.td
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/CodeGen/attr-cpuspecific-renaming.cpp
clang/test/CodeGen/pr52782-stdcall-func-decl.cpp
clang/test/CodeGenCXX/debug-info-class.cpp
clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
clang/test/CodeGenCXX/debug-info-template-explicit-specialization.cpp
clang/test/CodeGenCXX/debug-lambda-this.cpp
clang/test/CodeGenCXX/ibm128-declarations.cpp
clang/test/CodeGenCXX/standalone-debug-attribute.cpp
clang/test/Driver/cl-options.c
clang/test/Driver/clang-g-opts.c
clang/test/Driver/cuda-dwarf-2.cu
clang/test/Driver/debug-options-as.c
clang/test/Driver/debug-options.c
clang/test/Driver/integrated-as.s
clang/test/Driver/myriad-toolchain.c
clang/test/Driver/openmp-offload-gpu.c
clang/test/Driver/split-debug.c
clang/test/OpenMP/debug_private.c
clang/test/OpenMP/debug_task_shared.c
clang/test/OpenMP/debug_threadprivate_copyin.c

Removed: 
clang/test/CodeGenCXX/debug-info-ctor-homing-flag.cpp



diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index e12dc72407b13..ccb5fed1cb370 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -2672,19 +2672,6 @@ below. If multiple flags are present, the last one is 
used.
**-fno-standalone-debug** option can be used to get to turn on the
vtable-based optimization described above.
 
-.. option:: -fuse-ctor-homing
-
-   This optimization is similar to the optimizations that are enabled as part
-   of -fno-standalone-debug. Here, Clang only emits type info for a
-   non-trivial, non-aggregate C++ class in the modules that contain a
-   definition of one of its constructors. This relies on the additional
-   assumption that all classes that are not trivially constructible have a
-   non-trivial constructor that is used somewhere. The negation,
-   -fno-use-ctor-homing, ensures that constructor homing is not used.
-
-   This flag is not enabled by default, and needs to be used with -cc1 or
-   -Xclang.
-
 .. option:: -g
 
   Generate complete debug info.

diff  --git a/clang/include/clang/Basic/CodeGenOptions.h 
b/clang/include/clang/Basic/CodeGenOptions.h
index 23d76c308d847..5f5218c87a605 100644
--- a/clang/include/clang/Basic/CodeGenOptions.h
+++ b/clang/include/clang/Basic/CodeGenOptions.h
@@ -468,7 +468,7 @@ class CodeGenOptions : public CodeGenOptionsBase {
 
   /// Check if type and variable info should be emitted.
   bool hasReducedDebugInfo() const {
-return getDebugInfo() >= codegenoptions::DebugInfoConstructor;
+return getDebugInfo() >= codegenoptions::LimitedDebugInfo;
   }
 
   /// Check if maybe unused type info should be emitted.

diff  --git a/clang/include/clang/Basic/DebugInfoOptions.h 
b/clang/include/clang/Basic/DebugInfoOptions.h
index a99a2b5903d7e..98210cc3cfa13 100644
--- a/clang/include/clang/Basic/DebugInfoOptions.h
+++ b/clang/include/clang/Basic/DebugInfoOptions.h
@@ -34,12 +34,6 @@ enum DebugInfoKind {
   /// (-gline-tables-only).
   DebugLineTablesOnly,
 
-  /// Limit generated debug info for classes to reduce size. This emits class
-  /// type info only where the constructor is emitted, if it is a class that
-  /// has a constructor.
-  /// FIXME: Consider combining this with LimitedDebugInfo.
-  DebugInfoConstructor,
-
   /// Limit generated debug info to reduce size (-fno-standalone-debug). This
   /// emits forward decls for types that could be replaced with forward decls 
in
   /// the source code. For dynamic C++ classes type info is only emitted into

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 5410b5d3e617f..3036668390cad 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5234,11 +5234,6 @@ def 

Re: [clang] d4bcb45 - [MC][re-land] Omit DWARF unwind info if compact unwind is present where eligible

2022-06-13 Thread David Blaikie via cfe-commits
Please include details of what changed between one commit and a recommit of
a patch - helpful for reviewers checking what's changed since the last
commit, double-checking that the patch fully addresses the issues, etc.

On Sun, Jun 12, 2022 at 2:24 PM Jez Ng via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

>
> Author: Jez Ng
> Date: 2022-06-12T17:24:19-04:00
> New Revision: d4bcb45db78dc7ca371224cb01bea8dcb14e0698
>
> URL:
> https://github.com/llvm/llvm-project/commit/d4bcb45db78dc7ca371224cb01bea8dcb14e0698
> DIFF:
> https://github.com/llvm/llvm-project/commit/d4bcb45db78dc7ca371224cb01bea8dcb14e0698.diff
>
> LOG: [MC][re-land] Omit DWARF unwind info if compact unwind is present
> where eligible
>
> This reverts commit d941d597837d9e1405086f008c9bd6a71e7263c9.
>
> Differential Revision: https://reviews.llvm.org/D122258
>
> Added:
> clang/test/Driver/femit-dwarf-unwind.c
> clang/test/Driver/femit-dwarf-unwind.s
> llvm/test/MC/MachO/AArch64/emit-dwarf-unwind.s
> llvm/test/MC/X86/compact-unwind-mode-dwarf.s
>
> Modified:
> clang/include/clang/Basic/CodeGenOptions.def
> clang/include/clang/Driver/Options.td
> clang/lib/CodeGen/BackendUtil.cpp
> clang/lib/Driver/ToolChains/Clang.cpp
> clang/tools/driver/cc1as_main.cpp
> llvm/include/llvm/MC/MCContext.h
> llvm/include/llvm/MC/MCTargetOptions.h
> llvm/include/llvm/MC/MCTargetOptionsCommandFlags.h
> llvm/lib/CodeGen/LLVMTargetMachine.cpp
> llvm/lib/CodeGen/MachineModuleInfo.cpp
> llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp
> llvm/lib/ExecutionEngine/Orc/CompileUtils.cpp
> llvm/lib/ExecutionEngine/RuntimeDyld/RTDyldMemoryManager.cpp
> llvm/lib/MC/MCContext.cpp
> llvm/lib/MC/MCDwarf.cpp
> llvm/lib/MC/MCObjectFileInfo.cpp
> llvm/lib/MC/MCTargetOptions.cpp
> llvm/lib/MC/MCTargetOptionsCommandFlags.cpp
> llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
>
> Removed:
>
>
>
>
> 
> diff  --git a/clang/include/clang/Basic/CodeGenOptions.def
> b/clang/include/clang/Basic/CodeGenOptions.def
> index d8f667dc387bb..8e89106993c26 100644
> --- a/clang/include/clang/Basic/CodeGenOptions.def
> +++ b/clang/include/clang/Basic/CodeGenOptions.def
> @@ -114,6 +114,10 @@ CODEGENOPT(StackSizeSection  , 1, 0) ///< Set when
> -fstack-size-section is enabl
>  CODEGENOPT(ForceDwarfFrameSection , 1, 0) ///< Set when
> -fforce-dwarf-frame is
>///< enabled.
>
> +///< Set when -femit-dwarf-unwind is passed.
> +ENUM_CODEGENOPT(EmitDwarfUnwind, llvm::EmitDwarfUnwindType, 2,
> +llvm::EmitDwarfUnwindType::Default)
> +
>  ///< Set when -fxray-always-emit-customevents is enabled.
>  CODEGENOPT(XRayAlwaysEmitCustomEvents , 1, 0)
>
>
> diff  --git a/clang/include/clang/Driver/Options.td
> b/clang/include/clang/Driver/Options.td
> index 95840760f7746..002cd6cc8cb17 100644
> --- a/clang/include/clang/Driver/Options.td
> +++ b/clang/include/clang/Driver/Options.td
> @@ -3044,6 +3044,13 @@ def fmacro_prefix_map_EQ
>  defm force_dwarf_frame : BoolFOption<"force-dwarf-frame",
>CodeGenOpts<"ForceDwarfFrameSection">, DefaultFalse,
>PosFlag,
> NegFlag>;
> +def femit_dwarf_unwind_EQ : Joined<["-"], "femit-dwarf-unwind=">,
> +  Group, Flags<[CC1Option, CC1AsOption]>,
> +  HelpText<"When to emit DWARF unwind (EH frame) info">,
> +  Values<"always,no-compact-unwind,default">,
> +  NormalizedValues<["Always", "NoCompactUnwind", "Default"]>,
> +  NormalizedValuesScope<"llvm::EmitDwarfUnwindType">,
> +  MarshallingInfoEnum, "Default">;
>  def g_Flag : Flag<["-"], "g">, Group,
>HelpText<"Generate source-level debug information">;
>  def gline_tables_only : Flag<["-"], "gline-tables-only">, Group,
>
> diff  --git a/clang/lib/CodeGen/BackendUtil.cpp
> b/clang/lib/CodeGen/BackendUtil.cpp
> index 0de15b1e48078..4b294c254e476 100644
> --- a/clang/lib/CodeGen/BackendUtil.cpp
> +++ b/clang/lib/CodeGen/BackendUtil.cpp
> @@ -453,6 +453,7 @@ static bool initTargetOptions(DiagnosticsEngine ,
>}
>
>Options.MCOptions.SplitDwarfFile = CodeGenOpts.SplitDwarfFile;
> +  Options.MCOptions.EmitDwarfUnwind = CodeGenOpts.getEmitDwarfUnwind();
>Options.MCOptions.MCRelaxAll = CodeGenOpts.RelaxAll;
>Options.MCOptions.MCSaveTempLabels = CodeGenOpts.SaveTempLabels;
>Options.MCOptions.MCUseDwarfDirectory =
>
> diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp
> b/clang/lib/Driver/ToolChains/Clang.cpp
> index ceac142653ebe..62e891ce38c49 100644
> --- a/clang/lib/Driver/ToolChains/Clang.cpp
> +++ b/clang/lib/Driver/ToolChains/Clang.cpp
> @@ -2518,6 +2518,8 @@ static void
> CollectArgsForIntegratedAssembler(Compilation ,
> DefaultIncrementalLinkerCompatible))
>  CmdArgs.push_back("-mincremental-linker-compatible");
>
> +  Args.AddLastArg(CmdArgs, options::OPT_femit_dwarf_unwind_EQ);
> +
>// If you add more args here, also add them to the block below that

Re: [clang] d941d59 - Revert "[MC] Omit DWARF unwind info if compact unwind is present where eligible"

2022-06-13 Thread David Blaikie via cfe-commits
Please include details about the reason for a revert in the revert commit
message - helpful for folks following along/looking to see if a given
revert addresses an issue they're seeing, etc.

On Sun, Jun 12, 2022 at 7:47 AM Jez Ng via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

>
> Author: Jez Ng
> Date: 2022-06-12T10:47:08-04:00
> New Revision: d941d597837d9e1405086f008c9bd6a71e7263c9
>
> URL:
> https://github.com/llvm/llvm-project/commit/d941d597837d9e1405086f008c9bd6a71e7263c9
> DIFF:
> https://github.com/llvm/llvm-project/commit/d941d597837d9e1405086f008c9bd6a71e7263c9.diff
>
> LOG: Revert "[MC] Omit DWARF unwind info if compact unwind is present
> where eligible"
>
> This reverts commit ef501bf85d8c869248e51371f0e74bcec0e7b229.
>
> Added:
>
>
> Modified:
> clang/include/clang/Basic/CodeGenOptions.def
> clang/include/clang/Driver/Options.td
> clang/lib/CodeGen/BackendUtil.cpp
> clang/lib/Driver/ToolChains/Clang.cpp
> clang/tools/driver/cc1as_main.cpp
> llvm/include/llvm/MC/MCContext.h
> llvm/include/llvm/MC/MCTargetOptions.h
> llvm/include/llvm/MC/MCTargetOptionsCommandFlags.h
> llvm/lib/CodeGen/LLVMTargetMachine.cpp
> llvm/lib/CodeGen/MachineModuleInfo.cpp
> llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp
> llvm/lib/ExecutionEngine/Orc/CompileUtils.cpp
> llvm/lib/ExecutionEngine/RuntimeDyld/RTDyldMemoryManager.cpp
> llvm/lib/MC/MCContext.cpp
> llvm/lib/MC/MCDwarf.cpp
> llvm/lib/MC/MCObjectFileInfo.cpp
> llvm/lib/MC/MCTargetOptions.cpp
> llvm/lib/MC/MCTargetOptionsCommandFlags.cpp
> llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
>
> Removed:
> clang/test/Driver/femit-dwarf-unwind.c
> clang/test/Driver/femit-dwarf-unwind.s
> llvm/test/MC/MachO/emit-dwarf-unwind.s
> llvm/test/MC/X86/compact-unwind-mode-dwarf.s
>
>
>
> 
> diff  --git a/clang/include/clang/Basic/CodeGenOptions.def
> b/clang/include/clang/Basic/CodeGenOptions.def
> index 8e89106993c26..d8f667dc387bb 100644
> --- a/clang/include/clang/Basic/CodeGenOptions.def
> +++ b/clang/include/clang/Basic/CodeGenOptions.def
> @@ -114,10 +114,6 @@ CODEGENOPT(StackSizeSection  , 1, 0) ///< Set when
> -fstack-size-section is enabl
>  CODEGENOPT(ForceDwarfFrameSection , 1, 0) ///< Set when
> -fforce-dwarf-frame is
>///< enabled.
>
> -///< Set when -femit-dwarf-unwind is passed.
> -ENUM_CODEGENOPT(EmitDwarfUnwind, llvm::EmitDwarfUnwindType, 2,
> -llvm::EmitDwarfUnwindType::Default)
> -
>  ///< Set when -fxray-always-emit-customevents is enabled.
>  CODEGENOPT(XRayAlwaysEmitCustomEvents , 1, 0)
>
>
> diff  --git a/clang/include/clang/Driver/Options.td
> b/clang/include/clang/Driver/Options.td
> index 002cd6cc8cb17..95840760f7746 100644
> --- a/clang/include/clang/Driver/Options.td
> +++ b/clang/include/clang/Driver/Options.td
> @@ -3044,13 +3044,6 @@ def fmacro_prefix_map_EQ
>  defm force_dwarf_frame : BoolFOption<"force-dwarf-frame",
>CodeGenOpts<"ForceDwarfFrameSection">, DefaultFalse,
>PosFlag,
> NegFlag>;
> -def femit_dwarf_unwind_EQ : Joined<["-"], "femit-dwarf-unwind=">,
> -  Group, Flags<[CC1Option, CC1AsOption]>,
> -  HelpText<"When to emit DWARF unwind (EH frame) info">,
> -  Values<"always,no-compact-unwind,default">,
> -  NormalizedValues<["Always", "NoCompactUnwind", "Default"]>,
> -  NormalizedValuesScope<"llvm::EmitDwarfUnwindType">,
> -  MarshallingInfoEnum, "Default">;
>  def g_Flag : Flag<["-"], "g">, Group,
>HelpText<"Generate source-level debug information">;
>  def gline_tables_only : Flag<["-"], "gline-tables-only">, Group,
>
> diff  --git a/clang/lib/CodeGen/BackendUtil.cpp
> b/clang/lib/CodeGen/BackendUtil.cpp
> index 4b294c254e476..0de15b1e48078 100644
> --- a/clang/lib/CodeGen/BackendUtil.cpp
> +++ b/clang/lib/CodeGen/BackendUtil.cpp
> @@ -453,7 +453,6 @@ static bool initTargetOptions(DiagnosticsEngine ,
>}
>
>Options.MCOptions.SplitDwarfFile = CodeGenOpts.SplitDwarfFile;
> -  Options.MCOptions.EmitDwarfUnwind = CodeGenOpts.getEmitDwarfUnwind();
>Options.MCOptions.MCRelaxAll = CodeGenOpts.RelaxAll;
>Options.MCOptions.MCSaveTempLabels = CodeGenOpts.SaveTempLabels;
>Options.MCOptions.MCUseDwarfDirectory =
>
> diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp
> b/clang/lib/Driver/ToolChains/Clang.cpp
> index 62e891ce38c49..ceac142653ebe 100644
> --- a/clang/lib/Driver/ToolChains/Clang.cpp
> +++ b/clang/lib/Driver/ToolChains/Clang.cpp
> @@ -2518,8 +2518,6 @@ static void
> CollectArgsForIntegratedAssembler(Compilation ,
> DefaultIncrementalLinkerCompatible))
>  CmdArgs.push_back("-mincremental-linker-compatible");
>
> -  Args.AddLastArg(CmdArgs, options::OPT_femit_dwarf_unwind_EQ);
> -
>// If you add more args here, also add them to the block below that
>// starts with "// If CollectArgsForIntegratedAssembler() isn't called
> below".
>
> @@ 

Re: [clang] f13019f - [clang] Use any_of and none_of (NFC)

2022-06-13 Thread David Blaikie via cfe-commits
On Sun, Jun 12, 2022 at 10:17 AM Kazu Hirata via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

>
> Author: Kazu Hirata
> Date: 2022-06-12T10:17:12-07:00
> New Revision: f13019f8367a417075e70effb13dcf58024090b2
>
> URL:
> https://github.com/llvm/llvm-project/commit/f13019f8367a417075e70effb13dcf58024090b2
> DIFF:
> https://github.com/llvm/llvm-project/commit/f13019f8367a417075e70effb13dcf58024090b2.diff
>
> LOG: [clang] Use any_of and none_of (NFC)
>
> Added:
>
>
> Modified:
> clang/include/clang/Basic/Attr.td
> clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
> clang/lib/Sema/SemaDeclCXX.cpp
> clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
>
> Removed:
>
>
>
>
> 
> diff  --git a/clang/include/clang/Basic/Attr.td
> b/clang/include/clang/Basic/Attr.td
> index d1f407259cb6e..16384969f68e4 100644
> --- a/clang/include/clang/Basic/Attr.td
> +++ b/clang/include/clang/Basic/Attr.td
> @@ -1926,9 +1926,9 @@ def NonNull : InheritableParamAttr {
>  bool isNonNull(unsigned IdxAST) const {
>if (!args_size())
>  return true;
> -  return args_end() != std::find_if(
> -  args_begin(), args_end(),
> -  [=](const ParamIdx ) { return Idx.getASTIndex() == IdxAST;
> });
> +  return llvm::any_of(args(), [=](const ParamIdx ) {
> +return Idx.getASTIndex() == IdxAST;
> +  });
>

Generally, I think for locally scoped lambdas (lambdas that don't escape
their scope) we should prefer/default to default reference capture (`[&]`)
- it simplifies changes in the future. Would that be OK for these sort of
cleanups?


>  }
>}];
>// FIXME: We should merge duplicates into a single nonnull attribute.
>
> diff  --git a/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
> b/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
> index a7b0a1ac98a78..bffa66c2d9448 100644
> --- a/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
> +++ b/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
> @@ -199,11 +199,11 @@ struct LocationFileChecker {
>  // Try to reduce the include name the same way we tried to include it.
>  bool IsQuoted = false;
>  if (auto IncludeName = getRelativeIncludeName(CI, FileName,
> ))
> -  if (llvm::find_if(KnownFiles,
> -[, ](const auto ) {
> -  return KnownFile.first.equals(*IncludeName) &&
> - KnownFile.second == IsQuoted;
> -}) != KnownFiles.end()) {
> +  if (llvm::any_of(KnownFiles,
> +   [, ](const auto ) {
> + return KnownFile.first.equals(*IncludeName) &&
> +KnownFile.second == IsQuoted;
> +   })) {
>  KnownFileEntries.insert(File);
>  return true;
>}
>
> diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp
> b/clang/lib/Sema/SemaDeclCXX.cpp
> index 569b226da9233..214332e53c0f0 100644
> --- a/clang/lib/Sema/SemaDeclCXX.cpp
> +++ b/clang/lib/Sema/SemaDeclCXX.cpp
> @@ -8617,10 +8617,10 @@ bool
> Sema::CheckExplicitlyDefaultedComparison(Scope *S, FunctionDecl *FD,
>  int(1)))
>return true;
>
> -if (llvm::find_if(RD->friends(), [&](const FriendDecl *F) {
> +if (llvm::none_of(RD->friends(), [&](const FriendDecl *F) {
>return FD->getCanonicalDecl() ==
>   F->getFriendDecl()->getCanonicalDecl();
> -}) == RD->friends().end()) {
> +})) {
>Diag(FD->getLocation(), diag::err_defaulted_comparison_not_friend)
><< int(DCK) << int(0) << RD;
>Diag(RD->getCanonicalDecl()->getLocation(), diag::note_declared_at);
>
> diff  --git a/clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
> b/clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
> index 528284ca89858..9ee6ef4f9519f 100644
> --- a/clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
> +++ b/clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
> @@ -480,9 +480,7 @@ static void isOptionContainedIn(const
> CmdLineOptionList ,
>  return Opt.OptionName == SuppliedOption;
>};
>
> -  const auto *OptionIt = llvm::find_if(OptionList, SameOptName);
> -
> -  if (OptionIt == OptionList.end()) {
> +  if (llvm::none_of(OptionList, SameOptName)) {
>  Diags.Report(diag::err_analyzer_checker_option_unknown)
>  << SuppliedChecker << SuppliedOption;
>  return;
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] cb08f4a - Support warn_unused_result on typedefs

2022-06-02 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2022-06-02T20:57:31Z
New Revision: cb08f4aa4467cf562b62e542725f5351c5482495

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

LOG: Support warn_unused_result on typedefs

While it's not as robust as using the attribute on enums/classes (the
type information may be lost through a function pointer, a declaration
or use of the underlying type without using the typedef, etc) but I
think there's still value in being able to attribute a typedef and have
all return types written with that typedef pick up the
warn_unused_result behavior.

Specifically I'd like to be able to annotate LLVMErrorRef (a wrapper for
llvm::Error used in the C API - the underlying type is a raw pointer, so
it can't be attributed itself) to reduce the chance of unhandled errors.

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

Added: 


Modified: 
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/AttributeCommonInfo.h
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/AST/Expr.cpp
clang/lib/Basic/Attributes.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p1.cpp
clang/test/Misc/pragma-attribute-supported-attributes-list.test
clang/test/Sema/c2x-nodiscard.c
clang/test/Sema/unused-expr.c
clang/test/SemaCXX/warn-unused-result.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index fed29b03a8b14..4644323501272 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -2944,7 +2944,7 @@ def WarnUnusedResult : InheritableAttr {
C2x<"", "nodiscard", 201904>,
CXX11<"clang", "warn_unused_result">,
GCC<"warn_unused_result">];
-  let Subjects = SubjectList<[ObjCMethod, Enum, Record, FunctionLike]>;
+  let Subjects = SubjectList<[ObjCMethod, Enum, Record, FunctionLike, 
TypedefName]>;
   let Args = [StringArgument<"Message", 1>];
   let Documentation = [WarnUnusedResultsDocs];
   let AdditionalMembers = [{

diff  --git a/clang/include/clang/Basic/AttributeCommonInfo.h 
b/clang/include/clang/Basic/AttributeCommonInfo.h
index 9eff0966e458a..afa8a893e921a 100644
--- a/clang/include/clang/Basic/AttributeCommonInfo.h
+++ b/clang/include/clang/Basic/AttributeCommonInfo.h
@@ -146,6 +146,7 @@ class AttributeCommonInfo {
   bool isMicrosoftAttribute() const { return SyntaxUsed == AS_Microsoft; }
 
   bool isGNUScope() const;
+  bool isClangScope() const;
 
   bool isAlignasAttribute() const {
 // FIXME: Use a better mechanism to determine this.
@@ -164,6 +165,8 @@ class AttributeCommonInfo {
 return isCXX11Attribute() || isC2xAttribute();
   }
 
+  bool isGNUAttribute() const { return SyntaxUsed == AS_GNU; }
+
   bool isKeywordAttribute() const {
 return SyntaxUsed == AS_Keyword || SyntaxUsed == 
AS_ContextSensitiveKeyword;
   }

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 469f79a867524..0e6573241b55e 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -8734,6 +8734,10 @@ def warn_unused_result : Warning<
 def warn_unused_result_msg : Warning<
   "ignoring return value of function declared with %0 attribute: %1">,
   InGroup;
+def warn_unused_result_typedef_unsupported_spelling : Warning<
+  "'[[%select{nodiscard|gnu::warn_unused_result}0]]' attribute ignored when "
+  "applied to a typedef; consider using '__attribute__((warn_unused_result))' "
+  "or '[[clang::warn_unused_result]]' instead">, InGroup;
 def warn_unused_volatile : Warning<
   "expression result unused; assign into a variable to force a volatile load">,
   InGroup>;

diff  --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index c3dfae5cba061..79d092acccec9 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -1522,6 +1522,11 @@ const Attr *CallExpr::getUnusedResultAttr(const 
ASTContext ) const {
 if (const auto *A = TD->getAttr())
   return A;
 
+  for (const auto *TD = getCallReturnType(Ctx)->getAs(); TD;
+   TD = TD->desugar()->getAs())
+if (const auto *A = TD->getDecl()->getAttr())
+  return A;
+
   // Otherwise, see if the callee is marked nodiscard and return that attribute
   // instead.
   const Decl *D = getCalleeDecl();

diff  --git a/clang/lib/Basic/Attributes.cpp b/clang/lib/Basic/Attributes.cpp
index 62eea9c590825..bd27dc13a92f0 100644
--- a/clang/lib/Basic/Attributes.cpp
+++ b/clang/lib/Basic/Attributes.cpp
@@ -85,6 +85,10 @@ bool AttributeCommonInfo::isGNUScope() const {
   return ScopeName && (ScopeName->isStr("gnu") || ScopeName->isStr("__gnu__"));
 }
 
+bool 

Re: Call for an assistance pushing patch review forward

2022-05-30 Thread David Blaikie via cfe-commits
Beyond that it may be useful to look at who's been contributing to the
code you're trying to change and consider cc'ing them on the review.
(if they can't help, maybe they can point you to someone who can)

On Fri, May 27, 2022 at 2:23 PM stryku_t via cfe-commits
 wrote:
>
> Hi Paul,
>
> Thank you for the tips.
> Pinging is indeed mentioned in the docs, but I didn't want to piss everyone 
> off, so after two pings I thought that I'm doing something wrong. From now on 
> I'll ping once a week in such situations.
>
> Got review comments now, so we're back on track. Gonna implement changes over 
> the weekend.
>
> Thanks,
> Mateusz Janek
>
> czw., 26 maj 2022 o 22:51 Robinson, Paul  napisał(a):
>>
>> Hi Mateusz,
>>
>>
>>
>> I wouldn’t worry too much about the failed build.  I took a peek and it 
>> looks like the failures are mostly in places very unrelated to your patch.  
>> If your own testing shows no problems, it’s very likely you’re fine.
>>
>>
>>
>> Regarding lack of response, this is unfortunately more common than it should 
>> be.  Our recommended practice—and I’m surprised we don’t say anything on the 
>> website—is to add a “ping” comment to your review, maybe once a week.  This 
>> can “bump” it up in someone’s to-be-reviewed list; if nothing else, there’s 
>> another email to the list that will hopefully catch someone’s attention.
>>
>>
>>
>> Good luck,
>>
>> --paulr
>>
>>
>>
>> From: cfe-commits  On Behalf Of stryku_t 
>> via cfe-commits
>> Sent: Thursday, May 26, 2022 4:20 PM
>> To: cfe-commits@lists.llvm.org
>> Subject: Call for an assistance pushing patch review forward
>>
>>
>>
>> Hi,
>>
>> Some time ago I submitted a Clang patch for review: 
>> https://reviews.llvm.org/D123532
>>
>> It's been some time and I can't make progress with it.
>> I'm aware that there is failed build. But, as I mentioned in one of the 
>> comments, I can't reproduce it locally.
>> Tried to reach out to the people mentioned in the review, but I struggle 
>> getting answers.
>> At this point I'm not sure if I'm doing something wrong or people are just 
>> busy. Should tag different people? Different project? Am I expected to 
>> figure out failed builds on my own before someone will review the changes?
>>
>> Could someone from the community please assist me how for move forward with 
>> this patch? Also, I'd be grateful if there's someone who can hint me how to 
>> reproduce failed builds locally or using some CI server.
>>
>> Thanks in advance!
>>
>> Best regards,
>> Mateusz Janek
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] e59f648 - Move GCC-compatible pod-packing change to v15/old behavior available at v14 and below

2022-05-24 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2022-05-25T03:03:27Z
New Revision: e59f648d698efe58b96e9b6224449b2b8cfa872a

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

LOG: Move GCC-compatible pod-packing change to v15/old behavior available at 
v14 and below

Since this didn't make it into the v14 release - anyone requesting the
v14 ABI shouldn't get this GCC-compatible change that isn't backwards
compatible with v14 Clang.

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/LangOptions.h
clang/lib/AST/RecordLayoutBuilder.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/SemaCXX/class-layout.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 7a54a3368547..a457a8fb2efe 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -431,7 +431,7 @@ ABI Changes in Clang
   attribute is also specified on the member. Clang historically did perform
   such packing. Clang now matches the gcc behavior (except on Darwin and PS4).
   You can switch back to the old ABI behavior with the flag:
-  ``-fclang-abi-compat=13.0``.
+  ``-fclang-abi-compat=14.0``.
 
 OpenMP Support in Clang
 ---

diff  --git a/clang/include/clang/Basic/LangOptions.h 
b/clang/include/clang/Basic/LangOptions.h
index d442b4d96e76..6e7763a4a2b4 100644
--- a/clang/include/clang/Basic/LangOptions.h
+++ b/clang/include/clang/Basic/LangOptions.h
@@ -214,12 +214,9 @@ class LangOptions : public LangOptionsBase {
 /// global-scope inline variables incorrectly.
 Ver12,
 
-/// Attempt to be ABI-compatible with code generated by Clang 13.0.x.
-/// This causes clang to not pack non-POD members of packed structs.
-Ver13,
-
 /// Attempt to be ABI-compatible with code generated by Clang 14.0.x.
 /// This causes clang to mangle dependent nested names incorrectly.
+/// This causes clang to pack non-POD members of packed structs.
 Ver14,
 
 /// Conform to the underlying platform's C and C++ ABIs as closely

diff  --git a/clang/lib/AST/RecordLayoutBuilder.cpp 
b/clang/lib/AST/RecordLayoutBuilder.cpp
index 202823da7baa..8827e956fc2f 100644
--- a/clang/lib/AST/RecordLayoutBuilder.cpp
+++ b/clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1890,7 +1890,7 @@ void ItaniumRecordLayoutBuilder::LayoutField(const 
FieldDecl *D,
   llvm::Triple Target = Context.getTargetInfo().getTriple();
   bool FieldPacked = (Packed && (!FieldClass || FieldClass->isPOD() ||
  Context.getLangOpts().getClangABICompat() <=
- LangOptions::ClangABI::Ver13 ||
+ LangOptions::ClangABI::Ver14 ||
  Target.isPS4() || Target.isOSDarwin())) ||
  D->hasAttr();
 

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 88125dad8a92..32b084dfedec 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -3516,8 +3516,6 @@ void CompilerInvocation::GenerateLangArgs(const 
LangOptions ,
 GenerateArg(Args, OPT_fclang_abi_compat_EQ, "11.0", SA);
   else if (Opts.getClangABICompat() == LangOptions::ClangABI::Ver12)
 GenerateArg(Args, OPT_fclang_abi_compat_EQ, "12.0", SA);
-  else if (Opts.getClangABICompat() == LangOptions::ClangABI::Ver13)
-GenerateArg(Args, OPT_fclang_abi_compat_EQ, "13.0", SA);
   else if (Opts.getClangABICompat() == LangOptions::ClangABI::Ver14)
 GenerateArg(Args, OPT_fclang_abi_compat_EQ, "14.0", SA);
 
@@ -4010,8 +4008,6 @@ bool CompilerInvocation::ParseLangArgs(LangOptions , 
ArgList ,
 Opts.setClangABICompat(LangOptions::ClangABI::Ver11);
   else if (Major <= 12)
 Opts.setClangABICompat(LangOptions::ClangABI::Ver12);
-  else if (Major <= 13)
-Opts.setClangABICompat(LangOptions::ClangABI::Ver13);
   else if (Major <= 14)
 Opts.setClangABICompat(LangOptions::ClangABI::Ver14);
 } else if (Ver != "latest") {

diff  --git a/clang/test/SemaCXX/class-layout.cpp 
b/clang/test/SemaCXX/class-layout.cpp
index 79fa67707110..940966950d8b 100644
--- a/clang/test/SemaCXX/class-layout.cpp
+++ b/clang/test/SemaCXX/class-layout.cpp
@@ -1,9 +1,9 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++98 -Wno-inaccessible-base
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base
-// RUN: %clang_cc1 -triple x86_64-apple-darwin%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=13
+// RUN: %clang_cc1 -triple x86_64-apple-darwin%s 

Re: [clang] 7aa1fa0 - Reland "[dwarf] Emit a DIGlobalVariable for constant strings."

2022-05-23 Thread David Blaikie via cfe-commits
(when recommitting a patch it can be helpful to mention the revisions
of the previous commit/revert, the reason for the revert and what's
different in this version of the patch that addresses that issue (or
how was the issue otherwise addressed))

On Wed, May 18, 2022 at 1:59 PM Mitch Phillips via cfe-commits
 wrote:
>
>
> Author: Mitch Phillips
> Date: 2022-05-18T13:56:45-07:00
> New Revision: 7aa1fa0a0a07f7949d2d77c099aab43cf9b75a91
>
> URL: 
> https://github.com/llvm/llvm-project/commit/7aa1fa0a0a07f7949d2d77c099aab43cf9b75a91
> DIFF: 
> https://github.com/llvm/llvm-project/commit/7aa1fa0a0a07f7949d2d77c099aab43cf9b75a91.diff
>
> LOG: Reland "[dwarf] Emit a DIGlobalVariable for constant strings."
>
> An upcoming patch will extend llvm-symbolizer to provide the source line
> information for global variables. The goal is to move AddressSanitizer
> off of internal debug info for symbolization onto the DWARF standard
> (and doing a clean-up in the process). Currently, ASan reports the line
> information for constant strings if a memory safety bug happens around
> them. We want to keep this behaviour, so we need to emit debuginfo for
> these variables as well.
>
> Reviewed By: dblaikie, rnk, aprantl
>
> Differential Revision: https://reviews.llvm.org/D123534
>
> Added:
> clang/test/CodeGen/debug-info-variables.c
> llvm/test/DebugInfo/COFF/global-no-strings.ll
>
> Modified:
> clang/lib/CodeGen/CGDebugInfo.cpp
> clang/lib/CodeGen/CGDebugInfo.h
> clang/lib/CodeGen/CodeGenModule.cpp
> clang/test/VFS/external-names.c
> llvm/lib/AsmParser/LLParser.cpp
> llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
> llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
>
> Removed:
> llvm/test/Assembler/invalid-diglobalvariable-missing-name.ll
>
>
> 
> diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
> b/clang/lib/CodeGen/CGDebugInfo.cpp
> index 3d73bfb8ce79..753427029441 100644
> --- a/clang/lib/CodeGen/CGDebugInfo.cpp
> +++ b/clang/lib/CodeGen/CGDebugInfo.cpp
> @@ -5132,7 +5132,7 @@ std::string CGDebugInfo::GetName(const Decl *D, bool 
> Qualified) const {
>  return Name;
>codegenoptions::DebugTemplateNamesKind TemplateNamesKind =
>CGM.getCodeGenOpts().getDebugSimpleTemplateNames();
> -
> +
>if (!CGM.getCodeGenOpts().hasReducedDebugInfo())
>  TemplateNamesKind = codegenoptions::DebugTemplateNamesKind::Full;
>
> @@ -5459,6 +5459,21 @@ void CGDebugInfo::EmitGlobalAlias(const 
> llvm::GlobalValue *GV,
>ImportedDeclCache[GD.getCanonicalDecl().getDecl()].reset(ImportDI);
>  }
>
> +void CGDebugInfo::AddStringLiteralDebugInfo(llvm::GlobalVariable *GV,
> +const StringLiteral *S) {
> +  SourceLocation Loc = S->getStrTokenLoc(0);
> +  PresumedLoc PLoc = CGM.getContext().getSourceManager().getPresumedLoc(Loc);
> +  if (!PLoc.isValid())
> +return;
> +
> +  llvm::DIFile *File = getOrCreateFile(Loc);
> +  llvm::DIGlobalVariableExpression *Debug =
> +  DBuilder.createGlobalVariableExpression(
> +  nullptr, StringRef(), StringRef(), getOrCreateFile(Loc),
> +  getLineNumber(Loc), getOrCreateType(S->getType(), File), true);
> +  GV->addDebugInfo(Debug);
> +}
> +
>  llvm::DIScope *CGDebugInfo::getCurrentContextDescriptor(const Decl *D) {
>if (!LexicalBlockStack.empty())
>  return LexicalBlockStack.back();
>
> diff  --git a/clang/lib/CodeGen/CGDebugInfo.h 
> b/clang/lib/CodeGen/CGDebugInfo.h
> index 8984f3eb1d7a..38e3fa5b2fa9 100644
> --- a/clang/lib/CodeGen/CGDebugInfo.h
> +++ b/clang/lib/CodeGen/CGDebugInfo.h
> @@ -533,6 +533,14 @@ class CGDebugInfo {
>/// Emit an @import declaration.
>void EmitImportDecl(const ImportDecl );
>
> +  /// DebugInfo isn't attached to string literals by default. While certain
> +  /// aspects of debuginfo aren't useful for string literals (like a name), 
> it's
> +  /// nice to be able to symbolize the line and column information. This is
> +  /// especially useful for sanitizers, as it allows symbolization of
> +  /// heap-buffer-overflows on constant strings.
> +  void AddStringLiteralDebugInfo(llvm::GlobalVariable *GV,
> + const StringLiteral *S);
> +
>/// Emit C++ namespace alias.
>llvm::DIImportedEntity *EmitNamespaceAlias(const NamespaceAliasDecl );
>
>
> diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
> b/clang/lib/CodeGen/CodeGenModule.cpp
> index f8bf210dc0e2..703cf4edf5f5 100644
> --- a/clang/lib/CodeGen/CodeGenModule.cpp
> +++ b/clang/lib/CodeGen/CodeGenModule.cpp
> @@ -5670,6 +5670,11 @@ 
> CodeGenModule::GetAddrOfConstantStringFromLiteral(const StringLiteral *S,
>}
>
>auto GV = GenerateStringLiteral(C, LT, *this, GlobalVariableName, 
> Alignment);
> +
> +  CGDebugInfo *DI = getModuleDebugInfo();
> +  if (DI && getCodeGenOpts().hasReducedDebugInfo())
> +DI->AddStringLiteralDebugInfo(GV, S);
> +
>if (Entry)
>  *Entry = 

[clang] 0b903ef - Re-add release notes for GCC ABI compatibility for non-POD in packed structs

2022-05-21 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2022-05-22T01:15:34Z
New Revision: 0b903ef6aa0976a60d3f448837f3c43adaf09cc1

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

LOG: Re-add release notes for GCC ABI compatibility for non-POD in packed 
structs

Added: 


Modified: 
clang/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 5d1b12504f787..a889c74a55239 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -424,6 +424,12 @@ OpenCL C Language Changes in Clang
 ABI Changes in Clang
 
 
+- GCC doesn't pack non-POD members in packed structs unless the packed
+  attribute is also specified on the member. Clang historically did perform
+  such packing. Clang now matches the gcc behavior (except on Darwin and PS4).
+  You can switch back to the old ABI behavior with the flag:
+  ``-fclang-abi-compat=13.0``.
+
 OpenMP Support in Clang
 ---
 



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


[clang] 1cee3d9 - DebugInfo: Consider the type of NTTP when simplifying template names

2022-04-07 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2022-04-08T00:00:46Z
New Revision: 1cee3d9db77b2c62a03efe1cce45f627dcbe6457

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

LOG: DebugInfo: Consider the type of NTTP when simplifying template names

Since the NTTP may need to be cast to the type when rebuilding the name,
check that the type can be rebuilt when determining whether a template
name can be simplified.

Added: 


Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp
clang/test/CodeGenCXX/debug-info-simple-template-names.cpp

cross-project-tests/debuginfo-tests/clang_llvm_roundtrip/simplified_template_names.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 63b89f258a8ac..c18dbccf82936 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -5167,7 +5167,8 @@ std::string CGDebugInfo::GetName(const Decl *D, bool 
Qualified) const {
 // harder to parse back into a large integer, etc - so punting on
 // this for now. Re-parsing the integers back into APInt is 
probably
 // feasible some day.
-return TA.getAsIntegral().getBitWidth() <= 64;
+return TA.getAsIntegral().getBitWidth() <= 64 &&
+   IsReconstitutableType(TA.getIntegralType());
   case TemplateArgument::Type:
 return IsReconstitutableType(TA.getAsType());
   default:

diff  --git a/clang/test/CodeGenCXX/debug-info-simple-template-names.cpp 
b/clang/test/CodeGenCXX/debug-info-simple-template-names.cpp
index 190d121937a03..98faa0fc6f0bb 100644
--- a/clang/test/CodeGenCXX/debug-info-simple-template-names.cpp
+++ b/clang/test/CodeGenCXX/debug-info-simple-template-names.cpp
@@ -31,6 +31,10 @@ struct t4 {
 };
   
 t4 v1;
+enum { UnnamedEnum1 };
+template
+void f4() {
+}
 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "t3<(anonymous 
namespace)::LocalEnum, ((anonymous namespace)::LocalEnum)0>"
 void f() {
   // Basic examples of simplifiable/rebuildable names
@@ -122,4 +126,7 @@ void f() {
   int fnrt() __attribute__((noreturn));
   f1();
   // CHECK: !DISubprogram(name: "f1",
+  
+  f4();
+  // CHECK: !DISubprogram(name: "f4<((unnamed enum at {{.*}}))0>"
 }

diff  --git 
a/cross-project-tests/debuginfo-tests/clang_llvm_roundtrip/simplified_template_names.cpp
 
b/cross-project-tests/debuginfo-tests/clang_llvm_roundtrip/simplified_template_names.cpp
index 9bc14f8ce6577..b68d4e8c04b94 100644
--- 
a/cross-project-tests/debuginfo-tests/clang_llvm_roundtrip/simplified_template_names.cpp
+++ 
b/cross-project-tests/debuginfo-tests/clang_llvm_roundtrip/simplified_template_names.cpp
@@ -179,6 +179,10 @@ struct t12 {
   t11 v1;
 };
 
+template
+void f10() {
+}
+
 int main() {
   struct { } A;
   auto L = []{};
@@ -327,6 +331,7 @@ int main() {
   f1();
   int fnrt() __attribute__((noreturn));
   f1();
+  f10();
 }
 void t8::mem() {
   struct t7 { };



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


[clang] 6b30623 - DebugInfo: Make the simplified template names prefix more unique

2022-04-06 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2022-04-06T18:25:46Z
New Revision: 6b306233f78876a1d197ed6e1f05785505de7c63

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

LOG: DebugInfo: Make the simplified template names prefix more unique

Added: 


Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp
clang/test/CodeGenCXX/debug-info-simple-template-names.cpp
llvm/lib/Bitcode/Reader/MetadataLoader.cpp
llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
llvm/test/DebugInfo/X86/tu-to-non-tu.ll
llvm/test/ThinLTO/X86/debuginfo-compositetype-import.ll
llvm/test/tools/llvm-dwarfdump/X86/simplified-template-names-fail.s
llvm/test/tools/llvm-dwarfdump/X86/simplified-template-names.s

Removed: 




diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index a37dc81c4bb8f..eeabae09c2cab 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -5199,7 +5199,7 @@ std::string CGDebugInfo::GetName(const Decl *D, bool 
Qualified) const {
 TemplateNamesKind == codegenoptions::DebugTemplateNamesKind::Mangled;
 // check if it's a template
 if (Mangled)
-  OS << "_STN";
+  OS << "_STN|";
 
 OS << ND->getDeclName();
 std::string EncodedOriginalName;

diff  --git a/clang/test/CodeGenCXX/debug-info-simple-template-names.cpp 
b/clang/test/CodeGenCXX/debug-info-simple-template-names.cpp
index 5bf1b54b97708..190d121937a03 100644
--- a/clang/test/CodeGenCXX/debug-info-simple-template-names.cpp
+++ b/clang/test/CodeGenCXX/debug-info-simple-template-names.cpp
@@ -35,20 +35,20 @@ t4 v1;
 void f() {
   // Basic examples of simplifiable/rebuildable names
   f1<>();
-  // CHECK: !DISubprogram(name: "_STNf1|<>",
+  // CHECK: !DISubprogram(name: "_STN|f1|<>",
   // SIMPLE: !DISubprogram(name: "f1",
   // FULL: !DISubprogram(name: "f1<>",
   f1();
-  // CHECK: !DISubprogram(name: "_STNf1|",
+  // CHECK: !DISubprogram(name: "_STN|f1|",
   f1();
-  // CHECK: !DISubprogram(name: "_STNf1|",
+  // CHECK: !DISubprogram(name: "_STN|f1|",
   f2();
-  // CHECK: !DISubprogram(name: "_STNf2|",
+  // CHECK: !DISubprogram(name: "_STN|f2|",
 
   // Check that even though the nested name can't be rebuilt, it'll carry its
   // full name and the outer name can be rebuilt from that.
   f1>();
-  // CHECK: !DISubprogram(name: "_STNf1| >",
+  // CHECK: !DISubprogram(name: "_STN|f1| >",
 
   // Vector array types are encoded in DWARF but the decoding in llvm-dwarfdump
   // isn't implemented yet.
@@ -109,7 +109,7 @@ void f() {
   // worry about seeing conversion operators as parameters to other templates.
 
   f3();
-  // CHECK: !DISubprogram(name: "_STNf3|",
+  // CHECK: !DISubprogram(name: "_STN|f3|",
   
   f1<_BitInt(3)>();
   // CHECK: !DISubprogram(name: "f1<_BitInt(3)>",

diff  --git a/llvm/lib/Bitcode/Reader/MetadataLoader.cpp 
b/llvm/lib/Bitcode/Reader/MetadataLoader.cpp
index 7d097bbff6d82..420df9b4e14a9 100644
--- a/llvm/lib/Bitcode/Reader/MetadataLoader.cpp
+++ b/llvm/lib/Bitcode/Reader/MetadataLoader.cpp
@@ -1509,7 +1509,7 @@ Error 
MetadataLoader::MetadataLoaderImpl::parseOneMetadata(
 // DICompositeType flag specifying whether template parameters are
 // required on declarations of this type.
 StringRef NameStr = Name->getString();
-if (!NameStr.contains('<') || NameStr.startswith("_STN"))
+if (!NameStr.contains('<') || NameStr.startswith("_STN|"))
   TemplateParams = getMDOrNull(Record[14]);
   }
 } else {

diff  --git a/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp 
b/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
index 1dbe22dcd1c58..265096c7e3fba 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
@@ -291,7 +291,7 @@ struct DWARFTypePrinter {
   }
   Word = true;
   StringRef Name = NamePtr;
-  static constexpr StringRef MangledPrefix = "_STN";
+  static constexpr StringRef MangledPrefix = "_STN|";
   if (Name.startswith(MangledPrefix)) {
 Name = Name.drop_front(MangledPrefix.size());
 auto Separator = Name.find('|');

diff  --git a/llvm/test/DebugInfo/X86/tu-to-non-tu.ll 
b/llvm/test/DebugInfo/X86/tu-to-non-tu.ll
index c204c67e9b652..119c4884900a9 100644
--- a/llvm/test/DebugInfo/X86/tu-to-non-tu.ll
+++ b/llvm/test/DebugInfo/X86/tu-to-non-tu.ll
@@ -66,7 +66,7 @@
 ; };
 ; ref_templ_non_tu_simple v3;
 ; 
-; // Modify templ_non_tu's name to be mangled ('_STN' name '|' args)
+; // Modify templ_non_tu's name to be mangled ('_STN|' name '|' args)
 ; template <>
 ; struct templ_non_tu {
 ;   virtual void f1();
@@ -117,7 +117,7 @@
 ; CHECK: DW_AT_name {{.*}}"ref_templ_non_tu"
 ; CHECK: DW_TAG_structure_type
 ; CHECK-NOT: DW_TAG
-; CHECK: DW_AT_name {{.*}}"_STNtempl_non_tu|"
+; CHECK: DW_AT_name 

[clang] bb3980a - DebugInfo: Don't use enumerators in template names for debug info as they are not canonical

2022-04-05 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2022-04-05T17:16:42Z
New Revision: bb3980ae9fa7e19540080285f2bf2d960ea802fc

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

LOG: DebugInfo: Don't use enumerators in template names for debug info as they 
are not canonical

Since enumerators may not be available in every translation unit they
can't be reliably used to name entities. (this also makes simplified
template name roundtripping infeasible - since the expected name could
only be rebuilt if the enumeration definition could be found (or only if
it couldn't be found, depending on the context of the original name))

Added: 


Modified: 
clang/include/clang/AST/PrettyPrinter.h
clang/lib/AST/TemplateBase.cpp
clang/lib/CodeGen/CGDebugInfo.cpp
clang/test/CodeGenCXX/debug-info-simple-template-names.cpp
llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
llvm/test/tools/llvm-dwarfdump/X86/prettyprint_types.s
llvm/test/tools/llvm-dwarfdump/X86/simplified-template-names.s

Removed: 




diff  --git a/clang/include/clang/AST/PrettyPrinter.h 
b/clang/include/clang/AST/PrettyPrinter.h
index 54cb57227f7a0..cb25b2750dd43 100644
--- a/clang/include/clang/AST/PrettyPrinter.h
+++ b/clang/include/clang/AST/PrettyPrinter.h
@@ -74,7 +74,8 @@ struct PrintingPolicy {
 SuppressImplicitBase(false), FullyQualifiedName(false),
 PrintCanonicalTypes(false), PrintInjectedClassNameWithArguments(true),
 UsePreferredNames(true), AlwaysIncludeTypeForTemplateArgument(false),
-CleanUglifiedParameters(false), EntireContentsOfLargeArray(true) {}
+CleanUglifiedParameters(false), EntireContentsOfLargeArray(true),
+UseEnumerators(true) {}
 
   /// Adjust this printing policy for cases where it's known that we're
   /// printing C++ code (for instance, if AST dumping reaches a C++-only
@@ -290,6 +291,10 @@ struct PrintingPolicy {
   /// template parameters, no matter how many elements there are.
   unsigned EntireContentsOfLargeArray : 1;
 
+  /// Whether to print enumerator non-type template parameters with a matching
+  /// enumerator name or via cast of an integer.
+  unsigned UseEnumerators : 1;
+
   /// Callbacks to use to allow the behavior of printing to be customized.
   const PrintingCallbacks *Callbacks = nullptr;
 };

diff  --git a/clang/lib/AST/TemplateBase.cpp b/clang/lib/AST/TemplateBase.cpp
index 3418401517c84..229a8db21ab63 100644
--- a/clang/lib/AST/TemplateBase.cpp
+++ b/clang/lib/AST/TemplateBase.cpp
@@ -59,15 +59,17 @@ static void printIntegral(const TemplateArgument , 
raw_ostream ,
   const Type *T = TemplArg.getIntegralType().getTypePtr();
   const llvm::APSInt  = TemplArg.getAsIntegral();
 
-  if (const EnumType *ET = T->getAs()) {
-for (const EnumConstantDecl* ECD : ET->getDecl()->enumerators()) {
-  // In Sema::CheckTemplateArugment, enum template arguments value are
-  // extended to the size of the integer underlying the enum type.  This
-  // may create a size 
diff erence between the enum value and template
-  // argument value, requiring isSameValue here instead of operator==.
-  if (llvm::APSInt::isSameValue(ECD->getInitVal(), Val)) {
-ECD->printQualifiedName(Out, Policy);
-return;
+  if (Policy.UseEnumerators) {
+if (const EnumType *ET = T->getAs()) {
+  for (const EnumConstantDecl *ECD : ET->getDecl()->enumerators()) {
+// In Sema::CheckTemplateArugment, enum template arguments value are
+// extended to the size of the integer underlying the enum type.  This
+// may create a size 
diff erence between the enum value and template
+// argument value, requiring isSameValue here instead of operator==.
+if (llvm::APSInt::isSameValue(ECD->getInitVal(), Val)) {
+  ECD->printQualifiedName(Out, Policy);
+  return;
+}
   }
 }
   }

diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index beb640375dfba..a37dc81c4bb8f 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -248,6 +248,7 @@ PrintingPolicy CGDebugInfo::getPrintingPolicy() const {
   PP.PrintCanonicalTypes = true;
   PP.UsePreferredNames = false;
   PP.AlwaysIncludeTypeForTemplateArgument = true;
+  PP.UseEnumerators = false;
 
   // Apply -fdebug-prefix-map.
   PP.Callbacks = 

diff  --git a/clang/test/CodeGenCXX/debug-info-simple-template-names.cpp 
b/clang/test/CodeGenCXX/debug-info-simple-template-names.cpp
index 00c4361e11ef4..5bf1b54b97708 100644
--- a/clang/test/CodeGenCXX/debug-info-simple-template-names.cpp
+++ b/clang/test/CodeGenCXX/debug-info-simple-template-names.cpp
@@ -31,7 +31,7 @@ struct t4 {
 };
   
 t4 v1;
-// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "t3<(anonymous 

Re: [clang] abe997b - [CMake][Fuchsia] Switch to lld on Apple platforms

2022-03-28 Thread David Blaikie via cfe-commits
Neat!

On Tue, Mar 22, 2022 at 1:07 AM Petr Hosek via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

>
> Author: Petr Hosek
> Date: 2022-03-22T01:06:30-07:00
> New Revision: abe997bb2dd61188784954ae866352740629985d
>
> URL:
> https://github.com/llvm/llvm-project/commit/abe997bb2dd61188784954ae866352740629985d
> DIFF:
> https://github.com/llvm/llvm-project/commit/abe997bb2dd61188784954ae866352740629985d.diff
>
> LOG: [CMake][Fuchsia] Switch to lld on Apple platforms
>
> lld Mach-O backend supports all our use cases now.
>
> Differential Revision: https://reviews.llvm.org/D122047
>
> Added:
>
>
> Modified:
> clang/cmake/caches/Fuchsia-stage2.cmake
> clang/cmake/caches/Fuchsia.cmake
>
> Removed:
>
>
>
>
> 
> diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake
> b/clang/cmake/caches/Fuchsia-stage2.cmake
> index d64229bd572eb..df15aa65cc9d2 100644
> --- a/clang/cmake/caches/Fuchsia-stage2.cmake
> +++ b/clang/cmake/caches/Fuchsia-stage2.cmake
> @@ -9,10 +9,7 @@ set(LLVM_ENABLE_RUNTIMES
> "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "
>
>  set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
>  set(LLVM_ENABLE_DIA_SDK OFF CACHE BOOL "")
> -if(NOT APPLE)
> -  # TODO: Remove this once we switch to ld64.lld.
> -  set(LLVM_ENABLE_LLD ON CACHE BOOL "")
> -endif()
> +set(LLVM_ENABLE_LLD ON CACHE BOOL "")
>  set(LLVM_ENABLE_LTO ON CACHE BOOL "")
>  set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR ON CACHE BOOL "")
>  set(LLVM_ENABLE_LIBCXX ON CACHE BOOL "")
> @@ -31,11 +28,8 @@ if(WIN32)
>  endif()
>
>  set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "")
> -if(NOT APPLE)
> -  # TODO: Remove this once we switch to ld64.lld.
> -  set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
> -  set(CLANG_DEFAULT_OBJCOPY llvm-objcopy CACHE STRING "")
> -endif()
> +set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
> +set(CLANG_DEFAULT_OBJCOPY llvm-objcopy CACHE STRING "")
>  set(CLANG_DEFAULT_RTLIB compiler-rt CACHE STRING "")
>  set(CLANG_ENABLE_ARCMT OFF CACHE BOOL "")
>  set(CLANG_ENABLE_STATIC_ANALYZER ON CACHE BOOL "")
>
> diff  --git a/clang/cmake/caches/Fuchsia.cmake
> b/clang/cmake/caches/Fuchsia.cmake
> index 8e9e44d5917ed..bf2ea1802963d 100644
> --- a/clang/cmake/caches/Fuchsia.cmake
> +++ b/clang/cmake/caches/Fuchsia.cmake
> @@ -22,11 +22,8 @@ if(WIN32)
>  endif()
>
>  set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "")
> -if(NOT APPLE)
> -  # TODO: Remove this once we switch to ld64.lld.
> -  set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
> -  set(CLANG_DEFAULT_OBJCOPY llvm-objcopy CACHE STRING "")
> -endif()
> +set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
> +set(CLANG_DEFAULT_OBJCOPY llvm-objcopy CACHE STRING "")
>  set(CLANG_DEFAULT_RTLIB compiler-rt CACHE STRING "")
>  set(CLANG_ENABLE_ARCMT OFF CACHE BOOL "")
>  set(CLANG_ENABLE_STATIC_ANALYZER OFF CACHE BOOL "")
> @@ -112,11 +109,8 @@ if(UNIX)
>set(BOOTSTRAP_CMAKE_EXE_LINKER_FLAGS "-ldl -lpthread" CACHE STRING "")
>  endif()
>
> +set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "")
>  set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "")
> -if(NOT APPLE)
> -  # TODO: Remove this once we switch to ld64.lld.
> -  set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "")
> -endif()
>
>  set(CLANG_BOOTSTRAP_TARGETS
>check-all
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 34b9b1e - Disable -Wmissing-prototypes for internal linkage functions that aren't explicitly marked "static"

2022-03-25 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2022-03-25T23:53:19Z
New Revision: 34b9b1ea4874b109b998d59a837f81f2f730001c

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

LOG: Disable -Wmissing-prototypes for internal linkage functions that aren't 
explicitly marked "static"

Some functions can end up non-externally visible despite not being
declared "static" or in an unnamed namespace in C++ - such as by having
parameters that are of non-external types.

Such functions aren't mistakenly intended to be defining some function
that needs a declaration. They could be maybe more legible (except for
the operator new example) with an explicit static, but that's a
stylistic thing outside what should be addressed by a warning.

This reapplies 275c56226d7fbd6a4d554807374f78d323aa0c1c - once we figure
out what to do about the change in behavior for -Wnon-c-typedef-for-linkage
(this reverts the revert commit 85ee1d3ca1d06b6bd3477515b8d0c72c8df7c069)

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

Added: 


Modified: 
clang/lib/Sema/SemaDecl.cpp
clang/test/SemaCXX/anonymous-struct.cpp
clang/test/SemaCXX/warn-missing-prototypes.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 5c262063a6aef..4051ab29fb26f 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -14233,6 +14233,11 @@ ShouldWarnAboutMissingPrototype(const FunctionDecl *FD,
   if (FD->isDeleted())
 return false;
 
+  // Don't warn on implicitly local functions (such as having local-typed
+  // parameters).
+  if (!FD->isExternallyVisible())
+return false;
+
   for (const FunctionDecl *Prev = FD->getPreviousDecl();
Prev; Prev = Prev->getPreviousDecl()) {
 // Ignore any declarations that occur in function or method

diff  --git a/clang/test/SemaCXX/anonymous-struct.cpp 
b/clang/test/SemaCXX/anonymous-struct.cpp
index 0a5395e15780b..7cf05ee3c49ae 100644
--- a/clang/test/SemaCXX/anonymous-struct.cpp
+++ b/clang/test/SemaCXX/anonymous-struct.cpp
@@ -183,3 +183,9 @@ namespace BuiltinName {
 void memcpy(); // expected-note {{due to this member}}
   } A; // expected-note {{given name 'A' for linkage purposes by this typedef}}
 }
+namespace inline_defined_static_member {
+typedef struct { // expected-warning {{anonymous non-C-compatible type}}
+  static void f() { // expected-note {{due to this member}}
+  }
+} A; // expected-note {{given name 'A' for linkage purposes by this typedef}}
+}

diff  --git a/clang/test/SemaCXX/warn-missing-prototypes.cpp 
b/clang/test/SemaCXX/warn-missing-prototypes.cpp
index e8637e5a90eab..2880514ee02b7 100644
--- a/clang/test/SemaCXX/warn-missing-prototypes.cpp
+++ b/clang/test/SemaCXX/warn-missing-prototypes.cpp
@@ -44,3 +44,16 @@ void j() = delete;
 extern void k() {} // expected-warning {{no previous prototype for function 
'k'}}
 // expected-note@-1{{declare 'static' if the function is not intended to be 
used outside of this translation unit}}
 // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-2]]:{{.*}}-[[@LINE-2]]:{{.*}}}:"{{.*}}"
+
+namespace {
+struct anon { };
+}
+
+// No warning because this has internal linkage despite not being declared
+// explicitly 'static', owing to the internal linkage parameter.
+void l(anon) {
+}
+
+void *operator new(decltype(sizeof(3)) size, const anon &) throw() {
+  return nullptr;
+}



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


[clang] 7b498be - DebugInfo: Classify noreturn function types as non-reconstructible

2022-03-24 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2022-03-24T18:53:14Z
New Revision: 7b498beef03ae07bb98796461a957af836074b92

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

LOG: DebugInfo: Classify noreturn function types as non-reconstructible

This information isn't preserved in the DWARF description of function
types (though probably should be - it's preserved on the function
declarations/definitions themselves through the DW_AT_noreturn attribute
- but we should move or also include that in the subroutine type itself
too - but for now, with it not being there, the DWARF is lossy and
can't be reconstructed)

Added: 


Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp
clang/test/CodeGenCXX/debug-info-simple-template-names.cpp

cross-project-tests/debuginfo-tests/clang_llvm_roundtrip/simplified_template_names.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 75ce74b31846f..beb640375dfba 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -5078,6 +5078,7 @@ struct ReconstitutableType : public 
RecursiveASTVisitor {
   bool VisitFunctionProtoType(FunctionProtoType *FT) {
 // noexcept is not encoded in DWARF, so the reversi
 Reconstitutable &= !isNoexceptExceptionSpec(FT->getExceptionSpecType());
+Reconstitutable &= !FT->getNoReturnAttr();
 return Reconstitutable;
   }
   bool VisitRecordType(RecordType *RT) {

diff  --git a/clang/test/CodeGenCXX/debug-info-simple-template-names.cpp 
b/clang/test/CodeGenCXX/debug-info-simple-template-names.cpp
index 3d8e69abed99b..00c4361e11ef4 100644
--- a/clang/test/CodeGenCXX/debug-info-simple-template-names.cpp
+++ b/clang/test/CodeGenCXX/debug-info-simple-template-names.cpp
@@ -116,4 +116,10 @@ void f() {
 
   f1();
   // CHECK: !DISubprogram(name: "f1",
+
+  // Add a parameter just so this 
diff ers from other attributed function types
+  // that don't mangle 
diff erently.
+  int fnrt() __attribute__((noreturn));
+  f1();
+  // CHECK: !DISubprogram(name: "f1",
 }

diff  --git 
a/cross-project-tests/debuginfo-tests/clang_llvm_roundtrip/simplified_template_names.cpp
 
b/cross-project-tests/debuginfo-tests/clang_llvm_roundtrip/simplified_template_names.cpp
index 5ecc3bc7fc144..5b1afcb29cc7f 100644
--- 
a/cross-project-tests/debuginfo-tests/clang_llvm_roundtrip/simplified_template_names.cpp
+++ 
b/cross-project-tests/debuginfo-tests/clang_llvm_roundtrip/simplified_template_names.cpp
@@ -325,6 +325,8 @@ int main() {
   f1::*>();
   void fcc() __attribute__((swiftcall));
   f1();
+  int fnrt() __attribute__((noreturn));
+  f1();
 }
 void t8::mem() {
   struct t7 { };



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


[clang] 85ee1d3 - Revert "Disable -Wmissing-prototypes for internal linkage functions that aren't explicitly marked "static""

2022-03-09 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2022-03-09T21:12:56Z
New Revision: 85ee1d3ca1d06b6bd3477515b8d0c72c8df7c069

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

LOG: Revert "Disable -Wmissing-prototypes for internal linkage functions that 
aren't explicitly marked "static""

Regresses:
typedef struct {
  static void  f() {
  }
} a_t;

Causing this to error instead of warn, because the linkage is computed
earlier/too early perhaps. I'll send out a review to see if there's some
other path forward or if this is an acceptable regression, etc.

This reverts commit 275c56226d7fbd6a4d554807374f78d323aa0c1c.

Added: 


Modified: 
clang/lib/Sema/SemaDecl.cpp
clang/test/SemaCXX/warn-missing-prototypes.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index b88d9f2f847fd..fa086ae0f6126 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -14210,9 +14210,6 @@ ShouldWarnAboutMissingPrototype(const FunctionDecl *FD,
   if (!FD->isGlobal())
 return false;
 
-  if (!FD->isExternallyVisible())
-return false;
-
   // Don't warn about C++ member functions.
   if (isa(FD))
 return false;

diff  --git a/clang/test/SemaCXX/warn-missing-prototypes.cpp 
b/clang/test/SemaCXX/warn-missing-prototypes.cpp
index 2880514ee02b7..e8637e5a90eab 100644
--- a/clang/test/SemaCXX/warn-missing-prototypes.cpp
+++ b/clang/test/SemaCXX/warn-missing-prototypes.cpp
@@ -44,16 +44,3 @@ void j() = delete;
 extern void k() {} // expected-warning {{no previous prototype for function 
'k'}}
 // expected-note@-1{{declare 'static' if the function is not intended to be 
used outside of this translation unit}}
 // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-2]]:{{.*}}-[[@LINE-2]]:{{.*}}}:"{{.*}}"
-
-namespace {
-struct anon { };
-}
-
-// No warning because this has internal linkage despite not being declared
-// explicitly 'static', owing to the internal linkage parameter.
-void l(anon) {
-}
-
-void *operator new(decltype(sizeof(3)) size, const anon &) throw() {
-  return nullptr;
-}



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


[clang] c0a6433 - Simplify OpenMP Lambda use

2022-03-07 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2022-03-07T18:23:20Z
New Revision: c0a6433f2b5120d79f03431e9bf61b4da1184412

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

LOG: Simplify OpenMP Lambda use

* Use default ref capture for non-escaping lambdas (this makes
  maintenance easier by allowing new uses, removing uses, having
  conditional uses (such as in assertions) not require updates to an
  explicit capture list)
* Simplify addPrivate API not to take a lambda, since it calls it
  unconditionally/immediately anyway - most callers are simply passing
  in a named value or short expression anyway and the lambda syntax just
  adds noise/overhead

Reviewed By: ABataev

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

Added: 


Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/lib/CodeGen/CodeGenFunction.h

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 399b2f63e8443..3089cdc4e4a92 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -370,8 +370,7 @@ class CGOpenMPInnerExprInfo final : public 
CGOpenMPInlinedRegionInfo {
   /*RefersToEnclosingVariableOrCapture=*/false,
   VD->getType().getNonReferenceType(), VK_LValue,
   C.getLocation());
-  PrivScope.addPrivate(
-  VD, [, ]() { return CGF.EmitLValue().getAddress(CGF); });
+  PrivScope.addPrivate(VD, CGF.EmitLValue().getAddress(CGF));
 }
 (void)PrivScope.Privatize();
   }
@@ -634,10 +633,8 @@ static void 
emitInitWithReductionInitializer(CodeGenFunction ,
 const auto *RHSDRE =
 cast(cast(RHS)->getSubExpr());
 CodeGenFunction::OMPPrivateScope PrivateScope(CGF);
-PrivateScope.addPrivate(cast(LHSDRE->getDecl()),
-[=]() { return Private; });
-PrivateScope.addPrivate(cast(RHSDRE->getDecl()),
-[=]() { return Original; });
+PrivateScope.addPrivate(cast(LHSDRE->getDecl()), Private);
+PrivateScope.addPrivate(cast(RHSDRE->getDecl()), Original);
 (void)PrivateScope.Privatize();
 RValue Func = RValue::get(Reduction.second);
 CodeGenFunction::OpaqueValueMapping Map(CGF, OVE, Func);
@@ -1141,15 +1138,13 @@ emitCombinerOrInitializer(CodeGenModule , QualType 
Ty,
 Out->getLocation());
   CodeGenFunction::OMPPrivateScope Scope(CGF);
   Address AddrIn = CGF.GetAddrOfLocalVar();
-  Scope.addPrivate(In, [, AddrIn, PtrTy]() {
-return CGF.EmitLoadOfPointerLValue(AddrIn, PtrTy->castAs())
-.getAddress(CGF);
-  });
+  Scope.addPrivate(
+  In, CGF.EmitLoadOfPointerLValue(AddrIn, PtrTy->castAs())
+  .getAddress(CGF));
   Address AddrOut = CGF.GetAddrOfLocalVar();
-  Scope.addPrivate(Out, [, AddrOut, PtrTy]() {
-return CGF.EmitLoadOfPointerLValue(AddrOut, PtrTy->castAs())
-.getAddress(CGF);
-  });
+  Scope.addPrivate(
+  Out, CGF.EmitLoadOfPointerLValue(AddrOut, PtrTy->castAs())
+   .getAddress(CGF));
   (void)Scope.Privatize();
   if (!IsCombiner && Out->hasInit() &&
   !CGF.isTrivialInitializer(Out->getInit())) {
@@ -3938,8 +3933,7 @@ static void emitPrivatesInit(CodeGenFunction ,
   Address SrcElement) {
   // Clean up any temporaries needed by the initialization.
   CodeGenFunction::OMPPrivateScope InitScope(CGF);
-  InitScope.addPrivate(
-  Elem, [SrcElement]() -> Address { return SrcElement; });
+  InitScope.addPrivate(Elem, SrcElement);
   (void)InitScope.Privatize();
   // Emit initialization for single element.
   CodeGenFunction::CGCapturedStmtRAII CapInfoRAII(
@@ -3951,9 +3945,7 @@ static void emitPrivatesInit(CodeGenFunction ,
   }
 } else {
   CodeGenFunction::OMPPrivateScope InitScope(CGF);
-  InitScope.addPrivate(Elem, [SharedRefLValue, ]() -> Address {
-return SharedRefLValue.getAddress(CGF);
-  });
+  InitScope.addPrivate(Elem, SharedRefLValue.getAddress(CGF));
   (void)InitScope.Privatize();
   CodeGenFunction::CGCapturedStmtRAII CapInfoRAII(CGF, );
   CGF.EmitExprAsInit(Init, VD, PrivateLValue,
@@ -4099,14 +4091,11 @@ class OMPIteratorGeneratorScope final
 for (unsigned I = 0, End = E->numOfIterators(); I < End; ++I) {
   Uppers.push_back(CGF.EmitScalarExpr(E->getHelper(I).Upper));
   const auto *VD = cast(E->getIteratorDecl(I));
-  addPrivate(VD, [, VD]() {
-return CGF.CreateMemTemp(VD->getType(), VD->getName());
-  });
+  

Re: [clang] 1d1b089 - Fix more unused lambda capture warnings, NFC

2022-03-06 Thread David Blaikie via cfe-commits
On Mon, Feb 28, 2022 at 10:12 AM Reid Kleckner  wrote:

> I agree, but clearly this person chose a particular style, and I wasn't
> trying to revise their code style, just to fix some the Bazel build, which
> uses -Werror.
>

Oh, wow, yeah, this file/corner of the codebase is deep into lambdas, wow.
Sent https://reviews.llvm.org/D121077 for the broader change (both the
capture lists and at least one function that seemed to not really benefit
from taking a lambda - maybe other functions could have similar cleanup)


> The way that `assert` can affect a lambda's capture list seems like a
> particularly good argument for having a project wide style recommendation
> to never use explicit capture lists.
>

Yeah, not sure it's worth words in the style guide unless it's especially
contentious (the presence of code like this might argue that it is - but
hopefully even in this case only pointing it out will be enough) but maybe.

- Dave


>
> On Mon, Feb 28, 2022 at 9:45 AM David Blaikie  wrote:
>
>> FWIW, I think it's probably simpler/more maintainable to default capture
>> by reference ("[&]") if a lambda doesn't escape its scope (if it's never
>> type erased/put in a std::function or equivalent). Avoids assert/non-assert
>> unused issues, having to maintain/update the list when the code changes and
>> makes a capture live/dead/etc.
>>
>> On Wed, Feb 23, 2022 at 2:09 PM Reid Kleckner via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>>
>>> Author: Reid Kleckner
>>> Date: 2022-02-23T14:07:04-08:00
>>> New Revision: 1d1b089c5d503e2fc8697887411730105f66c774
>>>
>>> URL:
>>> https://github.com/llvm/llvm-project/commit/1d1b089c5d503e2fc8697887411730105f66c774
>>> DIFF:
>>> https://github.com/llvm/llvm-project/commit/1d1b089c5d503e2fc8697887411730105f66c774.diff
>>>
>>> LOG: Fix more unused lambda capture warnings, NFC
>>>
>>> Added:
>>>
>>>
>>> Modified:
>>> clang/lib/CodeGen/CGOpenMPRuntime.cpp
>>>
>>> Removed:
>>>
>>>
>>>
>>>
>>> 
>>> diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
>>> b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
>>> index b4033da890c4..3f4a78ddbf3c 100644
>>> --- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
>>> +++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
>>> @@ -10358,8 +10358,8 @@ void CGOpenMPRuntime::emitTargetCall(
>>>llvm::Value *MapTypesArray = nullptr;
>>>llvm::Value *MapNamesArray = nullptr;
>>>// Generate code for the host fallback function.
>>> -  auto & = [this, OutlinedFn, , ,
>>> RequiresOuterTask,
>>> -, OffloadingMandatory](CodeGenFunction )
>>> {
>>> +  auto & = [this, , OutlinedFn, ,
>>> RequiresOuterTask, ,
>>> +OffloadingMandatory](CodeGenFunction ) {
>>>  if (OffloadingMandatory) {
>>>CGF.Builder.CreateUnreachable();
>>>  } else {
>>> @@ -10371,9 +10371,8 @@ void CGOpenMPRuntime::emitTargetCall(
>>>  }
>>>};
>>>// Fill up the pointer arrays and transfer execution to the device.
>>> -  auto & = [this, Device, OutlinedFn, OutlinedFnID, ,
>>> ,
>>> -, , ,
>>> RequiresOuterTask,
>>> -, SizeEmitter,
>>> +  auto & = [this, Device, OutlinedFnID, , ,
>>> +, , SizeEmitter,
>>>  FallbackGen](CodeGenFunction , PrePostActionTy
>>> &) {
>>>  if (Device.getInt() == OMPC_DEVICE_ancestor) {
>>>// Reverse offloading is not supported, so just execute on the
>>> host.
>>> @@ -10392,6 +10391,7 @@ void CGOpenMPRuntime::emitTargetCall(
>>>
>>>  // From this point on, we need to have an ID of the target region
>>> defined.
>>>  assert(OutlinedFnID && "Invalid outlined function ID!");
>>> +(void)OutlinedFnID;
>>>
>>>  // Emit device ID if any.
>>>  llvm::Value *DeviceID;
>>> @@ -10529,8 +10529,7 @@ void CGOpenMPRuntime::emitTargetCall(
>>>};
>>>
>>>// Notify that the host version must be executed.
>>> -  auto & = [this, , OutlinedFn, , ,
>>> RequiresOuterTask,
>>> -FallbackGen](CodeGenFunction , PrePostActionTy
>>> &) {
>>> +  auto & = [FallbackGen](CodeGenFunction , PrePostActionTy
>>> &) {
>>>  FallbackGen(CGF);
>>>};
>>>
>>>
>>>
>>>
>>> ___
>>> cfe-commits mailing list
>>> cfe-commits@lists.llvm.org
>>> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>>
>>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [clang] 1d1b089 - Fix more unused lambda capture warnings, NFC

2022-02-28 Thread David Blaikie via cfe-commits
FWIW, I think it's probably simpler/more maintainable to default capture by
reference ("[&]") if a lambda doesn't escape its scope (if it's never type
erased/put in a std::function or equivalent). Avoids assert/non-assert
unused issues, having to maintain/update the list when the code changes and
makes a capture live/dead/etc.

On Wed, Feb 23, 2022 at 2:09 PM Reid Kleckner via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

>
> Author: Reid Kleckner
> Date: 2022-02-23T14:07:04-08:00
> New Revision: 1d1b089c5d503e2fc8697887411730105f66c774
>
> URL:
> https://github.com/llvm/llvm-project/commit/1d1b089c5d503e2fc8697887411730105f66c774
> DIFF:
> https://github.com/llvm/llvm-project/commit/1d1b089c5d503e2fc8697887411730105f66c774.diff
>
> LOG: Fix more unused lambda capture warnings, NFC
>
> Added:
>
>
> Modified:
> clang/lib/CodeGen/CGOpenMPRuntime.cpp
>
> Removed:
>
>
>
>
> 
> diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
> b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
> index b4033da890c4..3f4a78ddbf3c 100644
> --- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
> +++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
> @@ -10358,8 +10358,8 @@ void CGOpenMPRuntime::emitTargetCall(
>llvm::Value *MapTypesArray = nullptr;
>llvm::Value *MapNamesArray = nullptr;
>// Generate code for the host fallback function.
> -  auto & = [this, OutlinedFn, , ,
> RequiresOuterTask,
> -, OffloadingMandatory](CodeGenFunction ) {
> +  auto & = [this, , OutlinedFn, ,
> RequiresOuterTask, ,
> +OffloadingMandatory](CodeGenFunction ) {
>  if (OffloadingMandatory) {
>CGF.Builder.CreateUnreachable();
>  } else {
> @@ -10371,9 +10371,8 @@ void CGOpenMPRuntime::emitTargetCall(
>  }
>};
>// Fill up the pointer arrays and transfer execution to the device.
> -  auto & = [this, Device, OutlinedFn, OutlinedFnID, ,
> ,
> -, , ,
> RequiresOuterTask,
> -, SizeEmitter,
> +  auto & = [this, Device, OutlinedFnID, , ,
> +, , SizeEmitter,
>  FallbackGen](CodeGenFunction , PrePostActionTy &)
> {
>  if (Device.getInt() == OMPC_DEVICE_ancestor) {
>// Reverse offloading is not supported, so just execute on the host.
> @@ -10392,6 +10391,7 @@ void CGOpenMPRuntime::emitTargetCall(
>
>  // From this point on, we need to have an ID of the target region
> defined.
>  assert(OutlinedFnID && "Invalid outlined function ID!");
> +(void)OutlinedFnID;
>
>  // Emit device ID if any.
>  llvm::Value *DeviceID;
> @@ -10529,8 +10529,7 @@ void CGOpenMPRuntime::emitTargetCall(
>};
>
>// Notify that the host version must be executed.
> -  auto & = [this, , OutlinedFn, , ,
> RequiresOuterTask,
> -FallbackGen](CodeGenFunction , PrePostActionTy &)
> {
> +  auto & = [FallbackGen](CodeGenFunction , PrePostActionTy &)
> {
>  FallbackGen(CGF);
>};
>
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 1ea3266 - DebugInfo: Don't simplify template names using _BitInt(N)

2022-02-15 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2022-02-15T11:58:40-08:00
New Revision: 1ea326634b582f5574e0b22b85e5b0c631b30dcf

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

LOG: DebugInfo: Don't simplify template names using _BitInt(N)

_BitInt(N) only encodes the byte size in DWARF, not the bit size, so
can't be reconstituted.

Added: 


Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp
clang/test/CodeGenCXX/debug-info-simple-template-names.cpp

cross-project-tests/debuginfo-tests/clang_llvm_roundtrip/simplified_template_names.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index d8ba5592ad478..91a8f278de5c4 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -5032,6 +5032,15 @@ struct ReconstitutableType : public 
RecursiveASTVisitor {
 Reconstitutable = false;
 return false;
   }
+  bool VisitType(Type *T) {
+// _BitInt(N) isn't reconstitutable because the bit width isn't encoded in
+// the DWARF, only the byte width.
+if (T->isBitIntType()) {
+  Reconstitutable = false;
+  return false;
+}
+return true;
+  }
   bool TraverseEnumType(EnumType *ET) {
 // Unnamed enums can't be reconstituted due to a lack of column info we
 // produce in the DWARF, so we can't get Clang's full name back.

diff  --git a/clang/test/CodeGenCXX/debug-info-simple-template-names.cpp 
b/clang/test/CodeGenCXX/debug-info-simple-template-names.cpp
index 06e83ea6f59eb..d20c9478c363d 100644
--- a/clang/test/CodeGenCXX/debug-info-simple-template-names.cpp
+++ b/clang/test/CodeGenCXX/debug-info-simple-template-names.cpp
@@ -105,4 +105,10 @@ void f() {
 
   f3();
   // CHECK: !DISubprogram(name: "_STNf3|",
+  
+  f1<_BitInt(3)>();
+  // CHECK: !DISubprogram(name: "f1<_BitInt(3)>",
+
+  f1();
+  // CHECK: !DISubprogram(name: "f1",
 }

diff  --git 
a/cross-project-tests/debuginfo-tests/clang_llvm_roundtrip/simplified_template_names.cpp
 
b/cross-project-tests/debuginfo-tests/clang_llvm_roundtrip/simplified_template_names.cpp
index 898b27ec0e479..ee429ef3b5798 100644
--- 
a/cross-project-tests/debuginfo-tests/clang_llvm_roundtrip/simplified_template_names.cpp
+++ 
b/cross-project-tests/debuginfo-tests/clang_llvm_roundtrip/simplified_template_names.cpp
@@ -316,6 +316,8 @@ int main() {
   f1();
   operator_not_really();
   t12 v4;
+  f1<_BitInt(3)>();
+  f1();
 }
 void t8::mem() {
   struct t7 { };



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


[clang] 26c5cf8 - Fix Windows build that fails if a class has a member with the same naem

2022-02-10 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2022-02-10T15:27:31-08:00
New Revision: 26c5cf8fa031f5143fd180fdc8d9dbc26a88e89e

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

LOG: Fix Windows build that fails if a class has a member with the same naem

Added: 


Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index cca5576aac07..eb3f104f7eb9 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -5000,10 +5000,10 @@ static bool 
ReferencesAnonymousEntity(ArrayRef Args) {
 case TemplateArgument::Type: {
   struct ReferencesAnonymous
   : public RecursiveASTVisitor {
-bool ReferencesAnonymous = false;
+bool RefAnon = false;
 bool VisitRecordType(RecordType *RT) {
   if (ReferencesAnonymousEntity(RT)) {
-ReferencesAnonymous = true;
+RefAnon = true;
 return false;
   }
   return true;
@@ -5011,7 +5011,7 @@ static bool 
ReferencesAnonymousEntity(ArrayRef Args) {
   };
   ReferencesAnonymous RT;
   RT.TraverseType(TA.getAsType());
-  if (RT.ReferencesAnonymous)
+  if (RT.RefAnon)
 return true;
   break;
 }



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


[clang] 275c562 - Disable -Wmissing-prototypes for internal linkage functions that aren't explicitly marked "static"

2022-01-31 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2022-01-31T17:34:51-08:00
New Revision: 275c56226d7fbd6a4d554807374f78d323aa0c1c

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

LOG: Disable -Wmissing-prototypes for internal linkage functions that aren't 
explicitly marked "static"

Some functions can end up non-externally visible despite not being
declared "static" or in an unnamed namespace in C++ - such as by having
parameters that are of non-external types.

Such functions aren't mistakenly intended to be defining some function
that needs a declaration. They could be maybe more legible (except for
the `operator new` example) with an explicit static, but that's a
stylistic thing outside what should be addressed by a warning.

Added: 


Modified: 
clang/lib/Sema/SemaDecl.cpp
clang/test/SemaCXX/warn-missing-prototypes.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index e747ffc6f2ac1..cbd9df4d6a7b7 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -14196,6 +14196,9 @@ ShouldWarnAboutMissingPrototype(const FunctionDecl *FD,
   if (!FD->isGlobal())
 return false;
 
+  if (!FD->isExternallyVisible())
+return false;
+
   // Don't warn about C++ member functions.
   if (isa(FD))
 return false;

diff  --git a/clang/test/SemaCXX/warn-missing-prototypes.cpp 
b/clang/test/SemaCXX/warn-missing-prototypes.cpp
index e8637e5a90eab..2880514ee02b7 100644
--- a/clang/test/SemaCXX/warn-missing-prototypes.cpp
+++ b/clang/test/SemaCXX/warn-missing-prototypes.cpp
@@ -44,3 +44,16 @@ void j() = delete;
 extern void k() {} // expected-warning {{no previous prototype for function 
'k'}}
 // expected-note@-1{{declare 'static' if the function is not intended to be 
used outside of this translation unit}}
 // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-2]]:{{.*}}-[[@LINE-2]]:{{.*}}}:"{{.*}}"
+
+namespace {
+struct anon { };
+}
+
+// No warning because this has internal linkage despite not being declared
+// explicitly 'static', owing to the internal linkage parameter.
+void l(anon) {
+}
+
+void *operator new(decltype(sizeof(3)) size, const anon &) throw() {
+  return nullptr;
+}



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


[clang] 2771233 - GCC ABI Compatibility: Preserve alignment of non-pod members in packed structs

2022-01-28 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2022-01-28T11:04:20-08:00
New Revision: 277123376ce08c98b07c154bf83e4092a5d4d3c6

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

LOG: GCC ABI Compatibility: Preserve alignment of non-pod members in packed 
structs

This matches GCC: https://godbolt.org/z/sM5q95PGY

I realize this is an API break for clang+clang - so I'm totally open to
discussing how we should deal with that. If Apple wants to keep the
Clang layout indefinitely, if we want to put a flag on this so non-Apple
folks can opt out of this fix/new behavior.

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/LangOptions.h
clang/lib/AST/RecordLayoutBuilder.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/SemaCXX/class-layout.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 6a9b046a1427d..45e80785e462a 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -236,6 +236,12 @@ ABI Changes in Clang
   is still in the process of being stabilized, so this type should not yet be
   used in interfaces that require ABI stability.
 
+- GCC doesn't pack non-POD members in packed structs unless the packed
+  attribute is also specified on the member. Clang historically did perform
+  such packing. Clang now matches the gcc behavior (except on Darwin and PS4).
+  You can switch back to the old ABI behavior with the flag:
+  ``-fclang-abi-compat=13.0``.
+
 OpenMP Support in Clang
 ---
 

diff  --git a/clang/include/clang/Basic/LangOptions.h 
b/clang/include/clang/Basic/LangOptions.h
index 09afa641acf9b..50c7f038fc6be 100644
--- a/clang/include/clang/Basic/LangOptions.h
+++ b/clang/include/clang/Basic/LangOptions.h
@@ -181,6 +181,10 @@ class LangOptions : public LangOptionsBase {
 /// global-scope inline variables incorrectly.
 Ver12,
 
+/// Attempt to be ABI-compatible with code generated by Clang 13.0.x.
+/// This causes clang to not pack non-POD members of packed structs.
+Ver13,
+
 /// Conform to the underlying platform's C and C++ ABIs as closely
 /// as we can.
 Latest

diff  --git a/clang/lib/AST/RecordLayoutBuilder.cpp 
b/clang/lib/AST/RecordLayoutBuilder.cpp
index 61a30ead165ef..709e05716a562 100644
--- a/clang/lib/AST/RecordLayoutBuilder.cpp
+++ b/clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1887,7 +1887,12 @@ void ItaniumRecordLayoutBuilder::LayoutField(const 
FieldDecl *D,
   UnfilledBitsInLastUnit = 0;
   LastBitfieldStorageUnitSize = 0;
 
-  bool FieldPacked = Packed || D->hasAttr();
+  llvm::Triple Target = Context.getTargetInfo().getTriple();
+  bool FieldPacked = (Packed && (!FieldClass || FieldClass->isPOD() ||
+ Context.getLangOpts().getClangABICompat() <=
+ LangOptions::ClangABI::Ver13 ||
+ Target.isPS4() || Target.isOSDarwin())) ||
+ D->hasAttr();
 
   AlignRequirementKind AlignRequirement = AlignRequirementKind::None;
   CharUnits FieldSize;

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 7f1ce3da7e7eb..553a0b31c0ab3 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -3560,6 +3560,8 @@ void CompilerInvocation::GenerateLangArgs(const 
LangOptions ,
 GenerateArg(Args, OPT_fclang_abi_compat_EQ, "11.0", SA);
   else if (Opts.getClangABICompat() == LangOptions::ClangABI::Ver12)
 GenerateArg(Args, OPT_fclang_abi_compat_EQ, "12.0", SA);
+  else if (Opts.getClangABICompat() == LangOptions::ClangABI::Ver13)
+GenerateArg(Args, OPT_fclang_abi_compat_EQ, "13.0", SA);
 
   if (Opts.getSignReturnAddressScope() ==
   LangOptions::SignReturnAddressScopeKind::All)
@@ -4062,6 +4064,8 @@ bool CompilerInvocation::ParseLangArgs(LangOptions , 
ArgList ,
 Opts.setClangABICompat(LangOptions::ClangABI::Ver11);
   else if (Major <= 12)
 Opts.setClangABICompat(LangOptions::ClangABI::Ver12);
+  else if (Major <= 13)
+Opts.setClangABICompat(LangOptions::ClangABI::Ver13);
 } else if (Ver != "latest") {
   Diags.Report(diag::err_drv_invalid_value)
   << A->getAsString(Args) << A->getValue();

diff  --git a/clang/test/SemaCXX/class-layout.cpp 
b/clang/test/SemaCXX/class-layout.cpp
index 5403bd6e6a6f6..79fa677071109 100644
--- a/clang/test/SemaCXX/class-layout.cpp
+++ b/clang/test/SemaCXX/class-layout.cpp
@@ -1,6 +1,9 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++98 -Wno-inaccessible-base
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only 

[clang] 9c62728 - Default to DWARFv4 on Windows

2022-01-26 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2022-01-26T18:01:07-08:00
New Revision: 9c6272861032f511a23784ce0c5cc8f6ac2f625b

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

LOG: Default to DWARFv4 on Windows

Added: 


Modified: 
clang/lib/Driver/ToolChains/MSVC.h
clang/test/CodeGen/dwarf-version.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/MSVC.h 
b/clang/lib/Driver/ToolChains/MSVC.h
index 8f033de09bf64..c842773996eda 100644
--- a/clang/lib/Driver/ToolChains/MSVC.h
+++ b/clang/lib/Driver/ToolChains/MSVC.h
@@ -69,6 +69,10 @@ class LLVM_LIBRARY_VISIBILITY MSVCToolChain : public 
ToolChain {
 return llvm::DebuggerKind::Default;
   }
 
+  unsigned GetDefaultDwarfVersion() const override {
+return 4;
+  }
+
   enum class SubDirectoryType {
 Bin,
 Include,

diff  --git a/clang/test/CodeGen/dwarf-version.c 
b/clang/test/CodeGen/dwarf-version.c
index b329556ae0d9d..47025e241d13c 100644
--- a/clang/test/CodeGen/dwarf-version.c
+++ b/clang/test/CodeGen/dwarf-version.c
@@ -28,10 +28,10 @@
 // RUN: | FileCheck %s --check-prefixes=NODWARF,CODEVIEW
 // Explicitly request DWARF.
 // RUN: %clang -target i686-pc-windows-msvc -gdwarf -S -emit-llvm -o - %s \
-// RUN: | FileCheck %s --check-prefixes=VER5,NOCODEVIEW
+// RUN: | FileCheck %s --check-prefixes=VER4,NOCODEVIEW
 // Explicitly request both.
 // RUN: %clang -target i686-pc-windows-msvc -gdwarf -gcodeview -S -emit-llvm 
-o - %s \
-// RUN: | FileCheck %s --check-prefixes=VER5,CODEVIEW
+// RUN: | FileCheck %s --check-prefixes=VER4,CODEVIEW
 // RUN: %clang -target powerpc-ibm-aix-xcoff -g -S -emit-llvm -o - %s | \
 // RUN:   FileCheck %s --check-prefix=VER3
 // RUN: %clang -target powerpc-ibm-aix-xcoff -gdwarf-2 -S -emit-llvm -o - %s | 
\



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


[clang] 87e68ca - Improve relnotes for the DWARFv5 default change

2022-01-25 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2022-01-25T09:56:07-08:00
New Revision: 87e68cae50d7ca28975ca6fb456cf0ab2ac915a1

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

LOG: Improve relnotes for the DWARFv5 default change

Added: 


Modified: 
clang/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 5cd2896de54d..2272d7197ac5 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -256,9 +256,9 @@ DWARF Support in Clang
 --
 
 - The default DWARF version has increased from DWARFv4 to DWARFv5.  You can opt
-  back in to the old behavior with -gdwarf-4. Some platforms (Darwin, Android,
-  and SCE for instance) already opt out of this version bump as is suitable for
-  the platform
+  back in to the old behavior with ``-gdwarf-4`` or 
``-fdebug-default-version=4``.
+  Some platforms (Darwin, Android, and SCE for instance) already opt out of 
this
+  version bump as is suitable for the platform
 
 Arm and AArch64 Support in Clang
 



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


Re: [clang] d3b26de - Clang: Change the default DWARF version to 5

2022-01-24 Thread David Blaikie via cfe-commits
Oh, sorry, I see you are zmodem... yay for getting used to more usernames -
thanks for the workaround :)

On Mon, Jan 24, 2022 at 3:05 PM David Blaikie  wrote:

> Looks like that got addressed/worked around with
> https://github.com/llvm/llvm-project/commit/38e16e1cebb891ad47b85727bf46f7dac6d7da94
>
> I'll look into it further once I've cleaned up other live fallout.
>
> On Mon, Jan 24, 2022 at 10:01 AM Hans Wennborg  wrote:
>
>> For me, this broke some tests of the profiling runtime:
>>
>> $ ninja check-profile
>> ...
>> Failed Tests (2):
>>   Profile-i386 :: Linux/instrprof-debug-info-correlate.c
>>   Profile-x86_64 :: Linux/instrprof-debug-info-correlate.c
>>
>> Annoyingly, I can't find any buildbots where this fails, but I'm not
>> really sure which ones test this runtime.
>>
>> It also reproduces on Chromium's builders, e.g.
>>
>> https://logs.chromium.org/logs/chromium/buildbucket/cr-buildbucket/8824141369391584977/+/u/package_clang/stdout
>>
>> Filed https://github.com/llvm/llvm-project/issues/53387
>>
>>
>> On Mon, Jan 24, 2022 at 5:50 AM David Blaikie via cfe-commits
>>  wrote:
>> >
>> >
>> > Author: David Blaikie
>> > Date: 2022-01-23T20:49:57-08:00
>> > New Revision: d3b26dea16108c427b19b5480c9edc76edf8f5b4
>> >
>> > URL:
>> https://github.com/llvm/llvm-project/commit/d3b26dea16108c427b19b5480c9edc76edf8f5b4
>> > DIFF:
>> https://github.com/llvm/llvm-project/commit/d3b26dea16108c427b19b5480c9edc76edf8f5b4.diff
>> >
>> > LOG: Clang: Change the default DWARF version to 5
>> >
>> > (except on platforms that already opt in to specific versions - SCE,
>> > Android, and Darwin using DWARFv4 explicitly, for instance)
>> >
>> > Added:
>> >
>> >
>> > Modified:
>> > clang/docs/ReleaseNotes.rst
>> > clang/include/clang/Driver/ToolChain.h
>> > clang/lib/Driver/ToolChains/Linux.h
>> > clang/test/CodeGen/debug-info-extern-call.c
>> > clang/test/CodeGen/dwarf-version.c
>> > clang/test/Driver/cl-options.c
>> > clang/test/Driver/clang-g-opts.c
>> > clang/test/Driver/ve-toolchain.c
>> > clang/test/Driver/ve-toolchain.cpp
>> >
>> > Removed:
>> >
>> >
>> >
>> >
>> 
>> > diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
>> > index 2eec63901932e..4fe037741256f 100644
>> > --- a/clang/docs/ReleaseNotes.rst
>> > +++ b/clang/docs/ReleaseNotes.rst
>> > @@ -252,6 +252,14 @@ X86 Support in Clang
>> >
>> >  - Support for ``AVX512-FP16`` instructions has been added.
>> >
>> > +DWARF Support in Clang
>> > +--
>> > +
>> > +- The default DWARF version has increased from DWARFv4 to DWARFv5.
>> You can opt
>> > +  back in to the old behavior with -gdwarf-4. Some platforms (Darwin,
>> Android,
>> > +  and SCE for instance) already opt out of this version bump as is
>> suitable for
>> > +  the platform
>> > +
>> >  Arm and AArch64 Support in Clang
>> >  
>> >
>> >
>> > diff  --git a/clang/include/clang/Driver/ToolChain.h
>> b/clang/include/clang/Driver/ToolChain.h
>> > index eb95806a2f75d..37011de6bd6d7 100644
>> > --- a/clang/include/clang/Driver/ToolChain.h
>> > +++ b/clang/include/clang/Driver/ToolChain.h
>> > @@ -510,7 +510,7 @@ class ToolChain {
>> >
>> >// Return the DWARF version to emit, in the absence of arguments
>> >// to the contrary.
>> > -  virtual unsigned GetDefaultDwarfVersion() const { return 4; }
>> > +  virtual unsigned GetDefaultDwarfVersion() const { return 5; }
>> >
>> >// Some toolchains may have
>> > diff erent restrictions on the DWARF version and
>> >// may need to adjust it. E.g. NVPTX may need to enforce DWARF2 even
>> when host
>> >
>> > diff  --git a/clang/lib/Driver/ToolChains/Linux.h
>> b/clang/lib/Driver/ToolChains/Linux.h
>> > index a5ec33bd44f10..a5648d79d655f 100644
>> > --- a/clang/lib/Driver/ToolChains/Linux.h
>> > +++ b/clang/lib/Driver/ToolChains/Linux.h
>> > @@ -40,6 +40,7 @@ class LLVM_LIBRARY_VISIBILITY Linux : public
>> Generic_ELF {
>> >void AddIAMCUIncludeArgs(const llvm::opt::ArgList ,
>> >  

Re: [clang] d3b26de - Clang: Change the default DWARF version to 5

2022-01-24 Thread David Blaikie via cfe-commits
Looks like that got addressed/worked around with
https://github.com/llvm/llvm-project/commit/38e16e1cebb891ad47b85727bf46f7dac6d7da94

I'll look into it further once I've cleaned up other live fallout.

On Mon, Jan 24, 2022 at 10:01 AM Hans Wennborg  wrote:

> For me, this broke some tests of the profiling runtime:
>
> $ ninja check-profile
> ...
> Failed Tests (2):
>   Profile-i386 :: Linux/instrprof-debug-info-correlate.c
>   Profile-x86_64 :: Linux/instrprof-debug-info-correlate.c
>
> Annoyingly, I can't find any buildbots where this fails, but I'm not
> really sure which ones test this runtime.
>
> It also reproduces on Chromium's builders, e.g.
>
> https://logs.chromium.org/logs/chromium/buildbucket/cr-buildbucket/8824141369391584977/+/u/package_clang/stdout
>
> Filed https://github.com/llvm/llvm-project/issues/53387
>
>
> On Mon, Jan 24, 2022 at 5:50 AM David Blaikie via cfe-commits
>  wrote:
> >
> >
> > Author: David Blaikie
> > Date: 2022-01-23T20:49:57-08:00
> > New Revision: d3b26dea16108c427b19b5480c9edc76edf8f5b4
> >
> > URL:
> https://github.com/llvm/llvm-project/commit/d3b26dea16108c427b19b5480c9edc76edf8f5b4
> > DIFF:
> https://github.com/llvm/llvm-project/commit/d3b26dea16108c427b19b5480c9edc76edf8f5b4.diff
> >
> > LOG: Clang: Change the default DWARF version to 5
> >
> > (except on platforms that already opt in to specific versions - SCE,
> > Android, and Darwin using DWARFv4 explicitly, for instance)
> >
> > Added:
> >
> >
> > Modified:
> > clang/docs/ReleaseNotes.rst
> > clang/include/clang/Driver/ToolChain.h
> > clang/lib/Driver/ToolChains/Linux.h
> > clang/test/CodeGen/debug-info-extern-call.c
> > clang/test/CodeGen/dwarf-version.c
> > clang/test/Driver/cl-options.c
> > clang/test/Driver/clang-g-opts.c
> > clang/test/Driver/ve-toolchain.c
> > clang/test/Driver/ve-toolchain.cpp
> >
> > Removed:
> >
> >
> >
> >
> 
> > diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
> > index 2eec63901932e..4fe037741256f 100644
> > --- a/clang/docs/ReleaseNotes.rst
> > +++ b/clang/docs/ReleaseNotes.rst
> > @@ -252,6 +252,14 @@ X86 Support in Clang
> >
> >  - Support for ``AVX512-FP16`` instructions has been added.
> >
> > +DWARF Support in Clang
> > +--
> > +
> > +- The default DWARF version has increased from DWARFv4 to DWARFv5.  You
> can opt
> > +  back in to the old behavior with -gdwarf-4. Some platforms (Darwin,
> Android,
> > +  and SCE for instance) already opt out of this version bump as is
> suitable for
> > +  the platform
> > +
> >  Arm and AArch64 Support in Clang
> >  
> >
> >
> > diff  --git a/clang/include/clang/Driver/ToolChain.h
> b/clang/include/clang/Driver/ToolChain.h
> > index eb95806a2f75d..37011de6bd6d7 100644
> > --- a/clang/include/clang/Driver/ToolChain.h
> > +++ b/clang/include/clang/Driver/ToolChain.h
> > @@ -510,7 +510,7 @@ class ToolChain {
> >
> >// Return the DWARF version to emit, in the absence of arguments
> >// to the contrary.
> > -  virtual unsigned GetDefaultDwarfVersion() const { return 4; }
> > +  virtual unsigned GetDefaultDwarfVersion() const { return 5; }
> >
> >// Some toolchains may have
> > diff erent restrictions on the DWARF version and
> >// may need to adjust it. E.g. NVPTX may need to enforce DWARF2 even
> when host
> >
> > diff  --git a/clang/lib/Driver/ToolChains/Linux.h
> b/clang/lib/Driver/ToolChains/Linux.h
> > index a5ec33bd44f10..a5648d79d655f 100644
> > --- a/clang/lib/Driver/ToolChains/Linux.h
> > +++ b/clang/lib/Driver/ToolChains/Linux.h
> > @@ -40,6 +40,7 @@ class LLVM_LIBRARY_VISIBILITY Linux : public
> Generic_ELF {
> >void AddIAMCUIncludeArgs(const llvm::opt::ArgList ,
> > llvm::opt::ArgStringList ) const
> override;
> >RuntimeLibType GetDefaultRuntimeLibType() const override;
> > +  unsigned GetDefaultDwarfVersion() const override;
> >CXXStdlibType GetDefaultCXXStdlibType() const override;
> >bool
> >IsAArch64OutlineAtomicsDefault(const llvm::opt::ArgList ) const
> override;
> >
> > diff  --git a/clang/test/CodeGen/debug-info-extern-call.c
> b/clang/test/CodeGen/debug-info-extern-call.c
> > index 7cf90550ac00a..fad52d0df0b3f 100644
> > --- a/clang/test/CodeGen/debug-info-extern-call.c
> >

[clang] 90abe18 - Add missing function implementation from DWARF default change

2022-01-23 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2022-01-23T21:10:16-08:00
New Revision: 90abe181da7c61d982e4873c97fd12bc06fefe09

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

LOG: Add missing function implementation from DWARF default change

Fix for d3b26dea16108c427b19b5480c9edc76edf8f5b4

Added: 


Modified: 
clang/lib/Driver/ToolChains/Linux.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Linux.cpp 
b/clang/lib/Driver/ToolChains/Linux.cpp
index e413640abad3..af74b108e04e 100644
--- a/clang/lib/Driver/ToolChains/Linux.cpp
+++ b/clang/lib/Driver/ToolChains/Linux.cpp
@@ -324,6 +324,12 @@ ToolChain::RuntimeLibType 
Linux::GetDefaultRuntimeLibType() const {
   return Generic_ELF::GetDefaultRuntimeLibType();
 }
 
+unsigned Linux::GetDefaultDwarfVersion() const {
+  if (getTriple().isAndroid())
+return 4;
+  return ToolChain::GetDefaultDwarfVersion();
+}
+
 ToolChain::CXXStdlibType Linux::GetDefaultCXXStdlibType() const {
   if (getTriple().isAndroid())
 return ToolChain::CST_Libcxx;



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


[clang] d3b26de - Clang: Change the default DWARF version to 5

2022-01-23 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2022-01-23T20:49:57-08:00
New Revision: d3b26dea16108c427b19b5480c9edc76edf8f5b4

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

LOG: Clang: Change the default DWARF version to 5

(except on platforms that already opt in to specific versions - SCE,
Android, and Darwin using DWARFv4 explicitly, for instance)

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Driver/ToolChain.h
clang/lib/Driver/ToolChains/Linux.h
clang/test/CodeGen/debug-info-extern-call.c
clang/test/CodeGen/dwarf-version.c
clang/test/Driver/cl-options.c
clang/test/Driver/clang-g-opts.c
clang/test/Driver/ve-toolchain.c
clang/test/Driver/ve-toolchain.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 2eec63901932e..4fe037741256f 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -252,6 +252,14 @@ X86 Support in Clang
 
 - Support for ``AVX512-FP16`` instructions has been added.
 
+DWARF Support in Clang
+--
+
+- The default DWARF version has increased from DWARFv4 to DWARFv5.  You can opt
+  back in to the old behavior with -gdwarf-4. Some platforms (Darwin, Android,
+  and SCE for instance) already opt out of this version bump as is suitable for
+  the platform
+
 Arm and AArch64 Support in Clang
 
 

diff  --git a/clang/include/clang/Driver/ToolChain.h 
b/clang/include/clang/Driver/ToolChain.h
index eb95806a2f75d..37011de6bd6d7 100644
--- a/clang/include/clang/Driver/ToolChain.h
+++ b/clang/include/clang/Driver/ToolChain.h
@@ -510,7 +510,7 @@ class ToolChain {
 
   // Return the DWARF version to emit, in the absence of arguments
   // to the contrary.
-  virtual unsigned GetDefaultDwarfVersion() const { return 4; }
+  virtual unsigned GetDefaultDwarfVersion() const { return 5; }
 
   // Some toolchains may have 
diff erent restrictions on the DWARF version and
   // may need to adjust it. E.g. NVPTX may need to enforce DWARF2 even when 
host

diff  --git a/clang/lib/Driver/ToolChains/Linux.h 
b/clang/lib/Driver/ToolChains/Linux.h
index a5ec33bd44f10..a5648d79d655f 100644
--- a/clang/lib/Driver/ToolChains/Linux.h
+++ b/clang/lib/Driver/ToolChains/Linux.h
@@ -40,6 +40,7 @@ class LLVM_LIBRARY_VISIBILITY Linux : public Generic_ELF {
   void AddIAMCUIncludeArgs(const llvm::opt::ArgList ,
llvm::opt::ArgStringList ) const override;
   RuntimeLibType GetDefaultRuntimeLibType() const override;
+  unsigned GetDefaultDwarfVersion() const override;
   CXXStdlibType GetDefaultCXXStdlibType() const override;
   bool
   IsAArch64OutlineAtomicsDefault(const llvm::opt::ArgList ) const 
override;

diff  --git a/clang/test/CodeGen/debug-info-extern-call.c 
b/clang/test/CodeGen/debug-info-extern-call.c
index 7cf90550ac00a..fad52d0df0b3f 100644
--- a/clang/test/CodeGen/debug-info-extern-call.c
+++ b/clang/test/CodeGen/debug-info-extern-call.c
@@ -12,13 +12,13 @@
 // decls so that the dwarf generator can describe information needed for tail
 // call frame reconstrution.
 //
-// RUN: %clang -g -O2 -target x86_64-none-linux-gnu -ggdb -S -emit-llvm %s -o 
- \
+// RUN: %clang -gdwarf-4 -O2 -target x86_64-none-linux-gnu -ggdb -S -emit-llvm 
%s -o - \
 // RUN:   | FileCheck %s -check-prefix=DECLS-FOR-EXTERN
 //
 // Do not emit a subprogram for extern decls when entry values are disabled and
 // the tuning is not set to gdb.
 //
-// RUN: %clang -g -O2 -target x86_64-none-linux-gnu -gsce -S -emit-llvm %s -o 
- \
+// RUN: %clang -gdwarf-4 -O2 -target x86_64-none-linux-gnu -gsce -S -emit-llvm 
%s -o - \
 // RUN:   | FileCheck %s -check-prefix=NO-DECLS-FOR-EXTERN
 
 // DECLS-FOR-EXTERN-NOT: !DICompileUnit({{.*}}retainedTypes: !{{[0-9]+}}

diff  --git a/clang/test/CodeGen/dwarf-version.c 
b/clang/test/CodeGen/dwarf-version.c
index 6d131c470d5b3..b329556ae0d9d 100644
--- a/clang/test/CodeGen/dwarf-version.c
+++ b/clang/test/CodeGen/dwarf-version.c
@@ -2,8 +2,8 @@
 // RUN: %clang -target x86_64-linux-gnu -gdwarf-3 -S -emit-llvm -o - %s | 
FileCheck %s --check-prefix=VER3
 // RUN: %clang -target x86_64-linux-gnu -gdwarf-4 -S -emit-llvm -o - %s | 
FileCheck %s --check-prefix=VER4
 // RUN: %clang -target x86_64-linux-gnu -gdwarf-5 -S -emit-llvm -o - %s | 
FileCheck %s --check-prefix=VER5
-// RUN: %clang -target x86_64-linux-gnu -g -S -emit-llvm -o - %s | FileCheck 
%s --check-prefix=VER4
-// RUN: %clang -target x86_64-linux-gnu -gdwarf -S -emit-llvm -o - %s | 
FileCheck %s --check-prefix=VER4
+// RUN: %clang -target x86_64-linux-gnu -g -S -emit-llvm -o - %s | FileCheck 
%s --check-prefix=VER5
+// RUN: %clang -target x86_64-linux-gnu -gdwarf -S -emit-llvm -o - %s | 
FileCheck %s --check-prefix=VER5
 
 // The -isysroot is 

[clang] baa9b7c - unique_ptrify the ModuleManager's VisitState linked list

2022-01-19 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2022-01-19T09:57:46-08:00
New Revision: baa9b7c3c83ab6e4dfb15b8d7815a9958d5b5810

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

LOG: unique_ptrify the ModuleManager's VisitState linked list

Added: 


Modified: 
clang/include/clang/Serialization/ModuleManager.h
clang/lib/Serialization/ModuleManager.cpp

Removed: 




diff  --git a/clang/include/clang/Serialization/ModuleManager.h 
b/clang/include/clang/Serialization/ModuleManager.h
index 7081eedad4b49..4305bae5ee958 100644
--- a/clang/include/clang/Serialization/ModuleManager.h
+++ b/clang/include/clang/Serialization/ModuleManager.h
@@ -105,10 +105,6 @@ class ModuleManager {
   Stack.reserve(N);
 }
 
-~VisitState() {
-  delete NextState;
-}
-
 /// The stack used when marking the imports of a particular module
 /// as not-to-be-visited.
 SmallVector Stack;
@@ -121,14 +117,14 @@ class ModuleManager {
 unsigned NextVisitNumber = 1;
 
 /// The next visit state.
-VisitState *NextState = nullptr;
+std::unique_ptr NextState;
   };
 
   /// The first visit() state in the chain.
-  VisitState *FirstVisitState = nullptr;
+  std::unique_ptr FirstVisitState;
 
-  VisitState *allocateVisitState();
-  void returnVisitState(VisitState *State);
+  std::unique_ptr allocateVisitState();
+  void returnVisitState(std::unique_ptr State);
 
 public:
   using ModuleIterator = llvm::pointee_iterator<
@@ -142,7 +138,6 @@ class ModuleManager {
   explicit ModuleManager(FileManager , InMemoryModuleCache 
,
  const PCHContainerReader ,
  const HeaderSearch );
-  ~ModuleManager();
 
   /// Forward iterator to traverse all loaded modules.
   ModuleIterator begin() { return Chain.begin(); }

diff  --git a/clang/lib/Serialization/ModuleManager.cpp 
b/clang/lib/Serialization/ModuleManager.cpp
index f4882c7be3f7d..4fd217cf7a6ea 100644
--- a/clang/lib/Serialization/ModuleManager.cpp
+++ b/clang/lib/Serialization/ModuleManager.cpp
@@ -304,23 +304,22 @@ ModuleManager::addInMemoryBuffer(StringRef FileName,
   InMemoryBuffers[Entry] = std::move(Buffer);
 }
 
-ModuleManager::VisitState *ModuleManager::allocateVisitState() {
+std::unique_ptr ModuleManager::allocateVisitState() 
{
   // Fast path: if we have a cached state, use it.
   if (FirstVisitState) {
-VisitState *Result = FirstVisitState;
-FirstVisitState = FirstVisitState->NextState;
-Result->NextState = nullptr;
+auto Result = std::move(FirstVisitState);
+FirstVisitState = std::move(Result->NextState);
 return Result;
   }
 
   // Allocate and return a new state.
-  return new VisitState(size());
+  return std::make_unique(size());
 }
 
-void ModuleManager::returnVisitState(VisitState *State) {
+void ModuleManager::returnVisitState(std::unique_ptr State) {
   assert(State->NextState == nullptr && "Visited state is in list?");
-  State->NextState = FirstVisitState;
-  FirstVisitState = State;
+  State->NextState = std::move(FirstVisitState);
+  FirstVisitState = std::move(State);
 }
 
 void ModuleManager::setGlobalIndex(GlobalModuleIndex *Index) {
@@ -351,8 +350,6 @@ ModuleManager::ModuleManager(FileManager ,
 : FileMgr(FileMgr), ModuleCache(),
   PCHContainerRdr(PCHContainerRdr), HeaderSearchInfo(HeaderSearchInfo) {}
 
-ModuleManager::~ModuleManager() { delete FirstVisitState; }
-
 void ModuleManager::visit(llvm::function_ref Visitor,
   llvm::SmallPtrSetImpl *ModuleFilesHit) 
{
   // If the visitation order vector is the wrong size, recompute the order.
@@ -396,11 +393,10 @@ void 
ModuleManager::visit(llvm::function_ref Visitor,
 
 assert(VisitOrder.size() == N && "Visitation order is wrong?");
 
-delete FirstVisitState;
 FirstVisitState = nullptr;
   }
 
-  VisitState *State = allocateVisitState();
+  auto State = allocateVisitState();
   unsigned VisitNumber = State->NextVisitNumber++;
 
   // If the caller has provided us with a hit-set that came from the global
@@ -452,7 +448,7 @@ void 
ModuleManager::visit(llvm::function_ref Visitor,
 } while (true);
   }
 
-  returnVisitState(State);
+  returnVisitState(std::move(State));
 }
 
 bool ModuleManager::lookupModuleFile(StringRef FileName, off_t ExpectedSize,



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


[clang] e1e74f6 - -Wmissing-prototypes: Don't warn in named namespaces nested in anonymous namespaces

2022-01-04 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2022-01-04T10:08:23-08:00
New Revision: e1e74f6cd6ce41ce8303a5a91f29736808fccc36

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

LOG: -Wmissing-prototypes: Don't warn in named namespaces nested in anonymous 
namespaces

Added: 


Modified: 
clang/lib/AST/Decl.cpp
clang/test/SemaCXX/warn-missing-prototypes.cpp

Removed: 




diff  --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index e63560f1b6fea..3ef08cab96750 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -3251,7 +3251,6 @@ bool FunctionDecl::isGlobal() const {
 if (const auto *Namespace = cast(DC)) {
   if (!Namespace->getDeclName())
 return false;
-  break;
 }
   }
 

diff  --git a/clang/test/SemaCXX/warn-missing-prototypes.cpp 
b/clang/test/SemaCXX/warn-missing-prototypes.cpp
index bb71aa8b142d1..e8637e5a90eab 100644
--- a/clang/test/SemaCXX/warn-missing-prototypes.cpp
+++ b/clang/test/SemaCXX/warn-missing-prototypes.cpp
@@ -13,6 +13,10 @@ namespace NS {
 namespace {
   // Don't warn about functions in anonymous namespaces.
   void f() { }
+  // Even if they're in nested namespaces within an anonymous namespace.
+  namespace NS {
+void f() { }
+  }
 }
 
 struct A {



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


Re: [clang] ea22fdd - [Clang][DebugInfo] Cease turning instruction-referencing off by default

2021-12-22 Thread David Blaikie via cfe-commits
On Wed, Dec 22, 2021 at 11:47 AM Jeremy Morse 
wrote:

> On Wed, Dec 22, 2021 at 4:34 PM David Blaikie via cfe-commits
>  wrote:
> > Is there a way to turn this off now, if it's broken for some user/use
> case? I guess using an -mllvm flag, instead of an -Xclang flag?
>
> Yup, that should be achieved by "-mllvm
> -experimental-debug-variable-locations=false", there's a test for that
> in llvm/test/DebugInfo/X86/instr-ref-flag.ll.
>

Fair enough - probably would've been good to have that flag in this commit
message (hopefully some folks can find it here in the email thread) - and I
think I probably would've left the clang flag in (& changed its default) to
"ship" the feature (though, as you said on the other thread - LTO wouldn't
be affected by that flag flip, so would also have to make the change down
in LLVM too - sort of nice that they happened separately, really, to create
an incremental rollout)

Ah well - sounds alright, thanks for the details!


>
> > Generally I think for a significant change like this the process would
> be to add it under a flag, off by default, encourage people to test it by
> opting in via the flag, eventually change the default for the flag (letting
> people know they can opt-out using the flag if they see problems & to
> report them to you so they can be fixed & hopefully they can stop opting
> out) & then remove the flag when it's stable. Reverting a patch to disable
> a newly-on-by-default feature is a bit heavyweight and it can be nice to
> have a flag to control it while it's getting more exposure/experience.
>
> Indeed, I'd hoped this was largely achieved with
> https://lists.llvm.org/pipermail/llvm-dev/2021-July/151965.html , I
> guess what's missing is better communicating in how to opt out now,
> alas. It's unfortunate that people bisecting back are going to find
> this commit; I couldn't think of another way of rectifying things
> without pushing up several reverts and the re-applies at the same time
> though.
>
> --
> Thanks,
> Jeremy
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [clang] ea22fdd - [Clang][DebugInfo] Cease turning instruction-referencing off by default

2021-12-22 Thread David Blaikie via cfe-commits
Is there a way to turn this off now, if it's broken for some user/use case?
I guess using an -mllvm flag, instead of an -Xclang flag?

Generally I think for a significant change like this the process would be
to add it under a flag, off by default, encourage people to test it by
opting in via the flag, eventually change the default for the flag (letting
people know they can opt-out using the flag if they see problems & to
report them to you so they can be fixed & hopefully they can stop opting
out) & then remove the flag when it's stable. Reverting a patch to disable
a newly-on-by-default feature is a bit heavyweight and it can be nice to
have a flag to control it while it's getting more exposure/experience.

On Wed, Dec 22, 2021 at 11:31 AM Jeremy Morse via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

>
> Author: Jeremy Morse
> Date: 2021-12-22T16:30:05Z
> New Revision: ea22fdd120aeb1bbb9ea96670d70193dc02b2c5f
>
> URL:
> https://github.com/llvm/llvm-project/commit/ea22fdd120aeb1bbb9ea96670d70193dc02b2c5f
> DIFF:
> https://github.com/llvm/llvm-project/commit/ea22fdd120aeb1bbb9ea96670d70193dc02b2c5f.diff
>
> LOG: [Clang][DebugInfo] Cease turning instruction-referencing off by
> default
>
> Over in D114631 I turned this debug-info feature on by default, for x86_64
> only. I'd previously stripped out the clang cc1 option that controlled it
> in 651122fc4ac, unfortunately that turned out to not be completely
> effective, and the two things deleted in this patch continued to keep it
> off-by-default.  Oooff.
>
> As a follow-up, this patch removes the last few things to do with
> ValueTrackingVariableLocations from clang, which was the original purpose
> of D114631. In an ideal world, if this patch causes you trouble you'd
> revert 3c045070882f instead, which was where this behaviour was supposed
> to start being the default, although that might not be practical any more.
>
> Added:
>
>
> Modified:
> clang/include/clang/Basic/CodeGenOptions.def
> clang/lib/CodeGen/BackendUtil.cpp
>
> Removed:
>
>
>
>
> 
> diff  --git a/clang/include/clang/Basic/CodeGenOptions.def
> b/clang/include/clang/Basic/CodeGenOptions.def
> index 94b3003a9c33c..723302f108e20 100644
> --- a/clang/include/clang/Basic/CodeGenOptions.def
> +++ b/clang/include/clang/Basic/CodeGenOptions.def
> @@ -368,9 +368,6 @@ ENUM_CODEGENOPT(DebuggerTuning, llvm::DebuggerKind, 3,
>  /// emitted.
>  VALUE_CODEGENOPT(DwarfVersion, 3, 0)
>
> -/// Whether to use experimental new variable location tracking.
> -CODEGENOPT(ValueTrackingVariableLocations, 1, 0)
> -
>  /// Whether we should emit CodeView debug information. It's possible to
> emit
>  /// CodeView and DWARF into the same object.
>  CODEGENOPT(EmitCodeView, 1, 0)
>
> diff  --git a/clang/lib/CodeGen/BackendUtil.cpp
> b/clang/lib/CodeGen/BackendUtil.cpp
> index 5e16d3525b383..bacac0a20d4d5 100644
> --- a/clang/lib/CodeGen/BackendUtil.cpp
> +++ b/clang/lib/CodeGen/BackendUtil.cpp
> @@ -603,8 +603,6 @@ static bool initTargetOptions(DiagnosticsEngine ,
>Options.ForceDwarfFrameSection = CodeGenOpts.ForceDwarfFrameSection;
>Options.EmitCallSiteInfo = CodeGenOpts.EmitCallSiteInfo;
>Options.EnableAIXExtendedAltivecABI =
> CodeGenOpts.EnableAIXExtendedAltivecABI;
> -  Options.ValueTrackingVariableLocations =
> -  CodeGenOpts.ValueTrackingVariableLocations;
>Options.XRayOmitFunctionIndex = CodeGenOpts.XRayOmitFunctionIndex;
>Options.LoopAlignment = CodeGenOpts.LoopAlignment;
>
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [clang] b8e03be - [PS4][DWARF] Explicitly set default DWARF version to 4

2021-12-06 Thread David Blaikie via cfe-commits
Guess this is untestable right now, since it's overriding with the same
value? Maybe worth adding an explicit test for the PS4 default - so that
the test would fail /if/ the generic (non-PS4) default was changed (which
we'll hopefully change in the near future)?

On Tue, Nov 30, 2021 at 8:59 AM Paul Robinson via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

>
> Author: Paul Robinson
> Date: 2021-11-30T08:58:40-08:00
> New Revision: b8e03be88dc87303f7401ea7b9906947ac67a6db
>
> URL:
> https://github.com/llvm/llvm-project/commit/b8e03be88dc87303f7401ea7b9906947ac67a6db
> DIFF:
> https://github.com/llvm/llvm-project/commit/b8e03be88dc87303f7401ea7b9906947ac67a6db.diff
>
> LOG: [PS4][DWARF] Explicitly set default DWARF version to 4
>
> Added:
>
>
> Modified:
> clang/lib/Driver/ToolChains/PS4CPU.h
>
> Removed:
>
>
>
>
> 
> diff  --git a/clang/lib/Driver/ToolChains/PS4CPU.h
> b/clang/lib/Driver/ToolChains/PS4CPU.h
> index 82f9523f84fb8..4bedabaf267c0 100644
> --- a/clang/lib/Driver/ToolChains/PS4CPU.h
> +++ b/clang/lib/Driver/ToolChains/PS4CPU.h
> @@ -80,6 +80,7 @@ class LLVM_LIBRARY_VISIBILITY PS4CPU : public
> Generic_ELF {
>  return LangOptions::SSPStrong;
>}
>
> +  unsigned GetDefaultDwarfVersion() const override { return 4; }
>llvm::DebuggerKind getDefaultDebuggerTuning() const override {
>  return llvm::DebuggerKind::SCE;
>}
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 50fdd7d - Add more test coverage for D77598

2021-11-14 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2021-11-14T21:09:11-08:00
New Revision: 50fdd7df827137c8465abafa82a6bae7c87096c5

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

LOG: Add more test coverage for D77598

Add coverage to demonstrate why including the type of template
parameters is necessary to disambiguate function template
specializations.

Test courtesy of Richard Smith

Added: 


Modified: 
clang/test/AST/ast-dump-templates.cpp

Removed: 




diff  --git a/clang/test/AST/ast-dump-templates.cpp 
b/clang/test/AST/ast-dump-templates.cpp
index b08bc76ed179..3d26eb917c12 100644
--- a/clang/test/AST/ast-dump-templates.cpp
+++ b/clang/test/AST/ast-dump-templates.cpp
@@ -93,3 +93,14 @@ void test() {
 // CHECK1: {{^}}template<> struct foo<1, 0 + 0L> {
 template struct foo<1, 0 + 0L>;
 }
+
+namespace test5 {
+template void f() {}
+void (*p)() = f<0>;
+template void f() {}
+void (*q)() = f<>;
+// Not perfect - this code in the dump would be ambiguous, but it's the best we
+// can do to 
diff erentiate these two implicit specializations.
+// CHECK1: template<> void f<0L>()
+// CHECK1: template<> void f<0U>()
+}



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


[clang] b2589e3 - ast-print: Avoid extra whitespace before function opening brace

2021-11-14 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2021-11-14T20:45:16-08:00
New Revision: b2589e326ba4407d8314938a4f7498086e2203ea

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

LOG: ast-print: Avoid extra whitespace before function opening brace

Added: 


Modified: 
clang/include/clang/AST/Stmt.h
clang/lib/AST/DeclPrinter.cpp
clang/lib/AST/StmtPrinter.cpp
clang/test/AST/ast-dump-templates.cpp

Removed: 




diff  --git a/clang/include/clang/AST/Stmt.h b/clang/include/clang/AST/Stmt.h
index 73cbff537847..a32126d23d31 100644
--- a/clang/include/clang/AST/Stmt.h
+++ b/clang/include/clang/AST/Stmt.h
@@ -1216,6 +1216,11 @@ class alignas(void *) Stmt {
const PrintingPolicy , unsigned Indentation = 0,
StringRef NewlineSymbol = "\n",
const ASTContext *Context = nullptr) const;
+  void printPrettyControlled(raw_ostream , PrinterHelper *Helper,
+ const PrintingPolicy ,
+ unsigned Indentation = 0,
+ StringRef NewlineSymbol = "\n",
+ const ASTContext *Context = nullptr) const;
 
   /// Pretty-prints in JSON format.
   void printJson(raw_ostream , PrinterHelper *Helper,

diff  --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp
index 5c6781c26ed7..044eb8f8f8e5 100644
--- a/clang/lib/AST/DeclPrinter.cpp
+++ b/clang/lib/AST/DeclPrinter.cpp
@@ -782,11 +782,10 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) {
   Out << ";\n";
 }
 Indentation -= Policy.Indentation;
-  } else
-Out << ' ';
+  }
 
   if (D->getBody())
-D->getBody()->printPretty(Out, nullptr, SubPolicy, Indentation, "\n",
+D->getBody()->printPrettyControlled(Out, nullptr, SubPolicy, 
Indentation, "\n",
   );
 } else {
   if (!Policy.TerseOutput && isa(*D))

diff  --git a/clang/lib/AST/StmtPrinter.cpp b/clang/lib/AST/StmtPrinter.cpp
index 12af5bfa2013..fc267d7006a1 100644
--- a/clang/lib/AST/StmtPrinter.cpp
+++ b/clang/lib/AST/StmtPrinter.cpp
@@ -2595,6 +2595,14 @@ void Stmt::printPretty(raw_ostream , PrinterHelper 
*Helper,
   P.Visit(const_cast(this));
 }
 
+void Stmt::printPrettyControlled(raw_ostream , PrinterHelper *Helper,
+ const PrintingPolicy ,
+ unsigned Indentation, StringRef NL,
+ const ASTContext *Context) const {
+  StmtPrinter P(Out, Helper, Policy, Indentation, NL, Context);
+  P.PrintControlledStmt(const_cast(this));
+}
+
 void Stmt::printJson(raw_ostream , PrinterHelper *Helper,
  const PrintingPolicy , bool AddQuotes) const {
   std::string Buf;

diff  --git a/clang/test/AST/ast-dump-templates.cpp 
b/clang/test/AST/ast-dump-templates.cpp
index dcecdca58c75..b08bc76ed179 100644
--- a/clang/test/AST/ast-dump-templates.cpp
+++ b/clang/test/AST/ast-dump-templates.cpp
@@ -79,6 +79,8 @@ struct foo {
 // type/unsigned argument (see
 // TemplateParameterList::shouldIncludeTypeForArgument)
 // CHECK1: {{^}}template<> struct foo<0, 0L> {
+// CHECK1: {{^}}void test(){{ }}{
+// CHECK1: {{^}}foo<0, 0 + 0L>::fn();
 void test() {
   foo<0, 0 + 0L>::fn();
 }



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


[clang] 604446a - ast-dump: Add missing identation of class template specializations

2021-11-14 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2021-11-14T20:45:16-08:00
New Revision: 604446aa6b41461e2691c9f4253e9ef70a5d68e4

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

LOG: ast-dump: Add missing identation of class template specializations

Added: 


Modified: 
clang/lib/AST/DeclPrinter.cpp
clang/test/AST/ast-dump-templates.cpp

Removed: 




diff  --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp
index 884b8e730905..5c6781c26ed7 100644
--- a/clang/lib/AST/DeclPrinter.cpp
+++ b/clang/lib/AST/DeclPrinter.cpp
@@ -1185,6 +1185,7 @@ void 
DeclPrinter::VisitClassTemplateDecl(ClassTemplateDecl *D) {
 if (D->isThisDeclarationADefinition())
   Out << ";";
 Out << "\n";
+Indent();
 Visit(I);
   }
   }

diff  --git a/clang/test/AST/ast-dump-templates.cpp 
b/clang/test/AST/ast-dump-templates.cpp
index cb2994edcc67..dcecdca58c75 100644
--- a/clang/test/AST/ast-dump-templates.cpp
+++ b/clang/test/AST/ast-dump-templates.cpp
@@ -78,7 +78,7 @@ struct foo {
 // includes the type for the auto argument and omits it for the fixed
 // type/unsigned argument (see
 // TemplateParameterList::shouldIncludeTypeForArgument)
-// CHECK1: template<> struct foo<0, 0L> {
+// CHECK1: {{^}}template<> struct foo<0, 0L> {
 void test() {
   foo<0, 0 + 0L>::fn();
 }
@@ -88,6 +88,6 @@ void test() {
 // powered by the shouldIncludeTypeForArgument functionality.
 // Not sure if this it's intentional that these two specializations are 
rendered
 // 
diff erently in this way.
-// CHECK1: template<> struct foo<1, 0 + 0L> {
+// CHECK1: {{^}}template<> struct foo<1, 0 + 0L> {
 template struct foo<1, 0 + 0L>;
 }



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


[clang] 400eb59 - Add test for a case in D77598

2021-11-14 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2021-11-14T20:45:16-08:00
New Revision: 400eb59adf43b29af3117c163cf770e6d6e514f7

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

LOG: Add test for a case in D77598

This covers the DeclPrinter::VisitCXXRecordDecl caller - though also
demonstrates some possible inconsistency in template specialization
printing.

Added: 


Modified: 
clang/test/AST/ast-dump-templates.cpp

Removed: 




diff  --git a/clang/test/AST/ast-dump-templates.cpp 
b/clang/test/AST/ast-dump-templates.cpp
index ab4a7356028e1..cb2994edcc67e 100644
--- a/clang/test/AST/ast-dump-templates.cpp
+++ b/clang/test/AST/ast-dump-templates.cpp
@@ -67,3 +67,27 @@ namespace test3 {
   template A(T) -> A;
   // CHECK1: template  A(T) -> A;
 }
+
+namespace test4 {
+template 
+struct foo {
+  static void fn();
+};
+
+// Prints using an "integral" template argument. Test that this correctly
+// includes the type for the auto argument and omits it for the fixed
+// type/unsigned argument (see
+// TemplateParameterList::shouldIncludeTypeForArgument)
+// CHECK1: template<> struct foo<0, 0L> {
+void test() {
+  foo<0, 0 + 0L>::fn();
+}
+
+// Prints using an "expression" template argument. This renders based on the 
way
+// the user wrote the arguments (including that + expression) - so it's not
+// powered by the shouldIncludeTypeForArgument functionality.
+// Not sure if this it's intentional that these two specializations are 
rendered
+// 
diff erently in this way.
+// CHECK1: template<> struct foo<1, 0 + 0L> {
+template struct foo<1, 0 + 0L>;
+}



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


[clang] 5de3690 - Follow-up to D77598: Simplify API by passing template parameters only when used/to imply "TemplOverloaded/overloadable"

2021-11-14 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2021-11-14T13:35:22-08:00
New Revision: 5de369056dee2c4de81625cb05a5c212a0bdc053

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

LOG: Follow-up to D77598: Simplify API by passing template parameters only when 
used/to imply "TemplOverloaded/overloadable"

These arguments were redundant, and other parts of D77598 did rely on
the presence/absence of template parameters to imply whether types
should be included for the argument (like
clang::printTemplateArgumentList) so do that here too.

Added: 


Modified: 
clang/lib/AST/DeclPrinter.cpp

Removed: 




diff  --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp
index 38f2d10cdc90..884b8e730905 100644
--- a/clang/lib/AST/DeclPrinter.cpp
+++ b/clang/lib/AST/DeclPrinter.cpp
@@ -112,11 +112,9 @@ namespace {
 void printTemplateParameters(const TemplateParameterList *Params,
  bool OmitTemplateKW = false);
 void printTemplateArguments(llvm::ArrayRef Args,
-const TemplateParameterList *Params,
-bool TemplOverloaded);
+const TemplateParameterList *Params);
 void printTemplateArguments(llvm::ArrayRef Args,
-const TemplateParameterList *Params,
-bool TemplOverloaded);
+const TemplateParameterList *Params);
 void prettyPrintAttributes(Decl *D);
 void prettyPrintPragmas(Decl *D);
 void printDeclType(QualType T, StringRef DeclName, bool Pack = false);
@@ -652,16 +650,11 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) {
 llvm::raw_string_ostream POut(Proto);
 DeclPrinter TArgPrinter(POut, SubPolicy, Context, Indentation);
 const auto *TArgAsWritten = D->getTemplateSpecializationArgsAsWritten();
-const TemplateParameterList *TPL = D->getTemplateSpecializationInfo()
-   ->getTemplate()
-   ->getTemplateParameters();
 if (TArgAsWritten && !Policy.PrintCanonicalTypes)
-  TArgPrinter.printTemplateArguments(TArgAsWritten->arguments(), TPL,
- /*TemplOverloaded*/ true);
+  TArgPrinter.printTemplateArguments(TArgAsWritten->arguments(), nullptr);
 else if (const TemplateArgumentList *TArgs =
  D->getTemplateSpecializationArgs())
-  TArgPrinter.printTemplateArguments(TArgs->asArray(), TPL,
- /*TemplOverloaded*/ true);
+  TArgPrinter.printTemplateArguments(TArgs->asArray(), nullptr);
   }
 
   QualType Ty = D->getType();
@@ -1002,8 +995,7 @@ void DeclPrinter::VisitCXXRecordDecl(CXXRecordDecl *D) {
   dyn_cast(TSI->getType()))
 Args = TST->template_arguments();
   printTemplateArguments(
-  Args, S->getSpecializedTemplate()->getTemplateParameters(),
-  /*TemplOverloaded*/ false);
+  Args, S->getSpecializedTemplate()->getTemplateParameters());
 }
   }
 
@@ -1096,13 +1088,12 @@ void DeclPrinter::printTemplateParameters(const 
TemplateParameterList *Params,
 }
 
 void DeclPrinter::printTemplateArguments(ArrayRef Args,
- const TemplateParameterList *Params,
- bool TemplOverloaded) {
+ const TemplateParameterList *Params) {
   Out << "<";
   for (size_t I = 0, E = Args.size(); I < E; ++I) {
 if (I)
   Out << ", ";
-if (TemplOverloaded || !Params)
+if (!Params)
   Args[I].print(Policy, Out, /*IncludeType*/ true);
 else
   Args[I].print(Policy, Out,
@@ -1113,13 +1104,12 @@ void 
DeclPrinter::printTemplateArguments(ArrayRef Args,
 }
 
 void DeclPrinter::printTemplateArguments(ArrayRef Args,
- const TemplateParameterList *Params,
- bool TemplOverloaded) {
+ const TemplateParameterList *Params) {
   Out << "<";
   for (size_t I = 0, E = Args.size(); I < E; ++I) {
 if (I)
   Out << ", ";
-if (TemplOverloaded)
+if (!Params)
   Args[I].getArgument().print(Policy, Out, /*IncludeType*/ true);
 else
   Args[I].getArgument().print(



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


[clang] 6512098 - DebugInfo/Printing: Improve name of policy for including types for template arguments

2021-11-11 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2021-11-11T21:59:27-08:00
New Revision: 6512098877c3a230bbd38bc81b14a4e5844739ff

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

LOG: DebugInfo/Printing: Improve name of policy for including types for 
template arguments

Feedback from Richard Smith that the policy should be named closer to
the context its used in.

Added: 


Modified: 
clang/include/clang/AST/PrettyPrinter.h
clang/lib/AST/DeclTemplate.cpp
clang/lib/CodeGen/CGDebugInfo.cpp

Removed: 




diff  --git a/clang/include/clang/AST/PrettyPrinter.h 
b/clang/include/clang/AST/PrettyPrinter.h
index 38d122db0749..f6816e938f2a 100644
--- a/clang/include/clang/AST/PrettyPrinter.h
+++ b/clang/include/clang/AST/PrettyPrinter.h
@@ -75,7 +75,7 @@ struct PrintingPolicy {
 MSVCFormatting(false), ConstantsAsWritten(false),
 SuppressImplicitBase(false), FullyQualifiedName(false),
 PrintCanonicalTypes(false), PrintInjectedClassNameWithArguments(true),
-UsePreferredNames(true), UseIntegerTypeSuffixesAlways(false) {}
+UsePreferredNames(true), AlwaysIncludeTypeForTemplateArgument(false) {}
 
   /// Adjust this printing policy for cases where it's known that we're
   /// printing C++ code (for instance, if AST dumping reaches a C++-only
@@ -280,7 +280,7 @@ struct PrintingPolicy {
 
   /// Whether to use type suffixes (eg: 1U) on integral non-type template
   /// parameters.
-  unsigned UseIntegerTypeSuffixesAlways : 1;
+  unsigned AlwaysIncludeTypeForTemplateArgument : 1;
 
   /// Callbacks to use to allow the behavior of printing to be customized.
   const PrintingCallbacks *Callbacks = nullptr;

diff  --git a/clang/lib/AST/DeclTemplate.cpp b/clang/lib/AST/DeclTemplate.cpp
index 10f7155fcb96..223f06b9db1c 100644
--- a/clang/lib/AST/DeclTemplate.cpp
+++ b/clang/lib/AST/DeclTemplate.cpp
@@ -204,7 +204,7 @@ bool TemplateParameterList::hasAssociatedConstraints() 
const {
 bool TemplateParameterList::shouldIncludeTypeForArgument(
 const PrintingPolicy , const TemplateParameterList *TPL,
 unsigned Idx) {
-  if (!TPL || Idx >= TPL->size() || Policy.UseIntegerTypeSuffixesAlways)
+  if (!TPL || Idx >= TPL->size() || 
Policy.AlwaysIncludeTypeForTemplateArgument)
 return true;
   const NamedDecl *TemplParam = TPL->getParam(Idx);
   if (const auto *ParamValueDecl =

diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 1ce56f98e1f0..af651e6f44b7 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -247,7 +247,7 @@ PrintingPolicy CGDebugInfo::getPrintingPolicy() const {
   PP.SuppressInlineNamespace = false;
   PP.PrintCanonicalTypes = true;
   PP.UsePreferredNames = false;
-  PP.UseIntegerTypeSuffixesAlways = true;
+  PP.AlwaysIncludeTypeForTemplateArgument = true;
 
   // Apply -fdebug-prefix-map.
   PP.Callbacks = 



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


[clang] 8bf1244 - DebugInfo: workaround for context-sensitive use of non-type-template-parameter integer suffixes

2021-11-01 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2021-11-01T17:08:26-07:00
New Revision: 8bf12445383b2f3149a9d095bfbc0f6d5b00dfaa

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

LOG: DebugInfo: workaround for context-sensitive use of 
non-type-template-parameter integer suffixes

There's a nuanced check about when to use suffixes on these integer
non-type-template-parameters, but when rebuilding names for
-gsimple-template-names there isn't enough data in the DWARF to
determine when to use suffixes or not. So turn on suffixes always to
make it easy to match up names in llvm-dwarfdump --verify.

I /think/ if we correctly modelled auto non-type-template parameters
maybe we could put suffixes only on those. But there's also some logic
in Clang that puts the suffixes on overloaded functions - at least
that's what the parameter says (see D77598 and printTemplateArguments
"TemplOverloaded" parameter) - but I think maybe it's for anything that
/can/ be overloaded, not necessarily only the things that are overloaded
(the argument value is hardcoded at the various callsites, doesn't seem
to depend on overload resolution/searching for overloaded functions). So
maybe with "auto" modeled more accurately, and differentiating between
function templates (always using type suffixes there) and class/variable
templates (only using the suffix for "auto" types) we could correctly
use integer type suffixes only in the minimal set of cases.

But that seems all too much fuss, so let's just put integer type
suffixes everywhere always in the debug info of integer non-type
template parameters in template names.

(more context:
* https://reviews.llvm.org/D77598#inline-1057607
* https://groups.google.com/g/llvm-dev/c/ekLMllbLIZg/m/-dhJ0hO1AAAJ )

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

Added: 


Modified: 
clang/include/clang/AST/DeclTemplate.h
clang/include/clang/AST/PrettyPrinter.h
clang/lib/AST/DeclPrinter.cpp
clang/lib/AST/DeclTemplate.cpp
clang/lib/AST/Expr.cpp
clang/lib/AST/TypePrinter.cpp
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/test/CodeGenCXX/debug-info-template.cpp
clang/test/Modules/lsv-debuginfo.cpp
libcxx/test/libcxx/gdb/gdb_pretty_printer_test.sh.cpp

Removed: 




diff  --git a/clang/include/clang/AST/DeclTemplate.h 
b/clang/include/clang/AST/DeclTemplate.h
index 2408f50c074b..d33babef958e 100644
--- a/clang/include/clang/AST/DeclTemplate.h
+++ b/clang/include/clang/AST/DeclTemplate.h
@@ -203,7 +203,8 @@ class TemplateParameterList final
   void print(raw_ostream , const ASTContext ,
  const PrintingPolicy , bool OmitTemplateKW = false) const;
 
-  static bool shouldIncludeTypeForArgument(const TemplateParameterList *TPL,
+  static bool shouldIncludeTypeForArgument(const PrintingPolicy ,
+   const TemplateParameterList *TPL,
unsigned Idx);
 };
 

diff  --git a/clang/include/clang/AST/PrettyPrinter.h 
b/clang/include/clang/AST/PrettyPrinter.h
index 8cab7f189559..38d122db0749 100644
--- a/clang/include/clang/AST/PrettyPrinter.h
+++ b/clang/include/clang/AST/PrettyPrinter.h
@@ -75,7 +75,7 @@ struct PrintingPolicy {
 MSVCFormatting(false), ConstantsAsWritten(false),
 SuppressImplicitBase(false), FullyQualifiedName(false),
 PrintCanonicalTypes(false), PrintInjectedClassNameWithArguments(true),
-UsePreferredNames(true) {}
+UsePreferredNames(true), UseIntegerTypeSuffixesAlways(false) {}
 
   /// Adjust this printing policy for cases where it's known that we're
   /// printing C++ code (for instance, if AST dumping reaches a C++-only
@@ -273,8 +273,15 @@ struct PrintingPolicy {
   /// written. When a template argument is unnamed, printing it results in
   /// invalid C++ code.
   unsigned PrintInjectedClassNameWithArguments : 1;
+
+  /// Whether to use C++ template preferred_name attributes when printing
+  /// templates.
   unsigned UsePreferredNames : 1;
 
+  /// Whether to use type suffixes (eg: 1U) on integral non-type template
+  /// parameters.
+  unsigned UseIntegerTypeSuffixesAlways : 1;
+
   /// Callbacks to use to allow the behavior of printing to be customized.
   const PrintingCallbacks *Callbacks = nullptr;
 };

diff  --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp
index f2d7a792567d..7f3d3c5a9ec3 100644
--- a/clang/lib/AST/DeclPrinter.cpp
+++ b/clang/lib/AST/DeclPrinter.cpp
@@ -1105,9 +1105,9 @@ void 
DeclPrinter::printTemplateArguments(ArrayRef Args,
 if (TemplOverloaded || !Params)
   Args[I].print(Policy, Out, /*IncludeType*/ true);
 else
-  Args[I].print(
-  Policy, Out,
-  

Re: r307232 - [modules ts] Do not emit strong function definitions from the module interface unit in every user.

2021-11-01 Thread David Blaikie via cfe-commits
Ping

On Tue, Sep 21, 2021 at 7:58 PM David Blaikie  wrote:

> Ping
>
> On Sun, Sep 5, 2021 at 11:28 AM David Blaikie  wrote:
>
>> Hey Richard - was just going back over some of the modular codegen code
>> (due to a discussion on the EWG mailing list about file extensions that
>> ended up touching on the nature of how modules are built) - and I came
>> across this code & had the same question I see I wrote up here already but
>> got lost in the *-commits mail.
>>
>> Wondering if you've got some thoughts on why this choice was implemented
>> for C++20 modules - not homing inline functions/variables, only the extern
>> linkage ones for correctness?
>>
>> On Sun, Jul 16, 2017 at 8:26 PM David Blaikie  wrote:
>>
>>> Looks good - does this support available_externally definitions of
>>> strong external linkage functions in the users of a module? (is that
>>> tested?) Should it?
>>>
>>> Also should we consider having two flags for modular codegen - one for
>>> correctness (external function definitions), one for linkage size
>>> optimization (inline functions). Given the current data on optimized builds
>>> with inline functions (that it hurts object size to emit
>>> weak+available_externally definitions rather than linkonce_odr because so
>>> many definitions are optimized away entirely, that the bytes for the weak
>>> definition are wasted/unnecessary) - or at least something to keep in
>>> mind/run numbers on in the future for more generic codebases than Google's
>>> protobuf-heavy (& only protobuf modularized) code.
>>>
>>> On Wed, Jul 5, 2017 at 5:30 PM Richard Smith via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
 Author: rsmith
 Date: Wed Jul  5 17:30:00 2017
 New Revision: 307232

 URL: http://llvm.org/viewvc/llvm-project?rev=307232=rev
 Log:
 [modules ts] Do not emit strong function definitions from the module
 interface unit in every user.

 Added:
 cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/
 cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p4/
 cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cpp
 cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cppm
 cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p4/user.cpp
 Modified:
 cfe/trunk/lib/Serialization/ASTWriterDecl.cpp

 Modified: cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterDecl.cpp?rev=307232=307231=307232=diff

 ==
 --- cfe/trunk/lib/Serialization/ASTWriterDecl.cpp (original)
 +++ cfe/trunk/lib/Serialization/ASTWriterDecl.cpp Wed Jul  5 17:30:00
 2017
 @@ -2233,8 +2233,18 @@ void ASTRecordWriter::AddFunctionDefinit
Writer->ClearSwitchCaseIDs();

assert(FD->doesThisDeclarationHaveABody());
 -  bool ModulesCodegen = Writer->Context->getLangOpts().ModulesCodegen
 &&
 -Writer->WritingModule &&
 !FD->isDependentContext();
 +  bool ModulesCodegen = false;
 +  if (Writer->WritingModule && !FD->isDependentContext()) {
 +// Under -fmodules-codegen, codegen is performed for all defined
 functions.
 +// When building a C++ Modules TS module interface unit, a strong
 definition
 +// in the module interface is provided by the compilation of that
 module
 +// interface unit, not by its users. (Inline functions are still
 emitted
 +// in module users.)
 +ModulesCodegen =
 +Writer->Context->getLangOpts().ModulesCodegen ||
 +(Writer->WritingModule->Kind == Module::ModuleInterfaceUnit &&
 + Writer->Context->GetGVALinkageForFunction(FD) ==
 GVA_StrongExternal);
 +  }
Record->push_back(ModulesCodegen);
if (ModulesCodegen)
  Writer->ModularCodegenDecls.push_back(Writer->GetDeclRef(FD));

 Added: cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cpp
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cpp?rev=307232=auto

 ==
 --- cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cpp
 (added)
 +++ cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cpp Wed
 Jul  5 17:30:00 2017
 @@ -0,0 +1,23 @@
 +// RUN: %clang_cc1 -fmodules-ts %S/module.cppm -triple
 %itanium_abi_triple -emit-module-interface -o %t
 +// RUN: %clang_cc1 -fmodules-ts %s -triple %itanium_abi_triple
 -fmodule-file=%t -emit-llvm -o - | FileCheck %s --implicit-check-not=unused
 --implicit-check-not=global_module
 +
 +module Module;
 +
 +void use() {
 +  // CHECK: define linkonce_odr {{.*}}@_Z20used_inline_exportedv
 +  used_inline_exported();

Re: [clang] 2bd8493 - Improve type printing of const arrays to normalize array-of-const and const-array

2021-10-21 Thread David Blaikie via cfe-commits
On Thu, Oct 14, 2021 at 2:25 PM David Blaikie  wrote:

> On Tue, Oct 12, 2021 at 7:35 PM David Blaikie  wrote:
>
>> On Mon, Oct 11, 2021 at 2:46 PM Richard Smith 
>> wrote:
>>
>>> On Wed, 15 Sept 2021 at 13:52, David Blaikie  wrote:
>>>
>>>> On Tue, Sep 14, 2021 at 10:04 AM Richard Smith 
>>>> wrote:
>>>>
>>>>> On Mon, 13 Sept 2021 at 19:24, David Blaikie via cfe-commits <
>>>>> cfe-commits@lists.llvm.org> wrote:
>>>>>
>>>>>>
>>>>>> Author: David Blaikie
>>>>>> Date: 2021-09-13T19:17:05-07:00
>>>>>> New Revision: 2bd84938470bf2e337801faafb8a67710f46429d
>>>>>>
>>>>>> URL:
>>>>>> https://github.com/llvm/llvm-project/commit/2bd84938470bf2e337801faafb8a67710f46429d
>>>>>> DIFF:
>>>>>> https://github.com/llvm/llvm-project/commit/2bd84938470bf2e337801faafb8a67710f46429d.diff
>>>>>>
>>>>>> LOG: Improve type printing of const arrays to normalize
>>>>>> array-of-const and const-array
>>>>>>
>>>>>> Since these map to the same effective type - render them the same/in
>>>>>> the
>>>>>> more legible way (const x[n]).
>>>>>>
>>>>>
>>>>> Nice!
>>>>>
>>>>>
>>>>>> Added:
>>>>>>
>>>>>>
>>>>>> Modified:
>>>>>> clang/lib/AST/TypePrinter.cpp
>>>>>> clang/test/ARCMT/cxx-checking.mm
>>>>>> clang/test/AST/ast-dump-APValue-arithmetic.cpp
>>>>>> clang/test/AST/ast-dump-APValue-array.cpp
>>>>>> clang/test/CXX/basic/basic.types/p10.cpp
>>>>>> clang/test/Sema/assign.c
>>>>>> clang/test/Sema/typedef-retain.c
>>>>>> clang/test/SemaCXX/reinterpret-cast.cpp
>>>>>> clang/test/SemaCXX/static-assert-cxx17.cpp
>>>>>>
>>>>>> Removed:
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> 
>>>>>> diff  --git a/clang/lib/AST/TypePrinter.cpp
>>>>>> b/clang/lib/AST/TypePrinter.cpp
>>>>>> index aef1e4f3f4953..251db97c7db08 100644
>>>>>> --- a/clang/lib/AST/TypePrinter.cpp
>>>>>> +++ b/clang/lib/AST/TypePrinter.cpp
>>>>>> @@ -200,11 +200,12 @@ bool TypePrinter::canPrefixQualifiers(const
>>>>>> Type *T,
>>>>>>// type expands to a simple string.
>>>>>>bool CanPrefixQualifiers = false;
>>>>>>NeedARCStrongQualifier = false;
>>>>>> -  Type::TypeClass TC = T->getTypeClass();
>>>>>> +  const Type *UnderlyingType = T;
>>>>>>if (const auto *AT = dyn_cast(T))
>>>>>> -TC = AT->desugar()->getTypeClass();
>>>>>> +UnderlyingType = AT->desugar().getTypePtr();
>>>>>>if (const auto *Subst = dyn_cast(T))
>>>>>> -TC = Subst->getReplacementType()->getTypeClass();
>>>>>> +UnderlyingType = Subst->getReplacementType().getTypePtr();
>>>>>> +  Type::TypeClass TC = UnderlyingType->getTypeClass();
>>>>>>
>>>>>>switch (TC) {
>>>>>>  case Type::Auto:
>>>>>> @@ -243,6 +244,9 @@ bool TypePrinter::canPrefixQualifiers(const Type
>>>>>> *T,
>>>>>>
>>>>>>  case Type::ConstantArray:
>>>>>>  case Type::IncompleteArray:
>>>>>> +  return canPrefixQualifiers(
>>>>>> +
>>>>>> cast(UnderlyingType)->getElementType().getTypePtr(),
>>>>>> +  NeedARCStrongQualifier);
>>>>>>  case Type::VariableArray:
>>>>>>  case Type::DependentSizedArray:
>>>>>>
>>>>>
>>>>> Can we give these two cases the same treatment?
>>>>>
>>>>
>>>> Handled the DependentSizedArray in
>>>> https://github.com/llvm/llvm-project/commit/40acc0adad59ac39e9a7a02fcd93161298500c00
>>>>
>>>> But per the comment in that commit I wasn't able to reproduce the
>>>> problem with a vari

[clang] 8c13680 - PR18733: Remove -Wweak-template-vtables

2021-10-21 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2021-10-21T14:50:20-07:00
New Revision: 8c136805242014b6ad9ff1afcac9d7f4a18bec3f

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

LOG: PR18733: Remove -Wweak-template-vtables

It isn't really pulling its weight and I think splitting it out from
-Wweak-vtables was the wrong call: I think it was just a bug in the
original warning, which was trying to not diagnose template
instantiations, implicit or explicit.

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaDeclCXX.cpp
clang/test/SemaCXX/warn-weak-vtables.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 13f8fc3de03c..7cee98c8a64c 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1643,10 +1643,6 @@ def warn_weak_vtable : Warning<
   "%0 has no out-of-line virtual method definitions; its vtable will be "
   "emitted in every translation unit">,
   InGroup>, DefaultIgnore;
-def warn_weak_template_vtable : Warning<
-  "explicit template instantiation %0 will emit a vtable in every "
-  "translation unit">,
-  InGroup>, DefaultIgnore;
 
 def ext_using_undefined_std : ExtWarn<
   "using directive refers to implicitly-defined namespace 'std'">;

diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 2d1fd1b14040..03f7a95d0800 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -26,6 +26,7 @@
 #include "clang/AST/TypeOrdering.h"
 #include "clang/Basic/AttributeCommonInfo.h"
 #include "clang/Basic/PartialDiagnostic.h"
+#include "clang/Basic/Specifiers.h"
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Lex/LiteralSupport.h"
 #include "clang/Lex/Preprocessor.h"
@@ -17647,16 +17648,12 @@ bool Sema::DefineUsedVTables() {
 // no key function or the key function is inlined. Don't warn in C++ ABIs
 // that lack key functions, since the user won't be able to make one.
 if (Context.getTargetInfo().getCXXABI().hasKeyFunctions() &&
-Class->isExternallyVisible() && ClassTSK != TSK_ImplicitInstantiation) 
{
+Class->isExternallyVisible() && ClassTSK != TSK_ImplicitInstantiation 
&&
+ClassTSK != TSK_ExplicitInstantiationDefinition) {
   const FunctionDecl *KeyFunctionDef = nullptr;
   if (!KeyFunction || (KeyFunction->hasBody(KeyFunctionDef) &&
-   KeyFunctionDef->isInlined())) {
-Diag(Class->getLocation(),
- ClassTSK == TSK_ExplicitInstantiationDefinition
- ? diag::warn_weak_template_vtable
- : diag::warn_weak_vtable)
-<< Class;
-  }
+   KeyFunctionDef->isInlined()))
+Diag(Class->getLocation(), diag::warn_weak_vtable) << Class;
 }
   }
   VTableUses.clear();

diff  --git a/clang/test/SemaCXX/warn-weak-vtables.cpp 
b/clang/test/SemaCXX/warn-weak-vtables.cpp
index e678f9e461ef..9355af50310d 100644
--- a/clang/test/SemaCXX/warn-weak-vtables.cpp
+++ b/clang/test/SemaCXX/warn-weak-vtables.cpp
@@ -1,8 +1,8 @@
-// RUN: %clang_cc1 %s -fsyntax-only -verify -triple %itanium_abi_triple 
-Wweak-vtables -Wweak-template-vtables
+// RUN: %clang_cc1 %s -fsyntax-only -verify -triple %itanium_abi_triple 
-Wweak-vtables
 //
 // Check that this warning is disabled on MS ABI targets which don't have key
 // functions.
-// RUN: %clang_cc1 %s -fsyntax-only -triple %ms_abi_triple -Werror 
-Wweak-vtables -Wweak-template-vtables
+// RUN: %clang_cc1 %s -fsyntax-only -triple %ms_abi_triple -Werror 
-Wweak-vtables
 
 struct A { // expected-warning {{'A' has no out-of-line virtual method 
definitions; its vtable will be emitted in every translation unit}}
   virtual void f() { } 
@@ -63,7 +63,7 @@ template struct TemplVirt {
   virtual void f();
 };
 
-template class TemplVirt; // expected-warning{{explicit template 
instantiation 'TemplVirt' will emit a vtable in every translation unit}}
+template class TemplVirt;
 
 template<> struct TemplVirt {
   virtual void f();



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


Re: [clang] 2bd8493 - Improve type printing of const arrays to normalize array-of-const and const-array

2021-10-14 Thread David Blaikie via cfe-commits
On Tue, Oct 12, 2021 at 7:35 PM David Blaikie  wrote:

> On Mon, Oct 11, 2021 at 2:46 PM Richard Smith 
> wrote:
>
>> On Wed, 15 Sept 2021 at 13:52, David Blaikie  wrote:
>>
>>> On Tue, Sep 14, 2021 at 10:04 AM Richard Smith 
>>> wrote:
>>>
>>>> On Mon, 13 Sept 2021 at 19:24, David Blaikie via cfe-commits <
>>>> cfe-commits@lists.llvm.org> wrote:
>>>>
>>>>>
>>>>> Author: David Blaikie
>>>>> Date: 2021-09-13T19:17:05-07:00
>>>>> New Revision: 2bd84938470bf2e337801faafb8a67710f46429d
>>>>>
>>>>> URL:
>>>>> https://github.com/llvm/llvm-project/commit/2bd84938470bf2e337801faafb8a67710f46429d
>>>>> DIFF:
>>>>> https://github.com/llvm/llvm-project/commit/2bd84938470bf2e337801faafb8a67710f46429d.diff
>>>>>
>>>>> LOG: Improve type printing of const arrays to normalize array-of-const
>>>>> and const-array
>>>>>
>>>>> Since these map to the same effective type - render them the same/in
>>>>> the
>>>>> more legible way (const x[n]).
>>>>>
>>>>
>>>> Nice!
>>>>
>>>>
>>>>> Added:
>>>>>
>>>>>
>>>>> Modified:
>>>>> clang/lib/AST/TypePrinter.cpp
>>>>> clang/test/ARCMT/cxx-checking.mm
>>>>> clang/test/AST/ast-dump-APValue-arithmetic.cpp
>>>>> clang/test/AST/ast-dump-APValue-array.cpp
>>>>> clang/test/CXX/basic/basic.types/p10.cpp
>>>>> clang/test/Sema/assign.c
>>>>> clang/test/Sema/typedef-retain.c
>>>>> clang/test/SemaCXX/reinterpret-cast.cpp
>>>>> clang/test/SemaCXX/static-assert-cxx17.cpp
>>>>>
>>>>> Removed:
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> 
>>>>> diff  --git a/clang/lib/AST/TypePrinter.cpp
>>>>> b/clang/lib/AST/TypePrinter.cpp
>>>>> index aef1e4f3f4953..251db97c7db08 100644
>>>>> --- a/clang/lib/AST/TypePrinter.cpp
>>>>> +++ b/clang/lib/AST/TypePrinter.cpp
>>>>> @@ -200,11 +200,12 @@ bool TypePrinter::canPrefixQualifiers(const Type
>>>>> *T,
>>>>>// type expands to a simple string.
>>>>>bool CanPrefixQualifiers = false;
>>>>>NeedARCStrongQualifier = false;
>>>>> -  Type::TypeClass TC = T->getTypeClass();
>>>>> +  const Type *UnderlyingType = T;
>>>>>if (const auto *AT = dyn_cast(T))
>>>>> -TC = AT->desugar()->getTypeClass();
>>>>> +UnderlyingType = AT->desugar().getTypePtr();
>>>>>if (const auto *Subst = dyn_cast(T))
>>>>> -TC = Subst->getReplacementType()->getTypeClass();
>>>>> +UnderlyingType = Subst->getReplacementType().getTypePtr();
>>>>> +  Type::TypeClass TC = UnderlyingType->getTypeClass();
>>>>>
>>>>>switch (TC) {
>>>>>  case Type::Auto:
>>>>> @@ -243,6 +244,9 @@ bool TypePrinter::canPrefixQualifiers(const Type
>>>>> *T,
>>>>>
>>>>>  case Type::ConstantArray:
>>>>>  case Type::IncompleteArray:
>>>>> +  return canPrefixQualifiers(
>>>>> +
>>>>> cast(UnderlyingType)->getElementType().getTypePtr(),
>>>>> +  NeedARCStrongQualifier);
>>>>>  case Type::VariableArray:
>>>>>  case Type::DependentSizedArray:
>>>>>
>>>>
>>>> Can we give these two cases the same treatment?
>>>>
>>>
>>> Handled the DependentSizedArray in
>>> https://github.com/llvm/llvm-project/commit/40acc0adad59ac39e9a7a02fcd93161298500c00
>>>
>>> But per the comment in that commit I wasn't able to reproduce the
>>> problem with a variable array - though we could include it in the handling
>>> on principle/for consistency, even without a test/etc. Perhaps there's a
>>> way to test/provoke the behavior you might know that I couldn't figure out?
>>>
>>> Details from the commit:
>>>
>>> The VariableArray case I couldn't figure out how to test/provoke -
>>> you
>>>
>>> can't w

Re: [clang] 2bd8493 - Improve type printing of const arrays to normalize array-of-const and const-array

2021-10-12 Thread David Blaikie via cfe-commits
On Mon, Oct 11, 2021 at 2:46 PM Richard Smith  wrote:

> On Wed, 15 Sept 2021 at 13:52, David Blaikie  wrote:
>
>> On Tue, Sep 14, 2021 at 10:04 AM Richard Smith 
>> wrote:
>>
>>> On Mon, 13 Sept 2021 at 19:24, David Blaikie via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
>>>>
>>>> Author: David Blaikie
>>>> Date: 2021-09-13T19:17:05-07:00
>>>> New Revision: 2bd84938470bf2e337801faafb8a67710f46429d
>>>>
>>>> URL:
>>>> https://github.com/llvm/llvm-project/commit/2bd84938470bf2e337801faafb8a67710f46429d
>>>> DIFF:
>>>> https://github.com/llvm/llvm-project/commit/2bd84938470bf2e337801faafb8a67710f46429d.diff
>>>>
>>>> LOG: Improve type printing of const arrays to normalize array-of-const
>>>> and const-array
>>>>
>>>> Since these map to the same effective type - render them the same/in the
>>>> more legible way (const x[n]).
>>>>
>>>
>>> Nice!
>>>
>>>
>>>> Added:
>>>>
>>>>
>>>> Modified:
>>>> clang/lib/AST/TypePrinter.cpp
>>>> clang/test/ARCMT/cxx-checking.mm
>>>> clang/test/AST/ast-dump-APValue-arithmetic.cpp
>>>> clang/test/AST/ast-dump-APValue-array.cpp
>>>> clang/test/CXX/basic/basic.types/p10.cpp
>>>> clang/test/Sema/assign.c
>>>> clang/test/Sema/typedef-retain.c
>>>> clang/test/SemaCXX/reinterpret-cast.cpp
>>>> clang/test/SemaCXX/static-assert-cxx17.cpp
>>>>
>>>> Removed:
>>>>
>>>>
>>>>
>>>>
>>>> 
>>>> diff  --git a/clang/lib/AST/TypePrinter.cpp
>>>> b/clang/lib/AST/TypePrinter.cpp
>>>> index aef1e4f3f4953..251db97c7db08 100644
>>>> --- a/clang/lib/AST/TypePrinter.cpp
>>>> +++ b/clang/lib/AST/TypePrinter.cpp
>>>> @@ -200,11 +200,12 @@ bool TypePrinter::canPrefixQualifiers(const Type
>>>> *T,
>>>>// type expands to a simple string.
>>>>bool CanPrefixQualifiers = false;
>>>>NeedARCStrongQualifier = false;
>>>> -  Type::TypeClass TC = T->getTypeClass();
>>>> +  const Type *UnderlyingType = T;
>>>>if (const auto *AT = dyn_cast(T))
>>>> -TC = AT->desugar()->getTypeClass();
>>>> +UnderlyingType = AT->desugar().getTypePtr();
>>>>if (const auto *Subst = dyn_cast(T))
>>>> -TC = Subst->getReplacementType()->getTypeClass();
>>>> +UnderlyingType = Subst->getReplacementType().getTypePtr();
>>>> +  Type::TypeClass TC = UnderlyingType->getTypeClass();
>>>>
>>>>switch (TC) {
>>>>  case Type::Auto:
>>>> @@ -243,6 +244,9 @@ bool TypePrinter::canPrefixQualifiers(const Type *T,
>>>>
>>>>  case Type::ConstantArray:
>>>>  case Type::IncompleteArray:
>>>> +  return canPrefixQualifiers(
>>>> +
>>>> cast(UnderlyingType)->getElementType().getTypePtr(),
>>>> +  NeedARCStrongQualifier);
>>>>  case Type::VariableArray:
>>>>  case Type::DependentSizedArray:
>>>>
>>>
>>> Can we give these two cases the same treatment?
>>>
>>
>> Handled the DependentSizedArray in
>> https://github.com/llvm/llvm-project/commit/40acc0adad59ac39e9a7a02fcd93161298500c00
>>
>> But per the comment in that commit I wasn't able to reproduce the problem
>> with a variable array - though we could include it in the handling on
>> principle/for consistency, even without a test/etc. Perhaps there's a way
>> to test/provoke the behavior you might know that I couldn't figure out?
>>
>> Details from the commit:
>>
>> The VariableArray case I couldn't figure out how to test/provoke -
>> you
>>
>> can't write/form a variable array in any context other than a local
>>
>> variable that I know of, and in that case `const int x[n]` is the
>>
>> normalized form already (array-of-const) and you can't use typedefs
>>
>> (since you can't typedef int[n] with variable 'n') to force the
>>
>> const-array AST that would produce the undesirable type printing "int
>>
>> const [n]".
>>
>
> C has a fairly surprising rule here -- you 

[clang] 3909327 - Improve printing of const variable sized arrays

2021-10-12 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2021-10-12T19:04:53-07:00
New Revision: 39093279f2ede4af9048b89d048d7fe9182a50f8

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

LOG: Improve printing of const variable sized arrays

Follow-on from 40acc0adad59ac39e9a7a02fcd93161298500c00 with help from
Richard Smith on how to provoke this particular case.

Added: 
clang/test/Sema/vla.cpp

Modified: 
clang/lib/AST/TypePrinter.cpp

Removed: 




diff  --git a/clang/lib/AST/TypePrinter.cpp b/clang/lib/AST/TypePrinter.cpp
index 3c7a6b8b9e95..e573037db10e 100644
--- a/clang/lib/AST/TypePrinter.cpp
+++ b/clang/lib/AST/TypePrinter.cpp
@@ -242,6 +242,7 @@ bool TypePrinter::canPrefixQualifiers(const Type *T,
 T->isObjCQualifiedIdType() || T->isObjCQualifiedClassType();
   break;
 
+case Type::VariableArray:
 case Type::DependentSizedArray:
   NeedARCStrongQualifier = true;
   LLVM_FALLTHROUGH;
@@ -251,9 +252,6 @@ bool TypePrinter::canPrefixQualifiers(const Type *T,
   return canPrefixQualifiers(
   cast(UnderlyingType)->getElementType().getTypePtr(),
   NeedARCStrongQualifier);
-case Type::VariableArray:
-  NeedARCStrongQualifier = true;
-  LLVM_FALLTHROUGH;
 
 case Type::Adjusted:
 case Type::Decayed:

diff  --git a/clang/test/Sema/vla.cpp b/clang/test/Sema/vla.cpp
new file mode 100644
index ..b4416a07cf0e
--- /dev/null
+++ b/clang/test/Sema/vla.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+
+void f1(int n) {
+  typedef int x[n];
+  const x y; // expected-error {{default initialization of an object of const 
type 'const x' (aka 'const int [n]')}}
+}



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


[clang] f6a561c - DebugInfo: Use clang's preferred names for integer types

2021-10-06 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2021-10-06T16:02:34-07:00
New Revision: f6a561c4d6754b13165a49990e8365d819f64c86

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

LOG: DebugInfo: Use clang's preferred names for integer types

This reverts c7f16ab3e3f27d944db72908c9c1b1b7366f5515 / r109694 - which
suggested this was done to improve consistency with the gdb test suite.
Possible that at the time GCC did not canonicalize integer types, and so
matching types was important for cross-compiler validity, or that it was
only a case of over-constrained test cases that printed out/tested the
exact names of integer types.

In any case neither issue seems to exist today based on my limited
testing - both gdb and lldb canonicalize integer types (in a way that
happens to match Clang's preferred naming, incidentally) and so never
print the original text name produced in the DWARF by GCC or Clang.

This canonicalization appears to be in `integer_types_same_name_p` for
GDB and in `TypeSystemClang::GetBasicTypeEnumeration` for lldb.

(I tested this with one translation unit defining 3 variables - `long`,
`long (*)()`, and `int (*)()`, and another translation unit that had
main, and a function that took `long (*)()` as a parameter - then
compiled them with mismatched compilers (either GCC+Clang, or
Clang+(Clang with this patch applied)) and no matter the combination,
despite the debug info for one CU naming the type "long int" and the
other naming it "long", both debuggers printed out the name as "long"
and were able to correctly perform overload resolution and pass the
`long int (*)()` variable to the `long (*)()` function parameter)

Did find one hiccup, identified by the lldb test suite - that CodeView
was relying on these names to map them to builtin types in that format.
So added some handling for that in LLVM. (these could be split out into
separate patches, but seems small enough to not warrant it - will do
that if there ends up needing any reverti/revisiting)

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

Added: 
llvm/test/DebugInfo/COFF/types-integer-old.ll

Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp
clang/test/CodeGen/aarch64-debug-sve-vector-types.c
clang/test/CodeGen/aarch64-debug-sve-vectorx2-types.c
clang/test/CodeGen/aarch64-debug-sve-vectorx3-types.c
clang/test/CodeGen/aarch64-debug-sve-vectorx4-types.c
clang/test/CodeGen/debug-info-enum.cpp
clang/test/CodeGen/debug-info.c
clang/test/CodeGenCXX/debug-info-enum-class.cpp
clang/test/CodeGenObjC/objc-fixed-enum.m
lldb/test/Shell/SymbolFile/DWARF/x86/find-basic-variable.cpp
llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
llvm/test/CodeGen/MIR/X86/diexpr-win32.mir
llvm/test/DebugInfo/COFF/types-basic.ll

Removed: 




diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 5b5fbd065eae..9c98278aa622 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -873,23 +873,7 @@ llvm::DIType *CGDebugInfo::CreateType(const BuiltinType 
*BT) {
 break;
   }
 
-  switch (BT->getKind()) {
-  case BuiltinType::Long:
-BTName = "long int";
-break;
-  case BuiltinType::LongLong:
-BTName = "long long int";
-break;
-  case BuiltinType::ULong:
-BTName = "long unsigned int";
-break;
-  case BuiltinType::ULongLong:
-BTName = "long long unsigned int";
-break;
-  default:
-BTName = BT->getName(CGM.getLangOpts());
-break;
-  }
+  BTName = BT->getName(CGM.getLangOpts());
   // Bit size and offset of the type.
   uint64_t Size = CGM.getContext().getTypeSize(BT);
   return DBuilder.createBasicType(BTName, Size, Encoding);

diff  --git a/clang/test/CodeGen/aarch64-debug-sve-vector-types.c 
b/clang/test/CodeGen/aarch64-debug-sve-vector-types.c
index 4325e3f44747..b2c5b78f9394 100644
--- a/clang/test/CodeGen/aarch64-debug-sve-vector-types.c
+++ b/clang/test/CodeGen/aarch64-debug-sve-vector-types.c
@@ -46,12 +46,12 @@ void test_locals(void) {
 
   // CHECK-DAG: name: "__SVInt64_t",{{.*}}, baseType: ![[CT64:[0-9]+]]
   // CHECK-DAG: ![[CT64]] = !DICompositeType(tag: DW_TAG_array_type, baseType: 
![[ELTTY64:[0-9]+]], flags: DIFlagVector, elements: ![[ELTS1_64]])
-  // CHECK-DAG: ![[ELTTY64]] = !DIBasicType(name: "long int", size: 64, 
encoding: DW_ATE_signed)
+  // CHECK-DAG: ![[ELTTY64]] = !DIBasicType(name: "long", size: 64, encoding: 
DW_ATE_signed)
   __SVInt64_t s64;
 
   // CHECK-DAG: name: "__SVUint64_t",{{.*}}, baseType: ![[CT64:[0-9]+]]
   // CHECK-DAG: ![[CT64]] = !DICompositeType(tag: DW_TAG_array_type, baseType: 
![[ELTTY64:[0-9]+]], flags: DIFlagVector, elements: ![[ELTS1_64]])
-  // CHECK-DAG: ![[ELTTY64]] = !DIBasicType(name: "long unsigned int", size: 
64, encoding: DW_ATE_unsigned)
+  // 

[clang] 85f612e - DebugInfo: Use sugared function type when emitting function declarations for call sites

2021-09-28 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2021-09-28T10:44:35-07:00
New Revision: 85f612efeb352e759f120ee183bf31b1fd7e801a

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

LOG: DebugInfo: Use sugared function type when emitting function declarations 
for call sites

Otherwise we're losing type information for these functions.

Added: 


Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/CGDebugInfo.h
clang/lib/CodeGen/CGExpr.cpp
clang/lib/CodeGen/CodeGenFunction.cpp
clang/test/CodeGen/debug-info-extern-call.c

Removed: 




diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 100ce695f86b..5b5fbd065eae 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -3970,6 +3970,20 @@ llvm::DISubroutineType 
*CGDebugInfo::getOrCreateFunctionType(const Decl *D,
   return cast(getOrCreateType(FnType, F));
 }
 
+QualType
+CGDebugInfo::getFunctionType(const FunctionDecl *FD, QualType RetTy,
+ const SmallVectorImpl ) {
+  CallingConv CC = CallingConv::CC_C;
+  if (FD)
+if (const auto *SrcFnTy = FD->getType()->getAs())
+  CC = SrcFnTy->getCallConv();
+  SmallVector ArgTypes;
+  for (const VarDecl *VD : Args)
+ArgTypes.push_back(VD->getType());
+  return CGM.getContext().getFunctionType(RetTy, ArgTypes,
+  FunctionProtoType::ExtProtoInfo(CC));
+}
+
 void CGDebugInfo::emitFunctionStart(GlobalDecl GD, SourceLocation Loc,
 SourceLocation ScopeLoc, QualType FnType,
 llvm::Function *Fn, bool CurFuncIsThunk) {

diff  --git a/clang/lib/CodeGen/CGDebugInfo.h b/clang/lib/CodeGen/CGDebugInfo.h
index 6c1e65f60862..42bf6cd104c2 100644
--- a/clang/lib/CodeGen/CGDebugInfo.h
+++ b/clang/lib/CodeGen/CGDebugInfo.h
@@ -429,6 +429,9 @@ class CGDebugInfo {
   /// location will be reused.
   void EmitLocation(CGBuilderTy , SourceLocation Loc);
 
+  QualType getFunctionType(const FunctionDecl *FD, QualType RetTy,
+   const SmallVectorImpl );
+
   /// Emit a call to llvm.dbg.function.start to indicate
   /// start of a new function.
   /// \param Loc   The location of the function header.

diff  --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index fafaaf447234..5c92e1e7e073 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -5318,9 +5318,13 @@ RValue CodeGenFunction::EmitCall(QualType CalleeType, 
const CGCallee 
   // Generate function declaration DISuprogram in order to be used
   // in debug info about call sites.
   if (CGDebugInfo *DI = getDebugInfo()) {
-if (auto *CalleeDecl = dyn_cast_or_null(TargetDecl))
-  DI->EmitFuncDeclForCallSite(CallOrInvoke, QualType(FnType, 0),
+if (auto *CalleeDecl = dyn_cast_or_null(TargetDecl)) {
+  FunctionArgList Args;
+  QualType ResTy = BuildFunctionArgList(CalleeDecl, Args);
+  DI->EmitFuncDeclForCallSite(CallOrInvoke,
+  DI->getFunctionType(CalleeDecl, ResTy, Args),
   CalleeDecl);
+}
   }
 
   return Call;

diff  --git a/clang/lib/CodeGen/CodeGenFunction.cpp 
b/clang/lib/CodeGen/CodeGenFunction.cpp
index fbb06885ba35..da9a5303daad 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -988,16 +988,9 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, 
QualType RetTy,
 // Reconstruct the type from the argument list so that implicit parameters,
 // such as 'this' and 'vtt', show up in the debug info. Preserve the 
calling
 // convention.
-CallingConv CC = CallingConv::CC_C;
-if (FD)
-  if (const auto *SrcFnTy = FD->getType()->getAs())
-CC = SrcFnTy->getCallConv();
-SmallVector ArgTypes;
-for (const VarDecl *VD : Args)
-  ArgTypes.push_back(VD->getType());
-QualType FnType = getContext().getFunctionType(
-RetTy, ArgTypes, FunctionProtoType::ExtProtoInfo(CC));
-DI->emitFunctionStart(GD, Loc, StartLoc, FnType, CurFn, CurFuncIsThunk);
+DI->emitFunctionStart(GD, Loc, StartLoc,
+  DI->getFunctionType(FD, RetTy, Args), CurFn,
+  CurFuncIsThunk);
   }
 
   if (ShouldInstrumentFunction()) {

diff  --git a/clang/test/CodeGen/debug-info-extern-call.c 
b/clang/test/CodeGen/debug-info-extern-call.c
index f9abb93efe86..7cf90550ac00 100644
--- a/clang/test/CodeGen/debug-info-extern-call.c
+++ b/clang/test/CodeGen/debug-info-extern-call.c
@@ -22,7 +22,13 @@
 // RUN:   | FileCheck %s -check-prefix=NO-DECLS-FOR-EXTERN
 
 // DECLS-FOR-EXTERN-NOT: !DICompileUnit({{.*}}retainedTypes: !{{[0-9]+}}
+// DECLS-FOR-EXTERN: [[INT_TYPE:![0-9]+]] = 

Re: [clang] 76d845c - [clang-format] Fix unittest failures with -Werror

2021-09-27 Thread David Blaikie via cfe-commits
FWIW, a common way to address this issue is to use the 'unsigned' suffix,
as in:
EXPECT_EQ(x, 5u);

On Thu, Sep 23, 2021 at 4:24 PM Nemanja Ivanovic via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

>
> Author: Nemanja Ivanovic
> Date: 2021-09-23T18:24:39-05:00
> New Revision: 76d845cb169f048cb6f2176c3e7a6534dc5af097
>
> URL:
> https://github.com/llvm/llvm-project/commit/76d845cb169f048cb6f2176c3e7a6534dc5af097
> DIFF:
> https://github.com/llvm/llvm-project/commit/76d845cb169f048cb6f2176c3e7a6534dc5af097.diff
>
> LOG: [clang-format] Fix unittest failures with -Werror
>
> Commit a44ab1702539 added a unit test that fails to build with
> -Werror which causes build bot breaks on bots that include that
> option in their build. This patch just adds the necessary casts to
> silence the warnings.
>
> Added:
>
>
> Modified:
> clang/unittests/Format/QualifierFixerTest.cpp
>
> Removed:
>
>
>
>
> 
> diff  --git a/clang/unittests/Format/QualifierFixerTest.cpp
> b/clang/unittests/Format/QualifierFixerTest.cpp
> index 1bb1792113049..0592cef1eaae5 100755
> --- a/clang/unittests/Format/QualifierFixerTest.cpp
> +++ b/clang/unittests/Format/QualifierFixerTest.cpp
> @@ -554,7 +554,7 @@ TEST_F(QualifierFixerTest,
> ConstVolatileQualifiersOrder) {
>Style.QualifierOrder = {"inline", "static", "const", "volatile",
> "type"};
>
>// The Default
> -  EXPECT_EQ(Style.QualifierOrder.size(), 5);
> +  EXPECT_EQ(Style.QualifierOrder.size(), (size_t)5);
>
>verifyFormat("const volatile int a;", "const volatile int a;", Style);
>verifyFormat("const volatile int a;", "volatile const int a;", Style);
> @@ -603,7 +603,7 @@ TEST_F(QualifierFixerTest, InlineStatics) {
>FormatStyle Style = getLLVMStyle();
>Style.QualifierAlignment = FormatStyle::QAS_Left;
>Style.QualifierOrder = {"inline", "static", "const", "volatile",
> "type"};
> -  EXPECT_EQ(Style.QualifierOrder.size(), 5);
> +  EXPECT_EQ(Style.QualifierOrder.size(), (size_t)5);
>
>verifyFormat("inline static const volatile int a;",
> "const inline static volatile int a;", Style);
> @@ -621,7 +621,7 @@ TEST_F(QualifierFixerTest, AmpEqual) {
>FormatStyle Style = getLLVMStyle();
>Style.QualifierAlignment = FormatStyle::QAS_Custom;
>Style.QualifierOrder = {"static", "type", "const"};
> -  EXPECT_EQ(Style.QualifierOrder.size(), 3);
> +  EXPECT_EQ(Style.QualifierOrder.size(), (size_t)3);
>
>verifyFormat("foo(std::string const & = std::string()) const",
> "foo(const std::string & = std::string()) const", Style);
> @@ -634,7 +634,7 @@ TEST_F(QualifierFixerTest, MoveConstBeyondTypeSmall) {
>FormatStyle Style = getLLVMStyle();
>Style.QualifierAlignment = FormatStyle::QAS_Custom;
>Style.QualifierOrder = {"type", "const"};
> -  EXPECT_EQ(Style.QualifierOrder.size(), 2);
> +  EXPECT_EQ(Style.QualifierOrder.size(), (size_t)2);
>
>verifyFormat("int const a;", "const int a;", Style);
>verifyFormat("int const *a;", "const int*a;", Style);
> @@ -648,7 +648,7 @@ TEST_F(QualifierFixerTest, MoveConstBeforeTypeSmall) {
>FormatStyle Style = getLLVMStyle();
>Style.QualifierAlignment = FormatStyle::QAS_Custom;
>Style.QualifierOrder = {"const", "type"};
> -  EXPECT_EQ(Style.QualifierOrder.size(), 2);
> +  EXPECT_EQ(Style.QualifierOrder.size(), (size_t)2);
>
>verifyFormat("const int a;", "int const a;", Style);
>verifyFormat("const int *a;", "int const *a;", Style);
> @@ -670,7 +670,7 @@ TEST_F(QualifierFixerTest, MoveConstBeyondType) {
>FormatStyle Style = getLLVMStyle();
>Style.QualifierAlignment = FormatStyle::QAS_Custom;
>Style.QualifierOrder = {"static", "inline", "type", "const",
> "volatile"};
> -  EXPECT_EQ(Style.QualifierOrder.size(), 5);
> +  EXPECT_EQ(Style.QualifierOrder.size(), (size_t)5);
>
>verifyFormat("static inline int const volatile a;",
> "const inline static volatile int a;", Style);
> @@ -698,8 +698,8 @@ TEST_F(QualifierFixerTest, PrepareLeftRightOrdering) {
>QualifierAlignmentFixer::PrepareLeftRightOrdering(Style.QualifierOrder,
> Left,
>  Right,
> ConfiguredTokens);
>
> -  EXPECT_EQ(Left.size(), 2);
> -  EXPECT_EQ(Right.size(), 2);
> +  EXPECT_EQ(Left.size(), (size_t)2);
> +  EXPECT_EQ(Right.size(), (size_t)2);
>
>std::vector LeftResult = {"inline", "static"};
>std::vector RightResult = {"const", "volatile"};
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [clang] 2bd8493 - Improve type printing of const arrays to normalize array-of-const and const-array

2021-09-27 Thread David Blaikie via cfe-commits
Ping on this

On Wed, Sep 15, 2021 at 1:52 PM David Blaikie  wrote:

>
>
> On Tue, Sep 14, 2021 at 10:04 AM Richard Smith 
> wrote:
>
>> On Mon, 13 Sept 2021 at 19:24, David Blaikie via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>>
>>> Author: David Blaikie
>>> Date: 2021-09-13T19:17:05-07:00
>>> New Revision: 2bd84938470bf2e337801faafb8a67710f46429d
>>>
>>> URL:
>>> https://github.com/llvm/llvm-project/commit/2bd84938470bf2e337801faafb8a67710f46429d
>>> DIFF:
>>> https://github.com/llvm/llvm-project/commit/2bd84938470bf2e337801faafb8a67710f46429d.diff
>>>
>>> LOG: Improve type printing of const arrays to normalize array-of-const
>>> and const-array
>>>
>>> Since these map to the same effective type - render them the same/in the
>>> more legible way (const x[n]).
>>>
>>
>> Nice!
>>
>>
>>> Added:
>>>
>>>
>>> Modified:
>>> clang/lib/AST/TypePrinter.cpp
>>> clang/test/ARCMT/cxx-checking.mm
>>> clang/test/AST/ast-dump-APValue-arithmetic.cpp
>>> clang/test/AST/ast-dump-APValue-array.cpp
>>> clang/test/CXX/basic/basic.types/p10.cpp
>>> clang/test/Sema/assign.c
>>> clang/test/Sema/typedef-retain.c
>>> clang/test/SemaCXX/reinterpret-cast.cpp
>>> clang/test/SemaCXX/static-assert-cxx17.cpp
>>>
>>> Removed:
>>>
>>>
>>>
>>>
>>> 
>>> diff  --git a/clang/lib/AST/TypePrinter.cpp
>>> b/clang/lib/AST/TypePrinter.cpp
>>> index aef1e4f3f4953..251db97c7db08 100644
>>> --- a/clang/lib/AST/TypePrinter.cpp
>>> +++ b/clang/lib/AST/TypePrinter.cpp
>>> @@ -200,11 +200,12 @@ bool TypePrinter::canPrefixQualifiers(const Type
>>> *T,
>>>// type expands to a simple string.
>>>bool CanPrefixQualifiers = false;
>>>NeedARCStrongQualifier = false;
>>> -  Type::TypeClass TC = T->getTypeClass();
>>> +  const Type *UnderlyingType = T;
>>>if (const auto *AT = dyn_cast(T))
>>> -TC = AT->desugar()->getTypeClass();
>>> +UnderlyingType = AT->desugar().getTypePtr();
>>>if (const auto *Subst = dyn_cast(T))
>>> -TC = Subst->getReplacementType()->getTypeClass();
>>> +UnderlyingType = Subst->getReplacementType().getTypePtr();
>>> +  Type::TypeClass TC = UnderlyingType->getTypeClass();
>>>
>>>switch (TC) {
>>>  case Type::Auto:
>>> @@ -243,6 +244,9 @@ bool TypePrinter::canPrefixQualifiers(const Type *T,
>>>
>>>  case Type::ConstantArray:
>>>  case Type::IncompleteArray:
>>> +  return canPrefixQualifiers(
>>> +
>>> cast(UnderlyingType)->getElementType().getTypePtr(),
>>> +  NeedARCStrongQualifier);
>>>  case Type::VariableArray:
>>>  case Type::DependentSizedArray:
>>>
>>
>> Can we give these two cases the same treatment?
>>
>
> Handled the DependentSizedArray in
> https://github.com/llvm/llvm-project/commit/40acc0adad59ac39e9a7a02fcd93161298500c00
>
> But per the comment in that commit I wasn't able to reproduce the problem
> with a variable array - though we could include it in the handling on
> principle/for consistency, even without a test/etc. Perhaps there's a way
> to test/provoke the behavior you might know that I couldn't figure out?
>
> Details from the commit:
>
> The VariableArray case I couldn't figure out how to test/provoke - you
>
> can't write/form a variable array in any context other than a local
>
> variable that I know of, and in that case `const int x[n]` is the
>
> normalized form already (array-of-const) and you can't use typedefs
>
> (since you can't typedef int[n] with variable 'n') to force the
>
> const-array AST that would produce the undesirable type printing "int
>
> const [n]".
>
> Oh, also - another quirk of array type printing that I'd be up for
> addressing if you've got an opinion on it:
>
> "int [n]" is printed with a space between the "int" and array.
> "int *const[n]" is printed without a space before the array (though both
> have a space after "int")
>
> ClangFormat formats these as "int[n]" and "int *const[n]" - with *
> left/right depending on ClangFormat's heuristics/configuration.
>
> Reckon

Re: [clang] 38c09ea - DebugInfo: Add (initially no-op) -gsimple-template-names={simple, mangled}

2021-09-24 Thread David Blaikie via cfe-commits
On Thu, Sep 23, 2021 at 7:12 AM  wrote:

> Resending to cfe-commits instead of llvm-commits (doh!).
>
> > -Original Message-
> > From: Robinson, Paul
> > Sent: Thursday, September 23, 2021 10:05 AM
> > To: David Blaikie ; 'llvm-comm...@lists.llvm.org'
> > 
> > Cc: Adrian Prantl ; Jonas Devlieghere
> > 
> > Subject: RE: [clang] 38c09ea - DebugInfo: Add (initially no-op) -gsimple-
> > template-names={simple,mangled}
> >
> > -gsimple-template-names=mangled seems like a testing feature?
> > That would be parseable only by llvm-dwarfdump...
> > In which case it seems like it should be a -cc1 option not a
> > driver option.
>

Yep, sounds fair - done that in 8ec7d9b8f875368a5f92596332cd05059df6bbd2

> --paulr
> >
> > > -Original Message-
> > > From: cfe-commits  On Behalf Of
> > David
> > > Blaikie via cfe-commits
> > > Sent: Wednesday, September 22, 2021 2:12 PM
> > > To: cfe-commits@lists.llvm.org
> > > Subject: [clang] 38c09ea - DebugInfo: Add (initially no-op) -gsimple-
> > > template-names={simple,mangled}
> > >
> > >
> > > Author: David Blaikie
> > > Date: 2021-09-22T11:11:49-07:00
> > > New Revision: 38c09ea2d279eabe3602e2002f8cdfcc5380
> > >
> > > URL: https://urldefense.com/v3/__https://github.com/llvm/llvm-
> > >
> >
> project/commit/38c09ea2d279eabe3602e2002f8cdfcc5380__;!!JmoZiZGBv3RvKR
> > > Sx!sx4rLw3CFwdj-rfDEK1Ah3HnANZSLOpXYFIcie1Oiyili8LKwFHxFk-g0F7-Z2pXAg$
> > > DIFF: https://urldefense.com/v3/__https://github.com/llvm/llvm-
> > >
> >
> project/commit/38c09ea2d279eabe3602e2002f8cdfcc5380.diff__;!!JmoZiZGBv
> > > 3RvKRSx!sx4rLw3CFwdj-rfDEK1Ah3HnANZSLOpXYFIcie1Oiyili8LKwFHxFk-
> > > g0F4WQP9bxA$
> > >
> > > LOG: DebugInfo: Add (initially no-op) -gsimple-template-
> > > names={simple,mangled}
> > >
> > > This is to build the foundation of a new debug info feature to use only
> > > the base name of template as its debug info name (eg: "t1" instead of
> > > the full "t1"). The intent being that a consumer can still
> retrieve
> > > all that information from the DW_TAG_template_*_parameters.
> > >
> > > So gno-simple-template-names is business as usual/previously
> ("t1")
> > >=simple is the simplified name ("t1")
> > >=mangled is a special mode to communicate the full information, but
> > >also indicate that the name should be able to be simplified. The
> data
> > >is encoded as "_STNt1|" which will be matched with an
> > >llvm-dwarfdump --verify feature to deconstruct this name, rebuild
> the
> > >original name, and then try to rebuild the simple name via the DWARF
> > >tags - then compare the latter and the former to ensure that all the
> > >data necessary to fully rebuild the name is present.
> > >
> > > Added:
> > >
> > >
> > > Modified:
> > > clang/include/clang/Basic/CodeGenOptions.def
> > > clang/include/clang/Basic/DebugInfoOptions.h
> > > clang/include/clang/Driver/Options.td
> > > clang/lib/Driver/ToolChains/Clang.cpp
> > > clang/lib/Frontend/CompilerInvocation.cpp
> > > clang/test/Driver/debug-options.c
> > >
> > > Removed:
> > >
> > >
> > >
> > >
> >
> ##
> > > ##
> > > diff  --git a/clang/include/clang/Basic/CodeGenOptions.def
> > > b/clang/include/clang/Basic/CodeGenOptions.def
> > > index 37900bf3ead1..5d1d4f9dc58e 100644
> > > --- a/clang/include/clang/Basic/CodeGenOptions.def
> > > +++ b/clang/include/clang/Basic/CodeGenOptions.def
> > > @@ -320,6 +320,12 @@ CODEGENOPT(DebugFwdTemplateParams, 1, 0) ///<
> > Whether
> > > to emit complete
> > >   ///< template parameter
> > > descriptions in
> > >   ///< forward declarations
> > > (versus just
> > >   ///< including them in the
> > > name).
> > > +ENUM_CODEGENOPT(DebugSimpleTemplateNames,
> > > codegenoptions::DebugTemplateNamesKind, 2,
> > > codegenoptions::DebugTemplateNamesKind::Full) ///< Whether to emit
> > > template parameters
> > > + 

[clang] 8ec7d9b - DebugInfo: Move the '=' version of -gsimple-template-names to the frontend

2021-09-24 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2021-09-24T11:18:10-07:00
New Revision: 8ec7d9b8f875368a5f92596332cd05059df6bbd2

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

LOG: DebugInfo: Move the '=' version of -gsimple-template-names to the frontend

Based on feedback from Paul Robinson on 38c09ea that the 'mangled' mode
is only useful as an LLVM-developer-internal tool in combination with
llvm-dwarfdump --verify, so demote that to a frontend-only (not driver)
option. The driver support is simply -g{no-,}simple-template-names to
switch on simple template names, without the option to use the mangled
template name scheme there.

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/Driver/debug-options.c

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 28d96b1d08457..f0420702a5cc8 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2970,10 +2970,9 @@ def gno_split_dwarf : Flag<["-"], "gno-split-dwarf">, 
Group;
 def gsimple_template_names : Flag<["-"], "gsimple-template-names">, 
Group;
 def gsimple_template_names_EQ
 : Joined<["-"], "gsimple-template-names=">,
-  Group,
   HelpText<"Use simple template names in DWARF, or include the full "
"template name with a modified prefix for validation">,
-  Values<"simple,mangled">, Flags<[CC1Option]>;
+  Values<"simple,mangled">, Flags<[CC1Option, NoDriverOption]>;
 def gno_simple_template_names : Flag<["-"], "gno-simple-template-names">,
 Group;
 def ggnu_pubnames : Flag<["-"], "ggnu-pubnames">, Group, 
Flags<[CC1Option]>;

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index dc52190cbb377..30a80d38bf205 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -1415,9 +1415,8 @@ void CompilerInvocation::GenerateCodeGenArgs(
   if (TNK != codegenoptions::DebugTemplateNamesKind::Full) {
 if (TNK == codegenoptions::DebugTemplateNamesKind::Simple)
   GenerateArg(Args, OPT_gsimple_template_names_EQ, "simple", SA);
-if (TNK == codegenoptions::DebugTemplateNamesKind::Mangled)
+else if (TNK == codegenoptions::DebugTemplateNamesKind::Mangled)
   GenerateArg(Args, OPT_gsimple_template_names_EQ, "mangled", SA);
-
   }
   // ProfileInstrumentUsePath is marshalled automatically, no need to generate
   // it or PGOUseInstrumentor.
@@ -1694,6 +1693,10 @@ bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptions 
, ArgList ,
 ? llvm::DICompileUnit::DebugNameTableKind::Default
 : llvm::DICompileUnit::DebugNameTableKind::None);
   if (const Arg *A = Args.getLastArg(OPT_gsimple_template_names_EQ)) {
+StringRef Value = A->getValue();
+if (Value != "simple" && Value != "mangled")
+  Diags.Report(diag::err_drv_unsupported_option_argument)
+  << A->getOption().getName() << A->getValue();
 Opts.setDebugSimpleTemplateNames(
 StringRef(A->getValue()) == "simple"
 ? codegenoptions::DebugTemplateNamesKind::Simple

diff  --git a/clang/test/Driver/debug-options.c 
b/clang/test/Driver/debug-options.c
index 5f652cb49b71b..45a577dc7e7a2 100644
--- a/clang/test/Driver/debug-options.c
+++ b/clang/test/Driver/debug-options.c
@@ -437,13 +437,9 @@
 // NODIRECTORY: "-fno-dwarf-directory-asm"
 
 // RUN: %clang -### -target x86_64 -c -g -gsimple-template-names %s 2>&1 | 
FileCheck --check-prefix=SIMPLE_TEMP_NAMES %s
-// RUN: %clang -### -target x86_64 -c -g -gsimple-template-names=simple %s 
2>&1 | FileCheck --check-prefix=SIMPLE_TEMP_NAMES %s
 // SIMPLE_TEMP_NAMES: -gsimple-template-names=simple
 // SIMPLE_TEMP_NAMES: -debug-forward-template-params
-// RUN: %clang -### -target x86_64 -c -g -gsimple-template-names=mangled %s 
2>&1 | FileCheck --check-prefix=MANGLED_TEMP_NAMES %s
-// MANGLED_TEMP_NAMES: -gsimple-template-names=mangled
-// MANGLED_TEMP_NAMES: -debug-forward-template-params
+// RUN: not %clang -### -target x86_64 -c -g -gsimple-template-names=mangled 
%s 2>&1 | FileCheck --check-prefix=MANGLED_TEMP_NAMES %s
+// MANGLED_TEMP_NAMES: error: unknown argument: 
'-gsimple-template-names=mangled'
 // RUN: %clang -### -target x86_64 -c -g %s 2>&1 | FileCheck 
--check-prefix=FULL_TEMP_NAMES 
--implicit-check-not=debug-forward-template-params %s
 // FULL_TEMP_NAMES-NOT: -gsimple-template-names
-// RUN: %clang -### -target x86_64 -c -g -gsimple-template-names=other %s 2>&1 
| FileCheck --check-prefix=SIMPLE_TEMP_OTHER %s
-// SIMPLE_TEMP_OTHER: error: unsupported argument 'other' to option 
'gsimple-template-names='




[clang] 165926a - Fix that same path separator issue again...

2021-09-23 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2021-09-23T21:15:01-07:00
New Revision: 165926aa4ce9f05572cf8828210a1af5ce286bdb

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

LOG: Fix that same path separator issue again...

Added: 


Modified: 
clang/test/CodeGenCXX/debug-info-simple-template-names.cpp

Removed: 




diff  --git a/clang/test/CodeGenCXX/debug-info-simple-template-names.cpp 
b/clang/test/CodeGenCXX/debug-info-simple-template-names.cpp
index be290b3b97e5..73a8f49967a7 100644
--- a/clang/test/CodeGenCXX/debug-info-simple-template-names.cpp
+++ b/clang/test/CodeGenCXX/debug-info-simple-template-names.cpp
@@ -56,7 +56,7 @@ void f() {
   f1();
   // CHECK: !DISubprogram(name: "f1<(unnamed struct at 
{{.*}}debug-info-simple-template-names.cpp:[[# @LINE - 3]]:3)>",
   f1();
-  // CHECK: !DISubprogram(name: "f1",
+  // CHECK: !DISubprogram(name: "f1",
   enum {} unnamed_enum;
   f1();
   // CHECK: !DISubprogram(name: "f1<(unnamed enum at 
{{.*}}debug-info-simple-template-names.cpp:[[# @LINE - 2]]:3)>",



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


[clang] 8d9ddd4 - DebugInfo: STN: Handle unreconstitutable types in function types

2021-09-23 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2021-09-23T21:13:16-07:00
New Revision: 8d9ddd4f509c54d05a38427d7999c061d88ca35c

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

LOG: DebugInfo: STN: Handle unreconstitutable types in function types

Added: 


Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp
clang/test/CodeGenCXX/debug-info-simple-template-names.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 7119402dcb64..100ce695f86b 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -4881,7 +4881,7 @@ struct ReconstitutableType : public 
RecursiveASTVisitor {
   bool VisitFunctionProtoType(FunctionProtoType *FT) {
 // noexcept is not encoded in DWARF, so the reversi
 Reconstitutable &= !isNoexceptExceptionSpec(FT->getExceptionSpecType());
-return !Reconstitutable;
+return Reconstitutable;
   }
   bool TraverseRecordType(RecordType *RT) {
 // Unnamed classes/lambdas can't be reconstituted due to a lack of column

diff  --git a/clang/test/CodeGenCXX/debug-info-simple-template-names.cpp 
b/clang/test/CodeGenCXX/debug-info-simple-template-names.cpp
index 98109bc93f00..be290b3b97e5 100644
--- a/clang/test/CodeGenCXX/debug-info-simple-template-names.cpp
+++ b/clang/test/CodeGenCXX/debug-info-simple-template-names.cpp
@@ -55,6 +55,8 @@ void f() {
   } unnamed_struct;
   f1();
   // CHECK: !DISubprogram(name: "f1<(unnamed struct at 
{{.*}}debug-info-simple-template-names.cpp:[[# @LINE - 3]]:3)>",
+  f1();
+  // CHECK: !DISubprogram(name: "f1",
   enum {} unnamed_enum;
   f1();
   // CHECK: !DISubprogram(name: "f1<(unnamed enum at 
{{.*}}debug-info-simple-template-names.cpp:[[# @LINE - 2]]:3)>",



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


[clang] e70082e - Remove non-portable directory separator from test

2021-09-23 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2021-09-23T20:47:19-07:00
New Revision: e70082e9add7e82e580148fbd4c0a5a832763cb6

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

LOG: Remove non-portable directory separator from test

Added: 


Modified: 
clang/test/CodeGenCXX/debug-info-simple-template-names.cpp

Removed: 




diff  --git a/clang/test/CodeGenCXX/debug-info-simple-template-names.cpp 
b/clang/test/CodeGenCXX/debug-info-simple-template-names.cpp
index a73c2982791e..98109bc93f00 100644
--- a/clang/test/CodeGenCXX/debug-info-simple-template-names.cpp
+++ b/clang/test/CodeGenCXX/debug-info-simple-template-names.cpp
@@ -54,7 +54,7 @@ void f() {
   struct {
   } unnamed_struct;
   f1();
-  // CHECK: !DISubprogram(name: "f1<(unnamed struct at 
{{.*}}CodeGenCXX/debug-info-simple-template-names.cpp:[[# @LINE - 3]]:3)>",
+  // CHECK: !DISubprogram(name: "f1<(unnamed struct at 
{{.*}}debug-info-simple-template-names.cpp:[[# @LINE - 3]]:3)>",
   enum {} unnamed_enum;
   f1();
   // CHECK: !DISubprogram(name: "f1<(unnamed enum at 
{{.*}}debug-info-simple-template-names.cpp:[[# @LINE - 2]]:3)>",



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


[clang] 25ac0d3 - DebugInfo: Implement the -gsimple-template-names functionality

2021-09-23 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2021-09-23T19:58:32-07:00
New Revision: 25ac0d3c73d68c017546eb622ba7632c6b581bfb

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

LOG: DebugInfo: Implement the -gsimple-template-names functionality

This excludes certain names that can't be rebuilt from the available
DWARF:

* Atomic types - no DWARF differentiating int from atomic int.
* Vector types - enough DWARF (an attribute on the array type) to do
  this, but I haven't written the extra code to add the attributes
  required for this
* Lambdas - ambiguous with any other unnamed class
* Unnamed classes/enums - would need column info for the type in
  addition to file/line number
* noexcept function types - not encoded in DWARF

Added: 
clang/test/CodeGenCXX/debug-info-simple-template-names.cpp

Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 5889647e2de96..7119402dcb64f 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -25,6 +25,7 @@
 #include "clang/AST/DeclTemplate.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/RecordLayout.h"
+#include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/Basic/CodeGenOptions.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/SourceManager.h"
@@ -4855,11 +4856,173 @@ llvm::DIGlobalVariableExpression 
*CGDebugInfo::CollectAnonRecordDecls(
   return GVE;
 }
 
+namespace {
+struct ReconstitutableType : public RecursiveASTVisitor {
+  bool Reconstitutable = true;
+  bool VisitVectorType(VectorType *FT) {
+Reconstitutable = false;
+return false;
+  }
+  bool VisitAtomicType(AtomicType *FT) {
+Reconstitutable = false;
+return false;
+  }
+  bool TraverseEnumType(EnumType *ET) {
+// Unnamed enums can't be reconstituted due to a lack of column info we
+// produce in the DWARF, so we can't get Clang's full name back.
+if (const auto *ED = dyn_cast(ET->getDecl())) {
+  if (!ED->getIdentifier()) {
+Reconstitutable = false;
+return false;
+  }
+}
+return true;
+  }
+  bool VisitFunctionProtoType(FunctionProtoType *FT) {
+// noexcept is not encoded in DWARF, so the reversi
+Reconstitutable &= !isNoexceptExceptionSpec(FT->getExceptionSpecType());
+return !Reconstitutable;
+  }
+  bool TraverseRecordType(RecordType *RT) {
+// Unnamed classes/lambdas can't be reconstituted due to a lack of column
+// info we produce in the DWARF, so we can't get Clang's full name back.
+// But so long as it's not one of those, it doesn't matter if some sub-type
+// of the record (a template parameter) can't be reconstituted - because 
the
+// un-reconstitutable type itself will carry its own name.
+const auto *RD = dyn_cast(RT->getDecl());
+if (!RD)
+  return true;
+if (RD->isLambda() || !RD->getIdentifier()) {
+  Reconstitutable = false;
+  return false;
+}
+return true;
+  }
+};
+} // anonymous namespace
+
+// Test whether a type name could be rebuilt from emitted debug info.
+static bool IsReconstitutableType(QualType QT) {
+  ReconstitutableType T;
+  T.TraverseType(QT);
+  return T.Reconstitutable;
+}
+
 std::string CGDebugInfo::GetName(const Decl *D, bool Qualified) const {
   std::string Name;
   llvm::raw_string_ostream OS(Name);
-  if (const NamedDecl *ND = dyn_cast(D))
-ND->getNameForDiagnostic(OS, getPrintingPolicy(), Qualified);
+  const NamedDecl *ND = dyn_cast(D);
+  if (!ND)
+return Name;
+  codegenoptions::DebugTemplateNamesKind TemplateNamesKind =
+  CGM.getCodeGenOpts().getDebugSimpleTemplateNames();
+  Optional Args;
+
+  bool IsOperatorOverload = false; // isa(ND);
+  if (auto *RD = dyn_cast(ND)) {
+Args = GetTemplateArgs(RD);
+  } else if (auto *FD = dyn_cast(ND)) {
+Args = GetTemplateArgs(FD);
+auto NameKind = ND->getDeclName().getNameKind();
+IsOperatorOverload |=
+NameKind == DeclarationName::CXXOperatorName ||
+NameKind == DeclarationName::CXXConversionFunctionName;
+  } else if (auto *VD = dyn_cast(ND)) {
+Args = GetTemplateArgs(VD);
+  }
+  std::function)> HasReconstitutableArgs =
+  [&](ArrayRef Args) {
+return llvm::all_of(Args, [&](const TemplateArgument ) {
+  switch (TA.getKind()) {
+  case TemplateArgument::Template:
+// Easy to reconstitute - the value of the parameter in the debug
+// info is the string name of the template. (so the template name
+// itself won't benefit from any name rebuilding, but that's a
+// representational limitation - maybe DWARF could be
+// changed/improved to use some more structural representation)
+

[clang] 38c09ea - DebugInfo: Add (initially no-op) -gsimple-template-names={simple,mangled}

2021-09-22 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2021-09-22T11:11:49-07:00
New Revision: 38c09ea2d279eabe3602e2002f8cdfcc5380

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

LOG: DebugInfo: Add (initially no-op) -gsimple-template-names={simple,mangled}

This is to build the foundation of a new debug info feature to use only
the base name of template as its debug info name (eg: "t1" instead of
the full "t1"). The intent being that a consumer can still retrieve
all that information from the DW_TAG_template_*_parameters.

So gno-simple-template-names is business as usual/previously ("t1")
   =simple is the simplified name ("t1")
   =mangled is a special mode to communicate the full information, but
   also indicate that the name should be able to be simplified. The data
   is encoded as "_STNt1|" which will be matched with an
   llvm-dwarfdump --verify feature to deconstruct this name, rebuild the
   original name, and then try to rebuild the simple name via the DWARF
   tags - then compare the latter and the former to ensure that all the
   data necessary to fully rebuild the name is present.

Added: 


Modified: 
clang/include/clang/Basic/CodeGenOptions.def
clang/include/clang/Basic/DebugInfoOptions.h
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/Driver/debug-options.c

Removed: 




diff  --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index 37900bf3ead1..5d1d4f9dc58e 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -320,6 +320,12 @@ CODEGENOPT(DebugFwdTemplateParams, 1, 0) ///< Whether to 
emit complete
  ///< template parameter descriptions 
in
  ///< forward declarations (versus just
  ///< including them in the name).
+ENUM_CODEGENOPT(DebugSimpleTemplateNames, 
codegenoptions::DebugTemplateNamesKind, 2, 
codegenoptions::DebugTemplateNamesKind::Full) ///< Whether to emit template 
parameters
+   ///< in the textual names of 
template
+  ///< specializations.
+  ///< Implies DebugFwdTemplateNames to
+  ///< allow decorated names to be
+  ///< reconstructed when needed.
 CODEGENOPT(EmitLLVMUseLists, 1, 0) ///< Control whether to serialize use-lists.
 
 CODEGENOPT(WholeProgramVTables, 1, 0) ///< Whether to apply whole-program

diff  --git a/clang/include/clang/Basic/DebugInfoOptions.h 
b/clang/include/clang/Basic/DebugInfoOptions.h
index c1259d7797db..a99a2b5903d7 100644
--- a/clang/include/clang/Basic/DebugInfoOptions.h
+++ b/clang/include/clang/Basic/DebugInfoOptions.h
@@ -54,6 +54,12 @@ enum DebugInfoKind {
   UnusedTypeInfo,
 };
 
+enum class DebugTemplateNamesKind {
+  Full,
+  Simple,
+  Mangled
+};
+
 } // end namespace codegenoptions
 } // end namespace clang
 

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index f0932a0bd1de..13d740cdb0fb 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2967,6 +2967,15 @@ def gsplit_dwarf_EQ : Joined<["-"], "gsplit-dwarf=">, 
Group,
   HelpText<"Set DWARF fission mode to either 'split' or 'single'">,
   Values<"split,single">;
 def gno_split_dwarf : Flag<["-"], "gno-split-dwarf">, Group;
+def gsimple_template_names : Flag<["-"], "gsimple-template-names">, 
Group;
+def gsimple_template_names_EQ
+: Joined<["-"], "gsimple-template-names=">,
+  Group,
+  HelpText<"Use simple template names in DWARF, or include the full "
+   "template name with a modified prefix for validation">,
+  Values<"simple,mangled">, Flags<[CC1Option]>;
+def gno_simple_template_names : Flag<["-"], "gno-simple-template-names">,
+Group;
 def ggnu_pubnames : Flag<["-"], "ggnu-pubnames">, Group, 
Flags<[CC1Option]>;
 def gno_gnu_pubnames : Flag<["-"], "gno-gnu-pubnames">, Group;
 def gpubnames : Flag<["-"], "gpubnames">, Group, 
Flags<[CC1Option]>;

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index e6742c6575b9..6c7b8bbcaad7 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -4128,6 +4128,29 @@ static void renderDebugOptions(const ToolChain , 
const Driver ,
options::OPT_gpubnames)
 ? "-gpubnames"
 : 

[clang] 2ff049b - DebugInfo: Don't use preferred template names in debug info

2021-09-21 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2021-09-21T20:08:16-07:00
New Revision: 2ff049b12ee3fb60581835a28bf9d0acc1723f23

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

LOG: DebugInfo: Don't use preferred template names in debug info

Using the preferred name creates a mismatch between the textual name of
a type and the DWARF tags describing the parameters as well as possible
inconsistency between DWARF producers (like Clang and GCC, or
older/newer Clang versions, etc).

Added: 


Modified: 
clang/include/clang/AST/PrettyPrinter.h
clang/lib/AST/TypePrinter.cpp
clang/lib/CodeGen/CGDebugInfo.cpp
clang/test/CodeGenCXX/debug-info-template.cpp

Removed: 




diff  --git a/clang/include/clang/AST/PrettyPrinter.h 
b/clang/include/clang/AST/PrettyPrinter.h
index 3baf2b2ba94d6..8cab7f1895598 100644
--- a/clang/include/clang/AST/PrettyPrinter.h
+++ b/clang/include/clang/AST/PrettyPrinter.h
@@ -74,7 +74,8 @@ struct PrintingPolicy {
 MSWChar(LO.MicrosoftExt && !LO.WChar), IncludeNewlines(true),
 MSVCFormatting(false), ConstantsAsWritten(false),
 SuppressImplicitBase(false), FullyQualifiedName(false),
-PrintCanonicalTypes(false), PrintInjectedClassNameWithArguments(true) 
{}
+PrintCanonicalTypes(false), PrintInjectedClassNameWithArguments(true),
+UsePreferredNames(true) {}
 
   /// Adjust this printing policy for cases where it's known that we're
   /// printing C++ code (for instance, if AST dumping reaches a C++-only
@@ -272,6 +273,7 @@ struct PrintingPolicy {
   /// written. When a template argument is unnamed, printing it results in
   /// invalid C++ code.
   unsigned PrintInjectedClassNameWithArguments : 1;
+  unsigned UsePreferredNames : 1;
 
   /// Callbacks to use to allow the behavior of printing to be customized.
   const PrintingCallbacks *Callbacks = nullptr;

diff  --git a/clang/lib/AST/TypePrinter.cpp b/clang/lib/AST/TypePrinter.cpp
index 749a3e25d28a4..3c7a6b8b9e953 100644
--- a/clang/lib/AST/TypePrinter.cpp
+++ b/clang/lib/AST/TypePrinter.cpp
@@ -1370,9 +1370,11 @@ void TypePrinter::printTag(TagDecl *D, raw_ostream ) {
 
 void TypePrinter::printRecordBefore(const RecordType *T, raw_ostream ) {
   // Print the preferred name if we have one for this type.
-  for (const auto *PNA : T->getDecl()->specific_attrs()) {
-if (declaresSameEntity(PNA->getTypedefType()->getAsCXXRecordDecl(),
-   T->getDecl())) {
+  if (Policy.UsePreferredNames) {
+for (const auto *PNA : T->getDecl()->specific_attrs()) {
+  if (!declaresSameEntity(PNA->getTypedefType()->getAsCXXRecordDecl(),
+  T->getDecl()))
+continue;
   // Find the outermost typedef or alias template.
   QualType T = PNA->getTypedefType();
   while (true) {

diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 8660e23726b35..5889647e2de96 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -245,6 +245,7 @@ PrintingPolicy CGDebugInfo::getPrintingPolicy() const {
 
   PP.SuppressInlineNamespace = false;
   PP.PrintCanonicalTypes = true;
+  PP.UsePreferredNames = false;
 
   // Apply -fdebug-prefix-map.
   PP.Callbacks = 

diff  --git a/clang/test/CodeGenCXX/debug-info-template.cpp 
b/clang/test/CodeGenCXX/debug-info-template.cpp
index 546fe01833a7c..ba25e2136b221 100644
--- a/clang/test/CodeGenCXX/debug-info-template.cpp
+++ b/clang/test/CodeGenCXX/debug-info-template.cpp
@@ -258,3 +258,15 @@ template void f1();
 // CHECK: ![[TEMP_TEMP_INL_ARGS]] = !{![[TEMP_TEMP_INL_ARGS_T:[0-9]*]]}
 // CHECK: ![[TEMP_TEMP_INL_ARGS_T]] = !DITemplateValueParameter(tag: 
DW_TAG_GNU_template_template_param, value: 
!"TemplateTemplateParamInlineNamespace::inl::t1")
 } // namespace TemplateTemplateParamInlineNamespace
+
+namespace NoPreferredNames {
+template  struct t1;
+using t1i = t1;
+template 
+struct __attribute__((__preferred_name__(t1i))) t1 {};
+template 
+void f1() {}
+template void f1>();
+// CHECK: !DISubprogram(name: "f1 >",
+
+} // namespace NoPreferredNames



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


Re: r307232 - [modules ts] Do not emit strong function definitions from the module interface unit in every user.

2021-09-21 Thread David Blaikie via cfe-commits
Ping

On Sun, Sep 5, 2021 at 11:28 AM David Blaikie  wrote:

> Hey Richard - was just going back over some of the modular codegen code
> (due to a discussion on the EWG mailing list about file extensions that
> ended up touching on the nature of how modules are built) - and I came
> across this code & had the same question I see I wrote up here already but
> got lost in the *-commits mail.
>
> Wondering if you've got some thoughts on why this choice was implemented
> for C++20 modules - not homing inline functions/variables, only the extern
> linkage ones for correctness?
>
> On Sun, Jul 16, 2017 at 8:26 PM David Blaikie  wrote:
>
>> Looks good - does this support available_externally definitions of strong
>> external linkage functions in the users of a module? (is that tested?)
>> Should it?
>>
>> Also should we consider having two flags for modular codegen - one for
>> correctness (external function definitions), one for linkage size
>> optimization (inline functions). Given the current data on optimized builds
>> with inline functions (that it hurts object size to emit
>> weak+available_externally definitions rather than linkonce_odr because so
>> many definitions are optimized away entirely, that the bytes for the weak
>> definition are wasted/unnecessary) - or at least something to keep in
>> mind/run numbers on in the future for more generic codebases than Google's
>> protobuf-heavy (& only protobuf modularized) code.
>>
>> On Wed, Jul 5, 2017 at 5:30 PM Richard Smith via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: rsmith
>>> Date: Wed Jul  5 17:30:00 2017
>>> New Revision: 307232
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=307232=rev
>>> Log:
>>> [modules ts] Do not emit strong function definitions from the module
>>> interface unit in every user.
>>>
>>> Added:
>>> cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/
>>> cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p4/
>>> cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cpp
>>> cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cppm
>>> cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p4/user.cpp
>>> Modified:
>>> cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
>>>
>>> Modified: cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterDecl.cpp?rev=307232=307231=307232=diff
>>>
>>> ==
>>> --- cfe/trunk/lib/Serialization/ASTWriterDecl.cpp (original)
>>> +++ cfe/trunk/lib/Serialization/ASTWriterDecl.cpp Wed Jul  5 17:30:00
>>> 2017
>>> @@ -2233,8 +2233,18 @@ void ASTRecordWriter::AddFunctionDefinit
>>>Writer->ClearSwitchCaseIDs();
>>>
>>>assert(FD->doesThisDeclarationHaveABody());
>>> -  bool ModulesCodegen = Writer->Context->getLangOpts().ModulesCodegen &&
>>> -Writer->WritingModule &&
>>> !FD->isDependentContext();
>>> +  bool ModulesCodegen = false;
>>> +  if (Writer->WritingModule && !FD->isDependentContext()) {
>>> +// Under -fmodules-codegen, codegen is performed for all defined
>>> functions.
>>> +// When building a C++ Modules TS module interface unit, a strong
>>> definition
>>> +// in the module interface is provided by the compilation of that
>>> module
>>> +// interface unit, not by its users. (Inline functions are still
>>> emitted
>>> +// in module users.)
>>> +ModulesCodegen =
>>> +Writer->Context->getLangOpts().ModulesCodegen ||
>>> +(Writer->WritingModule->Kind == Module::ModuleInterfaceUnit &&
>>> + Writer->Context->GetGVALinkageForFunction(FD) ==
>>> GVA_StrongExternal);
>>> +  }
>>>Record->push_back(ModulesCodegen);
>>>if (ModulesCodegen)
>>>  Writer->ModularCodegenDecls.push_back(Writer->GetDeclRef(FD));
>>>
>>> Added: cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cpp?rev=307232=auto
>>>
>>> ==
>>> --- cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cpp
>>> (added)
>>> +++ cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cpp Wed
>>> Jul  5 17:30:00 2017
>>> @@ -0,0 +1,23 @@
>>> +// RUN: %clang_cc1 -fmodules-ts %S/module.cppm -triple
>>> %itanium_abi_triple -emit-module-interface -o %t
>>> +// RUN: %clang_cc1 -fmodules-ts %s -triple %itanium_abi_triple
>>> -fmodule-file=%t -emit-llvm -o - | FileCheck %s --implicit-check-not=unused
>>> --implicit-check-not=global_module
>>> +
>>> +module Module;
>>> +
>>> +void use() {
>>> +  // CHECK: define linkonce_odr {{.*}}@_Z20used_inline_exportedv
>>> +  used_inline_exported();
>>> +  // CHECK: declare {{.*}}@_Z18noninline_exportedv
>>> +  noninline_exported();
>>> +
>>> +  // FIXME: This symbol should not be visible here.
>>> +  // CHECK: define 

[clang] db6f1e8 - DebugInfo: Don't suppress inline namespaces when printing template template parameter names

2021-09-21 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2021-09-21T19:30:13-07:00
New Revision: db6f1e8a8857ccaa339304131373f3150528e812

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

LOG: DebugInfo: Don't suppress inline namespaces when printing template 
template parameter names

Added: 


Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp
clang/test/CodeGenCXX/debug-info-template.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 37d53dfbc7014..8660e23726b35 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2066,11 +2066,15 @@ 
CGDebugInfo::CollectTemplateParams(Optional OArgs,
   TemplateParams.push_back(DBuilder.createTemplateValueParameter(
   TheCU, Name, TTy, defaultParameter, V));
 } break;
-case TemplateArgument::Template:
+case TemplateArgument::Template: {
+  std::string QualName;
+  llvm::raw_string_ostream OS(QualName);
+  TA.getAsTemplate().getAsTemplateDecl()->printQualifiedName(
+  OS, getPrintingPolicy());
   TemplateParams.push_back(DBuilder.createTemplateTemplateParameter(
-  TheCU, Name, nullptr,
-  TA.getAsTemplate().getAsTemplateDecl()->getQualifiedNameAsString()));
+  TheCU, Name, nullptr, OS.str()));
   break;
+}
 case TemplateArgument::Pack:
   TemplateParams.push_back(DBuilder.createTemplateParameterPack(
   TheCU, Name, nullptr,

diff  --git a/clang/test/CodeGenCXX/debug-info-template.cpp 
b/clang/test/CodeGenCXX/debug-info-template.cpp
index d536cc5d34c33..546fe01833a7c 100644
--- a/clang/test/CodeGenCXX/debug-info-template.cpp
+++ b/clang/test/CodeGenCXX/debug-info-template.cpp
@@ -245,3 +245,16 @@ void f1() {}
 template void f1();
 // CHECK: !DISubprogram(name: "f1",
 } // namespace Nullptr_t
+
+namespace TemplateTemplateParamInlineNamespace {
+inline namespace inl {
+  template
+  struct t1 { };
+} // namespace inl
+template class> void f1() { }
+template void f1();
+// CHECK: !DISubprogram(name: 
"f1",
+// CHECK-SAME: templateParams: ![[TEMP_TEMP_INL_ARGS:[0-9]*]],
+// CHECK: ![[TEMP_TEMP_INL_ARGS]] = !{![[TEMP_TEMP_INL_ARGS_T:[0-9]*]]}
+// CHECK: ![[TEMP_TEMP_INL_ARGS_T]] = !DITemplateValueParameter(tag: 
DW_TAG_GNU_template_template_param, value: 
!"TemplateTemplateParamInlineNamespace::inl::t1")
+} // namespace TemplateTemplateParamInlineNamespace



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


[clang] d31dfc3 - DebugInfo: Unify some printing policy adjustments

2021-09-21 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2021-09-21T19:30:12-07:00
New Revision: d31dfc30115705332034a81b6b2ab904ca1cf029

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

LOG: DebugInfo: Unify some printing policy adjustments

Added: 


Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 00ed07ae2fc3c..37d53dfbc7014 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -243,6 +243,9 @@ PrintingPolicy CGDebugInfo::getPrintingPolicy() const {
 PP.SplitTemplateClosers = true;
   }
 
+  PP.SuppressInlineNamespace = false;
+  PP.PrintCanonicalTypes = true;
+
   // Apply -fdebug-prefix-map.
   PP.Callbacks = 
   return PP;
@@ -4850,12 +4853,8 @@ llvm::DIGlobalVariableExpression 
*CGDebugInfo::CollectAnonRecordDecls(
 std::string CGDebugInfo::GetName(const Decl *D, bool Qualified) const {
   std::string Name;
   llvm::raw_string_ostream OS(Name);
-  if (const NamedDecl *ND = dyn_cast(D)) {
-PrintingPolicy PP = getPrintingPolicy();
-PP.PrintCanonicalTypes = true;
-PP.SuppressInlineNamespace = false;
-ND->getNameForDiagnostic(OS, PP, Qualified);
-  }
+  if (const NamedDecl *ND = dyn_cast(D))
+ND->getNameForDiagnostic(OS, getPrintingPolicy(), Qualified);
   return Name;
 }
 



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


[clang] 131e878 - Print nullptr_t namespace qualified within std::

2021-09-21 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2021-09-21T11:21:40-07:00
New Revision: 131e8786640a49daf533b7ead4d3b5b82e0aea2a

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

LOG: Print nullptr_t namespace qualified within std::

This improves diagnostic (& important to me, DWARF) accuracy - otherwise
there could be ambiguities between "std::nullptr_t" and some user-defined
type that's /actually/ "nullptr_t" defined in the global namespace.

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

Added: 


Modified: 
clang/lib/AST/Type.cpp
clang/test/AST/ast-dump-recovery.cpp
clang/test/Analysis/plist-diagnostics-template-record.cpp
clang/test/CXX/drs/dr15xx.cpp
clang/test/CXX/drs/dr6xx.cpp
clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1-11.cpp
clang/test/CXX/temp/temp.param/p10-2a.cpp
clang/test/CodeGenCXX/debug-info-template.cpp
clang/test/OpenMP/task_affinity_messages.cpp
clang/test/OpenMP/task_depend_messages.cpp
clang/test/Sema/builtins-arm64-mte.c
clang/test/Sema/format-strings-pedantic.c
clang/test/SemaCXX/cxx0x-noexcept-expression.cpp
clang/test/SemaCXX/cxx2a-explicit-bool.cpp
clang/test/SemaCXX/nullability.cpp
clang/test/SemaCXX/nullptr.cpp
clang/test/SemaTemplate/deduction-guide.cpp
clang/test/SemaTemplate/deduction.cpp
clang/test/SemaTemplate/friend.cpp
clang/test/SemaTemplate/instantiate-local-class.cpp

Removed: 




diff  --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index f71c05d639ce3..112218d6eb369 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -3042,7 +3042,7 @@ StringRef BuiltinType::getName(const PrintingPolicy 
) const {
   case Char32:
 return "char32_t";
   case NullPtr:
-return "nullptr_t";
+return "std::nullptr_t";
   case Overload:
 return "";
   case BoundMember:

diff  --git a/clang/test/AST/ast-dump-recovery.cpp 
b/clang/test/AST/ast-dump-recovery.cpp
index 5ea9c08519695..8c6563961bd60 100644
--- a/clang/test/AST/ast-dump-recovery.cpp
+++ b/clang/test/AST/ast-dump-recovery.cpp
@@ -250,7 +250,7 @@ using Escape = decltype([] { return undef(); }());
 // CHECK-NEXT: `-RecoveryExpr {{.*}} '' contains-errors lvalue
 // CHECK-NEXT:   `-InitListExpr
 // CHECK-NEXT: `-DesignatedInitExpr {{.*}} 'void'
-// CHECK-NEXT:   `-CXXNullPtrLiteralExpr {{.*}} 'nullptr_t'
+// CHECK-NEXT:   `-CXXNullPtrLiteralExpr {{.*}} 'std::nullptr_t'
 struct {
   int& abc;
 } NoCrashOnInvalidInitList = {

diff  --git a/clang/test/Analysis/plist-diagnostics-template-record.cpp 
b/clang/test/Analysis/plist-diagnostics-template-record.cpp
index ffd6d03088363..3f45a43d260b9 100644
--- a/clang/test/Analysis/plist-diagnostics-template-record.cpp
+++ b/clang/test/Analysis/plist-diagnostics-template-record.cpp
@@ -38,5 +38,5 @@ int main() {
 
 // CHECK:  Calling constructor for DivByZeroint, float, 
double, 0
 // CHECK:  Calling constructor for DivByZerochar, float, 
double, 0
-// CHECK:  Calling constructor for 
DivByZeroVariadicchar, float, double, nullptr_t
+// CHECK:  Calling constructor for 
DivByZeroVariadicchar, float, double, 
std::nullptr_t
 

diff  --git a/clang/test/CXX/drs/dr15xx.cpp b/clang/test/CXX/drs/dr15xx.cpp
index e4f1105ceebe0..c588891a75d6a 100644
--- a/clang/test/CXX/drs/dr15xx.cpp
+++ b/clang/test/CXX/drs/dr15xx.cpp
@@ -113,7 +113,7 @@ namespace dr1512 { // dr1512: 4
   }
 
 #if __cplusplus >= 201103L
-  template struct Wrap { operator T(); }; // expected-note 
4{{converted to type 'nullptr_t'}} expected-note 4{{converted to type 'int *'}}
+  template struct Wrap { operator T(); }; // expected-note 
4{{converted to type 'std::nullptr_t'}} expected-note 4{{converted to type 'int 
*'}}
   void test_overload() {
 using nullptr_t = decltype(nullptr);
 void(Wrap() == Wrap());
@@ -127,7 +127,7 @@ namespace dr1512 { // dr1512: 4
 // but then only convert as far as 'nullptr_t', which we then can't 
convert to 'int*'.
 void(Wrap() == Wrap());
 void(Wrap() != Wrap());
-void(Wrap() < Wrap()); // expected-error {{invalid 
operands to binary expression ('Wrap' and 'Wrap')}}
+void(Wrap() < Wrap()); // expected-error {{invalid 
operands to binary expression ('Wrap' (aka 'Wrap') 
and 'Wrap')}}
 void(Wrap() > Wrap()); // expected-error {{invalid 
operands}}
 void(Wrap() <= Wrap()); // expected-error {{invalid 
operands}}
 void(Wrap() >= Wrap()); // expected-error {{invalid 
operands}}

diff  --git a/clang/test/CXX/drs/dr6xx.cpp b/clang/test/CXX/drs/dr6xx.cpp
index efca2b4292748..d3cf925eb3f3e 100644
--- a/clang/test/CXX/drs/dr6xx.cpp
+++ b/clang/test/CXX/drs/dr6xx.cpp
@@ -590,7 +590,7 @@ namespace dr652 { // dr652: yes
 namespace dr654 { // dr654: sup 1423
   void f() {
 if (nullptr) {} // expected-warning 

[clang] 8264846 - Senticify some comments - post-commit review for e4b9f5e851d1fe0ba93cbb11b2ed4558602c379e

2021-09-15 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2021-09-15T13:59:11-07:00
New Revision: 8264846c0ef847adeacca9b8fe0f867a8a378c5e

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

LOG: Senticify some comments - post-commit review for 
e4b9f5e851d1fe0ba93cbb11b2ed4558602c379e

Based on feedback from Paul Robinson.

Added: 


Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 8abdff010d256..43c9f8c565da0 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1651,10 +1651,10 @@ CGDebugInfo::getOrCreateInstanceMethodType(QualType 
ThisPtr,
   Qc.removeUnaligned();
   // Keep the removed qualifiers in sync with
   // CreateQualifiedType(const FunctionPrototype*, DIFile *Unit)
-  // on a 'real' member function type, these qualifiers are carried on the type
+  // On a 'real' member function type, these qualifiers are carried on the type
   // of the first parameter, not as separate DW_TAG_const_type (etc) decorator
-  // tags around them. (but in the raw function types with qualifiers, they 
have
-  // to use wrapper types)
+  // tags around them. (But, in the raw function types with qualifiers, they 
have
+  // to use wrapper types.)
 
   // Add "this" pointer.
   const auto *OriginalFunc = cast(



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


Re: [clang] 2bd8493 - Improve type printing of const arrays to normalize array-of-const and const-array

2021-09-15 Thread David Blaikie via cfe-commits
On Tue, Sep 14, 2021 at 10:04 AM Richard Smith 
wrote:

> On Mon, 13 Sept 2021 at 19:24, David Blaikie via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>>
>> Author: David Blaikie
>> Date: 2021-09-13T19:17:05-07:00
>> New Revision: 2bd84938470bf2e337801faafb8a67710f46429d
>>
>> URL:
>> https://github.com/llvm/llvm-project/commit/2bd84938470bf2e337801faafb8a67710f46429d
>> DIFF:
>> https://github.com/llvm/llvm-project/commit/2bd84938470bf2e337801faafb8a67710f46429d.diff
>>
>> LOG: Improve type printing of const arrays to normalize array-of-const
>> and const-array
>>
>> Since these map to the same effective type - render them the same/in the
>> more legible way (const x[n]).
>>
>
> Nice!
>
>
>> Added:
>>
>>
>> Modified:
>> clang/lib/AST/TypePrinter.cpp
>> clang/test/ARCMT/cxx-checking.mm
>> clang/test/AST/ast-dump-APValue-arithmetic.cpp
>> clang/test/AST/ast-dump-APValue-array.cpp
>> clang/test/CXX/basic/basic.types/p10.cpp
>> clang/test/Sema/assign.c
>> clang/test/Sema/typedef-retain.c
>> clang/test/SemaCXX/reinterpret-cast.cpp
>> clang/test/SemaCXX/static-assert-cxx17.cpp
>>
>> Removed:
>>
>>
>>
>>
>> 
>> diff  --git a/clang/lib/AST/TypePrinter.cpp
>> b/clang/lib/AST/TypePrinter.cpp
>> index aef1e4f3f4953..251db97c7db08 100644
>> --- a/clang/lib/AST/TypePrinter.cpp
>> +++ b/clang/lib/AST/TypePrinter.cpp
>> @@ -200,11 +200,12 @@ bool TypePrinter::canPrefixQualifiers(const Type *T,
>>// type expands to a simple string.
>>bool CanPrefixQualifiers = false;
>>NeedARCStrongQualifier = false;
>> -  Type::TypeClass TC = T->getTypeClass();
>> +  const Type *UnderlyingType = T;
>>if (const auto *AT = dyn_cast(T))
>> -TC = AT->desugar()->getTypeClass();
>> +UnderlyingType = AT->desugar().getTypePtr();
>>if (const auto *Subst = dyn_cast(T))
>> -TC = Subst->getReplacementType()->getTypeClass();
>> +UnderlyingType = Subst->getReplacementType().getTypePtr();
>> +  Type::TypeClass TC = UnderlyingType->getTypeClass();
>>
>>switch (TC) {
>>  case Type::Auto:
>> @@ -243,6 +244,9 @@ bool TypePrinter::canPrefixQualifiers(const Type *T,
>>
>>  case Type::ConstantArray:
>>  case Type::IncompleteArray:
>> +  return canPrefixQualifiers(
>> +  cast(UnderlyingType)->getElementType().getTypePtr(),
>> +  NeedARCStrongQualifier);
>>  case Type::VariableArray:
>>  case Type::DependentSizedArray:
>>
>
> Can we give these two cases the same treatment?
>

Handled the DependentSizedArray in
https://github.com/llvm/llvm-project/commit/40acc0adad59ac39e9a7a02fcd93161298500c00

But per the comment in that commit I wasn't able to reproduce the problem
with a variable array - though we could include it in the handling on
principle/for consistency, even without a test/etc. Perhaps there's a way
to test/provoke the behavior you might know that I couldn't figure out?

Details from the commit:

The VariableArray case I couldn't figure out how to test/provoke - you

can't write/form a variable array in any context other than a local

variable that I know of, and in that case `const int x[n]` is the

normalized form already (array-of-const) and you can't use typedefs

(since you can't typedef int[n] with variable 'n') to force the

const-array AST that would produce the undesirable type printing "int

const [n]".

Oh, also - another quirk of array type printing that I'd be up for
addressing if you've got an opinion on it:

"int [n]" is printed with a space between the "int" and array.
"int *const[n]" is printed without a space before the array (though both
have a space after "int")

ClangFormat formats these as "int[n]" and "int *const[n]" - with *
left/right depending on ClangFormat's heuristics/configuration.

Reckon we should remove the space in "int[n]"?



>
>
>>NeedARCStrongQualifier = true;
>
>
>> diff  --git a/clang/test/ARCMT/cxx-checking.mm b/clang/test/ARCMT/
>> cxx-checking.mm
>> index 952f3cdcbb79c..d6441def09b40 100644
>> --- a/clang/test/ARCMT/cxx-checking.mm
>> +++ b/clang/test/ARCMT/cxx-checking.mm
>> @@ -80,7 +80,7 @@
>>
>>  struct FlexibleArrayMember0 {
>>int length;
>> -  id array[]; // expected-error{{flexible array member 'array' of type
>> 'id __strong[]' with non-trivi

[clang] 40acc0a - Improve type printing of size-dependent const arrays to normalize array-of-const and const-array

2021-09-15 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2021-09-15T13:46:37-07:00
New Revision: 40acc0adad59ac39e9a7a02fcd93161298500c00

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

LOG: Improve type printing of size-dependent const arrays to normalize 
array-of-const and const-array

Follow-on from 2bd84938470bf2e337801faafb8a67710f46429d based on
postcommit feedback from Richard Smith.

The VariableArray case I couldn't figure out how to test/provoke - you
can't write/form a variable array in any context other than a local
variable that I know of, and in that case `const int x[n]` is the
normalized form already (array-of-const) and you can't use typedefs
(since you can't typedef int[n] with variable 'n') to force the
const-array AST that would produce the undesirable type printing "int
const [n]".

Added: 


Modified: 
clang/lib/AST/TypePrinter.cpp
clang/test/AST/ast-dump-array.cpp

Removed: 




diff  --git a/clang/lib/AST/TypePrinter.cpp b/clang/lib/AST/TypePrinter.cpp
index 251db97c7db08..749a3e25d28a4 100644
--- a/clang/lib/AST/TypePrinter.cpp
+++ b/clang/lib/AST/TypePrinter.cpp
@@ -242,13 +242,16 @@ bool TypePrinter::canPrefixQualifiers(const Type *T,
 T->isObjCQualifiedIdType() || T->isObjCQualifiedClassType();
   break;
 
+case Type::DependentSizedArray:
+  NeedARCStrongQualifier = true;
+  LLVM_FALLTHROUGH;
+
 case Type::ConstantArray:
 case Type::IncompleteArray:
   return canPrefixQualifiers(
   cast(UnderlyingType)->getElementType().getTypePtr(),
   NeedARCStrongQualifier);
 case Type::VariableArray:
-case Type::DependentSizedArray:
   NeedARCStrongQualifier = true;
   LLVM_FALLTHROUGH;
 

diff  --git a/clang/test/AST/ast-dump-array.cpp 
b/clang/test/AST/ast-dump-array.cpp
index fe7875ec95c90..2e94f7769e0bd 100644
--- a/clang/test/AST/ast-dump-array.cpp
+++ b/clang/test/AST/ast-dump-array.cpp
@@ -23,5 +23,6 @@ class array {
 
   using array_T_size = T[Size];
   // CHECK: `-DependentSizedArrayType 0x{{[^ ]*}} 'T [Size]' dependent   

+  using const_array_T_size = const T[Size];
+  // CHECK: `-DependentSizedArrayType 0x{{[^ ]*}} 'const T [Size]' dependent   

 };
-



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


[clang] 13e34f9 - Fixup some formatting from a recent commit

2021-09-14 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2021-09-14T00:41:19-07:00
New Revision: 13e34f9fc13fbe08af69b206eacac2e0008dd126

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

LOG: Fixup some formatting from a recent commit

Added: 


Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index e4dc3121a10f..8abdff010d25 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1376,8 +1376,8 @@ llvm::DIType *CGDebugInfo::CreateType(const FunctionType 
*Ty,
   }
 
   llvm::DITypeRefArray EltTypeArray = DBuilder.getOrCreateTypeArray(EltTys);
-  llvm::DIType *F = DBuilder.createSubroutineType(EltTypeArray, Flags,
-   getDwarfCC(Ty->getCallConv()));
+  llvm::DIType *F = DBuilder.createSubroutineType(
+  EltTypeArray, Flags, getDwarfCC(Ty->getCallConv()));
   return F;
 }
 



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


[clang] e4b9f5e - DebugInfo: Add support for template parameters with reference qualifiers

2021-09-14 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2021-09-14T00:39:47-07:00
New Revision: e4b9f5e851d1fe0ba93cbb11b2ed4558602c379e

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

LOG: DebugInfo: Add support for template parameters with reference qualifiers

Followon from the previous commit supporting cvr qualifiers.

Added: 


Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp
clang/test/CodeGenCXX/debug-info-template.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index b7a6cd4fdf84..e4dc3121a10f 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1338,6 +1338,15 @@ static unsigned getDwarfCC(CallingConv CC) {
   return 0;
 }
 
+static llvm::DINode::DIFlags getRefFlags(const FunctionProtoType *Func) {
+  llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero;
+  if (Func->getExtProtoInfo().RefQualifier == RQ_LValue)
+Flags |= llvm::DINode::FlagLValueReference;
+  if (Func->getExtProtoInfo().RefQualifier == RQ_RValue)
+Flags |= llvm::DINode::FlagRValueReference;
+  return Flags;
+}
+
 llvm::DIType *CGDebugInfo::CreateType(const FunctionType *Ty,
   llvm::DIFile *Unit) {
   const auto *FPT = dyn_cast(Ty);
@@ -1353,11 +1362,13 @@ llvm::DIType *CGDebugInfo::CreateType(const 
FunctionType *Ty,
   // Add the result type at least.
   EltTys.push_back(getOrCreateType(Ty->getReturnType(), Unit));
 
+  llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero;
   // Set up remainder of arguments if there is a prototype.
   // otherwise emit it as a variadic function.
   if (!FPT)
 EltTys.push_back(DBuilder.createUnspecifiedParameter());
   else {
+Flags = getRefFlags(FPT);
 for (const QualType  : FPT->param_types())
   EltTys.push_back(getOrCreateType(ParamType, Unit));
 if (FPT->isVariadic())
@@ -1365,7 +1376,7 @@ llvm::DIType *CGDebugInfo::CreateType(const FunctionType 
*Ty,
   }
 
   llvm::DITypeRefArray EltTypeArray = DBuilder.getOrCreateTypeArray(EltTys);
-  llvm::DIType *F = DBuilder.createSubroutineType(EltTypeArray, 
llvm::DINode::FlagZero,
+  llvm::DIType *F = DBuilder.createSubroutineType(EltTypeArray, Flags,
getDwarfCC(Ty->getCallConv()));
   return F;
 }
@@ -1640,15 +1651,17 @@ CGDebugInfo::getOrCreateInstanceMethodType(QualType 
ThisPtr,
   Qc.removeUnaligned();
   // Keep the removed qualifiers in sync with
   // CreateQualifiedType(const FunctionPrototype*, DIFile *Unit)
+  // on a 'real' member function type, these qualifiers are carried on the type
+  // of the first parameter, not as separate DW_TAG_const_type (etc) decorator
+  // tags around them. (but in the raw function types with qualifiers, they 
have
+  // to use wrapper types)
 
   // Add "this" pointer.
-  llvm::DITypeRefArray Args(
-  cast(
-  getOrCreateType(
-  CGM.getContext().getFunctionType(Func->getReturnType(),
-   Func->getParamTypes(), EPI),
-  Unit))
-  ->getTypeArray());
+  const auto *OriginalFunc = cast(
+  getOrCreateType(CGM.getContext().getFunctionType(
+  Func->getReturnType(), Func->getParamTypes(), EPI),
+  Unit));
+  llvm::DITypeRefArray Args = OriginalFunc->getTypeArray();
   assert(Args.size() && "Invalid number of arguments!");
 
   SmallVector Elts;
@@ -1690,13 +1703,7 @@ CGDebugInfo::getOrCreateInstanceMethodType(QualType 
ThisPtr,
 
   llvm::DITypeRefArray EltTypeArray = DBuilder.getOrCreateTypeArray(Elts);
 
-  llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero;
-  if (Func->getExtProtoInfo().RefQualifier == RQ_LValue)
-Flags |= llvm::DINode::FlagLValueReference;
-  if (Func->getExtProtoInfo().RefQualifier == RQ_RValue)
-Flags |= llvm::DINode::FlagRValueReference;
-
-  return DBuilder.createSubroutineType(EltTypeArray, Flags,
+  return DBuilder.createSubroutineType(EltTypeArray, OriginalFunc->getFlags(),
getDwarfCC(Func->getCallConv()));
 }
 

diff  --git a/clang/test/CodeGenCXX/debug-info-template.cpp 
b/clang/test/CodeGenCXX/debug-info-template.cpp
index 0abb669b6535..510c82a5074f 100644
--- a/clang/test/CodeGenCXX/debug-info-template.cpp
+++ b/clang/test/CodeGenCXX/debug-info-template.cpp
@@ -218,13 +218,13 @@ template void f1<>();
 
 namespace RawFuncQual {
 struct t1; // use this to ensure the type parameter doesn't shift due to other 
test cases in this file
-template
+template
 void f1() { }
-template void f1();
-// CHECK: !DISubprogram(name: "f1", 
+template void f1();
+// CHECK: !DISubprogram(name: "f1", 
 // CHECK-SAME: templateParams: ![[RAW_FUNC_QUAL_ARGS:[0-9]*]],
 
-// CHECK: ![[RAW_FUNC_QUAL_ARGS]] = 

[clang] db4ff98 - DebugInfo: Add support for template parameters with qualifiers

2021-09-14 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2021-09-14T00:04:40-07:00
New Revision: db4ff98bf9733605c713e75ab6677523e6d267cb

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

LOG: DebugInfo: Add support for template parameters with qualifiers

eg: t1 - DWARF doesn't have a particularly nice way to
encode this, for real member function types (like `void (t1::*)()
const`) the const-ness is encoded in the type of the artificial first
parameter. But `void () const` has no parameters, so encode it like a
normal const-qualified type, using DW_TAG_const_type. (similarly for
restrict and volatile)

Reference qualifiers (& and &&) coming in a separate commit shortly.

Added: 


Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/CGDebugInfo.h
clang/test/CodeGenCXX/debug-info-template.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 0b10343f29a61..b7a6cd4fdf845 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -915,29 +915,41 @@ llvm::DIType *CGDebugInfo::CreateType(const ComplexType 
*Ty) {
   return DBuilder.createBasicType("complex", Size, Encoding);
 }
 
+static void stripUnusedQualifiers(Qualifiers ) {
+  // Ignore these qualifiers for now.
+  Q.removeObjCGCAttr();
+  Q.removeAddressSpace();
+  Q.removeObjCLifetime();
+  Q.removeUnaligned();
+}
+
+static llvm::dwarf::Tag getNextQualifier(Qualifiers ) {
+  if (Q.hasConst()) {
+Q.removeConst();
+return llvm::dwarf::DW_TAG_const_type;
+  }
+  if (Q.hasVolatile()) {
+Q.removeVolatile();
+return llvm::dwarf::DW_TAG_volatile_type;
+  }
+  if (Q.hasRestrict()) {
+Q.removeRestrict();
+return llvm::dwarf::DW_TAG_restrict_type;
+  }
+  return (llvm::dwarf::Tag)0;
+}
+
 llvm::DIType *CGDebugInfo::CreateQualifiedType(QualType Ty,
llvm::DIFile *Unit) {
   QualifierCollector Qc;
   const Type *T = Qc.strip(Ty);
 
-  // Ignore these qualifiers for now.
-  Qc.removeObjCGCAttr();
-  Qc.removeAddressSpace();
-  Qc.removeObjCLifetime();
+  stripUnusedQualifiers(Qc);
 
   // We will create one Derived type for one qualifier and recurse to handle 
any
   // additional ones.
-  llvm::dwarf::Tag Tag;
-  if (Qc.hasConst()) {
-Tag = llvm::dwarf::DW_TAG_const_type;
-Qc.removeConst();
-  } else if (Qc.hasVolatile()) {
-Tag = llvm::dwarf::DW_TAG_volatile_type;
-Qc.removeVolatile();
-  } else if (Qc.hasRestrict()) {
-Tag = llvm::dwarf::DW_TAG_restrict_type;
-Qc.removeRestrict();
-  } else {
+  llvm::dwarf::Tag Tag = getNextQualifier(Qc);
+  if (!Tag) {
 assert(Qc.empty() && "Unknown type qualifier for debug info");
 return getOrCreateType(QualType(T, 0), Unit);
   }
@@ -949,6 +961,30 @@ llvm::DIType *CGDebugInfo::CreateQualifiedType(QualType Ty,
   return DBuilder.createQualifiedType(Tag, FromTy);
 }
 
+llvm::DIType *CGDebugInfo::CreateQualifiedType(const FunctionProtoType *F,
+   llvm::DIFile *Unit) {
+  FunctionProtoType::ExtProtoInfo EPI = F->getExtProtoInfo();
+  Qualifiers  = EPI.TypeQuals;
+  stripUnusedQualifiers(Q);
+
+  // We will create one Derived type for one qualifier and recurse to handle 
any
+  // additional ones.
+  llvm::dwarf::Tag Tag = getNextQualifier(Q);
+  if (!Tag) {
+assert(Q.empty() && "Unknown type qualifier for debug info");
+return nullptr;
+  }
+
+  auto *FromTy =
+  getOrCreateType(CGM.getContext().getFunctionType(F->getReturnType(),
+   F->getParamTypes(), 
EPI),
+  Unit);
+
+  // No need to fill in the Name, Line, Size, Alignment, Offset in case of
+  // CVR derived types.
+  return DBuilder.createQualifiedType(Tag, FromTy);
+}
+
 llvm::DIType *CGDebugInfo::CreateType(const ObjCObjectPointerType *Ty,
   llvm::DIFile *Unit) {
 
@@ -1304,6 +1340,14 @@ static unsigned getDwarfCC(CallingConv CC) {
 
 llvm::DIType *CGDebugInfo::CreateType(const FunctionType *Ty,
   llvm::DIFile *Unit) {
+  const auto *FPT = dyn_cast(Ty);
+  if (FPT) {
+if (llvm::DIType *QTy = CreateQualifiedType(FPT, Unit))
+  return QTy;
+  }
+
+  // Create the type without any qualifiers
+
   SmallVector EltTys;
 
   // Add the result type at least.
@@ -1311,9 +1355,9 @@ llvm::DIType *CGDebugInfo::CreateType(const FunctionType 
*Ty,
 
   // Set up remainder of arguments if there is a prototype.
   // otherwise emit it as a variadic function.
-  if (isa(Ty))
+  if (!FPT)
 EltTys.push_back(DBuilder.createUnspecifiedParameter());
-  else if (const auto *FPT = dyn_cast(Ty)) {
+  else {
 for (const QualType  : FPT->param_types())
   

[clang] 2bd8493 - Improve type printing of const arrays to normalize array-of-const and const-array

2021-09-13 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2021-09-13T19:17:05-07:00
New Revision: 2bd84938470bf2e337801faafb8a67710f46429d

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

LOG: Improve type printing of const arrays to normalize array-of-const and 
const-array

Since these map to the same effective type - render them the same/in the
more legible way (const x[n]).

Added: 


Modified: 
clang/lib/AST/TypePrinter.cpp
clang/test/ARCMT/cxx-checking.mm
clang/test/AST/ast-dump-APValue-arithmetic.cpp
clang/test/AST/ast-dump-APValue-array.cpp
clang/test/CXX/basic/basic.types/p10.cpp
clang/test/Sema/assign.c
clang/test/Sema/typedef-retain.c
clang/test/SemaCXX/reinterpret-cast.cpp
clang/test/SemaCXX/static-assert-cxx17.cpp

Removed: 




diff  --git a/clang/lib/AST/TypePrinter.cpp b/clang/lib/AST/TypePrinter.cpp
index aef1e4f3f4953..251db97c7db08 100644
--- a/clang/lib/AST/TypePrinter.cpp
+++ b/clang/lib/AST/TypePrinter.cpp
@@ -200,11 +200,12 @@ bool TypePrinter::canPrefixQualifiers(const Type *T,
   // type expands to a simple string.
   bool CanPrefixQualifiers = false;
   NeedARCStrongQualifier = false;
-  Type::TypeClass TC = T->getTypeClass();
+  const Type *UnderlyingType = T;
   if (const auto *AT = dyn_cast(T))
-TC = AT->desugar()->getTypeClass();
+UnderlyingType = AT->desugar().getTypePtr();
   if (const auto *Subst = dyn_cast(T))
-TC = Subst->getReplacementType()->getTypeClass();
+UnderlyingType = Subst->getReplacementType().getTypePtr();
+  Type::TypeClass TC = UnderlyingType->getTypeClass();
 
   switch (TC) {
 case Type::Auto:
@@ -243,6 +244,9 @@ bool TypePrinter::canPrefixQualifiers(const Type *T,
 
 case Type::ConstantArray:
 case Type::IncompleteArray:
+  return canPrefixQualifiers(
+  cast(UnderlyingType)->getElementType().getTypePtr(),
+  NeedARCStrongQualifier);
 case Type::VariableArray:
 case Type::DependentSizedArray:
   NeedARCStrongQualifier = true;

diff  --git a/clang/test/ARCMT/cxx-checking.mm 
b/clang/test/ARCMT/cxx-checking.mm
index 952f3cdcbb79c..d6441def09b40 100644
--- a/clang/test/ARCMT/cxx-checking.mm
+++ b/clang/test/ARCMT/cxx-checking.mm
@@ -80,7 +80,7 @@
 
 struct FlexibleArrayMember0 {
   int length;
-  id array[]; // expected-error{{flexible array member 'array' of type 'id 
__strong[]' with non-trivial destruction}}
+  id array[]; // expected-error{{flexible array member 'array' of type 
'__strong id []' with non-trivial destruction}}
 };
 
 struct FlexibleArrayMember1 {

diff  --git a/clang/test/AST/ast-dump-APValue-arithmetic.cpp 
b/clang/test/AST/ast-dump-APValue-arithmetic.cpp
index 835d8c8108346..e51c1cee04cfe 100644
--- a/clang/test/AST/ast-dump-APValue-arithmetic.cpp
+++ b/clang/test/AST/ast-dump-APValue-arithmetic.cpp
@@ -36,13 +36,13 @@ void Test() {
   // CHECK-NEXT:  |   |-value: ComplexFloat 3.141500e+00 + 4.20e+01i
 
   constexpr _Complex int ArrayOfComplexInt[10] = {ComplexInt, ComplexInt, 
ComplexInt, ComplexInt};
-  // CHECK:  | `-VarDecl {{.*}}  col:{{.*}} 
ArrayOfComplexInt '_Complex int const[10]' constexpr cinit
+  // CHECK:  | `-VarDecl {{.*}}  col:{{.*}} 
ArrayOfComplexInt 'const _Complex int [10]' constexpr cinit
   // CHECK-NEXT:  |   |-value: Array size=10
   // CHECK-NEXT:  |   | |-elements: ComplexInt 42 + 24i, ComplexInt 42 + 24i, 
ComplexInt 42 + 24i, ComplexInt 42 + 24i
   // CHECK-NEXT:  |   | `-filler: 6 x ComplexInt 0 + 0i
 
   constexpr _Complex float ArrayOfComplexFloat[10] = {ComplexFloat, 
ComplexFloat, ComplexInt, ComplexInt};
-  // CHECK:`-VarDecl {{.*}}  col:{{.*}} 
ArrayOfComplexFloat '_Complex float const[10]' constexpr cinit
+  // CHECK:`-VarDecl {{.*}}  col:{{.*}} 
ArrayOfComplexFloat 'const _Complex float [10]' constexpr cinit
   // CHECK-NEXT:  |-value: Array size=10
   // CHECK-NEXT:  | |-elements: ComplexFloat 3.141500e+00 + 4.20e+01i, 
ComplexFloat 3.141500e+00 + 4.20e+01i, ComplexFloat 4.20e+01 + 
2.40e+01i, ComplexFloat 4.20e+01 + 2.40e+01i
   // CHECK-NEXT:  | `-filler: 6 x ComplexFloat 0.00e+00 + 0.00e+00i

diff  --git a/clang/test/AST/ast-dump-APValue-array.cpp 
b/clang/test/AST/ast-dump-APValue-array.cpp
index f9b38ec332a5b..72e519208ac56 100644
--- a/clang/test/AST/ast-dump-APValue-array.cpp
+++ b/clang/test/AST/ast-dump-APValue-array.cpp
@@ -43,7 +43,7 @@ void Test() {
   constexpr float arr_f[3][5] = {
   {1, 2, 3, 4, 5},
   };
-  // CHECK:  | `-VarDecl {{.*}}  line:{{.*}} arr_f 
'float const[3][5]' constexpr cinit
+  // CHECK:  | `-VarDecl {{.*}}  line:{{.*}} arr_f 
'const float [3][5]' constexpr cinit
   // CHECK-NEXT:  |   |-value: Array size=3
   // CHECK-NEXT:  |   | |-element: Array size=5
   // CHECK-NEXT:  |   | | |-elements: Float 1.00e+00, 

Re: r307232 - [modules ts] Do not emit strong function definitions from the module interface unit in every user.

2021-09-05 Thread David Blaikie via cfe-commits
Hey Richard - was just going back over some of the modular codegen code
(due to a discussion on the EWG mailing list about file extensions that
ended up touching on the nature of how modules are built) - and I came
across this code & had the same question I see I wrote up here already but
got lost in the *-commits mail.

Wondering if you've got some thoughts on why this choice was implemented
for C++20 modules - not homing inline functions/variables, only the extern
linkage ones for correctness?

On Sun, Jul 16, 2017 at 8:26 PM David Blaikie  wrote:

> Looks good - does this support available_externally definitions of strong
> external linkage functions in the users of a module? (is that tested?)
> Should it?
>
> Also should we consider having two flags for modular codegen - one for
> correctness (external function definitions), one for linkage size
> optimization (inline functions). Given the current data on optimized builds
> with inline functions (that it hurts object size to emit
> weak+available_externally definitions rather than linkonce_odr because so
> many definitions are optimized away entirely, that the bytes for the weak
> definition are wasted/unnecessary) - or at least something to keep in
> mind/run numbers on in the future for more generic codebases than Google's
> protobuf-heavy (& only protobuf modularized) code.
>
> On Wed, Jul 5, 2017 at 5:30 PM Richard Smith via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: rsmith
>> Date: Wed Jul  5 17:30:00 2017
>> New Revision: 307232
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=307232=rev
>> Log:
>> [modules ts] Do not emit strong function definitions from the module
>> interface unit in every user.
>>
>> Added:
>> cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/
>> cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p4/
>> cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cpp
>> cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cppm
>> cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p4/user.cpp
>> Modified:
>> cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
>>
>> Modified: cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterDecl.cpp?rev=307232=307231=307232=diff
>>
>> ==
>> --- cfe/trunk/lib/Serialization/ASTWriterDecl.cpp (original)
>> +++ cfe/trunk/lib/Serialization/ASTWriterDecl.cpp Wed Jul  5 17:30:00 2017
>> @@ -2233,8 +2233,18 @@ void ASTRecordWriter::AddFunctionDefinit
>>Writer->ClearSwitchCaseIDs();
>>
>>assert(FD->doesThisDeclarationHaveABody());
>> -  bool ModulesCodegen = Writer->Context->getLangOpts().ModulesCodegen &&
>> -Writer->WritingModule &&
>> !FD->isDependentContext();
>> +  bool ModulesCodegen = false;
>> +  if (Writer->WritingModule && !FD->isDependentContext()) {
>> +// Under -fmodules-codegen, codegen is performed for all defined
>> functions.
>> +// When building a C++ Modules TS module interface unit, a strong
>> definition
>> +// in the module interface is provided by the compilation of that
>> module
>> +// interface unit, not by its users. (Inline functions are still
>> emitted
>> +// in module users.)
>> +ModulesCodegen =
>> +Writer->Context->getLangOpts().ModulesCodegen ||
>> +(Writer->WritingModule->Kind == Module::ModuleInterfaceUnit &&
>> + Writer->Context->GetGVALinkageForFunction(FD) ==
>> GVA_StrongExternal);
>> +  }
>>Record->push_back(ModulesCodegen);
>>if (ModulesCodegen)
>>  Writer->ModularCodegenDecls.push_back(Writer->GetDeclRef(FD));
>>
>> Added: cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cpp?rev=307232=auto
>>
>> ==
>> --- cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cpp
>> (added)
>> +++ cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cpp Wed
>> Jul  5 17:30:00 2017
>> @@ -0,0 +1,23 @@
>> +// RUN: %clang_cc1 -fmodules-ts %S/module.cppm -triple
>> %itanium_abi_triple -emit-module-interface -o %t
>> +// RUN: %clang_cc1 -fmodules-ts %s -triple %itanium_abi_triple
>> -fmodule-file=%t -emit-llvm -o - | FileCheck %s --implicit-check-not=unused
>> --implicit-check-not=global_module
>> +
>> +module Module;
>> +
>> +void use() {
>> +  // CHECK: define linkonce_odr {{.*}}@_Z20used_inline_exportedv
>> +  used_inline_exported();
>> +  // CHECK: declare {{.*}}@_Z18noninline_exportedv
>> +  noninline_exported();
>> +
>> +  // FIXME: This symbol should not be visible here.
>> +  // CHECK: define internal {{.*}}@_ZL26used_static_module_linkagev
>> +  used_static_module_linkage();
>> +
>> +  // FIXME: The module name should be mangled into the name of this
>> function.
>> +  // 

[clang-tools-extra] 5fb3f43 - Fully qualify template template parameters when printing

2021-09-02 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2021-09-02T15:04:34-07:00
New Revision: 5fb3f43778f85ebea48e880eef9493d188253890

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

LOG: Fully qualify template template parameters when printing

I discovered this quirk when working on some DWARF - AST printing prints
type template parameters fully qualified, but printed template template
parameters the way they were written syntactically, or wholely
unqualified - instead, we should print them consistently with the way we
print type template parameters: fully qualified.

The one place this got weird was for partial specializations like in
ast-print-temp-class.cpp - hence the need for checking for
TemplateNameDependenceScope::DependentInstantiation template template
parameters. (not 100% sure that's the right solution to that, though -
open to ideas)

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

Added: 


Modified: 
clang-tools-extra/clangd/DumpAST.cpp
clang/include/clang/AST/TemplateName.h
clang/lib/AST/NestedNameSpecifier.cpp
clang/lib/AST/TemplateBase.cpp
clang/lib/AST/TemplateName.cpp
clang/lib/CodeGen/CGDebugInfo.cpp
clang/test/CXX/drs/dr10xx.cpp
clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p9-0x.cpp
clang/test/Index/print-type.cpp
clang/test/Misc/diag-template.cpp
clang/test/SemaTemplate/temp_arg_template.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/DumpAST.cpp 
b/clang-tools-extra/clangd/DumpAST.cpp
index 36d61aca70fa6..22bad6f915142 100644
--- a/clang-tools-extra/clangd/DumpAST.cpp
+++ b/clang-tools-extra/clangd/DumpAST.cpp
@@ -295,7 +295,7 @@ class DumpVisitor : public RecursiveASTVisitor 
{
   }
   std::string getDetail(const TemplateName ) {
 return toString([&](raw_ostream ) {
-  TN.print(OS, Ctx.getPrintingPolicy(), /*SuppressNNS=*/true);
+  TN.print(OS, Ctx.getPrintingPolicy(), TemplateName::Qualified::None);
 });
   }
   std::string getDetail(const Attr *A) {

diff  --git a/clang/include/clang/AST/TemplateName.h 
b/clang/include/clang/AST/TemplateName.h
index 010b813dc5253..2befb5c1b45e0 100644
--- a/clang/include/clang/AST/TemplateName.h
+++ b/clang/include/clang/AST/TemplateName.h
@@ -309,16 +309,17 @@ class TemplateName {
   /// unexpanded parameter pack (for C++0x variadic templates).
   bool containsUnexpandedParameterPack() const;
 
+  enum class Qualified { None, AsWritten, Fully };
   /// Print the template name.
   ///
   /// \param OS the output stream to which the template name will be
   /// printed.
   ///
-  /// \param SuppressNNS if true, don't print the
-  /// nested-name-specifier that precedes the template name (if it has
-  /// one).
+  /// \param Qual print the (Qualified::None) simple name,
+  /// (Qualified::AsWritten) any written (possibly partial) qualifier, or
+  /// (Qualified::Fully) the fully qualified name.
   void print(raw_ostream , const PrintingPolicy ,
- bool SuppressNNS = false) const;
+ Qualified Qual = Qualified::AsWritten) const;
 
   /// Debugging aid that dumps the template name.
   void dump(raw_ostream ) const;

diff  --git a/clang/lib/AST/NestedNameSpecifier.cpp 
b/clang/lib/AST/NestedNameSpecifier.cpp
index 21afdd1570f4b..8f19d80cbdc58 100644
--- a/clang/lib/AST/NestedNameSpecifier.cpp
+++ b/clang/lib/AST/NestedNameSpecifier.cpp
@@ -311,7 +311,8 @@ void NestedNameSpecifier::print(raw_ostream , const 
PrintingPolicy ,
   = dyn_cast(T)) {
   // Print the template name without its corresponding
   // nested-name-specifier.
-  SpecType->getTemplateName().print(OS, InnerPolicy, true);
+  SpecType->getTemplateName().print(OS, InnerPolicy,
+TemplateName::Qualified::None);
 
   // Print the template argument list.
   printTemplateArgumentList(OS, SpecType->template_arguments(),

diff  --git a/clang/lib/AST/TemplateBase.cpp b/clang/lib/AST/TemplateBase.cpp
index f44230d1bd03d..619ce42f9dd1d 100644
--- a/clang/lib/AST/TemplateBase.cpp
+++ b/clang/lib/AST/TemplateBase.cpp
@@ -452,7 +452,7 @@ void TemplateArgument::print(const PrintingPolicy , 
raw_ostream ,
 break;
 
   case Template:
-getAsTemplate().print(Out, Policy);
+getAsTemplate().print(Out, Policy, TemplateName::Qualified::Fully);
 break;
 
   case TemplateExpansion:

diff  --git a/clang/lib/AST/TemplateName.cpp b/clang/lib/AST/TemplateName.cpp
index 22cfa9acbe1b2..c8bd74f0b5bb4 100644
--- a/clang/lib/AST/TemplateName.cpp
+++ b/clang/lib/AST/TemplateName.cpp
@@ -220,19 +220,28 @@ bool TemplateName::containsUnexpandedParameterPack() 
const {
   return getDependence() & TemplateNameDependence::UnexpandedPack;
 }
 
-void
-TemplateName::print(raw_ostream , const PrintingPolicy ,
-   

[clang] 4f3a92c - DebugInfo: Refactor/deduplicate various template argument list emission

2021-08-30 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2021-08-30T22:39:46-07:00
New Revision: 4f3a92ca0aff115ee17649610c46d8705e550a03

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

LOG: DebugInfo: Refactor/deduplicate various template argument list emission

Streamline template arguments across types, variables, and functions -
for convenient reuse in experiments related to template argument list
reconstitution (not including template argument lists in the "name" of
those entities, and leaving it to debug info consumers to rebuild the
full template name from the semantic descriptions of the argument lists)

But the change seems like a good refactoring/cleanup anyway.

I'd certainly be open to suggestions about how this might be more
streamlined - like is there no generic way to query template argument
lists across the 3 kinds of entities, rather than needing special case
code?

Added: 


Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/CGDebugInfo.h

Removed: 




diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index fcccd42c116da..0a20ce39135ac 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1888,23 +1888,25 @@ void CGDebugInfo::CollectCXXBasesAux(
 }
 
 llvm::DINodeArray
-CGDebugInfo::CollectTemplateParams(const TemplateParameterList *TPList,
-   ArrayRef TAList,
+CGDebugInfo::CollectTemplateParams(Optional OArgs,
llvm::DIFile *Unit) {
+  if (!OArgs)
+return llvm::DINodeArray();
+  TemplateArgs  = *OArgs;
   SmallVector TemplateParams;
-  for (unsigned i = 0, e = TAList.size(); i != e; ++i) {
-const TemplateArgument  = TAList[i];
+  for (unsigned i = 0, e = Args.Args.size(); i != e; ++i) {
+const TemplateArgument  = Args.Args[i];
 StringRef Name;
 bool defaultParameter = false;
-if (TPList)
-  Name = TPList->getParam(i)->getName();
+if (Args.TList)
+  Name = Args.TList->getParam(i)->getName();
 switch (TA.getKind()) {
 case TemplateArgument::Type: {
   llvm::DIType *TTy = getOrCreateType(TA.getAsType(), Unit);
 
-  if (TPList)
+  if (Args.TList)
 if (auto *templateType =
-dyn_cast_or_null(TPList->getParam(i)))
+
dyn_cast_or_null(Args.TList->getParam(i)))
   if (templateType->hasDefaultArgument())
 defaultParameter =
 templateType->getDefaultArgument() == TA.getAsType();
@@ -1915,9 +1917,9 @@ CGDebugInfo::CollectTemplateParams(const 
TemplateParameterList *TPList,
 } break;
 case TemplateArgument::Integral: {
   llvm::DIType *TTy = getOrCreateType(TA.getIntegralType(), Unit);
-  if (TPList && CGM.getCodeGenOpts().DwarfVersion >= 5)
-if (auto *templateType =
-dyn_cast_or_null(TPList->getParam(i)))
+  if (Args.TList && CGM.getCodeGenOpts().DwarfVersion >= 5)
+if (auto *templateType = dyn_cast_or_null(
+Args.TList->getParam(i)))
   if (templateType->hasDefaultArgument() &&
   !templateType->getDefaultArgument()->isValueDependent())
 defaultParameter = llvm::APSInt::isSameValue(
@@ -2002,7 +2004,7 @@ CGDebugInfo::CollectTemplateParams(const 
TemplateParameterList *TPList,
 case TemplateArgument::Pack:
   TemplateParams.push_back(DBuilder.createTemplateParameterPack(
   TheCU, Name, nullptr,
-  CollectTemplateParams(nullptr, TA.getPackAsArray(), Unit)));
+  CollectTemplateParams({{nullptr, TA.getPackAsArray()}}, Unit)));
   break;
 case TemplateArgument::Expression: {
   const Expr *E = TA.getAsExpr();
@@ -2025,43 +2027,58 @@ CGDebugInfo::CollectTemplateParams(const 
TemplateParameterList *TPList,
   return DBuilder.getOrCreateArray(TemplateParams);
 }
 
-llvm::DINodeArray
-CGDebugInfo::CollectFunctionTemplateParams(const FunctionDecl *FD,
-   llvm::DIFile *Unit) {
+Optional
+CGDebugInfo::GetTemplateArgs(const FunctionDecl *FD) const {
   if (FD->getTemplatedKind() ==
   FunctionDecl::TK_FunctionTemplateSpecialization) {
 const TemplateParameterList *TList = FD->getTemplateSpecializationInfo()
  ->getTemplate()
  ->getTemplateParameters();
-return CollectTemplateParams(
-TList, FD->getTemplateSpecializationArgs()->asArray(), Unit);
+return {{TList, FD->getTemplateSpecializationArgs()->asArray()}};
   }
-  return llvm::DINodeArray();
+  return None;
 }
-
-llvm::DINodeArray CGDebugInfo::CollectVarTemplateParams(const VarDecl *VL,
-llvm::DIFile *Unit) {
+Optional

[clang] 0e42ec1 - DebugInfo: Correct printing empty template parameter packs

2021-08-30 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2021-08-30T10:20:12-07:00
New Revision: 0e42ec1add336e7fbf6cc1f82f663cabe48bf55e

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

LOG: DebugInfo: Correct printing empty template parameter packs

Empty packs in the non-final position would result in an extra ", ".
Empty packs in the final position would result in missing the space
between trailing >>.

Added: 


Modified: 
clang/lib/AST/TypePrinter.cpp
clang/test/CodeGenCXX/debug-info-template.cpp

Removed: 




diff  --git a/clang/lib/AST/TypePrinter.cpp b/clang/lib/AST/TypePrinter.cpp
index b66e432b98e9a..aef1e4f3f4953 100644
--- a/clang/lib/AST/TypePrinter.cpp
+++ b/clang/lib/AST/TypePrinter.cpp
@@ -2052,20 +2052,21 @@ printTo(raw_ostream , ArrayRef Args, const 
PrintingPolicy ,
 
 // If the last character of our string is '>', add another space to
 // keep the two '>''s separate tokens.
-NeedSpace = Policy.SplitTemplateClosers && !ArgString.empty() &&
-ArgString.back() == '>';
-FirstArg = false;
+if (!ArgString.empty()) {
+  NeedSpace = Policy.SplitTemplateClosers && ArgString.back() == '>';
+  FirstArg = false;
+}
 
 // Use same template parameter for all elements of Pack
 if (!IsPack)
   ParmIndex++;
   }
 
-  if (NeedSpace)
-OS << ' ';
-
-  if (!IsPack)
+  if (!IsPack) {
+if (NeedSpace)
+  OS << ' ';
 OS << '>';
+  }
 }
 
 void clang::printTemplateArgumentList(raw_ostream ,

diff  --git a/clang/test/CodeGenCXX/debug-info-template.cpp 
b/clang/test/CodeGenCXX/debug-info-template.cpp
index 0255ec9df00fa..2ce0166590aa1 100644
--- a/clang/test/CodeGenCXX/debug-info-template.cpp
+++ b/clang/test/CodeGenCXX/debug-info-template.cpp
@@ -196,4 +196,22 @@ void f1() {
 }
 template void f1>();
 // CHECK: !DISubprogram(name: "f1 >",
+} // namespace IndirectDefaultArgument
+
+namespace EmptyTrailingPack {
+template
+struct t1 { };
+template
+void f1() {
+}
+template void f1>();
+// CHECK: !DISubprogram(name: "f1 >",
+} // namespace EmptyTrailingPack
+
+namespace EmptyInnerPack {
+template
+void f1() {
 }
+template void f1<>();
+// CHECK: !DISubprogram(name: "f1",
+} // namespace EmptyInnerPack



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


[clang] 32b2808 - TypePrinter:printTo remove redundant parameter (IsPack/SkipBrackets)

2021-08-27 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2021-08-27T17:12:42-07:00
New Revision: 32b280809f4755177feb8a82fc7a632efa3bf469

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

LOG: TypePrinter:printTo remove redundant parameter (IsPack/SkipBrackets)

Added: 


Modified: 
clang/lib/AST/TypePrinter.cpp

Removed: 




diff  --git a/clang/lib/AST/TypePrinter.cpp b/clang/lib/AST/TypePrinter.cpp
index 5de22f76f4584..b66e432b98e9a 100644
--- a/clang/lib/AST/TypePrinter.cpp
+++ b/clang/lib/AST/TypePrinter.cpp
@@ -1998,10 +1998,9 @@ static bool isSubstitutedDefaultArgument(ASTContext 
, TemplateArgument Arg,
 }
 
 template 
-static void printTo(raw_ostream , ArrayRef Args,
-const PrintingPolicy , bool SkipBrackets,
-const TemplateParameterList *TPL, bool IsPack,
-unsigned ParmIndex) {
+static void
+printTo(raw_ostream , ArrayRef Args, const PrintingPolicy ,
+const TemplateParameterList *TPL, bool IsPack, unsigned ParmIndex) {
   // Drop trailing template arguments that match default arguments.
   if (TPL && Policy.SuppressDefaultTemplateArgs &&
   !Policy.PrintCanonicalTypes && !Args.empty() && !IsPack &&
@@ -2018,7 +2017,7 @@ static void printTo(raw_ostream , ArrayRef Args,
   }
 
   const char *Comma = Policy.MSVCFormatting ? "," : ", ";
-  if (!SkipBrackets)
+  if (!IsPack)
 OS << '<';
 
   bool NeedSpace = false;
@@ -2031,7 +2030,7 @@ static void printTo(raw_ostream , ArrayRef Args,
 if (Argument.getKind() == TemplateArgument::Pack) {
   if (Argument.pack_size() && !FirstArg)
 OS << Comma;
-  printTo(ArgOS, Argument.getPackAsArray(), Policy, true, TPL,
+  printTo(ArgOS, Argument.getPackAsArray(), Policy, TPL,
   /*IsPack*/ true, ParmIndex);
 } else {
   if (!FirstArg)
@@ -2065,7 +2064,7 @@ static void printTo(raw_ostream , ArrayRef Args,
   if (NeedSpace)
 OS << ' ';
 
-  if (!SkipBrackets)
+  if (!IsPack)
 OS << '>';
 }
 
@@ -2080,14 +2079,14 @@ void clang::printTemplateArgumentList(raw_ostream ,
   ArrayRef Args,
   const PrintingPolicy ,
   const TemplateParameterList *TPL) {
-  printTo(OS, Args, Policy, false, TPL, /*isPack*/ false, /*parmIndex*/ 0);
+  printTo(OS, Args, Policy, TPL, /*isPack*/ false, /*parmIndex*/ 0);
 }
 
 void clang::printTemplateArgumentList(raw_ostream ,
   ArrayRef Args,
   const PrintingPolicy ,
   const TemplateParameterList *TPL) {
-  printTo(OS, Args, Policy, false, TPL, /*isPack*/ false, /*parmIndex*/ 0);
+  printTo(OS, Args, Policy, TPL, /*isPack*/ false, /*parmIndex*/ 0);
 }
 
 std::string Qualifiers::getAsString() const {



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


Re: [clang] c411c1b - Fix missing qualifier in template type diffing

2021-08-16 Thread David Blaikie via cfe-commits
Perhaps the test case could be stripped down a bit?

template 
class Array {};

template 
class S {};

template 
Array Make();

void Call() {
Array> v = Make>();
}

Seems to exhibit the same issue, by the looks of it.

On Mon, Aug 16, 2021 at 6:38 PM via cfe-commits 
wrote:

>
> Author: Weverything
> Date: 2021-08-16T18:34:18-07:00
> New Revision: c411c1bd7f7d3550d24333f80980c0be6481d34a
>
> URL:
> https://github.com/llvm/llvm-project/commit/c411c1bd7f7d3550d24333f80980c0be6481d34a
> DIFF:
> https://github.com/llvm/llvm-project/commit/c411c1bd7f7d3550d24333f80980c0be6481d34a.diff
>
> LOG: Fix missing qualifier in template type diffing
>
> Handle SubstTemplateTypeParmType so qualifiers do not get dropped from
> the diagnostic message.
>
> Added:
>
>
> Modified:
> clang/lib/AST/ASTDiagnostic.cpp
> clang/test/Misc/diag-template-diffing.cpp
>
> Removed:
>
>
>
>
> 
> diff  --git a/clang/lib/AST/ASTDiagnostic.cpp
> b/clang/lib/AST/ASTDiagnostic.cpp
> index dc22481d0a84c..7e435e8b35b80 100644
> --- a/clang/lib/AST/ASTDiagnostic.cpp
> +++ b/clang/lib/AST/ASTDiagnostic.cpp
> @@ -1088,6 +1088,9 @@ class TemplateDiff {
>  Ty->getAs())
>return TST;
>
> +if (const auto* SubstType = Ty->getAs())
> +  Ty = SubstType->getReplacementType();
> +
>  const RecordType *RT = Ty->getAs();
>
>  if (!RT)
>
> diff  --git a/clang/test/Misc/diag-template-
> diff ing.cpp b/clang/test/Misc/diag-template-
> diff ing.cpp
> index cc1cc9ca70679..6bf6e2de4277c 100644
> --- a/clang/test/Misc/diag-template-
> diff ing.cpp
> +++ b/clang/test/Misc/diag-template-
> diff ing.cpp
> @@ -1488,6 +1488,43 @@ void run(A_reg reg, A_ptr ptr,
> A_ref ref) {
>  }
>  }
>
> +namespace SubstTemplateTypeParmType {
> +template 
> +class Array {
> +};
> +
> +template 
> +class S{};
> +
> +template 
> +Array Make(T ()[num]);
> +
> +void Run(int, Array>) {}
> +
> +Array> Make();
> +void Call() {
> +  const S s1[5];
> +  S s2[5];
> +
> +  Run(0, Make(s1));   // Error
> +  Run(0, Make(s2));   // Okay
> +}
> +
> +// CHECK-ELIDE-NOTREE: no matching function for call to 'Run'
> +// CHECK-ELIDE-NOTREE: no known conversion from 'Array>' to
> 'Array>' for 2nd argument
> +// CHECK-NOELIDE-NOTREE: no matching function for call to 'Run'
> +// CHECK-NOELIDE-NOTREE: no known conversion from 'Array>'
> to 'Array>' for 2nd argument
> +// CHECK-ELIDE-TREE: no matching function for call to 'Run'
> +// CHECK-ELIDE-TREE: no known conversion from argument type to parameter
> type for 2nd argument
> +// CHECK-ELIDE-TREE:   Array<
> +// CHECK-ELIDE-TREE: [const != (no qualifiers)] S<...>>
> +// CHECK-NOELIDE-TREE: no matching function for call to 'Run'
> +// CHECK-NOELIDE-TREE: no known conversion from argument type to
> parameter type for 2nd argument
> +// CHECK-NOELIDE-TREE:   Array<
> +// CHECK-NOELIDE-TREE: [const != (no qualifiers)] S<
> +// CHECK-NOELIDE-TREE:   int>>
> +}
> +
>  // CHECK-ELIDE-NOTREE: {{[0-9]*}} errors generated.
>  // CHECK-NOELIDE-NOTREE: {{[0-9]*}} errors generated.
>  // CHECK-ELIDE-TREE: {{[0-9]*}} errors generated.
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [clang] 80ed75e - Revert "[NFC] Fix typos"

2021-08-16 Thread David Blaikie via cfe-commits
Ah, thanks for the details!

On Mon, Aug 16, 2021 at 1:26 PM Kostya Kortchinsky 
wrote:

> Apologies.
> As explained in another thread, this was a mistake of mine as I reverted 2
> CLs instead of 1 (mine).
> This was resolved with the original author.
> My own CL ended up breaking some 32-bit builders.
>
> On Mon, Aug 16, 2021 at 1:22 PM David Blaikie  wrote:
>
>> Please include in the commit message a reason for a revert.
>>
>> On Mon, Aug 16, 2021 at 11:14 AM Kostya Kortchinsky via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>>
>>> Author: Kostya Kortchinsky
>>> Date: 2021-08-16T11:13:05-07:00
>>> New Revision: 80ed75e7fb45f9f5fc84ca7cbe258be036015384
>>>
>>> URL:
>>> https://github.com/llvm/llvm-project/commit/80ed75e7fb45f9f5fc84ca7cbe258be036015384
>>> DIFF:
>>> https://github.com/llvm/llvm-project/commit/80ed75e7fb45f9f5fc84ca7cbe258be036015384.diff
>>>
>>> LOG: Revert "[NFC] Fix typos"
>>>
>>> This reverts commit b7425e956be60a73004d7ae5bb37da85872c29fb.
>>>
>>> Added:
>>>
>>>
>>> Modified:
>>> clang/lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp
>>> clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
>>> compiler-rt/test/profile/Linux/instrprof-cs.c
>>> llvm/include/llvm/Transforms/Instrumentation.h
>>> llvm/lib/ProfileData/SampleProfReader.cpp
>>>
>>> Removed:
>>>
>>>
>>>
>>>
>>> 
>>> diff  --git
>>> a/clang/lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp
>>> b/clang/lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp
>>> index a13de306eac84..175dfcef0df45 100644
>>> --- a/clang/lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp
>>> +++ b/clang/lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp
>>> @@ -6,7 +6,7 @@
>>>  //
>>>
>>>  
>>> //===--===//
>>>  //
>>> -//  This file defines a CheckObjCInstMethSignature, a flow-insensitive
>>> check
>>> +//  This file defines a CheckObjCInstMethSignature, a flow-insenstive
>>> check
>>>  //  that determines if an Objective-C class interface incorrectly
>>> redefines
>>>  //  the method signature in a subclass.
>>>  //
>>>
>>> diff  --git a/clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
>>> b/clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
>>> index dcca8be55e337..90c5583d89691 100644
>>> --- a/clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
>>> +++ b/clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
>>> @@ -6,7 +6,7 @@
>>>  //
>>>
>>>  
>>> //===--===//
>>>  //
>>> -//  This file defines a CheckNSError, a flow-insensitive check
>>> +//  This file defines a CheckNSError, a flow-insenstive check
>>>  //  that determines if an Objective-C class interface correctly returns
>>>  //  a non-void return type.
>>>  //
>>>
>>> diff  --git a/compiler-rt/test/profile/Linux/instrprof-cs.c
>>> b/compiler-rt/test/profile/Linux/instrprof-cs.c
>>> index 0ad6f0350c560..d825525a532db 100644
>>> --- a/compiler-rt/test/profile/Linux/instrprof-cs.c
>>> +++ b/compiler-rt/test/profile/Linux/instrprof-cs.c
>>> @@ -8,7 +8,7 @@
>>>  // RUN: %clang_profgen=%t.profraw -o %t.gen.cis -O2 %s
>>>  // RUN: %run %t.gen.cis
>>>  // RUN: llvm-profdata merge -o %t.cis.profdata %t.profraw
>>> -// Check context insensitive profile
>>> +// Check context insenstive profile
>>>  // RUN: %clang_profuse=%t.cis.profdata  -O2 -emit-llvm -S %s -o - |
>>> FileCheck %s --check-prefix=CIS
>>>  int g1 = 1;
>>>  int volatile g2 = 2;
>>>
>>> diff  --git a/llvm/include/llvm/Transforms/Instrumentation.h
>>> b/llvm/include/llvm/Transforms/Instrumentation.h
>>> index 0c822999aecf3..03108bacb0da5 100644
>>> --- a/llvm/include/llvm/Transforms/Instrumentation.h
>>> +++ b/llvm/include/llvm/Transforms/Instrumentation.h
>>> @@ -78,7 +78,7 @@ struct GCOVOptions {
>>>  ModulePass *createGCOVProfilerPass(const GCOVOptions  =
>>> GCOVOptions::getDefault());
>>>
>>> -// PGO Instrumention. Parameter IsCS indicates if this is the context
>>> sensitive
>>> +// PGO Instrumention. Parameter IsCS indicates if this is the context
>>> senstive
>>>  // instrumentation.
>>>  ModulePass *createPGOInstrumentationGenLegacyPass(bool IsCS = false);
>>>  ModulePass *
>>> @@ -138,7 +138,7 @@ struct InstrProfOptions {
>>>  };
>>>
>>>  /// Insert frontend instrumentation based profiling. Parameter IsCS
>>> indicates if
>>> -// this is the context sensitive instrumentation.
>>> +// this is the context senstive instrumentation.
>>>  ModulePass *createInstrProfilingLegacyPass(
>>>  const InstrProfOptions  = InstrProfOptions(), bool IsCS =
>>> false);
>>>
>>>
>>> diff  --git a/llvm/lib/ProfileData/SampleProfReader.cpp
>>> b/llvm/lib/ProfileData/SampleProfReader.cpp
>>> index a801ca1ef36d7..6058eddb13dc7 100644
>>> --- a/llvm/lib/ProfileData/SampleProfReader.cpp
>>> +++ 

Re: [clang] 80ed75e - Revert "[NFC] Fix typos"

2021-08-16 Thread David Blaikie via cfe-commits
Please include in the commit message a reason for a revert.

On Mon, Aug 16, 2021 at 11:14 AM Kostya Kortchinsky via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

>
> Author: Kostya Kortchinsky
> Date: 2021-08-16T11:13:05-07:00
> New Revision: 80ed75e7fb45f9f5fc84ca7cbe258be036015384
>
> URL:
> https://github.com/llvm/llvm-project/commit/80ed75e7fb45f9f5fc84ca7cbe258be036015384
> DIFF:
> https://github.com/llvm/llvm-project/commit/80ed75e7fb45f9f5fc84ca7cbe258be036015384.diff
>
> LOG: Revert "[NFC] Fix typos"
>
> This reverts commit b7425e956be60a73004d7ae5bb37da85872c29fb.
>
> Added:
>
>
> Modified:
> clang/lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp
> clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
> compiler-rt/test/profile/Linux/instrprof-cs.c
> llvm/include/llvm/Transforms/Instrumentation.h
> llvm/lib/ProfileData/SampleProfReader.cpp
>
> Removed:
>
>
>
>
> 
> diff  --git
> a/clang/lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp
> b/clang/lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp
> index a13de306eac84..175dfcef0df45 100644
> --- a/clang/lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp
> +++ b/clang/lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp
> @@ -6,7 +6,7 @@
>  //
>
>  
> //===--===//
>  //
> -//  This file defines a CheckObjCInstMethSignature, a flow-insensitive
> check
> +//  This file defines a CheckObjCInstMethSignature, a flow-insenstive
> check
>  //  that determines if an Objective-C class interface incorrectly
> redefines
>  //  the method signature in a subclass.
>  //
>
> diff  --git a/clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
> b/clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
> index dcca8be55e337..90c5583d89691 100644
> --- a/clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
> +++ b/clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
> @@ -6,7 +6,7 @@
>  //
>
>  
> //===--===//
>  //
> -//  This file defines a CheckNSError, a flow-insensitive check
> +//  This file defines a CheckNSError, a flow-insenstive check
>  //  that determines if an Objective-C class interface correctly returns
>  //  a non-void return type.
>  //
>
> diff  --git a/compiler-rt/test/profile/Linux/instrprof-cs.c
> b/compiler-rt/test/profile/Linux/instrprof-cs.c
> index 0ad6f0350c560..d825525a532db 100644
> --- a/compiler-rt/test/profile/Linux/instrprof-cs.c
> +++ b/compiler-rt/test/profile/Linux/instrprof-cs.c
> @@ -8,7 +8,7 @@
>  // RUN: %clang_profgen=%t.profraw -o %t.gen.cis -O2 %s
>  // RUN: %run %t.gen.cis
>  // RUN: llvm-profdata merge -o %t.cis.profdata %t.profraw
> -// Check context insensitive profile
> +// Check context insenstive profile
>  // RUN: %clang_profuse=%t.cis.profdata  -O2 -emit-llvm -S %s -o - |
> FileCheck %s --check-prefix=CIS
>  int g1 = 1;
>  int volatile g2 = 2;
>
> diff  --git a/llvm/include/llvm/Transforms/Instrumentation.h
> b/llvm/include/llvm/Transforms/Instrumentation.h
> index 0c822999aecf3..03108bacb0da5 100644
> --- a/llvm/include/llvm/Transforms/Instrumentation.h
> +++ b/llvm/include/llvm/Transforms/Instrumentation.h
> @@ -78,7 +78,7 @@ struct GCOVOptions {
>  ModulePass *createGCOVProfilerPass(const GCOVOptions  =
> GCOVOptions::getDefault());
>
> -// PGO Instrumention. Parameter IsCS indicates if this is the context
> sensitive
> +// PGO Instrumention. Parameter IsCS indicates if this is the context
> senstive
>  // instrumentation.
>  ModulePass *createPGOInstrumentationGenLegacyPass(bool IsCS = false);
>  ModulePass *
> @@ -138,7 +138,7 @@ struct InstrProfOptions {
>  };
>
>  /// Insert frontend instrumentation based profiling. Parameter IsCS
> indicates if
> -// this is the context sensitive instrumentation.
> +// this is the context senstive instrumentation.
>  ModulePass *createInstrProfilingLegacyPass(
>  const InstrProfOptions  = InstrProfOptions(), bool IsCS =
> false);
>
>
> diff  --git a/llvm/lib/ProfileData/SampleProfReader.cpp
> b/llvm/lib/ProfileData/SampleProfReader.cpp
> index a801ca1ef36d7..6058eddb13dc7 100644
> --- a/llvm/lib/ProfileData/SampleProfReader.cpp
> +++ b/llvm/lib/ProfileData/SampleProfReader.cpp
> @@ -53,7 +53,7 @@ using namespace sampleprof;
>  // For ext-binary format profiles, the flag is set in the summary.
>  static cl::opt ProfileIsFSDisciminator(
>  "profile-isfs", cl::Hidden, cl::init(false),
> -cl::desc("Profile uses flow sensitive discriminators"));
> +cl::desc("Profile uses flow senstive discriminators"));
>
>  /// Dump the function profile for \p FName.
>  ///
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>

[clang] 8322593 - PR51158: Don't emit -Wswitch or -Wcovered-switch-default for empty enums

2021-07-22 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2021-07-22T14:51:56-07:00
New Revision: 83225936af317e6bdd7103a8a039c51a29ce9f57

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

LOG: PR51158: Don't emit -Wswitch or -Wcovered-switch-default for empty enums

An empty enum is used to implement C++'s new-ish "byte" type (to make
sure it's a separate type for overloading, etc - compared to a typedef)
- without any enumerators. Some clang warnings don't make sense in this
sort of situation, so let's skip them for empty enums.

It's arguable that possibly some situations of enumerations without
enumerators might want the previous-to-this-patch behavior (if the enum
is autogenerated and in some cases comes up empty, then maybe a default
in an empty switch would still be considered problematic - so that when
you add the first enumeration you do get a -Wswitch warning). But I
think that's niche enough & this std::byte case is mainstream enough
that we should prioritize the latter over the former.

If someone's got a middle ground proposal to account for both of those
situations, I'm open to patches/suggestions/etc.

Added: 


Modified: 
clang/lib/Sema/SemaStmt.cpp
clang/test/SemaCXX/switch.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index 2ae27de9b207..64c53df0 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -1461,7 +1461,8 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, 
Stmt *Switch,
 
 // If switch has default case, then ignore it.
 if (!CaseListIsErroneous && !CaseListIsIncomplete && !HasConstantCond &&
-ET && ET->getDecl()->isCompleteDefinition()) {
+ET && ET->getDecl()->isCompleteDefinition() &&
+!empty(ET->getDecl()->enumerators())) {
   const EnumDecl *ED = ET->getDecl();
   EnumValsTy EnumVals;
 

diff  --git a/clang/test/SemaCXX/switch.cpp b/clang/test/SemaCXX/switch.cpp
index 0c60ce02097b..380f4d559ef8 100644
--- a/clang/test/SemaCXX/switch.cpp
+++ b/clang/test/SemaCXX/switch.cpp
@@ -130,3 +130,19 @@ void test(Opaque o, OpaqueClass oc, Defined d) {
 }
 
 }
+
+namespace EmptyEnum {
+
+enum Empty : int {};
+void test(Empty e) {
+  switch (e) {
+  case (Empty)0:
+break;
+  }
+  switch (e) {
+  default:
+break;
+  }
+}
+
+} // namespace EmptyEnum



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


<    1   2   3   4   5   6   7   8   9   10   >