[clang] [Clang][InstrProf] Allow absolute path in fun.list of -fprofile-list= (PR #67519)

2023-11-08 Thread Shivam Gupta via cfe-commits

https://github.com/xgupta updated 
https://github.com/llvm/llvm-project/pull/67519

>From 400c889a4f0e867e3e2ceee43ae5c91f62f63c4d Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Thu, 19 Oct 2023 18:20:05 +0530
Subject: [PATCH 1/2] [Clang][InstrProf] Allow absolute path in fun.list of
 -fprofile-list=

---
 clang/lib/Basic/ProfileList.cpp | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/clang/lib/Basic/ProfileList.cpp b/clang/lib/Basic/ProfileList.cpp
index 8fa16e2eb069a52..1853a3e34ec35ed 100644
--- a/clang/lib/Basic/ProfileList.cpp
+++ b/clang/lib/Basic/ProfileList.cpp
@@ -139,12 +139,22 @@ std::optional
 ProfileList::isFileExcluded(StringRef FileName,
 CodeGenOptions::ProfileInstrKind Kind) const {
   StringRef Section = getSectionName(Kind);
+  // Convert the input file path to its canonical (absolute) form
+  llvm::SmallString<128> CanonicalFileName(FileName);
+  llvm::sys::fs::make_absolute(CanonicalFileName);
+
   // Check for "source:="
   if (auto V = inSection(Section, "source", FileName))
 return V;
+  if (auto V = inSection(Section, "source", CanonicalFileName))
+return V;
   if (SCL->inSection(Section, "!src", FileName))
 return Forbid;
+  if (SCL->inSection(Section, "!src", CanonicalFileName))
+return Forbid;
   if (SCL->inSection(Section, "src", FileName))
 return Allow;
+  if (SCL->inSection(Section, "src", CanonicalFileName))
+return Allow;
   return std::nullopt;
 }

>From 42416cdec2e9675fc3d2dfafffcd3b7cf858cc4f Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Thu, 9 Nov 2023 11:27:40 +0530
Subject: [PATCH 2/2] add testing

---
 clang/lib/Basic/ProfileList.cpp | 15 +++
 clang/test/CodeGen/profile-filter.c |  3 ++-
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/clang/lib/Basic/ProfileList.cpp b/clang/lib/Basic/ProfileList.cpp
index 1853a3e34ec35ed..3dc01096a69e2ef 100644
--- a/clang/lib/Basic/ProfileList.cpp
+++ b/clang/lib/Basic/ProfileList.cpp
@@ -139,21 +139,20 @@ std::optional
 ProfileList::isFileExcluded(StringRef FileName,
 CodeGenOptions::ProfileInstrKind Kind) const {
   StringRef Section = getSectionName(Kind);
-  // Convert the input file path to its canonical (absolute) form
-  llvm::SmallString<128> CanonicalFileName(FileName);
-  llvm::sys::fs::make_absolute(CanonicalFileName);
-
   // Check for "source:="
   if (auto V = inSection(Section, "source", FileName))
 return V;
-  if (auto V = inSection(Section, "source", CanonicalFileName))
-return V;
   if (SCL->inSection(Section, "!src", FileName))
 return Forbid;
-  if (SCL->inSection(Section, "!src", CanonicalFileName))
-return Forbid;
   if (SCL->inSection(Section, "src", FileName))
 return Allow;
+  // Convert the input file path to its canonical (absolute) form
+  llvm::SmallString<128> CanonicalFileName(FileName);
+  llvm::sys::fs::make_absolute(CanonicalFileName);
+  if (auto V = inSection(Section, "source", CanonicalFileName))
+return V;
+  if (SCL->inSection(Section, "!src", CanonicalFileName))
+return Forbid;
   if (SCL->inSection(Section, "src", CanonicalFileName))
 return Allow;
   return std::nullopt;
diff --git a/clang/test/CodeGen/profile-filter.c 
b/clang/test/CodeGen/profile-filter.c
index e33e4a0a60b3d4f..2db9d5059e4ccea 100644
--- a/clang/test/CodeGen/profile-filter.c
+++ b/clang/test/CodeGen/profile-filter.c
@@ -4,7 +4,8 @@
 // RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping 
-dump-coverage-mapping -fprofile-list=%t-func.list -emit-llvm %s -o - | 
FileCheck %s --check-prefix=FUNC
 
 // RUN: echo "src:%s" | sed -e 's/\\//g' > %t-file.list
-// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping 
-dump-coverage-mapping -fprofile-list=%t-file.list -emit-llvm %s -o - | 
FileCheck %s --check-prefix=FILE
+// RUN: cd %S
+// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping 
-dump-coverage-mapping -fprofile-list=%t-file.list -emit-llvm profile-filter.c 
-o - | FileCheck %s --check-prefix=FILE
 
 // RUN: echo -e "[clang]\nfun:test1\n[llvm]\nfun:test2" > %t-section.list
 // RUN: %clang_cc1 -fprofile-instrument=llvm -fprofile-list=%t-section.list 
-emit-llvm %s -o - | FileCheck %s --check-prefix=SECTION

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


[clang] [Clang][InstrProf] Allow absolute path in fun.list of -fprofile-list= (PR #67519)

2023-11-08 Thread Shivam Gupta via cfe-commits

https://github.com/xgupta updated 
https://github.com/llvm/llvm-project/pull/67519

>From 8fdc14ad3a3060407800fe2c570a3631d2a6e1cc Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Thu, 19 Oct 2023 18:20:05 +0530
Subject: [PATCH 1/2] [Clang][InstrProf] Allow absolute path in fun.list of
 -fprofile-list=

---
 clang/lib/Basic/ProfileList.cpp | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/clang/lib/Basic/ProfileList.cpp b/clang/lib/Basic/ProfileList.cpp
index 8fa16e2eb069a52..1853a3e34ec35ed 100644
--- a/clang/lib/Basic/ProfileList.cpp
+++ b/clang/lib/Basic/ProfileList.cpp
@@ -139,12 +139,22 @@ std::optional
 ProfileList::isFileExcluded(StringRef FileName,
 CodeGenOptions::ProfileInstrKind Kind) const {
   StringRef Section = getSectionName(Kind);
+  // Convert the input file path to its canonical (absolute) form
+  llvm::SmallString<128> CanonicalFileName(FileName);
+  llvm::sys::fs::make_absolute(CanonicalFileName);
+
   // Check for "source:="
   if (auto V = inSection(Section, "source", FileName))
 return V;
+  if (auto V = inSection(Section, "source", CanonicalFileName))
+return V;
   if (SCL->inSection(Section, "!src", FileName))
 return Forbid;
+  if (SCL->inSection(Section, "!src", CanonicalFileName))
+return Forbid;
   if (SCL->inSection(Section, "src", FileName))
 return Allow;
+  if (SCL->inSection(Section, "src", CanonicalFileName))
+return Allow;
   return std::nullopt;
 }

>From 0300a2f7b0359497cc57f14c9dca802c78249b6d Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Thu, 9 Nov 2023 11:27:40 +0530
Subject: [PATCH 2/2] add testing

---
 clang/lib/Basic/ProfileList.cpp | 15 +++
 clang/test/CodeGen/profile-filter.c |  3 ++-
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/clang/lib/Basic/ProfileList.cpp b/clang/lib/Basic/ProfileList.cpp
index 1853a3e34ec35ed..3dc01096a69e2ef 100644
--- a/clang/lib/Basic/ProfileList.cpp
+++ b/clang/lib/Basic/ProfileList.cpp
@@ -139,21 +139,20 @@ std::optional
 ProfileList::isFileExcluded(StringRef FileName,
 CodeGenOptions::ProfileInstrKind Kind) const {
   StringRef Section = getSectionName(Kind);
-  // Convert the input file path to its canonical (absolute) form
-  llvm::SmallString<128> CanonicalFileName(FileName);
-  llvm::sys::fs::make_absolute(CanonicalFileName);
-
   // Check for "source:="
   if (auto V = inSection(Section, "source", FileName))
 return V;
-  if (auto V = inSection(Section, "source", CanonicalFileName))
-return V;
   if (SCL->inSection(Section, "!src", FileName))
 return Forbid;
-  if (SCL->inSection(Section, "!src", CanonicalFileName))
-return Forbid;
   if (SCL->inSection(Section, "src", FileName))
 return Allow;
+  // Convert the input file path to its canonical (absolute) form
+  llvm::SmallString<128> CanonicalFileName(FileName);
+  llvm::sys::fs::make_absolute(CanonicalFileName);
+  if (auto V = inSection(Section, "source", CanonicalFileName))
+return V;
+  if (SCL->inSection(Section, "!src", CanonicalFileName))
+return Forbid;
   if (SCL->inSection(Section, "src", CanonicalFileName))
 return Allow;
   return std::nullopt;
diff --git a/clang/test/CodeGen/profile-filter.c 
b/clang/test/CodeGen/profile-filter.c
index e33e4a0a60b3d4f..2db9d5059e4ccea 100644
--- a/clang/test/CodeGen/profile-filter.c
+++ b/clang/test/CodeGen/profile-filter.c
@@ -4,7 +4,8 @@
 // RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping 
-dump-coverage-mapping -fprofile-list=%t-func.list -emit-llvm %s -o - | 
FileCheck %s --check-prefix=FUNC
 
 // RUN: echo "src:%s" | sed -e 's/\\//g' > %t-file.list
-// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping 
-dump-coverage-mapping -fprofile-list=%t-file.list -emit-llvm %s -o - | 
FileCheck %s --check-prefix=FILE
+// RUN: cd %S
+// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping 
-dump-coverage-mapping -fprofile-list=%t-file.list -emit-llvm profile-filter.c 
-o - | FileCheck %s --check-prefix=FILE
 
 // RUN: echo -e "[clang]\nfun:test1\n[llvm]\nfun:test2" > %t-section.list
 // RUN: %clang_cc1 -fprofile-instrument=llvm -fprofile-list=%t-section.list 
-emit-llvm %s -o - | FileCheck %s --check-prefix=SECTION

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


[clang] [Clang][InstrProf] Allow absolute path in fun.list of -fprofile-list= (PR #67519)

2023-11-08 Thread Shivam Gupta via cfe-commits


@@ -139,9 +139,23 @@ std::optional
 ProfileList::isFileExcluded(StringRef FileName,
 CodeGenOptions::ProfileInstrKind Kind) const {
   StringRef Section = getSectionName(Kind);
-  // Check for "source:="
+
+  // Convert the input file path to its canonical (absolute) form
+  llvm::SmallString<128> CanonicalFileName(FileName);
+  llvm::sys::fs::make_absolute(CanonicalFileName);

xgupta wrote:

I updated the position of that piece of code. 
I could not think properly the test case, added one version which was failing 
previously but passing now with the changes in the source file.
I think the issue with the previous version that that was not working when we 
were mixing the relative and completed paths in q single command line 
invocation. 

https://github.com/llvm/llvm-project/pull/67519
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][InstrProf] Allow mix-up of absolute path with relative path on command line when using -fprofile-list= (PR #67519)

2023-11-08 Thread Shivam Gupta via cfe-commits

https://github.com/xgupta edited https://github.com/llvm/llvm-project/pull/67519
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][InstrProf] Allow mix-up of absolute path with relative path on command line when using -fprofile-list= (PR #67519)

2023-11-08 Thread Shivam Gupta via cfe-commits

https://github.com/xgupta edited https://github.com/llvm/llvm-project/pull/67519
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][InstrProf] Allow mix-up of absolute path with relative path on command line when using -fprofile-list= (PR #67519)

2023-11-08 Thread Shivam Gupta via cfe-commits

https://github.com/xgupta edited https://github.com/llvm/llvm-project/pull/67519
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][InstrProf] Allow mix-up of absolute path with relative path on command line when using -fprofile-list= (PR #67519)

2023-11-08 Thread Shivam Gupta via cfe-commits

https://github.com/xgupta edited https://github.com/llvm/llvm-project/pull/67519
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Skip tautological comparison if the comparison involves the 'size_t' type (PR #74427)

2023-12-04 Thread Shivam Gupta via cfe-commits

https://github.com/xgupta created 
https://github.com/llvm/llvm-project/pull/74427

The issue with size_t comes when we are trying to add -Wtype-limits to -Wextra 
for GCC compatibility in review https://reviews.llvm.org/D142826.

Example of issue (false positive) -

$ cat clang/test/Sema/type-limit-compare.cpp
// RUN: %clang_cc1 %s -fsyntax-only -Wtautological-type-limit-compare -verify

namespace std {
using size_t = decltype(sizeof(0));
} // namespace std

bool func(uint64_t Size) {
  if (sizeof(std::size_t) < sizeof(uint64_t) &&
 Size > (uint64_t)(__SIZE_MAX__))
return false;
  return true;
}

$ clang -c -Wtautological-type-limit-compare 
clang/test/Sema/type-limit-compare.cpp 
clang/test/Sema/type-limit-compare.cpp:16:11: warning: result of comparison 
'uint64_t' (aka 'unsigned long') > 18446744073709551615 is always false 
[-Wtautological-type-limit-compare]
   16 |  Size > (uint64_t)(__SIZE_MAX__))
  |   ^ 
1 warning generated.
 

>From 3d718dd24df0ec185815244dd933c49ad432ec59 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Tue, 5 Dec 2023 13:06:57 +0530
Subject: [PATCH] [clang] Skip tautological comparison if the comparison
 involves the 'size_t' type

The issue with size_t comes when we are trying to addd
-Wtype-limits to -Wextra for GCC compatibility in review
https://reviews.llvm.org/D142826.
---
 clang/lib/Sema/SemaChecking.cpp| 19 +++
 clang/test/Sema/type-limit-compare.cpp | 20 
 2 files changed, 39 insertions(+)
 create mode 100644 clang/test/Sema/type-limit-compare.cpp

diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 07ced5ffc3407..51a26f41f3d69 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -14577,6 +14577,25 @@ static bool CheckTautologicalComparison(Sema &S, 
BinaryOperator *E,
   if (InRange && IsEnumConstOrFromMacro(S, Constant))
 return false;
 
+  // Don't warn if the comparison involves integral or floating-point types 
with
+  // the same canonical types.
+  QualType LHSCanonical = Constant->getType().getCanonicalType();
+  QualType RHSCanonical = Other->getType().getCanonicalType();
+  if (TautologicalTypeCompare &&
+  (LHSCanonical->isIntegralOrEnumerationType() ||
+   LHSCanonical->isFloatingType()) &&
+  S.Context.hasSameType(LHSCanonical, RHSCanonical) &&
+  !S.Context.hasSameType(Constant->getType(), Other->getType())) {
+return false;
+  }
+
+  // Don't warn if the comparison involves the 'size_t' type.
+  QualType SizeT = S.Context.getSizeType();
+  if (S.Context.hasSameType(Constant->getType().getCanonicalType(), SizeT) &&
+  S.Context.hasSameType(Other->getType().getCanonicalType(), SizeT)) {
+return false;
+  }
+
   // A comparison of an unsigned bit-field against 0 is really a type problem,
   // even though at the type level the bit-field might promote to 'signed int'.
   if (Other->refersToBitField() && InRange && Value == 0 &&
diff --git a/clang/test/Sema/type-limit-compare.cpp 
b/clang/test/Sema/type-limit-compare.cpp
new file mode 100644
index 0..f585356541668
--- /dev/null
+++ b/clang/test/Sema/type-limit-compare.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 %s -fsyntax-only -Wtautological-type-limit-compare -verify
+
+// expected-no-diagnostics
+#if defined(_WIN32)
+typedef unsigned long long uint64_t;
+#else
+typedef unsigned long uint64_t;
+#endif
+
+namespace std {
+using size_t = decltype(sizeof(0));
+} // namespace std
+
+bool func(uint64_t Size) {
+  if (sizeof(std::size_t) < sizeof(uint64_t) &&
+ Size > (uint64_t)(__SIZE_MAX__))
+return false;
+  return true;
+}
+

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


[clang] [clang] Fix clang++ crash on assertions when compiling source (PR #70594)

2023-12-06 Thread Shivam Gupta via cfe-commits

xgupta wrote:

> @cor3ntin Could you describe the format of the `release note` briefly so I 
> can `amend` my `commit` accordingly?
Like this - 
https://github.com/llvm/llvm-project/pull/74553/files#diff-ec770381d76c859f5f572db789175fe44410a72608f58ad5dbb14335ba56eb97

You also need to clang-format this patch with git clang-format HEAD~1.

https://github.com/llvm/llvm-project/pull/70594
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][InstrProf] Allow mix-up of absolute path with relative path on command line when using -fprofile-list= (PR #67519)

2023-11-18 Thread Shivam Gupta via cfe-commits

https://github.com/xgupta updated 
https://github.com/llvm/llvm-project/pull/67519

>From a7f4b08b54350ebbe4b115214a84669eb69aee3e Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Thu, 19 Oct 2023 18:20:05 +0530
Subject: [PATCH] [Clang][InstrProf] Allow absolute path in fun.list of
 -fprofile-list=

---
 clang/lib/Basic/ProfileList.cpp | 9 +
 clang/test/CodeGen/profile-filter.c | 3 +++
 2 files changed, 12 insertions(+)

diff --git a/clang/lib/Basic/ProfileList.cpp b/clang/lib/Basic/ProfileList.cpp
index 8fa16e2eb069a52..3dc01096a69e2ef 100644
--- a/clang/lib/Basic/ProfileList.cpp
+++ b/clang/lib/Basic/ProfileList.cpp
@@ -146,5 +146,14 @@ ProfileList::isFileExcluded(StringRef FileName,
 return Forbid;
   if (SCL->inSection(Section, "src", FileName))
 return Allow;
+  // Convert the input file path to its canonical (absolute) form
+  llvm::SmallString<128> CanonicalFileName(FileName);
+  llvm::sys::fs::make_absolute(CanonicalFileName);
+  if (auto V = inSection(Section, "source", CanonicalFileName))
+return V;
+  if (SCL->inSection(Section, "!src", CanonicalFileName))
+return Forbid;
+  if (SCL->inSection(Section, "src", CanonicalFileName))
+return Allow;
   return std::nullopt;
 }
diff --git a/clang/test/CodeGen/profile-filter.c 
b/clang/test/CodeGen/profile-filter.c
index e33e4a0a60b3d4f..86ee79c04747101 100644
--- a/clang/test/CodeGen/profile-filter.c
+++ b/clang/test/CodeGen/profile-filter.c
@@ -6,6 +6,9 @@
 // RUN: echo "src:%s" | sed -e 's/\\//g' > %t-file.list
 // RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping 
-dump-coverage-mapping -fprofile-list=%t-file.list -emit-llvm %s -o - | 
FileCheck %s --check-prefix=FILE
 
+// RUN: cd %S
+// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping 
-dump-coverage-mapping -fprofile-list=%t-file.list -emit-llvm profile-filter.c 
-o - | FileCheck %s --check-prefix=FILE
+
 // RUN: echo -e "[clang]\nfun:test1\n[llvm]\nfun:test2" > %t-section.list
 // RUN: %clang_cc1 -fprofile-instrument=llvm -fprofile-list=%t-section.list 
-emit-llvm %s -o - | FileCheck %s --check-prefix=SECTION
 

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


[clang] [Clang][InstrProf] Allow mix-up of absolute path with relative path on command line when using -fprofile-list= (PR #67519)

2023-11-18 Thread Shivam Gupta via cfe-commits


@@ -4,7 +4,8 @@
 // RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping 
-dump-coverage-mapping -fprofile-list=%t-func.list -emit-llvm %s -o - | 
FileCheck %s --check-prefix=FUNC
 
 // RUN: echo "src:%s" | sed -e 's/\\//g' > %t-file.list
-// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping 
-dump-coverage-mapping -fprofile-list=%t-file.list -emit-llvm %s -o - | 
FileCheck %s --check-prefix=FILE
+// RUN: cd %S
+// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping 
-dump-coverage-mapping -fprofile-list=%t-file.list -emit-llvm profile-filter.c 
-o - | FileCheck %s --check-prefix=FILE

xgupta wrote:

Yes, I misunderstood the concept wrt ninja build and fun.list. Only 
modification is required in fun.list to supply full path, not required to 
update ProfileList.cpp

 Apologies for taking so much time to realize this simple concept. 

https://github.com/llvm/llvm-project/pull/67519
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][InstrProf] Allow mix-up of absolute path with relative path on command line when using -fprofile-list= (PR #67519)

2023-11-18 Thread Shivam Gupta via cfe-commits


@@ -4,7 +4,8 @@
 // RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping 
-dump-coverage-mapping -fprofile-list=%t-func.list -emit-llvm %s -o - | 
FileCheck %s --check-prefix=FUNC
 
 // RUN: echo "src:%s" | sed -e 's/\\//g' > %t-file.list
-// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping 
-dump-coverage-mapping -fprofile-list=%t-file.list -emit-llvm %s -o - | 
FileCheck %s --check-prefix=FILE
+// RUN: cd %S
+// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping 
-dump-coverage-mapping -fprofile-list=%t-file.list -emit-llvm profile-filter.c 
-o - | FileCheck %s --check-prefix=FILE

xgupta wrote:

Shall I close this PR or it continue in case it will be useful for someone else?

https://github.com/llvm/llvm-project/pull/67519
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][InstrProf] Allow mix-up of absolute path with relative path on command line when using -fprofile-list= (PR #67519)

2023-11-18 Thread Shivam Gupta via cfe-commits

https://github.com/xgupta edited https://github.com/llvm/llvm-project/pull/67519
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][InstrProf] Allow mix-up of absolute path with relative path on command line when using -fprofile-list= (PR #67519)

2023-11-18 Thread Shivam Gupta via cfe-commits

https://github.com/xgupta edited https://github.com/llvm/llvm-project/pull/67519
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][Sema] Add -Wswitch-default warning option (PR #73077)

2023-11-21 Thread Shivam Gupta via cfe-commits

xgupta wrote:

There is one clang-tidy check (bugprone-switch-missing-default-case) also for 
this feature.

https://github.com/llvm/llvm-project/pull/73077
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Add missing LinkageSpec case to getCursorKindForDecl (PR #72401)

2023-11-22 Thread Shivam Gupta via cfe-commits

xgupta wrote:

Does this fix https://github.com/llvm/llvm-project/issues/56687?

https://github.com/llvm/llvm-project/pull/72401
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][InstrProf] Allow mix-up of absolute path with relative path on command line when using -fprofile-list= (PR #67519)

2023-12-11 Thread Shivam Gupta via cfe-commits

xgupta wrote:

@ellishg, @gulfemsavrun  shall we close this PR, or it is of any use? For me, 
it is not much now since it was my mistake to understand the use of 
-fprofile-list.

https://github.com/llvm/llvm-project/pull/67519
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Skip tautological comparison if the comparison involves the 'size_t' type (PR #74427)

2023-12-11 Thread Shivam Gupta via cfe-commits

xgupta wrote:

Ping @cor3ntin, do you have any more comments for this PR?

https://github.com/llvm/llvm-project/pull/74427
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [polly] [clang] [polly][ScheduleOptimizer] Fix long compile time(hang) reported in polly (PR #75141)

2023-12-12 Thread Shivam Gupta via cfe-commits


@@ -0,0 +1,97 @@
+; RUN: opt -S -polly-optree -polly-delicm  -polly-opt-isl 
-polly-schedule-computeout=10 -debug-only="polly-opt-isl" < %s 2>&1 | 
FileCheck %s
+; Bailout if the computations of schedule compute exceeds the max scheduling 
quota.
+; Max compute out is initialized to 30, Here it is set to 10 for test 
purpose.
+
+target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
+target triple = "aarch64-unknown-linux-gnu"

xgupta wrote:

Target triple information is not required here since the transformation is 
target-independent.

https://github.com/llvm/llvm-project/pull/75141
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Add missing LinkageSpec case to getCursorKindForDecl (PR #72401)

2023-11-23 Thread Shivam Gupta via cfe-commits

https://github.com/xgupta approved this pull request.

It looks good to me, maybe we need a release note change as a formal practice.

https://github.com/llvm/llvm-project/pull/72401
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Add missing LinkageSpec case to getCursorKindForDecl (PR #72401)

2023-11-24 Thread Shivam Gupta via cfe-commits

https://github.com/xgupta closed https://github.com/llvm/llvm-project/pull/72401
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Add missing LinkageSpec case to getCursorKindForDecl (PR #72401)

2023-11-24 Thread Shivam Gupta via cfe-commits

xgupta wrote:

> By the way, I don't have permission to merge, so feel free to do it when you 
> think it's ready.

Thanks for the contribution.


https://github.com/llvm/llvm-project/pull/72401
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][Sema] placement new initializes typedef array with correct size (PR #83124)

2024-02-27 Thread Shivam Gupta via cfe-commits

https://github.com/xgupta edited https://github.com/llvm/llvm-project/pull/83124
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [RecursiveASTVisitor] Fix RecursiveASTVisitor (RAV) fails to visit the initializer of a bitfield (PR #69557)

2023-10-18 Thread Shivam Gupta via cfe-commits

https://github.com/xgupta created 
https://github.com/llvm/llvm-project/pull/69557

This fixes https://github.com/llvm/llvm-project/issues/64916.

Patch by Scott McPeak

>From 96f6b90ed4a70430f94eab2d9ca317dd8367022a Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Thu, 19 Oct 2023 09:06:43 +0530
Subject: [PATCH] [RecursiveASTVisitor] Fix RecursiveASTVisitor (RAV) fails to
 visit the initializer of a bitfield

Patch by Scott McPeak
---
 clang/include/clang/AST/RecursiveASTVisitor.h |  2 +-
 clang/unittests/Tooling/CMakeLists.txt|  1 +
 .../BitfieldInitializer.cpp   | 34 +++
 3 files changed, 36 insertions(+), 1 deletion(-)
 create mode 100644 
clang/unittests/Tooling/RecursiveASTVisitorTests/BitfieldInitializer.cpp

diff --git a/clang/include/clang/AST/RecursiveASTVisitor.h 
b/clang/include/clang/AST/RecursiveASTVisitor.h
index 3dd23eb38eeabfc..53bc15e1b19f668 100644
--- a/clang/include/clang/AST/RecursiveASTVisitor.h
+++ b/clang/include/clang/AST/RecursiveASTVisitor.h
@@ -2103,7 +2103,7 @@ DEF_TRAVERSE_DECL(FieldDecl, {
   TRY_TO(TraverseDeclaratorHelper(D));
   if (D->isBitField())
 TRY_TO(TraverseStmt(D->getBitWidth()));
-  else if (D->hasInClassInitializer())
+  if (D->hasInClassInitializer())
 TRY_TO(TraverseStmt(D->getInClassInitializer()));
 })
 
diff --git a/clang/unittests/Tooling/CMakeLists.txt 
b/clang/unittests/Tooling/CMakeLists.txt
index 2fbe78e3fab7528..5a10a6b285390e9 100644
--- a/clang/unittests/Tooling/CMakeLists.txt
+++ b/clang/unittests/Tooling/CMakeLists.txt
@@ -25,6 +25,7 @@ add_clang_unittest(ToolingTests
   QualTypeNamesTest.cpp
   RangeSelectorTest.cpp
   RecursiveASTVisitorTests/Attr.cpp
+  RecursiveASTVisitorTests/BitfieldInitializer.cpp
   RecursiveASTVisitorTests/CallbacksLeaf.cpp
   RecursiveASTVisitorTests/CallbacksUnaryOperator.cpp
   RecursiveASTVisitorTests/CallbacksBinaryOperator.cpp
diff --git 
a/clang/unittests/Tooling/RecursiveASTVisitorTests/BitfieldInitializer.cpp 
b/clang/unittests/Tooling/RecursiveASTVisitorTests/BitfieldInitializer.cpp
new file mode 100644
index 000..676a491a43040ea
--- /dev/null
+++ b/clang/unittests/Tooling/RecursiveASTVisitorTests/BitfieldInitializer.cpp
@@ -0,0 +1,34 @@
+//===- unittest/Tooling/RecursiveASTVisitorTests/BitfieldInitializer.cpp -===//
+//
+// 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
+//
+//===--===//
+
+#include "TestVisitor.h"
+#include 
+
+using namespace clang;
+
+namespace {
+
+// Check to ensure that bitfield initializers are visited.
+class BitfieldInitializerVisitor : public 
ExpectedLocationVisitor {
+public:
+  bool VisitIntegerLiteral(IntegerLiteral *IL) {
+Match(std::to_string(IL->getValue().getSExtValue()), IL->getLocation());
+return true;
+  }
+};
+
+TEST(RecursiveASTVisitor, BitfieldInitializerIsVisited) {
+  BitfieldInitializerVisitor Visitor;
+  Visitor.ExpectMatch("123", 2, 15); 
+  EXPECT_TRUE(Visitor.runOver(
+"struct S {\n"
+"  int x : 8 = 123;\n"
+"};\n"));
+}
+
+} // end anonymous namespace

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


[clang] [RecursiveASTVisitor] Fix RecursiveASTVisitor (RAV) fails to visit the initializer of a bitfield (PR #69557)

2023-10-18 Thread Shivam Gupta via cfe-commits

https://github.com/xgupta edited https://github.com/llvm/llvm-project/pull/69557
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [RecursiveASTVisitor] Fix RecursiveASTVisitor (RAV) fails to visit the initializer of a bitfield (PR #69557)

2023-10-18 Thread Shivam Gupta via cfe-commits

https://github.com/xgupta updated 
https://github.com/llvm/llvm-project/pull/69557

>From 96f6b90ed4a70430f94eab2d9ca317dd8367022a Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Thu, 19 Oct 2023 09:06:43 +0530
Subject: [PATCH 1/2] [RecursiveASTVisitor] Fix RecursiveASTVisitor (RAV) fails
 to visit the initializer of a bitfield

Patch by Scott McPeak
---
 clang/include/clang/AST/RecursiveASTVisitor.h |  2 +-
 clang/unittests/Tooling/CMakeLists.txt|  1 +
 .../BitfieldInitializer.cpp   | 34 +++
 3 files changed, 36 insertions(+), 1 deletion(-)
 create mode 100644 
clang/unittests/Tooling/RecursiveASTVisitorTests/BitfieldInitializer.cpp

diff --git a/clang/include/clang/AST/RecursiveASTVisitor.h 
b/clang/include/clang/AST/RecursiveASTVisitor.h
index 3dd23eb38eeabfc..53bc15e1b19f668 100644
--- a/clang/include/clang/AST/RecursiveASTVisitor.h
+++ b/clang/include/clang/AST/RecursiveASTVisitor.h
@@ -2103,7 +2103,7 @@ DEF_TRAVERSE_DECL(FieldDecl, {
   TRY_TO(TraverseDeclaratorHelper(D));
   if (D->isBitField())
 TRY_TO(TraverseStmt(D->getBitWidth()));
-  else if (D->hasInClassInitializer())
+  if (D->hasInClassInitializer())
 TRY_TO(TraverseStmt(D->getInClassInitializer()));
 })
 
diff --git a/clang/unittests/Tooling/CMakeLists.txt 
b/clang/unittests/Tooling/CMakeLists.txt
index 2fbe78e3fab7528..5a10a6b285390e9 100644
--- a/clang/unittests/Tooling/CMakeLists.txt
+++ b/clang/unittests/Tooling/CMakeLists.txt
@@ -25,6 +25,7 @@ add_clang_unittest(ToolingTests
   QualTypeNamesTest.cpp
   RangeSelectorTest.cpp
   RecursiveASTVisitorTests/Attr.cpp
+  RecursiveASTVisitorTests/BitfieldInitializer.cpp
   RecursiveASTVisitorTests/CallbacksLeaf.cpp
   RecursiveASTVisitorTests/CallbacksUnaryOperator.cpp
   RecursiveASTVisitorTests/CallbacksBinaryOperator.cpp
diff --git 
a/clang/unittests/Tooling/RecursiveASTVisitorTests/BitfieldInitializer.cpp 
b/clang/unittests/Tooling/RecursiveASTVisitorTests/BitfieldInitializer.cpp
new file mode 100644
index 000..676a491a43040ea
--- /dev/null
+++ b/clang/unittests/Tooling/RecursiveASTVisitorTests/BitfieldInitializer.cpp
@@ -0,0 +1,34 @@
+//===- unittest/Tooling/RecursiveASTVisitorTests/BitfieldInitializer.cpp -===//
+//
+// 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
+//
+//===--===//
+
+#include "TestVisitor.h"
+#include 
+
+using namespace clang;
+
+namespace {
+
+// Check to ensure that bitfield initializers are visited.
+class BitfieldInitializerVisitor : public 
ExpectedLocationVisitor {
+public:
+  bool VisitIntegerLiteral(IntegerLiteral *IL) {
+Match(std::to_string(IL->getValue().getSExtValue()), IL->getLocation());
+return true;
+  }
+};
+
+TEST(RecursiveASTVisitor, BitfieldInitializerIsVisited) {
+  BitfieldInitializerVisitor Visitor;
+  Visitor.ExpectMatch("123", 2, 15); 
+  EXPECT_TRUE(Visitor.runOver(
+"struct S {\n"
+"  int x : 8 = 123;\n"
+"};\n"));
+}
+
+} // end anonymous namespace

>From 76c581fe567f66fbe30bd083c245217fda2d023a Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Thu, 19 Oct 2023 09:24:38 +0530
Subject: [PATCH 2/2] clang-format

---
 .../RecursiveASTVisitorTests/BitfieldInitializer.cpp | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git 
a/clang/unittests/Tooling/RecursiveASTVisitorTests/BitfieldInitializer.cpp 
b/clang/unittests/Tooling/RecursiveASTVisitorTests/BitfieldInitializer.cpp
index 676a491a43040ea..c11e726fe855284 100644
--- a/clang/unittests/Tooling/RecursiveASTVisitorTests/BitfieldInitializer.cpp
+++ b/clang/unittests/Tooling/RecursiveASTVisitorTests/BitfieldInitializer.cpp
@@ -14,7 +14,8 @@ using namespace clang;
 namespace {
 
 // Check to ensure that bitfield initializers are visited.
-class BitfieldInitializerVisitor : public 
ExpectedLocationVisitor {
+class BitfieldInitializerVisitor
+: public ExpectedLocationVisitor {
 public:
   bool VisitIntegerLiteral(IntegerLiteral *IL) {
 Match(std::to_string(IL->getValue().getSExtValue()), IL->getLocation());
@@ -24,11 +25,10 @@ class BitfieldInitializerVisitor : public 
ExpectedLocationVisitorhttps://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Docs][LTO] Updated HowToSubmitABug.rst for LTO crashes (PR #68389)

2023-10-19 Thread Shivam Gupta via cfe-commits

https://github.com/xgupta updated 
https://github.com/llvm/llvm-project/pull/68389

>From bdf991f4563e3aa840bec35b1678ad4fe8f9fbb6 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Fri, 6 Oct 2023 12:32:24 +0530
Subject: [PATCH 1/2] [Docs][LTO] Update HowToSubmitABug.rst for LTO crashes

---
 llvm/docs/HowToSubmitABug.rst | 51 +++
 1 file changed, 51 insertions(+)

diff --git a/llvm/docs/HowToSubmitABug.rst b/llvm/docs/HowToSubmitABug.rst
index 733dae6c928d098..88f9af44add7c64 100644
--- a/llvm/docs/HowToSubmitABug.rst
+++ b/llvm/docs/HowToSubmitABug.rst
@@ -153,6 +153,57 @@ Please run this, then file a bug with the instructions and 
reduced .bc file
 that bugpoint emits.  If something goes wrong with bugpoint, please submit
 the "foo.bc" file and the option that llc crashes with.
 
+​.. _lto-crash:
+
+LTO bugs
+---
+
+If you find a bug that crashes llvm in LTO phase (by using -flto option),
+compile your source file to a .bc file by passing
+"``-flto -fuse-ld=lld -Wl,-plugin-opt=save-temps``"
+to clang (in addition to the options you already pass). If you are building
+a project, pass the appropriate CFLAGS, CXXFLAG​S and LDFLAGS for example -
+
+.. code-block:: bash
+
+   export CFLAGS="-flto -fuse-ld=lld" CXXFLAGS="-flto -fuse-ld=lld" 
LDFLAGS="-Wl,-plugin-opt=save-temps"
+
+This will generate four intermediate bytecode files:
+
+1. a.out.0.0.preopt.bc  (Before any link-time optimizations (LTO) are 
applied)
+2. a.out.0.2.internalize.bc (After initial optimizations applied)
+3. a.out.0.4.opt.bc (After the more extensive set of optimizations has 
been applied)
+4. a.out.0.5.precodegen.bc  (After LTO but before it's translated into machine 
code)
+
+Once you have these, one of the following commands should fail:
+
+#. ``opt "-passes=lto" a.out.0.0.preopt.bc``
+#. ``opt "-passes=lto" a.out.0.2.internalize.bc``
+#. ``opt "-passes=lto" a.out.0.4.opt.bc``
+#. ``llc a.out.0.5.precodegen.bc``
+
+If one of these do crash, you should be able to reduce
+this with :program:`llvm-reduce`
+command line (use the bc file corresponding to the command above that failed):
+
+#. ``llvm-reduce --test llvm-reduce.sh a.out.0.2.internalize.bc``
+
+An example of ``llvm-reduce.sh`` script
+
+.. code-block:: bash
+
+   $ cat llvm-reduce.sh
+   #!/usr/bin/env bash
+
+   $HOME/llvm/llvm-project/build/bin/opt "-passes=lto" $1 -o temp.bc  2>&1 
| tee err.log
+   grep "It->second == &Insn" err.log
+   exit $?
+
+Here we have grepped the failed assert message.
+
+Please run this, then file a bug with the instructions and reduced .bc file
+that llvm-reduce emits.
+
 .. _miscompiling:
 
 Miscompilations

>From 1823285171ddbefc49065c4995e9c33bee7b952a Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Thu, 19 Oct 2023 10:57:25 +0530
Subject: [PATCH 2/2] address review comment

---
 llvm/docs/HowToSubmitABug.rst | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/llvm/docs/HowToSubmitABug.rst b/llvm/docs/HowToSubmitABug.rst
index 88f9af44add7c64..197ed3e0fde6893 100644
--- a/llvm/docs/HowToSubmitABug.rst
+++ b/llvm/docs/HowToSubmitABug.rst
@@ -168,6 +168,12 @@ a project, pass the appropriate CFLAGS, CXXFLAG​S and 
LDFLAGS for example -
 
export CFLAGS="-flto -fuse-ld=lld" CXXFLAGS="-flto -fuse-ld=lld" 
LDFLAGS="-Wl,-plugin-opt=save-temps"
 
+On Windows, you should use lld-link as the linker.
+
+.. code-block:: bash
+
+   export CFLAGS="-flto -fuse-ld=lld-link" CXXFLAGS="-flto -fuse-ld=lld-link" 
LDFLAGS="-Wl,-plugin-opt=save-temps"
+
 This will generate four intermediate bytecode files:
 
 1. a.out.0.0.preopt.bc  (Before any link-time optimizations (LTO) are 
applied)

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


[clang-tools-extra] [Docs][LTO] Updated HowToSubmitABug.rst for LTO crashes (PR #68389)

2023-10-19 Thread Shivam Gupta via cfe-commits

https://github.com/xgupta updated 
https://github.com/llvm/llvm-project/pull/68389

>From bdf991f4563e3aa840bec35b1678ad4fe8f9fbb6 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Fri, 6 Oct 2023 12:32:24 +0530
Subject: [PATCH 1/3] [Docs][LTO] Update HowToSubmitABug.rst for LTO crashes

---
 llvm/docs/HowToSubmitABug.rst | 51 +++
 1 file changed, 51 insertions(+)

diff --git a/llvm/docs/HowToSubmitABug.rst b/llvm/docs/HowToSubmitABug.rst
index 733dae6c928d098..88f9af44add7c64 100644
--- a/llvm/docs/HowToSubmitABug.rst
+++ b/llvm/docs/HowToSubmitABug.rst
@@ -153,6 +153,57 @@ Please run this, then file a bug with the instructions and 
reduced .bc file
 that bugpoint emits.  If something goes wrong with bugpoint, please submit
 the "foo.bc" file and the option that llc crashes with.
 
+​.. _lto-crash:
+
+LTO bugs
+---
+
+If you find a bug that crashes llvm in LTO phase (by using -flto option),
+compile your source file to a .bc file by passing
+"``-flto -fuse-ld=lld -Wl,-plugin-opt=save-temps``"
+to clang (in addition to the options you already pass). If you are building
+a project, pass the appropriate CFLAGS, CXXFLAG​S and LDFLAGS for example -
+
+.. code-block:: bash
+
+   export CFLAGS="-flto -fuse-ld=lld" CXXFLAGS="-flto -fuse-ld=lld" 
LDFLAGS="-Wl,-plugin-opt=save-temps"
+
+This will generate four intermediate bytecode files:
+
+1. a.out.0.0.preopt.bc  (Before any link-time optimizations (LTO) are 
applied)
+2. a.out.0.2.internalize.bc (After initial optimizations applied)
+3. a.out.0.4.opt.bc (After the more extensive set of optimizations has 
been applied)
+4. a.out.0.5.precodegen.bc  (After LTO but before it's translated into machine 
code)
+
+Once you have these, one of the following commands should fail:
+
+#. ``opt "-passes=lto" a.out.0.0.preopt.bc``
+#. ``opt "-passes=lto" a.out.0.2.internalize.bc``
+#. ``opt "-passes=lto" a.out.0.4.opt.bc``
+#. ``llc a.out.0.5.precodegen.bc``
+
+If one of these do crash, you should be able to reduce
+this with :program:`llvm-reduce`
+command line (use the bc file corresponding to the command above that failed):
+
+#. ``llvm-reduce --test llvm-reduce.sh a.out.0.2.internalize.bc``
+
+An example of ``llvm-reduce.sh`` script
+
+.. code-block:: bash
+
+   $ cat llvm-reduce.sh
+   #!/usr/bin/env bash
+
+   $HOME/llvm/llvm-project/build/bin/opt "-passes=lto" $1 -o temp.bc  2>&1 
| tee err.log
+   grep "It->second == &Insn" err.log
+   exit $?
+
+Here we have grepped the failed assert message.
+
+Please run this, then file a bug with the instructions and reduced .bc file
+that llvm-reduce emits.
+
 .. _miscompiling:
 
 Miscompilations

>From 1823285171ddbefc49065c4995e9c33bee7b952a Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Thu, 19 Oct 2023 10:57:25 +0530
Subject: [PATCH 2/3] address review comment

---
 llvm/docs/HowToSubmitABug.rst | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/llvm/docs/HowToSubmitABug.rst b/llvm/docs/HowToSubmitABug.rst
index 88f9af44add7c64..197ed3e0fde6893 100644
--- a/llvm/docs/HowToSubmitABug.rst
+++ b/llvm/docs/HowToSubmitABug.rst
@@ -168,6 +168,12 @@ a project, pass the appropriate CFLAGS, CXXFLAG​S and 
LDFLAGS for example -
 
export CFLAGS="-flto -fuse-ld=lld" CXXFLAGS="-flto -fuse-ld=lld" 
LDFLAGS="-Wl,-plugin-opt=save-temps"
 
+On Windows, you should use lld-link as the linker.
+
+.. code-block:: bash
+
+   export CFLAGS="-flto -fuse-ld=lld-link" CXXFLAGS="-flto -fuse-ld=lld-link" 
LDFLAGS="-Wl,-plugin-opt=save-temps"
+
 This will generate four intermediate bytecode files:
 
 1. a.out.0.0.preopt.bc  (Before any link-time optimizations (LTO) are 
applied)

>From 0e19d37bf4eb9a312b4989fe941837e285f92a97 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Thu, 19 Oct 2023 12:29:23 +0530
Subject: [PATCH 3/3] rebase and improve some wording

---
 llvm/docs/HowToSubmitABug.rst | 36 ---
 1 file changed, 21 insertions(+), 15 deletions(-)

diff --git a/llvm/docs/HowToSubmitABug.rst b/llvm/docs/HowToSubmitABug.rst
index 197ed3e0fde6893..7e9ac089a0f70a1 100644
--- a/llvm/docs/HowToSubmitABug.rst
+++ b/llvm/docs/HowToSubmitABug.rst
@@ -158,30 +158,34 @@ the "foo.bc" file and the option that llc crashes with.
 LTO bugs
 ---
 
-If you find a bug that crashes llvm in LTO phase (by using -flto option),
-compile your source file to a .bc file by passing
-"``-flto -fuse-ld=lld -Wl,-plugin-opt=save-temps``"
-to clang (in addition to the options you already pass). If you are building
-a project, pass the appropriate CFLAGS, CXXFLAG​S and LDFLAGS for example -
+If you encounter a bug that leads to crashes in the LLVM LTO phase when using
+the `-flto` option, follow these steps to diagnose and report the issue:
+
+Compile your source file to a .bc (Bitcode) file with the following flags,
+in addition to your existing compilation options:
 
 .. code-block:: bash
 
export CFLAGS="-flto -fuse-ld=lld" CXXFLAGS=

[clang-tools-extra] [Docs][LTO] Updated HowToSubmitABug.rst for LTO crashes (PR #68389)

2023-10-19 Thread Shivam Gupta via cfe-commits

https://github.com/xgupta updated 
https://github.com/llvm/llvm-project/pull/68389

>From bdf991f4563e3aa840bec35b1678ad4fe8f9fbb6 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Fri, 6 Oct 2023 12:32:24 +0530
Subject: [PATCH 1/4] [Docs][LTO] Update HowToSubmitABug.rst for LTO crashes

---
 llvm/docs/HowToSubmitABug.rst | 51 +++
 1 file changed, 51 insertions(+)

diff --git a/llvm/docs/HowToSubmitABug.rst b/llvm/docs/HowToSubmitABug.rst
index 733dae6c928d098..88f9af44add7c64 100644
--- a/llvm/docs/HowToSubmitABug.rst
+++ b/llvm/docs/HowToSubmitABug.rst
@@ -153,6 +153,57 @@ Please run this, then file a bug with the instructions and 
reduced .bc file
 that bugpoint emits.  If something goes wrong with bugpoint, please submit
 the "foo.bc" file and the option that llc crashes with.
 
+​.. _lto-crash:
+
+LTO bugs
+---
+
+If you find a bug that crashes llvm in LTO phase (by using -flto option),
+compile your source file to a .bc file by passing
+"``-flto -fuse-ld=lld -Wl,-plugin-opt=save-temps``"
+to clang (in addition to the options you already pass). If you are building
+a project, pass the appropriate CFLAGS, CXXFLAG​S and LDFLAGS for example -
+
+.. code-block:: bash
+
+   export CFLAGS="-flto -fuse-ld=lld" CXXFLAGS="-flto -fuse-ld=lld" 
LDFLAGS="-Wl,-plugin-opt=save-temps"
+
+This will generate four intermediate bytecode files:
+
+1. a.out.0.0.preopt.bc  (Before any link-time optimizations (LTO) are 
applied)
+2. a.out.0.2.internalize.bc (After initial optimizations applied)
+3. a.out.0.4.opt.bc (After the more extensive set of optimizations has 
been applied)
+4. a.out.0.5.precodegen.bc  (After LTO but before it's translated into machine 
code)
+
+Once you have these, one of the following commands should fail:
+
+#. ``opt "-passes=lto" a.out.0.0.preopt.bc``
+#. ``opt "-passes=lto" a.out.0.2.internalize.bc``
+#. ``opt "-passes=lto" a.out.0.4.opt.bc``
+#. ``llc a.out.0.5.precodegen.bc``
+
+If one of these do crash, you should be able to reduce
+this with :program:`llvm-reduce`
+command line (use the bc file corresponding to the command above that failed):
+
+#. ``llvm-reduce --test llvm-reduce.sh a.out.0.2.internalize.bc``
+
+An example of ``llvm-reduce.sh`` script
+
+.. code-block:: bash
+
+   $ cat llvm-reduce.sh
+   #!/usr/bin/env bash
+
+   $HOME/llvm/llvm-project/build/bin/opt "-passes=lto" $1 -o temp.bc  2>&1 
| tee err.log
+   grep "It->second == &Insn" err.log
+   exit $?
+
+Here we have grepped the failed assert message.
+
+Please run this, then file a bug with the instructions and reduced .bc file
+that llvm-reduce emits.
+
 .. _miscompiling:
 
 Miscompilations

>From 1823285171ddbefc49065c4995e9c33bee7b952a Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Thu, 19 Oct 2023 10:57:25 +0530
Subject: [PATCH 2/4] address review comment

---
 llvm/docs/HowToSubmitABug.rst | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/llvm/docs/HowToSubmitABug.rst b/llvm/docs/HowToSubmitABug.rst
index 88f9af44add7c64..197ed3e0fde6893 100644
--- a/llvm/docs/HowToSubmitABug.rst
+++ b/llvm/docs/HowToSubmitABug.rst
@@ -168,6 +168,12 @@ a project, pass the appropriate CFLAGS, CXXFLAG​S and 
LDFLAGS for example -
 
export CFLAGS="-flto -fuse-ld=lld" CXXFLAGS="-flto -fuse-ld=lld" 
LDFLAGS="-Wl,-plugin-opt=save-temps"
 
+On Windows, you should use lld-link as the linker.
+
+.. code-block:: bash
+
+   export CFLAGS="-flto -fuse-ld=lld-link" CXXFLAGS="-flto -fuse-ld=lld-link" 
LDFLAGS="-Wl,-plugin-opt=save-temps"
+
 This will generate four intermediate bytecode files:
 
 1. a.out.0.0.preopt.bc  (Before any link-time optimizations (LTO) are 
applied)

>From 0e19d37bf4eb9a312b4989fe941837e285f92a97 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Thu, 19 Oct 2023 12:29:23 +0530
Subject: [PATCH 3/4] rebase and improve some wording

---
 llvm/docs/HowToSubmitABug.rst | 36 ---
 1 file changed, 21 insertions(+), 15 deletions(-)

diff --git a/llvm/docs/HowToSubmitABug.rst b/llvm/docs/HowToSubmitABug.rst
index 197ed3e0fde6893..7e9ac089a0f70a1 100644
--- a/llvm/docs/HowToSubmitABug.rst
+++ b/llvm/docs/HowToSubmitABug.rst
@@ -158,30 +158,34 @@ the "foo.bc" file and the option that llc crashes with.
 LTO bugs
 ---
 
-If you find a bug that crashes llvm in LTO phase (by using -flto option),
-compile your source file to a .bc file by passing
-"``-flto -fuse-ld=lld -Wl,-plugin-opt=save-temps``"
-to clang (in addition to the options you already pass). If you are building
-a project, pass the appropriate CFLAGS, CXXFLAG​S and LDFLAGS for example -
+If you encounter a bug that leads to crashes in the LLVM LTO phase when using
+the `-flto` option, follow these steps to diagnose and report the issue:
+
+Compile your source file to a .bc (Bitcode) file with the following flags,
+in addition to your existing compilation options:
 
 .. code-block:: bash
 
export CFLAGS="-flto -fuse-ld=lld" CXXFLAGS=

[clang] [Clang][InstrProf] Allow absolute path in fun.list of -fprofile-list= (PR #67519)

2023-10-19 Thread Shivam Gupta via cfe-commits

https://github.com/xgupta updated 
https://github.com/llvm/llvm-project/pull/67519

>From 400c889a4f0e867e3e2ceee43ae5c91f62f63c4d Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Thu, 19 Oct 2023 18:20:05 +0530
Subject: [PATCH] [Clang][InstrProf] Allow absolute path in fun.list of
 -fprofile-list=

---
 clang/lib/Basic/ProfileList.cpp | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/clang/lib/Basic/ProfileList.cpp b/clang/lib/Basic/ProfileList.cpp
index 8fa16e2eb069a52..1853a3e34ec35ed 100644
--- a/clang/lib/Basic/ProfileList.cpp
+++ b/clang/lib/Basic/ProfileList.cpp
@@ -139,12 +139,22 @@ std::optional
 ProfileList::isFileExcluded(StringRef FileName,
 CodeGenOptions::ProfileInstrKind Kind) const {
   StringRef Section = getSectionName(Kind);
+  // Convert the input file path to its canonical (absolute) form
+  llvm::SmallString<128> CanonicalFileName(FileName);
+  llvm::sys::fs::make_absolute(CanonicalFileName);
+
   // Check for "source:="
   if (auto V = inSection(Section, "source", FileName))
 return V;
+  if (auto V = inSection(Section, "source", CanonicalFileName))
+return V;
   if (SCL->inSection(Section, "!src", FileName))
 return Forbid;
+  if (SCL->inSection(Section, "!src", CanonicalFileName))
+return Forbid;
   if (SCL->inSection(Section, "src", FileName))
 return Allow;
+  if (SCL->inSection(Section, "src", CanonicalFileName))
+return Allow;
   return std::nullopt;
 }

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


[clang] [Clang][InstrProf] Allow absolute path in fun.list of -fprofile-list= (PR #67519)

2023-10-19 Thread Shivam Gupta via cfe-commits

https://github.com/xgupta reopened 
https://github.com/llvm/llvm-project/pull/67519
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][InstrProf] Allow absolute path in fun.list of -fprofile-list= (PR #67519)

2023-10-19 Thread Shivam Gupta via cfe-commits


@@ -139,9 +139,23 @@ std::optional
 ProfileList::isFileExcluded(StringRef FileName,
 CodeGenOptions::ProfileInstrKind Kind) const {
   StringRef Section = getSectionName(Kind);
-  // Check for "source:="
+
+  // Convert the input file path to its canonical (absolute) form
+  llvm::SmallString<128> CanonicalFileName(FileName);
+  llvm::sys::fs::make_absolute(CanonicalFileName);

xgupta wrote:

IIRC you mean first check the relative file name and then use the relative 
filename to get the absolute file name and then finally check for the absolute 
filename. 

Like this - 
```
diff --git a/clang/lib/Basic/ProfileList.cpp b/clang/lib/Basic/ProfileList.cpp
index 1853a3e34ec3..a561db4e7e49 100644
--- a/clang/lib/Basic/ProfileList.cpp
+++ b/clang/lib/Basic/ProfileList.cpp
@@ -139,21 +139,21 @@ std::optional
 ProfileList::isFileExcluded(StringRef FileName,
 CodeGenOptions::ProfileInstrKind Kind) const {
   StringRef Section = getSectionName(Kind);
-  // Convert the input file path to its canonical (absolute) form
-  llvm::SmallString<128> CanonicalFileName(FileName);
-  llvm::sys::fs::make_absolute(CanonicalFileName);
-
   // Check for "source:="
   if (auto V = inSection(Section, "source", FileName))
 return V;
-  if (auto V = inSection(Section, "source", CanonicalFileName))
-return V;
   if (SCL->inSection(Section, "!src", FileName))
 return Forbid;
-  if (SCL->inSection(Section, "!src", CanonicalFileName))
-return Forbid;
   if (SCL->inSection(Section, "src", FileName))
 return Allow;
+
+  // Convert the input file path to its canonical (absolute) form
+  llvm::SmallString<128> CanonicalFileName(FileName);
+  llvm::sys::fs::make_absolute(CanonicalFileName);
+  if (auto V = inSection(Section, "source", CanonicalFileName))
+return V;
+  if (SCL->inSection(Section, "!src", CanonicalFileName))
+return Forbid;
   if (SCL->inSection(Section, "src", CanonicalFileName))
 return Allow;
   return std::nullopt;
```

For me both are fine, let me know if you think the same as I understand and 
want this version.


https://github.com/llvm/llvm-project/pull/67519
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [Docs][LTO] Updated HowToSubmitABug.rst for LTO crashes (PR #68389)

2023-10-19 Thread Shivam Gupta via cfe-commits


@@ -153,6 +153,67 @@ Please run this, then file a bug with the instructions and 
reduced .bc file
 that bugpoint emits.  If something goes wrong with bugpoint, please submit
 the "foo.bc" file and the option that llc crashes with.
 
+LTO bugs
+---
+
+If you encounter a bug that leads to crashes in the LLVM LTO phase when using
+the `-flto` option, follow these steps to diagnose and report the issue:
+
+Compile your source file to a .bc (Bitcode) file with the following flags,
+in addition to your existing compilation options:
+
+.. code-block:: bash
+
+   export CFLAGS="-flto -fuse-ld=lld" CXXFLAGS="-flto -fuse-ld=lld" 
LDFLAGS="-Wl,-plugin-opt=save-temps"
+
+These flags enable LTO and save temporary files generated during compilation
+for later analysis.
+
+On Windows, you should use lld-link as the linker. Adjust your compilation 
+flags as follows:
+
+.. code-block:: bash
+
+   export CFLAGS="-flto -fuse-ld=lld-link" CXXFLAGS="-flto -fuse-ld=lld-link" 
LDFLAGS="-Wl,-plugin-opt=save-temps"

xgupta wrote:

I am not sure, I have never tried these on Windows (I mainly work on Linux), 
can you share the exact command, I think export is not a Windows command also. 

https://github.com/llvm/llvm-project/pull/68389
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [Docs][LTO] Updated HowToSubmitABug.rst for LTO crashes (PR #68389)

2023-10-20 Thread Shivam Gupta via cfe-commits

https://github.com/xgupta edited https://github.com/llvm/llvm-project/pull/68389
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] clang-linker-wrapper/LinkerWrapperOpts.td: "--sysroot" => "--sysroot=" (PR #65313)

2023-10-20 Thread Shivam Gupta via cfe-commits

https://github.com/xgupta closed https://github.com/llvm/llvm-project/pull/65313
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Workaround for MSVC ARM64 build performance regression (PR #65215)

2023-10-20 Thread Shivam Gupta via cfe-commits

xgupta wrote:

@tru Is it fine to commit this?

https://github.com/llvm/llvm-project/pull/65215
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Workaround for MSVC ARM64 build performance regression (PR #65215)

2023-10-20 Thread Shivam Gupta via cfe-commits

xgupta wrote:

I have the access.

https://github.com/llvm/llvm-project/pull/65215
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Workaround for MSVC ARM64 build performance regression (PR #65215)

2023-10-20 Thread Shivam Gupta via cfe-commits

https://github.com/xgupta closed https://github.com/llvm/llvm-project/pull/65215
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [AST] Use explicit type erasure in TypeSourceInfo constructor (PR #68435)

2023-10-20 Thread Shivam Gupta via cfe-commits

https://github.com/xgupta closed https://github.com/llvm/llvm-project/pull/68435
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [RecursiveASTVisitor] Fix RecursiveASTVisitor (RAV) fails to visit the initializer of a bitfield (PR #69557)

2023-10-25 Thread Shivam Gupta via cfe-commits

https://github.com/xgupta updated 
https://github.com/llvm/llvm-project/pull/69557

>From 2e363be5e79e2aeeb219628db0c917e530e04d99 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Thu, 19 Oct 2023 09:06:43 +0530
Subject: [PATCH 1/3] [RecursiveASTVisitor] Fix RecursiveASTVisitor (RAV) fails
 to visit the initializer of a bitfield

Patch by Scott McPeak
---
 clang/include/clang/AST/RecursiveASTVisitor.h |  2 +-
 clang/unittests/Tooling/CMakeLists.txt|  1 +
 .../BitfieldInitializer.cpp   | 34 +++
 3 files changed, 36 insertions(+), 1 deletion(-)
 create mode 100644 
clang/unittests/Tooling/RecursiveASTVisitorTests/BitfieldInitializer.cpp

diff --git a/clang/include/clang/AST/RecursiveASTVisitor.h 
b/clang/include/clang/AST/RecursiveASTVisitor.h
index 3dd23eb38eeabfc..53bc15e1b19f668 100644
--- a/clang/include/clang/AST/RecursiveASTVisitor.h
+++ b/clang/include/clang/AST/RecursiveASTVisitor.h
@@ -2103,7 +2103,7 @@ DEF_TRAVERSE_DECL(FieldDecl, {
   TRY_TO(TraverseDeclaratorHelper(D));
   if (D->isBitField())
 TRY_TO(TraverseStmt(D->getBitWidth()));
-  else if (D->hasInClassInitializer())
+  if (D->hasInClassInitializer())
 TRY_TO(TraverseStmt(D->getInClassInitializer()));
 })
 
diff --git a/clang/unittests/Tooling/CMakeLists.txt 
b/clang/unittests/Tooling/CMakeLists.txt
index 2fbe78e3fab7528..5a10a6b285390e9 100644
--- a/clang/unittests/Tooling/CMakeLists.txt
+++ b/clang/unittests/Tooling/CMakeLists.txt
@@ -25,6 +25,7 @@ add_clang_unittest(ToolingTests
   QualTypeNamesTest.cpp
   RangeSelectorTest.cpp
   RecursiveASTVisitorTests/Attr.cpp
+  RecursiveASTVisitorTests/BitfieldInitializer.cpp
   RecursiveASTVisitorTests/CallbacksLeaf.cpp
   RecursiveASTVisitorTests/CallbacksUnaryOperator.cpp
   RecursiveASTVisitorTests/CallbacksBinaryOperator.cpp
diff --git 
a/clang/unittests/Tooling/RecursiveASTVisitorTests/BitfieldInitializer.cpp 
b/clang/unittests/Tooling/RecursiveASTVisitorTests/BitfieldInitializer.cpp
new file mode 100644
index 000..676a491a43040ea
--- /dev/null
+++ b/clang/unittests/Tooling/RecursiveASTVisitorTests/BitfieldInitializer.cpp
@@ -0,0 +1,34 @@
+//===- unittest/Tooling/RecursiveASTVisitorTests/BitfieldInitializer.cpp -===//
+//
+// 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
+//
+//===--===//
+
+#include "TestVisitor.h"
+#include 
+
+using namespace clang;
+
+namespace {
+
+// Check to ensure that bitfield initializers are visited.
+class BitfieldInitializerVisitor : public 
ExpectedLocationVisitor {
+public:
+  bool VisitIntegerLiteral(IntegerLiteral *IL) {
+Match(std::to_string(IL->getValue().getSExtValue()), IL->getLocation());
+return true;
+  }
+};
+
+TEST(RecursiveASTVisitor, BitfieldInitializerIsVisited) {
+  BitfieldInitializerVisitor Visitor;
+  Visitor.ExpectMatch("123", 2, 15); 
+  EXPECT_TRUE(Visitor.runOver(
+"struct S {\n"
+"  int x : 8 = 123;\n"
+"};\n"));
+}
+
+} // end anonymous namespace

>From a6fa113206562f373f3aba81ce81acd5d9dcf9d1 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Thu, 19 Oct 2023 09:24:38 +0530
Subject: [PATCH 2/3] clang-format

---
 .../RecursiveASTVisitorTests/BitfieldInitializer.cpp | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git 
a/clang/unittests/Tooling/RecursiveASTVisitorTests/BitfieldInitializer.cpp 
b/clang/unittests/Tooling/RecursiveASTVisitorTests/BitfieldInitializer.cpp
index 676a491a43040ea..c11e726fe855284 100644
--- a/clang/unittests/Tooling/RecursiveASTVisitorTests/BitfieldInitializer.cpp
+++ b/clang/unittests/Tooling/RecursiveASTVisitorTests/BitfieldInitializer.cpp
@@ -14,7 +14,8 @@ using namespace clang;
 namespace {
 
 // Check to ensure that bitfield initializers are visited.
-class BitfieldInitializerVisitor : public 
ExpectedLocationVisitor {
+class BitfieldInitializerVisitor
+: public ExpectedLocationVisitor {
 public:
   bool VisitIntegerLiteral(IntegerLiteral *IL) {
 Match(std::to_string(IL->getValue().getSExtValue()), IL->getLocation());
@@ -24,11 +25,10 @@ class BitfieldInitializerVisitor : public 
ExpectedLocationVisitorFrom 1ce8c2ca7bf5110e4bfb11eeaaa891183e73f2e5 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Wed, 25 Oct 2023 22:16:34 +0530
Subject: [PATCH 3/3] Added release note

---
 clang/docs/ReleaseNotes.rst | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 42f20b9a9bb0410..a1f373b167a33cb 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -650,6 +650,9 @@ Bug Fixes to AST Handling
   `Issue 64170 `_
 - Fixed ``hasAnyBase`` not binding nodes in its submatcher.
   (`#65421 `_)
+- Fixed a

[clang] [RecursiveASTVisitor] Fix RecursiveASTVisitor (RAV) fails to visit the initializer of a bitfield (PR #69557)

2023-10-26 Thread Shivam Gupta via cfe-commits

https://github.com/xgupta updated 
https://github.com/llvm/llvm-project/pull/69557

>From 2e363be5e79e2aeeb219628db0c917e530e04d99 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Thu, 19 Oct 2023 09:06:43 +0530
Subject: [PATCH 1/4] [RecursiveASTVisitor] Fix RecursiveASTVisitor (RAV) fails
 to visit the initializer of a bitfield

Patch by Scott McPeak
---
 clang/include/clang/AST/RecursiveASTVisitor.h |  2 +-
 clang/unittests/Tooling/CMakeLists.txt|  1 +
 .../BitfieldInitializer.cpp   | 34 +++
 3 files changed, 36 insertions(+), 1 deletion(-)
 create mode 100644 
clang/unittests/Tooling/RecursiveASTVisitorTests/BitfieldInitializer.cpp

diff --git a/clang/include/clang/AST/RecursiveASTVisitor.h 
b/clang/include/clang/AST/RecursiveASTVisitor.h
index 3dd23eb38eeabfc..53bc15e1b19f668 100644
--- a/clang/include/clang/AST/RecursiveASTVisitor.h
+++ b/clang/include/clang/AST/RecursiveASTVisitor.h
@@ -2103,7 +2103,7 @@ DEF_TRAVERSE_DECL(FieldDecl, {
   TRY_TO(TraverseDeclaratorHelper(D));
   if (D->isBitField())
 TRY_TO(TraverseStmt(D->getBitWidth()));
-  else if (D->hasInClassInitializer())
+  if (D->hasInClassInitializer())
 TRY_TO(TraverseStmt(D->getInClassInitializer()));
 })
 
diff --git a/clang/unittests/Tooling/CMakeLists.txt 
b/clang/unittests/Tooling/CMakeLists.txt
index 2fbe78e3fab7528..5a10a6b285390e9 100644
--- a/clang/unittests/Tooling/CMakeLists.txt
+++ b/clang/unittests/Tooling/CMakeLists.txt
@@ -25,6 +25,7 @@ add_clang_unittest(ToolingTests
   QualTypeNamesTest.cpp
   RangeSelectorTest.cpp
   RecursiveASTVisitorTests/Attr.cpp
+  RecursiveASTVisitorTests/BitfieldInitializer.cpp
   RecursiveASTVisitorTests/CallbacksLeaf.cpp
   RecursiveASTVisitorTests/CallbacksUnaryOperator.cpp
   RecursiveASTVisitorTests/CallbacksBinaryOperator.cpp
diff --git 
a/clang/unittests/Tooling/RecursiveASTVisitorTests/BitfieldInitializer.cpp 
b/clang/unittests/Tooling/RecursiveASTVisitorTests/BitfieldInitializer.cpp
new file mode 100644
index 000..676a491a43040ea
--- /dev/null
+++ b/clang/unittests/Tooling/RecursiveASTVisitorTests/BitfieldInitializer.cpp
@@ -0,0 +1,34 @@
+//===- unittest/Tooling/RecursiveASTVisitorTests/BitfieldInitializer.cpp -===//
+//
+// 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
+//
+//===--===//
+
+#include "TestVisitor.h"
+#include 
+
+using namespace clang;
+
+namespace {
+
+// Check to ensure that bitfield initializers are visited.
+class BitfieldInitializerVisitor : public 
ExpectedLocationVisitor {
+public:
+  bool VisitIntegerLiteral(IntegerLiteral *IL) {
+Match(std::to_string(IL->getValue().getSExtValue()), IL->getLocation());
+return true;
+  }
+};
+
+TEST(RecursiveASTVisitor, BitfieldInitializerIsVisited) {
+  BitfieldInitializerVisitor Visitor;
+  Visitor.ExpectMatch("123", 2, 15); 
+  EXPECT_TRUE(Visitor.runOver(
+"struct S {\n"
+"  int x : 8 = 123;\n"
+"};\n"));
+}
+
+} // end anonymous namespace

>From a6fa113206562f373f3aba81ce81acd5d9dcf9d1 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Thu, 19 Oct 2023 09:24:38 +0530
Subject: [PATCH 2/4] clang-format

---
 .../RecursiveASTVisitorTests/BitfieldInitializer.cpp | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git 
a/clang/unittests/Tooling/RecursiveASTVisitorTests/BitfieldInitializer.cpp 
b/clang/unittests/Tooling/RecursiveASTVisitorTests/BitfieldInitializer.cpp
index 676a491a43040ea..c11e726fe855284 100644
--- a/clang/unittests/Tooling/RecursiveASTVisitorTests/BitfieldInitializer.cpp
+++ b/clang/unittests/Tooling/RecursiveASTVisitorTests/BitfieldInitializer.cpp
@@ -14,7 +14,8 @@ using namespace clang;
 namespace {
 
 // Check to ensure that bitfield initializers are visited.
-class BitfieldInitializerVisitor : public 
ExpectedLocationVisitor {
+class BitfieldInitializerVisitor
+: public ExpectedLocationVisitor {
 public:
   bool VisitIntegerLiteral(IntegerLiteral *IL) {
 Match(std::to_string(IL->getValue().getSExtValue()), IL->getLocation());
@@ -24,11 +25,10 @@ class BitfieldInitializerVisitor : public 
ExpectedLocationVisitorFrom 1ce8c2ca7bf5110e4bfb11eeaaa891183e73f2e5 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Wed, 25 Oct 2023 22:16:34 +0530
Subject: [PATCH 3/4] Added release note

---
 clang/docs/ReleaseNotes.rst | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 42f20b9a9bb0410..a1f373b167a33cb 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -650,6 +650,9 @@ Bug Fixes to AST Handling
   `Issue 64170 `_
 - Fixed ``hasAnyBase`` not binding nodes in its submatcher.
   (`#65421 `_)
+- Fixed a

[clang] [RecursiveASTVisitor] Fix RecursiveASTVisitor (RAV) fails to visit the initializer of a bitfield (PR #69557)

2023-10-26 Thread Shivam Gupta via cfe-commits

https://github.com/xgupta closed https://github.com/llvm/llvm-project/pull/69557
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [RecursiveASTVisitor] Fix RecursiveASTVisitor (RAV) fails to visit the initializer of a bitfield (PR #69557)

2023-10-26 Thread Shivam Gupta via cfe-commits

xgupta wrote:

Thanks @cor3ntin for the review!

https://github.com/llvm/llvm-project/pull/69557
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Docs][LTO] Updated HowToSubmitABug.rst for LTO crashes (PR #68389)

2023-10-26 Thread Shivam Gupta via cfe-commits

https://github.com/xgupta updated 
https://github.com/llvm/llvm-project/pull/68389

>From bdf991f4563e3aa840bec35b1678ad4fe8f9fbb6 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Fri, 6 Oct 2023 12:32:24 +0530
Subject: [PATCH 1/5] [Docs][LTO] Update HowToSubmitABug.rst for LTO crashes

---
 llvm/docs/HowToSubmitABug.rst | 51 +++
 1 file changed, 51 insertions(+)

diff --git a/llvm/docs/HowToSubmitABug.rst b/llvm/docs/HowToSubmitABug.rst
index 733dae6c928d098..88f9af44add7c64 100644
--- a/llvm/docs/HowToSubmitABug.rst
+++ b/llvm/docs/HowToSubmitABug.rst
@@ -153,6 +153,57 @@ Please run this, then file a bug with the instructions and 
reduced .bc file
 that bugpoint emits.  If something goes wrong with bugpoint, please submit
 the "foo.bc" file and the option that llc crashes with.
 
+​.. _lto-crash:
+
+LTO bugs
+---
+
+If you find a bug that crashes llvm in LTO phase (by using -flto option),
+compile your source file to a .bc file by passing
+"``-flto -fuse-ld=lld -Wl,-plugin-opt=save-temps``"
+to clang (in addition to the options you already pass). If you are building
+a project, pass the appropriate CFLAGS, CXXFLAG​S and LDFLAGS for example -
+
+.. code-block:: bash
+
+   export CFLAGS="-flto -fuse-ld=lld" CXXFLAGS="-flto -fuse-ld=lld" 
LDFLAGS="-Wl,-plugin-opt=save-temps"
+
+This will generate four intermediate bytecode files:
+
+1. a.out.0.0.preopt.bc  (Before any link-time optimizations (LTO) are 
applied)
+2. a.out.0.2.internalize.bc (After initial optimizations applied)
+3. a.out.0.4.opt.bc (After the more extensive set of optimizations has 
been applied)
+4. a.out.0.5.precodegen.bc  (After LTO but before it's translated into machine 
code)
+
+Once you have these, one of the following commands should fail:
+
+#. ``opt "-passes=lto" a.out.0.0.preopt.bc``
+#. ``opt "-passes=lto" a.out.0.2.internalize.bc``
+#. ``opt "-passes=lto" a.out.0.4.opt.bc``
+#. ``llc a.out.0.5.precodegen.bc``
+
+If one of these do crash, you should be able to reduce
+this with :program:`llvm-reduce`
+command line (use the bc file corresponding to the command above that failed):
+
+#. ``llvm-reduce --test llvm-reduce.sh a.out.0.2.internalize.bc``
+
+An example of ``llvm-reduce.sh`` script
+
+.. code-block:: bash
+
+   $ cat llvm-reduce.sh
+   #!/usr/bin/env bash
+
+   $HOME/llvm/llvm-project/build/bin/opt "-passes=lto" $1 -o temp.bc  2>&1 
| tee err.log
+   grep "It->second == &Insn" err.log
+   exit $?
+
+Here we have grepped the failed assert message.
+
+Please run this, then file a bug with the instructions and reduced .bc file
+that llvm-reduce emits.
+
 .. _miscompiling:
 
 Miscompilations

>From 1823285171ddbefc49065c4995e9c33bee7b952a Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Thu, 19 Oct 2023 10:57:25 +0530
Subject: [PATCH 2/5] address review comment

---
 llvm/docs/HowToSubmitABug.rst | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/llvm/docs/HowToSubmitABug.rst b/llvm/docs/HowToSubmitABug.rst
index 88f9af44add7c64..197ed3e0fde6893 100644
--- a/llvm/docs/HowToSubmitABug.rst
+++ b/llvm/docs/HowToSubmitABug.rst
@@ -168,6 +168,12 @@ a project, pass the appropriate CFLAGS, CXXFLAG​S and 
LDFLAGS for example -
 
export CFLAGS="-flto -fuse-ld=lld" CXXFLAGS="-flto -fuse-ld=lld" 
LDFLAGS="-Wl,-plugin-opt=save-temps"
 
+On Windows, you should use lld-link as the linker.
+
+.. code-block:: bash
+
+   export CFLAGS="-flto -fuse-ld=lld-link" CXXFLAGS="-flto -fuse-ld=lld-link" 
LDFLAGS="-Wl,-plugin-opt=save-temps"
+
 This will generate four intermediate bytecode files:
 
 1. a.out.0.0.preopt.bc  (Before any link-time optimizations (LTO) are 
applied)

>From 0e19d37bf4eb9a312b4989fe941837e285f92a97 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Thu, 19 Oct 2023 12:29:23 +0530
Subject: [PATCH 3/5] rebase and improve some wording

---
 llvm/docs/HowToSubmitABug.rst | 36 ---
 1 file changed, 21 insertions(+), 15 deletions(-)

diff --git a/llvm/docs/HowToSubmitABug.rst b/llvm/docs/HowToSubmitABug.rst
index 197ed3e0fde6893..7e9ac089a0f70a1 100644
--- a/llvm/docs/HowToSubmitABug.rst
+++ b/llvm/docs/HowToSubmitABug.rst
@@ -158,30 +158,34 @@ the "foo.bc" file and the option that llc crashes with.
 LTO bugs
 ---
 
-If you find a bug that crashes llvm in LTO phase (by using -flto option),
-compile your source file to a .bc file by passing
-"``-flto -fuse-ld=lld -Wl,-plugin-opt=save-temps``"
-to clang (in addition to the options you already pass). If you are building
-a project, pass the appropriate CFLAGS, CXXFLAG​S and LDFLAGS for example -
+If you encounter a bug that leads to crashes in the LLVM LTO phase when using
+the `-flto` option, follow these steps to diagnose and report the issue:
+
+Compile your source file to a .bc (Bitcode) file with the following flags,
+in addition to your existing compilation options:
 
 .. code-block:: bash
 
export CFLAGS="-flto -fuse-ld=lld" CXXFLAGS=

[clang] fae57a6 - [Clang] [Fix] Clang build fails when build directory contains space character

2021-09-20 Thread Shivam Gupta via cfe-commits

Author: Brain Swift
Date: 2021-09-20T18:19:08+05:30
New Revision: fae57a6a9795eccfa349270b110c09524e341abd

URL: 
https://github.com/llvm/llvm-project/commit/fae57a6a9795eccfa349270b110c09524e341abd
DIFF: 
https://github.com/llvm/llvm-project/commit/fae57a6a9795eccfa349270b110c09524e341abd.diff

LOG: [Clang] [Fix] Clang build fails when build directory contains space 
character

Clang build fails when build directory contains space character.

Error messages:

[ 95%] Linking CXX executable ../../../../bin/clang
clang: error: no such file or directory: 
'Space/Net/llvm/Build/tools/clang/tools/driver/Info.plist'
make[2]: *** [bin/clang-14] Error 1
make[1]: *** [tools/clang/tools/driver/CMakeFiles/clang.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs

The path name is actually:
  'Dev Space/Net/llvm/Build/tools/clang/tools/driver/Info.plist'

Bugzilla issue - https://bugs.llvm.org/show_bug.cgi?id=51884
Reporter and patch author - Brain Swift 

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D109979

Added: 


Modified: 
clang/tools/driver/CMakeLists.txt

Removed: 




diff  --git a/clang/tools/driver/CMakeLists.txt 
b/clang/tools/driver/CMakeLists.txt
index 7c32aadb8700..1bea470ed301 100644
--- a/clang/tools/driver/CMakeLists.txt
+++ b/clang/tools/driver/CMakeLists.txt
@@ -82,7 +82,7 @@ if (APPLE)
   set(TOOL_INFO_PLIST_OUT "${CMAKE_CURRENT_BINARY_DIR}/${TOOL_INFO_PLIST}")
   target_link_libraries(clang
 PRIVATE
-"-Wl,-sectcreate,__TEXT,__info_plist,${TOOL_INFO_PLIST_OUT}")
+"-Wl,-sectcreate,__TEXT,__info_plist,\"${TOOL_INFO_PLIST_OUT}\"")
   configure_file("${TOOL_INFO_PLIST}.in" "${TOOL_INFO_PLIST_OUT}" @ONLY)
 
   set(TOOL_INFO_UTI)



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


[clang] 7f5ca8c - [clang] Use portable "#!/usr/bin/env bash" shebang for tools and utils.

2021-09-23 Thread Shivam Gupta via cfe-commits

Author: Frederic Cambus
Date: 2021-09-23T21:16:43+05:30
New Revision: 7f5ca8cc2158debe3f09eb19b4613e75e124

URL: 
https://github.com/llvm/llvm-project/commit/7f5ca8cc2158debe3f09eb19b4613e75e124
DIFF: 
https://github.com/llvm/llvm-project/commit/7f5ca8cc2158debe3f09eb19b4613e75e124.diff

LOG: [clang] Use portable "#!/usr/bin/env bash" shebang for tools and utils.

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D110041

Added: 


Modified: 
clang/tools/diag-build/diag-build.sh
clang/utils/make-ast-dump-check.sh

Removed: 




diff  --git a/clang/tools/diag-build/diag-build.sh 
b/clang/tools/diag-build/diag-build.sh
index 018288dda9566..b1504ffcc418e 100755
--- a/clang/tools/diag-build/diag-build.sh
+++ b/clang/tools/diag-build/diag-build.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 
 # diag-build: a tool showing enabled warnings in a project.
 #

diff  --git a/clang/utils/make-ast-dump-check.sh 
b/clang/utils/make-ast-dump-check.sh
index 365f227cc1c66..cb4c7924e4c3e 100755
--- a/clang/utils/make-ast-dump-check.sh
+++ b/clang/utils/make-ast-dump-check.sh
@@ -1,4 +1,4 @@
-#! /bin/bash
+#!/usr/bin/env bash
 
 # This script is intended as a FileCheck replacement to update the test
 # expectations in a -ast-dump test.



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


[clang] 7a7caf9 - [clang] Fix library name (libsupc++) in the admonition note.

2021-09-29 Thread Shivam Gupta via cfe-commits

Author: Frederic Cambus
Date: 2021-09-29T19:45:06+05:30
New Revision: 7a7caf97012f53172743d650fd3c97bce99f86ef

URL: 
https://github.com/llvm/llvm-project/commit/7a7caf97012f53172743d650fd3c97bce99f86ef
DIFF: 
https://github.com/llvm/llvm-project/commit/7a7caf97012f53172743d650fd3c97bce99f86ef.diff

LOG: [clang] Fix library name (libsupc++) in the admonition note.

Differential Revision: https://reviews.llvm.org/D110715

Added: 


Modified: 
clang/docs/Toolchain.rst

Removed: 




diff  --git a/clang/docs/Toolchain.rst b/clang/docs/Toolchain.rst
index 9c4099e15c98c..2ed835c0317e4 100644
--- a/clang/docs/Toolchain.rst
+++ b/clang/docs/Toolchain.rst
@@ -312,7 +312,7 @@ library version of libstdc++ contains a copy of libsupc++.
 
 .. note::
 
-  Clang does not currently automatically link against libatomic when statically
+  Clang does not currently automatically link against libsupc++ when statically
   linking libstdc++. You may need to manually add ``-lsupc++`` to support this
   configuration when using ``-static`` or ``-static-libstdc++``.
 



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


[clang] 01641f6 - [clang] Fix sentence in the usage section of ThinLTO docs.

2021-09-29 Thread Shivam Gupta via cfe-commits

Author: Frederic Cambus
Date: 2021-09-30T07:26:19+05:30
New Revision: 01641f665f5a3f94fc9e2bba598b5a65a6a7bd01

URL: 
https://github.com/llvm/llvm-project/commit/01641f665f5a3f94fc9e2bba598b5a65a6a7bd01
DIFF: 
https://github.com/llvm/llvm-project/commit/01641f665f5a3f94fc9e2bba598b5a65a6a7bd01.diff

LOG: [clang] Fix sentence in the usage section of ThinLTO docs.

Reviewed By: tejohnson

Differential Revision: https://reviews.llvm.org/D110750

Added: 


Modified: 
clang/docs/ThinLTO.rst

Removed: 




diff  --git a/clang/docs/ThinLTO.rst b/clang/docs/ThinLTO.rst
index fa6d28e13ba78..579a513f952b2 100644
--- a/clang/docs/ThinLTO.rst
+++ b/clang/docs/ThinLTO.rst
@@ -87,7 +87,7 @@ When using lld-link, the -flto option need only be added to 
the compile step:
 
 As mentioned earlier, by default the linkers will launch the ThinLTO backend
 threads in parallel, passing the resulting native object files back to the
-linker for the final native link.  As such, the usage model the same as
+linker for the final native link.  As such, the usage model is the same as
 non-LTO.
 
 With gold, if you see an error during the link of the form:



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


[clang] 97a0ba4 - [clang] Update Clang version from 13 to 14 in scan-build.1.

2021-09-29 Thread Shivam Gupta via cfe-commits

Author: Frederic Cambus
Date: 2021-09-30T11:23:25+05:30
New Revision: 97a0ba475d105838bd9bb7ed8506f599210995c7

URL: 
https://github.com/llvm/llvm-project/commit/97a0ba475d105838bd9bb7ed8506f599210995c7
DIFF: 
https://github.com/llvm/llvm-project/commit/97a0ba475d105838bd9bb7ed8506f599210995c7.diff

LOG: [clang] Update Clang version from 13 to 14 in scan-build.1.

Reviewed By: NoQ

Differential Revision: https://reviews.llvm.org/D110763

Added: 


Modified: 
clang/tools/scan-build/man/scan-build.1

Removed: 




diff  --git a/clang/tools/scan-build/man/scan-build.1 
b/clang/tools/scan-build/man/scan-build.1
index 824037f3b30cb..5aa29f9d5b20b 100644
--- a/clang/tools/scan-build/man/scan-build.1
+++ b/clang/tools/scan-build/man/scan-build.1
@@ -2,9 +2,9 @@
 .\" See https://llvm.org/LICENSE.txt for license information.
 .\" SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 .\" $Id$
-.Dd Jul 27, 2021
+.Dd Sep 29, 2021
 .Dt SCAN-BUILD 1
-.Os "clang" "13"
+.Os "clang" "14"
 .Sh NAME
 .Nm scan-build
 .Nd Clang static analyzer



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


[clang] a3b099b - [Docs] Removed /Zd flag still mentioned in documentation

2021-11-26 Thread Shivam Gupta via cfe-commits

Author: Bhumitram Kumar
Date: 2021-11-26T18:08:06+05:30
New Revision: a3b099b68c0c156aa8ed9ec81c5dfdf150c6329c

URL: 
https://github.com/llvm/llvm-project/commit/a3b099b68c0c156aa8ed9ec81c5dfdf150c6329c
DIFF: 
https://github.com/llvm/llvm-project/commit/a3b099b68c0c156aa8ed9ec81c5dfdf150c6329c.diff

LOG: [Docs] Removed /Zd flag still mentioned in documentation

https://reviews.llvm.org/D93458 removed the /Zd flag as MSVC doesn't support 
that syntax. Instead users should be using -gline-tables-only.
The /Zd flag is still mentioned at 
https://clang.llvm.org/docs/UsersManual.html#clang-cl :   /Zd   
  Emit debug line number tables only.

Fix PR52571

Reviewed By: xgupta

Differential Revision: https://reviews.llvm.org/D114632

Added: 


Modified: 
clang/docs/UsersManual.rst

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index f534b21333583..ce66ef58fca62 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -3716,7 +3716,6 @@ Execute ``clang-cl /?`` to see a list of supported 
options:
   /Zc:trigraphs   Enable trigraphs
   /Zc:twoPhase-   Disable two-phase name lookup in templates
   /Zc:twoPhaseEnable two-phase name lookup in templates
-  /Zd Emit debug line number tables only
   /Zi Alias for /Z7. Does not produce PDBs.
   /Zl Don't mention any default libraries in the 
object file
   /Zp Set the default maximum struct packing alignment 
to 1



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


[clang] 4667821 - [NFC] Typo fix in ARCMTActions.h

2022-09-18 Thread Shivam Gupta via cfe-commits

Author: Shivam Gupta
Date: 2022-09-18T12:34:24+05:30
New Revision: 46678211512238159199a5857e9f9d774016060c

URL: 
https://github.com/llvm/llvm-project/commit/46678211512238159199a5857e9f9d774016060c
DIFF: 
https://github.com/llvm/llvm-project/commit/46678211512238159199a5857e9f9d774016060c.diff

LOG: [NFC] Typo fix in ARCMTActions.h

Added: 


Modified: 
clang/include/clang/ARCMigrate/ARCMTActions.h
clang/lib/ARCMigrate/ARCMTActions.cpp

Removed: 




diff  --git a/clang/include/clang/ARCMigrate/ARCMTActions.h 
b/clang/include/clang/ARCMigrate/ARCMTActions.h
index 641c259b38677..714f4b33db446 100644
--- a/clang/include/clang/ARCMigrate/ARCMTActions.h
+++ b/clang/include/clang/ARCMigrate/ARCMTActions.h
@@ -43,7 +43,7 @@ class MigrateSourceAction : public ASTFrontendAction {
 class MigrateAction : public WrapperFrontendAction {
   std::string MigrateDir;
   std::string PlistOut;
-  bool EmitPremigrationARCErros;
+  bool EmitPremigrationARCErrors;
 protected:
   bool BeginInvocation(CompilerInstance &CI) override;
 

diff  --git a/clang/lib/ARCMigrate/ARCMTActions.cpp 
b/clang/lib/ARCMigrate/ARCMTActions.cpp
index d72f53806e37b..0805d90d25aa6 100644
--- a/clang/lib/ARCMigrate/ARCMTActions.cpp
+++ b/clang/lib/ARCMigrate/ARCMTActions.cpp
@@ -39,7 +39,7 @@ ModifyAction::ModifyAction(std::unique_ptr 
WrappedAction)
 bool MigrateAction::BeginInvocation(CompilerInstance &CI) {
   if (arcmt::migrateWithTemporaryFiles(
   CI.getInvocation(), getCurrentInput(), 
CI.getPCHContainerOperations(),
-  CI.getDiagnostics().getClient(), MigrateDir, 
EmitPremigrationARCErros,
+  CI.getDiagnostics().getClient(), MigrateDir, 
EmitPremigrationARCErrors,
   PlistOut))
 return false; // errors, stop the action.
 
@@ -53,7 +53,7 @@ MigrateAction::MigrateAction(std::unique_ptr 
WrappedAction,
  StringRef plistOut,
  bool emitPremigrationARCErrors)
   : WrapperFrontendAction(std::move(WrappedAction)), MigrateDir(migrateDir),
-PlistOut(plistOut), EmitPremigrationARCErros(emitPremigrationARCErrors) {
+PlistOut(plistOut), EmitPremigrationARCErrors(emitPremigrationARCErrors) {
   if (MigrateDir.empty())
 MigrateDir = "."; // user current directory if none is given.
 }



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


[clang] 95668c0 - [Clang] Add -Wtype-limits to -Wextra for GCC compatibility

2023-02-01 Thread Shivam Gupta via cfe-commits

Author: Shivam Gupta
Date: 2023-02-01T19:29:16+05:30
New Revision: 95668c0d97e6184729f3a3e9621a58d9edffb6b0

URL: 
https://github.com/llvm/llvm-project/commit/95668c0d97e6184729f3a3e9621a58d9edffb6b0
DIFF: 
https://github.com/llvm/llvm-project/commit/95668c0d97e6184729f3a3e9621a58d9edffb6b0.diff

LOG: [Clang] Add -Wtype-limits to -Wextra for GCC compatibility

GCC added the -Wtype-limits warning group to -Wextra around
GCC 4.4 and the group has some very helpful extra warnings
like tautological comparison type limit warnings
(comparingan unsigned int to see if it's positive, etc).

Fix https://github.com/llvm/llvm-project/issues/58375

Reviewed By: #clang-vendors, thesamesam

Differential Revision: https://reviews.llvm.org/D142826

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/DiagnosticGroups.td
clang/test/Sema/tautological-constant-compare.c

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 2b2ca8b2987f0..e5d09ce61778e 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -61,6 +61,9 @@ Bug Fixes
   templates. This fixes
   `Issue 60344 `_.
 
+- ``-Wtype-limits`` was added to ``-Wextra`` for GCC compatibility. This fixes
+  `Issue 58375 `_.
+
 Improvements to Clang's diagnostics
 ^^^
 - We now generate a diagnostic for signed integer overflow due to unary minus

diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 6c997c37cc5cd..39e6c94fe6e29 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -992,6 +992,7 @@ def Extra : DiagGroup<"extra", [
 EmptyInitStatement,
 StringConcatation,
 FUseLdPath,
+TypeLimits,
   ]>;
 
 def Most : DiagGroup<"most", [

diff  --git a/clang/test/Sema/tautological-constant-compare.c 
b/clang/test/Sema/tautological-constant-compare.c
index 04b8a1416be0b..59094186899dd 100644
--- a/clang/test/Sema/tautological-constant-compare.c
+++ b/clang/test/Sema/tautological-constant-compare.c
@@ -4,8 +4,8 @@
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only 
-Wtautological-type-limit-compare -DTEST -verify -x c++ %s
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wtype-limits -DTEST 
-verify %s
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wtype-limits -DTEST 
-verify -x c++ %s
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wextra 
-Wno-sign-compare -verify=silent %s
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wextra 
-Wno-sign-compare -verify=silent -x c++ %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wextra 
-Wno-sign-compare -DTEST -verify %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wextra 
-Wno-sign-compare -DTEST -verify -x c++ %s
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wall -verify=silent 
%s
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wall -verify=silent 
-x c++ %s
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -verify=silent %s



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


[clang] 897e345 - Revert "[Clang] Add -Wtype-limits to -Wextra for GCC compatibility"

2023-02-01 Thread Shivam Gupta via cfe-commits

Author: Shivam Gupta
Date: 2023-02-02T05:59:27+05:30
New Revision: 897e345042cdf2b3c1dffd234d1b593205f69a32

URL: 
https://github.com/llvm/llvm-project/commit/897e345042cdf2b3c1dffd234d1b593205f69a32
DIFF: 
https://github.com/llvm/llvm-project/commit/897e345042cdf2b3c1dffd234d1b593205f69a32.diff

LOG: Revert "[Clang] Add -Wtype-limits to -Wextra for GCC compatibility"

This reverts commit 95668c0d97e6184729f3a3e9621a58d9edffb6b0.

This discovers a warning in
https://reviews.llvm.org/rGa68d4b11465f5b3326be1dd820f59fac275b7581.

and broke the x86_64-linux sanitizer
buildbot: https://lab.llvm.org/buildbot/#/builders/37/builds/19910.

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/DiagnosticGroups.td
clang/test/Sema/tautological-constant-compare.c

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 9d9c5c6cd3f34..9cc2a72f4c864 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -61,9 +61,6 @@ Bug Fixes
   templates. This fixes
   `Issue 60344 `_.
 
-- ``-Wtype-limits`` was added to ``-Wextra`` for GCC compatibility. This fixes
-  `Issue 58375 `_.
-
 Improvements to Clang's diagnostics
 ^^^
 - We now generate a diagnostic for signed integer overflow due to unary minus

diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 39e6c94fe6e29..6c997c37cc5cd 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -992,7 +992,6 @@ def Extra : DiagGroup<"extra", [
 EmptyInitStatement,
 StringConcatation,
 FUseLdPath,
-TypeLimits,
   ]>;
 
 def Most : DiagGroup<"most", [

diff  --git a/clang/test/Sema/tautological-constant-compare.c 
b/clang/test/Sema/tautological-constant-compare.c
index 59094186899dd..04b8a1416be0b 100644
--- a/clang/test/Sema/tautological-constant-compare.c
+++ b/clang/test/Sema/tautological-constant-compare.c
@@ -4,8 +4,8 @@
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only 
-Wtautological-type-limit-compare -DTEST -verify -x c++ %s
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wtype-limits -DTEST 
-verify %s
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wtype-limits -DTEST 
-verify -x c++ %s
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wextra 
-Wno-sign-compare -DTEST -verify %s
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wextra 
-Wno-sign-compare -DTEST -verify -x c++ %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wextra 
-Wno-sign-compare -verify=silent %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wextra 
-Wno-sign-compare -verify=silent -x c++ %s
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wall -verify=silent 
%s
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wall -verify=silent 
-x c++ %s
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -verify=silent %s



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


[clang] 68b8908 - [Clang[NFC] Fix bitmask for NullabilityPayload in Types.h

2023-01-23 Thread Shivam Gupta via cfe-commits

Author: Shivam Gupta
Date: 2023-01-23T20:18:08+05:30
New Revision: 68b890831615fc4350a47cf7ec404156128d03ac

URL: 
https://github.com/llvm/llvm-project/commit/68b890831615fc4350a47cf7ec404156128d03ac
DIFF: 
https://github.com/llvm/llvm-project/commit/68b890831615fc4350a47cf7ec404156128d03ac.diff

LOG: [Clang[NFC] Fix bitmask for NullabilityPayload in Types.h

Found by PVS-Studio - https://pvs-studio.com/en/blog/posts/cpp/1003/, N37.

The code you is using the bit mask NullabilityKindMask which is 0x3
(0011 in binary) to clear the bits in the NullabilityPayload variable.
Since NullabilityPayload is a 64-bit variable and NullabilityKindMask is
only a 8-bit variable(0x3), it will only affect the last 8 bits of the
variable. The higher 56 bits will remain unchanged.

Differential Revision: https://reviews.llvm.org/D142334

Added: 


Modified: 
clang/include/clang/APINotes/Types.h

Removed: 




diff  --git a/clang/include/clang/APINotes/Types.h 
b/clang/include/clang/APINotes/Types.h
index af5f05bc0d365..61f3592ea145b 100644
--- a/clang/include/clang/APINotes/Types.h
+++ b/clang/include/clang/APINotes/Types.h
@@ -482,7 +482,7 @@ inline bool operator!=(const ParamInfo &LHS, const 
ParamInfo &RHS) {
 /// API notes for a function or method.
 class FunctionInfo : public CommonEntityInfo {
 private:
-  static constexpr const unsigned NullabilityKindMask = 0x3;
+  static constexpr const uint64_t NullabilityKindMask = 0x3;
   static constexpr const unsigned NullabilityKindSize = 2;
 
   static constexpr const unsigned ReturnInfoIndex = 0;



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


[clang] 94b9187 - [Clang] Fix a Wbitfield-enum-conversion warning in DirectoryLookup.h

2023-01-23 Thread Shivam Gupta via cfe-commits

Author: Shivam Gupta
Date: 2023-01-23T23:48:48+05:30
New Revision: 94b9187a7d37e4269af35f8f7ec8e0f78fd6a06e

URL: 
https://github.com/llvm/llvm-project/commit/94b9187a7d37e4269af35f8f7ec8e0f78fd6a06e
DIFF: 
https://github.com/llvm/llvm-project/commit/94b9187a7d37e4269af35f8f7ec8e0f78fd6a06e.diff

LOG: [Clang] Fix a Wbitfield-enum-conversion warning in DirectoryLookup.h

When compiling clang/Lex/DirectoryLookup.h with option 
-Wbitfield-enum-conversion, we get the following warning:

DirectoryLookup.h:77:17: warning:
  bit-field 'DirCharacteristic' is not wide enough to store all enumerators 
of
  'CharacteristicKind' [-Wbitfield-enum-conversion]
  : u(Map), DirCharacteristic(DT), LookupType(LT_HeaderMap),

DirCharacteristic is a bitfield with 2 bits (4 values)
  /// DirCharacteristic - The type of directory this is: this is an instance of
  /// SrcMgr::CharacteristicKind.
  unsigned DirCharacteristic : 2;

Whereas SrcMgr::CharacterKind is an enum with 5 values:
enum CharacteristicKind {
  C_User,
  C_System,
  C_ExternCSystem,
  C_User_ModuleMap,
  C_System_ModuleMap
};

Solution is to increase DirCharacteristic bitfield from 2 to 3.
Patch by Dimitri van Heesch

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D142304

Added: 


Modified: 
clang/include/clang/Lex/DirectoryLookup.h

Removed: 




diff  --git a/clang/include/clang/Lex/DirectoryLookup.h 
b/clang/include/clang/Lex/DirectoryLookup.h
index 99f7c507c53e0..d668a830db38f 100644
--- a/clang/include/clang/Lex/DirectoryLookup.h
+++ b/clang/include/clang/Lex/DirectoryLookup.h
@@ -50,7 +50,7 @@ class DirectoryLookup {
 
   /// DirCharacteristic - The type of directory this is: this is an instance of
   /// SrcMgr::CharacteristicKind.
-  unsigned DirCharacteristic : 2;
+  unsigned DirCharacteristic : 3;
 
   /// LookupType - This indicates whether this DirectoryLookup object is a
   /// normal directory, a framework, or a headermap.



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


[clang] 40003af - [Clang][NFC] Remove a redundancy check in Sema::adjustMemberFunctionCC

2023-01-23 Thread Shivam Gupta via cfe-commits

Author: Shivam Gupta
Date: 2023-01-24T11:56:06+05:30
New Revision: 40003af98456607f9b6bd1910424c5243eeb5d01

URL: 
https://github.com/llvm/llvm-project/commit/40003af98456607f9b6bd1910424c5243eeb5d01
DIFF: 
https://github.com/llvm/llvm-project/commit/40003af98456607f9b6bd1910424c5243eeb5d01.diff

LOG: [Clang][NFC] Remove a redundancy check in Sema::adjustMemberFunctionCC

If the current calling convection CurCC is not equal to Target calling
convection ToCC and current calling convention (CurCC) is equal to the
default calling convention (DefaultCC), that means DefaultCC can not be
equal to ToCC so the right part of the expression DefaultCC == ToCC is
not needed.

revelant code -
  if (CurCC == ToCC)
return;
  if (CurCC != DefaultCC || DefaultCC == ToCC)
return;

Found by PVS-Studio - https://pvs-studio.com/en/blog/posts/cpp/1003/, N41.

Differential Revision: https://reviews.llvm.org/D142338

Added: 


Modified: 
clang/lib/Sema/SemaType.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 16986f6f0d0e5..89d819a77dcbb 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -7963,7 +7963,7 @@ void Sema::adjustMemberFunctionCC(QualType &T, bool 
IsStatic, bool IsCtorOrDtor,
 CallingConv DefaultCC =
 Context.getDefaultCallingConvention(IsVariadic, IsStatic);
 
-if (CurCC != DefaultCC || DefaultCC == ToCC)
+if (CurCC != DefaultCC)
   return;
 
 if (hasExplicitCallingConv(T))



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


[clang] a01579a - [NFC] Suggest Release mode in clang GettingStarted.html

2022-06-10 Thread Shivam Gupta via cfe-commits

Author: Shivam Gupta
Date: 2022-06-10T11:00:05+05:30
New Revision: a01579ad0a1bde4d90f4fb656f07586c3097428a

URL: 
https://github.com/llvm/llvm-project/commit/a01579ad0a1bde4d90f4fb656f07586c3097428a
DIFF: 
https://github.com/llvm/llvm-project/commit/a01579ad0a1bde4d90f4fb656f07586c3097428a.diff

LOG: [NFC] Suggest Release mode in clang GettingStarted.html

This fix https://github.com/llvm/llvm-project/issues/23841.
Lots of beginners are not of aware of this option do suggesting it here
would be helpful.

Added: 


Modified: 
clang/www/get_started.html

Removed: 




diff  --git a/clang/www/get_started.html b/clang/www/get_started.html
index ab5f7fac6a6c9..48ce7f8edbbcf 100755
--- a/clang/www/get_started.html
+++ b/clang/www/get_started.html
@@ -69,9 +69,13 @@ On Unix-like Systems
 cd llvm-project
 mkdir build (in-tree build is not supported)
 cd build
-cmake -DLLVM_ENABLE_PROJECTS=clang -G "Unix Makefiles" 
../llvm
+This builds both LLVM and Clang in release mode. Alternatively, if
+you need a debug build, switch Release to Debug. See
+https://llvm.org/docs/CMake.html#frequently-used-cmake-variables";>frequently
 used cmake variables
+for more options.
+
+cmake -DLLVM_ENABLE_PROJECTS=clang -DCMAKE_BUILD_TYPE=Release -G 
"Unix Makefiles" ../llvm
 make
-This builds both LLVM and Clang for debug mode.
 Note: For subsequent Clang development, you can just run
 make clang.
 CMake allows you to generate project files for several IDEs: Xcode,



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


[clang] 48e1829 - [Diagnostics] Fix inconsistent shift-overflow warnings in C++20

2022-06-14 Thread Shivam Gupta via cfe-commits

Author: Shivam Gupta
Date: 2022-06-14T20:19:46+05:30
New Revision: 48e1829874df15fd57e731d4824604f28e177585

URL: 
https://github.com/llvm/llvm-project/commit/48e1829874df15fd57e731d4824604f28e177585
DIFF: 
https://github.com/llvm/llvm-project/commit/48e1829874df15fd57e731d4824604f28e177585.diff

LOG: [Diagnostics] Fix inconsistent shift-overflow warnings in C++20

This fixes https://github.com/llvm/llvm-project/issues/52873.
Don't warn in C++2A mode (and newer), as signed left shifts
always wrap and never overflow. Ref. -
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1236r1.html.

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaExpr.cpp
clang/test/CXX/expr/expr.const/p2-0x.cpp
clang/test/SemaCXX/constant-expression-cxx2a.cpp
clang/test/SemaCXX/shift.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index e68640074cea5..8766adb27a09a 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -256,6 +256,10 @@ Improvements to Clang's diagnostics
 - The ``-Wdeprecated`` diagnostic will now warn on out-of-line ``constexpr``
   declarations downgraded to definitions in C++1z, in addition to the
   existing warning on out-of-line ``const`` declarations.
+- ``-Wshift-overflow`` will not warn for signed left shifts in C++20 mode
+  (and newer), as it will always wrap and never overflow. This fixes
+  `Issue 52873 `_.
+
 
 Non-comprehensive list of changes in this release
 -

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 7e6618bd2d11d..6edf5b355d029 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -11416,10 +11416,16 @@ static void DiagnoseBadShiftValues(Sema& S, 
ExprResult &LHS, ExprResult &RHS,
 return;
   llvm::APSInt Left = LHSResult.Val.getInt();
 
-  // If LHS does not have a signed type and non-negative value
-  // then, the behavior is undefined before C++2a. Warn about it.
-  if (Left.isNegative() && !S.getLangOpts().isSignedOverflowDefined() &&
-  !S.getLangOpts().CPlusPlus20) {
+  // Don't warn if signed overflow is defined, then all the rest of the
+  // diagnostics will not be triggered because the behavior is defined.
+  // Also don't warn in C++20 mode (and newer), as signed left shifts
+  // always wrap and never overflow.
+  if (S.getLangOpts().isSignedOverflowDefined() || S.getLangOpts().CPlusPlus20)
+return;
+
+  // If LHS does not have a non-negative value then, the
+  // behavior is undefined before C++2a. Warn about it.
+  if (Left.isNegative()) {
 S.DiagRuntimeBehavior(Loc, LHS.get(),
   S.PDiag(diag::warn_shift_lhs_negative)
 << LHS.get()->getSourceRange());

diff  --git a/clang/test/CXX/expr/expr.const/p2-0x.cpp 
b/clang/test/CXX/expr/expr.const/p2-0x.cpp
index 81efbb0a47271..6d2bc3f25179b 100644
--- a/clang/test/CXX/expr/expr.const/p2-0x.cpp
+++ b/clang/test/CXX/expr/expr.const/p2-0x.cpp
@@ -162,9 +162,9 @@ namespace UndefinedBehavior {
   constexpr int shl_signed_ok = 1 << 30; // ok
   constexpr int shl_signed_into_sign = 1 << 31; // ok (DR1457)
   constexpr int shl_signed_into_sign_2 = 0x7fff << 1; // ok (DR1457)
-  constexpr int shl_signed_off_end = 2 << 31; // cxx11-error {{constant 
expression}} cxx11-note {{signed left shift discards bits}} expected-warning 
{{signed shift result (0x1) requires 34 bits to represent, but 'int' 
only has 32 bits}}
-  constexpr int shl_signed_off_end_2 = 0x7fff << 2; // cxx11-error 
{{constant expression}} cxx11-note {{signed left shift discards bits}} 
expected-warning {{signed shift result (0x1FFFC) requires 34 bits to 
represent, but 'int' only has 32 bits}}
-  constexpr int shl_signed_overflow = 1024 << 31; // cxx11-error {{constant 
expression}} cxx11-note {{signed left shift discards bits}} expected-warning 
{{requires 43 bits to represent}}
+  constexpr int shl_signed_off_end = 2 << 31; // cxx11-error {{constant 
expression}} cxx11-note {{signed left shift discards bits}} cxx11-warning 
{{signed shift result (0x1) requires 34 bits to represent, but 'int' 
only has 32 bits}}
+  constexpr int shl_signed_off_end_2 = 0x7fff << 2; // cxx11-error 
{{constant expression}} cxx11-note {{signed left shift discards bits}} 
cxx11-warning {{signed shift result (0x1FFFC) requires 34 bits to 
represent, but 'int' only has 32 bits}}
+  constexpr int shl_signed_overflow = 1024 << 31; // cxx11-error {{constant 
expression}} cxx11-note {{signed left shift discards bits}} cxx11-warning 
{{requires 43 bits to represent}}
   constexpr int shl_signed_ok2 = 1024 << 20; // ok
 
   constexpr int shr_m1 = 0 >> -1; // expected-error {{constant expression}} 
expected-note {{negative shift count -1}}

diff  --git a/cl

[clang-tools-extra] 8311604 - [NFC] update clang-tools-extra README.txt

2022-06-10 Thread Shivam Gupta via cfe-commits

Author: Shivam Gupta
Date: 2022-06-10T16:59:57+05:30
New Revision: 8311604669c708f65be7335baba9fd774eef944c

URL: 
https://github.com/llvm/llvm-project/commit/8311604669c708f65be7335baba9fd774eef944c
DIFF: 
https://github.com/llvm/llvm-project/commit/8311604669c708f65be7335baba9fd774eef944c.diff

LOG: [NFC] update clang-tools-extra README.txt

Added: 


Modified: 
clang-tools-extra/README.txt

Removed: 




diff  --git a/clang-tools-extra/README.txt b/clang-tools-extra/README.txt
index 9c859a052c4b..6891e4078997 100644
--- a/clang-tools-extra/README.txt
+++ b/clang-tools-extra/README.txt
@@ -7,9 +7,6 @@ that are developed as part of the LLVM compiler infrastructure 
project and the
 Clang frontend.  These tools are kept in a separate "extra" repository to
 allow lighter weight checkouts of the core Clang codebase.
 
-This repository is only intended to be checked out inside of a full LLVM+Clang
-tree, and in the 'tools/extra' subdirectory of the Clang checkout.
-
 All discussion regarding Clang, Clang-based tools, and code in this repository
 should be held using the standard Clang forum:
   https://discourse.llvm.org/c/clang
@@ -19,4 +16,4 @@ commit lists:
   http://lists.llvm.org/mailman/listinfo/cfe-commits
 
 If you find a bug in these tools, please file it in the LLVM bug tracker:
-  http://llvm.org/bugs/
+  https://github.com/llvm/llvm-project/issues/



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


[clang] [Clang][InstrProf] Allow absolute path in fun.list of -fprofile-list= (PR #67519)

2023-09-26 Thread Shivam Gupta via cfe-commits

https://github.com/xgupta created 
https://github.com/llvm/llvm-project/pull/67519

None

>From 9a38bc6f7322d641daec8d323b502cd09b721c53 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Wed, 27 Sep 2023 11:18:47 +0530
Subject: [PATCH] [Clang][InstrProf] Allow absolute path in fun.list of
 -fprofile-list=

---
 clang/lib/Basic/ProfileList.cpp | 17 -
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Basic/ProfileList.cpp b/clang/lib/Basic/ProfileList.cpp
index 8fa16e2eb069a52..c3cb112cdf83922 100644
--- a/clang/lib/Basic/ProfileList.cpp
+++ b/clang/lib/Basic/ProfileList.cpp
@@ -139,9 +139,24 @@ std::optional
 ProfileList::isFileExcluded(StringRef FileName,
 CodeGenOptions::ProfileInstrKind Kind) const {
   StringRef Section = getSectionName(Kind);
-  // Check for "source:="
+
+  // Convert the input file path to its canonical (absolute) form
+  llvm::SmallString<128> CanonicalFileName(FileName);
+  llvm::sys::fs::make_absolute(CanonicalFileName);
+  llvm::dbgs() << "Parsing -fprofile-list option: " << CanonicalFileName << 
"\n";
+
+  // Check for "source:=" using absolute path
+  if (auto V = inSection(Section, "source", CanonicalFileName))
+return V;
+  // If the absolute path didn't match, try the relative path (FileName)
   if (auto V = inSection(Section, "source", FileName))
 return V;
+
+  if (SCL->inSection(Section, "!src", CanonicalFileName))
+return Forbid;
+  if (SCL->inSection(Section, "src", CanonicalFileName))
+return Allow;
+  // If the absolute path didn't match, try the relative path (FileName)
   if (SCL->inSection(Section, "!src", FileName))
 return Forbid;
   if (SCL->inSection(Section, "src", FileName))

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


[clang] [Clang][InstrProf] Allow absolute path in fun.list of -fprofile-list= (PR #67519)

2023-09-26 Thread Shivam Gupta via cfe-commits

https://github.com/xgupta updated 
https://github.com/llvm/llvm-project/pull/67519

>From 9a38bc6f7322d641daec8d323b502cd09b721c53 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Wed, 27 Sep 2023 11:18:47 +0530
Subject: [PATCH 1/2] [Clang][InstrProf] Allow absolute path in fun.list of
 -fprofile-list=

---
 clang/lib/Basic/ProfileList.cpp | 17 -
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Basic/ProfileList.cpp b/clang/lib/Basic/ProfileList.cpp
index 8fa16e2eb069a52..c3cb112cdf83922 100644
--- a/clang/lib/Basic/ProfileList.cpp
+++ b/clang/lib/Basic/ProfileList.cpp
@@ -139,9 +139,24 @@ std::optional
 ProfileList::isFileExcluded(StringRef FileName,
 CodeGenOptions::ProfileInstrKind Kind) const {
   StringRef Section = getSectionName(Kind);
-  // Check for "source:="
+
+  // Convert the input file path to its canonical (absolute) form
+  llvm::SmallString<128> CanonicalFileName(FileName);
+  llvm::sys::fs::make_absolute(CanonicalFileName);
+  llvm::dbgs() << "Parsing -fprofile-list option: " << CanonicalFileName << 
"\n";
+
+  // Check for "source:=" using absolute path
+  if (auto V = inSection(Section, "source", CanonicalFileName))
+return V;
+  // If the absolute path didn't match, try the relative path (FileName)
   if (auto V = inSection(Section, "source", FileName))
 return V;
+
+  if (SCL->inSection(Section, "!src", CanonicalFileName))
+return Forbid;
+  if (SCL->inSection(Section, "src", CanonicalFileName))
+return Allow;
+  // If the absolute path didn't match, try the relative path (FileName)
   if (SCL->inSection(Section, "!src", FileName))
 return Forbid;
   if (SCL->inSection(Section, "src", FileName))

>From 166e2ad0cb045c3f8970560d215d3cda95532876 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Wed, 27 Sep 2023 11:36:34 +0530
Subject: [PATCH 2/2] clang-format

---
 clang/lib/Basic/ProfileList.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Basic/ProfileList.cpp b/clang/lib/Basic/ProfileList.cpp
index c3cb112cdf83922..ad90651dafc7ef9 100644
--- a/clang/lib/Basic/ProfileList.cpp
+++ b/clang/lib/Basic/ProfileList.cpp
@@ -143,7 +143,8 @@ ProfileList::isFileExcluded(StringRef FileName,
   // Convert the input file path to its canonical (absolute) form
   llvm::SmallString<128> CanonicalFileName(FileName);
   llvm::sys::fs::make_absolute(CanonicalFileName);
-  llvm::dbgs() << "Parsing -fprofile-list option: " << CanonicalFileName << 
"\n";
+  llvm::dbgs() << "Parsing -fprofile-list option: " << CanonicalFileName
+   << "\n";
 
   // Check for "source:=" using absolute path
   if (auto V = inSection(Section, "source", CanonicalFileName))

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


[clang] [Clang][InstrProf] Allow absolute path in fun.list of -fprofile-list= (PR #67519)

2023-09-26 Thread Shivam Gupta via cfe-commits

https://github.com/xgupta updated 
https://github.com/llvm/llvm-project/pull/67519

>From 9a38bc6f7322d641daec8d323b502cd09b721c53 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Wed, 27 Sep 2023 11:18:47 +0530
Subject: [PATCH 1/3] [Clang][InstrProf] Allow absolute path in fun.list of
 -fprofile-list=

---
 clang/lib/Basic/ProfileList.cpp | 17 -
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Basic/ProfileList.cpp b/clang/lib/Basic/ProfileList.cpp
index 8fa16e2eb069a52..c3cb112cdf83922 100644
--- a/clang/lib/Basic/ProfileList.cpp
+++ b/clang/lib/Basic/ProfileList.cpp
@@ -139,9 +139,24 @@ std::optional
 ProfileList::isFileExcluded(StringRef FileName,
 CodeGenOptions::ProfileInstrKind Kind) const {
   StringRef Section = getSectionName(Kind);
-  // Check for "source:="
+
+  // Convert the input file path to its canonical (absolute) form
+  llvm::SmallString<128> CanonicalFileName(FileName);
+  llvm::sys::fs::make_absolute(CanonicalFileName);
+  llvm::dbgs() << "Parsing -fprofile-list option: " << CanonicalFileName << 
"\n";
+
+  // Check for "source:=" using absolute path
+  if (auto V = inSection(Section, "source", CanonicalFileName))
+return V;
+  // If the absolute path didn't match, try the relative path (FileName)
   if (auto V = inSection(Section, "source", FileName))
 return V;
+
+  if (SCL->inSection(Section, "!src", CanonicalFileName))
+return Forbid;
+  if (SCL->inSection(Section, "src", CanonicalFileName))
+return Allow;
+  // If the absolute path didn't match, try the relative path (FileName)
   if (SCL->inSection(Section, "!src", FileName))
 return Forbid;
   if (SCL->inSection(Section, "src", FileName))

>From 166e2ad0cb045c3f8970560d215d3cda95532876 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Wed, 27 Sep 2023 11:36:34 +0530
Subject: [PATCH 2/3] clang-format

---
 clang/lib/Basic/ProfileList.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Basic/ProfileList.cpp b/clang/lib/Basic/ProfileList.cpp
index c3cb112cdf83922..ad90651dafc7ef9 100644
--- a/clang/lib/Basic/ProfileList.cpp
+++ b/clang/lib/Basic/ProfileList.cpp
@@ -143,7 +143,8 @@ ProfileList::isFileExcluded(StringRef FileName,
   // Convert the input file path to its canonical (absolute) form
   llvm::SmallString<128> CanonicalFileName(FileName);
   llvm::sys::fs::make_absolute(CanonicalFileName);
-  llvm::dbgs() << "Parsing -fprofile-list option: " << CanonicalFileName << 
"\n";
+  llvm::dbgs() << "Parsing -fprofile-list option: " << CanonicalFileName
+   << "\n";
 
   // Check for "source:=" using absolute path
   if (auto V = inSection(Section, "source", CanonicalFileName))

>From e801f8a9fe18847ea65e3cbb526e54fc7df5e135 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Wed, 27 Sep 2023 11:37:48 +0530
Subject: [PATCH 3/3] Remove extra debug line

---
 clang/lib/Basic/ProfileList.cpp | 2 --
 1 file changed, 2 deletions(-)

diff --git a/clang/lib/Basic/ProfileList.cpp b/clang/lib/Basic/ProfileList.cpp
index ad90651dafc7ef9..98b8cfabd313b01 100644
--- a/clang/lib/Basic/ProfileList.cpp
+++ b/clang/lib/Basic/ProfileList.cpp
@@ -143,8 +143,6 @@ ProfileList::isFileExcluded(StringRef FileName,
   // Convert the input file path to its canonical (absolute) form
   llvm::SmallString<128> CanonicalFileName(FileName);
   llvm::sys::fs::make_absolute(CanonicalFileName);
-  llvm::dbgs() << "Parsing -fprofile-list option: " << CanonicalFileName
-   << "\n";
 
   // Check for "source:=" using absolute path
   if (auto V = inSection(Section, "source", CanonicalFileName))

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


[clang] [Clang][InstrProf] Allow absolute path in fun.list of -fprofile-list= (PR #67519)

2023-09-26 Thread Shivam Gupta via cfe-commits

https://github.com/xgupta edited https://github.com/llvm/llvm-project/pull/67519
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] dfdfd30 - [Clang] Fix -Wconstant-logical-operand when LHS is a constant

2023-07-18 Thread Shivam Gupta via cfe-commits

Author: Shivam Gupta
Date: 2023-07-19T12:12:11+05:30
New Revision: dfdfd306cfaf54fbc43e2d5eb36489dac3eb9976

URL: 
https://github.com/llvm/llvm-project/commit/dfdfd306cfaf54fbc43e2d5eb36489dac3eb9976
DIFF: 
https://github.com/llvm/llvm-project/commit/dfdfd306cfaf54fbc43e2d5eb36489dac3eb9976.diff

LOG: [Clang] Fix -Wconstant-logical-operand when LHS is a constant

This fix PR37919

The below code produces -Wconstant-logical-operand for the first statement,
but not the second.

void foo(int x) {
if (x && 5) {}
if (5 && x) {}
}

Reviewed By: nickdesaulniers

Differential Revision: https://reviews.llvm.org/D142609

Added: 


Modified: 
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaExpr.cpp
clang/test/C/drs/dr4xx.c
clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p5.cpp
clang/test/Parser/cxx2a-concept-declaration.cpp
clang/test/Sema/exprs.c
clang/test/SemaCXX/expressions.cpp
clang/test/SemaCXX/warn-unsequenced.cpp
clang/test/SemaTemplate/dependent-expr.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 2ffe3783c2f3e7..400b6f71133236 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -12679,6 +12679,8 @@ class Sema final {
   QualType CheckBitwiseOperands( // C99 6.5.[10...12]
   ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
   BinaryOperatorKind Opc);
+  void diagnoseLogicalInsteadOfBitwise(Expr *Op1, Expr *Op2, SourceLocation 
Loc,
+   BinaryOperatorKind Opc);
   QualType CheckLogicalOperands( // C99 6.5.[13,14]
 ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
 BinaryOperatorKind Opc);

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 56e9c4ca133278..87e0939d56ceb2 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -13893,6 +13893,56 @@ inline QualType Sema::CheckBitwiseOperands(ExprResult 
&LHS, ExprResult &RHS,
   return InvalidOperands(Loc, LHS, RHS);
 }
 
+// Diagnose cases where the user write a logical and/or but probably meant a
+// bitwise one.  We do this when one of the operands is a non-bool integer and
+// the other is a constant.
+void Sema::diagnoseLogicalInsteadOfBitwise(Expr *Op1, Expr *Op2,
+   SourceLocation Loc,
+   BinaryOperatorKind Opc) {
+  if (Op1->getType()->isIntegerType() && !Op1->getType()->isBooleanType() &&
+  Op2->getType()->isIntegerType() && !Op2->isValueDependent() &&
+  // Don't warn in macros or template instantiations.
+  !Loc.isMacroID() && !inTemplateInstantiation() &&
+  !Op2->getExprLoc().isMacroID() &&
+  !Op1->getExprLoc().isMacroID()) {
+bool IsOp1InMacro = Op1->getExprLoc().isMacroID();
+bool IsOp2InMacro = Op2->getExprLoc().isMacroID();
+
+// Exclude the specific expression from triggering the warning.
+if (!(IsOp1InMacro && IsOp2InMacro && Op1->getSourceRange() == 
Op2->getSourceRange())) {
+// If the RHS can be constant folded, and if it constant folds to something
+// that isn't 0 or 1 (which indicate a potential logical operation that
+// happened to fold to true/false) then warn.
+// Parens on the RHS are ignored.
+// If the RHS can be constant folded, and if it constant folds to something
+// that isn't 0 or 1 (which indicate a potential logical operation that
+// happened to fold to true/false) then warn.
+// Parens on the RHS are ignored.
+Expr::EvalResult EVResult;
+if (Op2->EvaluateAsInt(EVResult, Context)) {
+  llvm::APSInt Result = EVResult.Val.getInt();
+  if ((getLangOpts().Bool && !Op2->getType()->isBooleanType() &&
+   !Op2->getExprLoc().isMacroID()) ||
+  (Result != 0 && Result != 1)) {
+Diag(Loc, diag::warn_logical_instead_of_bitwise)
+<< Op2->getSourceRange() << (Opc == BO_LAnd ? "&&" : "||");
+// Suggest replacing the logical operator with the bitwise version
+Diag(Loc, diag::note_logical_instead_of_bitwise_change_operator)
+<< (Opc == BO_LAnd ? "&" : "|")
+<< FixItHint::CreateReplacement(
+   SourceRange(Loc, getLocForEndOfToken(Loc)),
+   Opc == BO_LAnd ? "&" : "|");
+if (Opc == BO_LAnd)
+  // Suggest replacing "Foo() && kNonZero" with "Foo()"
+  Diag(Loc, diag::note_logical_instead_of_bitwise_remove_constant)
+  << FixItHint::CreateRemoval(SourceRange(
+ getLocForEndOfToken(Op1->getEndLoc()), Op2->getEndLoc()));
+  }
+}
+  }
+  }
+}
+
 // C99 6.5.[13,14]
 inline QualType Sema::CheckLogicalOperands(ExprResult &LHS, ExprResult &RHS,
SourceLocation Loc,
@@ -13911,9 +13961,6 @@ inline QualType Sema::CheckLogicalOperands(ExprResult 
&LHS, 

[clang] 061e855 - [clang][Docs] Added release note for D142609

2023-07-19 Thread Shivam Gupta via cfe-commits

Author: Shivam Gupta
Date: 2023-07-19T15:00:24+05:30
New Revision: 061e855767dbe0821d81a8d47158f468dd00ae5f

URL: 
https://github.com/llvm/llvm-project/commit/061e855767dbe0821d81a8d47158f468dd00ae5f
DIFF: 
https://github.com/llvm/llvm-project/commit/061e855767dbe0821d81a8d47158f468dd00ae5f.diff

LOG: [clang][Docs] Added release note for D142609

Added: 


Modified: 
clang/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 805b0f5697f759..d09bffb0e25062 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -441,6 +441,9 @@ Improvements to Clang's diagnostics
 - ``-Wformat`` will no longer suggest a no-op fix-it for fixing scoped enum 
format
   warnings. Instead, it will suggest casting the enum object to the type 
specified
   in the format string.
+- Clang now emits ``-Wconstant-logical-operand`` warning even when constant 
logical
+  operand is on left side.
+  (`#37919 `_)
 
 Bug Fixes in This Version
 -



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


[clang-tools-extra] 4754407 - [clang-tidy][clang-tidy-diff.py] Change shebang from python to python3

2023-07-23 Thread Shivam Gupta via cfe-commits

Author: Shivam Gupta
Date: 2023-07-23T19:24:11+05:30
New Revision: 475440703238ca32adab6c3fe5e0039c3f96d1a5

URL: 
https://github.com/llvm/llvm-project/commit/475440703238ca32adab6c3fe5e0039c3f96d1a5
DIFF: 
https://github.com/llvm/llvm-project/commit/475440703238ca32adab6c3fe5e0039c3f96d1a5.diff

LOG: [clang-tidy][clang-tidy-diff.py] Change shebang from python to python3

Added: 


Modified: 
clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/tool/clang-tidy-
diff .py b/clang-tools-extra/clang-tidy/tool/clang-tidy-
diff .py
index 45c28d963b849a..c8a83bd49f0d2e 100755
--- a/clang-tools-extra/clang-tidy/tool/clang-tidy-
diff .py
+++ b/clang-tools-extra/clang-tidy/tool/clang-tidy-
diff .py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # ===- clang-tidy-
diff .py - ClangTidy Diff Checker ---*- python -*--===#
 #



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


[clang-tools-extra] 1e51268 - [clang-tidy] performance-* checks: Also allow allow member expressions to be used in a const manner.

2023-07-23 Thread Shivam Gupta via cfe-commits

Author: Shivam Gupta
Date: 2023-07-24T00:08:29+05:30
New Revision: 1e512688376c83d96f097e9b0ddb19132247a646

URL: 
https://github.com/llvm/llvm-project/commit/1e512688376c83d96f097e9b0ddb19132247a646
DIFF: 
https://github.com/llvm/llvm-project/commit/1e512688376c83d96f097e9b0ddb19132247a646.diff

LOG: [clang-tidy] performance-* checks: Also allow allow member expressions to 
be used in a const manner.

Until now when determining all the const uses of a VarDecl we only considered
how the variable itself was used. This change extends checking for const usages
of the type's members as well.

This increases the number of true positives for various performance checks that
share the same const usage analysis.

Path by Felix Berger

Reviewed By: njames93, PiotrZSL

Differential Revision: https://reviews.llvm.org/D97567

Added: 


Modified: 
clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/test/clang-tidy/checkers/performance/for-range-copy.cpp

clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-initialization.cpp
clang-tools-extra/unittests/clang-tidy/DeclRefExprUtilsTest.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp 
b/clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
index 891529997787db..2d73179150e8b8 100644
--- a/clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
+++ b/clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
@@ -43,14 +43,19 @@ constReferenceDeclRefExprs(const VarDecl &VarDecl, const 
Stmt &Stmt,
ASTContext &Context) {
   auto DeclRefToVar =
   declRefExpr(to(varDecl(equalsNode(&VarDecl.bind("declRef");
+  auto MemberExprOfVar = memberExpr(hasObjectExpression(DeclRefToVar));
+  auto DeclRefToVarOrMemberExprOfVar =
+  stmt(anyOf(DeclRefToVar, MemberExprOfVar));
   auto ConstMethodCallee = callee(cxxMethodDecl(isConst()));
   // Match method call expressions where the variable is referenced as the this
   // implicit object argument and operator call expression for member operators
   // where the variable is the 0-th argument.
   auto Matches = match(
-  findAll(expr(anyOf(cxxMemberCallExpr(ConstMethodCallee, 
on(DeclRefToVar)),
- cxxOperatorCallExpr(ConstMethodCallee,
- hasArgument(0, DeclRefToVar),
+  findAll(expr(anyOf(
+  cxxMemberCallExpr(ConstMethodCallee,
+on(DeclRefToVarOrMemberExprOfVar)),
+  cxxOperatorCallExpr(ConstMethodCallee,
+  hasArgument(0, 
DeclRefToVarOrMemberExprOfVar),
   Stmt, Context);
   SmallPtrSet DeclRefs;
   extractNodesByIdTo(Matches, "declRef", DeclRefs);
@@ -62,22 +67,23 @@ constReferenceDeclRefExprs(const VarDecl &VarDecl, const 
Stmt &Stmt,
   ConstReferenceOrValue,
   substTemplateTypeParmType(hasReplacementType(ConstReferenceOrValue;
   auto UsedAsConstRefOrValueArg = forEachArgumentWithParam(
-  DeclRefToVar, parmVarDecl(hasType(ConstReferenceOrValueOrReplaced)));
+  DeclRefToVarOrMemberExprOfVar,
+  parmVarDecl(hasType(ConstReferenceOrValueOrReplaced)));
   Matches = match(findAll(invocation(UsedAsConstRefOrValueArg)), Stmt, 
Context);
   extractNodesByIdTo(Matches, "declRef", DeclRefs);
   // References and pointers to const assignments.
-  Matches =
-  match(findAll(declStmt(
-has(varDecl(hasType(qualType(matchers::isReferenceToConst())),
-hasInitializer(ignoringImpCasts(DeclRefToVar)),
-Stmt, Context);
+  Matches = match(
+  findAll(declStmt(has(varDecl(
+  hasType(qualType(matchers::isReferenceToConst())),
+  hasInitializer(ignoringImpCasts(DeclRefToVarOrMemberExprOfVar)),
+  Stmt, Context);
   extractNodesByIdTo(Matches, "declRef", DeclRefs);
-  Matches =
-  match(findAll(declStmt(has(varDecl(
-hasType(qualType(matchers::isPointerToConst())),
-hasInitializer(ignoringImpCasts(unaryOperator(
-hasOperatorName("&"), hasUnaryOperand(DeclRefToVar,
-Stmt, Context);
+  Matches = match(findAll(declStmt(has(varDecl(
+  hasType(qualType(matchers::isPointerToConst())),
+  hasInitializer(ignoringImpCasts(unaryOperator(
+  hasOperatorName("&"),
+  
hasUnaryOperand(DeclRefToVarOrMemberExprOfVar,
+  Stmt, Context);
   extractNodesByIdTo(Matches, "declRef", DeclRefs);
   return DeclRefs;
 }

diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 2cc0010884a7a0..53b987ccab42e7 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -432,6 

[clang] a845252 - Revert "[Clang] Fix -Wconstant-logical-operand when LHS is a constant"

2023-08-07 Thread Shivam Gupta via cfe-commits

Author: Shivam Gupta
Date: 2023-08-08T08:00:02+05:30
New Revision: a84525233776a716e2c6291993f0b33fd1c76f7c

URL: 
https://github.com/llvm/llvm-project/commit/a84525233776a716e2c6291993f0b33fd1c76f7c
DIFF: 
https://github.com/llvm/llvm-project/commit/a84525233776a716e2c6291993f0b33fd1c76f7c.diff

LOG: Revert "[Clang] Fix -Wconstant-logical-operand when LHS is a constant"

This reverts commit dfdfd306cfaf54fbc43e2d5eb36489dac3eb9976.

An issue is reported for wrong warning, this has to be reconsidered.

Differential Revision: https://reviews.llvm.org/D157352

Added: 


Modified: 
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaExpr.cpp
clang/test/C/drs/dr4xx.c
clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p5.cpp
clang/test/Parser/cxx2a-concept-declaration.cpp
clang/test/Sema/exprs.c
clang/test/SemaCXX/expressions.cpp
clang/test/SemaCXX/warn-unsequenced.cpp
clang/test/SemaTemplate/dependent-expr.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 44bd3c4cf3a665..4cd58ba071283a 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -12728,8 +12728,6 @@ class Sema final {
   QualType CheckBitwiseOperands( // C99 6.5.[10...12]
   ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
   BinaryOperatorKind Opc);
-  void diagnoseLogicalInsteadOfBitwise(Expr *Op1, Expr *Op2, SourceLocation 
Loc,
-   BinaryOperatorKind Opc);
   QualType CheckLogicalOperands( // C99 6.5.[13,14]
 ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
 BinaryOperatorKind Opc);

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index b37e8598249944..c1c6a34e8bc84f 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -13880,56 +13880,6 @@ inline QualType Sema::CheckBitwiseOperands(ExprResult 
&LHS, ExprResult &RHS,
   return InvalidOperands(Loc, LHS, RHS);
 }
 
-// Diagnose cases where the user write a logical and/or but probably meant a
-// bitwise one.  We do this when one of the operands is a non-bool integer and
-// the other is a constant.
-void Sema::diagnoseLogicalInsteadOfBitwise(Expr *Op1, Expr *Op2,
-   SourceLocation Loc,
-   BinaryOperatorKind Opc) {
-  if (Op1->getType()->isIntegerType() && !Op1->getType()->isBooleanType() &&
-  Op2->getType()->isIntegerType() && !Op2->isValueDependent() &&
-  // Don't warn in macros or template instantiations.
-  !Loc.isMacroID() && !inTemplateInstantiation() &&
-  !Op2->getExprLoc().isMacroID() && !Op1->getExprLoc().isMacroID()) {
-bool IsOp1InMacro = Op1->getExprLoc().isMacroID();
-bool IsOp2InMacro = Op2->getExprLoc().isMacroID();
-
-// Exclude the specific expression from triggering the warning.
-if (!(IsOp1InMacro && IsOp2InMacro &&
-  Op1->getSourceRange() == Op2->getSourceRange())) {
-  // If the RHS can be constant folded, and if it constant folds to
-  // something that isn't 0 or 1 (which indicate a potential logical
-  // operation that happened to fold to true/false) then warn. Parens on 
the
-  // RHS are ignored. If the RHS can be constant folded, and if it constant
-  // folds to something that isn't 0 or 1 (which indicate a potential
-  // logical operation that happened to fold to true/false) then warn.
-  // Parens on the RHS are ignored.
-  Expr::EvalResult EVResult;
-  if (Op2->EvaluateAsInt(EVResult, Context)) {
-llvm::APSInt Result = EVResult.Val.getInt();
-if ((getLangOpts().Bool && !Op2->getType()->isBooleanType() &&
- !Op2->getExprLoc().isMacroID()) ||
-(Result != 0 && Result != 1)) {
-  Diag(Loc, diag::warn_logical_instead_of_bitwise)
-  << Op2->getSourceRange() << (Opc == BO_LAnd ? "&&" : "||");
-  // Suggest replacing the logical operator with the bitwise version
-  Diag(Loc, diag::note_logical_instead_of_bitwise_change_operator)
-  << (Opc == BO_LAnd ? "&" : "|")
-  << FixItHint::CreateReplacement(
- SourceRange(Loc, getLocForEndOfToken(Loc)),
- Opc == BO_LAnd ? "&" : "|");
-  if (Opc == BO_LAnd)
-// Suggest replacing "Foo() && kNonZero" with "Foo()"
-Diag(Loc, diag::note_logical_instead_of_bitwise_remove_constant)
-<< FixItHint::CreateRemoval(
-   SourceRange(getLocForEndOfToken(Op1->getEndLoc()),
-   Op2->getEndLoc()));
-}
-  }
-}
-  }
-}
-
 // C99 6.5.[13,14]
 inline QualType Sema::CheckLogicalOperands(ExprResult &LHS, ExprResult &RHS,
SourceLocation Loc,
@@ -13948,6 +13898,9 @@ inline QualType Sema::CheckLo

[clang-tools-extra] 42179bb - [clang-tidy] Add check for possibly incomplete switch statements

2023-07-16 Thread Shivam Gupta via cfe-commits

Author: Shivam Gupta
Date: 2023-07-17T10:40:11+05:30
New Revision: 42179bbf6bcc9f90256b443c30f5e99f862bc2f6

URL: 
https://github.com/llvm/llvm-project/commit/42179bbf6bcc9f90256b443c30f5e99f862bc2f6
DIFF: 
https://github.com/llvm/llvm-project/commit/42179bbf6bcc9f90256b443c30f5e99f862bc2f6.diff

LOG: [clang-tidy] Add check for possibly incomplete switch statements

While clang warns about a possibly incomplete switch statement when switching 
over an enum variable and failing to cover all enum values (either explicitly 
or with a default case), no such warning is emitted if a plain integer variable 
is used as switch variable.

Add a clang-tidy check to diagnose these scenarios.

No fixit hint is provided since there are multiple possible solutions.

Differential Revision: https://reviews.llvm.org/D4784

Added: 
clang-tools-extra/clang-tidy/bugprone/SwitchMissingDefaultCaseCheck.cpp
clang-tools-extra/clang-tidy/bugprone/SwitchMissingDefaultCaseCheck.h

clang-tools-extra/docs/clang-tidy/checks/bugprone/switch-missing-default-case.rst

clang-tools-extra/test/clang-tidy/checkers/bugprone/switch-missing-default-case.cpp

Modified: 
clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/checks/list.rst

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp 
b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
index e62e536555c29c..7509e94950e10e 100644
--- a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
@@ -65,6 +65,7 @@
 #include "SuspiciousSemicolonCheck.h"
 #include "SuspiciousStringCompareCheck.h"
 #include "SwappedArgumentsCheck.h"
+#include "SwitchMissingDefaultCaseCheck.h"
 #include "TerminatingContinueCheck.h"
 #include "ThrowKeywordMissingCheck.h"
 #include "TooSmallLoopVariableCheck.h"
@@ -116,6 +117,8 @@ class BugproneModule : public ClangTidyModule {
 "bugprone-implicit-widening-of-multiplication-result");
 CheckFactories.registerCheck(
 "bugprone-inaccurate-erase");
+CheckFactories.registerCheck(
+"bugprone-switch-missing-default-case");
 CheckFactories.registerCheck(
 "bugprone-incorrect-roundings");
 CheckFactories.registerCheck("bugprone-infinite-loop");

diff  --git a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
index 363d1a85b0ae51..8bd892eeb41ecd 100644
--- a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
@@ -21,6 +21,7 @@ add_clang_library(clangTidyBugproneModule
   ForwardingReferenceOverloadCheck.cpp
   ImplicitWideningOfMultiplicationResultCheck.cpp
   InaccurateEraseCheck.cpp
+  SwitchMissingDefaultCaseCheck.cpp
   IncorrectRoundingsCheck.cpp
   InfiniteLoopCheck.cpp
   IntegerDivisionCheck.cpp

diff  --git 
a/clang-tools-extra/clang-tidy/bugprone/SwitchMissingDefaultCaseCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/SwitchMissingDefaultCaseCheck.cpp
new file mode 100644
index 00..d1d50fe26b29e1
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/bugprone/SwitchMissingDefaultCaseCheck.cpp
@@ -0,0 +1,47 @@
+//===--- SwitchMissingDefaultCaseCheck.cpp - clang-tidy 
---===//
+//
+// 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
+//
+//===--===//
+
+#include "SwitchMissingDefaultCaseCheck.h"
+#include "clang/AST/ASTContext.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::bugprone {
+
+namespace {
+
+AST_MATCHER(SwitchStmt, hasDefaultCase) {
+  const SwitchCase *Case = Node.getSwitchCaseList();
+  while (Case) {
+if (DefaultStmt::classof(Case))
+  return true;
+
+Case = Case->getNextSwitchCase();
+  }
+  return false;
+}
+} // namespace
+
+void SwitchMissingDefaultCaseCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(
+  switchStmt(hasCondition(expr(unless(isInstantiationDependent()),
+   hasType(qualType(hasCanonicalType(
+   unless(hasDeclaration(enumDecl(,
+ unless(hasDefaultCase()))
+  .bind("switch"),
+  this);
+}
+
+void SwitchMissingDefaultCaseCheck::check(
+const ast_matchers::MatchFinder::MatchResult &Result) {
+  const auto *Switch = Result.Nodes.getNodeAs("switch");
+
+  diag(Switch->getSwitchLoc(), "switching on non-enum value without "
+   "default case may not cover all cases");
+}
+} // namespace cla

[clang] 64ae766 - [Docs] Update ClangFormatStyleOptions.rst's versionbadge's to have min-width

2023-04-14 Thread Shivam Gupta via cfe-commits

Author: Shivam Gupta
Date: 2023-04-14T23:57:26+05:30
New Revision: 64ae7669a7cefa12ea1117680cf9bfb5c3f6084c

URL: 
https://github.com/llvm/llvm-project/commit/64ae7669a7cefa12ea1117680cf9bfb5c3f6084c
DIFF: 
https://github.com/llvm/llvm-project/commit/64ae7669a7cefa12ea1117680cf9bfb5c3f6084c.diff

LOG: [Docs] Update ClangFormatStyleOptions.rst's versionbadge's to have 
min-width

This fix https://github.com/llvm/llvm-project/issues/61934

By default, the width property is used to set the width of a table column.
However, if the content of a cell in that column is wider than the width
specified by the width property, the cell's content will overflow the
column and the table will become wider than the specified width.
This causes the version numbers to be displayed outside of their table cells.

Using the min-width property instead of width ensures that the column is
wide enough to accommodate the content of its cells. If a cell's content is
wider than the specified min-width, the column will expand to fit the content.

Added: 


Modified: 
clang/docs/ClangFormatStyleOptions.rst

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index 899d5b2df6031..2e9038933c814 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -7,7 +7,7 @@
 .. raw:: html
 
   
-.versionbadge { background-color: #1c913d; height: 20px; display: 
inline-block; width: 120px; text-align: center; border-radius: 5px; color: 
#FF; font-family: "Verdana,Geneva,DejaVu Sans,sans-serif"; }
+.versionbadge { background-color: #1c913d; height: 20px; display: 
inline-block; min-width: 120px; text-align: center; border-radius: 5px; color: 
#FF; font-family: "Verdana,Geneva,DejaVu Sans,sans-serif"; }
   
 
 .. role:: versionbadge



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


[clang] 7261991 - [clang-rename] Exit gracefully when no input provided

2023-04-16 Thread Shivam Gupta via cfe-commits

Author: Shivam Gupta
Date: 2023-04-17T10:23:53+05:30
New Revision: 726199146a0bb53315ade042e759c65e6d96d556

URL: 
https://github.com/llvm/llvm-project/commit/726199146a0bb53315ade042e759c65e6d96d556
DIFF: 
https://github.com/llvm/llvm-project/commit/726199146a0bb53315ade042e759c65e6d96d556.diff

LOG: [clang-rename] Exit gracefully when no input provided

clang-rename on a non existing file segfaults

Command to run -
$ clang-rename -offset=0 -new-name=plop asdasd

Error while processing llvm-project/asdasd.
clang-rename: llvm-project/llvm/include/llvm/Support/ErrorOr.h:237:
llvm::ErrorOr::storage_type* llvm::ErrorOr::getStorage()
[with T = const clang::FileEntry*; llvm::ErrorOr::storage_type = const 
clang::FileEntry*]:
Assertion `!HasError && "Cannot get value when an error exists!"' failed.

[1]827497 IOT instruction  clang-rename -offset=0 -new-name=plop asdasd

Differential Revision: https://reviews.llvm.org/D148439

Added: 


Modified: 
clang/tools/clang-rename/ClangRename.cpp

Removed: 




diff  --git a/clang/tools/clang-rename/ClangRename.cpp 
b/clang/tools/clang-rename/ClangRename.cpp
index e7ceac7dbf30..7ba1978f0774 100644
--- a/clang/tools/clang-rename/ClangRename.cpp
+++ b/clang/tools/clang-rename/ClangRename.cpp
@@ -126,6 +126,9 @@ int main(int argc, const char **argv) {
 SymbolOffsets.push_back(Info.Offset);
   NewNames.push_back(Info.NewName);
 }
+  } else {
+errs() << "clang-rename: input must be provided.\n";
+return 1;
   }
 
   // Check the arguments for correctness.



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


[clang] 06387f9 - Revert "[clang-rename] Exit gracefully when no input provided"

2023-04-16 Thread Shivam Gupta via cfe-commits

Author: Shivam Gupta
Date: 2023-04-17T10:31:40+05:30
New Revision: 06387f94cfdf6bbd37ac3b925a50410e11a1fc9d

URL: 
https://github.com/llvm/llvm-project/commit/06387f94cfdf6bbd37ac3b925a50410e11a1fc9d
DIFF: 
https://github.com/llvm/llvm-project/commit/06387f94cfdf6bbd37ac3b925a50410e11a1fc9d.diff

LOG: Revert "[clang-rename] Exit gracefully when no input provided"

This reverts commit 726199146a0bb53315ade042e759c65e6d96d556.

This broke the buildbot -
https://lab.llvm.org/buildbot#builders/139/builds/39267

Added: 


Modified: 
clang/tools/clang-rename/ClangRename.cpp

Removed: 




diff  --git a/clang/tools/clang-rename/ClangRename.cpp 
b/clang/tools/clang-rename/ClangRename.cpp
index 7ba1978f0774..e7ceac7dbf30 100644
--- a/clang/tools/clang-rename/ClangRename.cpp
+++ b/clang/tools/clang-rename/ClangRename.cpp
@@ -126,9 +126,6 @@ int main(int argc, const char **argv) {
 SymbolOffsets.push_back(Info.Offset);
   NewNames.push_back(Info.NewName);
 }
-  } else {
-errs() << "clang-rename: input must be provided.\n";
-return 1;
   }
 
   // Check the arguments for correctness.



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


[clang] dd6a58b - [Sema] Avoid emitting warnings for constant destruction.

2023-05-06 Thread Shivam Gupta via cfe-commits

Author: Peter Kasting
Date: 2023-05-06T20:54:22+05:30
New Revision: dd6a58babc853d180b9a7e5bd709ae12477da004

URL: 
https://github.com/llvm/llvm-project/commit/dd6a58babc853d180b9a7e5bd709ae12477da004
DIFF: 
https://github.com/llvm/llvm-project/commit/dd6a58babc853d180b9a7e5bd709ae12477da004.diff

LOG: [Sema] Avoid emitting warnings for constant destruction.

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

Reviewed By: rsmith

Differential Revision: https://reviews.llvm.org/D149713

Added: 


Modified: 
clang/lib/Sema/SemaDeclCXX.cpp
clang/test/SemaCXX/warn-exit-time-destructors.cpp
clang/test/SemaCXX/warn-global-constructors.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index dcb3e676b0ba4..31936bce78621 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -15732,7 +15732,8 @@ void Sema::FinalizeVarWithDestructor(VarDecl *VD, const 
RecordType *Record) {
 }
   }
 
-  if (!VD->hasGlobalStorage()) return;
+  if (!VD->hasGlobalStorage() || !VD->needsDestruction(Context))
+return;
 
   // Emit warning for non-trivial dtor in global scope (a real global,
   // class-static, function-static).

diff  --git a/clang/test/SemaCXX/warn-exit-time-destructors.cpp 
b/clang/test/SemaCXX/warn-exit-time-destructors.cpp
index 17b3a9406369f..2f14243cb48c4 100644
--- a/clang/test/SemaCXX/warn-exit-time-destructors.cpp
+++ b/clang/test/SemaCXX/warn-exit-time-destructors.cpp
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -std=c++11 -fsyntax-only -Wexit-time-destructors %s -verify
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -Wexit-time-destructors %s 
-verify=expected,cxx11
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -Wexit-time-destructors %s 
-verify=expected
 
 namespace test1 {
   struct A { ~A(); };
@@ -48,3 +49,22 @@ namespace test4 {
 struct A { ~A(); };
 [[clang::no_destroy]] A a; // no warning
 }
+
+namespace test5 {
+#if __cplusplus >= 202002L
+#define CPP20_CONSTEXPR constexpr
+#else
+#define CPP20_CONSTEXPR
+#endif
+  struct S {
+CPP20_CONSTEXPR ~S() {}
+  };
+  S s; // cxx11-warning {{exit-time destructor}}
+
+  struct T {
+CPP20_CONSTEXPR ~T() { if (b) {} }
+bool b;
+  };
+  T t; // expected-warning {{exit-time destructor}}
+#undef CPP20_CONSTEXPR
+}

diff  --git a/clang/test/SemaCXX/warn-global-constructors.cpp 
b/clang/test/SemaCXX/warn-global-constructors.cpp
index 430f239a3ed7e..765654b5e9f4f 100644
--- a/clang/test/SemaCXX/warn-global-constructors.cpp
+++ b/clang/test/SemaCXX/warn-global-constructors.cpp
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -std=c++11 -fsyntax-only -Wglobal-constructors %s -verify
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -Wglobal-constructors %s 
-verify=expected,cxx11
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -Wglobal-constructors %s 
-verify=expected
 
 int opaque_int();
 
@@ -145,3 +146,22 @@ namespace bitfields {
   const HasUnnamedBitfield nonConstexprConst{1}; // expected-warning {{global 
constructor}}
   HasUnnamedBitfield nonConstexprMutable{1}; // expected-warning {{global 
constructor}}
 }
+
+namespace test7 {
+#if __cplusplus >= 202002L
+#define CPP20_CONSTEXPR constexpr
+#else
+#define CPP20_CONSTEXPR
+#endif
+  struct S {
+CPP20_CONSTEXPR ~S() {}
+  };
+  S s; // cxx11-warning {{global destructor}}
+
+  struct T {
+CPP20_CONSTEXPR ~T() { if (b) {} }
+bool b;
+  };
+  T t; // expected-warning {{global destructor}}
+#undef CPP20_CONSTEXPR
+}



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


[clang] c1ab198 - [Clang][OpenMP]Solved the the always truth condition in Arm64

2023-05-06 Thread Shivam Gupta via cfe-commits

Author: Samuel Maina
Date: 2023-05-06T22:00:00+05:30
New Revision: c1ab19850d5c42a6f76d9bd6049f9cba6e08fba1

URL: 
https://github.com/llvm/llvm-project/commit/c1ab19850d5c42a6f76d9bd6049f9cba6e08fba1
DIFF: 
https://github.com/llvm/llvm-project/commit/c1ab19850d5c42a6f76d9bd6049f9cba6e08fba1.diff

LOG: [Clang][OpenMP]Solved the the always truth condition in Arm64

There was a bug in the getAArch64MTV function on the third if statement which 
returns truth  as reported by this issue [[ 
https://github.com/llvm/llvm-project/issues/61319 |[Clang] Condition is always 
true which is caused by a possible copy-pasted bug in CGOpenMPRuntime.cpp
 ]].
All the testcases are passing. The first unit tests I could find are for 
functions that are 6 levels from this issue. The function is very low level and 
couldn't find a way to affect it from the higher functions.

Reviewed By: jhuber6

Differential Revision: https://reviews.llvm.org/D146370

Added: 


Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index ce92aa21e0fc5..a74f63cd1fac9 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -11160,7 +11160,7 @@ static bool getAArch64MTV(QualType QT, ParamKindTy 
Kind) {
   if (Kind == ParamKindTy::Uniform)
 return false;
 
-  if (Kind == ParamKindTy::LinearUVal || ParamKindTy::LinearRef)
+  if (Kind == ParamKindTy::LinearUVal || Kind == ParamKindTy::LinearRef)
 return false;
 
   if ((Kind == ParamKindTy::Linear || Kind == ParamKindTy::LinearVal) &&



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


[clang] 62eec15 - [clang-rename] Exit gracefully when no input provided

2023-04-26 Thread Shivam Gupta via cfe-commits

Author: Shivam Gupta
Date: 2023-04-26T20:23:14+05:30
New Revision: 62eec1584d2cd7634c31d4b82215fa8e260cf3b8

URL: 
https://github.com/llvm/llvm-project/commit/62eec1584d2cd7634c31d4b82215fa8e260cf3b8
DIFF: 
https://github.com/llvm/llvm-project/commit/62eec1584d2cd7634c31d4b82215fa8e260cf3b8.diff

LOG: [clang-rename] Exit gracefully when no input provided

clang-rename on a non existing file segfaults

Command to run -
$ clang-rename -offset=0 -new-name=plop asdasd

Error while processing llvm-project/asdasd.
clang-rename: llvm-project/llvm/include/llvm/Support/ErrorOr.h:237:
llvm::ErrorOr::storage_type* llvm::ErrorOr::getStorage()
[with T = const clang::FileEntry*; llvm::ErrorOr::storage_type = const 
clang::FileEntry*]:
Assertion `!HasError && "Cannot get value when an error exists!"' failed.

[1]827497 IOT instruction  clang-rename -offset=0 -new-name=plop asdasd

This fixes https://github.com/llvm/llvm-project/issues/36471.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D148439

Added: 
clang/test/clang-rename/NonExistFile.cpp

Modified: 
clang/docs/ReleaseNotes.rst
clang/tools/clang-rename/ClangRename.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 55ec1cdef52fa..7dfca82c00876 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -235,6 +235,8 @@ Improvements to Clang's diagnostics
 Bug Fixes in This Version
 -
 
+- Fix segfault while running clang-rename on a non existing file.
+  (`#36471 `_)
 - Fix crash when diagnosing incorrect usage of ``_Nullable`` involving alias
   templates.
   (`#60344 `_)

diff  --git a/clang/test/clang-rename/NonExistFile.cpp 
b/clang/test/clang-rename/NonExistFile.cpp
new file mode 100644
index 0..f45839be80473
--- /dev/null
+++ b/clang/test/clang-rename/NonExistFile.cpp
@@ -0,0 +1,2 @@
+// RUN: not clang-rename -offset=0 -new-name=bar non-existing-file 2>&1 | 
FileCheck %s
+// CHECK: clang-rename: non-existing-file does not exist.

diff  --git a/clang/tools/clang-rename/ClangRename.cpp 
b/clang/tools/clang-rename/ClangRename.cpp
index e7ceac7dbf303..24c9d8521dc27 100644
--- a/clang/tools/clang-rename/ClangRename.cpp
+++ b/clang/tools/clang-rename/ClangRename.cpp
@@ -229,6 +229,10 @@ int main(int argc, const char **argv) {
 Tool.applyAllReplacements(Rewrite);
 for (const auto &File : Files) {
   auto Entry = FileMgr.getFile(File);
+  if (!Entry) {
+errs() << "clang-rename: " << File << " does not exist.\n";
+return 1;
+  }
   const auto ID = Sources.getOrCreateFileID(*Entry, SrcMgr::C_User);
   Rewrite.getEditBuffer(ID).write(outs());
 }



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


[clang] a704854 - [Clang][Doc] Added an open project for improving command line docs

2023-04-28 Thread Shivam Gupta via cfe-commits

Author: Shivam Gupta
Date: 2023-04-28T23:32:37+05:30
New Revision: a70485493803d2e22cbc79184b78861b098ba416

URL: 
https://github.com/llvm/llvm-project/commit/a70485493803d2e22cbc79184b78861b098ba416
DIFF: 
https://github.com/llvm/llvm-project/commit/a70485493803d2e22cbc79184b78861b098ba416.diff

LOG: [Clang][Doc] Added an open project for improving command line docs

There seems to be a lot of documentation is missing
for different command line flags uses.
This create confusion with same looking options, better to
document clearly their uses.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D149405

Added: 


Modified: 
clang/www/OpenProjects.html

Removed: 




diff  --git a/clang/www/OpenProjects.html b/clang/www/OpenProjects.html
index 4b6b0283767c0..77f04160700fc 100755
--- a/clang/www/OpenProjects.html
+++ b/clang/www/OpenProjects.html
@@ -38,6 +38,8 @@ Open Clang Projects
   documenting https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Basic/DiagnosticDocs.td";>
   diagnostic group flags (adding code examples of what is diagnosed, or
   other relevant information), or
+  documenting https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Driver/Options.td";>
+  command line options, or
   help with completing other missing documentation.
 
 These projects are independent of each other.



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


[clang] 85ed0fb - Basic documentation of -mrecip=... option

2023-04-30 Thread Shivam Gupta via cfe-commits

Author: Tim Schmielau
Date: 2023-05-01T07:43:00+05:30
New Revision: 85ed0fb5037b7b261b9e5dd8c35fc71830f46b55

URL: 
https://github.com/llvm/llvm-project/commit/85ed0fb5037b7b261b9e5dd8c35fc71830f46b55
DIFF: 
https://github.com/llvm/llvm-project/commit/85ed0fb5037b7b261b9e5dd8c35fc71830f46b55.diff

LOG: Basic documentation of -mrecip=... option

The documentation is still rather terse because it needs to fit
onto a single line of clang --help output.
But at least it lists what the user can specify and documents the
non-obvious syntax.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D149456

Added: 


Modified: 
clang/include/clang/Driver/Options.td

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index d14fed015f793..8c80c7f5ff56a 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3959,8 +3959,12 @@ def mno_outline_atomics : Flag<["-"], 
"mno-outline-atomics">, Group, Group,
   HelpText<"Don't generate implicit floating point or vector instructions">;
 def mimplicit_float : Flag<["-"], "mimplicit-float">, Group;
-def mrecip : Flag<["-"], "mrecip">, Group;
+def mrecip : Flag<["-"], "mrecip">, Group,
+  HelpText<"Equivalent to '-mrecip=all'">;
 def mrecip_EQ : CommaJoined<["-"], "mrecip=">, Group, 
Flags<[CC1Option]>,
+  HelpText<"Control use of approximate reciprocal and reciprocal square root 
instructions followed by  iterations of "
+   "Newton-Raphson refinement. "
+   " = ( ['!'] ['vec-'] ('rcp'|'sqrt') [('h'|'s'|'d')] [':'] 
) | 'all' | 'default' | 'none'">,
   MarshallingInfoStringVector>;
 def mprefer_vector_width_EQ : Joined<["-"], "mprefer-vector-width=">, 
Group, Flags<[CC1Option]>,
   HelpText<"Specifies preferred vector width for auto-vectorization. Defaults 
to 'none' which allows target specific decisions.">,



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


[clang] [clang] Fixing Clang HIP inconsistent order for template functions (PR #101627)

2024-08-12 Thread Shivam Gupta via cfe-commits

xgupta wrote:

First CI is failing with error - 

```
clang: error: cannot find ROCm device library; provide its path via 
'--rocm-path' or '--rocm-device-lib-path', or pass '-nogpulib' to build without 
ROCm device library
clang: error: cannot find HIP runtime; provide its path via '--rocm-path', or 
pass '-nogpuinc' to build without HIP runtime
clang: error: cannot find HIP runtime; provide its path via '--rocm-path', or 
pass '-nogpuinc' to build without HIP runtime
```

I think the test run line is not following convention. You can not include 
hip_runtime.h, instead have to use cuda.h 
so probably you need to add cuda.h in . I have tried replacing #include 
"hip/hip_runtime.h" with #include "../CodeGenCUDA/Inputs/cuda.h" and using run 
line like this way  -

```// RUN: x=$( %clang_cc1  -x hip -triple amdgcn  -target-cpu gfx908  
-emit-llvm -fcuda-is-device %s -o - | md5sum | awk '{ print $1 }') && echo $x > 
%t.md5``` to pass the test case. 


https://github.com/llvm/llvm-project/pull/101627
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix logical error in 'if else' condition that lead to an unreachable code (PR #95666)

2024-06-15 Thread Shivam Gupta via cfe-commits

https://github.com/xgupta created 
https://github.com/llvm/llvm-project/pull/95666

This is described in https://pvs-studio.com/en/blog/posts/cpp/1126/ so caught 
by the PVS Studio analyzer.

Warning message  -
The use of 'if (A) {...} else if (A) {...}' pattern was detected

There were two same 'if' conditions (Tok->is(tok::hash) but different execution 
blocks leading to unreachable code for the second 'if-else' condition.

>From 0e88700adf7add65f3eb8a2d4d2c2de72703a0f0 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Sat, 15 Jun 2024 21:56:09 +0530
Subject: [PATCH] [Clang] Fix logical error in 'if else' condition that lead to
 an unreachable code

This is describe in https://pvs-studio.com/en/blog/posts/cpp/1126/ so caught by 
PVS
Studio analyzer.

Warning message  -
The use of 'if (A) {...} else if (A) {...}' pattern was detected

There were two same 'if' condition (Tok->is(tok::hash) but different execution 
blocks that was leading to
unnreachable code for second 'if else' condition.
---
 clang/lib/Format/TokenAnnotator.cpp | 23 +--
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 1fe3b61a5a81f..5a7029bda65f3 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -3369,11 +3369,19 @@ class ExpressionParser {
   FormatToken *Next = Tok->getNextNonComment();
 
   if (Tok->is(tok::hash)) {
-// Start of a macro expansion.
-First = Tok;
-Tok = Next;
-if (Tok)
-  Tok = Tok->getNextNonComment();
+
+if (Next && Next->is(tok::l_paren)) {
+  // Handle parameterized macro.
+  Next = Next->MatchingParen;
+  if (Next)
+Tok = Next->getNextNonComment();
+} else {
+  // Start of a macro expansion.
+  First = Tok;
+  Tok = Next;
+  if (Tok)
+Tok = Tok->getNextNonComment();
+}
   } else if (Tok->is(tok::hashhash)) {
 // Concatenation. Skip.
 Tok = Next;
@@ -3410,11 +3418,6 @@ class ExpressionParser {
 } else {
   break;
 }
-  } else if (Tok->is(tok::hash)) {
-if (Next->is(tok::l_paren))
-  Next = Next->MatchingParen;
-if (Next)
-  Tok = Next->getNextNonComment();
   } else {
 break;
   }

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


[clang] [Clang] Remove some dead code in getNumTeamsExprForTargetDirective (PR #95695)

2024-06-16 Thread Shivam Gupta via cfe-commits

https://github.com/xgupta created 
https://github.com/llvm/llvm-project/pull/95695

This was reported in https://pvs-studio.com/en/blog/posts/cpp/1126/, fragment 
N9.

V523 The 'then' statement is equivalent to the subsequent code fragment. 
CGOpenMPRuntime.cpp:6040, 6036

>From 16fde316ba9bd8a54545d71b46df968ae1bb86d3 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Sun, 16 Jun 2024 15:01:13 +0530
Subject: [PATCH] [Clang] Remove some dead code in
 getNumTeamsExprForTargetDirective

This was reported in https://pvs-studio.com/en/blog/posts/cpp/1126/, fragment 
N9.

V523 The 'then' statement is equivalent to the subsequent code fragment. 
CGOpenMPRuntime.cpp:6040, 6036
---
 clang/lib/CodeGen/CGOpenMPRuntime.cpp | 2 --
 1 file changed, 2 deletions(-)

diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index f6d12d46cfc07..0c99ee3b8c4a9 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -6037,8 +6037,6 @@ const Expr 
*CGOpenMPRuntime::getNumTeamsExprForTargetDirective(
 MinTeamsVal = MaxTeamsVal = 1;
 return nullptr;
   }
-  MinTeamsVal = MaxTeamsVal = 1;
-  return nullptr;
 }
 // A value of -1 is used to check if we need to emit no teams region
 MinTeamsVal = MaxTeamsVal = -1;

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


[clang] [Clang] Fix a variable shadowing in MapLattice (NFC) (PR #95697)

2024-06-16 Thread Shivam Gupta via cfe-commits

https://github.com/xgupta created 
https://github.com/llvm/llvm-project/pull/95697

Reported in https://pvs-studio.com/en/blog/posts/cpp/1126/, fragment N10.

The PVS-Studio warning:
V570 The 'C' variable is assigned to itself. MapLattice.h:52

>From 60fdd988d16ea624d2fd732cf03ee0fc69a14abc Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Sun, 16 Jun 2024 15:41:09 +0530
Subject: [PATCH] [Clang] Fix a variable shadowing in MapLattice (NFC)

Reported in https://pvs-studio.com/en/blog/posts/cpp/1126/, fragment N10.

The PVS-Studio warning:
V570 The 'C' variable is assigned to itself. MapLattice.h:52
---
 clang/include/clang/Analysis/FlowSensitive/MapLattice.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/include/clang/Analysis/FlowSensitive/MapLattice.h 
b/clang/include/clang/Analysis/FlowSensitive/MapLattice.h
index 16b0c978779a7..9d7afbe6ae7bf 100644
--- a/clang/include/clang/Analysis/FlowSensitive/MapLattice.h
+++ b/clang/include/clang/Analysis/FlowSensitive/MapLattice.h
@@ -49,7 +49,7 @@ template  class 
MapLattice {
 
   MapLattice() = default;
 
-  explicit MapLattice(Container C) { C = std::move(C); }
+  explicit MapLattice(Container C) : C { std::move(C) } {};
 
   // The `bottom` element is the empty map.
   static MapLattice bottom() { return MapLattice(); }

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


[clang] [Clang] Fix a variable shadowing in MapLattice (NFC) (PR #95697)

2024-06-16 Thread Shivam Gupta via cfe-commits

https://github.com/xgupta updated 
https://github.com/llvm/llvm-project/pull/95697

>From 60fdd988d16ea624d2fd732cf03ee0fc69a14abc Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Sun, 16 Jun 2024 15:41:09 +0530
Subject: [PATCH 1/2] [Clang] Fix a variable shadowing in MapLattice (NFC)

Reported in https://pvs-studio.com/en/blog/posts/cpp/1126/, fragment N10.

The PVS-Studio warning:
V570 The 'C' variable is assigned to itself. MapLattice.h:52
---
 clang/include/clang/Analysis/FlowSensitive/MapLattice.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/include/clang/Analysis/FlowSensitive/MapLattice.h 
b/clang/include/clang/Analysis/FlowSensitive/MapLattice.h
index 16b0c978779a7..9d7afbe6ae7bf 100644
--- a/clang/include/clang/Analysis/FlowSensitive/MapLattice.h
+++ b/clang/include/clang/Analysis/FlowSensitive/MapLattice.h
@@ -49,7 +49,7 @@ template  class 
MapLattice {
 
   MapLattice() = default;
 
-  explicit MapLattice(Container C) { C = std::move(C); }
+  explicit MapLattice(Container C) : C { std::move(C) } {};
 
   // The `bottom` element is the empty map.
   static MapLattice bottom() { return MapLattice(); }

>From bfa6cae6b4e01a7fb5fd599dc69a8a1ffa597878 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Sun, 16 Jun 2024 15:42:53 +0530
Subject: [PATCH 2/2] clang-format

---
 clang/include/clang/Analysis/FlowSensitive/MapLattice.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/include/clang/Analysis/FlowSensitive/MapLattice.h 
b/clang/include/clang/Analysis/FlowSensitive/MapLattice.h
index 9d7afbe6ae7bf..b2d147e4ae444 100644
--- a/clang/include/clang/Analysis/FlowSensitive/MapLattice.h
+++ b/clang/include/clang/Analysis/FlowSensitive/MapLattice.h
@@ -49,7 +49,7 @@ template  class 
MapLattice {
 
   MapLattice() = default;
 
-  explicit MapLattice(Container C) : C { std::move(C) } {};
+  explicit MapLattice(Container C) : C{std::move(C)} {};
 
   // The `bottom` element is the empty map.
   static MapLattice bottom() { return MapLattice(); }

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


[clang] [Clang] Fix logical error in 'if else' condition that lead to an unreachable code (PR #95666)

2024-06-16 Thread Shivam Gupta via cfe-commits

https://github.com/xgupta updated 
https://github.com/llvm/llvm-project/pull/95666

>From 0e88700adf7add65f3eb8a2d4d2c2de72703a0f0 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Sat, 15 Jun 2024 21:56:09 +0530
Subject: [PATCH 1/2] [Clang] Fix logical error in 'if else' condition that
 lead to an unreachable code

This is describe in https://pvs-studio.com/en/blog/posts/cpp/1126/ so caught by 
PVS
Studio analyzer.

Warning message  -
The use of 'if (A) {...} else if (A) {...}' pattern was detected

There were two same 'if' condition (Tok->is(tok::hash) but different execution 
blocks that was leading to
unnreachable code for second 'if else' condition.
---
 clang/lib/Format/TokenAnnotator.cpp | 23 +--
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 1fe3b61a5a81f..5a7029bda65f3 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -3369,11 +3369,19 @@ class ExpressionParser {
   FormatToken *Next = Tok->getNextNonComment();
 
   if (Tok->is(tok::hash)) {
-// Start of a macro expansion.
-First = Tok;
-Tok = Next;
-if (Tok)
-  Tok = Tok->getNextNonComment();
+
+if (Next && Next->is(tok::l_paren)) {
+  // Handle parameterized macro.
+  Next = Next->MatchingParen;
+  if (Next)
+Tok = Next->getNextNonComment();
+} else {
+  // Start of a macro expansion.
+  First = Tok;
+  Tok = Next;
+  if (Tok)
+Tok = Tok->getNextNonComment();
+}
   } else if (Tok->is(tok::hashhash)) {
 // Concatenation. Skip.
 Tok = Next;
@@ -3410,11 +3418,6 @@ class ExpressionParser {
 } else {
   break;
 }
-  } else if (Tok->is(tok::hash)) {
-if (Next->is(tok::l_paren))
-  Next = Next->MatchingParen;
-if (Next)
-  Tok = Next->getNextNonComment();
   } else {
 break;
   }

>From 17e1c3561830866592fd3a55e7a296194b221a90 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Sun, 16 Jun 2024 20:00:48 +0530
Subject: [PATCH 2/2] remove dead code

---
 clang/lib/Format/TokenAnnotator.cpp | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 5a7029bda65f3..3bc7caaa95529 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -3369,13 +3369,6 @@ class ExpressionParser {
   FormatToken *Next = Tok->getNextNonComment();
 
   if (Tok->is(tok::hash)) {
-
-if (Next && Next->is(tok::l_paren)) {
-  // Handle parameterized macro.
-  Next = Next->MatchingParen;
-  if (Next)
-Tok = Next->getNextNonComment();
-} else {
   // Start of a macro expansion.
   First = Tok;
   Tok = Next;

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


[clang] [Clang] Fix logical error in 'if else' condition that lead to an unreachable code (PR #95666)

2024-06-16 Thread Shivam Gupta via cfe-commits

https://github.com/xgupta updated 
https://github.com/llvm/llvm-project/pull/95666

>From 0e88700adf7add65f3eb8a2d4d2c2de72703a0f0 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Sat, 15 Jun 2024 21:56:09 +0530
Subject: [PATCH 1/3] [Clang] Fix logical error in 'if else' condition that
 lead to an unreachable code

This is describe in https://pvs-studio.com/en/blog/posts/cpp/1126/ so caught by 
PVS
Studio analyzer.

Warning message  -
The use of 'if (A) {...} else if (A) {...}' pattern was detected

There were two same 'if' condition (Tok->is(tok::hash) but different execution 
blocks that was leading to
unnreachable code for second 'if else' condition.
---
 clang/lib/Format/TokenAnnotator.cpp | 23 +--
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 1fe3b61a5a81f..5a7029bda65f3 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -3369,11 +3369,19 @@ class ExpressionParser {
   FormatToken *Next = Tok->getNextNonComment();
 
   if (Tok->is(tok::hash)) {
-// Start of a macro expansion.
-First = Tok;
-Tok = Next;
-if (Tok)
-  Tok = Tok->getNextNonComment();
+
+if (Next && Next->is(tok::l_paren)) {
+  // Handle parameterized macro.
+  Next = Next->MatchingParen;
+  if (Next)
+Tok = Next->getNextNonComment();
+} else {
+  // Start of a macro expansion.
+  First = Tok;
+  Tok = Next;
+  if (Tok)
+Tok = Tok->getNextNonComment();
+}
   } else if (Tok->is(tok::hashhash)) {
 // Concatenation. Skip.
 Tok = Next;
@@ -3410,11 +3418,6 @@ class ExpressionParser {
 } else {
   break;
 }
-  } else if (Tok->is(tok::hash)) {
-if (Next->is(tok::l_paren))
-  Next = Next->MatchingParen;
-if (Next)
-  Tok = Next->getNextNonComment();
   } else {
 break;
   }

>From 17e1c3561830866592fd3a55e7a296194b221a90 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Sun, 16 Jun 2024 20:00:48 +0530
Subject: [PATCH 2/3] remove dead code

---
 clang/lib/Format/TokenAnnotator.cpp | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 5a7029bda65f3..3bc7caaa95529 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -3369,13 +3369,6 @@ class ExpressionParser {
   FormatToken *Next = Tok->getNextNonComment();
 
   if (Tok->is(tok::hash)) {
-
-if (Next && Next->is(tok::l_paren)) {
-  // Handle parameterized macro.
-  Next = Next->MatchingParen;
-  if (Next)
-Tok = Next->getNextNonComment();
-} else {
   // Start of a macro expansion.
   First = Tok;
   Tok = Next;

>From 3928b8936f05562312e177443821f452829034db Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Sun, 16 Jun 2024 20:18:49 +0530
Subject: [PATCH 3/3] clang-format

---
 clang/lib/Format/TokenAnnotator.cpp | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 3bc7caaa95529..4150c59ac5081 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -3369,12 +3369,12 @@ class ExpressionParser {
   FormatToken *Next = Tok->getNextNonComment();
 
   if (Tok->is(tok::hash)) {
-  // Start of a macro expansion.
-  First = Tok;
-  Tok = Next;
-  if (Tok)
-Tok = Tok->getNextNonComment();
-}
+// Start of a macro expansion.
+First = Tok;
+Tok = Next;
+if (Tok)
+  Tok = Tok->getNextNonComment();
+  }
   } else if (Tok->is(tok::hashhash)) {
 // Concatenation. Skip.
 Tok = Next;

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


[clang] [Clang] Fix logical error in 'if else' condition that lead to an unreachable code (PR #95666)

2024-06-16 Thread Shivam Gupta via cfe-commits

https://github.com/xgupta updated 
https://github.com/llvm/llvm-project/pull/95666

>From 0e88700adf7add65f3eb8a2d4d2c2de72703a0f0 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Sat, 15 Jun 2024 21:56:09 +0530
Subject: [PATCH 1/4] [Clang] Fix logical error in 'if else' condition that
 lead to an unreachable code

This is describe in https://pvs-studio.com/en/blog/posts/cpp/1126/ so caught by 
PVS
Studio analyzer.

Warning message  -
The use of 'if (A) {...} else if (A) {...}' pattern was detected

There were two same 'if' condition (Tok->is(tok::hash) but different execution 
blocks that was leading to
unnreachable code for second 'if else' condition.
---
 clang/lib/Format/TokenAnnotator.cpp | 23 +--
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 1fe3b61a5a81f..5a7029bda65f3 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -3369,11 +3369,19 @@ class ExpressionParser {
   FormatToken *Next = Tok->getNextNonComment();
 
   if (Tok->is(tok::hash)) {
-// Start of a macro expansion.
-First = Tok;
-Tok = Next;
-if (Tok)
-  Tok = Tok->getNextNonComment();
+
+if (Next && Next->is(tok::l_paren)) {
+  // Handle parameterized macro.
+  Next = Next->MatchingParen;
+  if (Next)
+Tok = Next->getNextNonComment();
+} else {
+  // Start of a macro expansion.
+  First = Tok;
+  Tok = Next;
+  if (Tok)
+Tok = Tok->getNextNonComment();
+}
   } else if (Tok->is(tok::hashhash)) {
 // Concatenation. Skip.
 Tok = Next;
@@ -3410,11 +3418,6 @@ class ExpressionParser {
 } else {
   break;
 }
-  } else if (Tok->is(tok::hash)) {
-if (Next->is(tok::l_paren))
-  Next = Next->MatchingParen;
-if (Next)
-  Tok = Next->getNextNonComment();
   } else {
 break;
   }

>From 17e1c3561830866592fd3a55e7a296194b221a90 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Sun, 16 Jun 2024 20:00:48 +0530
Subject: [PATCH 2/4] remove dead code

---
 clang/lib/Format/TokenAnnotator.cpp | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 5a7029bda65f3..3bc7caaa95529 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -3369,13 +3369,6 @@ class ExpressionParser {
   FormatToken *Next = Tok->getNextNonComment();
 
   if (Tok->is(tok::hash)) {
-
-if (Next && Next->is(tok::l_paren)) {
-  // Handle parameterized macro.
-  Next = Next->MatchingParen;
-  if (Next)
-Tok = Next->getNextNonComment();
-} else {
   // Start of a macro expansion.
   First = Tok;
   Tok = Next;

>From 3928b8936f05562312e177443821f452829034db Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Sun, 16 Jun 2024 20:18:49 +0530
Subject: [PATCH 3/4] clang-format

---
 clang/lib/Format/TokenAnnotator.cpp | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 3bc7caaa95529..4150c59ac5081 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -3369,12 +3369,12 @@ class ExpressionParser {
   FormatToken *Next = Tok->getNextNonComment();
 
   if (Tok->is(tok::hash)) {
-  // Start of a macro expansion.
-  First = Tok;
-  Tok = Next;
-  if (Tok)
-Tok = Tok->getNextNonComment();
-}
+// Start of a macro expansion.
+First = Tok;
+Tok = Next;
+if (Tok)
+  Tok = Tok->getNextNonComment();
+  }
   } else if (Tok->is(tok::hashhash)) {
 // Concatenation. Skip.
 Tok = Next;

>From 6f000eb0403847996b3da588f07b4506d4ec7c41 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Sun, 16 Jun 2024 20:20:22 +0530
Subject: [PATCH 4/4] minor change

---
 clang/lib/Format/TokenAnnotator.cpp | 1 -
 1 file changed, 1 deletion(-)

diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 4150c59ac5081..07599b6e1e3e1 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -3374,7 +3374,6 @@ class ExpressionParser {
 Tok = Next;
 if (Tok)
   Tok = Tok->getNextNonComment();
-  }
   } else if (Tok->is(tok::hashhash)) {
 // Concatenation. Skip.
 Tok = Next;

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


[clang] [Clang] Remove unreachable code in verilogGroupDecl (NFC) (PR #95666)

2024-06-16 Thread Shivam Gupta via cfe-commits

https://github.com/xgupta edited https://github.com/llvm/llvm-project/pull/95666
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [llvm] [mlir] [clang][lldb][mlir] Fix some identical sub-expressions warnings (NFC) (PR #95715)

2024-06-16 Thread Shivam Gupta via cfe-commits

https://github.com/xgupta created 
https://github.com/llvm/llvm-project/pull/95715

This is reported in https://pvs-studio.com/en/blog/posts/cpp/1126/, fragment 
N4-8

V501 There are identical sub-expressions 'FirstStmt->getStmtClass()' to the 
left and to the right of the '!=' operator. ASTUtils.cpp:99
V501 There are identical sub-expressions to the left and to the right of the 
'!=' operator: Fn1->isVariadic() != Fn1->isVariadic(). SemaOverload.cpp:10190
V501 There are identical sub-expressions to the left and to the right of the 
'<' operator: G1->Rank < G1->Rank. SCCIterator.h:285
V501 There are identical sub-expressions 'slice1.getMixedOffsets().size()' to 
the left and to the right of the '==' operator. ValueBoundsOpInterface.cpp:581
V501 There are identical sub-expressions 'slice1.getMixedSizes().size()' to the 
left and to the right of the '==' operator. ValueBoundsOpInterface.cpp:583
V501 There are identical sub-expressions 'slice1.getMixedStrides().size()' to 
the left and to the right of the '==' operator. ValueBoundsOpInterface.cpp:585
V501 There are identical sub-expressions 'slice1.getMixedOffsets().size()' to 
the left and to the right of the '==' operator. ValueBoundsOpInterface.cpp:646
V501 There are identical sub-expressions 'slice1.getMixedSizes().size()' to the 
left and to the right of the '==' operator. ValueBoundsOpInterface.cpp:648
V501 There are identical sub-expressions 'slice1.getMixedStrides().size()' to 
the left and to the right of the '==' operator. ValueBoundsOpInterface.cpp:650
V501 There are identical sub-expressions 'EltRange.getEnd() >= Range.getEnd()' 
to the left and to the right of the '||' operator. HTMLLogger.cpp:421
V501 There are identical sub-expressions 'SrcExpr.get()->containsErrors()' to 
the left and to the right of the '||' operator. SemaCast.cpp:2938
V501 There are identical sub-expressions 'ND->getDeclContext()' to the left and 
to the right of the '!=' operator. SemaDeclCXX.cpp:4391
V501 There are identical sub-expressions 'DepType != OMPC_DOACROSS_source' to 
the left and to the right of the '&&' operator. SemaOpenMP.cpp:24348
V501 There are identical sub-expressions '!OldMethod->isStatic()' to the left 
and to the right of the '&&' operator. SemaOverload.cpp:1425
V501 There are identical sub-expressions 'lldb::eTypeClassUnion' to the left 
and to the right of the '|' operator. JSONUtils.cpp:139
V501 There are identical sub-expressions to the left and to the right of the 
'&&' operator: !BFI &&!BFI. JumpThreading.cpp:2531
V501 There are identical sub-expressions 'BI->isConditional()' to the left and 
to the right of the '&&' operator. VPlanHCFGBuilder.cpp:401
V501 There are identical sub-expressions to the left and to the right of the 
'==' operator: getNumRows() == getNumRows(). Simplex.cpp:108

>From f80cc3b6ee218e954d68e867637c38211f344d83 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Sun, 16 Jun 2024 23:39:47 +0530
Subject: [PATCH] [clang][lldb][mlir] Fix some identical sub-expressions
 warnings (NFC)

This is actually reported in 
https://pvs-studio.com/en/blog/posts/cpp/1126/, fragment N4-8

V501 There are identical sub-expressions 'FirstStmt->getStmtClass()' to the 
left and to the right of the '!=' operator. ASTUtils.cpp:99
V501 There are identical sub-expressions to the left and to the right of 
the '!=' operator: Fn1->isVariadic() != Fn1->isVariadic(). 
SemaOverload.cpp:10190
V501 There are identical sub-expressions to the left and to the right of 
the '<' operator: G1->Rank < G1->Rank. SCCIterator.h:285
V501 There are identical sub-expressions 'slice1.getMixedOffsets().size()' 
to the left and to the right of the '==' operator. 
ValueBoundsOpInterface.cpp:581
V501 There are identical sub-expressions 'slice1.getMixedSizes().size()' to 
the left and to the right of the '==' operator. ValueBoundsOpInterface.cpp:583
V501 There are identical sub-expressions 'slice1.getMixedStrides().size()' 
to the left and to the right of the '==' operator. 
ValueBoundsOpInterface.cpp:585
V501 There are identical sub-expressions 'slice1.getMixedOffsets().size()' 
to the left and to the right of the '==' operator. 
ValueBoundsOpInterface.cpp:646
V501 There are identical sub-expressions 'slice1.getMixedSizes().size()' to 
the left and to the right of the '==' operator. ValueBoundsOpInterface.cpp:648
V501 There are identical sub-expressions 'slice1.getMixedStrides().size()' 
to the left and to the right of the '==' operator. 
ValueBoundsOpInterface.cpp:650
V501 There are identical sub-expressions 'EltRange.getEnd() >= 
Range.getEnd()' to the left and to the right of the '||' operator. 
HTMLLogger.cpp:421
V501 There are identical sub-expressions 'SrcExpr.get()->containsErrors()' 
to the left and to the right of the '||' operator. SemaCast.cpp:2938
V501 There are identical sub-expressions 'ND->getDeclContext()' to the left 
and to the right of the '!=' operator. SemaDeclCXX.cpp:4391
V501 There are identical 

[clang] [Clang] Remove unreachable code in verilogGroupDecl (NFC) (PR #95666)

2024-06-16 Thread Shivam Gupta via cfe-commits

xgupta wrote:

> I think @sstwcw fixes this in #95703

Oh nice then, I will close this PR.

https://github.com/llvm/llvm-project/pull/95666
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Remove unreachable code in verilogGroupDecl (NFC) (PR #95666)

2024-06-16 Thread Shivam Gupta via cfe-commits

https://github.com/xgupta closed https://github.com/llvm/llvm-project/pull/95666
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [llvm] [mlir] [clang][lldb][mlir] Fix some identical sub-expressions warnings (NFC) (PR #95715)

2024-06-17 Thread Shivam Gupta via cfe-commits

https://github.com/xgupta updated 
https://github.com/llvm/llvm-project/pull/95715

>From f80cc3b6ee218e954d68e867637c38211f344d83 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Sun, 16 Jun 2024 23:39:47 +0530
Subject: [PATCH 1/2] [clang][lldb][mlir] Fix some identical sub-expressions
 warnings (NFC)

This is actually reported in 
https://pvs-studio.com/en/blog/posts/cpp/1126/, fragment N4-8

V501 There are identical sub-expressions 'FirstStmt->getStmtClass()' to the 
left and to the right of the '!=' operator. ASTUtils.cpp:99
V501 There are identical sub-expressions to the left and to the right of 
the '!=' operator: Fn1->isVariadic() != Fn1->isVariadic(). 
SemaOverload.cpp:10190
V501 There are identical sub-expressions to the left and to the right of 
the '<' operator: G1->Rank < G1->Rank. SCCIterator.h:285
V501 There are identical sub-expressions 'slice1.getMixedOffsets().size()' 
to the left and to the right of the '==' operator. 
ValueBoundsOpInterface.cpp:581
V501 There are identical sub-expressions 'slice1.getMixedSizes().size()' to 
the left and to the right of the '==' operator. ValueBoundsOpInterface.cpp:583
V501 There are identical sub-expressions 'slice1.getMixedStrides().size()' 
to the left and to the right of the '==' operator. 
ValueBoundsOpInterface.cpp:585
V501 There are identical sub-expressions 'slice1.getMixedOffsets().size()' 
to the left and to the right of the '==' operator. 
ValueBoundsOpInterface.cpp:646
V501 There are identical sub-expressions 'slice1.getMixedSizes().size()' to 
the left and to the right of the '==' operator. ValueBoundsOpInterface.cpp:648
V501 There are identical sub-expressions 'slice1.getMixedStrides().size()' 
to the left and to the right of the '==' operator. 
ValueBoundsOpInterface.cpp:650
V501 There are identical sub-expressions 'EltRange.getEnd() >= 
Range.getEnd()' to the left and to the right of the '||' operator. 
HTMLLogger.cpp:421
V501 There are identical sub-expressions 'SrcExpr.get()->containsErrors()' 
to the left and to the right of the '||' operator. SemaCast.cpp:2938
V501 There are identical sub-expressions 'ND->getDeclContext()' to the left 
and to the right of the '!=' operator. SemaDeclCXX.cpp:4391
V501 There are identical sub-expressions 'DepType != OMPC_DOACROSS_source' 
to the left and to the right of the '&&' operator. SemaOpenMP.cpp:24348
V501 There are identical sub-expressions '!OldMethod->isStatic()' to the 
left and to the right of the '&&' operator. SemaOverload.cpp:1425
V501 There are identical sub-expressions 'lldb::eTypeClassUnion' to the 
left and to the right of the '|' operator. JSONUtils.cpp:139
V501 There are identical sub-expressions to the left and to the right of 
the '&&' operator: !BFI &&!BFI. JumpThreading.cpp:2531
V501 There are identical sub-expressions 'BI->isConditional()' to the left 
and to the right of the '&&' operator. VPlanHCFGBuilder.cpp:401
V501 There are identical sub-expressions to the left and to the right of 
the '==' operator: getNumRows() == getNumRows(). Simplex.cpp:108
---
 clang-tools-extra/clang-tidy/utils/ASTUtils.cpp|  2 +-
 clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp|  7 +++
 clang/lib/Sema/SemaCast.cpp|  3 +--
 clang/lib/Sema/SemaDeclCXX.cpp |  2 +-
 clang/lib/Sema/SemaOpenMP.cpp  |  3 +--
 llvm/lib/Transforms/Scalar/JumpThreading.cpp   |  2 +-
 llvm/lib/Transforms/Vectorize/VPlanHCFGBuilder.cpp |  2 +-
 mlir/lib/Analysis/Presburger/Simplex.cpp   |  3 ++-
 mlir/lib/Interfaces/ValueBoundsOpInterface.cpp | 12 ++--
 9 files changed, 17 insertions(+), 19 deletions(-)

diff --git a/clang-tools-extra/clang-tidy/utils/ASTUtils.cpp 
b/clang-tools-extra/clang-tidy/utils/ASTUtils.cpp
index fd5dadc9b01db..0cdc7d08abc99 100644
--- a/clang-tools-extra/clang-tidy/utils/ASTUtils.cpp
+++ b/clang-tools-extra/clang-tidy/utils/ASTUtils.cpp
@@ -96,7 +96,7 @@ bool areStatementsIdentical(const Stmt *FirstStmt, const Stmt 
*SecondStmt,
   if (FirstStmt == SecondStmt)
 return true;
 
-  if (FirstStmt->getStmtClass() != FirstStmt->getStmtClass())
+  if (FirstStmt->getStmtClass() != SecondStmt->getStmtClass())
 return false;
 
   if (isa(FirstStmt) && isa(SecondStmt)) {
diff --git a/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp 
b/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
index a36cb41a63dfb..323f9698dc2aa 100644
--- a/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
+++ b/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
@@ -430,11 +430,10 @@ class HTMLLogger : public Logger {
   AST.getSourceManager(), AST.getLangOpts());
   if (EltRange.isInvalid())
 continue;
-  if (EltRange.getBegin() < Range.getBegin() ||
-  EltRange.getEnd() >= Range.getEnd() ||
-  EltRange.getEnd() < Range.getBegin() ||
-  EltRange.getEnd() >= Range.getEnd())
+  if (

[clang] [clang-tools-extra] [llvm] [mlir] [clang][lldb][mlir] Fix some identical sub-expressions warnings (NFC) (PR #95715)

2024-06-17 Thread Shivam Gupta via cfe-commits

https://github.com/xgupta updated 
https://github.com/llvm/llvm-project/pull/95715

>From f80cc3b6ee218e954d68e867637c38211f344d83 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Sun, 16 Jun 2024 23:39:47 +0530
Subject: [PATCH 1/3] [clang][lldb][mlir] Fix some identical sub-expressions
 warnings (NFC)

This is actually reported in 
https://pvs-studio.com/en/blog/posts/cpp/1126/, fragment N4-8

V501 There are identical sub-expressions 'FirstStmt->getStmtClass()' to the 
left and to the right of the '!=' operator. ASTUtils.cpp:99
V501 There are identical sub-expressions to the left and to the right of 
the '!=' operator: Fn1->isVariadic() != Fn1->isVariadic(). 
SemaOverload.cpp:10190
V501 There are identical sub-expressions to the left and to the right of 
the '<' operator: G1->Rank < G1->Rank. SCCIterator.h:285
V501 There are identical sub-expressions 'slice1.getMixedOffsets().size()' 
to the left and to the right of the '==' operator. 
ValueBoundsOpInterface.cpp:581
V501 There are identical sub-expressions 'slice1.getMixedSizes().size()' to 
the left and to the right of the '==' operator. ValueBoundsOpInterface.cpp:583
V501 There are identical sub-expressions 'slice1.getMixedStrides().size()' 
to the left and to the right of the '==' operator. 
ValueBoundsOpInterface.cpp:585
V501 There are identical sub-expressions 'slice1.getMixedOffsets().size()' 
to the left and to the right of the '==' operator. 
ValueBoundsOpInterface.cpp:646
V501 There are identical sub-expressions 'slice1.getMixedSizes().size()' to 
the left and to the right of the '==' operator. ValueBoundsOpInterface.cpp:648
V501 There are identical sub-expressions 'slice1.getMixedStrides().size()' 
to the left and to the right of the '==' operator. 
ValueBoundsOpInterface.cpp:650
V501 There are identical sub-expressions 'EltRange.getEnd() >= 
Range.getEnd()' to the left and to the right of the '||' operator. 
HTMLLogger.cpp:421
V501 There are identical sub-expressions 'SrcExpr.get()->containsErrors()' 
to the left and to the right of the '||' operator. SemaCast.cpp:2938
V501 There are identical sub-expressions 'ND->getDeclContext()' to the left 
and to the right of the '!=' operator. SemaDeclCXX.cpp:4391
V501 There are identical sub-expressions 'DepType != OMPC_DOACROSS_source' 
to the left and to the right of the '&&' operator. SemaOpenMP.cpp:24348
V501 There are identical sub-expressions '!OldMethod->isStatic()' to the 
left and to the right of the '&&' operator. SemaOverload.cpp:1425
V501 There are identical sub-expressions 'lldb::eTypeClassUnion' to the 
left and to the right of the '|' operator. JSONUtils.cpp:139
V501 There are identical sub-expressions to the left and to the right of 
the '&&' operator: !BFI &&!BFI. JumpThreading.cpp:2531
V501 There are identical sub-expressions 'BI->isConditional()' to the left 
and to the right of the '&&' operator. VPlanHCFGBuilder.cpp:401
V501 There are identical sub-expressions to the left and to the right of 
the '==' operator: getNumRows() == getNumRows(). Simplex.cpp:108
---
 clang-tools-extra/clang-tidy/utils/ASTUtils.cpp|  2 +-
 clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp|  7 +++
 clang/lib/Sema/SemaCast.cpp|  3 +--
 clang/lib/Sema/SemaDeclCXX.cpp |  2 +-
 clang/lib/Sema/SemaOpenMP.cpp  |  3 +--
 llvm/lib/Transforms/Scalar/JumpThreading.cpp   |  2 +-
 llvm/lib/Transforms/Vectorize/VPlanHCFGBuilder.cpp |  2 +-
 mlir/lib/Analysis/Presburger/Simplex.cpp   |  3 ++-
 mlir/lib/Interfaces/ValueBoundsOpInterface.cpp | 12 ++--
 9 files changed, 17 insertions(+), 19 deletions(-)

diff --git a/clang-tools-extra/clang-tidy/utils/ASTUtils.cpp 
b/clang-tools-extra/clang-tidy/utils/ASTUtils.cpp
index fd5dadc9b01db..0cdc7d08abc99 100644
--- a/clang-tools-extra/clang-tidy/utils/ASTUtils.cpp
+++ b/clang-tools-extra/clang-tidy/utils/ASTUtils.cpp
@@ -96,7 +96,7 @@ bool areStatementsIdentical(const Stmt *FirstStmt, const Stmt 
*SecondStmt,
   if (FirstStmt == SecondStmt)
 return true;
 
-  if (FirstStmt->getStmtClass() != FirstStmt->getStmtClass())
+  if (FirstStmt->getStmtClass() != SecondStmt->getStmtClass())
 return false;
 
   if (isa(FirstStmt) && isa(SecondStmt)) {
diff --git a/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp 
b/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
index a36cb41a63dfb..323f9698dc2aa 100644
--- a/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
+++ b/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
@@ -430,11 +430,10 @@ class HTMLLogger : public Logger {
   AST.getSourceManager(), AST.getLangOpts());
   if (EltRange.isInvalid())
 continue;
-  if (EltRange.getBegin() < Range.getBegin() ||
-  EltRange.getEnd() >= Range.getEnd() ||
-  EltRange.getEnd() < Range.getBegin() ||
-  EltRange.getEnd() >= Range.getEnd())
+  if (

[clang] [Clang] Remove some dead code in getNumTeamsExprForTargetDirective (PR #95695)

2024-07-24 Thread Shivam Gupta via cfe-commits

https://github.com/xgupta updated 
https://github.com/llvm/llvm-project/pull/95695

>From 16fde316ba9bd8a54545d71b46df968ae1bb86d3 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Sun, 16 Jun 2024 15:01:13 +0530
Subject: [PATCH 1/2] [Clang] Remove some dead code in
 getNumTeamsExprForTargetDirective

This was reported in https://pvs-studio.com/en/blog/posts/cpp/1126/, fragment 
N9.

V523 The 'then' statement is equivalent to the subsequent code fragment. 
CGOpenMPRuntime.cpp:6040, 6036
---
 clang/lib/CodeGen/CGOpenMPRuntime.cpp | 2 --
 1 file changed, 2 deletions(-)

diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index f6d12d46cfc07..0c99ee3b8c4a9 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -6037,8 +6037,6 @@ const Expr 
*CGOpenMPRuntime::getNumTeamsExprForTargetDirective(
 MinTeamsVal = MaxTeamsVal = 1;
 return nullptr;
   }
-  MinTeamsVal = MaxTeamsVal = 1;
-  return nullptr;
 }
 // A value of -1 is used to check if we need to emit no teams region
 MinTeamsVal = MaxTeamsVal = -1;

>From 85953f86f10f1451fa347a91a98fecbebc84a4c4 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Wed, 24 Jul 2024 17:27:44 +0200
Subject: [PATCH 2/2] address review comment

---
 clang/lib/CodeGen/CGOpenMPRuntime.cpp | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 0c99ee3b8c4a9..9dd01799bd412 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -6032,11 +6032,8 @@ const Expr 
*CGOpenMPRuntime::getNumTeamsExprForTargetDirective(
 MinTeamsVal = MaxTeamsVal = 0;
 return nullptr;
   }
-  if (isOpenMPParallelDirective(NestedDir->getDirectiveKind()) ||
-  isOpenMPSimdDirective(NestedDir->getDirectiveKind())) {
-MinTeamsVal = MaxTeamsVal = 1;
-return nullptr;
-  }
+  MinTeamsVal = MaxTeamsVal = 1;
+  return nullptr;
 }
 // A value of -1 is used to check if we need to emit no teams region
 MinTeamsVal = MaxTeamsVal = -1;

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


[clang] [Clang] Remove some dead code in getNumTeamsExprForTargetDirective (PR #95695)

2024-07-24 Thread Shivam Gupta via cfe-commits

https://github.com/xgupta closed https://github.com/llvm/llvm-project/pull/95695
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix a variable shadowing in MapLattice (NFC) (PR #95697)

2024-07-25 Thread Shivam Gupta via cfe-commits

https://github.com/xgupta closed https://github.com/llvm/llvm-project/pull/95697
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix a variable shadowing in MapLattice (NFC) (PR #95697)

2024-07-25 Thread Shivam Gupta via cfe-commits

xgupta wrote:

Thanks for the review @martinboehme!

https://github.com/llvm/llvm-project/pull/95697
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [llvm] [mlir] [clang][lldb][mlir] Fix some identical sub-expressions warnings (NFC) (PR #95715)

2024-07-26 Thread Shivam Gupta via cfe-commits


@@ -96,7 +96,7 @@ bool areStatementsIdentical(const Stmt *FirstStmt, const Stmt 
*SecondStmt,
   if (FirstStmt == SecondStmt)
 return true;
 
-  if (FirstStmt->getStmtClass() != FirstStmt->getStmtClass())
+  if (FirstStmt->getStmtClass() != SecondStmt->getStmtClass())

xgupta wrote:

@PiotrZSL If I removed this condition and ninja target still passes. Shall I 
remove this or can you provide a test case or guidance? I have this function is 
used in BranchCloneCheck.cpp but I am not sure how the test case look like. 

https://github.com/llvm/llvm-project/pull/95715
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [llvm] [mlir] [clang][lldb][mlir] Fix some identical sub-expressions warnings (NFC) (PR #95715)

2024-07-26 Thread Shivam Gupta via cfe-commits


@@ -4368,7 +4368,7 @@ bool 
Sema::DiagRedefinedPlaceholderFieldDecl(SourceLocation Loc,
   Diag(Loc, diag::err_using_placeholder_variable) << Name;
   for (DeclContextLookupResult::iterator It = Found; It != Result.end(); It++) 
{
 const NamedDecl *ND = *It;
-if (ND->getDeclContext() != ND->getDeclContext())
+if (ND->getDeclContext() != ClassDecl->getDeclContext())

xgupta wrote:

I am not familiar with this part of code to add a testcase, and not even sure 
it is right fix. I will just remove this changes from this PR. 

https://github.com/llvm/llvm-project/pull/95715
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [clang][lldb][mlir] Fix some identical sub-expressions warnings (NFC) (PR #95715)

2024-07-26 Thread Shivam Gupta via cfe-commits

https://github.com/xgupta updated 
https://github.com/llvm/llvm-project/pull/95715

>From c30bfb621f413c7271bb5a02a7d699e68e053ba1 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Sun, 16 Jun 2024 23:39:47 +0530
Subject: [PATCH 1/4] [clang][lldb][mlir] Fix some identical sub-expressions
 warnings (NFC)

This is actually reported in 
https://pvs-studio.com/en/blog/posts/cpp/1126/, fragment N4-8

V501 There are identical sub-expressions 'FirstStmt->getStmtClass()' to the 
left and to the right of the '!=' operator. ASTUtils.cpp:99
V501 There are identical sub-expressions to the left and to the right of 
the '!=' operator: Fn1->isVariadic() != Fn1->isVariadic(). 
SemaOverload.cpp:10190
V501 There are identical sub-expressions to the left and to the right of 
the '<' operator: G1->Rank < G1->Rank. SCCIterator.h:285
V501 There are identical sub-expressions 'slice1.getMixedOffsets().size()' 
to the left and to the right of the '==' operator. 
ValueBoundsOpInterface.cpp:581
V501 There are identical sub-expressions 'slice1.getMixedSizes().size()' to 
the left and to the right of the '==' operator. ValueBoundsOpInterface.cpp:583
V501 There are identical sub-expressions 'slice1.getMixedStrides().size()' 
to the left and to the right of the '==' operator. 
ValueBoundsOpInterface.cpp:585
V501 There are identical sub-expressions 'slice1.getMixedOffsets().size()' 
to the left and to the right of the '==' operator. 
ValueBoundsOpInterface.cpp:646
V501 There are identical sub-expressions 'slice1.getMixedSizes().size()' to 
the left and to the right of the '==' operator. ValueBoundsOpInterface.cpp:648
V501 There are identical sub-expressions 'slice1.getMixedStrides().size()' 
to the left and to the right of the '==' operator. 
ValueBoundsOpInterface.cpp:650
V501 There are identical sub-expressions 'EltRange.getEnd() >= 
Range.getEnd()' to the left and to the right of the '||' operator. 
HTMLLogger.cpp:421
V501 There are identical sub-expressions 'SrcExpr.get()->containsErrors()' 
to the left and to the right of the '||' operator. SemaCast.cpp:2938
V501 There are identical sub-expressions 'ND->getDeclContext()' to the left 
and to the right of the '!=' operator. SemaDeclCXX.cpp:4391
V501 There are identical sub-expressions 'DepType != OMPC_DOACROSS_source' 
to the left and to the right of the '&&' operator. SemaOpenMP.cpp:24348
V501 There are identical sub-expressions '!OldMethod->isStatic()' to the 
left and to the right of the '&&' operator. SemaOverload.cpp:1425
V501 There are identical sub-expressions 'lldb::eTypeClassUnion' to the 
left and to the right of the '|' operator. JSONUtils.cpp:139
V501 There are identical sub-expressions to the left and to the right of 
the '&&' operator: !BFI &&!BFI. JumpThreading.cpp:2531
V501 There are identical sub-expressions 'BI->isConditional()' to the left 
and to the right of the '&&' operator. VPlanHCFGBuilder.cpp:401
V501 There are identical sub-expressions to the left and to the right of 
the '==' operator: getNumRows() == getNumRows(). Simplex.cpp:108
---
 clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp|  7 +++
 clang/lib/Sema/SemaCast.cpp|  3 +--
 clang/lib/Sema/SemaDeclCXX.cpp |  2 +-
 clang/lib/Sema/SemaOpenMP.cpp  |  3 +--
 llvm/lib/Transforms/Scalar/JumpThreading.cpp   |  2 +-
 llvm/lib/Transforms/Vectorize/VPlanHCFGBuilder.cpp |  2 +-
 mlir/lib/Analysis/Presburger/Simplex.cpp   |  2 +-
 mlir/lib/Interfaces/ValueBoundsOpInterface.cpp | 12 ++--
 8 files changed, 15 insertions(+), 18 deletions(-)

diff --git a/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp 
b/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
index a36cb41a63dfb..323f9698dc2aa 100644
--- a/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
+++ b/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
@@ -430,11 +430,10 @@ class HTMLLogger : public Logger {
   AST.getSourceManager(), AST.getLangOpts());
   if (EltRange.isInvalid())
 continue;
-  if (EltRange.getBegin() < Range.getBegin() ||
-  EltRange.getEnd() >= Range.getEnd() ||
-  EltRange.getEnd() < Range.getBegin() ||
-  EltRange.getEnd() >= Range.getEnd())
+  if (EltRange.getEnd() <= Range.getBegin() ||
+  EltRange.getBegin() >= Range.getEnd())
 continue;
+
   unsigned Off = EltRange.getBegin().getRawEncoding() -
  Range.getBegin().getRawEncoding();
   unsigned Len = EltRange.getEnd().getRawEncoding() -
diff --git a/clang/lib/Sema/SemaCast.cpp b/clang/lib/Sema/SemaCast.cpp
index eca8363ee9605..18de4f6007d87 100644
--- a/clang/lib/Sema/SemaCast.cpp
+++ b/clang/lib/Sema/SemaCast.cpp
@@ -2945,8 +2945,7 @@ void CastOperation::CheckCStyleCast() {
   if (Self.getASTContext().isDependenceAllowed() &&
   (DestType->isDependentType() || SrcExpr.get()->is

[clang] [llvm] [mlir] [clang][lldb][mlir] Fix some identical sub-expressions warnings (NFC) (PR #95715)

2024-07-26 Thread Shivam Gupta via cfe-commits

https://github.com/xgupta edited https://github.com/llvm/llvm-project/pull/95715
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Documentation][Blocks ABI] Fix typoed integer (PR #65688)

2024-05-12 Thread Shivam Gupta via cfe-commits

https://github.com/xgupta updated 
https://github.com/llvm/llvm-project/pull/65688

>From eede884bb0e374d6ce0db4811ab1a62fc21f4c2c Mon Sep 17 00:00:00 2001
From: Alcaro 
Date: Fri, 4 Jun 2021 09:25:40 +0200
Subject: [PATCH] Fix typoed integer

---
 clang/docs/Block-ABI-Apple.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/docs/Block-ABI-Apple.rst b/clang/docs/Block-ABI-Apple.rst
index e21a8b68b5cd1..250d198ba6181 100644
--- a/clang/docs/Block-ABI-Apple.rst
+++ b/clang/docs/Block-ABI-Apple.rst
@@ -80,7 +80,7 @@ The following flags bits are in use thusly for a possible 
ABI.2010.3.16:
 In 10.6.ABI the (1<<29) was usually set and was always ignored by the runtime -
 it had been a transitional marker that did not get deleted after the
 transition. This bit is now paired with (1<<30), and represented as the pair
-(3<<30), for the following combinations of valid bit settings, and their
+(3<<29), for the following combinations of valid bit settings, and their
 meanings:
 
 .. code-block:: c

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


  1   2   >