[PATCH] D146802: [Documentation] improved documentation of diagnostic messages by explaining thier syntax and test of clang by telling which subobject is uninitialized

2023-03-24 Thread suman meena via Phabricator via cfe-commits
simideveloper created this revision.
Herald added a project: All.
simideveloper requested review of this revision.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146802

Files:
  clang/include/clang/Basic/DiagnosticASTKinds.td
  clang/lib/AST/Interp/Interp.cpp
  clang/test/AST/Interp/cxx20.cpp
  clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p4.cpp
  clang/test/SemaCXX/attr-require-constant-initialization.cpp
  clang/test/SemaCXX/constant-expression-cxx2a.cpp
  clang/test/SemaCXX/cxx2a-consteval.cpp

Index: clang/test/SemaCXX/cxx2a-consteval.cpp
===
--- clang/test/SemaCXX/cxx2a-consteval.cpp
+++ clang/test/SemaCXX/cxx2a-consteval.cpp
@@ -761,7 +761,7 @@
 };
 
 S s1; // expected-error {{call to consteval function 'NamespaceScopeConsteval::S::S' is not a constant expression}} \
- expected-note {{subobject of type 'int' is not initialized}}
+ expected-note {{subobject Val is not initialized}}
 
 template 
 struct T {
@@ -770,7 +770,7 @@
 };
 
 T t; // expected-error {{call to consteval function 'NamespaceScopeConsteval::T::T' is not a constant expression}} \
- expected-note {{subobject of type 'int' is not initialized}}
+ expected-note {{subobject Val is not initialized}}
 
 } // namespace NamespaceScopeConsteval
 
Index: clang/test/SemaCXX/constant-expression-cxx2a.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx2a.cpp
+++ clang/test/SemaCXX/constant-expression-cxx2a.cpp
@@ -409,12 +409,12 @@
 b.a.x = 2;
 return b;
   }
-  constexpr B uninit = return_uninit(); // expected-error {{constant expression}} expected-note {{subobject of type 'int' is not initialized}}
+  constexpr B uninit = return_uninit(); // expected-error {{constant expression}} expected-note {{subobject  arr and p or q  is not initialized}}
   static_assert(return_uninit().a.x == 2);
   constexpr A return_uninit_struct() {
 B b = {.b = 1};
 b.a.x = 2;
-return b.a; // expected-note {{in call to 'A(b.a)'}} expected-note {{subobject of type 'int' is not initialized}}
+return b.a; // expected-note {{in call to 'A(b.a)'}} expected-note {{subobject arr and p or q is not initialized}}
   }
   // Note that this is rejected even though return_uninit() is accepted, and
   // return_uninit() copies the same stuff wrapped in a union.
@@ -558,7 +558,7 @@
 }
   };
   constinit X x1(true);
-  constinit X x2(false); // expected-error {{constant initializer}} expected-note {{constinit}} expected-note {{subobject of type 'int' is not initialized}}
+  constinit X x2(false); // expected-error {{constant initializer}} expected-note {{constinit}} expected-note {{subobject n is not initialized}}
 
   struct Y {
 struct Z { int n; }; // expected-note {{here}}
@@ -577,7 +577,7 @@
   };
   // FIXME: This is working around clang not implementing DR2026. With that
   // fixed, we should be able to test this without the injected copy.
-  constexpr Y copy(Y y) { return y; } // expected-note {{in call to 'Y(y)'}} expected-note {{subobject of type 'int' is not initialized}}
+  constexpr Y copy(Y y) { return y; } // expected-note {{in call to 'Y(y)'}} expected-note {{subobject z1.n is not initialized}}
   constexpr Y y1 = copy(Y());
   static_assert(y1.z1.n == 1 && y1.z2.n == 2 && y1.z3.n == 3);
 
Index: clang/test/SemaCXX/attr-require-constant-initialization.cpp
===
--- clang/test/SemaCXX/attr-require-constant-initialization.cpp
+++ clang/test/SemaCXX/attr-require-constant-initialization.cpp
@@ -152,7 +152,7 @@
 #else
   ATTR static PODType pod; // expected-error {{variable does not have a constant initializer}}
 // expected-note@-1 {{required by 'require_constant_initialization' attribute here}}
-// expected-note-re@-2 non-constexpr constructor|subobject of type 'int' is not initialized
+// expected-note-re@-2 non-constexpr constructor|subobject value and value2 is not initialized
 #endif
   ATTR static PODType pot2 = {ReturnInt()}; // expected-error {{variable does not have a constant initializer}}
 // expected-note@-1 {{required by 'require_constant_initialization' attribute here}}
@@ -191,7 +191,7 @@
 PODType TT2::pod_noinit; // expected-note 0+ {{declared here}}
 #if __cplusplus >= 201103L
 // expected-error@-2 {{variable does not have a constant initializer}}
-// expected-note-re@-3 non-constexpr constructor|subobject of type 'int' is not initialized
+// expected-note-re@-3 non-constexpr constructor|subobject value and value2 is not initialized
 #endif
 PODType TT2::pod_copy_init(TT2::pod_noinit); // expected-error {{variable does not have a constant initializer}}
 #if __cplusplus >= 201103L
Index: clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p4.cpp
===

[PATCH] D146802: [Documentation] improved documentation of diagnostic messages by explaining thier syntax and test of clang by telling which subobject is uninitialized

2023-03-24 Thread suman meena via Phabricator via cfe-commits
simideveloper added a comment.

Oh sorry, I was unaware of the existing documentation.
thank you for your time, sir.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146802

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


[PATCH] D146867: [Diagnostic] printing name of uninitialized subobject instead of its type

2023-03-25 Thread suman meena via Phabricator via cfe-commits
simideveloper created this revision.
Herald added a project: All.
simideveloper requested review of this revision.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146867

Files:
  clang/include/clang/Basic/DiagnosticASTKinds.td
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/Interp/Interp.cpp

Index: clang/lib/AST/Interp/Interp.cpp
===
--- clang/lib/AST/Interp/Interp.cpp
+++ clang/lib/AST/Interp/Interp.cpp
@@ -369,9 +369,9 @@
 }
 
 static void DiagnoseUninitializedSubobject(InterpState &S, const SourceInfo &SI,
-   QualType SubObjType,
+   StringRef SubObjName,
SourceLocation SubObjLoc) {
-  S.FFDiag(SI, diag::note_constexpr_uninitialized) << true << SubObjType;
+  S.FFDiag(SI, diag::note_constexpr_uninitialized) << true << SubObjName;
   if (SubObjLoc.isValid())
 S.Note(SubObjLoc, diag::note_constexpr_subobject_declared_here);
 }
@@ -400,7 +400,7 @@
   } else {
 for (size_t I = 0; I != NumElems; ++I) {
   if (!BasePtr.atIndex(I).isInitialized()) {
-DiagnoseUninitializedSubobject(S, S.Current->getSource(OpPC), ElemType,
+DiagnoseUninitializedSubobject(S, S.Current->getSource(OpPC), BasePtr.getElemRecord()->getName(),
BasePtr.getFieldDesc()->getLocation());
 Result = false;
   }
@@ -427,7 +427,7 @@
   Result &= CheckArrayInitialized(S, OpPC, FieldPtr, CAT);
 } else if (!FieldPtr.isInitialized()) {
   DiagnoseUninitializedSubobject(S, S.Current->getSource(OpPC),
- F.Decl->getType(), F.Decl->getLocation());
+ F.Decl->getName(), F.Decl->getLocation());
   Result = false;
 }
   }
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -2119,7 +2119,7 @@
   EvalInfo &Info, SourceLocation DiagLoc,
   QualType Type, const APValue &Value,
   ConstantExprKind Kind,
-  SourceLocation SubobjectLoc,
+  const FieldDecl* SubobjectDecl,
   CheckedTemporaries &CheckedTemps);
 
 /// Check that this reference or pointer core constant expression is a valid
@@ -2267,7 +2267,7 @@
   assert(V && "evasluation result refers to uninitialised temporary");
   if (!CheckEvaluationResult(CheckEvaluationResultKind::ConstantExpression,
  Info, MTE->getExprLoc(), TempType, *V,
- Kind, SourceLocation(), CheckedTemps))
+ Kind,  /*SubobjectDecl=*/nullptr, CheckedTemps))
 return false;
 }
   }
@@ -2350,13 +2350,13 @@
   EvalInfo &Info, SourceLocation DiagLoc,
   QualType Type, const APValue &Value,
   ConstantExprKind Kind,
-  SourceLocation SubobjectLoc,
+  const FieldDecl* SubobjectDecl,
   CheckedTemporaries &CheckedTemps) {
-  if (!Value.hasValue()) {
+  if ((!Value.hasValue())&& SubobjectDecl!=nullptr) {
 Info.FFDiag(DiagLoc, diag::note_constexpr_uninitialized)
-  << true << Type;
-if (SubobjectLoc.isValid())
-  Info.Note(SubobjectLoc, diag::note_constexpr_subobject_declared_here);
+  << true << SubobjectDecl->getName();
+if (SubobjectDecl->getLocation().isValid())
+  Info.Note(SubobjectDecl->getLocation(), diag::note_constexpr_subobject_declared_here);
 return false;
   }
 
@@ -2372,20 +2372,20 @@
 QualType EltTy = Type->castAsArrayTypeUnsafe()->getElementType();
 for (unsigned I = 0, N = Value.getArrayInitializedElts(); I != N; ++I) {
   if (!CheckEvaluationResult(CERK, Info, DiagLoc, EltTy,
- Value.getArrayInitializedElt(I), Kind,
- SubobjectLoc, CheckedTemps))
+ Value.getArrayInitializedElt(I), Kind,SubobjectDecl
+ , CheckedTemps))
 return false;
 }
 if (!Value.hasArrayFiller())
   return true;
 return CheckEvaluationResult(CERK, Info, DiagLoc, EltTy,
- Value.getArrayFiller(), Kind, SubobjectLoc,
+ Value.getArrayFiller(), Kind, SubobjectDecl,
  CheckedTemps);
   }
   if (Value.isUnion() && Value.getUnionField()) {
 return CheckEvaluationResult(
 CERK, Info, DiagLoc, Value.getUnionField()->getType(),
-Value.getUnion

[PATCH] D146867: [Diagnostic] printing name of uninitialized subobject instead of its type

2023-03-25 Thread suman meena via Phabricator via cfe-commits
simideveloper added a comment.

I am an outreachy applicant and working on this issue for the past some weeks 
for my contribution on the community page till that time this issue was listed 
on the introductory issues list on the outreachy page I thought this issue is 
still open but was not aware of someone working sorry it's my bad if it's 
already solved.




Comment at: clang/include/clang/Basic/DiagnosticASTKinds.td:9
 
-//understanding syntax of diagnostics messages===//
-//keyword after def represents symbolic constant for that diagnostics 

junaire wrote:
> Why delete these? Looks like unrelated changes.
I submitted another review for documentation on diagnostic in which I added 
these comments but it was not relevant so I removed it 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146867

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


[PATCH] D146867: [Diagnostic] printing name of uninitialized subobject instead of its type

2023-03-25 Thread suman meena via Phabricator via cfe-commits
simideveloper added a comment.

can you please tell me if this issue is closed or I can work on making the 
changes you recommended?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146867

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


[PATCH] D146867: [Diagnostic] printing name of uninitialized subobject instead of its type

2023-03-27 Thread suman meena via Phabricator via cfe-commits
simideveloper added a comment.

but I think this patch https://reviews.llvm.org/D146358 has not been accepted 
yet so you should give me a chance.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146867

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


[PATCH] D146867: [Diagnostic] printing name of uninitialized subobject instead of its type

2023-03-27 Thread suman meena via Phabricator via cfe-commits
simideveloper added a comment.

okk thankyou sir


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146867

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


[PATCH] D146358: [clang][AST] Print name instead of type when diagnosing uninitialized subobject in constexpr variables

2023-03-29 Thread suman meena via Phabricator via cfe-commits
simideveloper added a comment.

hey, I was working on the same issue so can we collaborate on this issue?


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

https://reviews.llvm.org/D146358

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


[PATCH] D146358: [clang][AST] Print name instead of type when diagnosing uninitialized subobject in constexpr variables

2023-03-29 Thread suman meena via Phabricator via cfe-commits
simideveloper added a comment.

ok, no problem and thanks for those further issues @hazohelet


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

https://reviews.llvm.org/D146358

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