Re: Fix for the issue 12176

2017-09-29 Thread Oscar Forner Martinez via cfe-commits



On 28/09/17 21:28, Jonathan Roelofs wrote:

+silvas


On 9/28/17 2:19 PM, Oscar Forner Martinez via cfe-commits wrote:

Hi,

Please find attached a diff to fix the issue 12176.


Link for the lazy: llvm.org/PR12176

Thanks ;)



Let me know if there is anything any improvements you can think of.

Best regards,

Oscar


Extract-getDepthAndIndex-issue-12176.patch


Index: lib/Sema/DepthAndIndex.h
===
--- lib/Sema/DepthAndIndex.h    (nonexistent)
+++ lib/Sema/DepthAndIndex.h    (working copy)
@@ -0,0 +1,32 @@
+//===- DepthAndIndex.h - Static declaration of the getDepthAndIndex 
function -*- C++ -*-===//

+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open 
Source

+// License. See LICENSE.TXT for details.
+//===--===// 


+//
+//  This file defines getDepthAndIndex function.
+//
+//===--===// 


+
+#ifndef LLVM_CLANG_LIB_SEMA_DEPTHANDINDEX_H
+#define LLVM_CLANG_LIB_SEMA_DEPTHANDINDEX_H
+
+#include "clang/AST/DeclTemplate.h"
+#include "clang/Sema/DeclSpec.h"
+
+/// \brief Retrieve the depth and index of a template parameter.
+static std::pair<unsigned, unsigned>


This should be just a declaration and a doxygen comment for it. Drop 
the 'static'. You can also drop the "\brief" since autobrief is turned 
on.

Done


Then the body should go in a *.cpp somewhere in lib/Sema.
I haven't put the body in a *.cpp file because the other internal 
headers I've seen in lib/Sema have everything in the header file.



+getDepthAndIndex(NamedDecl *ND) {
+  if (TemplateTypeParmDecl *TTP = dyn_cast(ND))
+    return std::make_pair(TTP->getDepth(), TTP->getIndex());
+
+  if (NonTypeTemplateParmDecl *NTTP = 
dyn_cast(ND))

+    return std::make_pair(NTTP->getDepth(), NTTP->getIndex());
+
+  TemplateTemplateParmDecl *TTP = cast(ND);
+  return std::make_pair(TTP->getDepth(), TTP->getIndex());
+}
+
+#endif // LLVM_CLANG_LIB_SEMA_DEPTHANDINDEX_H
\ No newline at end of file
Index: lib/Sema/SemaTemplateDeduction.cpp
===
--- lib/Sema/SemaTemplateDeduction.cpp    (revision 314321)
+++ lib/Sema/SemaTemplateDeduction.cpp    (working copy)
@@ -11,6 +11,7 @@
//===--===/
    #include "clang/Sema/TemplateDeduction.h"
+#include "DepthAndIndex.h"
  #include "TreeTransform.h"
  #include "clang/AST/ASTContext.h"
  #include "clang/AST/ASTLambda.h"
@@ -579,19 +580,6 @@
    }
  }
  -/// \brief Retrieve the depth and index of a template parameter.
-static std::pair<unsigned, unsigned>
-getDepthAndIndex(NamedDecl *ND) {
-  if (TemplateTypeParmDecl *TTP = dyn_cast(ND))
-    return std::make_pair(TTP->getDepth(), TTP->getIndex());
-
-  if (NonTypeTemplateParmDecl *NTTP = 
dyn_cast(ND))

-    return std::make_pair(NTTP->getDepth(), NTTP->getIndex());
-
-  TemplateTemplateParmDecl *TTP = cast(ND);
-  return std::make_pair(TTP->getDepth(), TTP->getIndex());
-}
-
  /// \brief Retrieve the depth and index of an unexpanded parameter 
pack.

  static std::pair<unsigned, unsigned>
  getDepthAndIndex(UnexpandedParameterPack UPP) {


Maybe this ^ one should go too?

I added this method to the header.



Index: lib/Sema/SemaTemplateInstantiate.cpp


snip


Jon




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





Index: lib/Sema/DepthAndIndex.h
===
--- lib/Sema/DepthAndIndex.h	(nonexistent)
+++ lib/Sema/DepthAndIndex.h	(working copy)
@@ -0,0 +1,44 @@
+//===- DepthAndIndex.h - Static declaration of the getDepthAndIndex function -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//===--===//
+//
+//  This file defines getDepthAndIndex function.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_LIB_SEMA_DEPTHANDINDEX_H
+#define LLVM_CLANG_LIB_SEMA_DEPTHANDINDEX_H
+
+#include "clang/AST/DeclTemplate.h"
+#include "clang/Sema/DeclSpec.h"
+#include "clang/Sema/Template.h"
+
+/// Retrieve the depth and index of a template parameter.
+std::pair<unsigned, unsigned>
+getDepthAndIndex(NamedDecl *ND) {
+  if (TemplateTypeParmDecl *TTP = dyn_cast(ND))
+return std::make_pair(TTP->getDepth(), TTP->getIndex());
+
+  if (NonTypeTemplateParmDecl *N

Re: Fix for the issue 12176

2017-09-28 Thread Oscar Forner Martinez via cfe-commits

Hi Jonathan,

Thanks for the input. I will amend it and update it. I created an entry 
in Phabricator too (https://reviews.llvm.org/D38382).


Best regards,
Oscar


On 28/09/17 21:28, Jonathan Roelofs wrote:

+silvas


On 9/28/17 2:19 PM, Oscar Forner Martinez via cfe-commits wrote:

Hi,

Please find attached a diff to fix the issue 12176.


Link for the lazy: llvm.org/PR12176


Let me know if there is anything any improvements you can think of.

Best regards,

Oscar


Extract-getDepthAndIndex-issue-12176.patch


Index: lib/Sema/DepthAndIndex.h
===
--- lib/Sema/DepthAndIndex.h    (nonexistent)
+++ lib/Sema/DepthAndIndex.h    (working copy)
@@ -0,0 +1,32 @@
+//===- DepthAndIndex.h - Static declaration of the getDepthAndIndex 
function -*- C++ -*-===//

+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open 
Source

+// License. See LICENSE.TXT for details.
+//===--===// 


+//
+//  This file defines getDepthAndIndex function.
+//
+//===--===// 


+
+#ifndef LLVM_CLANG_LIB_SEMA_DEPTHANDINDEX_H
+#define LLVM_CLANG_LIB_SEMA_DEPTHANDINDEX_H
+
+#include "clang/AST/DeclTemplate.h"
+#include "clang/Sema/DeclSpec.h"
+
+/// \brief Retrieve the depth and index of a template parameter.
+static std::pair<unsigned, unsigned>


This should be just a declaration and a doxygen comment for it. Drop 
the 'static'. You can also drop the "\brief" since autobrief is turned 
on.


Then the body should go in a *.cpp somewhere in lib/Sema.


+getDepthAndIndex(NamedDecl *ND) {
+  if (TemplateTypeParmDecl *TTP = dyn_cast(ND))
+    return std::make_pair(TTP->getDepth(), TTP->getIndex());
+
+  if (NonTypeTemplateParmDecl *NTTP = 
dyn_cast(ND))

+    return std::make_pair(NTTP->getDepth(), NTTP->getIndex());
+
+  TemplateTemplateParmDecl *TTP = cast(ND);
+  return std::make_pair(TTP->getDepth(), TTP->getIndex());
+}
+
+#endif // LLVM_CLANG_LIB_SEMA_DEPTHANDINDEX_H
\ No newline at end of file
Index: lib/Sema/SemaTemplateDeduction.cpp
===
--- lib/Sema/SemaTemplateDeduction.cpp    (revision 314321)
+++ lib/Sema/SemaTemplateDeduction.cpp    (working copy)
@@ -11,6 +11,7 @@
//===--===/
    #include "clang/Sema/TemplateDeduction.h"
+#include "DepthAndIndex.h"
  #include "TreeTransform.h"
  #include "clang/AST/ASTContext.h"
  #include "clang/AST/ASTLambda.h"
@@ -579,19 +580,6 @@
    }
  }
  -/// \brief Retrieve the depth and index of a template parameter.
-static std::pair<unsigned, unsigned>
-getDepthAndIndex(NamedDecl *ND) {
-  if (TemplateTypeParmDecl *TTP = dyn_cast(ND))
-    return std::make_pair(TTP->getDepth(), TTP->getIndex());
-
-  if (NonTypeTemplateParmDecl *NTTP = 
dyn_cast(ND))

-    return std::make_pair(NTTP->getDepth(), NTTP->getIndex());
-
-  TemplateTemplateParmDecl *TTP = cast(ND);
-  return std::make_pair(TTP->getDepth(), TTP->getIndex());
-}
-
  /// \brief Retrieve the depth and index of an unexpanded parameter 
pack.

  static std::pair<unsigned, unsigned>
  getDepthAndIndex(UnexpandedParameterPack UPP) {


Maybe this ^ one should go too?


Index: lib/Sema/SemaTemplateInstantiate.cpp


snip


Jon




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





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


Re: Fix for the issue 12176

2017-09-28 Thread Jonathan Roelofs via cfe-commits

+silvas


On 9/28/17 2:19 PM, Oscar Forner Martinez via cfe-commits wrote:

Hi,

Please find attached a diff to fix the issue 12176.


Link for the lazy: llvm.org/PR12176

Let me know if there 
is anything any improvements you can think of.


Best regards,

Oscar


Extract-getDepthAndIndex-issue-12176.patch


Index: lib/Sema/DepthAndIndex.h
===
--- lib/Sema/DepthAndIndex.h(nonexistent)
+++ lib/Sema/DepthAndIndex.h(working copy)
@@ -0,0 +1,32 @@
+//===- DepthAndIndex.h - Static declaration of the getDepthAndIndex function 
-*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//===--===//
+//
+//  This file defines getDepthAndIndex function.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_LIB_SEMA_DEPTHANDINDEX_H
+#define LLVM_CLANG_LIB_SEMA_DEPTHANDINDEX_H
+
+#include "clang/AST/DeclTemplate.h"
+#include "clang/Sema/DeclSpec.h"
+
+/// \brief Retrieve the depth and index of a template parameter.
+static std::pair<unsigned, unsigned>


This should be just a declaration and a doxygen comment for it. Drop the 
'static'. You can also drop the "\brief" since autobrief is turned on.


Then the body should go in a *.cpp somewhere in lib/Sema.


+getDepthAndIndex(NamedDecl *ND) {
+  if (TemplateTypeParmDecl *TTP = dyn_cast(ND))
+return std::make_pair(TTP->getDepth(), TTP->getIndex());
+
+  if (NonTypeTemplateParmDecl *NTTP = dyn_cast(ND))
+return std::make_pair(NTTP->getDepth(), NTTP->getIndex());
+
+  TemplateTemplateParmDecl *TTP = cast(ND);
+  return std::make_pair(TTP->getDepth(), TTP->getIndex());
+}
+
+#endif // LLVM_CLANG_LIB_SEMA_DEPTHANDINDEX_H
\ No newline at end of file
Index: lib/Sema/SemaTemplateDeduction.cpp
===
--- lib/Sema/SemaTemplateDeduction.cpp  (revision 314321)
+++ lib/Sema/SemaTemplateDeduction.cpp  (working copy)
@@ -11,6 +11,7 @@
  
//===--===/
  
  #include "clang/Sema/TemplateDeduction.h"

+#include "DepthAndIndex.h"
  #include "TreeTransform.h"
  #include "clang/AST/ASTContext.h"
  #include "clang/AST/ASTLambda.h"
@@ -579,19 +580,6 @@
}
  }
  
-/// \brief Retrieve the depth and index of a template parameter.

-static std::pair<unsigned, unsigned>
-getDepthAndIndex(NamedDecl *ND) {
-  if (TemplateTypeParmDecl *TTP = dyn_cast(ND))
-return std::make_pair(TTP->getDepth(), TTP->getIndex());
-
-  if (NonTypeTemplateParmDecl *NTTP = dyn_cast(ND))
-return std::make_pair(NTTP->getDepth(), NTTP->getIndex());
-
-  TemplateTemplateParmDecl *TTP = cast(ND);
-  return std::make_pair(TTP->getDepth(), TTP->getIndex());
-}
-
  /// \brief Retrieve the depth and index of an unexpanded parameter pack.
  static std::pair<unsigned, unsigned>
  getDepthAndIndex(UnexpandedParameterPack UPP) {


Maybe this ^ one should go too?


Index: lib/Sema/SemaTemplateInstantiate.cpp


snip


Jon




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



--
Jon Roelofs
jonat...@codesourcery.com
CodeSourcery / Mentor Embedded / Siemens
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Fix for the issue 12176

2017-09-28 Thread Oscar Forner Martinez via cfe-commits

Hi,

Please find attached a diff to fix the issue 12176. Let me know if there 
is anything any improvements you can think of.


Best regards,

Oscar

Index: lib/Sema/DepthAndIndex.h
===
--- lib/Sema/DepthAndIndex.h	(nonexistent)
+++ lib/Sema/DepthAndIndex.h	(working copy)
@@ -0,0 +1,32 @@
+//===- DepthAndIndex.h - Static declaration of the getDepthAndIndex function -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//===--===//
+//
+//  This file defines getDepthAndIndex function.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_LIB_SEMA_DEPTHANDINDEX_H
+#define LLVM_CLANG_LIB_SEMA_DEPTHANDINDEX_H
+
+#include "clang/AST/DeclTemplate.h"
+#include "clang/Sema/DeclSpec.h"
+
+/// \brief Retrieve the depth and index of a template parameter.
+static std::pair<unsigned, unsigned>
+getDepthAndIndex(NamedDecl *ND) {
+  if (TemplateTypeParmDecl *TTP = dyn_cast(ND))
+return std::make_pair(TTP->getDepth(), TTP->getIndex());
+
+  if (NonTypeTemplateParmDecl *NTTP = dyn_cast(ND))
+return std::make_pair(NTTP->getDepth(), NTTP->getIndex());
+
+  TemplateTemplateParmDecl *TTP = cast(ND);
+  return std::make_pair(TTP->getDepth(), TTP->getIndex());
+}
+
+#endif // LLVM_CLANG_LIB_SEMA_DEPTHANDINDEX_H
\ No newline at end of file
Index: lib/Sema/SemaTemplateDeduction.cpp
===
--- lib/Sema/SemaTemplateDeduction.cpp	(revision 314321)
+++ lib/Sema/SemaTemplateDeduction.cpp	(working copy)
@@ -11,6 +11,7 @@
 //===--===/
 
 #include "clang/Sema/TemplateDeduction.h"
+#include "DepthAndIndex.h"
 #include "TreeTransform.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/ASTLambda.h"
@@ -579,19 +580,6 @@
   }
 }
 
-/// \brief Retrieve the depth and index of a template parameter.
-static std::pair<unsigned, unsigned>
-getDepthAndIndex(NamedDecl *ND) {
-  if (TemplateTypeParmDecl *TTP = dyn_cast(ND))
-return std::make_pair(TTP->getDepth(), TTP->getIndex());
-
-  if (NonTypeTemplateParmDecl *NTTP = dyn_cast(ND))
-return std::make_pair(NTTP->getDepth(), NTTP->getIndex());
-
-  TemplateTemplateParmDecl *TTP = cast(ND);
-  return std::make_pair(TTP->getDepth(), TTP->getIndex());
-}
-
 /// \brief Retrieve the depth and index of an unexpanded parameter pack.
 static std::pair<unsigned, unsigned>
 getDepthAndIndex(UnexpandedParameterPack UPP) {
Index: lib/Sema/SemaTemplateInstantiate.cpp
===
--- lib/Sema/SemaTemplateInstantiate.cpp	(revision 314321)
+++ lib/Sema/SemaTemplateInstantiate.cpp	(working copy)
@@ -11,6 +11,7 @@
 //===--===/
 
 #include "clang/Sema/SemaInternal.h"
+#include "DepthAndIndex.h"
 #include "TreeTransform.h"
 #include "clang/AST/ASTConsumer.h"
 #include "clang/AST/ASTContext.h"
@@ -693,19 +694,6 @@
   return None;
 }
 
-/// \brief Retrieve the depth and index of a parameter pack.
-static std::pair<unsigned, unsigned> 
-getDepthAndIndex(NamedDecl *ND) {
-  if (TemplateTypeParmDecl *TTP = dyn_cast(ND))
-return std::make_pair(TTP->getDepth(), TTP->getIndex());
-  
-  if (NonTypeTemplateParmDecl *NTTP = dyn_cast(ND))
-return std::make_pair(NTTP->getDepth(), NTTP->getIndex());
-  
-  TemplateTemplateParmDecl *TTP = cast(ND);
-  return std::make_pair(TTP->getDepth(), TTP->getIndex());
-}
-
 //===--===/
 // Template Instantiation for Types
 //===--===/
Index: lib/Sema/SemaTemplateVariadic.cpp
===
--- lib/Sema/SemaTemplateVariadic.cpp	(revision 314321)
+++ lib/Sema/SemaTemplateVariadic.cpp	(working copy)
@@ -10,6 +10,7 @@
 //===--===/
 
 #include "clang/Sema/Sema.h"
+#include "DepthAndIndex.h"
 #include "TypeLocBuilder.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/RecursiveASTVisitor.h"
@@ -26,19 +27,6 @@
 // Visitor that collects unexpanded parameter packs
 //
 
-/// \brief Retrieve the depth and index of a parameter pack.
-static std::pair<unsigned, unsigned> 
-getDepthAndIndex(NamedDecl *ND) {
-  if (Templat