[PATCH] D128608: [NFC][ASTImporter] remove the unnecessary condition checks in ASTImporter.cpp

2022-07-04 Thread Shivam Rajput via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG98c6a3c0c220: [NFC][ASTImporter] remove the unnecessary 
condition checks in ASTImporter.cpp (authored by phyBrackets).

Changed prior to commit:
  https://reviews.llvm.org/D128608?vs=440059&id=442167#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128608

Files:
  clang/include/clang/AST/ASTImportError.h
  clang/lib/AST/ASTImporter.cpp


Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -5667,11 +5667,6 @@
 D2->setPreviousDecl(Recent);
   }
 
-  if (FromTemplated->isCompleteDefinition() &&
-  !ToTemplated->isCompleteDefinition()) {
-// FIXME: Import definition!
-  }
-
   return D2;
 }
 
@@ -5950,11 +5945,6 @@
 ToVarTD->setPreviousDecl(Recent);
   }
 
-  if (DTemplated->isThisDeclarationADefinition() &&
-  !ToTemplated->isThisDeclarationADefinition()) {
-// FIXME: Import definition!
-  }
-
   return ToVarTD;
 }
 
Index: clang/include/clang/AST/ASTImportError.h
===
--- clang/include/clang/AST/ASTImportError.h
+++ clang/include/clang/AST/ASTImportError.h
@@ -19,7 +19,6 @@
 namespace clang {
 
 class ASTImportError : public llvm::ErrorInfo {
-
 public:
   /// \brief Kind of error when importing an AST component.
   enum ErrorKind {


Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -5667,11 +5667,6 @@
 D2->setPreviousDecl(Recent);
   }
 
-  if (FromTemplated->isCompleteDefinition() &&
-  !ToTemplated->isCompleteDefinition()) {
-// FIXME: Import definition!
-  }
-
   return D2;
 }
 
@@ -5950,11 +5945,6 @@
 ToVarTD->setPreviousDecl(Recent);
   }
 
-  if (DTemplated->isThisDeclarationADefinition() &&
-  !ToTemplated->isThisDeclarationADefinition()) {
-// FIXME: Import definition!
-  }
-
   return ToVarTD;
 }
 
Index: clang/include/clang/AST/ASTImportError.h
===
--- clang/include/clang/AST/ASTImportError.h
+++ clang/include/clang/AST/ASTImportError.h
@@ -19,7 +19,6 @@
 namespace clang {
 
 class ASTImportError : public llvm::ErrorInfo {
-
 public:
   /// \brief Kind of error when importing an AST component.
   enum ErrorKind {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D119268: avoid the warning of assignment operation inside the if statement

2022-02-08 Thread Shivam Rajput via Phabricator via cfe-commits
phyBrackets created this revision.
Herald added a subscriber: martong.
phyBrackets requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D119268

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


Index: clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -946,7 +946,7 @@
   // FIXME: This is a simplified version of what's in CFRefCount.cpp -- it 
makes
   // some assumptions about the value that CFRefCount can't. Even so, it should
   // probably be refactored.
-  if (Optional MR = L->getAs()) {
+  if ((Optional MR = L->getAs())) {
 const MemRegion *R = MR->getRegion()->StripCasts();
 
 // Are we dealing with an ElementRegion?  If so, we should be invalidating


Index: clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -946,7 +946,7 @@
   // FIXME: This is a simplified version of what's in CFRefCount.cpp -- it makes
   // some assumptions about the value that CFRefCount can't. Even so, it should
   // probably be refactored.
-  if (Optional MR = L->getAs()) {
+  if ((Optional MR = L->getAs())) {
 const MemRegion *R = MR->getRegion()->StripCasts();
 
 // Are we dealing with an ElementRegion?  If so, we should be invalidating
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D119364: Refactor nested if else with ternary operator

2022-02-09 Thread Shivam Rajput via Phabricator via cfe-commits
phyBrackets created this revision.
phyBrackets requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D119364

Files:
  clang/lib/CodeGen/CGExprScalar.cpp


Index: clang/lib/CodeGen/CGExprScalar.cpp
===
--- clang/lib/CodeGen/CGExprScalar.cpp
+++ clang/lib/CodeGen/CGExprScalar.cpp
@@ -65,20 +65,14 @@
   const auto &LHSAP = LHS->getValue();
   const auto &RHSAP = RHS->getValue();
   if (Opcode == BO_Add) {
-if (Signed)
-  Result = LHSAP.sadd_ov(RHSAP, Overflow);
-else
-  Result = LHSAP.uadd_ov(RHSAP, Overflow);
+Result = Signed ? LHSAP.sadd_ov(RHSAP, Overflow)
+: LHSAP.uadd_ov(RHSAP, Overflow);
   } else if (Opcode == BO_Sub) {
-if (Signed)
-  Result = LHSAP.ssub_ov(RHSAP, Overflow);
-else
-  Result = LHSAP.usub_ov(RHSAP, Overflow);
+Result = Signed ? LHSAP.ssub_ov(RHSAP, Overflow)
+: LHSAP.usub_ov(RHSAP, Overflow);
   } else if (Opcode == BO_Mul) {
-if (Signed)
-  Result = LHSAP.smul_ov(RHSAP, Overflow);
-else
-  Result = LHSAP.umul_ov(RHSAP, Overflow);
+Result = Signed ? LHSAP.smul_ov(RHSAP, Overflow)
+: LHSAP.umul_ov(RHSAP, Overflow);
   } else if (Opcode == BO_Div || Opcode == BO_Rem) {
 if (Signed && !RHS->isZero())
   Result = LHSAP.sdiv_ov(RHSAP, Overflow);


Index: clang/lib/CodeGen/CGExprScalar.cpp
===
--- clang/lib/CodeGen/CGExprScalar.cpp
+++ clang/lib/CodeGen/CGExprScalar.cpp
@@ -65,20 +65,14 @@
   const auto &LHSAP = LHS->getValue();
   const auto &RHSAP = RHS->getValue();
   if (Opcode == BO_Add) {
-if (Signed)
-  Result = LHSAP.sadd_ov(RHSAP, Overflow);
-else
-  Result = LHSAP.uadd_ov(RHSAP, Overflow);
+Result = Signed ? LHSAP.sadd_ov(RHSAP, Overflow)
+: LHSAP.uadd_ov(RHSAP, Overflow);
   } else if (Opcode == BO_Sub) {
-if (Signed)
-  Result = LHSAP.ssub_ov(RHSAP, Overflow);
-else
-  Result = LHSAP.usub_ov(RHSAP, Overflow);
+Result = Signed ? LHSAP.ssub_ov(RHSAP, Overflow)
+: LHSAP.usub_ov(RHSAP, Overflow);
   } else if (Opcode == BO_Mul) {
-if (Signed)
-  Result = LHSAP.smul_ov(RHSAP, Overflow);
-else
-  Result = LHSAP.umul_ov(RHSAP, Overflow);
+Result = Signed ? LHSAP.smul_ov(RHSAP, Overflow)
+: LHSAP.umul_ov(RHSAP, Overflow);
   } else if (Opcode == BO_Div || Opcode == BO_Rem) {
 if (Signed && !RHS->isZero())
   Result = LHSAP.sdiv_ov(RHSAP, Overflow);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D119462: resolve the bugtype typo inside emitAdditionOverflowbug function

2022-02-10 Thread Shivam Rajput via Phabricator via cfe-commits
phyBrackets created this revision.
Herald added a subscriber: martong.
phyBrackets requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D119462

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


Index: clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -257,7 +257,6 @@
   void emitNotCStringBug(CheckerContext &C, ProgramStateRef State,
  const Stmt *S, StringRef WarningMsg) const;
   void emitAdditionOverflowBug(CheckerContext &C, ProgramStateRef State) const;
-
   ProgramStateRef checkAdditionOverflow(CheckerContext &C,
 ProgramStateRef state,
 NonLoc left,
@@ -420,7 +419,6 @@
 
 SVal BufEnd =
 svalBuilder.evalBinOpLN(State, BO_Add, *BufLoc, LastOffset, PtrTy);
-
 State = CheckLocation(C, State, Buffer, BufEnd, Access);
 
 // If the buffer isn't large enough, abort.
@@ -622,8 +620,8 @@
 void CStringChecker::emitAdditionOverflowBug(CheckerContext &C,
  ProgramStateRef State) const {
   if (ExplodedNode *N = C.generateErrorNode(State)) {
-if (!BT_NotCString)
-  BT_NotCString.reset(
+if (!BT_AdditionOverflow)
+  BT_AdditionOverflow.reset(
   new BuiltinBug(Filter.CheckNameCStringOutOfBounds, "API",
  "Sum of expressions causes overflow."));
 
@@ -634,8 +632,8 @@
 "This expression will create a string whose length is too big to "
 "be represented as a size_t";
 
-auto Report =
-std::make_unique(*BT_NotCString, WarningMsg, 
N);
+auto Report = 
std::make_unique(*BT_AdditionOverflow,
+   WarningMsg, N);
 C.emitReport(std::move(Report));
   }
 }


Index: clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -257,7 +257,6 @@
   void emitNotCStringBug(CheckerContext &C, ProgramStateRef State,
  const Stmt *S, StringRef WarningMsg) const;
   void emitAdditionOverflowBug(CheckerContext &C, ProgramStateRef State) const;
-
   ProgramStateRef checkAdditionOverflow(CheckerContext &C,
 ProgramStateRef state,
 NonLoc left,
@@ -420,7 +419,6 @@
 
 SVal BufEnd =
 svalBuilder.evalBinOpLN(State, BO_Add, *BufLoc, LastOffset, PtrTy);
-
 State = CheckLocation(C, State, Buffer, BufEnd, Access);
 
 // If the buffer isn't large enough, abort.
@@ -622,8 +620,8 @@
 void CStringChecker::emitAdditionOverflowBug(CheckerContext &C,
  ProgramStateRef State) const {
   if (ExplodedNode *N = C.generateErrorNode(State)) {
-if (!BT_NotCString)
-  BT_NotCString.reset(
+if (!BT_AdditionOverflow)
+  BT_AdditionOverflow.reset(
   new BuiltinBug(Filter.CheckNameCStringOutOfBounds, "API",
  "Sum of expressions causes overflow."));
 
@@ -634,8 +632,8 @@
 "This expression will create a string whose length is too big to "
 "be represented as a size_t";
 
-auto Report =
-std::make_unique(*BT_NotCString, WarningMsg, N);
+auto Report = std::make_unique(*BT_AdditionOverflow,
+   WarningMsg, N);
 C.emitReport(std::move(Report));
   }
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D119462: resolve the bugtype typo inside emitAdditionOverflowbug function in CStringChecker.cpp.

2022-02-10 Thread Shivam Rajput via Phabricator via cfe-commits
phyBrackets updated this revision to Diff 407623.
phyBrackets added a comment.

Use the git blame


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119462

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


Index: clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -257,7 +257,6 @@
   void emitNotCStringBug(CheckerContext &C, ProgramStateRef State,
  const Stmt *S, StringRef WarningMsg) const;
   void emitAdditionOverflowBug(CheckerContext &C, ProgramStateRef State) const;
-
   ProgramStateRef checkAdditionOverflow(CheckerContext &C,
 ProgramStateRef state,
 NonLoc left,
@@ -420,7 +419,6 @@
 
 SVal BufEnd =
 svalBuilder.evalBinOpLN(State, BO_Add, *BufLoc, LastOffset, PtrTy);
-
 State = CheckLocation(C, State, Buffer, BufEnd, Access);
 
 // If the buffer isn't large enough, abort.
@@ -622,8 +620,8 @@
 void CStringChecker::emitAdditionOverflowBug(CheckerContext &C,
  ProgramStateRef State) const {
   if (ExplodedNode *N = C.generateErrorNode(State)) {
-if (!BT_NotCString)
-  BT_NotCString.reset(
+if (!BT_AdditionOverflow)
+  BT_AdditionOverflow.reset(
   new BuiltinBug(Filter.CheckNameCStringOutOfBounds, "API",
  "Sum of expressions causes overflow."));
 
@@ -634,8 +632,8 @@
 "This expression will create a string whose length is too big to "
 "be represented as a size_t";
 
-auto Report =
-std::make_unique(*BT_NotCString, WarningMsg, 
N);
+auto Report = 
std::make_unique(*BT_AdditionOverflow,
+   WarningMsg, N);
 C.emitReport(std::move(Report));
   }
 }


Index: clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -257,7 +257,6 @@
   void emitNotCStringBug(CheckerContext &C, ProgramStateRef State,
  const Stmt *S, StringRef WarningMsg) const;
   void emitAdditionOverflowBug(CheckerContext &C, ProgramStateRef State) const;
-
   ProgramStateRef checkAdditionOverflow(CheckerContext &C,
 ProgramStateRef state,
 NonLoc left,
@@ -420,7 +419,6 @@
 
 SVal BufEnd =
 svalBuilder.evalBinOpLN(State, BO_Add, *BufLoc, LastOffset, PtrTy);
-
 State = CheckLocation(C, State, Buffer, BufEnd, Access);
 
 // If the buffer isn't large enough, abort.
@@ -622,8 +620,8 @@
 void CStringChecker::emitAdditionOverflowBug(CheckerContext &C,
  ProgramStateRef State) const {
   if (ExplodedNode *N = C.generateErrorNode(State)) {
-if (!BT_NotCString)
-  BT_NotCString.reset(
+if (!BT_AdditionOverflow)
+  BT_AdditionOverflow.reset(
   new BuiltinBug(Filter.CheckNameCStringOutOfBounds, "API",
  "Sum of expressions causes overflow."));
 
@@ -634,8 +632,8 @@
 "This expression will create a string whose length is too big to "
 "be represented as a size_t";
 
-auto Report =
-std::make_unique(*BT_NotCString, WarningMsg, N);
+auto Report = std::make_unique(*BT_AdditionOverflow,
+   WarningMsg, N);
 C.emitReport(std::move(Report));
   }
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D119364: Refactor nested if else with ternary operator in CGExprScalar.cpp

2022-02-11 Thread Shivam Rajput via Phabricator via cfe-commits
phyBrackets added a comment.

In D119364#3310170 , @rjmccall wrote:

> Sure, LGTM

Yeah, will keep in mind. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119364

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


[PATCH] D119364: Refactor nested if else with ternary operator in CGExprScalar.cpp

2022-02-11 Thread Shivam Rajput via Phabricator via cfe-commits
phyBrackets added a comment.

In D119364#3310170 , @rjmccall wrote:

> Sure, LGTM

Hey Thanks, would you please help to land this patch . I don't have commit 
access .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119364

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


[PATCH] D119462: [analyzer][NFCi] Use the correct BugType in CStringChecker.

2022-02-11 Thread Shivam Rajput via Phabricator via cfe-commits
phyBrackets added a comment.

In D119462#3312482 , @steakhal wrote:

> I would recommend not touching the unrelated lines, unless you have a clear 
> motive. Other than that I think its fair to say that this must have been a 
> bug. Ill check the report diff tomorrow, prior accepting this.

Yeah will keep in mind. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119462

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


[PATCH] D119364: Refactor nested if else with ternary operator in CGExprScalar.cpp

2022-02-12 Thread Shivam Rajput via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGde4e855204aa: Refactor nested if else with ternary operator 
in CGExprScalar.cpp (authored by phyBrackets).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119364

Files:
  clang/lib/CodeGen/CGExprScalar.cpp


Index: clang/lib/CodeGen/CGExprScalar.cpp
===
--- clang/lib/CodeGen/CGExprScalar.cpp
+++ clang/lib/CodeGen/CGExprScalar.cpp
@@ -65,20 +65,14 @@
   const auto &LHSAP = LHS->getValue();
   const auto &RHSAP = RHS->getValue();
   if (Opcode == BO_Add) {
-if (Signed)
-  Result = LHSAP.sadd_ov(RHSAP, Overflow);
-else
-  Result = LHSAP.uadd_ov(RHSAP, Overflow);
+Result = Signed ? LHSAP.sadd_ov(RHSAP, Overflow)
+: LHSAP.uadd_ov(RHSAP, Overflow);
   } else if (Opcode == BO_Sub) {
-if (Signed)
-  Result = LHSAP.ssub_ov(RHSAP, Overflow);
-else
-  Result = LHSAP.usub_ov(RHSAP, Overflow);
+Result = Signed ? LHSAP.ssub_ov(RHSAP, Overflow)
+: LHSAP.usub_ov(RHSAP, Overflow);
   } else if (Opcode == BO_Mul) {
-if (Signed)
-  Result = LHSAP.smul_ov(RHSAP, Overflow);
-else
-  Result = LHSAP.umul_ov(RHSAP, Overflow);
+Result = Signed ? LHSAP.smul_ov(RHSAP, Overflow)
+: LHSAP.umul_ov(RHSAP, Overflow);
   } else if (Opcode == BO_Div || Opcode == BO_Rem) {
 if (Signed && !RHS->isZero())
   Result = LHSAP.sdiv_ov(RHSAP, Overflow);


Index: clang/lib/CodeGen/CGExprScalar.cpp
===
--- clang/lib/CodeGen/CGExprScalar.cpp
+++ clang/lib/CodeGen/CGExprScalar.cpp
@@ -65,20 +65,14 @@
   const auto &LHSAP = LHS->getValue();
   const auto &RHSAP = RHS->getValue();
   if (Opcode == BO_Add) {
-if (Signed)
-  Result = LHSAP.sadd_ov(RHSAP, Overflow);
-else
-  Result = LHSAP.uadd_ov(RHSAP, Overflow);
+Result = Signed ? LHSAP.sadd_ov(RHSAP, Overflow)
+: LHSAP.uadd_ov(RHSAP, Overflow);
   } else if (Opcode == BO_Sub) {
-if (Signed)
-  Result = LHSAP.ssub_ov(RHSAP, Overflow);
-else
-  Result = LHSAP.usub_ov(RHSAP, Overflow);
+Result = Signed ? LHSAP.ssub_ov(RHSAP, Overflow)
+: LHSAP.usub_ov(RHSAP, Overflow);
   } else if (Opcode == BO_Mul) {
-if (Signed)
-  Result = LHSAP.smul_ov(RHSAP, Overflow);
-else
-  Result = LHSAP.umul_ov(RHSAP, Overflow);
+Result = Signed ? LHSAP.smul_ov(RHSAP, Overflow)
+: LHSAP.umul_ov(RHSAP, Overflow);
   } else if (Opcode == BO_Div || Opcode == BO_Rem) {
 if (Signed && !RHS->isZero())
   Result = LHSAP.sdiv_ov(RHSAP, Overflow);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D119364: Refactor nested if else with ternary operator in CGExprScalar.cpp

2022-02-12 Thread Shivam Rajput via Phabricator via cfe-commits
phyBrackets added a comment.

Hey @rjmccall , would you tell me about this build fail 
https://green.lab.llvm.org/green/job/lldb-cmake/41339/


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119364

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


[PATCH] D119462: [analyzer][NFCi] Use the correct BugType in CStringChecker.

2022-02-14 Thread Shivam Rajput via Phabricator via cfe-commits
phyBrackets added a comment.

Hey @steakhal , any updates on this ? should I commit it ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119462

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


[PATCH] D119462: [analyzer][NFCi] Use the correct BugType in CStringChecker.

2022-02-14 Thread Shivam Rajput via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6745b6a0f185: [analyzer][NFCi] Use the correct BugType in 
CStringChecker. (authored by phyBrackets).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119462

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


Index: clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -257,7 +257,6 @@
   void emitNotCStringBug(CheckerContext &C, ProgramStateRef State,
  const Stmt *S, StringRef WarningMsg) const;
   void emitAdditionOverflowBug(CheckerContext &C, ProgramStateRef State) const;
-
   ProgramStateRef checkAdditionOverflow(CheckerContext &C,
 ProgramStateRef state,
 NonLoc left,
@@ -420,7 +419,6 @@
 
 SVal BufEnd =
 svalBuilder.evalBinOpLN(State, BO_Add, *BufLoc, LastOffset, PtrTy);
-
 State = CheckLocation(C, State, Buffer, BufEnd, Access);
 
 // If the buffer isn't large enough, abort.
@@ -622,8 +620,8 @@
 void CStringChecker::emitAdditionOverflowBug(CheckerContext &C,
  ProgramStateRef State) const {
   if (ExplodedNode *N = C.generateErrorNode(State)) {
-if (!BT_NotCString)
-  BT_NotCString.reset(
+if (!BT_AdditionOverflow)
+  BT_AdditionOverflow.reset(
   new BuiltinBug(Filter.CheckNameCStringOutOfBounds, "API",
  "Sum of expressions causes overflow."));
 
@@ -634,8 +632,8 @@
 "This expression will create a string whose length is too big to "
 "be represented as a size_t";
 
-auto Report =
-std::make_unique(*BT_NotCString, WarningMsg, 
N);
+auto Report = 
std::make_unique(*BT_AdditionOverflow,
+   WarningMsg, N);
 C.emitReport(std::move(Report));
   }
 }


Index: clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -257,7 +257,6 @@
   void emitNotCStringBug(CheckerContext &C, ProgramStateRef State,
  const Stmt *S, StringRef WarningMsg) const;
   void emitAdditionOverflowBug(CheckerContext &C, ProgramStateRef State) const;
-
   ProgramStateRef checkAdditionOverflow(CheckerContext &C,
 ProgramStateRef state,
 NonLoc left,
@@ -420,7 +419,6 @@
 
 SVal BufEnd =
 svalBuilder.evalBinOpLN(State, BO_Add, *BufLoc, LastOffset, PtrTy);
-
 State = CheckLocation(C, State, Buffer, BufEnd, Access);
 
 // If the buffer isn't large enough, abort.
@@ -622,8 +620,8 @@
 void CStringChecker::emitAdditionOverflowBug(CheckerContext &C,
  ProgramStateRef State) const {
   if (ExplodedNode *N = C.generateErrorNode(State)) {
-if (!BT_NotCString)
-  BT_NotCString.reset(
+if (!BT_AdditionOverflow)
+  BT_AdditionOverflow.reset(
   new BuiltinBug(Filter.CheckNameCStringOutOfBounds, "API",
  "Sum of expressions causes overflow."));
 
@@ -634,8 +632,8 @@
 "This expression will create a string whose length is too big to "
 "be represented as a size_t";
 
-auto Report =
-std::make_unique(*BT_NotCString, WarningMsg, N);
+auto Report = std::make_unique(*BT_AdditionOverflow,
+   WarningMsg, N);
 C.emitReport(std::move(Report));
   }
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D119462: [analyzer][NFCi] Use the correct BugType in CStringChecker.

2022-02-14 Thread Shivam Rajput via Phabricator via cfe-commits
phyBrackets added a comment.

In D119462#3319031 , @steakhal wrote:

> I think yes, go ahead!

Thanks !


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119462

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


[PATCH] D124768: update

2022-05-02 Thread Shivam Rajput via Phabricator via cfe-commits
phyBrackets created this revision.
Herald added a project: All.
phyBrackets requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124768

Files:
  clang/include/clang/AST/ASTImportError.h


Index: clang/include/clang/AST/ASTImportError.h
===
--- clang/include/clang/AST/ASTImportError.h
+++ clang/include/clang/AST/ASTImportError.h
@@ -11,6 +11,9 @@
 //
 
//===--===//
 
+#ifndef LLVM_CLANG_AST_ASTIMPORTERROR_H
+#define LLVM_CLANG_AST_ASTIMPORTERROR_H
+
 #include "llvm/Support/Error.h"
 #include "clang/AST/APValue.h"
 
@@ -43,4 +46,6 @@
 std::error_code convertToErrorCode() const override;
   };
 
-}
+  } // namespace clang
+
+#endif // LLVM_CLANG_AST_ASTIMPORTERROR_H


Index: clang/include/clang/AST/ASTImportError.h
===
--- clang/include/clang/AST/ASTImportError.h
+++ clang/include/clang/AST/ASTImportError.h
@@ -11,6 +11,9 @@
 //
 //===--===//
 
+#ifndef LLVM_CLANG_AST_ASTIMPORTERROR_H
+#define LLVM_CLANG_AST_ASTIMPORTERROR_H
+
 #include "llvm/Support/Error.h"
 #include "clang/AST/APValue.h"
 
@@ -43,4 +46,6 @@
 std::error_code convertToErrorCode() const override;
   };
 
-}
+  } // namespace clang
+
+#endif // LLVM_CLANG_AST_ASTIMPORTERROR_H
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D124774: [AST][FIXME]: trying to fixed a fixme in ASTImporterSharedState.h

2022-05-02 Thread Shivam Rajput via Phabricator via cfe-commits
phyBrackets created this revision.
Herald added a subscriber: martong.
Herald added a reviewer: a.sidorin.
Herald added a project: All.
phyBrackets requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124774

Files:
  clang/include/clang/AST/ASTImportError.h
  clang/include/clang/AST/ASTImporter.h
  clang/include/clang/AST/ASTImporterLookupTable.h
  clang/include/clang/AST/ASTImporterSharedState.h

Index: clang/include/clang/AST/ASTImporterSharedState.h
===
--- clang/include/clang/AST/ASTImporterSharedState.h
+++ clang/include/clang/AST/ASTImporterSharedState.h
@@ -17,8 +17,6 @@
 #include "clang/AST/ASTImporterLookupTable.h"
 #include "clang/AST/Decl.h"
 #include "llvm/ADT/DenseMap.h"
-// FIXME We need this because of ImportError.
-#include "clang/AST/ASTImporter.h"
 
 namespace clang {
 
Index: clang/include/clang/AST/ASTImporterLookupTable.h
===
--- clang/include/clang/AST/ASTImporterLookupTable.h
+++ clang/include/clang/AST/ASTImporterLookupTable.h
@@ -14,6 +14,7 @@
 #ifndef LLVM_CLANG_AST_ASTIMPORTERLOOKUPTABLE_H
 #define LLVM_CLANG_AST_ASTIMPORTERLOOKUPTABLE_H
 
+#include "clang/AST/ASTImportError.h"
 #include "clang/AST/DeclBase.h" // lookup_result
 #include "clang/AST/DeclarationName.h"
 #include "llvm/ADT/DenseMap.h"
Index: clang/include/clang/AST/ASTImporter.h
===
--- clang/include/clang/AST/ASTImporter.h
+++ clang/include/clang/AST/ASTImporter.h
@@ -14,7 +14,7 @@
 #ifndef LLVM_CLANG_AST_ASTIMPORTER_H
 #define LLVM_CLANG_AST_ASTIMPORTER_H
 
-#include "clang/AST/APValue.h"
+#include "clang/AST/ASTImporterLookupTable.h"
 #include "clang/AST/DeclBase.h"
 #include "clang/AST/DeclarationName.h"
 #include "clang/AST/ExprCXX.h"
@@ -29,7 +29,6 @@
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/SmallVector.h"
-#include "llvm/Support/Error.h"
 #include 
 
 namespace clang {
@@ -49,33 +48,6 @@
 class TranslationUnitDecl;
 class TypeSourceInfo;
 
-  class ImportError : public llvm::ErrorInfo {
-  public:
-/// \brief Kind of error when importing an AST component.
-enum ErrorKind {
-NameConflict, /// Naming ambiguity (likely ODR violation).
-UnsupportedConstruct, /// Not supported node or case.
-Unknown /// Other error.
-};
-
-ErrorKind Error;
-
-static char ID;
-
-ImportError() : Error(Unknown) {}
-ImportError(const ImportError &Other) : Error(Other.Error) {}
-ImportError &operator=(const ImportError &Other) {
-  Error = Other.Error;
-  return *this;
-}
-ImportError(ErrorKind Error) : Error(Error) { }
-
-std::string toString() const;
-
-void log(raw_ostream &OS) const override;
-std::error_code convertToErrorCode() const override;
-  };
-
   // \brief Returns with a list of declarations started from the canonical decl
   // then followed by subsequent decls in the translation unit.
   // This gives a canonical list for each entry in the redecl chain.
Index: clang/include/clang/AST/ASTImportError.h
===
--- /dev/null
+++ clang/include/clang/AST/ASTImportError.h
@@ -0,0 +1,51 @@
+//===- ASTImporter.h - Import Error while Importing AST ---*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+//  This file defines the ASTImportError class which basically defines the kind
+//  of error while importing AST .
+//
+//===--===//
+
+#ifndef LLVM_CLANG_AST_ASTIMPORTERROR_H
+#define LLVM_CLANG_AST_ASTIMPORTERROR_H
+
+#include "clang/AST/APValue.h"
+#include "llvm/Support/Error.h"
+
+namespace clang {
+
+class ImportError : public llvm::ErrorInfo {
+public:
+  /// \brief Kind of error when importing an AST component.
+  enum ErrorKind {
+NameConflict, /// Naming ambiguity (likely ODR violation).
+UnsupportedConstruct, /// Not supported node or case.
+Unknown   /// Other error.
+  };
+
+  ErrorKind Error;
+
+  static char ID;
+
+  ImportError() : Error(Unknown) {}
+  ImportError(const ImportError &Other) : Error(Other.Error) {}
+  ImportError &operator=(const ImportError &Other) {
+Error = Other.Error;
+return *this;
+  }
+  ImportError(ErrorKind Error) : Error(Error) {}
+
+  std::string toString() const;
+
+  void log(raw_ostream &OS) const override;
+  std::error_code convertToErrorCode() const override;
+};
+
+} // namespace clang
+
+#endif // LLVM_CLANG_AST_ASTIMPORTERR

[PATCH] D124774: [clang][ASTImporter][NFC]: Move clang::ImportError into own header and rename it .

2022-05-03 Thread Shivam Rajput via Phabricator via cfe-commits
phyBrackets added inline comments.



Comment at: clang/include/clang/AST/ASTImporterLookupTable.h:17
 
+#include "clang/AST/ASTImportError.h"
 #include "clang/AST/DeclBase.h" // lookup_result

balazske wrote:
> This include is not needed here.
Hey thanks for reviewing , I have a doubt if I remove this include it from here 
, then I need to include this header in the ASTImporterSharedState.h , now the 
ASTImporterSharedState.h and ASTImporter.h both have ASTImportError.h included 
, isn't this affect on ASTImporter.cpp file on conflicting over ASTImportError 
? Strangely it builds fine on my system tho .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124774

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


[PATCH] D124774: [clang][ASTImporter][NFC]: Move clang::ImportError into own header and rename it .

2022-05-04 Thread Shivam Rajput via Phabricator via cfe-commits
phyBrackets added inline comments.



Comment at: clang/include/clang/AST/ASTImportError.h:22
+
+class ImportError : public llvm::ErrorInfo {
+public:

balazske wrote:
> balazske wrote:
> > Rename to `ASTImportError`.
> The rename to `ASTImportError` is better in a separate patch. The rename 
> would touch code in much more places and there is a rule to make independent 
> changes in separate patches. Still I think this class should not be called 
> just `ImportError` if it has an own header (it is not an internal-like class 
> of `ASTImporter` as is used to be).
So, what do you suggest , for this patch should I go with name //ImportError// 
only ? And rename it as //ASTImportError// in a separate patch ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124774

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


[PATCH] D124774: [clang][ASTImporter][NFC]: Move clang::ImportError into own header and rename it .

2022-05-04 Thread Shivam Rajput via Phabricator via cfe-commits
phyBrackets added inline comments.



Comment at: clang/include/clang/AST/ASTImporterLookupTable.h:17
 
+#include "clang/AST/ASTImportError.h"
 #include "clang/AST/DeclBase.h" // lookup_result

balazske wrote:
> phyBrackets wrote:
> > balazske wrote:
> > > This include is not needed here.
> > Hey thanks for reviewing , I have a doubt if I remove this include it from 
> > here , then I need to include this header in the ASTImporterSharedState.h , 
> > now the ASTImporterSharedState.h and ASTImporter.h both have 
> > ASTImportError.h included , isn't this affect on ASTImporter.cpp file on 
> > conflicting over ASTImportError ? Strangely it builds fine on my system tho 
> > .
> > isn't this affect on ASTImporter.cpp file on conflicting over 
> > ASTImportError ?
> This is no problem, this is why the include guard `#ifndef 
> LLVM_CLANG_AST_ASTIMPORTERROR_H` is there.
> 
> 
ahh yes! Thanks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124774

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


[PATCH] D124774: [clang][ASTImporter][NFC]: Move clang::ImportError into own header and rename it .

2022-05-04 Thread Shivam Rajput via Phabricator via cfe-commits
phyBrackets updated this revision to Diff 426992.
phyBrackets added a comment.

Address inline comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124774

Files:
  clang/include/clang/AST/ASTImportError.h
  clang/include/clang/AST/ASTImporter.h
  clang/include/clang/AST/ASTImporterLookupTable.h
  clang/include/clang/AST/ASTImporterSharedState.h


Index: clang/include/clang/AST/ASTImporterSharedState.h
===
--- clang/include/clang/AST/ASTImporterSharedState.h
+++ clang/include/clang/AST/ASTImporterSharedState.h
@@ -14,6 +14,7 @@
 #ifndef LLVM_CLANG_AST_ASTIMPORTERSHAREDSTATE_H
 #define LLVM_CLANG_AST_ASTIMPORTERSHAREDSTATE_H
 
+#include "clang/AST/ASTImportError.h"
 #include "clang/AST/ASTImporterLookupTable.h"
 #include "clang/AST/Decl.h"
 #include "llvm/ADT/DenseMap.h"
Index: clang/include/clang/AST/ASTImporterLookupTable.h
===
--- clang/include/clang/AST/ASTImporterLookupTable.h
+++ clang/include/clang/AST/ASTImporterLookupTable.h
@@ -14,7 +14,6 @@
 #ifndef LLVM_CLANG_AST_ASTIMPORTERLOOKUPTABLE_H
 #define LLVM_CLANG_AST_ASTIMPORTERLOOKUPTABLE_H
 
-#include "clang/AST/ASTImportError.h"
 #include "clang/AST/DeclBase.h" // lookup_result
 #include "clang/AST/DeclarationName.h"
 #include "llvm/ADT/DenseMap.h"
Index: clang/include/clang/AST/ASTImporter.h
===
--- clang/include/clang/AST/ASTImporter.h
+++ clang/include/clang/AST/ASTImporter.h
@@ -14,7 +14,7 @@
 #ifndef LLVM_CLANG_AST_ASTIMPORTER_H
 #define LLVM_CLANG_AST_ASTIMPORTER_H
 
-#include "clang/AST/ASTImporterLookupTable.h"
+#include "clang/AST/ASTImportError.h"
 #include "clang/AST/DeclBase.h"
 #include "clang/AST/DeclarationName.h"
 #include "clang/AST/ExprCXX.h"
Index: clang/include/clang/AST/ASTImportError.h
===
--- clang/include/clang/AST/ASTImportError.h
+++ clang/include/clang/AST/ASTImportError.h
@@ -1,4 +1,5 @@
-//===- ASTImporter.h - Import Error while Importing AST ---*- C++ -*-===//
+//===- ASTImportError.h -  Define errors while importing AST  ---*- C++
+//-*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -14,7 +15,6 @@
 #ifndef LLVM_CLANG_AST_ASTIMPORTERROR_H
 #define LLVM_CLANG_AST_ASTIMPORTERROR_H
 
-#include "clang/AST/APValue.h"
 #include "llvm/Support/Error.h"
 
 namespace clang {
@@ -42,10 +42,10 @@
 
   std::string toString() const;
 
-  void log(raw_ostream &OS) const override;
+  void log(llvm::raw_ostream &OS) const override;
   std::error_code convertToErrorCode() const override;
 };
 
 } // namespace clang
 
-#endif // LLVM_CLANG_AST_ASTIMPORTERROR_H
\ No newline at end of file
+#endif // LLVM_CLANG_AST_ASTIMPORTERROR_H


Index: clang/include/clang/AST/ASTImporterSharedState.h
===
--- clang/include/clang/AST/ASTImporterSharedState.h
+++ clang/include/clang/AST/ASTImporterSharedState.h
@@ -14,6 +14,7 @@
 #ifndef LLVM_CLANG_AST_ASTIMPORTERSHAREDSTATE_H
 #define LLVM_CLANG_AST_ASTIMPORTERSHAREDSTATE_H
 
+#include "clang/AST/ASTImportError.h"
 #include "clang/AST/ASTImporterLookupTable.h"
 #include "clang/AST/Decl.h"
 #include "llvm/ADT/DenseMap.h"
Index: clang/include/clang/AST/ASTImporterLookupTable.h
===
--- clang/include/clang/AST/ASTImporterLookupTable.h
+++ clang/include/clang/AST/ASTImporterLookupTable.h
@@ -14,7 +14,6 @@
 #ifndef LLVM_CLANG_AST_ASTIMPORTERLOOKUPTABLE_H
 #define LLVM_CLANG_AST_ASTIMPORTERLOOKUPTABLE_H
 
-#include "clang/AST/ASTImportError.h"
 #include "clang/AST/DeclBase.h" // lookup_result
 #include "clang/AST/DeclarationName.h"
 #include "llvm/ADT/DenseMap.h"
Index: clang/include/clang/AST/ASTImporter.h
===
--- clang/include/clang/AST/ASTImporter.h
+++ clang/include/clang/AST/ASTImporter.h
@@ -14,7 +14,7 @@
 #ifndef LLVM_CLANG_AST_ASTIMPORTER_H
 #define LLVM_CLANG_AST_ASTIMPORTER_H
 
-#include "clang/AST/ASTImporterLookupTable.h"
+#include "clang/AST/ASTImportError.h"
 #include "clang/AST/DeclBase.h"
 #include "clang/AST/DeclarationName.h"
 #include "clang/AST/ExprCXX.h"
Index: clang/include/clang/AST/ASTImportError.h
===
--- clang/include/clang/AST/ASTImportError.h
+++ clang/include/clang/AST/ASTImportError.h
@@ -1,4 +1,5 @@
-//===- ASTImporter.h - Import Error while Importing AST ---*- C++ -*-===//
+//===- ASTImportError.h -  Define errors while importing AST  ---*- C++
+//-*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.or

[PATCH] D124774: [clang][ASTImporter][NFC]: Move clang::ImportError into own header.

2022-05-05 Thread Shivam Rajput via Phabricator via cfe-commits
phyBrackets updated this revision to Diff 427252.
phyBrackets added a comment.

address inline comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124774

Files:
  clang/include/clang/AST/ASTImportError.h


Index: clang/include/clang/AST/ASTImportError.h
===
--- clang/include/clang/AST/ASTImportError.h
+++ clang/include/clang/AST/ASTImportError.h
@@ -1,4 +1,4 @@
-//===- ASTImportError.h -  Define errors while importing AST  ---*- C++
+//===- ASTImportError.h - Define errors while importing AST  ---*- C++
 //-*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.


Index: clang/include/clang/AST/ASTImportError.h
===
--- clang/include/clang/AST/ASTImportError.h
+++ clang/include/clang/AST/ASTImportError.h
@@ -1,4 +1,4 @@
-//===- ASTImportError.h -  Define errors while importing AST  ---*- C++
+//===- ASTImportError.h - Define errors while importing AST  ---*- C++
 //-*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D124774: [clang][ASTImporter][NFC]: Move clang::ImportError into own header.

2022-05-05 Thread Shivam Rajput via Phabricator via cfe-commits
phyBrackets added a comment.

I'm having a problem , this patch expected to address the previous inline 
comment but after making the specific change and committing it , when  I'm 
creating the patch using //arc diff --update // , the changes were 
suddenly gone and I thought that maybe the changes were there in the commit 
atleast but I think commit got reverted and there is nothing for diff but 
suddenly the patch were created .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124774

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


[PATCH] D124774: [clang][ASTImporter][NFC]: Move clang::ImportError into own header.

2022-05-05 Thread Shivam Rajput via Phabricator via cfe-commits
phyBrackets updated this revision to Diff 427259.
phyBrackets added a comment.

address inline comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124774

Files:
  clang/include/clang/AST/ASTImportError.h


Index: clang/include/clang/AST/ASTImportError.h
===
--- clang/include/clang/AST/ASTImportError.h
+++ clang/include/clang/AST/ASTImportError.h
@@ -1,5 +1,4 @@
-//===- ASTImportError.h - Define errors while importing AST  ---*- C++
-//-*-===//
+//===- ASTImportError.h - Define errors while importing AST *- C++-*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.


Index: clang/include/clang/AST/ASTImportError.h
===
--- clang/include/clang/AST/ASTImportError.h
+++ clang/include/clang/AST/ASTImportError.h
@@ -1,5 +1,4 @@
-//===- ASTImportError.h - Define errors while importing AST  ---*- C++
-//-*-===//
+//===- ASTImportError.h - Define errors while importing AST *- C++-*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D124774: [clang][ASTImporter][NFC]: Move clang::ImportError into own header.

2022-05-05 Thread Shivam Rajput via Phabricator via cfe-commits
phyBrackets added a comment.

In D124774#3493382 , @phyBrackets 
wrote:

> I'm having a problem , this patch expected to address the previous inline 
> comment but after making the specific change and committing it , when  I'm 
> creating the patch using //arc diff --update // , the changes 
> were suddenly gone and I thought that maybe the changes were there in the 
> commit atleast but I think commit got reverted and there is nothing for diff 
> but suddenly the patch were created .

I think there was the problem with number of the character in line 1 , Now it 
seems correct .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124774

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


[PATCH] D124774: [clang][ASTImporter][NFC]: Move clang::ImportError into own header.

2022-05-05 Thread Shivam Rajput via Phabricator via cfe-commits
phyBrackets updated this revision to Diff 427261.
phyBrackets added a comment.

Correct the number of character in line 1


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124774

Files:
  clang/include/clang/AST/ASTImportError.h


Index: clang/include/clang/AST/ASTImportError.h
===
--- clang/include/clang/AST/ASTImportError.h
+++ clang/include/clang/AST/ASTImportError.h
@@ -1,4 +1,4 @@
-//===- ASTImportError.h - Define errors while importing AST *- C++-*-===//
+//===- ASTImportError.h - Define errors while importing AST -*- C++-*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.


Index: clang/include/clang/AST/ASTImportError.h
===
--- clang/include/clang/AST/ASTImportError.h
+++ clang/include/clang/AST/ASTImportError.h
@@ -1,4 +1,4 @@
-//===- ASTImportError.h - Define errors while importing AST *- C++-*-===//
+//===- ASTImportError.h - Define errors while importing AST -*- C++-*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D124774: [clang][ASTImporter][NFC]: Move clang::ImportError into own header.

2022-05-05 Thread Shivam Rajput via Phabricator via cfe-commits
phyBrackets updated this revision to Diff 427264.
phyBrackets added a comment.

address the buildbot failing issue


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124774

Files:
  clang/include/clang/AST/ASTImportError.h


Index: clang/include/clang/AST/ASTImportError.h
===
--- clang/include/clang/AST/ASTImportError.h
+++ clang/include/clang/AST/ASTImportError.h
@@ -1,4 +1,4 @@
-//===- ASTImportError.h - Define errors while importing AST -*- C++-*-===//
+//===- ASTImportError.h - Define errors while importing AST -*- C++ 
-*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.


Index: clang/include/clang/AST/ASTImportError.h
===
--- clang/include/clang/AST/ASTImportError.h
+++ clang/include/clang/AST/ASTImportError.h
@@ -1,4 +1,4 @@
-//===- ASTImportError.h - Define errors while importing AST -*- C++-*-===//
+//===- ASTImportError.h - Define errors while importing AST -*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D124774: [clang][ASTImporter][NFC]: Move clang::ImportError into own header.

2022-05-05 Thread Shivam Rajput via Phabricator via cfe-commits
phyBrackets added a comment.

is there still any problem ? I'm not sure ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124774

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


[PATCH] D124774: [clang][ASTImporter][NFC]: Move clang::ImportError into own header.

2022-05-05 Thread Shivam Rajput via Phabricator via cfe-commits
phyBrackets updated this revision to Diff 427322.
phyBrackets added a comment.

Rebase several commits


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124774

Files:
  clang/include/clang/AST/ASTImportError.h
  clang/include/clang/AST/ASTImporter.h
  clang/include/clang/AST/ASTImporterSharedState.h

Index: clang/include/clang/AST/ASTImporterSharedState.h
===
--- clang/include/clang/AST/ASTImporterSharedState.h
+++ clang/include/clang/AST/ASTImporterSharedState.h
@@ -14,11 +14,10 @@
 #ifndef LLVM_CLANG_AST_ASTIMPORTERSHAREDSTATE_H
 #define LLVM_CLANG_AST_ASTIMPORTERSHAREDSTATE_H
 
+#include "clang/AST/ASTImportError.h"
 #include "clang/AST/ASTImporterLookupTable.h"
 #include "clang/AST/Decl.h"
 #include "llvm/ADT/DenseMap.h"
-// FIXME We need this because of ImportError.
-#include "clang/AST/ASTImporter.h"
 
 namespace clang {
 
Index: clang/include/clang/AST/ASTImporter.h
===
--- clang/include/clang/AST/ASTImporter.h
+++ clang/include/clang/AST/ASTImporter.h
@@ -14,7 +14,7 @@
 #ifndef LLVM_CLANG_AST_ASTIMPORTER_H
 #define LLVM_CLANG_AST_ASTIMPORTER_H
 
-#include "clang/AST/APValue.h"
+#include "clang/AST/ASTImportError.h"
 #include "clang/AST/DeclBase.h"
 #include "clang/AST/DeclarationName.h"
 #include "clang/AST/ExprCXX.h"
@@ -29,7 +29,6 @@
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/SmallVector.h"
-#include "llvm/Support/Error.h"
 #include 
 
 namespace clang {
@@ -49,33 +48,6 @@
 class TranslationUnitDecl;
 class TypeSourceInfo;
 
-  class ImportError : public llvm::ErrorInfo {
-  public:
-/// \brief Kind of error when importing an AST component.
-enum ErrorKind {
-NameConflict, /// Naming ambiguity (likely ODR violation).
-UnsupportedConstruct, /// Not supported node or case.
-Unknown /// Other error.
-};
-
-ErrorKind Error;
-
-static char ID;
-
-ImportError() : Error(Unknown) {}
-ImportError(const ImportError &Other) : Error(Other.Error) {}
-ImportError &operator=(const ImportError &Other) {
-  Error = Other.Error;
-  return *this;
-}
-ImportError(ErrorKind Error) : Error(Error) { }
-
-std::string toString() const;
-
-void log(raw_ostream &OS) const override;
-std::error_code convertToErrorCode() const override;
-  };
-
   // \brief Returns with a list of declarations started from the canonical decl
   // then followed by subsequent decls in the translation unit.
   // This gives a canonical list for each entry in the redecl chain.
Index: clang/include/clang/AST/ASTImportError.h
===
--- /dev/null
+++ clang/include/clang/AST/ASTImportError.h
@@ -0,0 +1,50 @@
+//===- ASTImportError.h - Define errors while importing AST -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+//  This file defines the ASTImportError class which basically defines the kind
+//  of error while importing AST .
+//
+//===--===//
+
+#ifndef LLVM_CLANG_AST_ASTIMPORTERROR_H
+#define LLVM_CLANG_AST_ASTIMPORTERROR_H
+
+#include "llvm/Support/Error.h"
+
+namespace clang {
+
+class ImportError : public llvm::ErrorInfo {
+public:
+  /// \brief Kind of error when importing an AST component.
+  enum ErrorKind {
+NameConflict, /// Naming ambiguity (likely ODR violation).
+UnsupportedConstruct, /// Not supported node or case.
+Unknown   /// Other error.
+  };
+
+  ErrorKind Error;
+
+  static char ID;
+
+  ImportError() : Error(Unknown) {}
+  ImportError(const ImportError &Other) : Error(Other.Error) {}
+  ImportError &operator=(const ImportError &Other) {
+Error = Other.Error;
+return *this;
+  }
+  ImportError(ErrorKind Error) : Error(Error) {}
+
+  std::string toString() const;
+
+  void log(llvm::raw_ostream &OS) const override;
+  std::error_code convertToErrorCode() const override;
+};
+
+} // namespace clang
+
+#endif // LLVM_CLANG_AST_ASTIMPORTERROR_H
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D124774: [clang][ASTImporter][NFC]: Move clang::ImportError into own header.

2022-05-05 Thread Shivam Rajput via Phabricator via cfe-commits
phyBrackets added a comment.

Thanks @martong @balazske for the Review .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124774

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


[PATCH] D124774: [clang][ASTImporter][NFC]: Move clang::ImportError into own header.

2022-05-05 Thread Shivam Rajput via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdcb906757ada: [clang][ASTImporter][NFC]: Move 
clang::ImportError into own header. (authored by phyBrackets).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124774

Files:
  clang/include/clang/AST/ASTImportError.h
  clang/include/clang/AST/ASTImporter.h
  clang/include/clang/AST/ASTImporterSharedState.h

Index: clang/include/clang/AST/ASTImporterSharedState.h
===
--- clang/include/clang/AST/ASTImporterSharedState.h
+++ clang/include/clang/AST/ASTImporterSharedState.h
@@ -14,11 +14,10 @@
 #ifndef LLVM_CLANG_AST_ASTIMPORTERSHAREDSTATE_H
 #define LLVM_CLANG_AST_ASTIMPORTERSHAREDSTATE_H
 
+#include "clang/AST/ASTImportError.h"
 #include "clang/AST/ASTImporterLookupTable.h"
 #include "clang/AST/Decl.h"
 #include "llvm/ADT/DenseMap.h"
-// FIXME We need this because of ImportError.
-#include "clang/AST/ASTImporter.h"
 
 namespace clang {
 
Index: clang/include/clang/AST/ASTImporter.h
===
--- clang/include/clang/AST/ASTImporter.h
+++ clang/include/clang/AST/ASTImporter.h
@@ -14,7 +14,7 @@
 #ifndef LLVM_CLANG_AST_ASTIMPORTER_H
 #define LLVM_CLANG_AST_ASTIMPORTER_H
 
-#include "clang/AST/APValue.h"
+#include "clang/AST/ASTImportError.h"
 #include "clang/AST/DeclBase.h"
 #include "clang/AST/DeclarationName.h"
 #include "clang/AST/ExprCXX.h"
@@ -29,7 +29,6 @@
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/SmallVector.h"
-#include "llvm/Support/Error.h"
 #include 
 
 namespace clang {
@@ -49,33 +48,6 @@
 class TranslationUnitDecl;
 class TypeSourceInfo;
 
-  class ImportError : public llvm::ErrorInfo {
-  public:
-/// \brief Kind of error when importing an AST component.
-enum ErrorKind {
-NameConflict, /// Naming ambiguity (likely ODR violation).
-UnsupportedConstruct, /// Not supported node or case.
-Unknown /// Other error.
-};
-
-ErrorKind Error;
-
-static char ID;
-
-ImportError() : Error(Unknown) {}
-ImportError(const ImportError &Other) : Error(Other.Error) {}
-ImportError &operator=(const ImportError &Other) {
-  Error = Other.Error;
-  return *this;
-}
-ImportError(ErrorKind Error) : Error(Error) { }
-
-std::string toString() const;
-
-void log(raw_ostream &OS) const override;
-std::error_code convertToErrorCode() const override;
-  };
-
   // \brief Returns with a list of declarations started from the canonical decl
   // then followed by subsequent decls in the translation unit.
   // This gives a canonical list for each entry in the redecl chain.
Index: clang/include/clang/AST/ASTImportError.h
===
--- /dev/null
+++ clang/include/clang/AST/ASTImportError.h
@@ -0,0 +1,50 @@
+//===- ASTImportError.h - Define errors while importing AST -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+//  This file defines the ASTImportError class which basically defines the kind
+//  of error while importing AST .
+//
+//===--===//
+
+#ifndef LLVM_CLANG_AST_ASTIMPORTERROR_H
+#define LLVM_CLANG_AST_ASTIMPORTERROR_H
+
+#include "llvm/Support/Error.h"
+
+namespace clang {
+
+class ImportError : public llvm::ErrorInfo {
+public:
+  /// \brief Kind of error when importing an AST component.
+  enum ErrorKind {
+NameConflict, /// Naming ambiguity (likely ODR violation).
+UnsupportedConstruct, /// Not supported node or case.
+Unknown   /// Other error.
+  };
+
+  ErrorKind Error;
+
+  static char ID;
+
+  ImportError() : Error(Unknown) {}
+  ImportError(const ImportError &Other) : Error(Other.Error) {}
+  ImportError &operator=(const ImportError &Other) {
+Error = Other.Error;
+return *this;
+  }
+  ImportError(ErrorKind Error) : Error(Error) {}
+
+  std::string toString() const;
+
+  void log(llvm::raw_ostream &OS) const override;
+  std::error_code convertToErrorCode() const override;
+};
+
+} // namespace clang
+
+#endif // LLVM_CLANG_AST_ASTIMPORTERROR_H
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D120489: [analyzer] Done some changes to detect Uninitialized read by the char array manipulation functions

2022-05-06 Thread Shivam Rajput via Phabricator via cfe-commits
phyBrackets added a comment.

In D120489#3493313 , @martong wrote:

> Maybe it is not too late to update the clang/docs/ReleaseNotes.rst? A new 
> checker is certainly important for the users. Many thanks!

Yeah done! Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120489

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


[PATCH] D125340: [clang][NFC][AST] rename the ImportError to ASTImportError

2022-05-10 Thread Shivam Rajput via Phabricator via cfe-commits
phyBrackets created this revision.
Herald added a subscriber: martong.
Herald added a reviewer: a.sidorin.
Herald added a reviewer: shafik.
Herald added a project: All.
phyBrackets requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

this patch is the continuation of my previous patch regarding the ImportError 
in ASTImportError.h


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D125340

Files:
  clang/include/clang/AST/ASTImportError.h
  clang/include/clang/AST/ASTImporter.h
  clang/include/clang/AST/ASTImporterSharedState.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/CrossTU/CrossTranslationUnit.cpp
  clang/unittests/AST/ASTImporterFixtures.h
  clang/unittests/AST/ASTImporterODRStrategiesTest.cpp
  clang/unittests/AST/ASTImporterTest.cpp

Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -3178,8 +3178,8 @@
 
   auto ToBlockOrError = importOrError(FromBlock, Lang_CXX03);
 
-  const auto ExpectUnsupportedConstructError = [](const ImportError &Error) {
-EXPECT_EQ(ImportError::UnsupportedConstruct, Error.Error);
+  const auto ExpectUnsupportedConstructError = [](const ASTImportError &Error) {
+EXPECT_EQ(ASTImportError::UnsupportedConstruct, Error.Error);
   };
   llvm::handleAllErrors(ToBlockOrError.takeError(),
 ExpectUnsupportedConstructError);
@@ -5435,9 +5435,9 @@
 
   // But an error is set to the counterpart in the "from" context.
   ASTImporter *Importer = findFromTU(FromSpec)->Importer.get();
-  Optional OptErr = Importer->getImportDeclErrorIfAny(FromSpec);
+  Optional OptErr = Importer->getImportDeclErrorIfAny(FromSpec);
   ASSERT_TRUE(OptErr);
-  EXPECT_EQ(OptErr->Error, ImportError::NameConflict);
+  EXPECT_EQ(OptErr->Error, ASTImportError::NameConflict);
 }
 
 // Check a case when a new AST node is created but not linked to the AST before
@@ -5459,9 +5459,9 @@
   0u);
 
   ASTImporter *Importer = findFromTU(FromFoo)->Importer.get();
-  Optional OptErr = Importer->getImportDeclErrorIfAny(FromFoo);
+  Optional OptErr = Importer->getImportDeclErrorIfAny(FromFoo);
   ASSERT_TRUE(OptErr);
-  EXPECT_EQ(OptErr->Error, ImportError::UnsupportedConstruct);
+  EXPECT_EQ(OptErr->Error, ASTImportError::UnsupportedConstruct);
 }
 
 // Check a case when a new AST node is created and linked to the AST before
@@ -5492,12 +5492,13 @@
   // An error is set to the counterpart in the "from" context both for the fwd
   // decl and the definition.
   ASTImporter *Importer = findFromTU(FromProto)->Importer.get();
-  Optional OptErr = Importer->getImportDeclErrorIfAny(FromProto);
+  Optional OptErr =
+  Importer->getImportDeclErrorIfAny(FromProto);
   ASSERT_TRUE(OptErr);
-  EXPECT_EQ(OptErr->Error, ImportError::UnsupportedConstruct);
+  EXPECT_EQ(OptErr->Error, ASTImportError::UnsupportedConstruct);
   OptErr = Importer->getImportDeclErrorIfAny(FromDef);
   ASSERT_TRUE(OptErr);
-  EXPECT_EQ(OptErr->Error, ImportError::UnsupportedConstruct);
+  EXPECT_EQ(OptErr->Error, ASTImportError::UnsupportedConstruct);
 }
 
 // An error should be set for a class if we cannot import one member.
@@ -5517,16 +5518,16 @@
   // An error is set for X.
   EXPECT_FALSE(ImportedX);
   ASTImporter *Importer = findFromTU(FromX)->Importer.get();
-  Optional OptErr = Importer->getImportDeclErrorIfAny(FromX);
+  Optional OptErr = Importer->getImportDeclErrorIfAny(FromX);
   ASSERT_TRUE(OptErr);
-  EXPECT_EQ(OptErr->Error, ImportError::UnsupportedConstruct);
+  EXPECT_EQ(OptErr->Error, ASTImportError::UnsupportedConstruct);
 
   // An error is set for f().
   auto *FromF = FirstDeclMatcher().match(
   FromTU, cxxMethodDecl(hasName("f")));
   OptErr = Importer->getImportDeclErrorIfAny(FromF);
   ASSERT_TRUE(OptErr);
-  EXPECT_EQ(OptErr->Error, ImportError::UnsupportedConstruct);
+  EXPECT_EQ(OptErr->Error, ASTImportError::UnsupportedConstruct);
   // And any subsequent import should fail.
   CXXMethodDecl *ImportedF = Import(FromF, Lang_CXX03);
   EXPECT_FALSE(ImportedF);
@@ -5584,7 +5585,7 @@
 
   // An error is set to the templated CXXRecordDecl of F.
   ASTImporter *Importer = findFromTU(FromFRD)->Importer.get();
-  Optional OptErr = Importer->getImportDeclErrorIfAny(FromFRD);
+  Optional OptErr = Importer->getImportDeclErrorIfAny(FromFRD);
   EXPECT_TRUE(OptErr);
 
   // An error is set to A.
@@ -5642,7 +5643,7 @@
   // There is no error set for X.
   EXPECT_TRUE(ImportedX);
   ASTImporter *Importer = findFromTU(FromX)->Importer.get();
-  Optional OptErr = Importer->getImportDeclErrorIfAny(FromX);
+  Optional OptErr = Importer->getImportDeclErrorIfAny(FromX);
   ASSERT_FALSE(OptErr);
 
   // An error is set for f().
@@ -5650,7 +5651,7 @@
   FromTU, functionDecl(hasName("f")));
   OptErr = Importer->getImportDeclErrorIfAny(FromF);
   ASSERT_TRUE(OptErr);
-  EXPECT_EQ(OptErr->

[PATCH] D125340: [clang][NFC][AST] rename the ImportError to ASTImportError

2022-05-11 Thread Shivam Rajput via Phabricator via cfe-commits
phyBrackets added a comment.

In D125340#3505723 , @martong wrote:

> What are the benefits of this renaming? I mean is there a name clash? Do we 
> have another kind of "import" in Clang or in some of the dependent projects, 
> don't we?

AS it suggested by @balazske in the previous patch , and I also think if we 
moved the ImportError into it's own header then it's better to be named as 
ASTImportError .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125340

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


[PATCH] D125340: [clang][NFC][AST] rename the ImportError to ASTImportError

2022-05-11 Thread Shivam Rajput via Phabricator via cfe-commits
phyBrackets added a comment.

In D125340#3506210 , @balazske wrote:

> I found one other place in **LibASTImporter.rst** where `ImportError` is 
> used. LLDB should be checked too.

Yeah , I update the file **LibASTImporter.rst**, I'm not sure if there is need 
to change the ImportError that are used in lldb ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125340

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


[PATCH] D125340: [clang][NFC][AST] rename the ImportError to ASTImportError

2022-06-14 Thread Shivam Rajput via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9d637956b792: [clang][NFC][AST] rename the ImportError to 
ASTImportError (authored by phyBrackets).

Changed prior to commit:
  https://reviews.llvm.org/D125340?vs=428508&id=436881#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125340

Files:
  clang/include/clang/AST/ASTImportError.h
  clang/include/clang/AST/ASTImporter.h
  clang/include/clang/AST/ASTImporterSharedState.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/CrossTU/CrossTranslationUnit.cpp
  clang/unittests/AST/ASTImporterFixtures.h
  clang/unittests/AST/ASTImporterODRStrategiesTest.cpp
  clang/unittests/AST/ASTImporterTest.cpp

Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -3208,8 +3208,8 @@
 
   auto ToBlockOrError = importOrError(FromBlock, Lang_CXX03);
 
-  const auto ExpectUnsupportedConstructError = [](const ImportError &Error) {
-EXPECT_EQ(ImportError::UnsupportedConstruct, Error.Error);
+  const auto ExpectUnsupportedConstructError = [](const ASTImportError &Error) {
+EXPECT_EQ(ASTImportError::UnsupportedConstruct, Error.Error);
   };
   llvm::handleAllErrors(ToBlockOrError.takeError(),
 ExpectUnsupportedConstructError);
@@ -5469,9 +5469,9 @@
 
   // But an error is set to the counterpart in the "from" context.
   ASTImporter *Importer = findFromTU(FromSpec)->Importer.get();
-  Optional OptErr = Importer->getImportDeclErrorIfAny(FromSpec);
+  Optional OptErr = Importer->getImportDeclErrorIfAny(FromSpec);
   ASSERT_TRUE(OptErr);
-  EXPECT_EQ(OptErr->Error, ImportError::NameConflict);
+  EXPECT_EQ(OptErr->Error, ASTImportError::NameConflict);
 }
 
 // Check a case when a new AST node is created but not linked to the AST before
@@ -5493,9 +5493,9 @@
   0u);
 
   ASTImporter *Importer = findFromTU(FromFoo)->Importer.get();
-  Optional OptErr = Importer->getImportDeclErrorIfAny(FromFoo);
+  Optional OptErr = Importer->getImportDeclErrorIfAny(FromFoo);
   ASSERT_TRUE(OptErr);
-  EXPECT_EQ(OptErr->Error, ImportError::UnsupportedConstruct);
+  EXPECT_EQ(OptErr->Error, ASTImportError::UnsupportedConstruct);
 }
 
 // Check a case when a new AST node is created and linked to the AST before
@@ -5526,12 +5526,13 @@
   // An error is set to the counterpart in the "from" context both for the fwd
   // decl and the definition.
   ASTImporter *Importer = findFromTU(FromProto)->Importer.get();
-  Optional OptErr = Importer->getImportDeclErrorIfAny(FromProto);
+  Optional OptErr =
+  Importer->getImportDeclErrorIfAny(FromProto);
   ASSERT_TRUE(OptErr);
-  EXPECT_EQ(OptErr->Error, ImportError::UnsupportedConstruct);
+  EXPECT_EQ(OptErr->Error, ASTImportError::UnsupportedConstruct);
   OptErr = Importer->getImportDeclErrorIfAny(FromDef);
   ASSERT_TRUE(OptErr);
-  EXPECT_EQ(OptErr->Error, ImportError::UnsupportedConstruct);
+  EXPECT_EQ(OptErr->Error, ASTImportError::UnsupportedConstruct);
 }
 
 // An error should be set for a class if we cannot import one member.
@@ -5551,16 +5552,16 @@
   // An error is set for X.
   EXPECT_FALSE(ImportedX);
   ASTImporter *Importer = findFromTU(FromX)->Importer.get();
-  Optional OptErr = Importer->getImportDeclErrorIfAny(FromX);
+  Optional OptErr = Importer->getImportDeclErrorIfAny(FromX);
   ASSERT_TRUE(OptErr);
-  EXPECT_EQ(OptErr->Error, ImportError::UnsupportedConstruct);
+  EXPECT_EQ(OptErr->Error, ASTImportError::UnsupportedConstruct);
 
   // An error is set for f().
   auto *FromF = FirstDeclMatcher().match(
   FromTU, cxxMethodDecl(hasName("f")));
   OptErr = Importer->getImportDeclErrorIfAny(FromF);
   ASSERT_TRUE(OptErr);
-  EXPECT_EQ(OptErr->Error, ImportError::UnsupportedConstruct);
+  EXPECT_EQ(OptErr->Error, ASTImportError::UnsupportedConstruct);
   // And any subsequent import should fail.
   CXXMethodDecl *ImportedF = Import(FromF, Lang_CXX03);
   EXPECT_FALSE(ImportedF);
@@ -5618,7 +5619,7 @@
 
   // An error is set to the templated CXXRecordDecl of F.
   ASTImporter *Importer = findFromTU(FromFRD)->Importer.get();
-  Optional OptErr = Importer->getImportDeclErrorIfAny(FromFRD);
+  Optional OptErr = Importer->getImportDeclErrorIfAny(FromFRD);
   EXPECT_TRUE(OptErr);
 
   // An error is set to A.
@@ -5676,7 +5677,7 @@
   // There is no error set for X.
   EXPECT_TRUE(ImportedX);
   ASTImporter *Importer = findFromTU(FromX)->Importer.get();
-  Optional OptErr = Importer->getImportDeclErrorIfAny(FromX);
+  Optional OptErr = Importer->getImportDeclErrorIfAny(FromX);
   ASSERT_FALSE(OptErr);
 
   // An error is set for f().
@@ -5684,7 +5685,7 @@
   FromTU, functionDecl(hasName("f")));
   OptErr = Importer->getImportDeclErrorIfAny(FromF);
   ASSERT_TRUE(OptErr);
-  EXPECT_EQ(OptErr->Error, ImportError::UnsupportedConstruct);

[PATCH] D128608: [NFC][AST] remove the unnecessary condition checks in ASTImporter.cpp

2022-06-26 Thread Shivam Rajput via Phabricator via cfe-commits
phyBrackets created this revision.
Herald added a subscriber: martong.
Herald added a reviewer: a.sidorin.
Herald added a reviewer: shafik.
Herald added a project: All.
phyBrackets requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

I think that these conditions are unnecessary because in VisitClassTemplateDecl 
we import the definition via the templated CXXRecordDecl and in 
VisitVarTemplateDecl via the templated VarDecl. These are named ToTemplted and 
DTemplated respectively.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128608

Files:
  clang/lib/AST/ASTImporter.cpp


Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -5667,11 +5667,6 @@
 D2->setPreviousDecl(Recent);
   }
 
-  if (FromTemplated->isCompleteDefinition() &&
-  !ToTemplated->isCompleteDefinition()) {
-// FIXME: Import definition!
-  }
-
   return D2;
 }
 
@@ -5950,11 +5945,6 @@
 ToVarTD->setPreviousDecl(Recent);
   }
 
-  if (DTemplated->isThisDeclarationADefinition() &&
-  !ToTemplated->isThisDeclarationADefinition()) {
-// FIXME: Import definition!
-  }
-
   return ToVarTD;
 }
 


Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -5667,11 +5667,6 @@
 D2->setPreviousDecl(Recent);
   }
 
-  if (FromTemplated->isCompleteDefinition() &&
-  !ToTemplated->isCompleteDefinition()) {
-// FIXME: Import definition!
-  }
-
   return D2;
 }
 
@@ -5950,11 +5945,6 @@
 ToVarTD->setPreviousDecl(Recent);
   }
 
-  if (DTemplated->isThisDeclarationADefinition() &&
-  !ToTemplated->isThisDeclarationADefinition()) {
-// FIXME: Import definition!
-  }
-
   return ToVarTD;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D120489: [analyzer][NFCi] Does some changes to detect Uninitialized read by the char array manipulation functions

2022-02-24 Thread Shivam Rajput via Phabricator via cfe-commits
phyBrackets created this revision.
Herald added subscribers: ASDenysPetrov, martong, dkrupp, donat.nagy, 
Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun.
phyBrackets requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Few weeks back I was experimenting with reading the uninitialized values from 
src , which is actually a bug but the CSA seems to give up at that point . I 
was curious about that and I pinged @steakhal on the discord and according to 
him this seems to be a genuine issue and needs to be fix. So I goes with fixing 
this bug and thanks to @steakhal who help me creating this patch. This feature 
seems to break some tests but this was the genuine problem and the broken tests 
also needs to fix in certain manner. I add a test but yeah we need more 
tests,I'll try to add more tests.Thanks


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D120489

Files:
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  clang/test/Analysis/bstring.c

Index: clang/test/Analysis/bstring.c
===
--- clang/test/Analysis/bstring.c
+++ clang/test/Analysis/bstring.c
@@ -70,6 +70,11 @@
 
 #endif /* VARIANT */
 
+void top(char *dst) {
+  char buf[10];
+  memcpy(dst, buf, 10); // expected-warning{{Bytes string function accesses uninitialized/garbage values}}
+  (void)buf;
+}
 
 void memcpy0 () {
   char src[] = {1, 2, 3, 4};
@@ -297,9 +302,12 @@
   int dst[5] = {0};
   int *p;
 
-  p = mempcpy(dst, src, 4 * sizeof(int));
+  p = mempcpy(dst, src, 4 * sizeof(int)); // expected-warning{{Bytes string function accesses uninitialized/garbage values}}
+  // FIXME: This behaviour is actually Unexpected and needs to be fix, 
+  // mempcpy seems to consider the src buffered byte as uninitialized
+  // and returning undef which is actually not the case It should return something like Unknown .
 
-  clang_analyzer_eval(p == &dst[4]); // expected-warning{{TRUE}}
+  clang_analyzer_eval(p == &dst[4]); // no-warning (above is fatal)
 }
 
 struct st {
@@ -314,9 +322,10 @@
   struct st *p2;
 
   p1 = (&s2) + 1;
-  p2 = mempcpy(&s2, &s1, sizeof(struct st));
-
-  clang_analyzer_eval(p1 == p2); // expected-warning{{TRUE}}
+  p2 = mempcpy(&s2, &s1, sizeof(struct st)); // expected-warning{{Bytes string function accesses uninitialized/garbage values}}
+  // FIXME: It seems same as mempcpy14() case.
+  
+  clang_analyzer_eval(p1 == p2); // no-warning (above is fatal)
 }
 
 void mempcpy16() {
Index: clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -80,7 +80,7 @@
  check::RegionChanges
  > {
   mutable std::unique_ptr BT_Null, BT_Bounds, BT_Overlap,
-  BT_NotCString, BT_AdditionOverflow;
+  BT_NotCString, BT_AdditionOverflow, BT_UninitRead;
 
   mutable const char *CurrentFunctionDescription;
 
@@ -92,11 +92,13 @@
 DefaultBool CheckCStringOutOfBounds;
 DefaultBool CheckCStringBufferOverlap;
 DefaultBool CheckCStringNotNullTerm;
+DefaultBool CheckCStringUninitializedRead;
 
 CheckerNameRef CheckNameCStringNullArg;
 CheckerNameRef CheckNameCStringOutOfBounds;
 CheckerNameRef CheckNameCStringBufferOverlap;
 CheckerNameRef CheckNameCStringNotNullTerm;
+CheckerNameRef CheckNameCStringUninitializedRead;
   };
 
   CStringChecksFilter Filter;
@@ -257,6 +259,8 @@
   void emitNotCStringBug(CheckerContext &C, ProgramStateRef State,
  const Stmt *S, StringRef WarningMsg) const;
   void emitAdditionOverflowBug(CheckerContext &C, ProgramStateRef State) const;
+  void emitUninitializedRead(CheckerContext &C, ProgramStateRef State,
+ const Expr *E) const;
 
   ProgramStateRef checkAdditionOverflow(CheckerContext &C,
 ProgramStateRef state,
@@ -368,6 +372,15 @@
 return nullptr;
   }
 
+  // Ensure that we wouldn't read uninitialized value.
+  if (Access == AccessKind::read) {
+if (StInBound->getSVal(ER).isUndef()) {
+  llvm::errs() << "Reading from " << ER << "\n";
+  emitUninitializedRead(C, StInBound, Buffer.Expression);
+  return nullptr;
+}
+  }
+
   // Array bound check succeeded.  From this point forward the array bound
   // should always succeed.
   return StInBound;
@@ -421,6 +434,7 @@
 SVal BufEnd =
 svalBuilder.evalBinOpLN(State, BO_Add, *BufLoc, LastOffset, PtrTy);
 
+State = CheckLocation(C, State, Buffer, BufStart, Access);
 State = CheckLocation(C, State, Buffer, BufEnd, Access);
 
 // If the buffer isn't large enough, abort.
@@ -580,6 +594,27 @@
   }
 }
 
+void CStringChecker::em

[PATCH] D120489: [analyzer] Done some changes to detect Uninitialized read by the char array manipulation functions

2022-02-24 Thread Shivam Rajput via Phabricator via cfe-commits
phyBrackets added a comment.

@steakhal would you just help, where in the file and what exactly write to in 
the documentation?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120489

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


[PATCH] D120489: [analyzer] Done some changes to detect Uninitialized read by the char array manipulation functions

2022-02-24 Thread Shivam Rajput via Phabricator via cfe-commits
phyBrackets updated this revision to Diff 411286.
phyBrackets added a comment.

Revised the changes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120489

Files:
  clang/docs/analyzer/checkers.rst
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  clang/test/Analysis/bstring.c

Index: clang/test/Analysis/bstring.c
===
--- clang/test/Analysis/bstring.c
+++ clang/test/Analysis/bstring.c
@@ -70,6 +70,11 @@
 
 #endif /* VARIANT */
 
+void top(char *dst) {
+  char buf[10];
+  memcpy(dst, buf, 10); // expected-warning{{Bytes string function accesses uninitialized/garbage values}}
+  (void)buf;
+}
 
 void memcpy0 () {
   char src[] = {1, 2, 3, 4};
@@ -297,9 +302,12 @@
   int dst[5] = {0};
   int *p;
 
-  p = mempcpy(dst, src, 4 * sizeof(int));
+  p = mempcpy(dst, src, 4 * sizeof(int)); // expected-warning{{Bytes string function accesses uninitialized/garbage values}}
+  // FIXME: This behaviour is actually Unexpected and needs to be fix, 
+  // mempcpy seems to consider the src buffered byte as uninitialized
+  // and returning undef which is actually not the case It should return something like Unknown .
 
-  clang_analyzer_eval(p == &dst[4]); // expected-warning{{TRUE}}
+  clang_analyzer_eval(p == &dst[4]); // no-warning (above is fatal)
 }
 
 struct st {
@@ -314,9 +322,10 @@
   struct st *p2;
 
   p1 = (&s2) + 1;
-  p2 = mempcpy(&s2, &s1, sizeof(struct st));
-
-  clang_analyzer_eval(p1 == p2); // expected-warning{{TRUE}}
+  p2 = mempcpy(&s2, &s1, sizeof(struct st)); // expected-warning{{Bytes string function accesses uninitialized/garbage values}}
+  // FIXME: It seems same as mempcpy14() case.
+  
+  clang_analyzer_eval(p1 == p2); // no-warning (above is fatal)
 }
 
 void mempcpy16() {
Index: clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -80,7 +80,7 @@
  check::RegionChanges
  > {
   mutable std::unique_ptr BT_Null, BT_Bounds, BT_Overlap,
-  BT_NotCString, BT_AdditionOverflow;
+  BT_NotCString, BT_AdditionOverflow, BT_UninitRead;
 
   mutable const char *CurrentFunctionDescription;
 
@@ -92,11 +92,13 @@
 DefaultBool CheckCStringOutOfBounds;
 DefaultBool CheckCStringBufferOverlap;
 DefaultBool CheckCStringNotNullTerm;
+DefaultBool CheckCStringUninitializedRead;
 
 CheckerNameRef CheckNameCStringNullArg;
 CheckerNameRef CheckNameCStringOutOfBounds;
 CheckerNameRef CheckNameCStringBufferOverlap;
 CheckerNameRef CheckNameCStringNotNullTerm;
+CheckerNameRef CheckNameCStringUninitializedRead;
   };
 
   CStringChecksFilter Filter;
@@ -257,6 +259,8 @@
   void emitNotCStringBug(CheckerContext &C, ProgramStateRef State,
  const Stmt *S, StringRef WarningMsg) const;
   void emitAdditionOverflowBug(CheckerContext &C, ProgramStateRef State) const;
+  void emitUninitializedReadBug(CheckerContext &C, ProgramStateRef State,
+const Expr *E) const;
 
   ProgramStateRef checkAdditionOverflow(CheckerContext &C,
 ProgramStateRef state,
@@ -368,6 +372,14 @@
 return nullptr;
   }
 
+  // Ensure that we wouldn't read uninitialized value.
+  if (Access == AccessKind::read) {
+if (StInBound->getSVal(ER).isUndef()) {
+  emitUninitializedReadBug(C, StInBound, Buffer.Expression);
+  return nullptr;
+}
+  }
+
   // Array bound check succeeded.  From this point forward the array bound
   // should always succeed.
   return StInBound;
@@ -421,6 +433,7 @@
 SVal BufEnd =
 svalBuilder.evalBinOpLN(State, BO_Add, *BufLoc, LastOffset, PtrTy);
 
+State = CheckLocation(C, State, Buffer, BufStart, Access);
 State = CheckLocation(C, State, Buffer, BufEnd, Access);
 
 // If the buffer isn't large enough, abort.
@@ -580,6 +593,26 @@
   }
 }
 
+void CStringChecker::emitUninitializedReadBug(CheckerContext &C,
+  ProgramStateRef State,
+  const Expr *E) const {
+  if (ExplodedNode *N = C.generateErrorNode(State)) {
+const char *Msg =
+"Bytes string function accesses uninitialized/garbage values";
+if (!BT_UninitRead)
+  BT_UninitRead.reset(
+  new BuiltinBug(Filter.CheckNameCStringUninitializedRead,
+ "Accessing unitialized/garbage values", Msg));
+
+BuiltinBug *BT = static_cast(BT_UninitRead.get());
+
+auto Report = std::make_unique(*BT, Msg, N);
+Report->addRange(E->getSourceRange());
+bugreporter::trackExpressionValue(N, E, *Report);
+ 

[PATCH] D120489: [analyzer] Done some changes to detect Uninitialized read by the char array manipulation functions

2022-02-25 Thread Shivam Rajput via Phabricator via cfe-commits
phyBrackets updated this revision to Diff 411447.
phyBrackets added a comment.

update the documentation for the uninitialized read checker


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120489

Files:
  clang/docs/analyzer/checkers.rst
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  clang/test/Analysis/bstring.c

Index: clang/test/Analysis/bstring.c
===
--- clang/test/Analysis/bstring.c
+++ clang/test/Analysis/bstring.c
@@ -70,6 +70,11 @@
 
 #endif /* VARIANT */
 
+void top(char *dst) {
+  char buf[10];
+  memcpy(dst, buf, 10); // expected-warning{{Bytes string function accesses uninitialized/garbage values}}
+  (void)buf;
+}
 
 void memcpy0 () {
   char src[] = {1, 2, 3, 4};
@@ -297,9 +302,12 @@
   int dst[5] = {0};
   int *p;
 
-  p = mempcpy(dst, src, 4 * sizeof(int));
+  p = mempcpy(dst, src, 4 * sizeof(int)); // expected-warning{{Bytes string function accesses uninitialized/garbage values}}
+  // FIXME: This behaviour is actually Unexpected and needs to be fix, 
+  // mempcpy seems to consider the src buffered byte as uninitialized
+  // and returning undef which is actually not the case It should return something like Unknown .
 
-  clang_analyzer_eval(p == &dst[4]); // expected-warning{{TRUE}}
+  clang_analyzer_eval(p == &dst[4]); // no-warning (above is fatal)
 }
 
 struct st {
@@ -314,9 +322,10 @@
   struct st *p2;
 
   p1 = (&s2) + 1;
-  p2 = mempcpy(&s2, &s1, sizeof(struct st));
-
-  clang_analyzer_eval(p1 == p2); // expected-warning{{TRUE}}
+  p2 = mempcpy(&s2, &s1, sizeof(struct st)); // expected-warning{{Bytes string function accesses uninitialized/garbage values}}
+  // FIXME: It seems same as mempcpy14() case.
+  
+  clang_analyzer_eval(p1 == p2); // no-warning (above is fatal)
 }
 
 void mempcpy16() {
Index: clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -80,7 +80,7 @@
  check::RegionChanges
  > {
   mutable std::unique_ptr BT_Null, BT_Bounds, BT_Overlap,
-  BT_NotCString, BT_AdditionOverflow;
+  BT_NotCString, BT_AdditionOverflow, BT_UninitRead;
 
   mutable const char *CurrentFunctionDescription;
 
@@ -92,11 +92,13 @@
 DefaultBool CheckCStringOutOfBounds;
 DefaultBool CheckCStringBufferOverlap;
 DefaultBool CheckCStringNotNullTerm;
+DefaultBool CheckCStringUninitializedRead;
 
 CheckerNameRef CheckNameCStringNullArg;
 CheckerNameRef CheckNameCStringOutOfBounds;
 CheckerNameRef CheckNameCStringBufferOverlap;
 CheckerNameRef CheckNameCStringNotNullTerm;
+CheckerNameRef CheckNameCStringUninitializedRead;
   };
 
   CStringChecksFilter Filter;
@@ -257,6 +259,8 @@
   void emitNotCStringBug(CheckerContext &C, ProgramStateRef State,
  const Stmt *S, StringRef WarningMsg) const;
   void emitAdditionOverflowBug(CheckerContext &C, ProgramStateRef State) const;
+  void emitUninitializedReadBug(CheckerContext &C, ProgramStateRef State,
+const Expr *E) const;
 
   ProgramStateRef checkAdditionOverflow(CheckerContext &C,
 ProgramStateRef state,
@@ -368,6 +372,14 @@
 return nullptr;
   }
 
+  // Ensure that we wouldn't read uninitialized value.
+  if (Access == AccessKind::read) {
+if (StInBound->getSVal(ER).isUndef()) {
+  emitUninitializedReadBug(C, StInBound, Buffer.Expression);
+  return nullptr;
+}
+  }
+
   // Array bound check succeeded.  From this point forward the array bound
   // should always succeed.
   return StInBound;
@@ -421,6 +433,7 @@
 SVal BufEnd =
 svalBuilder.evalBinOpLN(State, BO_Add, *BufLoc, LastOffset, PtrTy);
 
+State = CheckLocation(C, State, Buffer, BufStart, Access);
 State = CheckLocation(C, State, Buffer, BufEnd, Access);
 
 // If the buffer isn't large enough, abort.
@@ -580,6 +593,26 @@
   }
 }
 
+void CStringChecker::emitUninitializedReadBug(CheckerContext &C,
+  ProgramStateRef State,
+  const Expr *E) const {
+  if (ExplodedNode *N = C.generateErrorNode(State)) {
+const char *Msg =
+"Bytes string function accesses uninitialized/garbage values";
+if (!BT_UninitRead)
+  BT_UninitRead.reset(
+  new BuiltinBug(Filter.CheckNameCStringUninitializedRead,
+ "Accessing unitialized/garbage values", Msg));
+
+BuiltinBug *BT = static_cast(BT_UninitRead.get());
+
+auto Report = std::make_unique(*BT, Msg, N);
+Report->addRange(E->getSourceRange());
+bugreporter:

[PATCH] D120489: [analyzer] Done some changes to detect Uninitialized read by the char array manipulation functions

2022-02-26 Thread Shivam Rajput via Phabricator via cfe-commits
phyBrackets updated this revision to Diff 411601.
phyBrackets added a comment.

aligned the indentation


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120489

Files:
  clang/docs/analyzer/checkers.rst
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  clang/test/Analysis/bstring.c

Index: clang/test/Analysis/bstring.c
===
--- clang/test/Analysis/bstring.c
+++ clang/test/Analysis/bstring.c
@@ -70,6 +70,11 @@
 
 #endif /* VARIANT */
 
+void top(char *dst) {
+  char buf[10];
+  memcpy(dst, buf, 10); // expected-warning{{Bytes string function accesses uninitialized/garbage values}}
+  (void)buf;
+}
 
 void memcpy0 () {
   char src[] = {1, 2, 3, 4};
@@ -297,9 +302,12 @@
   int dst[5] = {0};
   int *p;
 
-  p = mempcpy(dst, src, 4 * sizeof(int));
+  p = mempcpy(dst, src, 4 * sizeof(int)); // expected-warning{{Bytes string function accesses uninitialized/garbage values}}
+  // FIXME: This behaviour is actually Unexpected and needs to be fix, 
+  // mempcpy seems to consider the src buffered byte as uninitialized
+  // and returning undef which is actually not the case It should return something like Unknown .
 
-  clang_analyzer_eval(p == &dst[4]); // expected-warning{{TRUE}}
+  clang_analyzer_eval(p == &dst[4]); // no-warning (above is fatal)
 }
 
 struct st {
@@ -314,9 +322,10 @@
   struct st *p2;
 
   p1 = (&s2) + 1;
-  p2 = mempcpy(&s2, &s1, sizeof(struct st));
-
-  clang_analyzer_eval(p1 == p2); // expected-warning{{TRUE}}
+  p2 = mempcpy(&s2, &s1, sizeof(struct st)); // expected-warning{{Bytes string function accesses uninitialized/garbage values}}
+  // FIXME: It seems same as mempcpy14() case.
+  
+  clang_analyzer_eval(p1 == p2); // no-warning (above is fatal)
 }
 
 void mempcpy16() {
Index: clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -80,7 +80,7 @@
  check::RegionChanges
  > {
   mutable std::unique_ptr BT_Null, BT_Bounds, BT_Overlap,
-  BT_NotCString, BT_AdditionOverflow;
+  BT_NotCString, BT_AdditionOverflow, BT_UninitRead;
 
   mutable const char *CurrentFunctionDescription;
 
@@ -92,11 +92,13 @@
 DefaultBool CheckCStringOutOfBounds;
 DefaultBool CheckCStringBufferOverlap;
 DefaultBool CheckCStringNotNullTerm;
+DefaultBool CheckCStringUninitializedRead;
 
 CheckerNameRef CheckNameCStringNullArg;
 CheckerNameRef CheckNameCStringOutOfBounds;
 CheckerNameRef CheckNameCStringBufferOverlap;
 CheckerNameRef CheckNameCStringNotNullTerm;
+CheckerNameRef CheckNameCStringUninitializedRead;
   };
 
   CStringChecksFilter Filter;
@@ -257,6 +259,8 @@
   void emitNotCStringBug(CheckerContext &C, ProgramStateRef State,
  const Stmt *S, StringRef WarningMsg) const;
   void emitAdditionOverflowBug(CheckerContext &C, ProgramStateRef State) const;
+  void emitUninitializedReadBug(CheckerContext &C, ProgramStateRef State,
+const Expr *E) const;
 
   ProgramStateRef checkAdditionOverflow(CheckerContext &C,
 ProgramStateRef state,
@@ -368,6 +372,14 @@
 return nullptr;
   }
 
+  // Ensure that we wouldn't read uninitialized value.
+  if (Access == AccessKind::read) {
+if (StInBound->getSVal(ER).isUndef()) {
+  emitUninitializedReadBug(C, StInBound, Buffer.Expression);
+  return nullptr;
+}
+  }
+
   // Array bound check succeeded.  From this point forward the array bound
   // should always succeed.
   return StInBound;
@@ -421,6 +433,7 @@
 SVal BufEnd =
 svalBuilder.evalBinOpLN(State, BO_Add, *BufLoc, LastOffset, PtrTy);
 
+State = CheckLocation(C, State, Buffer, BufStart, Access);
 State = CheckLocation(C, State, Buffer, BufEnd, Access);
 
 // If the buffer isn't large enough, abort.
@@ -580,6 +593,26 @@
   }
 }
 
+void CStringChecker::emitUninitializedReadBug(CheckerContext &C,
+  ProgramStateRef State,
+  const Expr *E) const {
+  if (ExplodedNode *N = C.generateErrorNode(State)) {
+const char *Msg =
+"Bytes string function accesses uninitialized/garbage values";
+if (!BT_UninitRead)
+  BT_UninitRead.reset(
+  new BuiltinBug(Filter.CheckNameCStringUninitializedRead,
+ "Accessing unitialized/garbage values", Msg));
+
+BuiltinBug *BT = static_cast(BT_UninitRead.get());
+
+auto Report = std::make_unique(*BT, Msg, N);
+Report->addRange(E->getSourceRange());
+bugreporter::trackExpressionValue(N, E, *Report)

[PATCH] D120489: [analyzer] Done some changes to detect Uninitialized read by the char array manipulation functions

2022-02-26 Thread Shivam Rajput via Phabricator via cfe-commits
phyBrackets updated this revision to Diff 411652.
phyBrackets added a comment.

fix some alignment issue


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120489

Files:
  clang/docs/analyzer/checkers.rst
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  clang/test/Analysis/bstring.c

Index: clang/test/Analysis/bstring.c
===
--- clang/test/Analysis/bstring.c
+++ clang/test/Analysis/bstring.c
@@ -70,6 +70,11 @@
 
 #endif /* VARIANT */
 
+void top(char *dst) {
+  char buf[10];
+  memcpy(dst, buf, 10); // expected-warning{{Bytes string function accesses uninitialized/garbage values}}
+  (void)buf;
+}
 
 void memcpy0 () {
   char src[] = {1, 2, 3, 4};
@@ -297,9 +302,12 @@
   int dst[5] = {0};
   int *p;
 
-  p = mempcpy(dst, src, 4 * sizeof(int));
+  p = mempcpy(dst, src, 4 * sizeof(int)); // expected-warning{{Bytes string function accesses uninitialized/garbage values}}
+  // FIXME: This behaviour is actually Unexpected and needs to be fix, 
+  // mempcpy seems to consider the src buffered byte as uninitialized
+  // and returning undef which is actually not the case It should return something like Unknown .
 
-  clang_analyzer_eval(p == &dst[4]); // expected-warning{{TRUE}}
+  clang_analyzer_eval(p == &dst[4]); // no-warning (above is fatal)
 }
 
 struct st {
@@ -314,9 +322,10 @@
   struct st *p2;
 
   p1 = (&s2) + 1;
-  p2 = mempcpy(&s2, &s1, sizeof(struct st));
-
-  clang_analyzer_eval(p1 == p2); // expected-warning{{TRUE}}
+  p2 = mempcpy(&s2, &s1, sizeof(struct st)); // expected-warning{{Bytes string function accesses uninitialized/garbage values}}
+  // FIXME: It seems same as mempcpy14() case.
+  
+  clang_analyzer_eval(p1 == p2); // no-warning (above is fatal)
 }
 
 void mempcpy16() {
Index: clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -80,7 +80,7 @@
  check::RegionChanges
  > {
   mutable std::unique_ptr BT_Null, BT_Bounds, BT_Overlap,
-  BT_NotCString, BT_AdditionOverflow;
+  BT_NotCString, BT_AdditionOverflow, BT_UninitRead;
 
   mutable const char *CurrentFunctionDescription;
 
@@ -92,11 +92,13 @@
 DefaultBool CheckCStringOutOfBounds;
 DefaultBool CheckCStringBufferOverlap;
 DefaultBool CheckCStringNotNullTerm;
+DefaultBool CheckCStringUninitializedRead;
 
 CheckerNameRef CheckNameCStringNullArg;
 CheckerNameRef CheckNameCStringOutOfBounds;
 CheckerNameRef CheckNameCStringBufferOverlap;
 CheckerNameRef CheckNameCStringNotNullTerm;
+CheckerNameRef CheckNameCStringUninitializedRead;
   };
 
   CStringChecksFilter Filter;
@@ -257,6 +259,8 @@
   void emitNotCStringBug(CheckerContext &C, ProgramStateRef State,
  const Stmt *S, StringRef WarningMsg) const;
   void emitAdditionOverflowBug(CheckerContext &C, ProgramStateRef State) const;
+  void emitUninitializedReadBug(CheckerContext &C, ProgramStateRef State,
+const Expr *E) const;
 
   ProgramStateRef checkAdditionOverflow(CheckerContext &C,
 ProgramStateRef state,
@@ -368,6 +372,14 @@
 return nullptr;
   }
 
+  // Ensure that we wouldn't read uninitialized value.
+  if (Access == AccessKind::read) {
+if (StInBound->getSVal(ER).isUndef()) {
+  emitUninitializedReadBug(C, StInBound, Buffer.Expression);
+  return nullptr;
+}
+  }
+
   // Array bound check succeeded.  From this point forward the array bound
   // should always succeed.
   return StInBound;
@@ -421,6 +433,7 @@
 SVal BufEnd =
 svalBuilder.evalBinOpLN(State, BO_Add, *BufLoc, LastOffset, PtrTy);
 
+State = CheckLocation(C, State, Buffer, BufStart, Access);
 State = CheckLocation(C, State, Buffer, BufEnd, Access);
 
 // If the buffer isn't large enough, abort.
@@ -580,6 +593,26 @@
   }
 }
 
+void CStringChecker::emitUninitializedReadBug(CheckerContext &C,
+  ProgramStateRef State,
+  const Expr *E) const {
+  if (ExplodedNode *N = C.generateErrorNode(State)) {
+const char *Msg =
+"Bytes string function accesses uninitialized/garbage values";
+if (!BT_UninitRead)
+  BT_UninitRead.reset(
+  new BuiltinBug(Filter.CheckNameCStringUninitializedRead,
+ "Accessing unitialized/garbage values", Msg));
+
+BuiltinBug *BT = static_cast(BT_UninitRead.get());
+
+auto Report = std::make_unique(*BT, Msg, N);
+Report->addRange(E->getSourceRange());
+bugreporter::trackExpressionValue(N, E, *Report

[PATCH] D120489: [analyzer] Done some changes to detect Uninitialized read by the char array manipulation functions

2022-02-28 Thread Shivam Rajput via Phabricator via cfe-commits
phyBrackets added inline comments.



Comment at: clang/test/Analysis/bstring.c:310
 
-  clang_analyzer_eval(p == &dst[4]); // expected-warning{{TRUE}}
+  clang_analyzer_eval(p == &dst[4]); // no-warning (above is fatal)
 }

NoQ wrote:
> Hmm, given that your change suppresses some existing tests, maybe disable 
> your checker on this file and copy the updated tests to a new file that would 
> have the checker enabled?
I don't know how will it affect that but still that's an exception and from 
these exceptions test cases, we are updated about how it gonna fail on some 
tests cases and try to work on those exceptions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120489

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


[PATCH] D120489: [analyzer] Done some changes to detect Uninitialized read by the char array manipulation functions

2022-02-28 Thread Shivam Rajput via Phabricator via cfe-commits
phyBrackets added a comment.

Hey @NoQ and @steakhal , can i land this patch ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120489

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


[PATCH] D120489: [analyzer] Done some changes to detect Uninitialized read by the char array manipulation functions

2022-03-02 Thread Shivam Rajput via Phabricator via cfe-commits
phyBrackets updated this revision to Diff 412391.
phyBrackets added a comment.
Herald added a project: All.

Created the separate test file for UninitializedRead checker


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120489

Files:
  clang/docs/analyzer/checkers.rst
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  clang/test/Analysis/bstring.c
  clang/test/Analysis/bstring_UninitRead.c

Index: clang/test/Analysis/bstring_UninitRead.c
===
--- /dev/null
+++ clang/test/Analysis/bstring_UninitRead.c
@@ -0,0 +1,116 @@
+// RUN: %clang_analyze_cc1 -verify %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=unix.cstring \
+// RUN:   -analyzer-checker=alpha.unix.cstring \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -analyzer-config eagerly-assume=false  
+//
+// RUN: %clang_analyze_cc1 -verify %s -DUSE_BUILTINS \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=unix.cstring \
+// RUN:   -analyzer-checker=alpha.unix.cstring \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -analyzer-config eagerly-assume=false
+//
+// RUN: %clang_analyze_cc1 -verify %s -DVARIANT \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=unix.cstring \
+// RUN:   -analyzer-checker=alpha.unix.cstring \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -analyzer-config eagerly-assume=false
+//
+// RUN: %clang_analyze_cc1 -verify %s -DUSE_BUILTINS -DVARIANT \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=unix.cstring \
+// RUN:   -analyzer-checker=alpha.unix.cstring \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -analyzer-config eagerly-assume=false
+
+// This file is generally for the alpha.unix.cstring.UninitializedRead Checker, the reason for putting it into
+// the separate file because the checker is break the some existing test cases in bstring.c file , so we don't 
+// wanna mess up with some existing test case so it's better to create separate file for it, this file also include 
+// the broken test for the reference in future about the broken tests.
+
+#ifdef USE_BUILTINS
+# define BUILTIN(f) __builtin_ ## f
+#else /* USE_BUILTINS */
+# define BUILTIN(f) f
+#endif /* USE_BUILTINS */
+
+typedef typeof(sizeof(int)) size_t;
+
+void clang_analyzer_eval(int);
+
+
+
+#ifdef VARIANT
+
+#define __memcpy_chk BUILTIN(__memcpy_chk)
+void *__memcpy_chk(void *restrict s1, const void *restrict s2, size_t n,
+   size_t destlen);
+
+#define memcpy(a,b,c) __memcpy_chk(a,b,c,(size_t)-1)
+
+#else /* VARIANT */
+
+#define memcpy BUILTIN(memcpy)
+void *memcpy(void *restrict s1, const void *restrict s2, size_t n);
+
+#endif /* VARIANT */
+
+void top(char *dst) {
+  char buf[10];
+  memcpy(dst, buf, 10); // expected-warning{{Bytes string function accesses uninitialized/garbage values}}
+  (void)buf;
+}
+
+//===--===
+// mempcpy()
+//===--===
+
+#ifdef VARIANT
+
+#define __mempcpy_chk BUILTIN(__mempcpy_chk)
+void *__mempcpy_chk(void *restrict s1, const void *restrict s2, size_t n,
+   size_t destlen);
+
+#define mempcpy(a,b,c) __mempcpy_chk(a,b,c,(size_t)-1)
+
+#else /* VARIANT */
+
+#define mempcpy BUILTIN(mempcpy)
+void *mempcpy(void *restrict s1, const void *restrict s2, size_t n);
+
+#endif /* VARIANT */
+
+void mempcpy14() {
+  int src[] = {1, 2, 3, 4};
+  int dst[5] = {0};
+  int *p;
+
+  p = mempcpy(dst, src, 4 * sizeof(int)); // expected-warning{{Bytes string function accesses uninitialized/garbage values}}
+  // FIXME: This behaviour is actually Unexpected and needs to be fix, 
+  // mempcpy seems to consider the src buffered byte as uninitialized
+  // and returning undef which is actually not the case It should return something like Unknown .
+
+  clang_analyzer_eval(p == &dst[4]); // no-warning (above is fatal)
+}
+
+struct st {
+  int i;
+  int j;
+};
+
+
+void mempcpy15() {
+  struct st s1 = {0};
+  struct st s2;
+  struct st *p1;
+  struct st *p2;
+
+  p1 = (&s2) + 1;
+  p2 = mempcpy(&s2, &s1, sizeof(struct st)); // expected-warning{{Bytes string function accesses uninitialized/garbage values}}
+  // FIXME: It seems same as mempcpy14() case.
+  
+  clang_analyzer_eval(p1 == p2); // no-warning (above is fatal)
+}
Index: clang/test/Analysis/bstring.c
===
--- clang/test/Analysis/bstring.c
+++ clang/test/Analysis/bstring.c
@@ -2,13 +2,15 @@
 // RUN:   -analyzer-checker=core \
 // RUN:   -analyzer-checker=unix.cstring \
 // RUN:   -analyzer-checker=alpha.unix.cstring \
+// RUN:   -analyzer-disable-checker=alpha.unix.cstring.UninitializedRead \
 // RUN:   -analyzer-checker=debug

[PATCH] D120489: [analyzer] Done some changes to detect Uninitialized read by the char array manipulation functions

2022-03-02 Thread Shivam Rajput via Phabricator via cfe-commits
phyBrackets added a comment.

Hey @NoQ and @steakhal , will you just check , if everything looks fine or not! 
The test cases run successfully tho now!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120489

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


[PATCH] D120489: [analyzer] Done some changes to detect Uninitialized read by the char array manipulation functions

2022-03-02 Thread Shivam Rajput via Phabricator via cfe-commits
phyBrackets added inline comments.



Comment at: clang/test/Analysis/bstring_UninitRead.c:67-85
+//===--===
+// mempcpy()
+//===--===
+
+#ifdef VARIANT
+
+#define __mempcpy_chk BUILTIN(__mempcpy_chk)

steakhal wrote:
> I don't think you should copy these as well.
> The matching logic is already tested in `bstring.c`.
> 
> That being said, a single `RUN` line should be enough in this file.
I'm not able to run test successfully with single RUN , 
```
// RUN: -analyzer-checker=alpha.unix.cstring.UninitializedRead

```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120489

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


[PATCH] D120489: [analyzer] Done some changes to detect Uninitialized read by the char array manipulation functions

2022-03-02 Thread Shivam Rajput via Phabricator via cfe-commits
phyBrackets added inline comments.



Comment at: clang/test/Analysis/bstring_UninitRead.c:67-85
+//===--===
+// mempcpy()
+//===--===
+
+#ifdef VARIANT
+
+#define __mempcpy_chk BUILTIN(__mempcpy_chk)

phyBrackets wrote:
> steakhal wrote:
> > I don't think you should copy these as well.
> > The matching logic is already tested in `bstring.c`.
> > 
> > That being said, a single `RUN` line should be enough in this file.
> I'm not able to run test successfully with single RUN , 
> ```
> // RUN: -analyzer-checker=alpha.unix.cstring.UninitializedRead
> 
> ```
wait , I think I got this! Thanks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120489

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


[PATCH] D120489: [analyzer] Done some changes to detect Uninitialized read by the char array manipulation functions

2022-03-02 Thread Shivam Rajput via Phabricator via cfe-commits
phyBrackets updated this revision to Diff 412452.
phyBrackets added a comment.

Remove unneccesary RUN and some macros definitions


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120489

Files:
  clang/docs/analyzer/checkers.rst
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  clang/test/Analysis/bstring.c
  clang/test/Analysis/bstring_UninitRead.c

Index: clang/test/Analysis/bstring_UninitRead.c
===
--- /dev/null
+++ clang/test/Analysis/bstring_UninitRead.c
@@ -0,0 +1,59 @@
+// RUN: %clang_analyze_cc1 -verify %s \
+// RUN: -analyzer-checker=alpha.unix.cstring 
+
+
+// This file is generally for the alpha.unix.cstring.UninitializedRead Checker, the reason for putting it into
+// the separate file because the checker is break the some existing test cases in bstring.c file , so we don't 
+// wanna mess up with some existing test case so it's better to create separate file for it, this file also include 
+// the broken test for the reference in future about the broken tests.
+
+
+typedef typeof(sizeof(int)) size_t;
+
+void clang_analyzer_eval(int);
+
+void *memcpy(void *restrict s1, const void *restrict s2, size_t n);
+
+void top(char *dst) {
+  char buf[10];
+  memcpy(dst, buf, 10); // expected-warning{{Bytes string function accesses uninitialized/garbage values}}
+  (void)buf;
+}
+
+//===--===
+// mempcpy()
+//===--===
+
+void *mempcpy(void *restrict s1, const void *restrict s2, size_t n);
+
+void mempcpy14() {
+  int src[] = {1, 2, 3, 4};
+  int dst[5] = {0};
+  int *p;
+
+  p = mempcpy(dst, src, 4 * sizeof(int)); // expected-warning{{Bytes string function accesses uninitialized/garbage values}}
+   // FIXME: This behaviour is actually surprising and needs to be fixed, 
+   // mempcpy seems to consider the very last byte of the src buffer uninitialized
+   // and returning undef unfortunately. It should have returned unknown or a conjured value instead.
+
+  clang_analyzer_eval(p == &dst[4]); // no-warning (above is fatal)
+}
+
+struct st {
+  int i;
+  int j;
+};
+
+
+void mempcpy15() {
+  struct st s1 = {0};
+  struct st s2;
+  struct st *p1;
+  struct st *p2;
+
+  p1 = (&s2) + 1;
+  p2 = mempcpy(&s2, &s1, sizeof(struct st)); // expected-warning{{Bytes string function accesses uninitialized/garbage values}}
+  // FIXME: It seems same as mempcpy14() case.
+  
+  clang_analyzer_eval(p1 == p2); // no-warning (above is fatal)
+}
Index: clang/test/Analysis/bstring.c
===
--- clang/test/Analysis/bstring.c
+++ clang/test/Analysis/bstring.c
@@ -2,13 +2,15 @@
 // RUN:   -analyzer-checker=core \
 // RUN:   -analyzer-checker=unix.cstring \
 // RUN:   -analyzer-checker=alpha.unix.cstring \
+// RUN:   -analyzer-disable-checker=alpha.unix.cstring.UninitializedRead \
 // RUN:   -analyzer-checker=debug.ExprInspection \
-// RUN:   -analyzer-config eagerly-assume=false
+// RUN:   -analyzer-config eagerly-assume=false  
 //
 // RUN: %clang_analyze_cc1 -verify %s -DUSE_BUILTINS \
 // RUN:   -analyzer-checker=core \
 // RUN:   -analyzer-checker=unix.cstring \
 // RUN:   -analyzer-checker=alpha.unix.cstring \
+// RUN:   -analyzer-disable-checker=alpha.unix.cstring.UninitializedRead \
 // RUN:   -analyzer-checker=debug.ExprInspection \
 // RUN:   -analyzer-config eagerly-assume=false
 //
@@ -16,6 +18,7 @@
 // RUN:   -analyzer-checker=core \
 // RUN:   -analyzer-checker=unix.cstring \
 // RUN:   -analyzer-checker=alpha.unix.cstring \
+// RUN:   -analyzer-disable-checker=alpha.unix.cstring.UninitializedRead \
 // RUN:   -analyzer-checker=debug.ExprInspection \
 // RUN:   -analyzer-config eagerly-assume=false
 //
@@ -23,6 +26,7 @@
 // RUN:   -analyzer-checker=core \
 // RUN:   -analyzer-checker=unix.cstring \
 // RUN:   -analyzer-checker=alpha.unix.cstring \
+// RUN:   -analyzer-disable-checker=alpha.unix.cstring.UninitializedRead \
 // RUN:   -analyzer-checker=debug.ExprInspection \
 // RUN:   -analyzer-config eagerly-assume=false
 
@@ -70,7 +74,6 @@
 
 #endif /* VARIANT */
 
-
 void memcpy0 () {
   char src[] = {1, 2, 3, 4};
   char dst[4] = {0};
@@ -315,7 +318,7 @@
 
   p1 = (&s2) + 1;
   p2 = mempcpy(&s2, &s1, sizeof(struct st));
-
+  
   clang_analyzer_eval(p1 == p2); // expected-warning{{TRUE}}
 }
 
Index: clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -80,7 +80,7 @@
  check::RegionChanges
  > {
   mutable std::unique_ptr BT_Null, BT_Bounds, BT_Overla

[PATCH] D120489: [analyzer] Done some changes to detect Uninitialized read by the char array manipulation functions

2022-03-02 Thread Shivam Rajput via Phabricator via cfe-commits
phyBrackets updated this revision to Diff 412464.
phyBrackets added a comment.

enabled the core checker


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120489

Files:
  clang/docs/analyzer/checkers.rst
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  clang/test/Analysis/bstring.c
  clang/test/Analysis/bstring_UninitRead.c

Index: clang/test/Analysis/bstring_UninitRead.c
===
--- /dev/null
+++ clang/test/Analysis/bstring_UninitRead.c
@@ -0,0 +1,59 @@
+// RUN: %clang_analyze_cc1 -verify %s \
+// RUN: -analyzer-checker=core,alpha.unix.cstring
+
+
+// This file is generally for the alpha.unix.cstring.UninitializedRead Checker, the reason for putting it into
+// the separate file because the checker is break the some existing test cases in bstring.c file , so we don't 
+// wanna mess up with some existing test case so it's better to create separate file for it, this file also include 
+// the broken test for the reference in future about the broken tests.
+
+
+typedef typeof(sizeof(int)) size_t;
+
+void clang_analyzer_eval(int);
+
+void *memcpy(void *restrict s1, const void *restrict s2, size_t n);
+
+void top(char *dst) {
+  char buf[10];
+  memcpy(dst, buf, 10); // expected-warning{{Bytes string function accesses uninitialized/garbage values}}
+  (void)buf;
+}
+
+//===--===
+// mempcpy()
+//===--===
+
+void *mempcpy(void *restrict s1, const void *restrict s2, size_t n);
+
+void mempcpy14() {
+  int src[] = {1, 2, 3, 4};
+  int dst[5] = {0};
+  int *p;
+
+  p = mempcpy(dst, src, 4 * sizeof(int)); // expected-warning{{Bytes string function accesses uninitialized/garbage values}}
+   // FIXME: This behaviour is actually surprising and needs to be fixed, 
+   // mempcpy seems to consider the very last byte of the src buffer uninitialized
+   // and returning undef unfortunately. It should have returned unknown or a conjured value instead.
+
+  clang_analyzer_eval(p == &dst[4]); // no-warning (above is fatal)
+}
+
+struct st {
+  int i;
+  int j;
+};
+
+
+void mempcpy15() {
+  struct st s1 = {0};
+  struct st s2;
+  struct st *p1;
+  struct st *p2;
+
+  p1 = (&s2) + 1;
+  p2 = mempcpy(&s2, &s1, sizeof(struct st)); // expected-warning{{Bytes string function accesses uninitialized/garbage values}}
+  // FIXME: It seems same as mempcpy14() case.
+  
+  clang_analyzer_eval(p1 == p2); // no-warning (above is fatal)
+}
Index: clang/test/Analysis/bstring.c
===
--- clang/test/Analysis/bstring.c
+++ clang/test/Analysis/bstring.c
@@ -2,13 +2,15 @@
 // RUN:   -analyzer-checker=core \
 // RUN:   -analyzer-checker=unix.cstring \
 // RUN:   -analyzer-checker=alpha.unix.cstring \
+// RUN:   -analyzer-disable-checker=alpha.unix.cstring.UninitializedRead \
 // RUN:   -analyzer-checker=debug.ExprInspection \
-// RUN:   -analyzer-config eagerly-assume=false
+// RUN:   -analyzer-config eagerly-assume=false  
 //
 // RUN: %clang_analyze_cc1 -verify %s -DUSE_BUILTINS \
 // RUN:   -analyzer-checker=core \
 // RUN:   -analyzer-checker=unix.cstring \
 // RUN:   -analyzer-checker=alpha.unix.cstring \
+// RUN:   -analyzer-disable-checker=alpha.unix.cstring.UninitializedRead \
 // RUN:   -analyzer-checker=debug.ExprInspection \
 // RUN:   -analyzer-config eagerly-assume=false
 //
@@ -16,6 +18,7 @@
 // RUN:   -analyzer-checker=core \
 // RUN:   -analyzer-checker=unix.cstring \
 // RUN:   -analyzer-checker=alpha.unix.cstring \
+// RUN:   -analyzer-disable-checker=alpha.unix.cstring.UninitializedRead \
 // RUN:   -analyzer-checker=debug.ExprInspection \
 // RUN:   -analyzer-config eagerly-assume=false
 //
@@ -23,6 +26,7 @@
 // RUN:   -analyzer-checker=core \
 // RUN:   -analyzer-checker=unix.cstring \
 // RUN:   -analyzer-checker=alpha.unix.cstring \
+// RUN:   -analyzer-disable-checker=alpha.unix.cstring.UninitializedRead \
 // RUN:   -analyzer-checker=debug.ExprInspection \
 // RUN:   -analyzer-config eagerly-assume=false
 
@@ -70,7 +74,6 @@
 
 #endif /* VARIANT */
 
-
 void memcpy0 () {
   char src[] = {1, 2, 3, 4};
   char dst[4] = {0};
@@ -315,7 +318,7 @@
 
   p1 = (&s2) + 1;
   p2 = mempcpy(&s2, &s1, sizeof(struct st));
-
+  
   clang_analyzer_eval(p1 == p2); // expected-warning{{TRUE}}
 }
 
Index: clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -80,7 +80,7 @@
  check::RegionChanges
  > {
   mutable std::unique_ptr BT_Null, BT_Bounds, BT_Overlap,
-  BT_NotCStrin

[PATCH] D120489: [analyzer] Done some changes to detect Uninitialized read by the char array manipulation functions

2022-03-02 Thread Shivam Rajput via Phabricator via cfe-commits
phyBrackets added inline comments.



Comment at: clang/test/Analysis/bstring_UninitRead.c:2
+// RUN: %clang_analyze_cc1 -verify %s \
+// RUN: -analyzer-checker=alpha.unix.cstring 
+

steakhal wrote:
> 
Yeah done! Thanks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120489

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


[PATCH] D120489: [analyzer] Done some changes to detect Uninitialized read by the char array manipulation functions

2022-03-02 Thread Shivam Rajput via Phabricator via cfe-commits
phyBrackets added a comment.

@steakhal , if everything looks fine, can i land this ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120489

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


[PATCH] D120489: [analyzer] Done some changes to detect Uninitialized read by the char array manipulation functions

2022-03-03 Thread Shivam Rajput via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbd1917c88a32: [analyzer] Done some changes to detect 
Uninitialized read by the char array… (authored by Shivam 
<75530356+phybrack...@users.noreply.github.com>, committed by 
phyBrackets).

Changed prior to commit:
  https://reviews.llvm.org/D120489?vs=412464&id=412750#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120489

Files:
  clang/docs/analyzer/checkers.rst
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  clang/test/Analysis/bstring.c
  clang/test/Analysis/bstring_UninitRead.c

Index: clang/test/Analysis/bstring_UninitRead.c
===
--- /dev/null
+++ clang/test/Analysis/bstring_UninitRead.c
@@ -0,0 +1,59 @@
+// RUN: %clang_analyze_cc1 -verify %s \
+// RUN: -analyzer-checker=core,alpha.unix.cstring
+
+
+// This file is generally for the alpha.unix.cstring.UninitializedRead Checker, the reason for putting it into
+// the separate file because the checker is break the some existing test cases in bstring.c file , so we don't 
+// wanna mess up with some existing test case so it's better to create separate file for it, this file also include 
+// the broken test for the reference in future about the broken tests.
+
+
+typedef typeof(sizeof(int)) size_t;
+
+void clang_analyzer_eval(int);
+
+void *memcpy(void *restrict s1, const void *restrict s2, size_t n);
+
+void top(char *dst) {
+  char buf[10];
+  memcpy(dst, buf, 10); // expected-warning{{Bytes string function accesses uninitialized/garbage values}}
+  (void)buf;
+}
+
+//===--===
+// mempcpy()
+//===--===
+
+void *mempcpy(void *restrict s1, const void *restrict s2, size_t n);
+
+void mempcpy14() {
+  int src[] = {1, 2, 3, 4};
+  int dst[5] = {0};
+  int *p;
+
+  p = mempcpy(dst, src, 4 * sizeof(int)); // expected-warning{{Bytes string function accesses uninitialized/garbage values}}
+   // FIXME: This behaviour is actually surprising and needs to be fixed, 
+   // mempcpy seems to consider the very last byte of the src buffer uninitialized
+   // and returning undef unfortunately. It should have returned unknown or a conjured value instead.
+
+  clang_analyzer_eval(p == &dst[4]); // no-warning (above is fatal)
+}
+
+struct st {
+  int i;
+  int j;
+};
+
+
+void mempcpy15() {
+  struct st s1 = {0};
+  struct st s2;
+  struct st *p1;
+  struct st *p2;
+
+  p1 = (&s2) + 1;
+  p2 = mempcpy(&s2, &s1, sizeof(struct st)); // expected-warning{{Bytes string function accesses uninitialized/garbage values}}
+  // FIXME: It seems same as mempcpy14() case.
+  
+  clang_analyzer_eval(p1 == p2); // no-warning (above is fatal)
+}
Index: clang/test/Analysis/bstring.c
===
--- clang/test/Analysis/bstring.c
+++ clang/test/Analysis/bstring.c
@@ -2,13 +2,15 @@
 // RUN:   -analyzer-checker=core \
 // RUN:   -analyzer-checker=unix.cstring \
 // RUN:   -analyzer-checker=alpha.unix.cstring \
+// RUN:   -analyzer-disable-checker=alpha.unix.cstring.UninitializedRead \
 // RUN:   -analyzer-checker=debug.ExprInspection \
-// RUN:   -analyzer-config eagerly-assume=false
+// RUN:   -analyzer-config eagerly-assume=false  
 //
 // RUN: %clang_analyze_cc1 -verify %s -DUSE_BUILTINS \
 // RUN:   -analyzer-checker=core \
 // RUN:   -analyzer-checker=unix.cstring \
 // RUN:   -analyzer-checker=alpha.unix.cstring \
+// RUN:   -analyzer-disable-checker=alpha.unix.cstring.UninitializedRead \
 // RUN:   -analyzer-checker=debug.ExprInspection \
 // RUN:   -analyzer-config eagerly-assume=false
 //
@@ -16,6 +18,7 @@
 // RUN:   -analyzer-checker=core \
 // RUN:   -analyzer-checker=unix.cstring \
 // RUN:   -analyzer-checker=alpha.unix.cstring \
+// RUN:   -analyzer-disable-checker=alpha.unix.cstring.UninitializedRead \
 // RUN:   -analyzer-checker=debug.ExprInspection \
 // RUN:   -analyzer-config eagerly-assume=false
 //
@@ -23,6 +26,7 @@
 // RUN:   -analyzer-checker=core \
 // RUN:   -analyzer-checker=unix.cstring \
 // RUN:   -analyzer-checker=alpha.unix.cstring \
+// RUN:   -analyzer-disable-checker=alpha.unix.cstring.UninitializedRead \
 // RUN:   -analyzer-checker=debug.ExprInspection \
 // RUN:   -analyzer-config eagerly-assume=false
 
@@ -315,7 +319,7 @@
 
   p1 = (&s2) + 1;
   p2 = mempcpy(&s2, &s1, sizeof(struct st));
-
+  
   clang_analyzer_eval(p1 == p2); // expected-warning{{TRUE}}
 }
 
Index: clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -80,7 +80,7 @@
  

[PATCH] D120489: [analyzer] Done some changes to detect Uninitialized read by the char array manipulation functions

2022-03-03 Thread Shivam Rajput via Phabricator via cfe-commits
phyBrackets added a comment.

https://github.com/llvm/llvm-project/commit/bd1917c88a32c0930864d04f4e71155dcc3fa592
 , Hey @steakhal , I land it but why it is not showing the

void emitUninitializedReadBug(CheckerContext &C, ProgramStateRef State,
   const Expr *E) const;
  ``` ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120489

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


[PATCH] D121045: [Analyzer][Refactor] Removed the duplicating of a if statement having same condition

2022-03-05 Thread Shivam Rajput via Phabricator via cfe-commits
phyBrackets created this revision.
Herald added subscribers: manas, steakhal, ASDenysPetrov, martong, dkrupp, 
donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, 
xazax.hun.
Herald added a project: All.
phyBrackets requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121045

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


Index: clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
@@ -107,11 +107,7 @@
   dyn_cast(Ex->IgnoreParenCasts());
 if (!BO)
   break;
-if (BO->getOpcode() == BO_Assign) {
-  Ex = BO->getRHS();
-  continue;
-}
-if (BO->getOpcode() == BO_Comma) {
+if (BO->getOpcode() == BO_Assign || BO->getOpcode() == BO_Comma) {
   Ex = BO->getRHS();
   continue;
 }


Index: clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
@@ -107,11 +107,7 @@
   dyn_cast(Ex->IgnoreParenCasts());
 if (!BO)
   break;
-if (BO->getOpcode() == BO_Assign) {
-  Ex = BO->getRHS();
-  continue;
-}
-if (BO->getOpcode() == BO_Comma) {
+if (BO->getOpcode() == BO_Assign || BO->getOpcode() == BO_Comma) {
   Ex = BO->getRHS();
   continue;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121045: [analyzer][NFC] Merge similar conditional paths

2022-03-06 Thread Shivam Rajput via Phabricator via cfe-commits
phyBrackets added a comment.

In D121045#3362373 , @steakhal wrote:

> I would probably query the opcode only once and reuse it, but is also fine.
>
> Btw whats your intention making this change? Do you plan greater 
> refactorings/cleanups?

Yeah, I think query the opcode once is a nice idea tho, let me do this in this 
patch only. And yeah I'm thinking of refactoring/cleanups where it needed and 
would love to make some big refactors. But I found this when I was looking into 
this issue (https://github.com/llvm/llvm-project/issues/53564 and needs to look 
at the deadstorechecker file.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121045

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


[PATCH] D121045: [analyzer][NFC] Merge similar conditional paths

2022-03-06 Thread Shivam Rajput via Phabricator via cfe-commits
phyBrackets updated this revision to Diff 413300.
phyBrackets added a comment.

query the opcode only once and reuse it


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121045

Files:
  clang/docs/DataFlowAnalysisIntro.md
  clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp


Index: clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
@@ -107,11 +107,8 @@
   dyn_cast(Ex->IgnoreParenCasts());
 if (!BO)
   break;
-if (BO->getOpcode() == BO_Assign) {
-  Ex = BO->getRHS();
-  continue;
-}
-if (BO->getOpcode() == BO_Comma) {
+BinaryOperatorKind BO_AssignOrComma = BO->getOpcode();
+if (BO_AssignOrComma == BO_Assign || BO_AssignOrComma == BO_Comma) {
   Ex = BO->getRHS();
   continue;
 }
Index: clang/docs/DataFlowAnalysisIntro.md
===
--- clang/docs/DataFlowAnalysisIntro.md
+++ clang/docs/DataFlowAnalysisIntro.md
@@ -287,7 +287,7 @@
 
 (Note that there are other ways to write this equation that produce higher
 precision analysis results. The trick is to keep exploring the execution paths
-separately and delay joining until later. Hoowever, we won't discuss those
+separately and delay joining until later. However, we won't discuss those
 variations here.)
 
 To make a conclusion about all paths through the program, we repeat this


Index: clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
@@ -107,11 +107,8 @@
   dyn_cast(Ex->IgnoreParenCasts());
 if (!BO)
   break;
-if (BO->getOpcode() == BO_Assign) {
-  Ex = BO->getRHS();
-  continue;
-}
-if (BO->getOpcode() == BO_Comma) {
+BinaryOperatorKind BO_AssignOrComma = BO->getOpcode();
+if (BO_AssignOrComma == BO_Assign || BO_AssignOrComma == BO_Comma) {
   Ex = BO->getRHS();
   continue;
 }
Index: clang/docs/DataFlowAnalysisIntro.md
===
--- clang/docs/DataFlowAnalysisIntro.md
+++ clang/docs/DataFlowAnalysisIntro.md
@@ -287,7 +287,7 @@
 
 (Note that there are other ways to write this equation that produce higher
 precision analysis results. The trick is to keep exploring the execution paths
-separately and delay joining until later. Hoowever, we won't discuss those
+separately and delay joining until later. However, we won't discuss those
 variations here.)
 
 To make a conclusion about all paths through the program, we repeat this
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121045: [analyzer][NFC] Merge similar conditional paths

2022-03-06 Thread Shivam Rajput via Phabricator via cfe-commits
phyBrackets added a comment.

Sorry but Idk why that DataFlowAnalysisIntro typo change also commited , I only 
add the deadstorechecker file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121045

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


[PATCH] D121045: [analyzer][NFC] Merge similar conditional paths

2022-03-07 Thread Shivam Rajput via Phabricator via cfe-commits
phyBrackets updated this revision to Diff 413402.
phyBrackets added a comment.

used the correct name for Opcodes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121045

Files:
  clang/docs/DataFlowAnalysisIntro.md
  clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp


Index: clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
@@ -107,11 +107,8 @@
   dyn_cast(Ex->IgnoreParenCasts());
 if (!BO)
   break;
-if (BO->getOpcode() == BO_Assign) {
-  Ex = BO->getRHS();
-  continue;
-}
-if (BO->getOpcode() == BO_Comma) {
+BinaryOperatorKind Op = BO->getOpcode();
+if (Op == BO_Assign || Op == BO_Comma) {
   Ex = BO->getRHS();
   continue;
 }
Index: clang/docs/DataFlowAnalysisIntro.md
===
--- clang/docs/DataFlowAnalysisIntro.md
+++ clang/docs/DataFlowAnalysisIntro.md
@@ -287,7 +287,7 @@
 
 (Note that there are other ways to write this equation that produce higher
 precision analysis results. The trick is to keep exploring the execution paths
-separately and delay joining until later. Hoowever, we won't discuss those
+separately and delay joining until later. However, we won't discuss those
 variations here.)
 
 To make a conclusion about all paths through the program, we repeat this


Index: clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
@@ -107,11 +107,8 @@
   dyn_cast(Ex->IgnoreParenCasts());
 if (!BO)
   break;
-if (BO->getOpcode() == BO_Assign) {
-  Ex = BO->getRHS();
-  continue;
-}
-if (BO->getOpcode() == BO_Comma) {
+BinaryOperatorKind Op = BO->getOpcode();
+if (Op == BO_Assign || Op == BO_Comma) {
   Ex = BO->getRHS();
   continue;
 }
Index: clang/docs/DataFlowAnalysisIntro.md
===
--- clang/docs/DataFlowAnalysisIntro.md
+++ clang/docs/DataFlowAnalysisIntro.md
@@ -287,7 +287,7 @@
 
 (Note that there are other ways to write this equation that produce higher
 precision analysis results. The trick is to keep exploring the execution paths
-separately and delay joining until later. Hoowever, we won't discuss those
+separately and delay joining until later. However, we won't discuss those
 variations here.)
 
 To make a conclusion about all paths through the program, we repeat this
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121045: [analyzer][NFC] Merge similar conditional paths

2022-03-07 Thread Shivam Rajput via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG90a6e3547863: [analyzer][NFC] Merge similar conditional 
paths (authored by phyBrackets).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121045

Files:
  clang/docs/DataFlowAnalysisIntro.md
  clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp


Index: clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
@@ -107,11 +107,8 @@
   dyn_cast(Ex->IgnoreParenCasts());
 if (!BO)
   break;
-if (BO->getOpcode() == BO_Assign) {
-  Ex = BO->getRHS();
-  continue;
-}
-if (BO->getOpcode() == BO_Comma) {
+BinaryOperatorKind Op = BO->getOpcode();
+if (Op == BO_Assign || Op == BO_Comma) {
   Ex = BO->getRHS();
   continue;
 }
Index: clang/docs/DataFlowAnalysisIntro.md
===
--- clang/docs/DataFlowAnalysisIntro.md
+++ clang/docs/DataFlowAnalysisIntro.md
@@ -287,7 +287,7 @@
 
 (Note that there are other ways to write this equation that produce higher
 precision analysis results. The trick is to keep exploring the execution paths
-separately and delay joining until later. Hoowever, we won't discuss those
+separately and delay joining until later. However, we won't discuss those
 variations here.)
 
 To make a conclusion about all paths through the program, we repeat this


Index: clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
@@ -107,11 +107,8 @@
   dyn_cast(Ex->IgnoreParenCasts());
 if (!BO)
   break;
-if (BO->getOpcode() == BO_Assign) {
-  Ex = BO->getRHS();
-  continue;
-}
-if (BO->getOpcode() == BO_Comma) {
+BinaryOperatorKind Op = BO->getOpcode();
+if (Op == BO_Assign || Op == BO_Comma) {
   Ex = BO->getRHS();
   continue;
 }
Index: clang/docs/DataFlowAnalysisIntro.md
===
--- clang/docs/DataFlowAnalysisIntro.md
+++ clang/docs/DataFlowAnalysisIntro.md
@@ -287,7 +287,7 @@
 
 (Note that there are other ways to write this equation that produce higher
 precision analysis results. The trick is to keep exploring the execution paths
-separately and delay joining until later. Hoowever, we won't discuss those
+separately and delay joining until later. However, we won't discuss those
 variations here.)
 
 To make a conclusion about all paths through the program, we repeat this
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121045: [analyzer][NFC] Merge similar conditional paths

2022-03-07 Thread Shivam Rajput via Phabricator via cfe-commits
phyBrackets added a comment.

Thanks @steakhal !


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121045

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


[PATCH] D117195: supdate

2022-01-13 Thread Shivam Rajput via Phabricator via cfe-commits
phyBrackets created this revision.
phyBrackets requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D117195

Files:
  clang/docs/AddressSanitizer.rst


Index: clang/docs/AddressSanitizer.rst
===
--- clang/docs/AddressSanitizer.rst
+++ clang/docs/AddressSanitizer.rst
@@ -44,9 +44,9 @@
 
 % cat example_UseAfterFree.cc
 int main(int argc, char **argv) {
-  int *array = new int[100];
-  delete [] array;
-  return array[argc];  // BOOM
+  int *array = new int[100] ;
+  delete [] array ;
+  return array[argc] ;  // BOOM
 }
 
 # Compile and link


Index: clang/docs/AddressSanitizer.rst
===
--- clang/docs/AddressSanitizer.rst
+++ clang/docs/AddressSanitizer.rst
@@ -44,9 +44,9 @@
 
 % cat example_UseAfterFree.cc
 int main(int argc, char **argv) {
-  int *array = new int[100];
-  delete [] array;
-  return array[argc];  // BOOM
+  int *array = new int[100] ;
+  delete [] array ;
+  return array[argc] ;  // BOOM
 }
 
 # Compile and link
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits