[PATCH] D119017: [clang] roll-forward "[clang] Mark `trivial_abi` types as "trivially relocatable"".

2022-03-18 Thread Soumi Manna via Phabricator via cfe-commits
Manna added a comment.
Herald added a project: All.

LIT test (SemaCXX/attr-trivial-abi.cpp) is failing for x86 build of clang. The 
same failures are happening with our downstream X86 clang build.

- TEST 'Clang :: SemaCXX/attr-trivial-abi.cpp' FAILED 

Script:
---

: 'RUN: at line 1';   ...\llorg\builds\llorgx86winefi2_prod\llvm\bin\clang.exe 
-cc1 -internal-isystem 
.../llorg\builds\llorgx86winefi2_prod\llvm\lib\clang\15.0.0\include 
-nostdsysteminc -fsyntax-only -verify 
...\llorg\llvm\clang\test\SemaCXX\attr-trivial-abi.cpp -std=c++11
-

Exit Code: 1Command Output (stdout):


$ ":" "RUN: at line 1"
$ "\llorg\builds\llorgx86winefi2_prod\llvm\bin\clang.exe" "-cc1" 
"-internal-isystem" 
"...\llorg\builds\llorgx86winefi2_prod\llvm\lib\clang\15.0.0\include" 
"-nostdsysteminc" "-fsyntax-only" "-verify" 
"\llorg\llvm\clang\test\SemaCXX\attr-trivial-abi.cpp" "-std=c++11"

command stderr:
===

error: 'error' diagnostics seen but not expected:

  File ...\llorg\llvm\clang\test\SemaCXX\attr-trivial-abi.cpp Line 13: 
static_assert failed due to requirement '!__is_trivially_relocatable(a)' ""
  File \llorg\llvm\clang\test\SemaCXX\attr-trivial-abi.cpp Line 141: 
static_assert failed due to requirement 
'!__is_trivially_relocatable(deletedCopyMoveConstructor::CopyDeleted)' ""
  File \llorg\llvm\clang\test\SemaCXX\attr-trivial-abi.cpp Line 167: 
static_assert failed due to requirement 
'!__is_trivially_relocatable(deletedCopyMoveConstructor::S20)' ""

3 errors generated. error: command failed with exit status: 
1--



Failed Tests (1):

  Clang :: SemaCXX/attr-trivial-abi.cpp

Testing Time: 2.11s

  Failed: 1

The test might need to be updated so that shouldn't run with x86 build. 
@devin.jeanpierre, could you please look at the test failures? Thanks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119017

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


[PATCH] D119017: [clang] roll-forward "[clang] Mark `trivial_abi` types as "trivially relocatable"".

2022-03-18 Thread Soumi Manna via Phabricator via cfe-commits
Manna added a comment.

In D119017#3392984 , 
@devin.jeanpierre wrote:

> In D119017#3392961 , @Manna wrote:
>
>> LIT test (SemaCXX/attr-trivial-abi.cpp) is failing for x86 build of clang. 
>> The same failures are happening with our downstream X86 clang build.
>> [...]
>> The test might need to be updated so that shouldn't run with x86 build. 
>> @devin.jeanpierre, could you please look at the test failures? Thanks
>
> A couple questions -- was that failure introduced by this change, or a 
> different change? Also, what target triple, so that I can reproduce? (New to 
> clang development...)
>
> (I am hoping that I'm not expected to roll back this change after it's been 
> in for a month.)

Thanks for the quick response!

>> was that failure introduced by this change, or a different change?

Yes, the failures were introduced by this change.

>> lf so, what target triple, so that I can reproduce? (New to clang 
>> development...)

You can reproduce the test failure if you checkout 32 bit clang compiler.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119017

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


[PATCH] D119017: [clang] roll-forward "[clang] Mark `trivial_abi` types as "trivially relocatable"".

2022-03-18 Thread Soumi Manna via Phabricator via cfe-commits
Manna added a comment.

In D119017#3392996 , 
@devin.jeanpierre wrote:

> In D119017#3392993 , @Manna wrote:
>
 lf so, what target triple, so that I can reproduce? (New to clang 
 development...)
>>
>> You can reproduce the test failure if you checkout 32 bit clang compiler.
>
> Please bear with me, how do I do this? :(

You can downloads an already built 32bit version of the compiler.

This is the link for the doc. You can look at paragraph "Using Visual Studio"
This is the command: cmake -DLLVM_ENABLE_PROJECTS=clang -G "Visual Studio 15 
2017" -A Win32 -Thost=x64 ..\llvm

This is the doc:Clang - Getting Started (llvm.org)
https://clang.llvm.org/get_started.html#:~:text=The%20following%20details%20setting%20up%20for%20and%20building,for%20information%20on%20running%20regression%20tests%20on%20Windows


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119017

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


[PATCH] D159474: [NFC][CLANG] Fix static analyzer bugs about unnecessary object copies with auto

2023-09-28 Thread Soumi Manna via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG06c9cc7eaa8a: [NFC][CLANG] Fix static analyzer bugs about 
unnecessary object copies with auto (authored by Manna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D159474

Files:
  clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
  clang/lib/Analysis/UnsafeBufferUsage.cpp
  clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp


Index: clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
===
--- clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
+++ clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
@@ -900,7 +900,7 @@
 return;
 
   Symbols.emplace_back(std::move(*Class));
-  for (const auto Base : Record.Bases)
+  for (const auto &Base : Record.Bases)
 serializeRelationship(RelationshipKind::InheritsFrom, Record, Base);
   if (!Record.ParentInformation.empty())
 serializeRelationship(RelationshipKind::MemberOf, Record,
@@ -914,7 +914,7 @@
 return;
 
   Symbols.emplace_back(std::move(*Class));
-  for (const auto Base : Record.Bases)
+  for (const auto &Base : Record.Bases)
 serializeRelationship(RelationshipKind::InheritsFrom, Record, Base);
   if (!Record.ParentInformation.empty())
 serializeRelationship(RelationshipKind::MemberOf, Record,
@@ -929,7 +929,7 @@
 
   Symbols.emplace_back(std::move(*Class));
 
-  for (const auto Base : Record.Bases)
+  for (const auto &Base : Record.Bases)
 serializeRelationship(RelationshipKind::InheritsFrom, Record, Base);
   if (!Record.ParentInformation.empty())
 serializeRelationship(RelationshipKind::MemberOf, Record,
@@ -944,7 +944,7 @@
 
   Symbols.emplace_back(std::move(*Class));
 
-  for (const auto Base : Record.Bases)
+  for (const auto &Base : Record.Bases)
 serializeRelationship(RelationshipKind::InheritsFrom, Record, Base);
   if (!Record.ParentInformation.empty())
 serializeRelationship(RelationshipKind::MemberOf, Record,
Index: clang/lib/Analysis/UnsafeBufferUsage.cpp
===
--- clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -2295,7 +2295,7 @@
   // Variables will be removed from `FixItsForVariable`:
   SmallVector ToErase;
 
-  for (auto [VD, Ignore] : FixItsForVariable) {
+  for (const auto &[VD, Ignore] : FixItsForVariable) {
 VarGrpRef Grp = VarGrpMgr.getGroupOfVar(VD);
 if (llvm::any_of(Grp,
  [&FixItsForVariable](const VarDecl *GrpMember) -> bool {
Index: clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
===
--- clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
+++ clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
@@ -172,7 +172,7 @@
   SmallVector getBases(const CXXRecordDecl *Decl) {
 // FIXME: store AccessSpecifier given by inheritance
 SmallVector Bases;
-for (const auto BaseSpecifier : Decl->bases()) {
+for (const auto &BaseSpecifier : Decl->bases()) {
   // skip classes not inherited as public
   if (BaseSpecifier.getAccessSpecifier() != AccessSpecifier::AS_public)
 continue;


Index: clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
===
--- clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
+++ clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
@@ -900,7 +900,7 @@
 return;
 
   Symbols.emplace_back(std::move(*Class));
-  for (const auto Base : Record.Bases)
+  for (const auto &Base : Record.Bases)
 serializeRelationship(RelationshipKind::InheritsFrom, Record, Base);
   if (!Record.ParentInformation.empty())
 serializeRelationship(RelationshipKind::MemberOf, Record,
@@ -914,7 +914,7 @@
 return;
 
   Symbols.emplace_back(std::move(*Class));
-  for (const auto Base : Record.Bases)
+  for (const auto &Base : Record.Bases)
 serializeRelationship(RelationshipKind::InheritsFrom, Record, Base);
   if (!Record.ParentInformation.empty())
 serializeRelationship(RelationshipKind::MemberOf, Record,
@@ -929,7 +929,7 @@
 
   Symbols.emplace_back(std::move(*Class));
 
-  for (const auto Base : Record.Bases)
+  for (const auto &Base : Record.Bases)
 serializeRelationship(RelationshipKind::InheritsFrom, Record, Base);
   if (!Record.ParentInformation.empty())
 serializeRelationship(RelationshipKind::MemberOf, Record,
@@ -944,7 +944,7 @@
 
   Symbols.emplace_back(std::move(*Class));
 
-  for (const auto Base : Record.Bases)
+  for (const auto &Base : Record.Bases)
 serializeRelationship(RelationshipKind::InheritsFrom, Record, Base);
   if (!Record.ParentInformation.empty())
 serializeRelationship(RelationshipKind::MemberOf, Record,
Index: clang/lib/Analysis/UnsafeBufferUsage.cpp
===

[PATCH] D157989: [NFC] Initialize pointer field

2023-08-15 Thread Soumi Manna via Phabricator via cfe-commits
Manna created this revision.
Manna added reviewers: aaron.ballman, tahonermann.
Herald added a subscriber: hiraditya.
Herald added a project: All.
Manna requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157989

Files:
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp


Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -931,7 +931,7 @@
   (void)OutlinedFnID;
 
   // Return value of the runtime offloading call.
-  Value *Return;
+  Value *Return = nullptr;
 
   // Arguments for the target kernel.
   SmallVector ArgsVector;


Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -931,7 +931,7 @@
   (void)OutlinedFnID;
 
   // Return value of the runtime offloading call.
-  Value *Return;
+  Value *Return = nullptr;
 
   // Arguments for the target kernel.
   SmallVector ArgsVector;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D157989: [NFC] Initialize pointer field

2023-08-15 Thread Soumi Manna via Phabricator via cfe-commits
Manna added a comment.

Thank you @tahonermann for reviews and feedbacks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157989

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


[PATCH] D157989: [NFC] Initialize pointer field

2023-08-16 Thread Soumi Manna via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbd1ddc5850b1: [NFC][OpenMP] Initialize pointer field 
(authored by Manna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157989

Files:
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp


Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -931,7 +931,7 @@
   (void)OutlinedFnID;
 
   // Return value of the runtime offloading call.
-  Value *Return;
+  Value *Return = nullptr;
 
   // Arguments for the target kernel.
   SmallVector ArgsVector;


Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -931,7 +931,7 @@
   (void)OutlinedFnID;
 
   // Return value of the runtime offloading call.
-  Value *Return;
+  Value *Return = nullptr;
 
   // Arguments for the target kernel.
   SmallVector ArgsVector;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D158227: [clang] EditedSource::applyRewrites - useless call

2023-08-17 Thread Soumi Manna via Phabricator via cfe-commits
Manna created this revision.
Manna added reviewers: RKSimon, aaron.ballman, tahonermann.
Herald added a project: All.
Manna requested review of this revision.
Herald added a project: clang.

Fixes https://github.com/llvm/llvm-project/issues/53426


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158227

Files:
  clang/lib/Edit/EditedSource.cpp


Index: clang/lib/Edit/EditedSource.cpp
===
--- clang/lib/Edit/EditedSource.cpp
+++ clang/lib/Edit/EditedSource.cpp
@@ -430,7 +430,7 @@
 if (offs == CurEnd) {
   StrVec += act.Text;
   CurLen += act.RemoveLen;
-  CurEnd.getWithOffset(act.RemoveLen);
+  CurEnd = CurEnd.getWithOffset(act.RemoveLen);
   continue;
 }
 


Index: clang/lib/Edit/EditedSource.cpp
===
--- clang/lib/Edit/EditedSource.cpp
+++ clang/lib/Edit/EditedSource.cpp
@@ -430,7 +430,7 @@
 if (offs == CurEnd) {
   StrVec += act.Text;
   CurLen += act.RemoveLen;
-  CurEnd.getWithOffset(act.RemoveLen);
+  CurEnd = CurEnd.getWithOffset(act.RemoveLen);
   continue;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D158285: [NFC][CLANG] Fix wrong orders of function arguments positions

2023-08-18 Thread Soumi Manna via Phabricator via cfe-commits
Manna created this revision.
Manna added reviewers: aaron.ballman, tahonermann.
Herald added subscribers: steakhal, martong.
Herald added a reviewer: NoQ.
Herald added a project: All.
Manna requested review of this revision.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158285

Files:
  clang/lib/AST/Interp/InterpBlock.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp


Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -1470,7 +1470,7 @@
 [SSE, State = this->State]() -> SymbolRef {
   if (SSE->getOpcode() == BO_Sub)
 return State->getSymbolManager().getSymSymExpr(
-SSE->getRHS(), BO_Sub, SSE->getLHS(), SSE->getType());
+SSE->getLHS(), BO_Sub, SSE->getRHS(), SSE->getType());
   return nullptr;
 },
 SSE->getType());
@@ -1531,7 +1531,7 @@
   if (!QueriedRangeSet) {
 const BinaryOperatorKind ROP =
 BinaryOperator::reverseComparisonOp(QueriedOP);
-SymSym = SymMgr.getSymSymExpr(RHS, ROP, LHS, T);
+SymSym = SymMgr.getSymSymExpr(LHS, ROP, RHS, T);
 QueriedRangeSet = getConstraint(State, SymSym);
   }
 
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -18097,7 +18097,7 @@
 break;
   case OMPC_allocate:
 Res = ActOnOpenMPAllocateClause(Data.DepModOrTailExpr, VarList, StartLoc,
-LParenLoc, ColonLoc, EndLoc);
+ColonLoc, LParenLoc, EndLoc);
 break;
   case OMPC_nontemporal:
 Res = ActOnOpenMPNontemporalClause(VarList, StartLoc, LParenLoc, EndLoc);
Index: clang/lib/AST/Interp/InterpBlock.cpp
===
--- clang/lib/AST/Interp/InterpBlock.cpp
+++ clang/lib/AST/Interp/InterpBlock.cpp
@@ -92,7 +92,7 @@
 #endif
 
 DeadBlock::DeadBlock(DeadBlock *&Root, Block *Blk)
-: Root(Root), B(Blk->Desc, Blk->IsStatic, Blk->IsExtern, /*isDead=*/true) {
+: Root(Root), B(Blk->Desc, Blk->IsExtern, Blk->IsStatic, /*isDead=*/true) {
   // Add the block to the chain of dead blocks.
   if (Root)
 Root->Prev = this;


Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -1470,7 +1470,7 @@
 [SSE, State = this->State]() -> SymbolRef {
   if (SSE->getOpcode() == BO_Sub)
 return State->getSymbolManager().getSymSymExpr(
-SSE->getRHS(), BO_Sub, SSE->getLHS(), SSE->getType());
+SSE->getLHS(), BO_Sub, SSE->getRHS(), SSE->getType());
   return nullptr;
 },
 SSE->getType());
@@ -1531,7 +1531,7 @@
   if (!QueriedRangeSet) {
 const BinaryOperatorKind ROP =
 BinaryOperator::reverseComparisonOp(QueriedOP);
-SymSym = SymMgr.getSymSymExpr(RHS, ROP, LHS, T);
+SymSym = SymMgr.getSymSymExpr(LHS, ROP, RHS, T);
 QueriedRangeSet = getConstraint(State, SymSym);
   }
 
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -18097,7 +18097,7 @@
 break;
   case OMPC_allocate:
 Res = ActOnOpenMPAllocateClause(Data.DepModOrTailExpr, VarList, StartLoc,
-LParenLoc, ColonLoc, EndLoc);
+ColonLoc, LParenLoc, EndLoc);
 break;
   case OMPC_nontemporal:
 Res = ActOnOpenMPNontemporalClause(VarList, StartLoc, LParenLoc, EndLoc);
Index: clang/lib/AST/Interp/InterpBlock.cpp
===
--- clang/lib/AST/Interp/InterpBlock.cpp
+++ clang/lib/AST/Interp/InterpBlock.cpp
@@ -92,7 +92,7 @@
 #endif
 
 DeadBlock::DeadBlock(DeadBlock *&Root, Block *Blk)
-: Root(Root), B(Blk->Desc, Blk->IsStatic, Blk->IsExtern, /*isDead=*/true) {
+: Root(Root), B(Blk->Desc, Blk->IsExtern, Blk->IsStatic, /*isDead=*/true) {
   // Add the block to the chain of dead blocks.
   if (Root)
 Root->Prev = this;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D158293: [NFC][CLANG] Fix potential dereferencing of null return values

2023-08-18 Thread Soumi Manna via Phabricator via cfe-commits
Manna created this revision.
Manna added reviewers: aaron.ballman, tahonermann.
Herald added projects: All, clang, clang-format.
Herald added reviewers: rymiel, HazardyKnusperkeks, owenpan, MyDeveloperDay.
Manna requested review of this revision.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158293

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Lex/PPDirectives.cpp


Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -547,7 +547,7 @@
   } SkippingRangeState(*this);
 
   while (true) {
-if (CurLexer->isDependencyDirectivesLexer()) {
+if (CurLexer && CurLexer->isDependencyDirectivesLexer()) {
   CurLexer->LexDependencyDirectiveTokenWhileSkipping(Tok);
 } else {
   SkippingRangeState.beginLexPass();
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2006,7 +2006,7 @@
   Current.setType(TT_LambdaArrow);
 } else if (Current.is(tok::arrow) && AutoFound &&
(Line.MightBeFunctionDecl || Line.InPPDirective) &&
-   Current.NestingLevel == 0 &&
+   Current.NestingLevel == 0 && Current.Previous &&
!Current.Previous->isOneOf(tok::kw_operator, tok::identifier)) {
   // not auto operator->() -> xxx;
   Current.setType(TT_TrailingReturnArrow);


Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -547,7 +547,7 @@
   } SkippingRangeState(*this);
 
   while (true) {
-if (CurLexer->isDependencyDirectivesLexer()) {
+if (CurLexer && CurLexer->isDependencyDirectivesLexer()) {
   CurLexer->LexDependencyDirectiveTokenWhileSkipping(Tok);
 } else {
   SkippingRangeState.beginLexPass();
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2006,7 +2006,7 @@
   Current.setType(TT_LambdaArrow);
 } else if (Current.is(tok::arrow) && AutoFound &&
(Line.MightBeFunctionDecl || Line.InPPDirective) &&
-   Current.NestingLevel == 0 &&
+   Current.NestingLevel == 0 && Current.Previous &&
!Current.Previous->isOneOf(tok::kw_operator, tok::identifier)) {
   // not auto operator->() -> xxx;
   Current.setType(TT_TrailingReturnArrow);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D158295: [NFC][clang][analyzer] Avoid potential dereferencing of null pointer value

2023-08-18 Thread Soumi Manna via Phabricator via cfe-commits
Manna created this revision.
Manna added reviewers: aaron.ballman, tahonermann, steakhal.
Herald added subscribers: manas, ASDenysPetrov, martong, dkrupp, donat.nagy, 
Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun.
Herald added a reviewer: NoQ.
Herald added a project: All.
Manna requested review of this revision.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158295

Files:
  clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp


Index: 
clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
@@ -1425,7 +1425,10 @@
 
   // Fetch the new reference count from the state, and use it to handle
   // this symbol.
-  state = handleSymbolDeath(state, Sym, *getRefBinding(state, Sym), 
Leaked);
+  const RefVal* T = getRefBinding(state, Sym);
+  if (!T)
+return;
+  state = handleSymbolDeath(state, Sym, *T, Leaked);
 }
   }
 


Index: clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
@@ -1425,7 +1425,10 @@
 
   // Fetch the new reference count from the state, and use it to handle
   // this symbol.
-  state = handleSymbolDeath(state, Sym, *getRefBinding(state, Sym), Leaked);
+  const RefVal* T = getRefBinding(state, Sym);
+  if (!T)
+return;
+  state = handleSymbolDeath(state, Sym, *T, Leaked);
 }
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D158293: [NFC][Clang] Fix static code analyzer concern about null value dereference

2023-08-22 Thread Soumi Manna via Phabricator via cfe-commits
Manna updated this revision to Diff 552347.
Manna retitled this revision from "[NFC][CLANG] Fix potential dereferencing of 
null return values" to "[NFC][Clang] Fix static code analyzer concern about 
null value dereference".
Manna added a comment.
Herald added subscribers: manas, ASDenysPetrov, dkrupp, donat.nagy, Szelethus, 
a.sidorin, baloghadamsoftware.

CurLexer is dereferenced and should not be null in 
clang::​Preprocessor::​SkipExcludedConditionalBlock(clang::​SourceLocation, 
clang::​SourceLocation, bool, bool, clang::​SourceLocation)

This patch adds  NULL value check for pointer CurLexer.


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

https://reviews.llvm.org/D158293

Files:
  clang/lib/Lex/PPDirectives.cpp


Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -547,7 +547,7 @@
   } SkippingRangeState(*this);
 
   while (true) {
-if (CurLexer->isDependencyDirectivesLexer()) {
+if (CurLexer && CurLexer->isDependencyDirectivesLexer()) {
   CurLexer->LexDependencyDirectiveTokenWhileSkipping(Tok);
 } else {
   SkippingRangeState.beginLexPass();


Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -547,7 +547,7 @@
   } SkippingRangeState(*this);
 
   while (true) {
-if (CurLexer->isDependencyDirectivesLexer()) {
+if (CurLexer && CurLexer->isDependencyDirectivesLexer()) {
   CurLexer->LexDependencyDirectiveTokenWhileSkipping(Tok);
 } else {
   SkippingRangeState.beginLexPass();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D158293: [NFC][Clang] Fix static code analyzer concern about null value dereference

2023-08-22 Thread Soumi Manna via Phabricator via cfe-commits
Manna added inline comments.



Comment at: clang/lib/Format/TokenAnnotator.cpp:2009-2010
(Line.MightBeFunctionDecl || Line.InPPDirective) &&
-   Current.NestingLevel == 0 &&
+   Current.NestingLevel == 0 && Current.Previous &&
!Current.Previous->isOneOf(tok::kw_operator, tok::identifier)) {
   // not auto operator->() -> xxx;

owenpan wrote:
> tahonermann wrote:
> > owenpan wrote:
> > > `Current.Previous` can't be null here because `AutoFound` is `true`.
> > Could you please elaborate on why you believe it is safe to move the check 
> > of `Current.Previous` inside the body of the `if` statement? Doing so will 
> > short circuit the remaining `else if` cases such that `Current.setType()` 
> > will not be called at all. It isn't obvious to me that those cases should 
> > not be considered if the previous token was not one of `kw_operator` or 
> > `identifier`. This looks like it has potential to change behavior.
> > 
> > The change that was originally proposed is clearly safe.
> > Could you please elaborate on why you believe it is safe to move the check 
> > of `Current.Previous` inside the body of the `if` statement? Doing so will 
> > short circuit the remaining `else if` cases such that `Current.setType()` 
> > will not be called at all. It isn't obvious to me that those cases should 
> > not be considered if the previous token was not one of `kw_operator` or 
> > `identifier`. This looks like it has potential to change behavior.
> 
> Ahh, you are right.
> 
> > The change that was originally proposed is clearly safe.
> 
> My point that `Previous` can't be null still stands. So we should either make 
> no changes here or add an assertion just before the `if` statement at line 
> 1991 above.
Thank you @owenpan and @tahonermann for reviews and feedbacks, I have removed 
my previous change since Current.Previous can't be null here.


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

https://reviews.llvm.org/D158293

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


[PATCH] D158227: [clang] EditedSource::applyRewrites - useless call

2023-08-22 Thread Soumi Manna via Phabricator via cfe-commits
Manna added a comment.

Thank you @aaron.ballman for reviews and feedbacks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158227

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


[PATCH] D158522: [NFC][CLANG] Fix static analyzer bugs about large copy by values

2023-08-22 Thread Soumi Manna via Phabricator via cfe-commits
Manna created this revision.
Manna added reviewers: aaron.ballman, tahonermann.
Herald added subscribers: ctetreau, manas, ASDenysPetrov, dkrupp, donat.nagy, 
Szelethus, a.sidorin, baloghadamsoftware.
Herald added a project: All.
Manna requested review of this revision.
Herald added a project: clang.

Static Analyzer Tool complains about a large function call parameter which is 
is passed by value in CGBuiltin.cpp file.

1. In CodeGenFunction::​EmitSMELdrStr(clang::​SVETypeFlags, 
llvm::​SmallVectorImpl &, unsigned int): We are passing 
parameter TypeFlags of type clang::SVETypeFlags  by value.

2. In CodeGenFunction::​EmitSMEZero(clang::​SVETypeFlags, 
llvm::​SmallVectorImpl &, unsigned int): We are passing 
parameter TypeFlags of type clang::SVETypeFlags  by value.

3. In cCodeGenFunction::​EmitSMEReadWrite(clang::​SVETypeFlags, 
llvm::​SmallVectorImpl &, unsigned int): We are passing 
parameter TypeFlags of type clang::SVETypeFlags  by value.

4. In CodeGenFunction::​EmitSMELd1St1(clang::​SVETypeFlags, 
llvm::​SmallVectorImpl &, unsigned int): We are passing 
parameter TypeFlags of type clang::SVETypeFlags  by value.

I see many places in CGBuiltin.cpp file, we are passing parameter TypeFlags of 
type clang::SVETypeFlags by reference.

clang::SVETypeFlags inherits several other types: 
https://clang.llvm.org/doxygen/classclang_1_1SVETypeFlags-members.html

This patch passes parameter TypeFlags by reference instead of by value in the 
function.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158522

Files:
  clang/lib/CodeGen/CGBuiltin.cpp


Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -9515,7 +9515,7 @@
   return Builder.CreateAdd(Base, CastOffset, "tileslice");
 }
 
-Value *CodeGenFunction::EmitSMELd1St1(SVETypeFlags TypeFlags,
+Value *CodeGenFunction::EmitSMELd1St1(const SVETypeFlags &TypeFlags,
   SmallVectorImpl &Ops,
   unsigned IntID) {
   Ops[3] = EmitSVEPredicateCast(
@@ -9545,7 +9545,7 @@
   return Builder.CreateCall(F, NewOps);
 }
 
-Value *CodeGenFunction::EmitSMEReadWrite(SVETypeFlags TypeFlags,
+Value *CodeGenFunction::EmitSMEReadWrite(const SVETypeFlags &TypeFlags,
  SmallVectorImpl &Ops,
  unsigned IntID) {
   auto *VecTy = getSVEType(TypeFlags);
@@ -9562,7 +9562,7 @@
   return Builder.CreateCall(F, Ops);
 }
 
-Value *CodeGenFunction::EmitSMEZero(SVETypeFlags TypeFlags,
+Value *CodeGenFunction::EmitSMEZero(const SVETypeFlags &TypeFlags,
 SmallVectorImpl &Ops,
 unsigned IntID) {
   // svzero_za() intrinsic zeros the entire za tile and has no paramters.
@@ -9572,7 +9572,7 @@
   return Builder.CreateCall(F, Ops);
 }
 
-Value *CodeGenFunction::EmitSMELdrStr(SVETypeFlags TypeFlags,
+Value *CodeGenFunction::EmitSMELdrStr(const SVETypeFlags &TypeFlags,
   SmallVectorImpl &Ops,
   unsigned IntID) {
   Function *Cntsb = CGM.getIntrinsic(Intrinsic::aarch64_sme_cntsb);


Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -9515,7 +9515,7 @@
   return Builder.CreateAdd(Base, CastOffset, "tileslice");
 }
 
-Value *CodeGenFunction::EmitSMELd1St1(SVETypeFlags TypeFlags,
+Value *CodeGenFunction::EmitSMELd1St1(const SVETypeFlags &TypeFlags,
   SmallVectorImpl &Ops,
   unsigned IntID) {
   Ops[3] = EmitSVEPredicateCast(
@@ -9545,7 +9545,7 @@
   return Builder.CreateCall(F, NewOps);
 }
 
-Value *CodeGenFunction::EmitSMEReadWrite(SVETypeFlags TypeFlags,
+Value *CodeGenFunction::EmitSMEReadWrite(const SVETypeFlags &TypeFlags,
  SmallVectorImpl &Ops,
  unsigned IntID) {
   auto *VecTy = getSVEType(TypeFlags);
@@ -9562,7 +9562,7 @@
   return Builder.CreateCall(F, Ops);
 }
 
-Value *CodeGenFunction::EmitSMEZero(SVETypeFlags TypeFlags,
+Value *CodeGenFunction::EmitSMEZero(const SVETypeFlags &TypeFlags,
 SmallVectorImpl &Ops,
 unsigned IntID) {
   // svzero_za() intrinsic zeros the entire za tile and has no paramters.
@@ -9572,7 +9572,7 @@
   return Builder.CreateCall(F, Ops);
 }
 
-Value *CodeGenFunction::EmitSMELdrStr(SVETypeFlags TypeFlags,
+Value *CodeGenFunction::EmitSMELdrStr(const SVETypeFlags &TypeFlags,
   SmallVectorImpl &Ops,
   unsigned IntID) {
   Function *Cntsb = CGM.getIntrinsic(Intrinsic::aarch64_sme_cntsb);

[PATCH] D158522: [NFC][CLANG] Fix static analyzer bugs about large copy by values

2023-08-22 Thread Soumi Manna via Phabricator via cfe-commits
Manna added a comment.

In D158522#4607054 , @sdesmalen wrote:

> It indeed makes sense to pass these by reference.

Thank you @sdesmalen for reviews!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158522

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


[PATCH] D158522: [NFC][CLANG] Fix static analyzer bugs about large copy by values

2023-08-22 Thread Soumi Manna via Phabricator via cfe-commits
Manna updated this revision to Diff 552428.
Manna added a comment.

Fix build errors. I have updated CodeGenFunction.h as well.


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

https://reviews.llvm.org/D158522

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CodeGenFunction.h


Index: clang/lib/CodeGen/CodeGenFunction.h
===
--- clang/lib/CodeGen/CodeGenFunction.h
+++ clang/lib/CodeGen/CodeGenFunction.h
@@ -4292,16 +4292,16 @@
   unsigned IntID);
   llvm::Value *EmitAArch64SVEBuiltinExpr(unsigned BuiltinID, const CallExpr 
*E);
 
-  llvm::Value *EmitSMELd1St1(SVETypeFlags TypeFlags,
+  llvm::Value *EmitSMELd1St1(const SVETypeFlags &TypeFlags,
  llvm::SmallVectorImpl &Ops,
  unsigned IntID);
-  llvm::Value *EmitSMEReadWrite(SVETypeFlags TypeFlags,
+  llvm::Value *EmitSMEReadWrite(const SVETypeFlags &TypeFlags,
 llvm::SmallVectorImpl &Ops,
 unsigned IntID);
-  llvm::Value *EmitSMEZero(SVETypeFlags TypeFlags,
+  llvm::Value *EmitSMEZero(const SVETypeFlags &TypeFlags,
llvm::SmallVectorImpl &Ops,
unsigned IntID);
-  llvm::Value *EmitSMELdrStr(SVETypeFlags TypeFlags,
+  llvm::Value *EmitSMELdrStr(const SVETypeFlags &TypeFlags,
  llvm::SmallVectorImpl &Ops,
  unsigned IntID);
   llvm::Value *EmitAArch64SMEBuiltinExpr(unsigned BuiltinID, const CallExpr 
*E);
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -9515,7 +9515,7 @@
   return Builder.CreateAdd(Base, CastOffset, "tileslice");
 }
 
-Value *CodeGenFunction::EmitSMELd1St1(SVETypeFlags TypeFlags,
+Value *CodeGenFunction::EmitSMELd1St1(const SVETypeFlags &TypeFlags,
   SmallVectorImpl &Ops,
   unsigned IntID) {
   Ops[3] = EmitSVEPredicateCast(
@@ -9545,7 +9545,7 @@
   return Builder.CreateCall(F, NewOps);
 }
 
-Value *CodeGenFunction::EmitSMEReadWrite(SVETypeFlags TypeFlags,
+Value *CodeGenFunction::EmitSMEReadWrite(const SVETypeFlags &TypeFlags,
  SmallVectorImpl &Ops,
  unsigned IntID) {
   auto *VecTy = getSVEType(TypeFlags);
@@ -9562,7 +9562,7 @@
   return Builder.CreateCall(F, Ops);
 }
 
-Value *CodeGenFunction::EmitSMEZero(SVETypeFlags TypeFlags,
+Value *CodeGenFunction::EmitSMEZero(const SVETypeFlags &TypeFlags,
 SmallVectorImpl &Ops,
 unsigned IntID) {
   // svzero_za() intrinsic zeros the entire za tile and has no paramters.
@@ -9572,7 +9572,7 @@
   return Builder.CreateCall(F, Ops);
 }
 
-Value *CodeGenFunction::EmitSMELdrStr(SVETypeFlags TypeFlags,
+Value *CodeGenFunction::EmitSMELdrStr(const SVETypeFlags &TypeFlags,
   SmallVectorImpl &Ops,
   unsigned IntID) {
   Function *Cntsb = CGM.getIntrinsic(Intrinsic::aarch64_sme_cntsb);


Index: clang/lib/CodeGen/CodeGenFunction.h
===
--- clang/lib/CodeGen/CodeGenFunction.h
+++ clang/lib/CodeGen/CodeGenFunction.h
@@ -4292,16 +4292,16 @@
   unsigned IntID);
   llvm::Value *EmitAArch64SVEBuiltinExpr(unsigned BuiltinID, const CallExpr *E);
 
-  llvm::Value *EmitSMELd1St1(SVETypeFlags TypeFlags,
+  llvm::Value *EmitSMELd1St1(const SVETypeFlags &TypeFlags,
  llvm::SmallVectorImpl &Ops,
  unsigned IntID);
-  llvm::Value *EmitSMEReadWrite(SVETypeFlags TypeFlags,
+  llvm::Value *EmitSMEReadWrite(const SVETypeFlags &TypeFlags,
 llvm::SmallVectorImpl &Ops,
 unsigned IntID);
-  llvm::Value *EmitSMEZero(SVETypeFlags TypeFlags,
+  llvm::Value *EmitSMEZero(const SVETypeFlags &TypeFlags,
llvm::SmallVectorImpl &Ops,
unsigned IntID);
-  llvm::Value *EmitSMELdrStr(SVETypeFlags TypeFlags,
+  llvm::Value *EmitSMELdrStr(const SVETypeFlags &TypeFlags,
  llvm::SmallVectorImpl &Ops,
  unsigned IntID);
   llvm::Value *EmitAArch64SMEBuiltinExpr(unsigned BuiltinID, const CallExpr *E);
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -9515,7 +9515,7 @@
   return Builder.CreateAdd(Base, CastOffset, "tileslice");
 }
 
-Value *CodeGenFunction::EmitSMELd1St1(SVETypeFlags TypeFlags,
+Value *CodeGenFunction::EmitS

[PATCH] D158522: [NFC][CLANG] Fix static analyzer bugs about large copy by values

2023-08-22 Thread Soumi Manna via Phabricator via cfe-commits
Manna added a comment.

In D158522#4607628 , @tahonermann 
wrote:

> Looks fine to me!

Thanks @tahonermann for reviews!


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

https://reviews.llvm.org/D158522

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


[PATCH] D158488: [NFC] Initialize member pointers to nullptr.

2023-08-22 Thread Soumi Manna via Phabricator via cfe-commits
Manna added a comment.

This has already been addressed by https://reviews.llvm.org/D157989


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

https://reviews.llvm.org/D158488

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


[PATCH] D158293: [NFC][Clang] Fix static code analyzer concern about null value dereference

2023-08-23 Thread Soumi Manna via Phabricator via cfe-commits
Manna updated this revision to Diff 552706.
Manna edited the summary of this revision.
Manna removed reviewers: rymiel, HazardyKnusperkeks, owenpan, MyDeveloperDay.

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

https://reviews.llvm.org/D158293

Files:
  clang/lib/Lex/PPDirectives.cpp


Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -491,7 +491,8 @@
   llvm::SaveAndRestore SARSkipping(SkippingExcludedConditionalBlock, true);
 
   ++NumSkipped;
-  assert(!CurTokenLexer && CurPPLexer && "Lexing a macro, not a file?");
+  assert(!CurTokenLexer && CurPPLexer && CurLexer &&
+ "Lexing a macro, not a file?");
 
   if (PreambleConditionalStack.reachedEOFWhileSkipping())
 PreambleConditionalStack.clearSkipInfo();


Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -491,7 +491,8 @@
   llvm::SaveAndRestore SARSkipping(SkippingExcludedConditionalBlock, true);
 
   ++NumSkipped;
-  assert(!CurTokenLexer && CurPPLexer && "Lexing a macro, not a file?");
+  assert(!CurTokenLexer && CurPPLexer && CurLexer &&
+ "Lexing a macro, not a file?");
 
   if (PreambleConditionalStack.reachedEOFWhileSkipping())
 PreambleConditionalStack.clearSkipInfo();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D158293: [NFC][Clang] Fix static code analyzer concern about null value dereference

2023-08-23 Thread Soumi Manna via Phabricator via cfe-commits
Manna marked an inline comment as done.
Manna added inline comments.



Comment at: clang/lib/Lex/PPDirectives.cpp:555
   while (true) {
 CurLexer->Lex(Tok);
 

tahonermann wrote:
> I don't think this change is sufficient. If `CurLexer` is null, then the 
> `else` branch will be entered and an unconditional dereference occurs there 
> as well. It looks like more analysis is needed, but perhaps the correct fix 
> is to add a non-null assertion somewhere above.
Thank you @tahonermann for review and feedback. Yes, my analysis was wrong. 

>>perhaps the correct fix is to add a non-null assertion somewhere above.

It sounds reasonable to me. I have added an assert above.


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

https://reviews.llvm.org/D158293

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


[PATCH] D158227: [clang] EditedSource::applyRewrites - useless call

2023-08-23 Thread Soumi Manna 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 rG9e150adaea7b: [NFC][clang] EditedSource::applyRewrites - 
useless call (authored by Manna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158227

Files:
  clang/lib/Edit/EditedSource.cpp


Index: clang/lib/Edit/EditedSource.cpp
===
--- clang/lib/Edit/EditedSource.cpp
+++ clang/lib/Edit/EditedSource.cpp
@@ -430,7 +430,7 @@
 if (offs == CurEnd) {
   StrVec += act.Text;
   CurLen += act.RemoveLen;
-  CurEnd.getWithOffset(act.RemoveLen);
+  CurEnd = CurEnd.getWithOffset(act.RemoveLen);
   continue;
 }
 


Index: clang/lib/Edit/EditedSource.cpp
===
--- clang/lib/Edit/EditedSource.cpp
+++ clang/lib/Edit/EditedSource.cpp
@@ -430,7 +430,7 @@
 if (offs == CurEnd) {
   StrVec += act.Text;
   CurLen += act.RemoveLen;
-  CurEnd.getWithOffset(act.RemoveLen);
+  CurEnd = CurEnd.getWithOffset(act.RemoveLen);
   continue;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D158227: [clang] EditedSource::applyRewrites - useless call

2023-08-23 Thread Soumi Manna via Phabricator via cfe-commits
Manna added a comment.

The failure seems unrelated to my change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158227

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


[PATCH] D158522: [NFC][CLANG] Fix static analyzer bugs about large copy by values

2023-08-23 Thread Soumi Manna via Phabricator via cfe-commits
Manna added a comment.

Failure is unrelated to my patch.


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

https://reviews.llvm.org/D158522

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


[PATCH] D158522: [NFC][CLANG] Fix static analyzer bugs about large copy by values

2023-08-23 Thread Soumi Manna 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 rG30c60ec52f15: [NFC][CLANG] Fix static analyzer bugs about 
large copy by values (authored by Manna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158522

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CodeGenFunction.h


Index: clang/lib/CodeGen/CodeGenFunction.h
===
--- clang/lib/CodeGen/CodeGenFunction.h
+++ clang/lib/CodeGen/CodeGenFunction.h
@@ -4292,16 +4292,16 @@
   unsigned IntID);
   llvm::Value *EmitAArch64SVEBuiltinExpr(unsigned BuiltinID, const CallExpr 
*E);
 
-  llvm::Value *EmitSMELd1St1(SVETypeFlags TypeFlags,
+  llvm::Value *EmitSMELd1St1(const SVETypeFlags &TypeFlags,
  llvm::SmallVectorImpl &Ops,
  unsigned IntID);
-  llvm::Value *EmitSMEReadWrite(SVETypeFlags TypeFlags,
+  llvm::Value *EmitSMEReadWrite(const SVETypeFlags &TypeFlags,
 llvm::SmallVectorImpl &Ops,
 unsigned IntID);
-  llvm::Value *EmitSMEZero(SVETypeFlags TypeFlags,
+  llvm::Value *EmitSMEZero(const SVETypeFlags &TypeFlags,
llvm::SmallVectorImpl &Ops,
unsigned IntID);
-  llvm::Value *EmitSMELdrStr(SVETypeFlags TypeFlags,
+  llvm::Value *EmitSMELdrStr(const SVETypeFlags &TypeFlags,
  llvm::SmallVectorImpl &Ops,
  unsigned IntID);
   llvm::Value *EmitAArch64SMEBuiltinExpr(unsigned BuiltinID, const CallExpr 
*E);
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -9515,7 +9515,7 @@
   return Builder.CreateAdd(Base, CastOffset, "tileslice");
 }
 
-Value *CodeGenFunction::EmitSMELd1St1(SVETypeFlags TypeFlags,
+Value *CodeGenFunction::EmitSMELd1St1(const SVETypeFlags &TypeFlags,
   SmallVectorImpl &Ops,
   unsigned IntID) {
   Ops[3] = EmitSVEPredicateCast(
@@ -9545,7 +9545,7 @@
   return Builder.CreateCall(F, NewOps);
 }
 
-Value *CodeGenFunction::EmitSMEReadWrite(SVETypeFlags TypeFlags,
+Value *CodeGenFunction::EmitSMEReadWrite(const SVETypeFlags &TypeFlags,
  SmallVectorImpl &Ops,
  unsigned IntID) {
   auto *VecTy = getSVEType(TypeFlags);
@@ -9562,7 +9562,7 @@
   return Builder.CreateCall(F, Ops);
 }
 
-Value *CodeGenFunction::EmitSMEZero(SVETypeFlags TypeFlags,
+Value *CodeGenFunction::EmitSMEZero(const SVETypeFlags &TypeFlags,
 SmallVectorImpl &Ops,
 unsigned IntID) {
   // svzero_za() intrinsic zeros the entire za tile and has no paramters.
@@ -9572,7 +9572,7 @@
   return Builder.CreateCall(F, Ops);
 }
 
-Value *CodeGenFunction::EmitSMELdrStr(SVETypeFlags TypeFlags,
+Value *CodeGenFunction::EmitSMELdrStr(const SVETypeFlags &TypeFlags,
   SmallVectorImpl &Ops,
   unsigned IntID) {
   Function *Cntsb = CGM.getIntrinsic(Intrinsic::aarch64_sme_cntsb);


Index: clang/lib/CodeGen/CodeGenFunction.h
===
--- clang/lib/CodeGen/CodeGenFunction.h
+++ clang/lib/CodeGen/CodeGenFunction.h
@@ -4292,16 +4292,16 @@
   unsigned IntID);
   llvm::Value *EmitAArch64SVEBuiltinExpr(unsigned BuiltinID, const CallExpr *E);
 
-  llvm::Value *EmitSMELd1St1(SVETypeFlags TypeFlags,
+  llvm::Value *EmitSMELd1St1(const SVETypeFlags &TypeFlags,
  llvm::SmallVectorImpl &Ops,
  unsigned IntID);
-  llvm::Value *EmitSMEReadWrite(SVETypeFlags TypeFlags,
+  llvm::Value *EmitSMEReadWrite(const SVETypeFlags &TypeFlags,
 llvm::SmallVectorImpl &Ops,
 unsigned IntID);
-  llvm::Value *EmitSMEZero(SVETypeFlags TypeFlags,
+  llvm::Value *EmitSMEZero(const SVETypeFlags &TypeFlags,
llvm::SmallVectorImpl &Ops,
unsigned IntID);
-  llvm::Value *EmitSMELdrStr(SVETypeFlags TypeFlags,
+  llvm::Value *EmitSMELdrStr(const SVETypeFlags &TypeFlags,
  llvm::SmallVectorImpl &Ops,
  unsigned IntID);
   llvm::Value *EmitAArch64SMEBuiltinExpr(unsigned BuiltinID, const CallExpr *E);
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -9515,7 +9515,7 @

[PATCH] D158227: [clang] EditedSource::applyRewrites - useless call

2023-08-23 Thread Soumi Manna via Phabricator via cfe-commits
Manna added a comment.

In D158227#4610219 , @dyung wrote:

> In D158227#4610097 , @Manna wrote:
>
>> The failure seems unrelated to my change.
>
> Hi @Manna, I'm not sure which failure you are referring to, but there is a 
> test failure on at least 2 build bots that seems to have been caused by your 
> change. Can you take a look and revert if you need time to investigate?
>
> https://lab.llvm.org/buildbot/#/builders/139/builds/48141
> https://lab.llvm.org/buildbot/#/builders/216/builds/26116

Thank you @dyung for reporting the buildbot failure. I have reverted my patch. 
I will investigate it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158227

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


[PATCH] D159474: [NFC][CLANG] Fix static analyzer bugs about unnecessary object copies with auto

2023-09-08 Thread Soumi Manna via Phabricator via cfe-commits
Manna updated this revision to Diff 556273.

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

https://reviews.llvm.org/D159474

Files:
  clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
  clang/lib/Analysis/UnsafeBufferUsage.cpp
  clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp


Index: clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
===
--- clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
+++ clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
@@ -900,7 +900,7 @@
 return;
 
   Symbols.emplace_back(std::move(*Class));
-  for (const auto Base : Record.Bases)
+  for (const auto &Base : Record.Bases)
 serializeRelationship(RelationshipKind::InheritsFrom, Record, Base);
   if (!Record.ParentInformation.empty())
 serializeRelationship(RelationshipKind::MemberOf, Record,
@@ -914,7 +914,7 @@
 return;
 
   Symbols.emplace_back(std::move(*Class));
-  for (const auto Base : Record.Bases)
+  for (const auto &Base : Record.Bases)
 serializeRelationship(RelationshipKind::InheritsFrom, Record, Base);
   if (!Record.ParentInformation.empty())
 serializeRelationship(RelationshipKind::MemberOf, Record,
@@ -929,7 +929,7 @@
 
   Symbols.emplace_back(std::move(*Class));
 
-  for (const auto Base : Record.Bases)
+  for (const auto &Base : Record.Bases)
 serializeRelationship(RelationshipKind::InheritsFrom, Record, Base);
   if (!Record.ParentInformation.empty())
 serializeRelationship(RelationshipKind::MemberOf, Record,
@@ -944,7 +944,7 @@
 
   Symbols.emplace_back(std::move(*Class));
 
-  for (const auto Base : Record.Bases)
+  for (const auto &Base : Record.Bases)
 serializeRelationship(RelationshipKind::InheritsFrom, Record, Base);
   if (!Record.ParentInformation.empty())
 serializeRelationship(RelationshipKind::MemberOf, Record,
Index: clang/lib/Analysis/UnsafeBufferUsage.cpp
===
--- clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -2253,7 +2253,7 @@
   // Variables will be removed from `FixItsForVariable`:
   SmallVector ToErase;
 
-  for (auto [VD, Ignore] : FixItsForVariable) {
+  for (const auto &[VD, Ignore] : FixItsForVariable) {
 VarGrpRef Grp = VarGrpMgr.getGroupOfVar(VD);
 if (llvm::any_of(Grp,
  [&FixItsForVariable](const VarDecl *GrpMember) -> bool {
Index: clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
===
--- clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
+++ clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
@@ -172,7 +172,7 @@
   SmallVector getBases(const CXXRecordDecl *Decl) {
 // FIXME: store AccessSpecifier given by inheritance
 SmallVector Bases;
-for (const auto BaseSpecifier : Decl->bases()) {
+for (const auto &BaseSpecifier : Decl->bases()) {
   // skip classes not inherited as public
   if (BaseSpecifier.getAccessSpecifier() != AccessSpecifier::AS_public)
 continue;


Index: clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
===
--- clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
+++ clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
@@ -900,7 +900,7 @@
 return;
 
   Symbols.emplace_back(std::move(*Class));
-  for (const auto Base : Record.Bases)
+  for (const auto &Base : Record.Bases)
 serializeRelationship(RelationshipKind::InheritsFrom, Record, Base);
   if (!Record.ParentInformation.empty())
 serializeRelationship(RelationshipKind::MemberOf, Record,
@@ -914,7 +914,7 @@
 return;
 
   Symbols.emplace_back(std::move(*Class));
-  for (const auto Base : Record.Bases)
+  for (const auto &Base : Record.Bases)
 serializeRelationship(RelationshipKind::InheritsFrom, Record, Base);
   if (!Record.ParentInformation.empty())
 serializeRelationship(RelationshipKind::MemberOf, Record,
@@ -929,7 +929,7 @@
 
   Symbols.emplace_back(std::move(*Class));
 
-  for (const auto Base : Record.Bases)
+  for (const auto &Base : Record.Bases)
 serializeRelationship(RelationshipKind::InheritsFrom, Record, Base);
   if (!Record.ParentInformation.empty())
 serializeRelationship(RelationshipKind::MemberOf, Record,
@@ -944,7 +944,7 @@
 
   Symbols.emplace_back(std::move(*Class));
 
-  for (const auto Base : Record.Bases)
+  for (const auto &Base : Record.Bases)
 serializeRelationship(RelationshipKind::InheritsFrom, Record, Base);
   if (!Record.ParentInformation.empty())
 serializeRelationship(RelationshipKind::MemberOf, Record,
Index: clang/lib/Analysis/UnsafeBufferUsage.cpp
===
--- clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -2253,7 +2253,7 @@
   // Variables will be removed from `F

[PATCH] D159474: [NFC][CLANG] Fix static analyzer bugs about unnecessary object copies with auto

2023-09-12 Thread Soumi Manna via Phabricator via cfe-commits
Manna added a comment.

Thank you @tahonermann for reviews and feedbacks.


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

https://reviews.llvm.org/D159474

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


[PATCH] D158293: [NFC][Clang] Fix static code analyzer concern about null value dereference

2023-08-30 Thread Soumi Manna via Phabricator via cfe-commits
Manna updated this revision to Diff 554762.
Manna marked an inline comment as done.
Manna added a comment.

Thanks @tahonermann for review and feedback. I have added an assert separately 
to tell which predicate failed if a failure occurs in future.


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

https://reviews.llvm.org/D158293

Files:
  clang/lib/Lex/PPDirectives.cpp


Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -492,6 +492,7 @@
 
   ++NumSkipped;
   assert(!CurTokenLexer && CurPPLexer && "Lexing a macro, not a file?");
+  assert(CurLexer && "Invalid lexer value");
 
   if (PreambleConditionalStack.reachedEOFWhileSkipping())
 PreambleConditionalStack.clearSkipInfo();


Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -492,6 +492,7 @@
 
   ++NumSkipped;
   assert(!CurTokenLexer && CurPPLexer && "Lexing a macro, not a file?");
+  assert(CurLexer && "Invalid lexer value");
 
   if (PreambleConditionalStack.reachedEOFWhileSkipping())
 PreambleConditionalStack.clearSkipInfo();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D158293: [NFC][Clang] Fix static code analyzer concern about null value dereference

2023-08-30 Thread Soumi Manna via Phabricator via cfe-commits
Manna updated this revision to Diff 554810.
Manna added a comment.

This patch splits all predicates and updates assert messages.


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

https://reviews.llvm.org/D158293

Files:
  clang/lib/Lex/PPDirectives.cpp


Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -491,7 +491,9 @@
   llvm::SaveAndRestore SARSkipping(SkippingExcludedConditionalBlock, true);
 
   ++NumSkipped;
-  assert(!CurTokenLexer && CurPPLexer && "Lexing a macro, not a file?");
+  assert(!CurTokenLexer && "Conditional PP block cannot appear in a macro!");
+  assert(CurPPLexer && "Conditional PP block must be in a file!");
+  assert(CurLexer && "Conditional PP block but no current lexer set!");
 
   if (PreambleConditionalStack.reachedEOFWhileSkipping())
 PreambleConditionalStack.clearSkipInfo();


Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -491,7 +491,9 @@
   llvm::SaveAndRestore SARSkipping(SkippingExcludedConditionalBlock, true);
 
   ++NumSkipped;
-  assert(!CurTokenLexer && CurPPLexer && "Lexing a macro, not a file?");
+  assert(!CurTokenLexer && "Conditional PP block cannot appear in a macro!");
+  assert(CurPPLexer && "Conditional PP block must be in a file!");
+  assert(CurLexer && "Conditional PP block but no current lexer set!");
 
   if (PreambleConditionalStack.reachedEOFWhileSkipping())
 PreambleConditionalStack.clearSkipInfo();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D158293: [NFC][Clang] Fix static code analyzer concern about null value dereference

2023-08-30 Thread Soumi Manna via Phabricator via cfe-commits
Manna marked an inline comment as done.
Manna added inline comments.



Comment at: clang/lib/Lex/PPDirectives.cpp:494-495
   ++NumSkipped;
   assert(!CurTokenLexer && CurPPLexer && "Lexing a macro, not a file?");
+  assert(CurLexer && "Invalid lexer value");
 

tahonermann wrote:
> Would you mind splitting out all of the predicates? The updates to the 
> messages in the suggested edit are intended to match the style present in 
> other similar assertions.
Thanks @tahonermann for the suggestion. Done


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

https://reviews.llvm.org/D158293

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


[PATCH] D158293: [NFC][Clang] Fix static code analyzer concern about null value dereference

2023-09-05 Thread Soumi Manna via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Manna marked an inline comment as done.
Closed by commit rG33b02d766eb8: [NFC][Clang] Fix static code analyzer concern 
about null value dereference (authored by Manna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158293

Files:
  clang/lib/Lex/PPDirectives.cpp


Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -491,7 +491,9 @@
   llvm::SaveAndRestore SARSkipping(SkippingExcludedConditionalBlock, true);
 
   ++NumSkipped;
-  assert(!CurTokenLexer && CurPPLexer && "Lexing a macro, not a file?");
+  assert(!CurTokenLexer && "Conditional PP block cannot appear in a macro!");
+  assert(CurPPLexer && "Conditional PP block must be in a file!");
+  assert(CurLexer && "Conditional PP block but no current lexer set!");
 
   if (PreambleConditionalStack.reachedEOFWhileSkipping())
 PreambleConditionalStack.clearSkipInfo();


Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -491,7 +491,9 @@
   llvm::SaveAndRestore SARSkipping(SkippingExcludedConditionalBlock, true);
 
   ++NumSkipped;
-  assert(!CurTokenLexer && CurPPLexer && "Lexing a macro, not a file?");
+  assert(!CurTokenLexer && "Conditional PP block cannot appear in a macro!");
+  assert(CurPPLexer && "Conditional PP block must be in a file!");
+  assert(CurLexer && "Conditional PP block but no current lexer set!");
 
   if (PreambleConditionalStack.reachedEOFWhileSkipping())
 PreambleConditionalStack.clearSkipInfo();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D158293: [NFC][Clang] Fix static code analyzer concern about null value dereference

2023-09-05 Thread Soumi Manna via Phabricator via cfe-commits
Manna added a comment.

In D158293#4629232 , @tahonermann 
wrote:

> Thanks, Soumi, looks good to me!

Thank you @tahonermann for reviews!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158293

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


[PATCH] D159474: [NFC][CLANG] Fix static analyzer bugs about unnecessary object copies with auto

2023-09-06 Thread Soumi Manna via Phabricator via cfe-commits
Manna created this revision.
Manna added a reviewer: tahonermann.
Herald added subscribers: manas, ASDenysPetrov, dkrupp, donat.nagy, Szelethus, 
a.sidorin, baloghadamsoftware.
Herald added a reviewer: NoQ.
Herald added a reviewer: ributzka.
Herald added a project: All.
Manna requested review of this revision.
Herald added a reviewer: dang.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D159474

Files:
  clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
  clang/lib/Analysis/UnsafeBufferUsage.cpp
  clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp


Index: clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
===
--- clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
+++ clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
@@ -597,7 +597,7 @@
 
   Object Generics;
   Array GenericParameters;
-  for (const auto Param : Template.getParameters()) {
+  for (const auto &Param : Template.getParameters()) {
 Object Parameter;
 Parameter["name"] = Param.Name;
 Parameter["index"] = Param.Index;
@@ -608,7 +608,7 @@
 Generics["parameters"] = std::move(GenericParameters);
 
   Array GenericConstraints;
-  for (const auto Constr : Template.getConstraints()) {
+  for (const auto &Constr : Template.getConstraints()) {
 Object Constraint;
 Constraint["kind"] = Constr.Kind;
 Constraint["lhs"] = Constr.LHS;
@@ -900,7 +900,7 @@
 return;
 
   Symbols.emplace_back(std::move(*Class));
-  for (const auto Base : Record.Bases)
+  for (const auto &Base : Record.Bases)
 serializeRelationship(RelationshipKind::InheritsFrom, Record, Base);
   if (!Record.ParentInformation.empty())
 serializeRelationship(RelationshipKind::MemberOf, Record,
@@ -914,7 +914,7 @@
 return;
 
   Symbols.emplace_back(std::move(*Class));
-  for (const auto Base : Record.Bases)
+  for (const auto &Base : Record.Bases)
 serializeRelationship(RelationshipKind::InheritsFrom, Record, Base);
   if (!Record.ParentInformation.empty())
 serializeRelationship(RelationshipKind::MemberOf, Record,
@@ -929,7 +929,7 @@
 
   Symbols.emplace_back(std::move(*Class));
 
-  for (const auto Base : Record.Bases)
+  for (const auto &Base : Record.Bases)
 serializeRelationship(RelationshipKind::InheritsFrom, Record, Base);
   if (!Record.ParentInformation.empty())
 serializeRelationship(RelationshipKind::MemberOf, Record,
@@ -944,7 +944,7 @@
 
   Symbols.emplace_back(std::move(*Class));
 
-  for (const auto Base : Record.Bases)
+  for (const auto &Base : Record.Bases)
 serializeRelationship(RelationshipKind::InheritsFrom, Record, Base);
   if (!Record.ParentInformation.empty())
 serializeRelationship(RelationshipKind::MemberOf, Record,
Index: clang/lib/Analysis/UnsafeBufferUsage.cpp
===
--- clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -2253,7 +2253,7 @@
   // Variables will be removed from `FixItsForVariable`:
   SmallVector ToErase;
 
-  for (auto [VD, Ignore] : FixItsForVariable) {
+  for (const auto &[VD, Ignore] : FixItsForVariable) {
 VarGrpRef Grp = VarGrpMgr.getGroupOfVar(VD);
 if (llvm::any_of(Grp,
  [&FixItsForVariable](const VarDecl *GrpMember) -> bool {
Index: clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
===
--- clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
+++ clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
@@ -172,7 +172,7 @@
   SmallVector getBases(const CXXRecordDecl *Decl) {
 // FIXME: store AccessSpecifier given by inheritance
 SmallVector Bases;
-for (const auto BaseSpecifier : Decl->bases()) {
+for (const auto &BaseSpecifier : Decl->bases()) {
   // skip classes not inherited as public
   if (BaseSpecifier.getAccessSpecifier() != AccessSpecifier::AS_public)
 continue;


Index: clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
===
--- clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
+++ clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
@@ -597,7 +597,7 @@
 
   Object Generics;
   Array GenericParameters;
-  for (const auto Param : Template.getParameters()) {
+  for (const auto &Param : Template.getParameters()) {
 Object Parameter;
 Parameter["name"] = Param.Name;
 Parameter["index"] = Param.Index;
@@ -608,7 +608,7 @@
 Generics["parameters"] = std::move(GenericParameters);
 
   Array GenericConstraints;
-  for (const auto Constr : Template.getConstraints()) {
+  for (const auto &Constr : Template.getConstraints()) {
 Object Constraint;
 Constraint["kind"] = Constr.Kind;
 Constraint["lhs"] = Constr.LHS;
@@ -900,7 +900,7 @@
 return;
 
   Symbols.emplace_back(std::move(*Class));
-  for (

[PATCH] D153033: [CLANG]Fix potential null pointer dereference bugs

2023-06-22 Thread Soumi Manna via Phabricator via cfe-commits
Manna marked an inline comment as done.
Manna added a comment.

ping @aaron.ballman


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

https://reviews.llvm.org/D153033

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


[PATCH] D150931: [NFC][Clang] Fix Static Code Analysis Concerns with copy without assign

2023-06-22 Thread Soumi Manna via Phabricator via cfe-commits
Manna added a comment.

ping @tahonermann


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

https://reviews.llvm.org/D150931

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


[PATCH] D153146: [CLANG] Fix potential integer overflow value in getRVVTypeSize()

2023-06-22 Thread Soumi Manna via Phabricator via cfe-commits
Manna updated this revision to Diff 533589.
Manna edited the summary of this revision.
Manna added a comment.

Thank you @erichkeane for review and comments. I have changed the types of 
variables MinElts and EltSize to uint64_t instead of the cast.


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

https://reviews.llvm.org/D153146

Files:
  clang/lib/AST/ASTContext.cpp


Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -9564,8 +9564,8 @@
 
   ASTContext::BuiltinVectorTypeInfo Info = 
Context.getBuiltinVectorTypeInfo(Ty);
 
-  unsigned EltSize = Context.getTypeSize(Info.ElementType);
-  unsigned MinElts = Info.EC.getKnownMinValue();
+  uint64_t EltSize = Context.getTypeSize(Info.ElementType);
+  uint64_t MinElts = Info.EC.getKnownMinValue();
   return VScale->first * MinElts * EltSize;
 }
 


Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -9564,8 +9564,8 @@
 
   ASTContext::BuiltinVectorTypeInfo Info = Context.getBuiltinVectorTypeInfo(Ty);
 
-  unsigned EltSize = Context.getTypeSize(Info.ElementType);
-  unsigned MinElts = Info.EC.getKnownMinValue();
+  uint64_t EltSize = Context.getTypeSize(Info.ElementType);
+  uint64_t MinElts = Info.EC.getKnownMinValue();
   return VScale->first * MinElts * EltSize;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D150744: [NFC][CLANG] Fix uninitialized scalar field issues

2023-06-22 Thread Soumi Manna via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5e12f5ab2df1: [CLANG] Fix uninitialized scalar field issues 
(authored by Manna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150744

Files:
  clang/include/clang/Analysis/Analyses/Consumed.h
  clang/include/clang/Parse/Parser.h
  clang/lib/AST/ExprConstant.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/CodeGen/ConstantEmitter.h
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/StaticAnalyzer/Checkers/MoveChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/STLAlgorithmModeling.cpp

Index: clang/lib/StaticAnalyzer/Checkers/STLAlgorithmModeling.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/STLAlgorithmModeling.cpp
+++ clang/lib/StaticAnalyzer/Checkers/STLAlgorithmModeling.cpp
@@ -61,7 +61,7 @@
 public:
   STLAlgorithmModeling() = default;
 
-  bool AggressiveStdFindModeling;
+  bool AggressiveStdFindModeling = false;
 
   bool evalCall(const CallEvent &Call, CheckerContext &C) const;
 }; //
Index: clang/lib/StaticAnalyzer/Checkers/MoveChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/MoveChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/MoveChecker.cpp
@@ -184,7 +184,7 @@
 bool Found;
   };
 
-  AggressivenessKind Aggressiveness;
+  AggressivenessKind Aggressiveness = AK_KnownsAndLocals;
 
 public:
   void setAggressiveness(StringRef Str, CheckerManager &Mgr) {
Index: clang/lib/Serialization/ASTReaderDecl.cpp
===
--- clang/lib/Serialization/ASTReaderDecl.cpp
+++ clang/lib/Serialization/ASTReaderDecl.cpp
@@ -89,7 +89,7 @@
 using RecordData = ASTReader::RecordData;
 
 TypeID DeferredTypeID = 0;
-unsigned AnonymousDeclNumber;
+unsigned AnonymousDeclNumber = 0;
 GlobalDeclID NamedDeclForTagDecl = 0;
 IdentifierInfo *TypedefNameForLinkage = nullptr;
 
Index: clang/lib/CodeGen/ConstantEmitter.h
===
--- clang/lib/CodeGen/ConstantEmitter.h
+++ clang/lib/CodeGen/ConstantEmitter.h
@@ -42,7 +42,7 @@
 
   /// The AST address space where this (non-abstract) initializer is going.
   /// Used for generating appropriate placeholders.
-  LangAS DestAddressSpace;
+  LangAS DestAddressSpace = LangAS::Default;
 
   llvm::SmallVector, 4>
 PlaceholderAddresses;
Index: clang/lib/CodeGen/CGOpenMPRuntime.h
===
--- clang/lib/CodeGen/CGOpenMPRuntime.h
+++ clang/lib/CodeGen/CGOpenMPRuntime.h
@@ -232,7 +232,7 @@
   /// as those marked as `omp declare target`.
   class DisableAutoDeclareTargetRAII {
 CodeGenModule &CGM;
-bool SavedShouldMarkAsGlobal;
+bool SavedShouldMarkAsGlobal = false;
 
   public:
 DisableAutoDeclareTargetRAII(CodeGenModule &CGM);
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -1294,7 +1294,7 @@
   class SpeculativeEvaluationRAII {
 EvalInfo *Info = nullptr;
 Expr::EvalStatus OldStatus;
-unsigned OldSpeculativeEvaluationDepth;
+unsigned OldSpeculativeEvaluationDepth = 0;
 
 void moveFromAndCancel(SpeculativeEvaluationRAII &&Other) {
   Info = Other.Info;
Index: clang/include/clang/Parse/Parser.h
===
--- clang/include/clang/Parse/Parser.h
+++ clang/include/clang/Parse/Parser.h
@@ -1188,7 +1188,7 @@
   /// RAII object used to modify the scope flags for the current scope.
   class ParseScopeFlags {
 Scope *CurScope;
-unsigned OldFlags;
+unsigned OldFlags = 0;
 ParseScopeFlags(const ParseScopeFlags &) = delete;
 void operator=(const ParseScopeFlags &) = delete;
 
Index: clang/include/clang/Analysis/Analyses/Consumed.h
===
--- clang/include/clang/Analysis/Analyses/Consumed.h
+++ clang/include/clang/Analysis/Analyses/Consumed.h
@@ -244,7 +244,7 @@
 ConsumedBlockInfo BlockInfo;
 std::unique_ptr CurrStates;
 
-ConsumedState ExpectedReturnState;
+ConsumedState ExpectedReturnState = CS_None;
 
 void determineExpectedReturnState(AnalysisDeclContext &AC,
   const FunctionDecl *D);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D150744: [NFC][CLANG] Fix uninitialized scalar field issues

2023-06-22 Thread Soumi Manna via Phabricator via cfe-commits
Manna added a comment.

Thank you everyone for reviews!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150744

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


[PATCH] D150931: [NFC][Clang] Fix Static Code Analysis Concerns with copy without assign

2023-06-22 Thread Soumi Manna via Phabricator via cfe-commits
Manna added a comment.

Thank you @tahonermann and @aaronpuchert for reviews and comments!


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

https://reviews.llvm.org/D150931

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


[PATCH] D150931: [NFC][Clang] Fix Static Code Analysis Concerns with copy without assign

2023-06-22 Thread Soumi Manna via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG11528fceac6b: [Clang] Fix Static Code Analysis Concerns with 
copy without assign (authored by Manna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150931

Files:
  clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h


Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
@@ -84,6 +84,10 @@
   CallEventRef(const T *Call) : IntrusiveRefCntPtr(Call) {}
   CallEventRef(const CallEventRef &Orig) : IntrusiveRefCntPtr(Orig) {}
 
+  // The copy assignment operator is defined as deleted pending further
+  // motivation.
+  CallEventRef &operator=(const CallEventRef &) = delete;
+
   CallEventRef cloneWithState(ProgramStateRef State) const {
 return this->get()->template cloneWithState(State);
   }
Index: clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h
===
--- clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h
+++ clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h
@@ -319,6 +319,7 @@
 protected:
   SExpr(TIL_Opcode Op) : Opcode(Op) {}
   SExpr(const SExpr &E) : Opcode(E.Opcode), Flags(E.Flags) {}
+  SExpr &operator=(const SExpr &) = delete;
 
   const TIL_Opcode Opcode;
   unsigned char Reserved = 0;


Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
@@ -84,6 +84,10 @@
   CallEventRef(const T *Call) : IntrusiveRefCntPtr(Call) {}
   CallEventRef(const CallEventRef &Orig) : IntrusiveRefCntPtr(Orig) {}
 
+  // The copy assignment operator is defined as deleted pending further
+  // motivation.
+  CallEventRef &operator=(const CallEventRef &) = delete;
+
   CallEventRef cloneWithState(ProgramStateRef State) const {
 return this->get()->template cloneWithState(State);
   }
Index: clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h
===
--- clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h
+++ clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h
@@ -319,6 +319,7 @@
 protected:
   SExpr(TIL_Opcode Op) : Opcode(Op) {}
   SExpr(const SExpr &E) : Opcode(E.Opcode), Flags(E.Flags) {}
+  SExpr &operator=(const SExpr &) = delete;
 
   const TIL_Opcode Opcode;
   unsigned char Reserved = 0;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D153033: [CLANG]Fix potential null pointer dereference bugs

2023-06-22 Thread Soumi Manna via Phabricator via cfe-commits
Manna added a comment.

Thank you for reviews @aaron.ballman!


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

https://reviews.llvm.org/D153033

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


[PATCH] D153033: [CLANG]Fix potential null pointer dereference bugs

2023-06-22 Thread Soumi Manna via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG982a87ab74d8: [CLANG] Fix potential null pointer dereference 
bugs (authored by Manna).

Changed prior to commit:
  https://reviews.llvm.org/D153033?vs=532138&id=533742#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153033

Files:
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/Analysis/ThreadSafety.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp


Index: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
@@ -1204,10 +1204,12 @@
 // FIXME: Add a checker option to turn this uniqueing feature off.
 const ExplodedNode *StreamOpenNode = getAcquisitionSite(Err, LeakSym, C);
 assert(StreamOpenNode && "Could not find place of stream opening.");
-PathDiagnosticLocation LocUsedForUniqueing =
-PathDiagnosticLocation::createBegin(
-StreamOpenNode->getStmtForDiagnostics(), C.getSourceManager(),
-StreamOpenNode->getLocationContext());
+
+PathDiagnosticLocation LocUsedForUniqueing;
+if (const Stmt *StreamStmt = StreamOpenNode->getStmtForDiagnostics())
+   LocUsedForUniqueing = PathDiagnosticLocation::createBegin(
+  StreamStmt, C.getSourceManager(),
+  StreamOpenNode->getLocationContext());
 
 std::unique_ptr R =
 std::make_unique(
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -4955,7 +4955,8 @@
   };
   // The matrix subscript operator ([][])is considered a single operator.
   // Separating the index expressions by parenthesis is not allowed.
-  if (base->hasPlaceholderType(BuiltinType::IncompleteMatrixIdx) &&
+  if (base && !base->getType().isNull() &&
+  base->hasPlaceholderType(BuiltinType::IncompleteMatrixIdx) &&
   !isa(base)) {
 Diag(base->getExprLoc(), diag::err_matrix_separate_incomplete_index)
 << SourceRange(base->getBeginLoc(), rbLoc);
Index: clang/lib/Analysis/ThreadSafety.cpp
===
--- clang/lib/Analysis/ThreadSafety.cpp
+++ clang/lib/Analysis/ThreadSafety.cpp
@@ -502,9 +502,8 @@
 for (Context::iterator I = C.begin(), E = C.end(); I != E; ++I) {
   const NamedDecl *D = I.getKey();
   D->printName(llvm::errs());
-  const unsigned *i = C.lookup(D);
   llvm::errs() << " -> ";
-  dumpVarDefinitionName(*i);
+  dumpVarDefinitionName(I.getData());
   llvm::errs() << "\n";
 }
   }
Index: clang/lib/AST/MicrosoftMangle.cpp
===
--- clang/lib/AST/MicrosoftMangle.cpp
+++ clang/lib/AST/MicrosoftMangle.cpp
@@ -2689,7 +2689,7 @@
 // Copy constructor closure always takes an unqualified reference.
 mangleFunctionArgumentType(getASTContext().getLValueReferenceType(
Proto->getParamType(0)
-   ->getAs()
+   ->castAs()
->getPointeeType(),
/*SpelledAsLValue=*/true),
Range);
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -10030,6 +10030,9 @@
 return false;
 
   ObjCTypeParamList *typeParams = iface->getTypeParamList();
+  if (!typeParams)
+return false;
+
   for (unsigned i = 0, n = lhsArgs.size(); i != n; ++i) {
 if (ctx.hasSameType(lhsArgs[i], rhsArgs[i]))
   continue;


Index: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
@@ -1204,10 +1204,12 @@
 // FIXME: Add a checker option to turn this uniqueing feature off.
 const ExplodedNode *StreamOpenNode = getAcquisitionSite(Err, LeakSym, C);
 assert(StreamOpenNode && "Could not find place of stream opening.");
-PathDiagnosticLocation LocUsedForUniqueing =
-PathDiagnosticLocation::createBegin(
-StreamOpenNode->getStmtForDiagnostics(), C.getSourceManager(),
-StreamOpenNode->getLocationContext());
+
+PathDiagnosticLocation LocUsedForUniqueing;
+if (const Stmt *StreamStmt = StreamOpenNode->getStmtForDiagnostics())
+   LocUsedForUniqueing = PathDiagnosticLocation::createBegin(
+  StreamStmt, C.getSourceManager(),
+  StreamOpenN

[PATCH] D152197: Fix static analyzer bugs with null pointer dereferences in CheckSizelessVectorOperands()

2023-06-22 Thread Soumi Manna via Phabricator via cfe-commits
Manna marked an inline comment as done.
Manna added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:11148
   if (LHSType->isVLSTBuiltinType() && RHSType->isVLSTBuiltinType() &&
+  LHSBuiltinTy && RHSBuiltinTy &&
   Context.getBuiltinVectorTypeInfo(LHSBuiltinTy).EC !=

erichkeane wrote:
> I think this is unnecessary.  `isVLSTBuiltinType` only returns true if 
> `LHSType` is a `BuiltinType` already (or at least, a subset-of). See : 
> https://clang.llvm.org/doxygen/Type_8cpp_source.html#l02409
> 
> 
This makes sense to me. Thank you for the pointer and explanation!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152197

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


[PATCH] D151606: [NFC][CLANG] Fix Static Code Analyzer Concerns with bad bit right shift operation in getNVPTXLaneID()

2023-06-22 Thread Soumi Manna via Phabricator via cfe-commits
Manna added a comment.

Thank you @tahonermann and @tra for reviews and comments!


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

https://reviews.llvm.org/D151606

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


[PATCH] D151606: [NFC][CLANG] Fix Static Code Analyzer Concerns with bad bit right shift operation in getNVPTXLaneID()

2023-06-22 Thread Soumi Manna via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG213709e7be03: [CLANG] Fix Static Code Analyzer Concerns with 
bad bit right shift operation in… (authored by Manna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151606

Files:
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp


Index: clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
@@ -525,6 +525,7 @@
   CGBuilderTy &Bld = CGF.Builder;
   unsigned LaneIDBits =
   llvm::Log2_32(CGF.getTarget().getGridValue().GV_Warp_Size);
+  assert(LaneIDBits < 32 && "Invalid LaneIDBits size in NVPTX device.");
   unsigned LaneIDMask = ~0u >> (32u - LaneIDBits);
   auto &RT = static_cast(CGF.CGM.getOpenMPRuntime());
   return Bld.CreateAnd(RT.getGPUThreadID(CGF), Bld.getInt32(LaneIDMask),


Index: clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
@@ -525,6 +525,7 @@
   CGBuilderTy &Bld = CGF.Builder;
   unsigned LaneIDBits =
   llvm::Log2_32(CGF.getTarget().getGridValue().GV_Warp_Size);
+  assert(LaneIDBits < 32 && "Invalid LaneIDBits size in NVPTX device.");
   unsigned LaneIDMask = ~0u >> (32u - LaneIDBits);
   auto &RT = static_cast(CGF.CGM.getOpenMPRuntime());
   return Bld.CreateAnd(RT.getGPUThreadID(CGF), Bld.getInt32(LaneIDMask),
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D153146: [CLANG] Fix potential integer overflow value in getRVVTypeSize()

2023-06-28 Thread Soumi Manna via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7372c0d46d21: [CLANG] Fix potential integer overflow value 
in getRVVTypeSize() (authored by Manna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153146

Files:
  clang/lib/AST/ASTContext.cpp


Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -9564,8 +9564,8 @@
 
   ASTContext::BuiltinVectorTypeInfo Info = 
Context.getBuiltinVectorTypeInfo(Ty);
 
-  unsigned EltSize = Context.getTypeSize(Info.ElementType);
-  unsigned MinElts = Info.EC.getKnownMinValue();
+  uint64_t EltSize = Context.getTypeSize(Info.ElementType);
+  uint64_t MinElts = Info.EC.getKnownMinValue();
   return VScale->first * MinElts * EltSize;
 }
 


Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -9564,8 +9564,8 @@
 
   ASTContext::BuiltinVectorTypeInfo Info = Context.getBuiltinVectorTypeInfo(Ty);
 
-  unsigned EltSize = Context.getTypeSize(Info.ElementType);
-  unsigned MinElts = Info.EC.getKnownMinValue();
+  uint64_t EltSize = Context.getTypeSize(Info.ElementType);
+  uint64_t MinElts = Info.EC.getKnownMinValue();
   return VScale->first * MinElts * EltSize;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D152194: [StaticAnalyzer] Fix nullptr dereference issue found by static analyzer tool

2023-06-28 Thread Soumi Manna via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa806ec4857c2: [analyzer] Refactor codes in findMethodDecl() 
(authored by Manna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152194

Files:
  clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp


Index: clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
+++ clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
@@ -742,8 +742,6 @@
   const ObjCMethodDecl *Method = nullptr;
 
   QualType ReceiverType = MessageExpr->getReceiverType();
-  const auto *ReceiverObjectPtrType =
-  ReceiverType->getAs();
 
   // Do this "devirtualization" on instance and class methods only. Trust the
   // static type on super and super class calls.
@@ -753,7 +751,8 @@
 // type, look up the method in the tracked type, not in the receiver type.
 // This way we preserve more information.
 if (ReceiverType->isObjCIdType() || ReceiverType->isObjCClassType() ||
-ASTCtxt.canAssignObjCInterfaces(ReceiverObjectPtrType, TrackedType)) {
+ASTCtxt.canAssignObjCInterfaces(
+ReceiverType->castAs(), TrackedType)) {
   const ObjCInterfaceDecl *InterfaceDecl = TrackedType->getInterfaceDecl();
   // The method might not be found.
   Selector Sel = MessageExpr->getSelector();


Index: clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
+++ clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
@@ -742,8 +742,6 @@
   const ObjCMethodDecl *Method = nullptr;
 
   QualType ReceiverType = MessageExpr->getReceiverType();
-  const auto *ReceiverObjectPtrType =
-  ReceiverType->getAs();
 
   // Do this "devirtualization" on instance and class methods only. Trust the
   // static type on super and super class calls.
@@ -753,7 +751,8 @@
 // type, look up the method in the tracked type, not in the receiver type.
 // This way we preserve more information.
 if (ReceiverType->isObjCIdType() || ReceiverType->isObjCClassType() ||
-ASTCtxt.canAssignObjCInterfaces(ReceiverObjectPtrType, TrackedType)) {
+ASTCtxt.canAssignObjCInterfaces(
+ReceiverType->castAs(), TrackedType)) {
   const ObjCInterfaceDecl *InterfaceDecl = TrackedType->getInterfaceDecl();
   // The method might not be found.
   Selector Sel = MessageExpr->getSelector();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D147574: [NFC][clang] Fix Coverity static analyzer tool concerns about auto_causes_copy

2023-04-05 Thread Soumi Manna via Phabricator via cfe-commits
Manna added a comment.

Thanks @erichkeane.

Is this known failure?

Failed Tests (1):

  Clang :: SemaCXX/warn-unsafe-buffer-usage-fixits-addressof-arraysubscript.cpp

https://buildkite.com/llvm-project/premerge-checks/builds/145026#01874e21-00e2-47a9-9bc4-975357d197ef


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147574

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


[PATCH] D147574: [NFC][clang] Fix Coverity static analyzer tool concerns about auto_causes_copy

2023-04-05 Thread Soumi Manna via Phabricator via cfe-commits
Manna added a comment.

In D147574#4245881 , @erichkeane 
wrote:

> In D147574#4245877 , @Manna wrote:
>
>> Thanks @erichkeane.
>>
>> Is this known failure?
>>
>> Failed Tests (1):
>>
>>   Clang :: 
>> SemaCXX/warn-unsafe-buffer-usage-fixits-addressof-arraysubscript.cpp
>>
>> https://buildkite.com/llvm-project/premerge-checks/builds/145026#01874e21-00e2-47a9-9bc4-975357d197ef
>
> Looks like the commit that added that test got reverted here 
> d5c428356f6ee107a97977eb9ef1aa4d5fa0c378 
>  because 
> it caused the test to fail, so it looks like the answer is 'yes'.

Thanks @erichkeane for confirming!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147574

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


[PATCH] D147574: [NFC][clang] Fix Coverity static analyzer tool concerns about auto_causes_copy

2023-04-05 Thread Soumi Manna via Phabricator via cfe-commits
Manna added a comment.

In D147574#4246004 , @aaron.ballman 
wrote:

> LGTM

Thank you @aaron.ballman


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147574

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


[PATCH] D147574: [NFC][clang] Fix Coverity static analyzer tool concerns about auto_causes_copy

2023-04-05 Thread Soumi Manna via Phabricator via cfe-commits
Manna added a comment.

I have committed the patch here: https://reviews.llvm.org/rG59cb47015a18


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147574

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


[PATCH] D147708: [NFC][clang] Fix static analyzer tool remarks about large copies by values

2023-04-06 Thread Soumi Manna via Phabricator via cfe-commits
Manna created this revision.
Manna added reviewers: erichkeane, aaron.ballman.
Herald added subscribers: manas, ASDenysPetrov, dkrupp, donat.nagy, Szelethus, 
arphaman, a.sidorin, baloghadamsoftware.
Herald added a project: All.
Manna requested review of this revision.
Herald added a project: clang.

Reported by Coverity:

Big parameter passed by value
Copying large values is inefficient, consider passing by reference; Low, 
medium, and high size thresholds for detection can be adjusted.

1. Inside "SemaConcept.cpp" file, in 
subsumes, clang::​NamedDecl *, 
llvm::​ArrayRef)::​[lambda(clang::​AtomicConstraint const 
&, clang::​AtomicConstraint const &) (instance 
2)]>(llvm::​SmallVector, 
4u>, llvm::​SmallVector, 
4u>, T1): A large function call parameter exceeding the low threshold is passed 
by value.

  i. pass_by_value: Passing parameter PDNF of type NormalForm (size 144 bytes) 
by value, which exceeds the low threshold of 128 bytes. ii. pass_by_value: 
Passing parameter QCNF of type NormalForm (size 144 bytes) by value, which 
exceeds the low threshold of 128 bytes.

2. Inside "CodeGenAction.cpp" file, in 
clang::​reportOptRecordError(llvm::​Error, clang::​DiagnosticsEngine &, 
clang::​CodeGenOptions): A very large function call parameter exceeding the 
high threshold is passed by value.

i. pass_by_value: Passing parameter CodeGenOpts of type clang::CodeGenOptions 
const (size 1560 bytes) by value, which exceeds the high threshold of 512 bytes.

3. Inside "CodeCompleteConsumer.cpp" file, in 
clang::​PrintingCodeCompleteConsumer::​ProcessCodeCompleteResults(clang::​Sema 
&, clang::​CodeCompletionContext, clang::​CodeCompletionResult *, unsigned 
int): A large function call parameter exceeding the low threshold is passed by 
value.

i. pass_by_value: Passing parameter Context of type 
clang::CodeCompletionContext (size 200 bytes) by value, which exceeds the low 
threshold of 128 bytes.

4. Inside "GlobalModuleIndex.cpp" file, in 
clang::​GlobalModuleIndex::​GlobalModuleIndex(std::​unique_ptr>, llvm::​BitstreamCursor): A large 
function call parameter exceeding the medium threshold is passed by value.

i. pass_by_value: Passing parameter Cursor of type llvm::BitstreamCursor (size 
352 bytes) by value, which exceeds the medium threshold of 256 bytes.

5. Inside "CGNonTrivialStruct.cpp" file, in ::​getParamAddrs<1ull, 
<0ull...>>(std::​integer_sequence, 
std::​array, clang::​CodeGen::​FunctionArgList, 
clang::​CodeGen::​CodeGenFunction *): A large function call parameter exceeding 
the low threshold is passed by value.

i. pass_by_value: Passing parameter Args of type 
clang::CodeGen::FunctionArgList (size 144 bytes) by value, which exceeds the 
low threshold of 128 bytes.

6. Inside "CodeGenModule.cpp" file, in 
clang::​CodeGen::​CodeGenModule::​EmitBackendOptionsMetadata(clang::​CodeGenOptions):
 A very large function call parameter exceeding the high threshold is passed by 
value.

i. pass_by_value: Passing parameter CodeGenOpts of type clang::CodeGenOptions 
const (size 2008 bytes) by value, which exceeds the high threshold of 512 bytes.

7. Inside "SemaCodeComplete.cpp" file, in 
HandleCodeCompleteResults(clang::​Sema *, clang::​CodeCompleteConsumer *, 
clang::​CodeCompletionContext, clang::​CodeCompletionResult *, unsigned int): A 
large function call parameter exceeding the low threshold is passed by value.

i. pass_by_value: Passing parameter Context of type 
clang::CodeCompletionContext (size 200 bytes) by value, which exceeds the low 
threshold of 128 bytes.

8. Inside "CGGPUBuiltin.cpp" file, in 
::​containsNonScalarVarargs(clang::​CodeGen::​CodeGenFunction *, 
clang::​CodeGen::​CallArgList): A very large function call parameter exceeding 
the high threshold is passed by value.

i. pass_by_value: Passing parameter Args of type clang::CodeGen::CallArgList 
(size 1176 bytes) by value, which exceeds the high threshold of 512 bytes.

9. Inside "ASTUnit.cpp" file, in 
::​AugmentedCodeCompleteConsumer::​ProcessCodeCompleteResults(clang::​Sema
 &, clang::​CodeCompletionContext, clang::​CodeCompletionResult *, unsigned 
int): A large function call parameter exceeding the low threshold is passed by 
value.

i. pass_by_value: Passing parameter Context of type 
clang::CodeCompletionContext (size 200 bytes) by value, which exceeds the low 
threshold of 128 bytes.

10. Inside "SemaConcept.cpp" file, in 
::​SatisfactionStackRAII::​SatisfactionStackRAII(clang::​Sema &, 
clang::​NamedDecl const *, llvm::​FoldingSetNodeID): A large function call 
parameter exceeding the low threshold is passed by value.

i. pass_by_value: Passing parameter FSNID of type llvm::FoldingSetNodeID (size 
144 bytes) by value, which exceeds the low threshold of 128 bytes.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147708

Files:
  clang/lib/CodeGen/CGGPUBuiltin.cpp
  clang/lib/CodeGen/CGNonTrivialStruct.cpp
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Frontend/ASTUnit.c

[PATCH] D147708: [NFC][clang] Fix static analyzer tool remarks about large copies by values

2023-04-06 Thread Soumi Manna via Phabricator via cfe-commits
Manna updated this revision to Diff 511478.
Manna added a comment.

Thanks @erichkeane for reviews. I have updated patch.


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

https://reviews.llvm.org/D147708

Files:
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/Sema/CodeCompleteConsumer.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/lib/Sema/SemaConcept.cpp


Index: clang/lib/Sema/SemaConcept.cpp
===
--- clang/lib/Sema/SemaConcept.cpp
+++ clang/lib/Sema/SemaConcept.cpp
@@ -160,7 +160,7 @@
   Sema &SemaRef;
   bool Inserted = false;
   SatisfactionStackRAII(Sema &SemaRef, const NamedDecl *ND,
-llvm::FoldingSetNodeID FSNID)
+llvm::FoldingSetNodeID &FSNID)
   : SemaRef(SemaRef) {
   if (ND) {
   SemaRef.PushSatisfactionStackEntry(ND, FSNID);
@@ -1370,7 +1370,7 @@
 }
 
 template
-static bool subsumes(NormalForm PDNF, NormalForm QCNF,
+static bool subsumes(NormalForm &PDNF, NormalForm &QCNF,
  AtomicSubsumptionEvaluator E) {
   // C++ [temp.constr.order] p2
   //   Then, P subsumes Q if and only if, for every disjunctive clause Pi in 
the
Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -4148,7 +4148,7 @@
 
 static void HandleCodeCompleteResults(Sema *S,
   CodeCompleteConsumer *CodeCompleter,
-  CodeCompletionContext Context,
+  CodeCompletionContext &Context,
   CodeCompletionResult *Results,
   unsigned NumResults) {
   if (CodeCompleter)
Index: clang/lib/Sema/CodeCompleteConsumer.cpp
===
--- clang/lib/Sema/CodeCompleteConsumer.cpp
+++ clang/lib/Sema/CodeCompleteConsumer.cpp
@@ -638,8 +638,8 @@
 }
 
 void PrintingCodeCompleteConsumer::ProcessCodeCompleteResults(
-Sema &SemaRef, CodeCompletionContext Context, CodeCompletionResult 
*Results,
-unsigned NumResults) {
+Sema &SemaRef, CodeCompletionContext Context,
+CodeCompletionResult *Results, unsigned NumResults) {
   std::stable_sort(Results, Results + NumResults);
 
   if (!Context.getPreferredType().isNull())
Index: clang/lib/CodeGen/CodeGenAction.cpp
===
--- clang/lib/CodeGen/CodeGenAction.cpp
+++ clang/lib/CodeGen/CodeGenAction.cpp
@@ -86,7 +86,7 @@
   };
 
   static void reportOptRecordError(Error E, DiagnosticsEngine &Diags,
-   const CodeGenOptions CodeGenOpts) {
+   const CodeGenOptions &CodeGenOpts) {
 handleAllErrors(
 std::move(E),
   [&](const LLVMRemarkSetupFileError &E) {


Index: clang/lib/Sema/SemaConcept.cpp
===
--- clang/lib/Sema/SemaConcept.cpp
+++ clang/lib/Sema/SemaConcept.cpp
@@ -160,7 +160,7 @@
   Sema &SemaRef;
   bool Inserted = false;
   SatisfactionStackRAII(Sema &SemaRef, const NamedDecl *ND,
-llvm::FoldingSetNodeID FSNID)
+llvm::FoldingSetNodeID &FSNID)
   : SemaRef(SemaRef) {
   if (ND) {
   SemaRef.PushSatisfactionStackEntry(ND, FSNID);
@@ -1370,7 +1370,7 @@
 }
 
 template
-static bool subsumes(NormalForm PDNF, NormalForm QCNF,
+static bool subsumes(NormalForm &PDNF, NormalForm &QCNF,
  AtomicSubsumptionEvaluator E) {
   // C++ [temp.constr.order] p2
   //   Then, P subsumes Q if and only if, for every disjunctive clause Pi in the
Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -4148,7 +4148,7 @@
 
 static void HandleCodeCompleteResults(Sema *S,
   CodeCompleteConsumer *CodeCompleter,
-  CodeCompletionContext Context,
+  CodeCompletionContext &Context,
   CodeCompletionResult *Results,
   unsigned NumResults) {
   if (CodeCompleter)
Index: clang/lib/Sema/CodeCompleteConsumer.cpp
===
--- clang/lib/Sema/CodeCompleteConsumer.cpp
+++ clang/lib/Sema/CodeCompleteConsumer.cpp
@@ -638,8 +638,8 @@
 }
 
 void PrintingCodeCompleteConsumer::ProcessCodeCompleteResults(
-Sema &SemaRef, CodeCompletionContext Context, CodeCompletionResult *Results,
-unsigned NumResults) {
+Sema &SemaRef, CodeCompletionContext Context,
+CodeCompletionResult *Results, unsigned NumResults) {
   std::stable_sort(Results, Re

[PATCH] D147708: [NFC][clang] Fix static analyzer tool remarks about large copies by values

2023-04-06 Thread Soumi Manna via Phabricator via cfe-commits
Manna added a comment.

I have uploaded wrong one. I will fix it with new patch.


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

https://reviews.llvm.org/D147708

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


[PATCH] D147708: [NFC][clang] Fix static analyzer tool remarks about large copies by values

2023-04-06 Thread Soumi Manna via Phabricator via cfe-commits
Manna updated this revision to Diff 511486.
Manna added a comment.

I have addressed @erichkeane's review comments.


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

https://reviews.llvm.org/D147708

Files:
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/lib/Sema/SemaConcept.cpp


Index: clang/lib/Sema/SemaConcept.cpp
===
--- clang/lib/Sema/SemaConcept.cpp
+++ clang/lib/Sema/SemaConcept.cpp
@@ -160,7 +160,7 @@
   Sema &SemaRef;
   bool Inserted = false;
   SatisfactionStackRAII(Sema &SemaRef, const NamedDecl *ND,
-llvm::FoldingSetNodeID FSNID)
+const llvm::FoldingSetNodeID &FSNID)
   : SemaRef(SemaRef) {
   if (ND) {
   SemaRef.PushSatisfactionStackEntry(ND, FSNID);
@@ -1370,7 +1370,8 @@
 }
 
 template
-static bool subsumes(NormalForm PDNF, NormalForm QCNF,
+static bool subsumes(const NormalForm &PDNF,
+ const NormalForm &QCNF,
  AtomicSubsumptionEvaluator E) {
   // C++ [temp.constr.order] p2
   //   Then, P subsumes Q if and only if, for every disjunctive clause Pi in 
the
Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -4148,7 +4148,7 @@
 
 static void HandleCodeCompleteResults(Sema *S,
   CodeCompleteConsumer *CodeCompleter,
-  CodeCompletionContext Context,
+  const CodeCompletionContext &Context,
   CodeCompletionResult *Results,
   unsigned NumResults) {
   if (CodeCompleter)
Index: clang/lib/CodeGen/CodeGenAction.cpp
===
--- clang/lib/CodeGen/CodeGenAction.cpp
+++ clang/lib/CodeGen/CodeGenAction.cpp
@@ -86,7 +86,7 @@
   };
 
   static void reportOptRecordError(Error E, DiagnosticsEngine &Diags,
-   const CodeGenOptions CodeGenOpts) {
+   const CodeGenOptions &CodeGenOpts) {
 handleAllErrors(
 std::move(E),
   [&](const LLVMRemarkSetupFileError &E) {


Index: clang/lib/Sema/SemaConcept.cpp
===
--- clang/lib/Sema/SemaConcept.cpp
+++ clang/lib/Sema/SemaConcept.cpp
@@ -160,7 +160,7 @@
   Sema &SemaRef;
   bool Inserted = false;
   SatisfactionStackRAII(Sema &SemaRef, const NamedDecl *ND,
-llvm::FoldingSetNodeID FSNID)
+const llvm::FoldingSetNodeID &FSNID)
   : SemaRef(SemaRef) {
   if (ND) {
   SemaRef.PushSatisfactionStackEntry(ND, FSNID);
@@ -1370,7 +1370,8 @@
 }
 
 template
-static bool subsumes(NormalForm PDNF, NormalForm QCNF,
+static bool subsumes(const NormalForm &PDNF,
+ const NormalForm &QCNF,
  AtomicSubsumptionEvaluator E) {
   // C++ [temp.constr.order] p2
   //   Then, P subsumes Q if and only if, for every disjunctive clause Pi in the
Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -4148,7 +4148,7 @@
 
 static void HandleCodeCompleteResults(Sema *S,
   CodeCompleteConsumer *CodeCompleter,
-  CodeCompletionContext Context,
+  const CodeCompletionContext &Context,
   CodeCompletionResult *Results,
   unsigned NumResults) {
   if (CodeCompleter)
Index: clang/lib/CodeGen/CodeGenAction.cpp
===
--- clang/lib/CodeGen/CodeGenAction.cpp
+++ clang/lib/CodeGen/CodeGenAction.cpp
@@ -86,7 +86,7 @@
   };
 
   static void reportOptRecordError(Error E, DiagnosticsEngine &Diags,
-   const CodeGenOptions CodeGenOpts) {
+   const CodeGenOptions &CodeGenOpts) {
 handleAllErrors(
 std::move(E),
   [&](const LLVMRemarkSetupFileError &E) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D147708: [NFC][clang] Fix static analyzer tool remarks about large copies by values

2023-04-06 Thread Soumi Manna via Phabricator via cfe-commits
Manna updated this revision to Diff 511547.
Manna added a comment.

Fix clang-format error.


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

https://reviews.llvm.org/D147708

Files:
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/lib/Sema/SemaConcept.cpp


Index: clang/lib/Sema/SemaConcept.cpp
===
--- clang/lib/Sema/SemaConcept.cpp
+++ clang/lib/Sema/SemaConcept.cpp
@@ -160,7 +160,7 @@
   Sema &SemaRef;
   bool Inserted = false;
   SatisfactionStackRAII(Sema &SemaRef, const NamedDecl *ND,
-llvm::FoldingSetNodeID FSNID)
+const llvm::FoldingSetNodeID &FSNID)
   : SemaRef(SemaRef) {
   if (ND) {
   SemaRef.PushSatisfactionStackEntry(ND, FSNID);
@@ -1370,7 +1370,7 @@
 }
 
 template
-static bool subsumes(NormalForm PDNF, NormalForm QCNF,
+static bool subsumes(const NormalForm &PDNF, const NormalForm &QCNF,
  AtomicSubsumptionEvaluator E) {
   // C++ [temp.constr.order] p2
   //   Then, P subsumes Q if and only if, for every disjunctive clause Pi in 
the
Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -4148,7 +4148,7 @@
 
 static void HandleCodeCompleteResults(Sema *S,
   CodeCompleteConsumer *CodeCompleter,
-  CodeCompletionContext Context,
+  const CodeCompletionContext &Context,
   CodeCompletionResult *Results,
   unsigned NumResults) {
   if (CodeCompleter)
Index: clang/lib/CodeGen/CodeGenAction.cpp
===
--- clang/lib/CodeGen/CodeGenAction.cpp
+++ clang/lib/CodeGen/CodeGenAction.cpp
@@ -86,7 +86,7 @@
   };
 
   static void reportOptRecordError(Error E, DiagnosticsEngine &Diags,
-   const CodeGenOptions CodeGenOpts) {
+   const CodeGenOptions &CodeGenOpts) {
 handleAllErrors(
 std::move(E),
   [&](const LLVMRemarkSetupFileError &E) {


Index: clang/lib/Sema/SemaConcept.cpp
===
--- clang/lib/Sema/SemaConcept.cpp
+++ clang/lib/Sema/SemaConcept.cpp
@@ -160,7 +160,7 @@
   Sema &SemaRef;
   bool Inserted = false;
   SatisfactionStackRAII(Sema &SemaRef, const NamedDecl *ND,
-llvm::FoldingSetNodeID FSNID)
+const llvm::FoldingSetNodeID &FSNID)
   : SemaRef(SemaRef) {
   if (ND) {
   SemaRef.PushSatisfactionStackEntry(ND, FSNID);
@@ -1370,7 +1370,7 @@
 }
 
 template
-static bool subsumes(NormalForm PDNF, NormalForm QCNF,
+static bool subsumes(const NormalForm &PDNF, const NormalForm &QCNF,
  AtomicSubsumptionEvaluator E) {
   // C++ [temp.constr.order] p2
   //   Then, P subsumes Q if and only if, for every disjunctive clause Pi in the
Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -4148,7 +4148,7 @@
 
 static void HandleCodeCompleteResults(Sema *S,
   CodeCompleteConsumer *CodeCompleter,
-  CodeCompletionContext Context,
+  const CodeCompletionContext &Context,
   CodeCompletionResult *Results,
   unsigned NumResults) {
   if (CodeCompleter)
Index: clang/lib/CodeGen/CodeGenAction.cpp
===
--- clang/lib/CodeGen/CodeGenAction.cpp
+++ clang/lib/CodeGen/CodeGenAction.cpp
@@ -86,7 +86,7 @@
   };
 
   static void reportOptRecordError(Error E, DiagnosticsEngine &Diags,
-   const CodeGenOptions CodeGenOpts) {
+   const CodeGenOptions &CodeGenOpts) {
 handleAllErrors(
 std::move(E),
   [&](const LLVMRemarkSetupFileError &E) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D147757: Fix static analyzer tool remarks about unchecked return values

2023-04-06 Thread Soumi Manna via Phabricator via cfe-commits
Manna created this revision.
Manna added reviewers: erichkeane, aaron.ballman.
Herald added subscribers: manas, ASDenysPetrov, luismarques, s.egerton, dkrupp, 
donat.nagy, Szelethus, PkmX, a.sidorin, simoncook, baloghadamsoftware, 
kristof.beyls, arichardson.
Herald added a reviewer: NoQ.
Herald added a project: All.
Manna requested review of this revision.
Herald added a subscriber: pcwang-thead.
Herald added a project: clang.

Reported by Coverity:

Unchecked return value
If the function returns an error value, the error value may be mistaken for a 
normal value.

1. Inside "Parser.cpp" file, in 
clang::​Parser::​ParseKNRParamDeclarations(clang::​Declarator &): Value 
returned from a function is not checked for errors before being used.

check_return: Calling TryConsumeToken without checking return value (as is done 
elsewhere 75 out of 86 times).

2. Inside "CallGraph.h" file, in 
clang::​CallGraph::​addToCallGraph(clang::​Decl *): Value returned from a 
function is not checked for errors before being used.

check_return: Calling TraverseDecl without checking return value (as is done 
elsewhere 22 out of 23 times).

3. Inside "SemaExpr.cpp" file, in 
clang::​Sema::​BuildCXXDefaultArgExpr(clang::​SourceLocation, 
clang::​FunctionDecl *, clang::​ParmVarDecl *, clang::​Expr *): Value returned 
from a function is not checked for errors before being used.

check_return: Calling TraverseDecl without checking return value (as is done 
elsewhere 29 out of 31 times)

4. Inside "CGStmt.cpp" file, in 
clang::​CodeGen::​CodeGenFunction::​EmitAsmInput(clang::​TargetInfo::​ConstraintInfo
 const &, clang::​Expr const *, std::​__cxx11::​basic_string, std::​allocator> &): Value returned from a 
function is not checked for errors before being used.

check_return: Calling EvaluateAsRValue without checking return value (as is 
done elsewhere 21 out of 25 times).

5. Inside "SemaChecking.cpp" file, in 
clang::​Sema::​CheckRISCVBuiltinFunctionCall(clang::​TargetInfo const &, 
unsigned int, clang::​CallExpr *): Value returned from a function is not 
checked for errors before being used.

check_return: Calling consume_front without checking return value (as is done 
elsewhere 180 out of 213 times)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147757

Files:
  clang/include/clang/Analysis/CallGraph.h
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/Parse/Parser.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaExpr.cpp


Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -6033,7 +6033,7 @@
 // point where the enclosing initializer is used in a function call.
 ImmediateCallVisitor V;
 if (!NestedDefaultChecking)
-  V.TraverseDecl(Param);
+  V.(void)TraverseDecl(Param);
 if (V.HasImmediateCalls) {
   ExprEvalContexts.back().DelayedDefaultInitializationContext = {
   CallLoc, Param, CurContext};
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -4590,7 +4590,7 @@
 }
 
 // Convert features like "zbr" and "experimental-zbr" to "Zbr".
-OF.consume_front("experimental-");
+OF.(void)consume_front("experimental-");
 std::string FeatureStr = OF.str();
 FeatureStr[0] = std::toupper(FeatureStr[0]);
 // Combine strings.
Index: clang/lib/Parse/Parser.cpp
===
--- clang/lib/Parse/Parser.cpp
+++ clang/lib/Parse/Parser.cpp
@@ -1603,7 +1603,7 @@
 // Otherwise recover by skipping to next semi or mandatory function body.
 if (SkipUntil(tok::l_brace, StopAtSemi | StopBeforeMatch))
   break;
-TryConsumeToken(tok::semi);
+(void)TryConsumeToken(tok::semi);
   }
 
   // The actions module must verify that all arguments were declared.
Index: clang/lib/CodeGen/CGStmt.cpp
===
--- clang/lib/CodeGen/CGStmt.cpp
+++ clang/lib/CodeGen/CGStmt.cpp
@@ -2213,7 +2213,7 @@
   if (!Info.allowsRegister() && !Info.allowsMemory()) {
 if (Info.requiresImmediateConstant()) {
   Expr::EvalResult EVResult;
-  InputExpr->EvaluateAsRValue(EVResult, getContext(), true);
+  InputExpr->(void)EvaluateAsRValue(EVResult, getContext(), true);
 
   llvm::APSInt IntResult;
   if (EVResult.Val.toIntegralConstant(IntResult, InputExpr->getType(),
Index: clang/include/clang/Analysis/CallGraph.h
===
--- clang/include/clang/Analysis/CallGraph.h
+++ clang/include/clang/Analysis/CallGraph.h
@@ -60,7 +60,7 @@
   ///
   /// Recursively walks the declaration to find all the dependent Decls as 
well.
   void addToCallGraph(Decl *D) {
-TraverseDecl(D);
+(void)TraverseDecl(D);
   }
 
   /// Determine 

[PATCH] D147757: Fix static analyzer tool remarks about unchecked return values

2023-04-06 Thread Soumi Manna via Phabricator via cfe-commits
Manna abandoned this revision.
Manna added a comment.

Closing this revision.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147757

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


[PATCH] D147791: [NFC][CLANG] Fix static analyzer tool remarks about unchecked return values

2023-04-07 Thread Soumi Manna via Phabricator via cfe-commits
Manna created this revision.
Manna added reviewers: erichkeane, aaron.ballman.
Herald added subscribers: manas, ASDenysPetrov, dkrupp, donat.nagy, Szelethus, 
a.sidorin, baloghadamsoftware.
Herald added a reviewer: NoQ.
Herald added projects: All, clang, clang-format.
Herald added reviewers: rymiel, HazardyKnusperkeks, owenpan, MyDeveloperDay.
Manna requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Reported by Coverity:

Unchecked return value
If the function returns an error value, the error value may be mistaken for a 
normal value.

1. Inside "Parser.cpp" file, in 
clang::Parser::ParseKNRParamDeclarations(clang::Declarator &): Value returned 
from a function is not checked for errors before being used.

check_return: Calling TryConsumeToken without checking return value (as is done 
elsewhere 75 out of 86 times).

2. Inside "CallGraph.h" file, in clang::CallGraph::addToCallGraph(clang::Decl 
*): Value returned from a function is not checked for errors before being used.

check_return: Calling TraverseDecl without checking return value (as is done 
elsewhere 22 out of 23 times).

3. Inside "TokenAnnotator.cpp" file ,in 
clang::​format::​::​AnnotatingParser::​consumeToken(): Value returned 
from a function is not checked for errors before being used.

  check_return: Calling consumeToken without checking return value (as is done 
elsewhere 6 out of 7 times).

4. Inside "UnsafeBufferUsage.cpp" file, In 
clang::​ast_matchers::​MatchDescendantVisitor::​findMatch(clang::​DynTypedNode 
const &): Value returned from a function is not checked for errors before being 
used.

check_return: Calling TraverseStmt without checking return value (as is done 
elsewhere 485 out of 489 times)

5. Inside "ItaniumDemangle.h" file, in 
llvm::​itanium_demangle::​AbstractManglingParser::​CanonicalizerAllocator>,
 ::​CanonicalizerAllocator>::​parseFunctionType(): Value returned from 
a function is not checked for errors before being used.

  check_return: Calling consumeIf without checking return value (as is done 
elsewhere 47 out of 50 times).

6. Inside "ItaniumDemangle.h" file, in 
llvm::​itanium_demangle::​AbstractManglingParser::​CanonicalizerAllocator>,
 ::​CanonicalizerAllocator>::​parseBaseUnresolvedName(): Value 
returned from a function is not checked for errors before being used.

check_return: Calling consumeIf without checking return value (as is done 
elsewhere 47 out of 50 times).

7. Inside "ItaniumDemangle.h" file, in 
llvm::​itanium_demangle::​AbstractManglingParser,
 llvm::​esimd::​SimpleAllocator>::​parseNumber(bool): Value returned from a 
function is not checked for errors before being used.

check_return: Calling consumeIf without checking return value (as is done 
elsewhere 95 out of 102 times).

8. Inside "ExprConstant.cpp" file, in 
clang::​Expr::​isPotentialConstantExprUnevaluated(clang::​Expr *, 
clang::​FunctionDecl const *, 
llvm::​SmallVectorImpl> &): Value returned from a function is not checked 
for errors before being used.

check_return: Calling Evaluate without checking return value (as is done 
elsewhere 23 out of 27 times).

9. Inside "ASTMatchFinder.cpp" file, in 
clang::​ast_matchers::​internal::​::​MatchASTVisitor::​dataTraverseNode(clang::​Stmt
 *, llvm::​SmallVectorImpl, 
llvm::​PointerIntPairInfo>>> *): Value returned from a 
function is not checked for errors before being used.

check_return: Calling TraverseDecl without checking return value (as is done 
elsewhere 29 out of 33 times).

10. Inside "ParseObjc.cpp" file, in 
clang::​Parser::​isStartOfObjCClassMessageMissingOpenBracket(): Value returned 
from a function is not checked for errors before being used.

check_return: Calling TryAnnotateTypeOrScopeToken without checking return value 
(as is done elsewhere 19 out of 21 times).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147791

Files:
  clang/include/clang/Analysis/CallGraph.h
  clang/lib/AST/ExprConstant.cpp
  clang/lib/ASTMatchers/ASTMatchFinder.cpp
  clang/lib/Analysis/UnsafeBufferUsage.cpp
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Parse/ParseObjc.cpp
  clang/lib/Parse/Parser.cpp
  llvm/include/llvm/Demangle/ItaniumDemangle.h

Index: llvm/include/llvm/Demangle/ItaniumDemangle.h
===
--- llvm/include/llvm/Demangle/ItaniumDemangle.h
+++ llvm/include/llvm/Demangle/ItaniumDemangle.h
@@ -,7 +,7 @@
   if (consumeIf("dn"))
 return getDerived().parseDestructorName();
 
-  consumeIf("on");
+  (void)consumeIf("on");
 
   Node *Oper = getDerived().parseOperatorName(/*NameState=*/nullptr);
   if (Oper == nullptr)
@@ -3466,7 +3466,7 @@
 AbstractManglingParser::parseNumber(bool AllowNegative) {
   const char *Tmp = First;
   if (AllowNegative)
-consumeIf('n');
+(void)consumeIf('n');
   if (numLeft() == 0 || !std::isdigit(*First))
 return StringView();
   while (numLeft() != 0 && std::isdigit(*First))
@@ -3535,7 +353

[PATCH] D147791: [NFC][CLANG] Fix static analyzer tool remarks about unchecked return values

2023-04-07 Thread Soumi Manna via Phabricator via cfe-commits
Manna added a comment.

In D147791#4251497 , @erichkeane 
wrote:

> I don't see much value in these changes.  In the cases I know anything about, 
> the change in state (or out params) is the error checking that we need.  The 
> casts add nothing but noise, so I don't think these are good changes.

Thanks @erichkeane for reviews and feedback. I agree with you that all changes 
will silence the static analyzer tool but will not make any big impact. I can 
close them as a False positive if you are OK.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147791

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


[PATCH] D147708: [NFC][clang] Fix static analyzer tool remarks about large copies by values

2023-04-07 Thread Soumi Manna via Phabricator via cfe-commits
Manna added a comment.

Thanks @erichkeane.
I have committed the patch here: https://reviews.llvm.org/rG33cf2a39cb11


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

https://reviews.llvm.org/D147708

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


[PATCH] D147901: [NFC][CLANG][API] Fix coverity remarks about large copies by values

2023-04-09 Thread Soumi Manna via Phabricator via cfe-commits
Manna created this revision.
Manna added reviewers: erichkeane, aaron.ballman.
Herald added a reviewer: ributzka.
Herald added a project: All.
Manna requested review of this revision.
Herald added a reviewer: dang.
Herald added a project: clang.

Reported by Coverity Static Analyzer Tool:

Big parameter passed by value (PASS_BY_VALUE)
Copying large values is inefficient, consider passing by reference; Low, 
medium, and high size thresholds for detection can be adjusted.

1. pass_by_value: Passing parameter Availabilities of type 
clang::extractapi::AvailabilitySet (size 320 bytes) by value, which exceeds the 
medium threshold of 256 bytes in "API.cpp" and "API.h" files.

This patch passes parameter as const AvailabilitySet &Availabilities  instead 
of AvailabilitySet Availabilities.

2. Inside "APIIgnoresList.h" file,  in 
clang::​extractapi::​APIIgnoresList::​APIIgnoresList(llvm::​SmallVector, llvm::​SmallVector>, 13u>): A large function call 
parameter exceeding the medium threshold is passed by value.

pass_by_value: Passing parameter SymbolsToIgnore of type 
clang::extractapi::APIIgnoresList::SymbolNameList (size 268 bytes) by value, 
which exceeds the medium threshold of 256 bytes.

This patch passes parameter as const SymbolNameList &SymbolsToIgnore instead of 
SymbolNameList SymbolsToIgnore.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147901

Files:
  clang/include/clang/ExtractAPI/API.h
  clang/include/clang/ExtractAPI/APIIgnoresList.h
  clang/lib/ExtractAPI/API.cpp

Index: clang/lib/ExtractAPI/API.cpp
===
--- clang/lib/ExtractAPI/API.cpp
+++ clang/lib/ExtractAPI/API.cpp
@@ -46,7 +46,7 @@
 
 GlobalVariableRecord *
 APISet::addGlobalVar(StringRef Name, StringRef USR, PresumedLoc Loc,
- AvailabilitySet Availabilities, LinkageInfo Linkage,
+ const AvailabilitySet &Availabilities, LinkageInfo Linkage,
  const DocComment &Comment, DeclarationFragments Fragments,
  DeclarationFragments SubHeading, bool IsFromSystemHeader) {
   return addTopLevelRecord(USRBasedLookupTable, GlobalVariables, USR, Name, Loc,
@@ -56,7 +56,7 @@
 
 GlobalFunctionRecord *APISet::addGlobalFunction(
 StringRef Name, StringRef USR, PresumedLoc Loc,
-AvailabilitySet Availabilities, LinkageInfo Linkage,
+const AvailabilitySet &Availabilities, LinkageInfo Linkage,
 const DocComment &Comment, DeclarationFragments Fragments,
 DeclarationFragments SubHeading, FunctionSignature Signature,
 bool IsFromSystemHeader) {
@@ -66,13 +66,11 @@
IsFromSystemHeader);
 }
 
-EnumConstantRecord *APISet::addEnumConstant(EnumRecord *Enum, StringRef Name,
-StringRef USR, PresumedLoc Loc,
-AvailabilitySet Availabilities,
-const DocComment &Comment,
-DeclarationFragments Declaration,
-DeclarationFragments SubHeading,
-bool IsFromSystemHeader) {
+EnumConstantRecord *APISet::addEnumConstant(
+EnumRecord *Enum, StringRef Name, StringRef USR, PresumedLoc Loc,
+const AvailabilitySet &Availabilities, const DocComment &Comment,
+DeclarationFragments Declaration, DeclarationFragments SubHeading,
+bool IsFromSystemHeader) {
   auto Record = std::make_unique(
   USR, Name, Loc, std::move(Availabilities), Comment, Declaration,
   SubHeading, IsFromSystemHeader);
@@ -83,7 +81,7 @@
 }
 
 EnumRecord *APISet::addEnum(StringRef Name, StringRef USR, PresumedLoc Loc,
-AvailabilitySet Availabilities,
+const AvailabilitySet &Availabilities,
 const DocComment &Comment,
 DeclarationFragments Declaration,
 DeclarationFragments SubHeading,
@@ -95,7 +93,7 @@
 
 StructFieldRecord *APISet::addStructField(StructRecord *Struct, StringRef Name,
   StringRef USR, PresumedLoc Loc,
-  AvailabilitySet Availabilities,
+  const AvailabilitySet &Availabilities,
   const DocComment &Comment,
   DeclarationFragments Declaration,
   DeclarationFragments SubHeading,
@@ -110,7 +108,7 @@
 }
 
 StructRecord *APISet::addStruct(StringRef Name, StringRef USR, PresumedLoc Loc,
-AvailabilitySet Availabilities,
+const AvailabilitySet &Availabilities,
 const DocComment &Comment,
 DeclarationFragments Declaration

[PATCH] D147901: [NFC][CLANG][API] Fix coverity remarks about large copies by values

2023-04-09 Thread Soumi Manna via Phabricator via cfe-commits
Manna added a comment.

x64 debian failures seem unrelated to my fix: 
https://lab.llvm.org/buildbot/#/builders/21/builds/67315/steps/6/logs/stdio


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147901

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


[PATCH] D147708: [NFC][clang] Fix static analyzer tool remarks about large copies by values

2023-04-10 Thread Soumi Manna via Phabricator via cfe-commits
Manna closed this revision.
Manna added a comment.

I am closing this revision since it's already been pushed 
https://reviews.llvm.org/rG33cf2a39cb11


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

https://reviews.llvm.org/D147708

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


[PATCH] D147574: [NFC][clang] Fix Coverity static analyzer tool concerns about auto_causes_copy

2023-04-10 Thread Soumi Manna via Phabricator via cfe-commits
Manna closed this revision.
Manna added a comment.

I am closing this revision since it's already been pushed: 
https://reviews.llvm.org/rG59cb47015a18


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147574

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


[PATCH] D148189: [NFC][Clang] Fix static analyzer tool remark about missing user-defined assignment operator

2023-04-12 Thread Soumi Manna via Phabricator via cfe-commits
Manna created this revision.
Manna added reviewers: erichkeane, aaron.ballman.
Herald added subscribers: manas, ASDenysPetrov, dkrupp, donat.nagy, Szelethus, 
a.sidorin, baloghadamsoftware.
Herald added a reviewer: NoQ.
Herald added a project: All.
Manna requested review of this revision.
Herald added a project: clang.

Reported by Coverity:

Copy without assign
This class has a user-defined copy constructor but no user-defined assignment 
operator. If the copy constructor is necessary to manage owned resources then a 
corresponding assignment operator is usually required. If an object of this 
type is assigned memory leaks and/or use-after-free errors may occur. Note that 
a compiler-generated assignment operator will perform only a bit-wise copy for 
any fields that do not have their own assignment operators defined.

Class has user-written copy constructor but no user-written assignment operator

copy_without_assign: Class ::DeclUseTracker has a user-written copy 
constructor ::DeclUseTracker::DeclUseTracker(::DeclUseTracker 
const &) =delete but no corresponding user-written assignment operator.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D148189

Files:
  clang/lib/Analysis/UnsafeBufferUsage.cpp


Index: clang/lib/Analysis/UnsafeBufferUsage.cpp
===
--- clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -645,6 +645,7 @@
 public:
   DeclUseTracker() = default;
   DeclUseTracker(const DeclUseTracker &) = delete; // Let's avoid copies.
+  DeclUseTracker &operator=(const DeclUseTracker &) = delete;
   DeclUseTracker(DeclUseTracker &&) = default;
   DeclUseTracker &operator=(DeclUseTracker &&) = default;
 


Index: clang/lib/Analysis/UnsafeBufferUsage.cpp
===
--- clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -645,6 +645,7 @@
 public:
   DeclUseTracker() = default;
   DeclUseTracker(const DeclUseTracker &) = delete; // Let's avoid copies.
+  DeclUseTracker &operator=(const DeclUseTracker &) = delete;
   DeclUseTracker(DeclUseTracker &&) = default;
   DeclUseTracker &operator=(DeclUseTracker &&) = default;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D148189: [NFC][Clang] Fix static analyzer tool remark about missing user-defined assignment operator

2023-04-13 Thread Soumi Manna via Phabricator via cfe-commits
Manna added a comment.

Thank you @aaron.ballman for reviews and feedback.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148189

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


[PATCH] D148189: [NFC][Clang] Fix static analyzer tool remark about missing user-defined assignment operator

2023-04-13 Thread Soumi Manna via Phabricator via cfe-commits
Manna added a comment.

The lit test failure seem unrelated to my fix:
https://buildkite.com/llvm-project/premerge-checks/builds/146438#0187786e-2f04-40a2-acf1-78eee9f00e7f

Failed Tests (1):

  Clang :: SemaCXX/warn-unsafe-buffer-usage-fixits-pre-increment.cpp


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148189

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


[PATCH] D150968: [NFC][CLANG] Fix issue with dereference null return value found by Coverity static analyzer tool

2023-05-19 Thread Soumi Manna via Phabricator via cfe-commits
Manna created this revision.
Herald added subscribers: manas, ASDenysPetrov, dkrupp, donat.nagy, Szelethus, 
a.sidorin, baloghadamsoftware.
Herald added a project: All.
Manna requested review of this revision.
Herald added a project: clang.

Reported by Coverity:

  In 
clang::​FunctionDecl::​isReplaceableGlobalAllocationFunction(std::​optional *, bool *): Return value of function which returns null is dereferenced 
without checking 
  
  if (!IsSizedDelete && !Ty.isNull() && Ty->isEnumeralType()) {
   QualType T = Ty;
   //Condition TD, taking false branch.
  while (const auto *TD = T->getAs())
T = TD->getDecl()->getUnderlyingType();
//returned_null: getAs returns nullptr (checked 95 out of 97 times). 

  //Dereference null return value (NULL_RETURNS)
  // dereference: Dereferencing a pointer that might be nullptr T->getAs() 
when calling getDecl. 
  IdentifierInfo *II = T->getAs()->getDecl()->getIdentifier();
  if (II && II->isStr("__hot_cold_t"))
Consume();
}

This patch uses castAs instead of getAs which will assert if the type doesn't 
match.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150968

Files:
  clang/lib/AST/Decl.cpp


Index: clang/lib/AST/Decl.cpp
===
--- clang/lib/AST/Decl.cpp
+++ clang/lib/AST/Decl.cpp
@@ -3301,7 +3301,7 @@
 QualType T = Ty;
 while (const auto *TD = T->getAs())
   T = TD->getDecl()->getUnderlyingType();
-IdentifierInfo *II = T->getAs()->getDecl()->getIdentifier();
+IdentifierInfo *II = T->castAs()->getDecl()->getIdentifier();
 if (II && II->isStr("__hot_cold_t"))
   Consume();
   }


Index: clang/lib/AST/Decl.cpp
===
--- clang/lib/AST/Decl.cpp
+++ clang/lib/AST/Decl.cpp
@@ -3301,7 +3301,7 @@
 QualType T = Ty;
 while (const auto *TD = T->getAs())
   T = TD->getDecl()->getUnderlyingType();
-IdentifierInfo *II = T->getAs()->getDecl()->getIdentifier();
+IdentifierInfo *II = T->castAs()->getDecl()->getIdentifier();
 if (II && II->isStr("__hot_cold_t"))
   Consume();
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D150968: [NFC][CLANG] Fix issue with dereference null return value found by Coverity static analyzer tool

2023-05-19 Thread Soumi Manna via Phabricator via cfe-commits
Manna added a comment.

Thank you @erichkeane for review!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150968

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


[PATCH] D150895: [NFC][CLANG] Fix dereference issue before null check found by Coverity static analyzer tool

2023-05-19 Thread Soumi Manna via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Manna marked an inline comment as done.
Closed by commit rGbe37e3e25982: [NFC][CLANG] Fix dereference issue before null 
check found by Coverity static… (authored by Manna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150895

Files:
  clang/lib/Parse/ParsePragma.cpp


Index: clang/lib/Parse/ParsePragma.cpp
===
--- clang/lib/Parse/ParsePragma.cpp
+++ clang/lib/Parse/ParsePragma.cpp
@@ -4041,7 +4041,6 @@
 
   PP.Lex(Tok);
   II = Tok.getIdentifierInfo();
-  StringRef IntrinsicClass = II->getName();
   if (!II || !(II->isStr("vector") || II->isStr("sifive_vector"))) {
 PP.Diag(Tok.getLocation(), diag::warn_pragma_invalid_argument)
 << PP.getSpelling(Tok) << "riscv" << /*Expected=*/true
@@ -4056,8 +4055,8 @@
 return;
   }
 
-  if (IntrinsicClass == "vector")
+  if (II->isStr("vector"))
 Actions.DeclareRISCVVBuiltins = true;
-  else if (IntrinsicClass == "sifive_vector")
+  else if (II->isStr("sifive_vector"))
 Actions.DeclareRISCVVectorBuiltins = true;
 }


Index: clang/lib/Parse/ParsePragma.cpp
===
--- clang/lib/Parse/ParsePragma.cpp
+++ clang/lib/Parse/ParsePragma.cpp
@@ -4041,7 +4041,6 @@
 
   PP.Lex(Tok);
   II = Tok.getIdentifierInfo();
-  StringRef IntrinsicClass = II->getName();
   if (!II || !(II->isStr("vector") || II->isStr("sifive_vector"))) {
 PP.Diag(Tok.getLocation(), diag::warn_pragma_invalid_argument)
 << PP.getSpelling(Tok) << "riscv" << /*Expected=*/true
@@ -4056,8 +4055,8 @@
 return;
   }
 
-  if (IntrinsicClass == "vector")
+  if (II->isStr("vector"))
 Actions.DeclareRISCVVBuiltins = true;
-  else if (IntrinsicClass == "sifive_vector")
+  else if (II->isStr("sifive_vector"))
 Actions.DeclareRISCVVectorBuiltins = true;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D150744: [NFC][CLANG] Fix uninitialized scalar field issues found by Coverity

2023-05-19 Thread Soumi Manna via Phabricator via cfe-commits
Manna added inline comments.



Comment at: clang/include/clang/Parse/Parser.h:1190
   class ParseScopeFlags {
 Scope *CurScope;
+unsigned OldFlags = 0;

tahonermann wrote:
> shafik wrote:
> > @tahonermann I feel like we should have a default member initializer for 
> > any member that by default is not initialized. I realize in this case there 
> > currently should be no way for this to be bot initialized but that may not 
> > stay true and I don't believe there will be a penalty for doing this since 
> > it is initialized in the `mem-initializer-list` and therefore the default 
> > init should be omitted when calling the constructor. 
> I think that is very reasonable and I'm not opposed to such a policy. Per my 
> other comment, the trade off to always initializing is that a default 
> initializer can prevent use of tools like ubsan to discover when an 
> appropriate (presumably non-default) value has not been assigned. I suspect 
> (but have no data to draw on) that adding a default member initializer 
> prevents more bugs than would be found by tools like ubsan detecting use of 
> an uninitialized data member that should have a (non-default) assigned value.
> 
> I'm definitely in favor of using default member initializers over 
> `mem-initializer-list`!
>>since it is initialized in the mem-initializer-list and therefore the default 
>>init should be omitted when calling the constructor.

Agreed. That is motivated me to add default initialization. 

>>he trade off to always initializing is that a default initializer can prevent 
>>use of tools like ubsan to discover when an appropriate (presumably 
>>non-default) value has not been assigned. I suspect (but have no data to draw 
>>on) that adding a default member initializer prevents more bugs than would be 
>>found by tools like ubsan detecting use of an uninitialized data member that 
>>should have a (non-default) assigned value.

Thanks @tahonermann for the information! i was not aware of this ubsan tool.

@shafik and @tahonermann, thank you for your comments. Do you think we should 
hold off these changes for merging? 



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

https://reviews.llvm.org/D150744

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


[PATCH] D150931: [NFC][Clang][Coverity] Fix Static Code Analysis Concerns with copy without assign

2023-05-19 Thread Soumi Manna via Phabricator via cfe-commits
Manna updated this revision to Diff 523957.
Manna added a comment.

I have addressed review comments.


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

https://reviews.llvm.org/D150931

Files:
  clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h


Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
@@ -84,6 +84,10 @@
   CallEventRef(const T *Call) : IntrusiveRefCntPtr(Call) {}
   CallEventRef(const CallEventRef &Orig) : IntrusiveRefCntPtr(Orig) {}
 
+  // The copy assignment operator is defined as deleted pending further
+  // motivation.
+  CallEventRef &operator=(const CallEventRef &) = delete;
+
   CallEventRef cloneWithState(ProgramStateRef State) const {
 return this->get()->template cloneWithState(State);
   }
Index: clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h
===
--- clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h
+++ clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h
@@ -319,6 +319,7 @@
 protected:
   SExpr(TIL_Opcode Op) : Opcode(Op) {}
   SExpr(const SExpr &E) : Opcode(E.Opcode), Flags(E.Flags) {}
+  SExpr &operator=(const SExpr &) = delete
 
   const TIL_Opcode Opcode;
   unsigned char Reserved = 0;


Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
@@ -84,6 +84,10 @@
   CallEventRef(const T *Call) : IntrusiveRefCntPtr(Call) {}
   CallEventRef(const CallEventRef &Orig) : IntrusiveRefCntPtr(Orig) {}
 
+  // The copy assignment operator is defined as deleted pending further
+  // motivation.
+  CallEventRef &operator=(const CallEventRef &) = delete;
+
   CallEventRef cloneWithState(ProgramStateRef State) const {
 return this->get()->template cloneWithState(State);
   }
Index: clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h
===
--- clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h
+++ clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h
@@ -319,6 +319,7 @@
 protected:
   SExpr(TIL_Opcode Op) : Opcode(Op) {}
   SExpr(const SExpr &E) : Opcode(E.Opcode), Flags(E.Flags) {}
+  SExpr &operator=(const SExpr &) = delete
 
   const TIL_Opcode Opcode;
   unsigned char Reserved = 0;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D150931: [NFC][Clang][Coverity] Fix Static Code Analysis Concerns with copy without assign

2023-05-19 Thread Soumi Manna via Phabricator via cfe-commits
Manna marked 2 inline comments as done.
Manna added inline comments.



Comment at: clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h:323-324
 
+  // The copy assignment operator is defined as deleted pending further
+  // motivation.
+  SExpr &operator=(const SExpr &) = delete;

aaronpuchert wrote:
> We can probably even drop the comment. Types in an inheritance hierarchy tend 
> to be not assignable, and I don't see why it would ever be needed for what 
> amounts to be AST nodes.
Thank you @aaronpuchert for reviews and feedbacks. 

I have dropped the comment.



Comment at: clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h:387-389
+  // The copy assignment operator is defined as deleted pending further
+  // motivation.
+  Variable &operator=(const Variable &) = delete;

aaronpuchert wrote:
> My understanding is that deleting copy assignment on the base class 
> automatically deletes it for the derived classes, so I'd appreciate if we 
> could drop this and the following additions. That's just noise in my view.
> 
> Also, most of these classes don't seem to have a user-declared copy 
> constructor, or am I missing something?
Yup, Sounds reasonable to me. Removed


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

https://reviews.llvm.org/D150931

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


[PATCH] D151010: [NFC][CLANG] Fix issue with dereference null return value found by Coverity static analyzer tool

2023-05-19 Thread Soumi Manna via Phabricator via cfe-commits
Manna created this revision.
Manna added a reviewer: erichkeane.
Herald added subscribers: manas, ASDenysPetrov, dkrupp, donat.nagy, Szelethus, 
a.sidorin, baloghadamsoftware.
Herald added a project: All.
Manna requested review of this revision.
Herald added a project: clang.

Reported by Coverity static analyzer tool:

in TypeIsInnerPointer(clang::​QualType): Return value of function which returns 
null is dereferenced without checking

  if (OrigT == T || !T->isPointerType())
 return true;
   //returned_null: getAs returns nullptr (checked 229 out of 237 times). 
   //var_assigned: Assigning: PT = nullptr return value from getAs.
   const PointerType* PT = T->getAs();

   //Dereference null return value (NULL_RETURNS)
   //dereference: Dereferencing a pointer that might be nullptr PT when calling 
getPointeeType. 
   QualType UPointeeT = PT->getPointeeType().getUnqualifiedType();
   if (UPointeeT->isRecordType()) {
   //returned_null: getAs returns nullptr (checked 279 out of 294 times). 
   //var_assigned: Assigning: RecordTy = nullptr return value from getAs.
  const RecordType *RecordTy = UPointeeT->getAs();

  //Dereference null return value (NULL_RETURNS)
  //dereference: Dereferencing a pointer that might be nullptr RecordTy 
when calling getDecl. 
  if (!RecordTy->getDecl()->isCompleteDefinition())
 return false;
}

This patch uses castAs instead of getAs which will assert if the type doesn't 
match.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151010

Files:
  clang/lib/ARCMigrate/ObjCMT.cpp


Index: clang/lib/ARCMigrate/ObjCMT.cpp
===
--- clang/lib/ARCMigrate/ObjCMT.cpp
+++ clang/lib/ARCMigrate/ObjCMT.cpp
@@ -1056,10 +1056,10 @@
 T = TD->getDecl()->getUnderlyingType();
   if (OrigT == T || !T->isPointerType())
 return true;
-  const PointerType* PT = T->getAs();
+  const PointerType* PT = T->castAs();
   QualType UPointeeT = PT->getPointeeType().getUnqualifiedType();
   if (UPointeeT->isRecordType()) {
-const RecordType *RecordTy = UPointeeT->getAs();
+const RecordType *RecordTy = UPointeeT->castAs();
 if (!RecordTy->getDecl()->isCompleteDefinition())
   return false;
   }


Index: clang/lib/ARCMigrate/ObjCMT.cpp
===
--- clang/lib/ARCMigrate/ObjCMT.cpp
+++ clang/lib/ARCMigrate/ObjCMT.cpp
@@ -1056,10 +1056,10 @@
 T = TD->getDecl()->getUnderlyingType();
   if (OrigT == T || !T->isPointerType())
 return true;
-  const PointerType* PT = T->getAs();
+  const PointerType* PT = T->castAs();
   QualType UPointeeT = PT->getPointeeType().getUnqualifiedType();
   if (UPointeeT->isRecordType()) {
-const RecordType *RecordTy = UPointeeT->getAs();
+const RecordType *RecordTy = UPointeeT->castAs();
 if (!RecordTy->getDecl()->isCompleteDefinition())
   return false;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D150968: [NFC][CLANG] Fix issue with dereference null return value found by Coverity static analyzer tool

2023-05-19 Thread Soumi Manna via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG34d8cd153812: [NFC][CLANG] Fix issue with dereference null 
return value found by Coverity… (authored by Manna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150968

Files:
  clang/lib/AST/Decl.cpp


Index: clang/lib/AST/Decl.cpp
===
--- clang/lib/AST/Decl.cpp
+++ clang/lib/AST/Decl.cpp
@@ -3301,7 +3301,7 @@
 QualType T = Ty;
 while (const auto *TD = T->getAs())
   T = TD->getDecl()->getUnderlyingType();
-IdentifierInfo *II = T->getAs()->getDecl()->getIdentifier();
+IdentifierInfo *II = T->castAs()->getDecl()->getIdentifier();
 if (II && II->isStr("__hot_cold_t"))
   Consume();
   }


Index: clang/lib/AST/Decl.cpp
===
--- clang/lib/AST/Decl.cpp
+++ clang/lib/AST/Decl.cpp
@@ -3301,7 +3301,7 @@
 QualType T = Ty;
 while (const auto *TD = T->getAs())
   T = TD->getDecl()->getUnderlyingType();
-IdentifierInfo *II = T->getAs()->getDecl()->getIdentifier();
+IdentifierInfo *II = T->castAs()->getDecl()->getIdentifier();
 if (II && II->isStr("__hot_cold_t"))
   Consume();
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D151010: [NFC][CLANG] Fix issue with dereference null return value found by Coverity static analyzer tool

2023-05-19 Thread Soumi Manna via Phabricator via cfe-commits
Manna updated this revision to Diff 523983.
Manna added a comment.

Fix Clang-format error


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

https://reviews.llvm.org/D151010

Files:
  clang/lib/ARCMigrate/ObjCMT.cpp


Index: clang/lib/ARCMigrate/ObjCMT.cpp
===
--- clang/lib/ARCMigrate/ObjCMT.cpp
+++ clang/lib/ARCMigrate/ObjCMT.cpp
@@ -1056,10 +1056,10 @@
 T = TD->getDecl()->getUnderlyingType();
   if (OrigT == T || !T->isPointerType())
 return true;
-  const PointerType* PT = T->getAs();
+  const PointerType* PT = T->castAs();
   QualType UPointeeT = PT->getPointeeType().getUnqualifiedType();
   if (UPointeeT->isRecordType()) {
-const RecordType *RecordTy = UPointeeT->getAs();
+const RecordType *RecordTy = UPointeeT->castAs();
 if (!RecordTy->getDecl()->isCompleteDefinition())
   return false;
   }


Index: clang/lib/ARCMigrate/ObjCMT.cpp
===
--- clang/lib/ARCMigrate/ObjCMT.cpp
+++ clang/lib/ARCMigrate/ObjCMT.cpp
@@ -1056,10 +1056,10 @@
 T = TD->getDecl()->getUnderlyingType();
   if (OrigT == T || !T->isPointerType())
 return true;
-  const PointerType* PT = T->getAs();
+  const PointerType* PT = T->castAs();
   QualType UPointeeT = PT->getPointeeType().getUnqualifiedType();
   if (UPointeeT->isRecordType()) {
-const RecordType *RecordTy = UPointeeT->getAs();
+const RecordType *RecordTy = UPointeeT->castAs();
 if (!RecordTy->getDecl()->isCompleteDefinition())
   return false;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D151010: [NFC][CLANG] Fix issue with dereference null return value found by Coverity static analyzer tool

2023-05-19 Thread Soumi Manna via Phabricator via cfe-commits
Manna updated this revision to Diff 523986.

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

https://reviews.llvm.org/D151010

Files:
  clang/lib/ARCMigrate/ObjCMT.cpp


Index: clang/lib/ARCMigrate/ObjCMT.cpp
===
--- clang/lib/ARCMigrate/ObjCMT.cpp
+++ clang/lib/ARCMigrate/ObjCMT.cpp
@@ -1056,10 +1056,10 @@
 T = TD->getDecl()->getUnderlyingType();
   if (OrigT == T || !T->isPointerType())
 return true;
-  const PointerType* PT = T->getAs();
+  const PointerType *PT = T->castAs();
   QualType UPointeeT = PT->getPointeeType().getUnqualifiedType();
   if (UPointeeT->isRecordType()) {
-const RecordType *RecordTy = UPointeeT->getAs();
+const RecordType *RecordTy = UPointeeT->castAs();
 if (!RecordTy->getDecl()->isCompleteDefinition())
   return false;
   }


Index: clang/lib/ARCMigrate/ObjCMT.cpp
===
--- clang/lib/ARCMigrate/ObjCMT.cpp
+++ clang/lib/ARCMigrate/ObjCMT.cpp
@@ -1056,10 +1056,10 @@
 T = TD->getDecl()->getUnderlyingType();
   if (OrigT == T || !T->isPointerType())
 return true;
-  const PointerType* PT = T->getAs();
+  const PointerType *PT = T->castAs();
   QualType UPointeeT = PT->getPointeeType().getUnqualifiedType();
   if (UPointeeT->isRecordType()) {
-const RecordType *RecordTy = UPointeeT->getAs();
+const RecordType *RecordTy = UPointeeT->castAs();
 if (!RecordTy->getDecl()->isCompleteDefinition())
   return false;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D151010: [NFC][CLANG] Fix issue with dereference null return value found by Coverity static analyzer tool

2023-05-20 Thread Soumi Manna via Phabricator via cfe-commits
Manna abandoned this revision.
Manna added a comment.

This is False Positive. We are correctly checking type mismatch.


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

https://reviews.llvm.org/D151010

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


[PATCH] D150931: [NFC][Clang][Coverity] Fix Static Code Analysis Concerns with copy without assign

2023-05-20 Thread Soumi Manna via Phabricator via cfe-commits
Manna updated this revision to Diff 524044.
Manna marked 2 inline comments as done.
Manna added a comment.

I have updated patch to resolve build errors.


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

https://reviews.llvm.org/D150931

Files:
  clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h


Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
@@ -84,6 +84,10 @@
   CallEventRef(const T *Call) : IntrusiveRefCntPtr(Call) {}
   CallEventRef(const CallEventRef &Orig) : IntrusiveRefCntPtr(Orig) {}
 
+  // The copy assignment operator is defined as deleted pending further
+  // motivation.
+  CallEventRef &operator=(const CallEventRef &) = delete;
+
   CallEventRef cloneWithState(ProgramStateRef State) const {
 return this->get()->template cloneWithState(State);
   }
Index: clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h
===
--- clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h
+++ clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h
@@ -319,6 +319,7 @@
 protected:
   SExpr(TIL_Opcode Op) : Opcode(Op) {}
   SExpr(const SExpr &E) : Opcode(E.Opcode), Flags(E.Flags) {}
+  SExpr &operator=(const SExpr &) = delete;
 
   const TIL_Opcode Opcode;
   unsigned char Reserved = 0;


Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
@@ -84,6 +84,10 @@
   CallEventRef(const T *Call) : IntrusiveRefCntPtr(Call) {}
   CallEventRef(const CallEventRef &Orig) : IntrusiveRefCntPtr(Orig) {}
 
+  // The copy assignment operator is defined as deleted pending further
+  // motivation.
+  CallEventRef &operator=(const CallEventRef &) = delete;
+
   CallEventRef cloneWithState(ProgramStateRef State) const {
 return this->get()->template cloneWithState(State);
   }
Index: clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h
===
--- clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h
+++ clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h
@@ -319,6 +319,7 @@
 protected:
   SExpr(TIL_Opcode Op) : Opcode(Op) {}
   SExpr(const SExpr &E) : Opcode(E.Opcode), Flags(E.Flags) {}
+  SExpr &operator=(const SExpr &) = delete;
 
   const TIL_Opcode Opcode;
   unsigned char Reserved = 0;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D150931: [NFC][Clang][Coverity] Fix Static Code Analysis Concerns with copy without assign

2023-05-20 Thread Soumi Manna via Phabricator via cfe-commits
Manna added a comment.

In D150931#4358903 , @aaronpuchert 
wrote:

> Changes to `ThreadSafetyTIL.h` look good to me, thanks!

Thank you @aaronpuchert for reviews!


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

https://reviews.llvm.org/D150931

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


[PATCH] D151040: [NFC][CLANG] Fix static analyzer concerns

2023-05-20 Thread Soumi Manna via Phabricator via cfe-commits
Manna created this revision.
Herald added subscribers: manas, ASDenysPetrov, dkrupp, donat.nagy, Szelethus, 
a.sidorin, baloghadamsoftware.
Herald added a project: All.
Manna requested review of this revision.
Herald added a project: clang.

Dereference null return value

Inside "ExprConstant.cpp" file, in 
::​RecordExprEvaluator::​VisitCXXStdInitializerListExpr(clang::​CXXStdInitializerListExpr
 const *): Return value of function which returns null is dereferenced without 
checking.

  bool RecordExprEvaluator::VisitCXXStdInitializerListExpr(
   const CXXStdInitializerListExpr *E) {
   // returned_null: getAsConstantArrayType returns nullptr (checked 81 out 
of 93 times). [show details]
   //var_assigned: Assigning: ArrayType = nullptr return value from 
getAsConstantArrayType.
const ConstantArrayType *ArrayType =
   Info.Ctx.getAsConstantArrayType(E->getSubExpr()->getType());
LValue Array;
//Condition !EvaluateLValue(E->getSubExpr(), Array, this->Info, false), 
taking false branch.
if (!EvaluateLValue(E->getSubExpr(), Array, Info))
 return false;
  
// Get a pointer to the first element of the array.

   //Dereference null return value (NULL_RETURNS)
  //dereference: Dereferencing a pointer that might be nullptr ArrayType when 
calling addArray. [show details]
Array.addArray(Info, E, ArrayType);
  `

This patch adds an assert


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151040

Files:
  clang/lib/AST/ExprConstant.cpp


Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -10169,6 +10169,7 @@
 const CXXStdInitializerListExpr *E) {
   const ConstantArrayType *ArrayType =
   Info.Ctx.getAsConstantArrayType(E->getSubExpr()->getType());
+  assert(ArrayType && "unexpected type for array initializer");
 
   LValue Array;
   if (!EvaluateLValue(E->getSubExpr(), Array, Info))


Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -10169,6 +10169,7 @@
 const CXXStdInitializerListExpr *E) {
   const ConstantArrayType *ArrayType =
   Info.Ctx.getAsConstantArrayType(E->getSubExpr()->getType());
+  assert(ArrayType && "unexpected type for array initializer");
 
   LValue Array;
   if (!EvaluateLValue(E->getSubExpr(), Array, Info))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D151010: [NFC][CLANG] Fix issue with dereference null return value found by Coverity static analyzer tool

2023-05-21 Thread Soumi Manna via Phabricator via cfe-commits
Manna abandoned this revision.
Manna added a comment.

This is False Positive. We are correctly checking type mismatch.


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

https://reviews.llvm.org/D151010

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


[PATCH] D151040: [NFC][CLANG] Fix static code analyzer concerns

2023-05-22 Thread Soumi Manna via Phabricator via cfe-commits
Manna updated this revision to Diff 524291.
Manna added a comment.

Thank you @erichkeane for reviews. I have updated patch to avoid regression if 
the LValue doesn't evaluate right.


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

https://reviews.llvm.org/D151040

Files:
  clang/lib/AST/ExprConstant.cpp


Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -10174,6 +10174,8 @@
   if (!EvaluateLValue(E->getSubExpr(), Array, Info))
 return false;
 
+  assert(ArrayType && "unexpected type for array initializer");
+
   // Get a pointer to the first element of the array.
   Array.addArray(Info, E, ArrayType);
 


Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -10174,6 +10174,8 @@
   if (!EvaluateLValue(E->getSubExpr(), Array, Info))
 return false;
 
+  assert(ArrayType && "unexpected type for array initializer");
+
   // Get a pointer to the first element of the array.
   Array.addArray(Info, E, ArrayType);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D151130: [NFC][CLANG] Fix static code analyzer concerns with dereference null return value

2023-05-22 Thread Soumi Manna via Phabricator via cfe-commits
Manna created this revision.
Herald added subscribers: manas, ASDenysPetrov, dkrupp, donat.nagy, Szelethus, 
a.sidorin, baloghadamsoftware.
Herald added a project: All.
Manna requested review of this revision.
Herald added a project: clang.

Reported by Static Analyzer Tool:

Inside "SemaExprMember.cpp" file, in 
clang::​Sema::​BuildMemberReferenceExpr(clang::​Expr *, clang::​QualType, 
clang::​SourceLocation, bool, clang::​CXXScopeSpec &, clang::​SourceLocation, 
clang::​NamedDecl *, clang::​DeclarationNameInfo const &, 
clang::​TemplateArgumentListInfo const *, clang::​Scope const *, 
clang::​Sema::​ActOnMemberAccessExtraArgs *): Return value of function which 
returns null is dereferenced without checking

  //Condition !Base, taking true branch.
  if (!Base) {
TypoExpr *TE = nullptr;
QualType RecordTy = BaseType;
  
//Condition IsArrow, taking true branch.
 if (IsArrow) RecordTy = RecordTy->castAs()->getPointeeType();
//returned_null: getAs returns nullptr (checked 279 out of 294 times). 
[show details]
//Condition TemplateArgs != NULL, taking true branch.

 //Dereference null return value (NULL_RETURNS)
 //dereference: Dereferencing a pointer that might be nullptr 
RecordTy->getAs() when calling LookupMemberExprInRecord. [show details]
 if (LookupMemberExprInRecord(
   *this, R, nullptr, RecordTy->getAs(), OpLoc, IsArrow,
   SS, TemplateArgs != nullptr, TemplateKWLoc, TE))
return ExprError();
 if (TE)
   return TE;

This patch uses castAs instead of getAs which will assert if the type doesn't 
match.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151130

Files:
  clang/lib/Sema/SemaExprMember.cpp


Index: clang/lib/Sema/SemaExprMember.cpp
===
--- clang/lib/Sema/SemaExprMember.cpp
+++ clang/lib/Sema/SemaExprMember.cpp
@@ -767,7 +767,7 @@
 QualType RecordTy = BaseType;
 if (IsArrow) RecordTy = RecordTy->castAs()->getPointeeType();
 if (LookupMemberExprInRecord(
-*this, R, nullptr, RecordTy->getAs(), OpLoc, IsArrow,
+*this, R, nullptr, RecordTy->castAs(), OpLoc, IsArrow,
 SS, TemplateArgs != nullptr, TemplateKWLoc, TE))
   return ExprError();
 if (TE)


Index: clang/lib/Sema/SemaExprMember.cpp
===
--- clang/lib/Sema/SemaExprMember.cpp
+++ clang/lib/Sema/SemaExprMember.cpp
@@ -767,7 +767,7 @@
 QualType RecordTy = BaseType;
 if (IsArrow) RecordTy = RecordTy->castAs()->getPointeeType();
 if (LookupMemberExprInRecord(
-*this, R, nullptr, RecordTy->getAs(), OpLoc, IsArrow,
+*this, R, nullptr, RecordTy->castAs(), OpLoc, IsArrow,
 SS, TemplateArgs != nullptr, TemplateKWLoc, TE))
   return ExprError();
 if (TE)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D151137: ]NFC][Clang] Fix Coverity bug with dereference null return value in clang::​CodeGen::​CodeGenFunction::​EmitOMPArraySectionExpr()

2023-05-22 Thread Soumi Manna via Phabricator via cfe-commits
Manna created this revision.
Manna added a reviewer: erichkeane.
Herald added a project: All.
Manna requested review of this revision.

Reported by Coverity:

Inside  "CGExpr.cpp" file, in 
clang::​CodeGen::​CodeGenFunction::​EmitOMPArraySectionExpr(clang::​OMPArraySectionExpr
 const *, bool): Return value of function which returns null is dereferenced 
without checking.

} else {
//returned_null: getAsConstantArrayType returns nullptr (checked 83 out 
of 95 times).
// var_assigned: Assigning: CAT = nullptr return value from 
getAsConstantArrayType.
  auto *CAT = C.getAsConstantArrayType(ArrayTy);
//identity_transfer: Member function call CAT->getSize() returns an 
offset off CAT (this). 

 // Dereference null return value (NULL_RETURNS)
 //dereference: Dereferencing a pointer that might be nullptr 
CAT->getSize() when calling APInt. 
 ConstLength = CAT->getSize();
}

This patch adds an assert to resolve the bug.


https://reviews.llvm.org/D151137

Files:
  clang/lib/CodeGen/CGExpr.cpp


Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ clang/lib/CodeGen/CGExpr.cpp
@@ -4102,6 +4102,7 @@
 }
   } else {
 auto *CAT = C.getAsConstantArrayType(ArrayTy);
+assert(CAT && "unexpected type for array initializer");
 ConstLength = CAT->getSize();
   }
   if (Length) {


Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ clang/lib/CodeGen/CGExpr.cpp
@@ -4102,6 +4102,7 @@
 }
   } else {
 auto *CAT = C.getAsConstantArrayType(ArrayTy);
+assert(CAT && "unexpected type for array initializer");
 ConstLength = CAT->getSize();
   }
   if (Length) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D151130: [NFC][CLANG] Fix static code analyzer concerns with dereference null return value

2023-05-22 Thread Soumi Manna via Phabricator via cfe-commits
Manna added a comment.

Thank you @erichkeane for reviews!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151130

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


[PATCH] D151137: ]NFC][Clang] Fix Coverity bug with dereference null return value in clang::​CodeGen::​CodeGenFunction::​EmitOMPArraySectionExpr()

2023-05-22 Thread Soumi Manna via Phabricator via cfe-commits
Manna added a comment.

Thank you @erichkeane for reviews!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151137

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


[PATCH] D151130: [NFC][CLANG] Fix static code analyzer concerns with dereference null return value

2023-05-23 Thread Soumi Manna via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7586aeab7ad3: [NFC][CLANG] Fix static code analyzer concerns 
with dereference null return… (authored by Manna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151130

Files:
  clang/lib/Sema/SemaExprMember.cpp


Index: clang/lib/Sema/SemaExprMember.cpp
===
--- clang/lib/Sema/SemaExprMember.cpp
+++ clang/lib/Sema/SemaExprMember.cpp
@@ -767,7 +767,7 @@
 QualType RecordTy = BaseType;
 if (IsArrow) RecordTy = RecordTy->castAs()->getPointeeType();
 if (LookupMemberExprInRecord(
-*this, R, nullptr, RecordTy->getAs(), OpLoc, IsArrow,
+*this, R, nullptr, RecordTy->castAs(), OpLoc, IsArrow,
 SS, TemplateArgs != nullptr, TemplateKWLoc, TE))
   return ExprError();
 if (TE)


Index: clang/lib/Sema/SemaExprMember.cpp
===
--- clang/lib/Sema/SemaExprMember.cpp
+++ clang/lib/Sema/SemaExprMember.cpp
@@ -767,7 +767,7 @@
 QualType RecordTy = BaseType;
 if (IsArrow) RecordTy = RecordTy->castAs()->getPointeeType();
 if (LookupMemberExprInRecord(
-*this, R, nullptr, RecordTy->getAs(), OpLoc, IsArrow,
+*this, R, nullptr, RecordTy->castAs(), OpLoc, IsArrow,
 SS, TemplateArgs != nullptr, TemplateKWLoc, TE))
   return ExprError();
 if (TE)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D151137: ]NFC][Clang] Fix Coverity bug with dereference null return value in clang::​CodeGen::​CodeGenFunction::​EmitOMPArraySectionExpr()

2023-05-23 Thread Soumi Manna via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcc6a6c48d4bb: [NFC][Clang] Fix Coverity bug with dereference 
null return value in clang… (authored by Manna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151137

Files:
  clang/lib/CodeGen/CGExpr.cpp


Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ clang/lib/CodeGen/CGExpr.cpp
@@ -4102,6 +4102,7 @@
 }
   } else {
 auto *CAT = C.getAsConstantArrayType(ArrayTy);
+assert(CAT && "unexpected type for array initializer");
 ConstLength = CAT->getSize();
   }
   if (Length) {


Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ clang/lib/CodeGen/CGExpr.cpp
@@ -4102,6 +4102,7 @@
 }
   } else {
 auto *CAT = C.getAsConstantArrayType(ArrayTy);
+assert(CAT && "unexpected type for array initializer");
 ConstLength = CAT->getSize();
   }
   if (Length) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D151040: [NFC][CLANG] Fix static code analyzer concerns

2023-05-23 Thread Soumi Manna via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG64e9ba7048b8: [NFC][CLANG] Fix static code analyzer concerns 
(authored by Manna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151040

Files:
  clang/lib/AST/ExprConstant.cpp


Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -10174,6 +10174,8 @@
   if (!EvaluateLValue(E->getSubExpr(), Array, Info))
 return false;
 
+  assert(ArrayType && "unexpected type for array initializer");
+
   // Get a pointer to the first element of the array.
   Array.addArray(Info, E, ArrayType);
 


Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -10174,6 +10174,8 @@
   if (!EvaluateLValue(E->getSubExpr(), Array, Info))
 return false;
 
+  assert(ArrayType && "unexpected type for array initializer");
+
   // Get a pointer to the first element of the array.
   Array.addArray(Info, E, ArrayType);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D151054: [NFC][CLANG] Fix issue with dereference null return value found by Coverity static analyzer tool

2023-05-23 Thread Soumi Manna via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG806b0cd5ab56: [NFC][CLANG] Fix issue with dereference null 
return value found by Coverity… (authored by Manna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151054

Files:
  clang/lib/CodeGen/ItaniumCXXABI.cpp


Index: clang/lib/CodeGen/ItaniumCXXABI.cpp
===
--- clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -580,7 +580,7 @@
   CGBuilderTy &Builder = CGF.Builder;
 
   const FunctionProtoType *FPT =
-MPT->getPointeeType()->getAs();
+  MPT->getPointeeType()->castAs();
   auto *RD =
   cast(MPT->getClass()->castAs()->getDecl());
 


Index: clang/lib/CodeGen/ItaniumCXXABI.cpp
===
--- clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -580,7 +580,7 @@
   CGBuilderTy &Builder = CGF.Builder;
 
   const FunctionProtoType *FPT =
-MPT->getPointeeType()->getAs();
+  MPT->getPointeeType()->castAs();
   auto *RD =
   cast(MPT->getClass()->castAs()->getDecl());
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D151280: [NFC][CLANG] Fix static code analyzer concerns

2023-05-23 Thread Soumi Manna via Phabricator via cfe-commits
Manna created this revision.
Manna added a reviewer: erichkeane.
Herald added subscribers: manas, ASDenysPetrov, dkrupp, donat.nagy, Szelethus, 
a.sidorin, baloghadamsoftware.
Herald added a project: All.
Manna requested review of this revision.
Herald added a project: clang.

Reported by Static Analyzer Tool, Coverity:

Dereference null return value

Inside "CGExprConstant.cpp" file, in 
::​ConstExprEmitter::​VisitObjCEncodeExpr(clang::​ObjCEncodeExpr *, 
clang::​QualType): Return value of function which returns null is dereferenced 
without checking.

  std::string Str;
  CGM.getContext().getObjCEncodingForType(E->getEncodedType(), Str);
//returned_null: getAsConstantArrayType returns nullptr (checked 81 out 
of 93 times).
//var_assigned: Assigning: CAT = nullptr return value from 
getAsConstantArrayType.
  const ConstantArrayType *CAT = CGM.getContext().getAsConstantArrayType(T);
  
 // Resize the string to the right size, adding zeros at the end, or
 // truncating as needed.
identity_transfer: Member function call CAT->getSize() returns an 
offset off CAT (this). 

 //Dereference null return value (NULL_RETURNS)
 //dereference: Dereferencing a pointer that might be nullptr 
CAT->getSize() when calling getZExtValue.
 Str.resize(CAT->getSize().getZExtValue(), '\0');
 return llvm::ConstantDataArray::getString(VMContext, Str, false);

This patch adds an assert for unexpected type for array initializer.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151280

Files:
  clang/lib/CodeGen/CGExprConstant.cpp


Index: clang/lib/CodeGen/CGExprConstant.cpp
===
--- clang/lib/CodeGen/CGExprConstant.cpp
+++ clang/lib/CodeGen/CGExprConstant.cpp
@@ -1340,6 +1340,7 @@
 std::string Str;
 CGM.getContext().getObjCEncodingForType(E->getEncodedType(), Str);
 const ConstantArrayType *CAT = CGM.getContext().getAsConstantArrayType(T);
+assert(CAT && "unexpected type for array initializer");
 
 // Resize the string to the right size, adding zeros at the end, or
 // truncating as needed.


Index: clang/lib/CodeGen/CGExprConstant.cpp
===
--- clang/lib/CodeGen/CGExprConstant.cpp
+++ clang/lib/CodeGen/CGExprConstant.cpp
@@ -1340,6 +1340,7 @@
 std::string Str;
 CGM.getContext().getObjCEncodingForType(E->getEncodedType(), Str);
 const ConstantArrayType *CAT = CGM.getContext().getAsConstantArrayType(T);
+assert(CAT && "unexpected type for array initializer");
 
 // Resize the string to the right size, adding zeros at the end, or
 // truncating as needed.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D151281: [NFC][CLANG] Fix issue with dereference null return value found by Coverity

2023-05-23 Thread Soumi Manna via Phabricator via cfe-commits
Manna created this revision.
Manna added a reviewer: erichkeane.
Herald added a project: All.
Manna requested review of this revision.
Herald added a project: clang.

Reported by Static Analyzer Tool, Coverity:

Inside "SemaDeclCXX.cpp" file, in 
clang::​Sema::​CheckExplicitlyDefaultedSpecialMember(clang::​CXXMethodDecl *, 
clang::​Sema::​CXXSpecialMember, clang::​SourceLocation): Return value of 
function which returns null is dereferenced without checking.

  //returned_null: getAs returns nullptr (checked 117 out of 143 times). [show 
details]
  // var_assigned: Assigning: Type = nullptr return value from getAs.
  const FunctionProtoType *Type = MD->getType()->getAs();
  
  //Dereference null return value (NULL_RETURNS)
  //dereference: Dereferencing a pointer that might be nullptr Type when 
calling getReturnType. 
  ReturnType = Type->getReturnType();
  
  
  //Dereference null return value (NULL_RETURNS)
  //dereference: Dereferencing a pointer that might be nullptr Type when 
calling getParamType. 
  QualType ArgType = ExpectedParams ? Type->getParamType(0) : QualType();

This patch uses castAs instead of getAs which will assert if the type doesn't 
match.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151281

Files:
  clang/lib/Sema/SemaDeclCXX.cpp


Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -7517,7 +7517,7 @@
 }
   }
 
-  const FunctionProtoType *Type = MD->getType()->getAs();
+  const FunctionProtoType *Type = MD->getType()->castAs();
 
   bool CanHaveConstParam = false;
   if (CSM == CXXCopyConstructor)


Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -7517,7 +7517,7 @@
 }
   }
 
-  const FunctionProtoType *Type = MD->getType()->getAs();
+  const FunctionProtoType *Type = MD->getType()->castAs();
 
   bool CanHaveConstParam = false;
   if (CSM == CXXCopyConstructor)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D151281: [NFC][CLANG] Fix issue with dereference null return value found by Coverity

2023-05-24 Thread Soumi Manna via Phabricator via cfe-commits
Manna added a comment.

Thank you @erichkeane for reviews!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151281

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


[PATCH] D151280: [NFC][CLANG] Fix static code analyzer concerns

2023-05-24 Thread Soumi Manna via Phabricator via cfe-commits
Manna updated this revision to Diff 525388.
Manna added a comment.

Thank you @erichkeane for reviews! I have updated assert message.


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

https://reviews.llvm.org/D151280

Files:
  clang/lib/CodeGen/CGExprConstant.cpp


Index: clang/lib/CodeGen/CGExprConstant.cpp
===
--- clang/lib/CodeGen/CGExprConstant.cpp
+++ clang/lib/CodeGen/CGExprConstant.cpp
@@ -1340,6 +1340,7 @@
 std::string Str;
 CGM.getContext().getObjCEncodingForType(E->getEncodedType(), Str);
 const ConstantArrayType *CAT = CGM.getContext().getAsConstantArrayType(T);
+assert(CAT && "String data not of constant array type!");
 
 // Resize the string to the right size, adding zeros at the end, or
 // truncating as needed.


Index: clang/lib/CodeGen/CGExprConstant.cpp
===
--- clang/lib/CodeGen/CGExprConstant.cpp
+++ clang/lib/CodeGen/CGExprConstant.cpp
@@ -1340,6 +1340,7 @@
 std::string Str;
 CGM.getContext().getObjCEncodingForType(E->getEncodedType(), Str);
 const ConstantArrayType *CAT = CGM.getContext().getAsConstantArrayType(T);
+assert(CAT && "String data not of constant array type!");
 
 // Resize the string to the right size, adding zeros at the end, or
 // truncating as needed.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D151281: [NFC][CLANG] Fix issue with dereference null return value found by Coverity

2023-05-24 Thread Soumi Manna via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGad571e0d84b3: [NFC][CLANG] Fix issue with dereference null 
return value found by Coverity (authored by Manna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151281

Files:
  clang/lib/Sema/SemaDeclCXX.cpp


Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -7517,7 +7517,7 @@
 }
   }
 
-  const FunctionProtoType *Type = MD->getType()->getAs();
+  const FunctionProtoType *Type = MD->getType()->castAs();
 
   bool CanHaveConstParam = false;
   if (CSM == CXXCopyConstructor)


Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -7517,7 +7517,7 @@
 }
   }
 
-  const FunctionProtoType *Type = MD->getType()->getAs();
+  const FunctionProtoType *Type = MD->getType()->castAs();
 
   bool CanHaveConstParam = false;
   if (CSM == CXXCopyConstructor)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D151469: [NFC][CLANG] Fix issue with dereference null return value in EvaluateBuiltinClassifyType()

2023-05-25 Thread Soumi Manna via Phabricator via cfe-commits
Manna created this revision.
Manna added a reviewer: erichkeane.
Herald added a project: All.
Manna requested review of this revision.
Herald added a project: clang.

This patch uses cast instead of dyn_cast which will assert if the type doesn't 
match.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151469

Files:
  clang/lib/AST/ExprConstant.cpp


Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -11291,7 +11291,7 @@
   assert(!T->isDependentType() && "unexpected dependent type");
 
   QualType CanTy = T.getCanonicalType();
-  const BuiltinType *BT = dyn_cast(CanTy);
+  const BuiltinType *BT = cast(CanTy);
 
   switch (CanTy->getTypeClass()) {
 #define TYPE(ID, BASE)


Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -11291,7 +11291,7 @@
   assert(!T->isDependentType() && "unexpected dependent type");
 
   QualType CanTy = T.getCanonicalType();
-  const BuiltinType *BT = dyn_cast(CanTy);
+  const BuiltinType *BT = cast(CanTy);
 
   switch (CanTy->getTypeClass()) {
 #define TYPE(ID, BASE)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D151469: [NFC][CLANG] Fix issue with dereference null return value in EvaluateBuiltinClassifyType()

2023-05-25 Thread Soumi Manna via Phabricator via cfe-commits
Manna updated this revision to Diff 525697.
Manna added a comment.

Thank you @erichkeane for reviews! I have updated patch to avoid the regression.


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

https://reviews.llvm.org/D151469

Files:
  clang/lib/AST/ExprConstant.cpp


Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -11291,7 +11291,6 @@
   assert(!T->isDependentType() && "unexpected dependent type");
 
   QualType CanTy = T.getCanonicalType();
-  const BuiltinType *BT = dyn_cast(CanTy);
 
   switch (CanTy->getTypeClass()) {
 #define TYPE(ID, BASE)
@@ -11304,7 +11303,7 @@
   llvm_unreachable("unexpected non-canonical or dependent type");
 
   case Type::Builtin:
-switch (BT->getKind()) {
+switch (cast(CanTy)->getKind()) {
 #define BUILTIN_TYPE(ID, SINGLETON_ID)
 #define SIGNED_TYPE(ID, SINGLETON_ID) \
 case BuiltinType::ID: return GCCTypeClass::Integer;


Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -11291,7 +11291,6 @@
   assert(!T->isDependentType() && "unexpected dependent type");
 
   QualType CanTy = T.getCanonicalType();
-  const BuiltinType *BT = dyn_cast(CanTy);
 
   switch (CanTy->getTypeClass()) {
 #define TYPE(ID, BASE)
@@ -11304,7 +11303,7 @@
   llvm_unreachable("unexpected non-canonical or dependent type");
 
   case Type::Builtin:
-switch (BT->getKind()) {
+switch (cast(CanTy)->getKind()) {
 #define BUILTIN_TYPE(ID, SINGLETON_ID)
 #define SIGNED_TYPE(ID, SINGLETON_ID) \
 case BuiltinType::ID: return GCCTypeClass::Integer;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   3   >