Re: r255281 - Do not generate DW_TAG_imported_module for anonymous namespaces (even nested) for all the platforms except PS4.

2016-01-15 Thread David Blaikie via cfe-commits
On Mon, Dec 21, 2015 at 2:35 AM, Romanova, Katya <
katya_roman...@playstation.sony.com> wrote:

> Hi David,
>
>
>
> Thank you so much for the review.
>
> I copied and pasted the diff file. Let me know if it’s OK to commit.
>
>
>
>
>
> >> Could/should this ^ just be: Opts.DebugExplicitImport =
> Triple.isPS4CPU(); ?
>
> Done.
>
>
>
> >> Extra semicolon here ^
>
> Done.
>

Thanks! Feel free to commit those changes. (you're welcome to commit
changes like that without review, btw)


>
>
> >> And is there any reason not to just use nullptr here and elsewhere?
> Anything with the substring "PtrTy" in the name seems like it should be
> pointer-like and be convertible from nullptr_t, no? (what is
> DeclGroupPtrTy?)
>
> No, it's not convertible from nullptr_t.
>
>
>
> /home/llvm/tools/clang/lib/Parse/ParseDeclCXX.cpp:68:12: error: could not
> cnvert ‘nullptr’ from ‘std::nullptr_t’ to ‘clang::Parser::DeclGroupPtrTy
> {aka clang::OpaquePtr}’
>
>  return nullptr;
>

Ah - well, I fixed that and updated every instance of the old code to use
nullptr instead.


>
>
>
>
>
>
> Index: lib/Frontend/CompilerInvocation.cpp
>
> ===
>
> --- lib/Frontend/CompilerInvocation.cpp (revision 256140)
>
> +++ lib/Frontend/CompilerInvocation.cpp (working copy)
>
> @@ -1,4 +1,4 @@
>
> -//===--- CompilerInvocation.cpp
> ---===//
>
> +//===---
>
> //
>
> // The LLVM Compiler Infrastructure
>
> //
>
> @@ -417,8 +417,7 @@
>
>Opts.EmitCodeView = Args.hasArg(OPT_gcodeview);
>
>Opts.SplitDwarfFile = Args.getLastArgValue(OPT_split_dwarf_file);
>
>Opts.DebugTypeExtRefs = Args.hasArg(OPT_dwarf_ext_refs);
>
> -  if (Triple.isPS4CPU())
>
> -Opts.DebugExplicitImport = true;
>
> +  Opts.DebugExplicitImport = Triple.isPS4CPU();
>
>
>
>for (const auto  : Args.getAllArgValues(OPT_fdebug_prefix_map_EQ))
>
>  Opts.DebugPrefixMap.insert(StringRef(Arg).split('='));
>
> Index: lib/Parse/ParseDeclCXX.cpp
>
> ===
>
> --- lib/Parse/ParseDeclCXX.cpp  (revision 256140)
>
> +++ lib/Parse/ParseDeclCXX.cpp  (working copy)
>
> @@ -65,7 +65,7 @@
>
>if (Tok.is(tok::code_completion)) {
>
>  Actions.CodeCompleteNamespaceDecl(getCurScope());
>
>  cutOffParsing();
>
> -return DeclGroupPtrTy();;
>
> +return DeclGroupPtrTy();
>
>}
>
>
>
>SourceLocation IdentLoc;
>
>
>
>
>
> Thank you!
>
> Katya.
>
>
>
>
>
>
>
> *From:* David Blaikie [mailto:dblai...@gmail.com]
> *Sent:* Sunday, December 13, 2015 3:46 PM
> *To:* Romanova, Katya
> *Cc:* cfe-commits
> *Subject:* Re: r255281 - Do not generate DW_TAG_imported_module for
> anonymous namespaces (even nested) for all the platforms except PS4.
>
>
>
>
>
>
>
> On Thu, Dec 10, 2015 at 10:52 AM, Ekaterina Romanova via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> Author: kromanova
> Date: Thu Dec 10 12:52:50 2015
> New Revision: 255281
>
> URL: http://llvm.org/viewvc/llvm-project?rev=255281=rev
> Log:
> Do not generate DW_TAG_imported_module for anonymous namespaces (even
> nested) for all the platforms except PS4.
> For PS4, generate explicit import for anonymous namespaces and mark it by
> DW_AT_artificial attribute.
>
> Differential Revision: http://reviews.llvm.org/D12624
>
>
> Added:
> cfe/trunk/test/CodeGenCXX/debug-info-anon-namespace.cpp
> Modified:
> cfe/trunk/include/clang/Frontend/CodeGenOptions.def
> cfe/trunk/include/clang/Parse/Parser.h
> cfe/trunk/include/clang/Sema/Sema.h
> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> cfe/trunk/lib/Frontend/CompilerInvocation.cpp
> cfe/trunk/lib/Parse/ParseDecl.cpp
> cfe/trunk/lib/Parse/ParseDeclCXX.cpp
> cfe/trunk/lib/Sema/SemaDeclCXX.cpp
>
> Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=255281=255280=255281=diff
>
> ==
> --- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
> +++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Thu Dec 10
> 12:52:50 2015
> @@ -166,6 +166,10 @@ CODEGENOPT(DebugColumnInfo, 1, 0) ///< W
>  CODEGENOPT(DebugTypeExtRefs, 1, 0) ///< Whether or not debug info should
> contain
> ///< external references to a PCH or
> module.
>
> +CODEGENOPT(DebugExplicitImport, 1, 0)  ///< Whether or not debug info
> should
> +   ///< contain explicit imports for
> +   ///< anonymous namespaces
> +
>  CODEGENOPT(EmitLLVMUseLists, 1, 0) ///< Control whether to serialize
> use-lists.
>
>  /// The user specified number of registers to be used for integral
> arguments,
>
> Modified: cfe/trunk/include/clang/Parse/Parser.h
> URL:
> 

RE: r255281 - Do not generate DW_TAG_imported_module for anonymous namespaces (even nested) for all the platforms except PS4.

2015-12-21 Thread Romanova, Katya via cfe-commits
Hi David,

Thank you so much for the review.
I copied and pasted the diff file. Let me know if it’s OK to commit.


>> Could/should this ^ just be: Opts.DebugExplicitImport = Triple.isPS4CPU(); ?
Done.

>> Extra semicolon here ^
Done.

>> And is there any reason not to just use nullptr here and elsewhere? Anything 
>> with the substring "PtrTy" in the name seems like it should be pointer-like 
>> and be convertible from nullptr_t, no? (what is DeclGroupPtrTy?)
No, it's not convertible from nullptr_t.

/home/llvm/tools/clang/lib/Parse/ParseDeclCXX.cpp:68:12: error: could not 
cnvert ‘nullptr’ from ‘std::nullptr_t’ to ‘clang::Parser::DeclGroupPtrTy {aka 
clang::OpaquePtr}’
 return nullptr;



Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp (revision 256140)
+++ lib/Frontend/CompilerInvocation.cpp (working copy)
@@ -1,4 +1,4 @@
-//===--- CompilerInvocation.cpp 
---===//
+//===---
//
// The LLVM Compiler Infrastructure
//
@@ -417,8 +417,7 @@
   Opts.EmitCodeView = Args.hasArg(OPT_gcodeview);
   Opts.SplitDwarfFile = Args.getLastArgValue(OPT_split_dwarf_file);
   Opts.DebugTypeExtRefs = Args.hasArg(OPT_dwarf_ext_refs);
-  if (Triple.isPS4CPU())
-Opts.DebugExplicitImport = true;
+  Opts.DebugExplicitImport = Triple.isPS4CPU();

   for (const auto  : Args.getAllArgValues(OPT_fdebug_prefix_map_EQ))
 Opts.DebugPrefixMap.insert(StringRef(Arg).split('='));
Index: lib/Parse/ParseDeclCXX.cpp
===
--- lib/Parse/ParseDeclCXX.cpp  (revision 256140)
+++ lib/Parse/ParseDeclCXX.cpp  (working copy)
@@ -65,7 +65,7 @@
   if (Tok.is(tok::code_completion)) {
 Actions.CodeCompleteNamespaceDecl(getCurScope());
 cutOffParsing();
-return DeclGroupPtrTy();;
+return DeclGroupPtrTy();
   }

   SourceLocation IdentLoc;


Thank you!
Katya.



From: David Blaikie [mailto:dblai...@gmail.com]
Sent: Sunday, December 13, 2015 3:46 PM
To: Romanova, Katya
Cc: cfe-commits
Subject: Re: r255281 - Do not generate DW_TAG_imported_module for anonymous 
namespaces (even nested) for all the platforms except PS4.



On Thu, Dec 10, 2015 at 10:52 AM, Ekaterina Romanova via cfe-commits 
> wrote:
Author: kromanova
Date: Thu Dec 10 12:52:50 2015
New Revision: 255281

URL: http://llvm.org/viewvc/llvm-project?rev=255281=rev
Log:
Do not generate DW_TAG_imported_module for anonymous namespaces (even nested) 
for all the platforms except PS4.
For PS4, generate explicit import for anonymous namespaces and mark it by 
DW_AT_artificial attribute.

Differential Revision: http://reviews.llvm.org/D12624


Added:
cfe/trunk/test/CodeGenCXX/debug-info-anon-namespace.cpp
Modified:
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=255281=255280=255281=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Thu Dec 10 12:52:50 2015
@@ -166,6 +166,10 @@ CODEGENOPT(DebugColumnInfo, 1, 0) ///< W
 CODEGENOPT(DebugTypeExtRefs, 1, 0) ///< Whether or not debug info should 
contain
///< external references to a PCH or module.

+CODEGENOPT(DebugExplicitImport, 1, 0)  ///< Whether or not debug info should
+   ///< contain explicit imports for
+   ///< anonymous namespaces
+
 CODEGENOPT(EmitLLVMUseLists, 1, 0) ///< Control whether to serialize use-lists.

 /// The user specified number of registers to be used for integral arguments,

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=255281=255280=255281=diff
==
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Thu Dec 10 12:52:50 2015
@@ -2337,8 +2337,8 @@ private:

   void DiagnoseUnexpectedNamespace(NamedDecl *Context);

-  Decl *ParseNamespace(unsigned Context, SourceLocation ,
-   SourceLocation InlineLoc = SourceLocation());
+  DeclGroupPtrTy ParseNamespace(unsigned Context, SourceLocation ,
+SourceLocation InlineLoc = SourceLocation());
   void 

Re: r255281 - Do not generate DW_TAG_imported_module for anonymous namespaces (even nested) for all the platforms except PS4.

2015-12-13 Thread David Blaikie via cfe-commits
On Thu, Dec 10, 2015 at 10:52 AM, Ekaterina Romanova via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: kromanova
> Date: Thu Dec 10 12:52:50 2015
> New Revision: 255281
>
> URL: http://llvm.org/viewvc/llvm-project?rev=255281=rev
> Log:
> Do not generate DW_TAG_imported_module for anonymous namespaces (even
> nested) for all the platforms except PS4.
> For PS4, generate explicit import for anonymous namespaces and mark it by
> DW_AT_artificial attribute.
>
> Differential Revision: http://reviews.llvm.org/D12624
>
>
> Added:
> cfe/trunk/test/CodeGenCXX/debug-info-anon-namespace.cpp
> Modified:
> cfe/trunk/include/clang/Frontend/CodeGenOptions.def
> cfe/trunk/include/clang/Parse/Parser.h
> cfe/trunk/include/clang/Sema/Sema.h
> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> cfe/trunk/lib/Frontend/CompilerInvocation.cpp
> cfe/trunk/lib/Parse/ParseDecl.cpp
> cfe/trunk/lib/Parse/ParseDeclCXX.cpp
> cfe/trunk/lib/Sema/SemaDeclCXX.cpp
>
> Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=255281=255280=255281=diff
>
> ==
> --- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
> +++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Thu Dec 10
> 12:52:50 2015
> @@ -166,6 +166,10 @@ CODEGENOPT(DebugColumnInfo, 1, 0) ///< W
>  CODEGENOPT(DebugTypeExtRefs, 1, 0) ///< Whether or not debug info should
> contain
> ///< external references to a PCH or
> module.
>
> +CODEGENOPT(DebugExplicitImport, 1, 0)  ///< Whether or not debug info
> should
> +   ///< contain explicit imports for
> +   ///< anonymous namespaces
> +
>  CODEGENOPT(EmitLLVMUseLists, 1, 0) ///< Control whether to serialize
> use-lists.
>
>  /// The user specified number of registers to be used for integral
> arguments,
>
> Modified: cfe/trunk/include/clang/Parse/Parser.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=255281=255280=255281=diff
>
> ==
> --- cfe/trunk/include/clang/Parse/Parser.h (original)
> +++ cfe/trunk/include/clang/Parse/Parser.h Thu Dec 10 12:52:50 2015
> @@ -2337,8 +2337,8 @@ private:
>
>void DiagnoseUnexpectedNamespace(NamedDecl *Context);
>
> -  Decl *ParseNamespace(unsigned Context, SourceLocation ,
> -   SourceLocation InlineLoc = SourceLocation());
> +  DeclGroupPtrTy ParseNamespace(unsigned Context, SourceLocation ,
> +SourceLocation InlineLoc =
> SourceLocation());
>void ParseInnerNamespace(std::vector& IdentLoc,
> std::vector& Ident,
> std::vector& NamespaceLoc,
>
> Modified: cfe/trunk/include/clang/Sema/Sema.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=255281=255280=255281=diff
>
> ==
> --- cfe/trunk/include/clang/Sema/Sema.h (original)
> +++ cfe/trunk/include/clang/Sema/Sema.h Thu Dec 10 12:52:50 2015
> @@ -4093,7 +4093,8 @@ public:
> SourceLocation IdentLoc,
> IdentifierInfo *Ident,
> SourceLocation LBrace,
> -   AttributeList *AttrList);
> +   AttributeList *AttrList,
> +   UsingDirectiveDecl * );
>void ActOnFinishNamespaceDef(Decl *Dcl, SourceLocation RBrace);
>
>NamespaceDecl *getStdNamespace() const;
>
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=255281=255280=255281=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Dec 10 12:52:50 2015
> @@ -3408,10 +3408,14 @@ llvm::DIScope *CGDebugInfo::getCurrentCo
>  void CGDebugInfo::EmitUsingDirective(const UsingDirectiveDecl ) {
>if (CGM.getCodeGenOpts().getDebugInfo() <
> CodeGenOptions::LimitedDebugInfo)
>  return;
> -  DBuilder.createImportedModule(
> -  getCurrentContextDescriptor(cast(UD.getDeclContext())),
> -  getOrCreateNameSpace(UD.getNominatedNamespace()),
> -  getLineNumber(UD.getLocation()));
> +  const NamespaceDecl *NSDecl = UD.getNominatedNamespace();
> +  if (!NSDecl->isAnonymousNamespace() ||
> +  CGM.getCodeGenOpts().DebugExplicitImport) {
> +DBuilder.createImportedModule(
> +getCurrentContextDescriptor(cast(UD.getDeclContext())),
> +getOrCreateNameSpace(NSDecl),
> +

r255281 - Do not generate DW_TAG_imported_module for anonymous namespaces (even nested) for all the platforms except PS4.

2015-12-10 Thread Ekaterina Romanova via cfe-commits
Author: kromanova
Date: Thu Dec 10 12:52:50 2015
New Revision: 255281

URL: http://llvm.org/viewvc/llvm-project?rev=255281=rev
Log:
Do not generate DW_TAG_imported_module for anonymous namespaces (even nested) 
for all the platforms except PS4.
For PS4, generate explicit import for anonymous namespaces and mark it by 
DW_AT_artificial attribute.

Differential Revision: http://reviews.llvm.org/D12624


Added:
cfe/trunk/test/CodeGenCXX/debug-info-anon-namespace.cpp
Modified:
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=255281=255280=255281=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Thu Dec 10 12:52:50 2015
@@ -166,6 +166,10 @@ CODEGENOPT(DebugColumnInfo, 1, 0) ///< W
 CODEGENOPT(DebugTypeExtRefs, 1, 0) ///< Whether or not debug info should 
contain
///< external references to a PCH or module.
 
+CODEGENOPT(DebugExplicitImport, 1, 0)  ///< Whether or not debug info should 
+   ///< contain explicit imports for 
+   ///< anonymous namespaces
+
 CODEGENOPT(EmitLLVMUseLists, 1, 0) ///< Control whether to serialize use-lists.
 
 /// The user specified number of registers to be used for integral arguments,

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=255281=255280=255281=diff
==
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Thu Dec 10 12:52:50 2015
@@ -2337,8 +2337,8 @@ private:
 
   void DiagnoseUnexpectedNamespace(NamedDecl *Context);
 
-  Decl *ParseNamespace(unsigned Context, SourceLocation ,
-   SourceLocation InlineLoc = SourceLocation());
+  DeclGroupPtrTy ParseNamespace(unsigned Context, SourceLocation ,
+SourceLocation InlineLoc = SourceLocation());
   void ParseInnerNamespace(std::vector& IdentLoc,
std::vector& Ident,
std::vector& NamespaceLoc,

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=255281=255280=255281=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Dec 10 12:52:50 2015
@@ -4093,7 +4093,8 @@ public:
SourceLocation IdentLoc,
IdentifierInfo *Ident,
SourceLocation LBrace,
-   AttributeList *AttrList);
+   AttributeList *AttrList,
+   UsingDirectiveDecl * );
   void ActOnFinishNamespaceDef(Decl *Dcl, SourceLocation RBrace);
 
   NamespaceDecl *getStdNamespace() const;

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=255281=255280=255281=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Dec 10 12:52:50 2015
@@ -3408,10 +3408,14 @@ llvm::DIScope *CGDebugInfo::getCurrentCo
 void CGDebugInfo::EmitUsingDirective(const UsingDirectiveDecl ) {
   if (CGM.getCodeGenOpts().getDebugInfo() < CodeGenOptions::LimitedDebugInfo)
 return;
-  DBuilder.createImportedModule(
-  getCurrentContextDescriptor(cast(UD.getDeclContext())),
-  getOrCreateNameSpace(UD.getNominatedNamespace()),
-  getLineNumber(UD.getLocation()));
+  const NamespaceDecl *NSDecl = UD.getNominatedNamespace();
+  if (!NSDecl->isAnonymousNamespace() || 
+  CGM.getCodeGenOpts().DebugExplicitImport) { 
+DBuilder.createImportedModule(
+getCurrentContextDescriptor(cast(UD.getDeclContext())),
+getOrCreateNameSpace(NSDecl),
+getLineNumber(UD.getLocation()));
+  }
 }
 
 void CGDebugInfo::EmitUsingDecl(const UsingDecl ) {

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=255281=255280=255281=diff