[PATCH] D90568: [clang] Add [is|set]Nested methods to NamespaceDecl

2022-11-24 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

My bots look happy at least. Thanks for the quick fix!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90568

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


[PATCH] D90568: [clang] Add [is|set]Nested methods to NamespaceDecl

2022-11-24 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

In D90568#3949134 , @thakis wrote:

> This breaks the build: http://45.33.8.238/linux/92294/step_4.txt
>
> Please take a look and revert for now if it takes a while to fix.

Apologies it took 2 times, It should all be good now, lmk if there's any other 
issues.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90568

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


[PATCH] D90568: [clang] Add [is|set]Nested methods to NamespaceDecl

2022-11-24 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

This breaks the build: http://45.33.8.238/linux/92294/step_4.txt

Please take a look and revert for now if it takes a while to fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90568

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


[PATCH] D90568: [clang] Add [is|set]Nested methods to NamespaceDecl

2022-11-24 Thread Nathan James via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG15e76eed0c76: [clang] Add [is|set]Nested methods to 
NamespaceDecl (authored by njames93).

Changed prior to commit:
  https://reviews.llvm.org/D90568?vs=477467&id=477750#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90568

Files:
  clang/include/clang/AST/Decl.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/DeclCXX.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/JSONNodeDumper.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Sema/HLSLExternalSemaSource.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/test/AST/ast-dump-decl.cpp
  clang/test/AST/ast-dump-namespace-json.cpp
  clang/unittests/Sema/ExternalSemaSourceTest.cpp

Index: clang/unittests/Sema/ExternalSemaSourceTest.cpp
===
--- clang/unittests/Sema/ExternalSemaSourceTest.cpp
+++ clang/unittests/Sema/ExternalSemaSourceTest.cpp
@@ -121,7 +121,7 @@
   CurrentSema->getPreprocessor().getIdentifierInfo(CorrectTo);
   NamespaceDecl *NewNamespace =
   NamespaceDecl::Create(Context, DestContext, false, Typo.getBeginLoc(),
-Typo.getLoc(), ToIdent, nullptr);
+Typo.getLoc(), ToIdent, nullptr, false);
   DestContext->addDecl(NewNamespace);
   TypoCorrection Correction(ToIdent);
   Correction.addCorrectionDecl(NewNamespace);
Index: clang/test/AST/ast-dump-namespace-json.cpp
===
--- clang/test/AST/ast-dump-namespace-json.cpp
+++ clang/test/AST/ast-dump-namespace-json.cpp
@@ -170,6 +170,7 @@
 // CHECK-NEXT: }
 // CHECK-NEXT:},
 // CHECK-NEXT:"name": "quux"
+// CHECK-NEXT:"isNested": true
 // CHECK-NEXT:   }
 // CHECK-NEXT:  ]
 // CHECK-NEXT: }
@@ -195,7 +196,7 @@
 // CHECK-NEXT:"tokLen": 1
 // CHECK-NEXT:   }
 // CHECK-NEXT:  },
-// CHECK-NEXT:  "name": "quux",
+// CHECK-NEXT:  "name": "quux"
 // CHECK-NEXT:  "inner": [
 // CHECK-NEXT:   {
 // CHECK-NEXT:"id": "0x{{.*}}",
@@ -220,7 +221,8 @@
 // CHECK-NEXT: }
 // CHECK-NEXT:},
 // CHECK-NEXT:"name": "frobble",
-// CHECK-NEXT:"isInline": true
+// CHECK-NEXT:"isInline": true,
+// CHECK-NEXT:"isNested": true
 // CHECK-NEXT:   }
 // CHECK-NEXT:  ]
 // CHECK-NEXT: }
Index: clang/test/AST/ast-dump-decl.cpp
===
--- clang/test/AST/ast-dump-decl.cpp
+++ clang/test/AST/ast-dump-decl.cpp
@@ -53,6 +53,23 @@
 }
 // CHECK:  NamespaceDecl{{.*}} TestNamespaceDeclInline inline
 
+namespace TestNestedNameSpace::Nested {
+}
+// CHECK:  NamespaceDecl{{.*}} TestNestedNameSpace
+// CHECK:  NamespaceDecl{{.*}} Nested nested{{\s*$}}
+
+namespace TestMultipleNested::SecondLevelNested::Nested {
+}
+// CHECK:  NamespaceDecl{{.*}} TestMultipleNested
+// CHECK:  NamespaceDecl{{.*}} SecondLevelNested nested
+// CHECK:  NamespaceDecl{{.*}} Nested nested{{\s*$}}
+
+namespace TestInlineNested::inline SecondLevel::inline Nested {
+}
+// CHECK:  NamespaceDecl{{.*}} TestInlineNested
+// CHECK:  NamespaceDecl{{.*}} SecondLevel inline nested
+// CHECK:  NamespaceDecl{{.*}} Nested inline nested{{\s*$}}
+
 namespace testUsingDirectiveDecl {
   namespace A {
   }
Index: clang/lib/Serialization/ASTWriterDecl.cpp
===
--- clang/lib/Serialization/ASTWriterDecl.cpp
+++ clang/lib/Serialization/ASTWriterDecl.cpp
@@ -1252,6 +1252,7 @@
   VisitRedeclarable(D);
   VisitNamedDecl(D);
   Record.push_back(D->isInline());
+  Record.push_back(D->isNested());
   Record.AddSourceLocation(D->getBeginLoc());
   Record.AddSourceLocation(D->getRBraceLoc());
 
Index: clang/lib/Serialization/ASTReaderDecl.cpp
===
--- clang/lib/Serialization/ASTReaderDecl.cpp
+++ clang/lib/Serialization/ASTReaderDecl.cpp
@@ -1745,6 +1745,7 @@
   RedeclarableResult Redecl = VisitRedeclarable(D);
   VisitNamedDecl(D);
   D->setInline(Record.readInt());
+  D->setNested(Record.readInt());
   D->LocStart = readSourceLocation();
   D->RBraceLoc = readSourceLocation();
 
@@ -1758,7 +1759,7 @@
   } else {
 // Link this namespace back to the first declaration, which has already
 // been deserialized.
-D->AnonOrFirstNamespaceAndInline.setPointer(D->getFirstDecl());
+D->AnonOrFirstNamespaceAndFlags.setPointer(D->getFirstDecl());
   }
 
   mergeRedeclarable(D, Redecl);
@@ -2784,8 +2785,8 @@
 // We cannot have loaded any redeclarations of this declaration yet, so
 // the

[PATCH] D90568: [clang] Add [is|set]Nested methods to NamespaceDecl

2022-11-23 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 477467.
njames93 added a comment.

Hopefully fixed line endings


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90568

Files:
  clang/include/clang/AST/Decl.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/DeclCXX.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/JSONNodeDumper.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Sema/HLSLExternalSemaSource.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/test/AST/ast-dump-decl.cpp
  clang/test/AST/ast-dump-namespace-json.cpp
  clang/unittests/Sema/ExternalSemaSourceTest.cpp

Index: clang/unittests/Sema/ExternalSemaSourceTest.cpp
===
--- clang/unittests/Sema/ExternalSemaSourceTest.cpp
+++ clang/unittests/Sema/ExternalSemaSourceTest.cpp
@@ -121,7 +121,7 @@
   CurrentSema->getPreprocessor().getIdentifierInfo(CorrectTo);
   NamespaceDecl *NewNamespace =
   NamespaceDecl::Create(Context, DestContext, false, Typo.getBeginLoc(),
-Typo.getLoc(), ToIdent, nullptr);
+Typo.getLoc(), ToIdent, nullptr, false);
   DestContext->addDecl(NewNamespace);
   TypoCorrection Correction(ToIdent);
   Correction.addCorrectionDecl(NewNamespace);
Index: clang/test/AST/ast-dump-namespace-json.cpp
===
--- clang/test/AST/ast-dump-namespace-json.cpp
+++ clang/test/AST/ast-dump-namespace-json.cpp
@@ -170,6 +170,7 @@
 // CHECK-NEXT: }
 // CHECK-NEXT:},
 // CHECK-NEXT:"name": "quux"
+// CHECK-NEXT:"isNested": true
 // CHECK-NEXT:   }
 // CHECK-NEXT:  ]
 // CHECK-NEXT: }
@@ -195,7 +196,7 @@
 // CHECK-NEXT:"tokLen": 1
 // CHECK-NEXT:   }
 // CHECK-NEXT:  },
-// CHECK-NEXT:  "name": "quux",
+// CHECK-NEXT:  "name": "quux"
 // CHECK-NEXT:  "inner": [
 // CHECK-NEXT:   {
 // CHECK-NEXT:"id": "0x{{.*}}",
@@ -220,7 +221,8 @@
 // CHECK-NEXT: }
 // CHECK-NEXT:},
 // CHECK-NEXT:"name": "frobble",
-// CHECK-NEXT:"isInline": true
+// CHECK-NEXT:"isInline": true,
+// CHECK-NEXT:"isNested": true
 // CHECK-NEXT:   }
 // CHECK-NEXT:  ]
 // CHECK-NEXT: }
Index: clang/test/AST/ast-dump-decl.cpp
===
--- clang/test/AST/ast-dump-decl.cpp
+++ clang/test/AST/ast-dump-decl.cpp
@@ -53,6 +53,23 @@
 }
 // CHECK:  NamespaceDecl{{.*}} TestNamespaceDeclInline inline
 
+namespace TestNestedNameSpace::Nested {
+}
+// CHECK:  NamespaceDecl{{.*}} TestNestedNameSpace
+// CHECK:  NamespaceDecl{{.*}} Nested nested{{\s*$}}
+
+namespace TestMultipleNested::SecondLevelNested::Nested {
+}
+// CHECK:  NamespaceDecl{{.*}} TestMultipleNested
+// CHECK:  NamespaceDecl{{.*}} SecondLevelNested nested
+// CHECK:  NamespaceDecl{{.*}} Nested nested{{\s*$}}
+
+namespace TestInlineNested::inline SecondLevel::inline Nested {
+}
+// CHECK:  NamespaceDecl{{.*}} TestInlineNested
+// CHECK:  NamespaceDecl{{.*}} SecondLevel inline nested
+// CHECK:  NamespaceDecl{{.*}} Nested inline nested{{\s*$}}
+
 namespace testUsingDirectiveDecl {
   namespace A {
   }
Index: clang/lib/Serialization/ASTWriterDecl.cpp
===
--- clang/lib/Serialization/ASTWriterDecl.cpp
+++ clang/lib/Serialization/ASTWriterDecl.cpp
@@ -1252,6 +1252,7 @@
   VisitRedeclarable(D);
   VisitNamedDecl(D);
   Record.push_back(D->isInline());
+  Record.push_back(D->isNested());
   Record.AddSourceLocation(D->getBeginLoc());
   Record.AddSourceLocation(D->getRBraceLoc());
 
Index: clang/lib/Serialization/ASTReaderDecl.cpp
===
--- clang/lib/Serialization/ASTReaderDecl.cpp
+++ clang/lib/Serialization/ASTReaderDecl.cpp
@@ -1745,6 +1745,7 @@
   RedeclarableResult Redecl = VisitRedeclarable(D);
   VisitNamedDecl(D);
   D->setInline(Record.readInt());
+  D->setNested(Record.readInt());
   D->LocStart = readSourceLocation();
   D->RBraceLoc = readSourceLocation();
 
@@ -1758,7 +1759,7 @@
   } else {
 // Link this namespace back to the first declaration, which has already
 // been deserialized.
-D->AnonOrFirstNamespaceAndInline.setPointer(D->getFirstDecl());
+D->AnonOrFirstNamespaceAndFlags.setPointer(D->getFirstDecl());
   }
 
   mergeRedeclarable(D, Redecl);
@@ -2784,8 +2785,8 @@
 // We cannot have loaded any redeclarations of this declaration yet, so
 // there's nothing else that needs to be updated.
 if (auto *Namespace = dyn_cast(D))
-  Namespace->AnonOrFirstNamespaceAndInline.setPointer(
-  assert_cast(ExistingCanon));
+  Namespace->AnonOrFirstNamespa

[PATCH] D90568: [clang] Add [is|set]Nested methods to NamespaceDecl

2022-11-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/AST/Decl.h:546
+
+  enum Flags : unsigned { F_Inline = 1 << 0, F_Nested = 1 << 1 };
+

njames93 wrote:
> aaron.ballman wrote:
> > I'm not really loving the `F_` prefixes -- the enumerators are already 
> > privately scoped to `NamespaceDecl`, is that not sufficient protection?
> I think just having it named as Inline and Nested is going to confuse things 
> even more, `BlockDecl` seems to use `flag_is` for its packing, and I 
> think that is even worse. WDYT
Eh, I don't feel super strongly, but if you want to force there to be a 
qualified name, then I'd hoist it out of `NamespaceDecl` and make a scoped enum 
so you can write `Namespace::Inline` or `Namespace::Nested`.



Comment at: clang/test/AST/ast-dump-decl.cpp:1
-// Test without serialization:
-// RUN: %clang_cc1 -std=c++11 -triple x86_64-linux-gnu -fms-extensions \
-// RUN: -ast-dump -ast-dump-filter Test %s \
-// RUN: | FileCheck --strict-whitespace %s
-//
-// Test with serialization: FIXME: Find why the outputs differs and fix it!
-//: %clang_cc1 -std=c++11 -triple x86_64-linux-gnu -fms-extensions 
-emit-pch -o %t %s
-//: %clang_cc1 -x c++ -std=c++11 -triple x86_64-linux-gnu -fms-extensions 
-include-pch %t \
-//: -ast-dump-all -ast-dump-filter Test /dev/null \
-//: | sed -e "s/ //" -e "s/ imported//" \
-//: | FileCheck --strict-whitespace %s
-
-class testEnumDecl {
-  enum class TestEnumDeclScoped;
-  enum TestEnumDeclFixed : int;
-};
-// CHECK: EnumDecl{{.*}} class TestEnumDeclScoped 'int'
-// CHECK: EnumDecl{{.*}} TestEnumDeclFixed 'int'
-
-class testFieldDecl {
-  int TestFieldDeclInit = 0;
-};
-// CHECK:  FieldDecl{{.*}} TestFieldDeclInit 'int'
-// CHECK-NEXT:   IntegerLiteral
-
-namespace testVarDeclNRVO {
-  class A { };
-  A foo() {
-A TestVarDeclNRVO;
-return TestVarDeclNRVO;
-  }
-}
-// CHECK: VarDecl{{.*}} TestVarDeclNRVO 'A':'testVarDeclNRVO::A' nrvo
-
-void testParmVarDeclInit(int TestParmVarDeclInit = 0);
-// CHECK:  ParmVarDecl{{.*}} TestParmVarDeclInit 'int'
-// CHECK-NEXT:   IntegerLiteral{{.*}}
-
-namespace TestNamespaceDecl {
-  int i;
-}
-// CHECK:  NamespaceDecl{{.*}} TestNamespaceDecl
-// CHECK-NEXT:   VarDecl
-
-namespace TestNamespaceDecl {
-  int j;
-}
-// CHECK:  NamespaceDecl{{.*}} TestNamespaceDecl
-// CHECK-NEXT:   original Namespace
-// CHECK-NEXT:   VarDecl
-
-inline namespace TestNamespaceDeclInline {
-}
-// CHECK:  NamespaceDecl{{.*}} TestNamespaceDeclInline inline
-
-namespace testUsingDirectiveDecl {
-  namespace A {
-  }
-}
-namespace TestUsingDirectiveDecl {
-  using namespace testUsingDirectiveDecl::A;
-}
-// CHECK:  NamespaceDecl{{.*}} TestUsingDirectiveDecl
-// CHECK-NEXT:   UsingDirectiveDecl{{.*}} Namespace{{.*}} 'A'
-
-namespace testNamespaceAlias {
-  namespace A {
-  }
-}
-namespace TestNamespaceAlias = testNamespaceAlias::A;
-// CHECK:  NamespaceAliasDecl{{.*}} TestNamespaceAlias
-// CHECK-NEXT:   Namespace{{.*}} 'A'
-
-using TestTypeAliasDecl = int;
-// CHECK: TypeAliasDecl{{.*}} TestTypeAliasDecl 'int'
-
-namespace testTypeAliasTemplateDecl {
-  template class A;
-  template using TestTypeAliasTemplateDecl = A;
-}
-// CHECK:  TypeAliasTemplateDecl{{.*}} TestTypeAliasTemplateDecl
-// CHECK-NEXT:   TemplateTypeParmDecl
-// CHECK-NEXT:   TypeAliasDecl{{.*}} TestTypeAliasTemplateDecl 'A'
-
-namespace testCXXRecordDecl {
-  class TestEmpty {};
-// CHECK:  CXXRecordDecl{{.*}} class TestEmpty
-// CHECK-NEXT:   DefinitionData pass_in_registers empty aggregate 
standard_layout trivially_copyable pod trivial literal 
has_constexpr_non_copy_move_ctor can_const_default_init
-// CHECK-NEXT: DefaultConstructor exists trivial constexpr
-// CHECK-NEXT: CopyConstructor simple trivial has_const_param
-// CHECK-NEXT: MoveConstructor exists simple trivial
-// CHECK-NEXT: CopyAssignment simple trivial has_const_param
-// CHECK-NEXT: MoveAssignment exists simple trivial
-// CHECK-NEXT: Destructor simple irrelevant trivial
-
-  class A { };
-  class B { };
-  class TestCXXRecordDecl : virtual A, public B {
-int i;
-  };
-}
-// CHECK:  CXXRecordDecl{{.*}} class TestCXXRecordDecl
-// CHECK-NEXT:   DefinitionData{{$}}
-// CHECK-NEXT: DefaultConstructor exists non_trivial
-// CHECK-NEXT: CopyConstructor simple non_trivial has_const_param
-// CHECK-NEXT: MoveConstructor exists simple non_trivial
-// CHECK-NEXT: CopyAssignment simple non_trivial has_const_param
-// CHECK-NEXT: MoveAssignment exists simple non_trivial
-// CHECK-NEXT: Destructor simple irrelevant trivial
-// CHECK-NEXT:   virtual private 'A':'testCXXRecordDecl::A'
-// CHECK-NEXT:   public 'B':'testCXXRecordDecl::B'
-// CHECK-NEXT:   CXXRecordDecl{{.*}} class TestCXXRecordDecl
-// CHECK-NEXT:   FieldDecl
-
-template
-class TestCXXRecordDeclPack : public T... {
-};
-// CHECK:  CXXRecordDecl{{.*}} class TestCXXRecordDeclPack
-/

[PATCH] D90568: [clang] Add [is|set]Nested methods to NamespaceDecl

2022-11-10 Thread Nathan James via Phabricator via cfe-commits
njames93 added inline comments.



Comment at: clang/test/AST/ast-dump-decl.cpp:1
-// Test without serialization:
-// RUN: %clang_cc1 -std=c++11 -triple x86_64-linux-gnu -fms-extensions \
-// RUN: -ast-dump -ast-dump-filter Test %s \
-// RUN: | FileCheck --strict-whitespace %s
-//
-// Test with serialization: FIXME: Find why the outputs differs and fix it!
-//: %clang_cc1 -std=c++11 -triple x86_64-linux-gnu -fms-extensions 
-emit-pch -o %t %s
-//: %clang_cc1 -x c++ -std=c++11 -triple x86_64-linux-gnu -fms-extensions 
-include-pch %t \
-//: -ast-dump-all -ast-dump-filter Test /dev/null \
-//: | sed -e "s/ //" -e "s/ imported//" \
-//: | FileCheck --strict-whitespace %s
-
-class testEnumDecl {
-  enum class TestEnumDeclScoped;
-  enum TestEnumDeclFixed : int;
-};
-// CHECK: EnumDecl{{.*}} class TestEnumDeclScoped 'int'
-// CHECK: EnumDecl{{.*}} TestEnumDeclFixed 'int'
-
-class testFieldDecl {
-  int TestFieldDeclInit = 0;
-};
-// CHECK:  FieldDecl{{.*}} TestFieldDeclInit 'int'
-// CHECK-NEXT:   IntegerLiteral
-
-namespace testVarDeclNRVO {
-  class A { };
-  A foo() {
-A TestVarDeclNRVO;
-return TestVarDeclNRVO;
-  }
-}
-// CHECK: VarDecl{{.*}} TestVarDeclNRVO 'A':'testVarDeclNRVO::A' nrvo
-
-void testParmVarDeclInit(int TestParmVarDeclInit = 0);
-// CHECK:  ParmVarDecl{{.*}} TestParmVarDeclInit 'int'
-// CHECK-NEXT:   IntegerLiteral{{.*}}
-
-namespace TestNamespaceDecl {
-  int i;
-}
-// CHECK:  NamespaceDecl{{.*}} TestNamespaceDecl
-// CHECK-NEXT:   VarDecl
-
-namespace TestNamespaceDecl {
-  int j;
-}
-// CHECK:  NamespaceDecl{{.*}} TestNamespaceDecl
-// CHECK-NEXT:   original Namespace
-// CHECK-NEXT:   VarDecl
-
-inline namespace TestNamespaceDeclInline {
-}
-// CHECK:  NamespaceDecl{{.*}} TestNamespaceDeclInline inline
-
-namespace testUsingDirectiveDecl {
-  namespace A {
-  }
-}
-namespace TestUsingDirectiveDecl {
-  using namespace testUsingDirectiveDecl::A;
-}
-// CHECK:  NamespaceDecl{{.*}} TestUsingDirectiveDecl
-// CHECK-NEXT:   UsingDirectiveDecl{{.*}} Namespace{{.*}} 'A'
-
-namespace testNamespaceAlias {
-  namespace A {
-  }
-}
-namespace TestNamespaceAlias = testNamespaceAlias::A;
-// CHECK:  NamespaceAliasDecl{{.*}} TestNamespaceAlias
-// CHECK-NEXT:   Namespace{{.*}} 'A'
-
-using TestTypeAliasDecl = int;
-// CHECK: TypeAliasDecl{{.*}} TestTypeAliasDecl 'int'
-
-namespace testTypeAliasTemplateDecl {
-  template class A;
-  template using TestTypeAliasTemplateDecl = A;
-}
-// CHECK:  TypeAliasTemplateDecl{{.*}} TestTypeAliasTemplateDecl
-// CHECK-NEXT:   TemplateTypeParmDecl
-// CHECK-NEXT:   TypeAliasDecl{{.*}} TestTypeAliasTemplateDecl 'A'
-
-namespace testCXXRecordDecl {
-  class TestEmpty {};
-// CHECK:  CXXRecordDecl{{.*}} class TestEmpty
-// CHECK-NEXT:   DefinitionData pass_in_registers empty aggregate 
standard_layout trivially_copyable pod trivial literal 
has_constexpr_non_copy_move_ctor can_const_default_init
-// CHECK-NEXT: DefaultConstructor exists trivial constexpr
-// CHECK-NEXT: CopyConstructor simple trivial has_const_param
-// CHECK-NEXT: MoveConstructor exists simple trivial
-// CHECK-NEXT: CopyAssignment simple trivial has_const_param
-// CHECK-NEXT: MoveAssignment exists simple trivial
-// CHECK-NEXT: Destructor simple irrelevant trivial
-
-  class A { };
-  class B { };
-  class TestCXXRecordDecl : virtual A, public B {
-int i;
-  };
-}
-// CHECK:  CXXRecordDecl{{.*}} class TestCXXRecordDecl
-// CHECK-NEXT:   DefinitionData{{$}}
-// CHECK-NEXT: DefaultConstructor exists non_trivial
-// CHECK-NEXT: CopyConstructor simple non_trivial has_const_param
-// CHECK-NEXT: MoveConstructor exists simple non_trivial
-// CHECK-NEXT: CopyAssignment simple non_trivial has_const_param
-// CHECK-NEXT: MoveAssignment exists simple non_trivial
-// CHECK-NEXT: Destructor simple irrelevant trivial
-// CHECK-NEXT:   virtual private 'A':'testCXXRecordDecl::A'
-// CHECK-NEXT:   public 'B':'testCXXRecordDecl::B'
-// CHECK-NEXT:   CXXRecordDecl{{.*}} class TestCXXRecordDecl
-// CHECK-NEXT:   FieldDecl
-
-template
-class TestCXXRecordDeclPack : public T... {
-};
-// CHECK:  CXXRecordDecl{{.*}} class TestCXXRecordDeclPack
-// CHECK:public 'T'...
-// CHECK-NEXT:   CXXRecordDecl{{.*}} class TestCXXRecordDeclPack
-
-thread_local int TestThreadLocalInt;
-// CHECK: TestThreadLocalInt {{.*}} tls_dynamic
-
-class testCXXMethodDecl {
-  virtual void TestCXXMethodDeclPure() = 0;
-  void TestCXXMethodDeclDelete() = delete;
-  void TestCXXMethodDeclThrow() throw();
-  void TestCXXMethodDeclThrowType() throw(int);
-};
-// CHECK: CXXMethodDecl{{.*}} TestCXXMethodDeclPure 'void ()' virtual pure
-// CHECK: CXXMethodDecl{{.*}} TestCXXMethodDeclDelete 'void ()' delete
-// CHECK: CXXMethodDecl{{.*}} TestCXXMethodDeclThrow 'void () throw()'
-// CHECK: CXXMethodDecl{{.*}} TestCXXMethodDeclThrowType 'void () throw(int)'
-
-namespace testCXXConstructorDecl {
-  class A { };

[PATCH] D90568: [clang] Add [is|set]Nested methods to NamespaceDecl

2022-11-10 Thread Nathan James via Phabricator via cfe-commits
njames93 added inline comments.



Comment at: clang/include/clang/AST/Decl.h:546
+
+  enum Flags : unsigned { F_Inline = 1 << 0, F_Nested = 1 << 1 };
+

aaron.ballman wrote:
> I'm not really loving the `F_` prefixes -- the enumerators are already 
> privately scoped to `NamespaceDecl`, is that not sufficient protection?
I think just having it named as Inline and Nested is going to confuse things 
even more, `BlockDecl` seems to use `flag_is` for its packing, and I 
think that is even worse. WDYT


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90568

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


[PATCH] D90568: [clang] Add [is|set]Nested methods to NamespaceDecl

2022-11-10 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added inline comments.



Comment at: clang/lib/AST/ASTContext.cpp:8767-8770
 const_cast(*Context), Context->getTranslationUnitDecl(),
 /*Inline*/ false, SourceLocation(), SourceLocation(),
 &Context->Idents.get("std"),
+/*PrevDecl*/ nullptr, /*Nested*/ false);

Overriding my old comment from a while ago,



Comment at: clang/lib/AST/ASTContext.cpp:8957-8959
+   /*Inline*/ false, SourceLocation(),
SourceLocation(), &Context->Idents.get("std"),
+   /*PrevDecl*/ nullptr, /*Nested*/ false);





Comment at: clang/lib/AST/ItaniumMangle.cpp:605-607
 /*Inline*/ false, SourceLocation(), SourceLocation(),
 &getASTContext().Idents.get("std"),
+/*PrevDecl*/ nullptr, /*Nested*/ false);





Comment at: clang/lib/Sema/HLSLExternalSemaSource.cpp:386
+  AST, AST.getTranslationUnitDecl(), false, SourceLocation(),
+  SourceLocation(), &HLSL, PrevDecl, false);
   HLSLNamespace->setImplicit(true);




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90568

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


[PATCH] D90568: [clang] Add [is|set]Nested methods to NamespaceDecl

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

Generally LGTM, though I found a few minor things.




Comment at: clang/include/clang/AST/Decl.h:546
+
+  enum Flags : unsigned { F_Inline = 1 << 0, F_Nested = 1 << 1 };
+

I'm not really loving the `F_` prefixes -- the enumerators are already 
privately scoped to `NamespaceDecl`, is that not sufficient protection?



Comment at: clang/lib/AST/DeclCXX.cpp:2888
+  AnonOrFirstNamespaceAndFlags(nullptr,
+   F_Inline * Inline | F_Nested * Nested) {
   setPreviousDecl(PrevDecl);

I love it and hate it in equal measures; I think multiplying a bool and an 
enumerator together is just a bit too clever. How about:
```
unsigned Flags = 0;
if (Inline) Flags |= F_Inline;
if (Nested) Flags |= F_Nested;
AnonOrFirstNamespaceAndFlags(nullptr, Flags);
```
It's longer, but I think it's also more clear.



Comment at: clang/lib/AST/ItaniumMangle.cpp:602-607
   if (!StdNamespace) {
 StdNamespace = NamespaceDecl::Create(
 getASTContext(), getASTContext().getTranslationUnitDecl(),
 /*Inline*/ false, SourceLocation(), SourceLocation(),
 &getASTContext().Idents.get("std"),
+/*PrevDecl*/ nullptr, /*Nested*/ false);

Not your problem, but I'm curious if you agree: we should probably have a 
helper method for getting the `std` namespace (and creating it if necessary) so 
we don't do this dance in at least three different places.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90568

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


[PATCH] D90568: [clang] Add [is|set]Nested methods to NamespaceDecl

2021-02-19 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

Ping?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90568

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


[PATCH] D90568: [clang] Add [is|set]Nested methods to NamespaceDecl

2020-11-19 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

Ping?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90568

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


[PATCH] D90568: [clang] Add [is|set]Nested methods to NamespaceDecl

2020-11-03 Thread Mark de Wever via Phabricator via cfe-commits
Mordante added a comment.

In D90568#2370079 , @njames93 wrote:

> Added JsonNodeDumper and argument comments.

Thanks, I've no further comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90568

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


[PATCH] D90568: [clang] Add [is|set]Nested methods to NamespaceDecl

2020-11-02 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 302437.
njames93 added a comment.

Added JsonNodeDumper and argument comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90568

Files:
  clang/include/clang/AST/Decl.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/DeclCXX.cpp
  clang/lib/AST/JSONNodeDumper.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/test/AST/ast-dump-decl.cpp
  clang/test/AST/ast-dump-namespace-json.cpp
  clang/unittests/Sema/ExternalSemaSourceTest.cpp

Index: clang/unittests/Sema/ExternalSemaSourceTest.cpp
===
--- clang/unittests/Sema/ExternalSemaSourceTest.cpp
+++ clang/unittests/Sema/ExternalSemaSourceTest.cpp
@@ -121,7 +121,7 @@
   CurrentSema->getPreprocessor().getIdentifierInfo(CorrectTo);
   NamespaceDecl *NewNamespace =
   NamespaceDecl::Create(Context, DestContext, false, Typo.getBeginLoc(),
-Typo.getLoc(), ToIdent, nullptr);
+Typo.getLoc(), ToIdent, nullptr, false);
   DestContext->addDecl(NewNamespace);
   TypoCorrection Correction(ToIdent);
   Correction.addCorrectionDecl(NewNamespace);
Index: clang/test/AST/ast-dump-namespace-json.cpp
===
--- clang/test/AST/ast-dump-namespace-json.cpp
+++ clang/test/AST/ast-dump-namespace-json.cpp
@@ -146,6 +146,7 @@
 // CHECK-NEXT:   }
 // CHECK-NEXT:  },
 // CHECK-NEXT:  "name": "baz",
+// CHECK-NEXT:  "isNested": true,
 // CHECK-NEXT:  "inner": [
 // CHECK-NEXT:   {
 // CHECK-NEXT:"id": "0x{{.*}}",
@@ -196,6 +197,7 @@
 // CHECK-NEXT:   }
 // CHECK-NEXT:  },
 // CHECK-NEXT:  "name": "quux",
+// CHECK-NEXT:  "isNested": true,
 // CHECK-NEXT:  "inner": [
 // CHECK-NEXT:   {
 // CHECK-NEXT:"id": "0x{{.*}}",
Index: clang/test/AST/ast-dump-decl.cpp
===
--- clang/test/AST/ast-dump-decl.cpp
+++ clang/test/AST/ast-dump-decl.cpp
@@ -53,6 +53,23 @@
 }
 // CHECK:  NamespaceDecl{{.*}} TestNamespaceDeclInline inline
 
+namespace TestNestedNameSpace::Nested {
+}
+// CHECK:  NamespaceDecl{{.*}} TestNestedNameSpace nested
+// CHECK:  NamespaceDecl{{.*}} Nested{{\s*$}}
+
+namespace TestMultipleNested::SecondLevelNested::Nested {
+}
+// CHECK:  NamespaceDecl{{.*}} TestMultipleNested nested
+// CHECK:  NamespaceDecl{{.*}} SecondLevelNested nested
+// CHECK:  NamespaceDecl{{.*}} Nested{{\s*$}}
+
+namespace TestInlineNested::inline SecondLevel::inline Nested {
+}
+// CHECK:  NamespaceDecl{{.*}} TestInlineNested nested
+// CHECK:  NamespaceDecl{{.*}} SecondLevel inline nested
+// CHECK:  NamespaceDecl{{.*}} Nested inline{{\s*$}}
+
 namespace testUsingDirectiveDecl {
   namespace A {
   }
Index: clang/lib/Serialization/ASTWriterDecl.cpp
===
--- clang/lib/Serialization/ASTWriterDecl.cpp
+++ clang/lib/Serialization/ASTWriterDecl.cpp
@@ -1234,6 +1234,7 @@
   VisitRedeclarable(D);
   VisitNamedDecl(D);
   Record.push_back(D->isInline());
+  Record.push_back(D->isNested());
   Record.AddSourceLocation(D->getBeginLoc());
   Record.AddSourceLocation(D->getRBraceLoc());
 
Index: clang/lib/Serialization/ASTReaderDecl.cpp
===
--- clang/lib/Serialization/ASTReaderDecl.cpp
+++ clang/lib/Serialization/ASTReaderDecl.cpp
@@ -1594,6 +1594,7 @@
   RedeclarableResult Redecl = VisitRedeclarable(D);
   VisitNamedDecl(D);
   D->setInline(Record.readInt());
+  D->setNested(Record.readInt());
   D->LocStart = readSourceLocation();
   D->RBraceLoc = readSourceLocation();
 
@@ -1607,7 +1608,7 @@
   } else {
 // Link this namespace back to the first declaration, which has already
 // been deserialized.
-D->AnonOrFirstNamespaceAndInline.setPointer(D->getFirstDecl());
+D->AnonOrFirstNamespaceAndFlags.setPointer(D->getFirstDecl());
   }
 
   mergeRedeclarable(D, Redecl);
@@ -2594,8 +2595,8 @@
 // We cannot have loaded any redeclarations of this declaration yet, so
 // there's nothing else that needs to be updated.
 if (auto *Namespace = dyn_cast(D))
-  Namespace->AnonOrFirstNamespaceAndInline.setPointer(
-  assert_cast(ExistingCanon));
+  Namespace->AnonOrFirstNamespaceAndFlags.setPointer(
+  assert_cast(ExistingCanon));
 
 // When we merge a template, merge its pattern.
 if (auto *DTemplate = dyn_cast(D))
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -

[PATCH] D90568: [clang] Add [is|set]Nested methods to NamespaceDecl

2020-11-02 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added inline comments.



Comment at: clang/lib/AST/ASTContext.cpp:7866
SourceLocation(), &Context->Idents.get("std"),
-   /*PrevDecl*/ nullptr);
+   /*PrevDecl*/ nullptr, false);
 NS->setImplicit();

As noted elsewhere instead of just `false` please use `/*Nested*/ false`

Also a little below.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90568

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


[PATCH] D90568: [clang] Add [is|set]Nested methods to NamespaceDecl

2020-11-02 Thread Mark de Wever via Phabricator via cfe-commits
Mordante added a comment.

Just a few minor nits. I'll leave the approving to the other reviewers.




Comment at: clang/lib/AST/TextNodeDumper.cpp:1828
+  if (D->isNested())
+OS << " nested";
   if (!D->isOriginalNamespace())

Can you also modify `JSONNodeDumper::VisitNamespaceDecl` ?



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:11169
+&PP.getIdentifierTable().get("std"),
+/*PrevDecl=*/nullptr, false);
 getStdNamespace()->setImplicit(true);

Please change `false` to `/*Nested=*/false`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90568

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


[PATCH] D90568: [clang] Add [is|set]Nested methods to NamespaceDecl

2020-11-01 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added a reviewer: rsmith.
Herald added subscribers: cfe-commits, martong.
Herald added a reviewer: shafik.
Herald added a project: clang.
njames93 requested review of this revision.

Adds support for NamespaceDecl to inform if its part of a nested namespace.
This flag only corresponds to the outer namespaces in a nested namespace 
declaration.
In this example:
namespace  {}
Only  and  will be classified as nested.

This flag isn't meant for assisting in building the AST, more for static 
analysis and refactorings.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D90568

Files:
  clang/include/clang/AST/Decl.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/DeclCXX.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/test/AST/ast-dump-decl.cpp
  clang/unittests/Sema/ExternalSemaSourceTest.cpp

Index: clang/unittests/Sema/ExternalSemaSourceTest.cpp
===
--- clang/unittests/Sema/ExternalSemaSourceTest.cpp
+++ clang/unittests/Sema/ExternalSemaSourceTest.cpp
@@ -121,7 +121,7 @@
   CurrentSema->getPreprocessor().getIdentifierInfo(CorrectTo);
   NamespaceDecl *NewNamespace =
   NamespaceDecl::Create(Context, DestContext, false, Typo.getBeginLoc(),
-Typo.getLoc(), ToIdent, nullptr);
+Typo.getLoc(), ToIdent, nullptr, false);
   DestContext->addDecl(NewNamespace);
   TypoCorrection Correction(ToIdent);
   Correction.addCorrectionDecl(NewNamespace);
Index: clang/test/AST/ast-dump-decl.cpp
===
--- clang/test/AST/ast-dump-decl.cpp
+++ clang/test/AST/ast-dump-decl.cpp
@@ -53,6 +53,23 @@
 }
 // CHECK:  NamespaceDecl{{.*}} TestNamespaceDeclInline inline
 
+namespace TestNestedNameSpace::Nested {
+}
+// CHECK:  NamespaceDecl{{.*}} TestNestedNameSpace nested
+// CHECK:  NamespaceDecl{{.*}} Nested{{\s*$}}
+
+namespace TestMultipleNested::SecondLevelNested::Nested {
+}
+// CHECK:  NamespaceDecl{{.*}} TestMultipleNested nested
+// CHECK:  NamespaceDecl{{.*}} SecondLevelNested nested
+// CHECK:  NamespaceDecl{{.*}} Nested{{\s*$}}
+
+namespace TestInlineNested::inline SecondLevel::inline Nested{
+}
+// CHECK:  NamespaceDecl{{.*}} TestInlineNested nested
+// CHECK:  NamespaceDecl{{.*}} SecondLevel inline nested
+// CHECK:  NamespaceDecl{{.*}} Nested inline{{\s*$}}
+
 namespace testUsingDirectiveDecl {
   namespace A {
   }
Index: clang/lib/Serialization/ASTWriterDecl.cpp
===
--- clang/lib/Serialization/ASTWriterDecl.cpp
+++ clang/lib/Serialization/ASTWriterDecl.cpp
@@ -1234,6 +1234,7 @@
   VisitRedeclarable(D);
   VisitNamedDecl(D);
   Record.push_back(D->isInline());
+  Record.push_back(D->isNested());
   Record.AddSourceLocation(D->getBeginLoc());
   Record.AddSourceLocation(D->getRBraceLoc());
 
Index: clang/lib/Serialization/ASTReaderDecl.cpp
===
--- clang/lib/Serialization/ASTReaderDecl.cpp
+++ clang/lib/Serialization/ASTReaderDecl.cpp
@@ -1594,6 +1594,7 @@
   RedeclarableResult Redecl = VisitRedeclarable(D);
   VisitNamedDecl(D);
   D->setInline(Record.readInt());
+  D->setNested(Record.readInt());
   D->LocStart = readSourceLocation();
   D->RBraceLoc = readSourceLocation();
 
@@ -1607,7 +1608,7 @@
   } else {
 // Link this namespace back to the first declaration, which has already
 // been deserialized.
-D->AnonOrFirstNamespaceAndInline.setPointer(D->getFirstDecl());
+D->AnonOrFirstNamespaceAndFlags.setPointer(D->getFirstDecl());
   }
 
   mergeRedeclarable(D, Redecl);
@@ -2594,8 +2595,8 @@
 // We cannot have loaded any redeclarations of this declaration yet, so
 // there's nothing else that needs to be updated.
 if (auto *Namespace = dyn_cast(D))
-  Namespace->AnonOrFirstNamespaceAndInline.setPointer(
-  assert_cast(ExistingCanon));
+  Namespace->AnonOrFirstNamespaceAndFlags.setPointer(
+  assert_cast(ExistingCanon));
 
 // When we merge a template, merge its pattern.
 if (auto *DTemplate = dyn_cast(D))
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -10824,10 +10824,13 @@
 
 /// ActOnStartNamespaceDef - This is called at the start of a namespace
 /// definition.
-Decl *Sema::ActOnStartNamespaceDef(
-Scope *NamespcScope, SourceLocation InlineLoc, SourceLocation NamespaceLoc,
-SourceLocation IdentLoc, IdentifierInfo *II, SourceLocation LBrace,
-const ParsedAttributesView