[PATCH] D129014: rewording static_assert to more generic static assertion

2022-07-01 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta added a comment.

Running check-clang after applying the patch, results into 36 failed test 
cases. Please update them all. 
Also add a description of patch motivation(via the Edit Revision option on the 
top) for why you are making the changes (like any wrong behavior you are seeing 
etc).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129014

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


[PATCH] D129048: Rewording the "static_assert" to static assertion

2022-07-03 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta added a comment.

Three test cases are failing - Please see: 
https://buildkite.com/llvm-project/premerge-checks/builds/100784#0181c539-bcd1-4d01-a2db-f27a63e2f17e/6-15379
But I think you want to actually modify 
https://github.com/llvm/llvm-project/blob/93d6fdfc232c59975d52146532693178def5ad16/clang/include/clang/Basic/DiagnosticSemaKinds.td#L11133
 and 
https://github.com/llvm/llvm-project/blob/93d6fdfc232c59975d52146532693178def5ad16/clang/include/clang/Basic/DiagnosticSemaKinds.td#L11142.

Please also add more description to the patch as I said before like this - 
Failing a _Static_assert in C should not report that static_assert failed. It’d 
probably be better to reword the diagnostic to be more like GCC and say “static 
assertion” failed in both C and C++.
For example - 
cat test.c
_Static_assert(0, "oh no!");

clang prints
:1:1: error: static_assert failed: oh no!
_Static_assert(0, "oh no!");
^  ~
1 error generated.

while gcc 
:1:1: error: static assertion failed: "oh no!"

1 | _Static_assert(0, "oh no!");
Compiler returned: 1




Comment at: 
clang/test/CXX/expr/expr.prim/expr.prim.req/nested-requirement.cpp:48
 }
\ No newline at end of file


a 'newline' is missing here.



Comment at: 
clang/test/CXX/temp/temp.constr/temp.constr.constr/partial-specializations.cpp:85
 }
\ No newline at end of file


same


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129048

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


[PATCH] D106074: [AIX] Clang's library integration support for 128-bit long double is incomplete on AIX.

2021-07-21 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta added a comment.

@anjankgk You need to provide your identity for commit in "your name " form.
see https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access

> Prior to obtaining commit access, it is common practice to request that 
> someone with commit access commits on your behalf. When doing so, please 
> provide the name and email address you would like to use in the Author 
> property of the commit.




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

https://reviews.llvm.org/D106074

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


[PATCH] D106371: [AIX] Generate large code model relocations when mcmodel=medium on AIX

2021-07-22 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta added a comment.

In D106371#2894736 , @anjankgk wrote:

> Anjan Kumar Guttahalli Krishna 
>
> Thank you!

Seems you are contributing with an official mail, I think you can ask for 
commit access, if you want to continue contributing, bar is quite low in LLVM 
community.
May follow: 
https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access


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

https://reviews.llvm.org/D106371

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


[PATCH] D129048: Rewording the "static_assert" to static assertion

2022-07-19 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta added a comment.

In D129048#3662634 , @Codesbyusman 
wrote:

> the libcxx updates but not tested. working on them

I just run the check-cxx on local system. It seems to pass all testcases after 
applying the current patch.

Testing Time: 2147.75s

  Unsupported  :  307
  Passed   : 7184
  Expectedly Failed:   41


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129048

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


[PATCH] D102134: [docs]Updated the AMD GPU Attributes documentation

2021-05-12 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta resigned from this revision.
xgupta added a comment.

I am really an idol reviewer for this patch -:) don't know anything about 
AMDGPU.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102134

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


[PATCH] D95737: [NFC][Docs] Fix RAVFrontendAction doc's CMakelists.txt for Shared build

2021-01-30 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta created this revision.
xgupta added reviewers: awarzynski, stephenkelly.
xgupta requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Example tutorial  giving 
undefine reference error while building with ```BUILD_SHARED_LIBS=ON```.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95737

Files:
  clang/docs/RAVFrontendAction.rst


Index: clang/docs/RAVFrontendAction.rst
===
--- clang/docs/RAVFrontendAction.rst
+++ clang/docs/RAVFrontendAction.rst
@@ -207,7 +207,14 @@
 
 add_clang_executable(find-class-decls FindClassDecls.cpp)
 
-target_link_libraries(find-class-decls clangTooling)
+target_link_libraries(find-class-decls 
+  PRIVATE
+  clangAST
+  clangBasic
+  clangFrontend
+  clangSerialization
+  clangTooling
+  )
 
 When running this tool over a small code snippet it will output all
 declarations of a class n::m::C it found:


Index: clang/docs/RAVFrontendAction.rst
===
--- clang/docs/RAVFrontendAction.rst
+++ clang/docs/RAVFrontendAction.rst
@@ -207,7 +207,14 @@
 
 add_clang_executable(find-class-decls FindClassDecls.cpp)
 
-target_link_libraries(find-class-decls clangTooling)
+target_link_libraries(find-class-decls 
+  PRIVATE
+  clangAST
+  clangBasic
+  clangFrontend
+  clangSerialization
+  clangTooling
+  )
 
 When running this tool over a small code snippet it will output all
 declarations of a class n::m::C it found:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D95766: [Branch-Rename] Fix some links

2021-02-01 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta created this revision.
xgupta added reviewers: mehdi_amini, sqlbyme.
Herald added a reviewer: bollu.
Herald added subscribers: libcxx-commits, teijeong, rdzhabarov, tatianashp, 
ThomasRaoux, AlexeySotkin, msifontes, jurahul, Kayjukh, grosul1, Joonsoo, 
liufengdb, aartbik, lucyrfox, mgester, arpith-jacob, antiagainst, shauheen, 
rriddle, usaxena95, kadircet, jfb, arphaman, delcypher, hiraditya.
Herald added a reviewer: mravishankar.
Herald added a reviewer: antiagainst.
Herald added a reviewer: aartbik.
Herald added a reviewer: sscalpone.
Herald added a reviewer: ftynse.
Herald added a project: libunwind.
Herald added a reviewer: libunwind.
xgupta requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: llvm-commits, openmp-commits, lldb-commits, 
Sanitizers, cfe-commits, sstefan1, stephenneuendorffer, nicolasvasilache.
Herald added projects: clang, Sanitizers, LLDB, libc++, OpenMP, libc++abi, 
MLIR, LLVM.
Herald added a reviewer: libc++.
Herald added a reviewer: libc++abi.

According to the status of branch rename 
, the master branch of the 
LLVM repository is removed on 28 Jan 2021.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95766

Files:
  clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.h
  clang-tools-extra/clangd/README.md
  clang-tools-extra/docs/clang-rename.rst
  clang-tools-extra/docs/clang-tidy/Contributing.rst
  clang-tools-extra/docs/clang-tidy/Integrations.rst
  clang/docs/ClangPlugins.rst
  clang/docs/ClangTools.rst
  clang/docs/ControlFlowIntegrityDesign.rst
  clang/docs/InternalsManual.rst
  clang/docs/LibTooling.rst
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/www/analyzer/checker_dev_manual.html
  clang/www/analyzer/open_projects.html
  clang/www/hacking.html
  clang/www/menu.html.incl
  compiler-rt/include/sanitizer/tsan_interface_atomic.h
  compiler-rt/lib/tsan/rtl/tsan_interface.h
  compiler-rt/www/menu.html.incl
  flang/README.md
  flang/docs/_templates/indexsidebar.html
  flang/docs/flang-c-style.el
  libcxx/docs/index.rst
  libcxx/www/atomic_design.html
  libcxx/www/atomic_design_a.html
  libcxx/www/atomic_design_b.html
  libcxx/www/atomic_design_c.html
  libcxx/www/index.html
  libcxx/www/ts1z_status.html
  libcxx/www/type_traits_design.html
  libcxx/www/upcoming_meeting.html
  libcxxabi/www/index.html
  libunwind/docs/index.rst
  lldb/docs/resources/build.rst
  lldb/docs/resources/test.rst
  lldb/docs/use/python-reference.rst
  llvm/docs/Vectorizers.rst
  llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
  llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
  llvm/test/Transforms/SLPVectorizer/AArch64/matmul.ll
  llvm/utils/lit/setup.py
  mlir/docs/DeclarativeRewrites.md
  mlir/docs/Dialects/SPIR-V.md
  mlir/docs/Dialects/Vector.md
  mlir/docs/OpDefinitions.md
  mlir/docs/PatternRewriter.md
  mlir/docs/Rationale/RationaleGenericDAGRewriter.md
  mlir/docs/SPIRVToLLVMDialectConversion.md
  mlir/docs/ShapeInference.md
  mlir/docs/Tutorials/UnderstandingTheIRStructure.md
  openmp/www/index.html
  polly/www/menu.html.incl

Index: polly/www/menu.html.incl
===
--- polly/www/menu.html.incl
+++ polly/www/menu.html.incl
@@ -34,7 +34,7 @@
 http://lab.llvm.org:8080/coverage/coverage-reports/polly/index.html";>Code Coverage
 http://llvm.org/reports/scan-build/";>Static analysis
 Doxygen
-https://github.com/llvm/llvm-project/tree/master/polly";>Source @ GitHub
+https://github.com/llvm/llvm-project/tree/main/polly";>Source @ GitHub
   
 
   
Index: openmp/www/index.html
===
--- openmp/www/index.html
+++ openmp/www/index.html
@@ -25,7 +25,7 @@
 https://lists.llvm.org/mailman/listinfo/openmp-dev";>openmp-dev
 https://lists.llvm.org/mailman/listinfo/openmp-commits";>openmp-commits
 https://bugs.llvm.org/";>Bug Reports
-https://github.com/llvm/llvm-project/tree/master/openmp";>Browse Sources
+https://github.com/llvm/llvm-project/tree/main/openmp";>Browse Sources
   
 
 
Index: mlir/docs/Tutorials/UnderstandingTheIRStructure.md
===
--- mlir/docs/Tutorials/UnderstandingTheIRStructure.md
+++ mlir/docs/Tutorials/UnderstandingTheIRStructure.md
@@ -86,7 +86,7 @@
 ```
 
 The code for the pass is available
-[here in the repo](https://github.com/llvm/llvm-project/blob/master/mlir/test/lib/IR/TestPrintNesting.cpp)
+[here in the repo](https://github.com/llvm/llvm-project/blob/main/mlir/test/lib/IR/TestPrintNesting.cpp)
 and can be exercised with `mlir-opt -test-print-nesting`.
 
 ### Example
@@ -273,7 +273,7 @@
 ```
 
 The illustrating code for this pass is available
-[here in the repo](https://github.com/llvm/llvm-project/blob/master/mlir/test/lib/IR/TestPrintDefUse.cpp)
+[here in the repo](https://github.com/llvm/llvm-project/blob/main/mlir

[PATCH] D95766: [Branch-Rename] Fix some links

2021-02-01 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.h:20
 // Check for underscores in the names of googletest tests, per
-// 
https://github.com/google/googletest/blob/master/googletest/docs/faq.md#why-should-test-suite-names-and-test-names-not-contain-underscore
 ///

mehdi_amini wrote:
> You removed the wrong word here?
Yes, docs were moved one step back.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95766

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


[PATCH] D95766: [Branch-Rename] Fix some links

2021-02-01 Thread Shivam Gupta via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG94fac81fccfe: [Branch-Rename] Fix some links (authored by 
xgupta).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95766

Files:
  clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.h
  clang-tools-extra/clangd/README.md
  clang-tools-extra/docs/clang-rename.rst
  clang-tools-extra/docs/clang-tidy/Contributing.rst
  clang-tools-extra/docs/clang-tidy/Integrations.rst
  clang/docs/ClangPlugins.rst
  clang/docs/ClangTools.rst
  clang/docs/ControlFlowIntegrityDesign.rst
  clang/docs/InternalsManual.rst
  clang/docs/LibTooling.rst
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/www/analyzer/checker_dev_manual.html
  clang/www/analyzer/open_projects.html
  clang/www/hacking.html
  clang/www/menu.html.incl
  compiler-rt/include/sanitizer/tsan_interface_atomic.h
  compiler-rt/lib/tsan/rtl/tsan_interface.h
  compiler-rt/www/menu.html.incl
  flang/README.md
  flang/docs/_templates/indexsidebar.html
  flang/docs/flang-c-style.el
  libcxx/docs/index.rst
  libcxx/www/atomic_design.html
  libcxx/www/atomic_design_a.html
  libcxx/www/atomic_design_b.html
  libcxx/www/atomic_design_c.html
  libcxx/www/index.html
  libcxx/www/ts1z_status.html
  libcxx/www/type_traits_design.html
  libcxx/www/upcoming_meeting.html
  libcxxabi/www/index.html
  libunwind/docs/index.rst
  lldb/docs/resources/build.rst
  lldb/docs/resources/test.rst
  lldb/docs/use/python-reference.rst
  llvm/docs/Vectorizers.rst
  llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
  llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
  llvm/test/Transforms/SLPVectorizer/AArch64/matmul.ll
  llvm/utils/lit/setup.py
  mlir/docs/DeclarativeRewrites.md
  mlir/docs/Dialects/SPIR-V.md
  mlir/docs/Dialects/Vector.md
  mlir/docs/OpDefinitions.md
  mlir/docs/PatternRewriter.md
  mlir/docs/Rationale/RationaleGenericDAGRewriter.md
  mlir/docs/SPIRVToLLVMDialectConversion.md
  mlir/docs/ShapeInference.md
  mlir/docs/Tutorials/UnderstandingTheIRStructure.md
  openmp/www/index.html
  polly/www/menu.html.incl

Index: polly/www/menu.html.incl
===
--- polly/www/menu.html.incl
+++ polly/www/menu.html.incl
@@ -34,7 +34,7 @@
 http://lab.llvm.org:8080/coverage/coverage-reports/polly/index.html";>Code Coverage
 http://llvm.org/reports/scan-build/";>Static analysis
 Doxygen
-https://github.com/llvm/llvm-project/tree/master/polly";>Source @ GitHub
+https://github.com/llvm/llvm-project/tree/main/polly";>Source @ GitHub
   
 
   
Index: openmp/www/index.html
===
--- openmp/www/index.html
+++ openmp/www/index.html
@@ -25,7 +25,7 @@
 https://lists.llvm.org/mailman/listinfo/openmp-dev";>openmp-dev
 https://lists.llvm.org/mailman/listinfo/openmp-commits";>openmp-commits
 https://bugs.llvm.org/";>Bug Reports
-https://github.com/llvm/llvm-project/tree/master/openmp";>Browse Sources
+https://github.com/llvm/llvm-project/tree/main/openmp";>Browse Sources
   
 
 
Index: mlir/docs/Tutorials/UnderstandingTheIRStructure.md
===
--- mlir/docs/Tutorials/UnderstandingTheIRStructure.md
+++ mlir/docs/Tutorials/UnderstandingTheIRStructure.md
@@ -86,7 +86,7 @@
 ```
 
 The code for the pass is available
-[here in the repo](https://github.com/llvm/llvm-project/blob/master/mlir/test/lib/IR/TestPrintNesting.cpp)
+[here in the repo](https://github.com/llvm/llvm-project/blob/main/mlir/test/lib/IR/TestPrintNesting.cpp)
 and can be exercised with `mlir-opt -test-print-nesting`.
 
 ### Example
@@ -273,7 +273,7 @@
 ```
 
 The illustrating code for this pass is available
-[here in the repo](https://github.com/llvm/llvm-project/blob/master/mlir/test/lib/IR/TestPrintDefUse.cpp)
+[here in the repo](https://github.com/llvm/llvm-project/blob/main/mlir/test/lib/IR/TestPrintDefUse.cpp)
 and can be exercised with `mlir-opt -test-print-defuse`.
 
 The chaining of `Value`s and their uses can be viewed as following:
Index: mlir/docs/ShapeInference.md
===
--- mlir/docs/ShapeInference.md
+++ mlir/docs/ShapeInference.md
@@ -291,5 +291,5 @@
 the shape function. The reference implementation is general and can support the
 arbitrary computations needed to specify output shapes.
 
-[InferTypeOpInterface]: https://github.com/llvm/llvm-project/tree/master/mlir/include/mlir/Interfaces/InferTypeOpInterface.td
-[ShapedType]: https://github.com/llvm/llvm-project/tree/master/mlir/include/mlir/IR/BuiltinTypes.h
+[InferTypeOpInterface]: https://github.com/llvm/llvm-project/tree/main/mlir/include/mlir/Interfaces/InferTypeOpInte

[PATCH] D95737: [NFC][Docs] Fix RAVFrontendAction doc's CMakelists.txt for Shared build

2021-02-01 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta accepted this revision.
xgupta added a comment.
This revision is now accepted and ready to land.

I build the project on my system x64 with shared libraries enable. It is 
working correctly. It is also NFC.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95737

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


[PATCH] D95737: [NFC][Docs] Fix RAVFrontendAction doc's CMakelists.txt for Shared build

2021-02-01 Thread Shivam Gupta via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6ee1f64a2e82: [NFC][Docs] Fix RAVFrontendAction doc's 
CMakelists.txt for Shared build (authored by xgupta).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95737

Files:
  clang/docs/RAVFrontendAction.rst


Index: clang/docs/RAVFrontendAction.rst
===
--- clang/docs/RAVFrontendAction.rst
+++ clang/docs/RAVFrontendAction.rst
@@ -207,7 +207,14 @@
 
 add_clang_executable(find-class-decls FindClassDecls.cpp)
 
-target_link_libraries(find-class-decls clangTooling)
+target_link_libraries(find-class-decls 
+  PRIVATE
+  clangAST
+  clangBasic
+  clangFrontend
+  clangSerialization
+  clangTooling
+  )
 
 When running this tool over a small code snippet it will output all
 declarations of a class n::m::C it found:


Index: clang/docs/RAVFrontendAction.rst
===
--- clang/docs/RAVFrontendAction.rst
+++ clang/docs/RAVFrontendAction.rst
@@ -207,7 +207,14 @@
 
 add_clang_executable(find-class-decls FindClassDecls.cpp)
 
-target_link_libraries(find-class-decls clangTooling)
+target_link_libraries(find-class-decls 
+  PRIVATE
+  clangAST
+  clangBasic
+  clangFrontend
+  clangSerialization
+  clangTooling
+  )
 
 When running this tool over a small code snippet it will output all
 declarations of a class n::m::C it found:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2021-09-17 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta created this revision.
xgupta added reviewers: aaron.ballman, t.p.northover.
Herald added a subscriber: mgorny.
xgupta requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

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 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109979

Files:
  clang/tools/driver/CMakeLists.txt


Index: clang/tools/driver/CMakeLists.txt
===
--- clang/tools/driver/CMakeLists.txt
+++ clang/tools/driver/CMakeLists.txt
@@ -82,7 +82,7 @@
   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)


Index: clang/tools/driver/CMakeLists.txt
===
--- clang/tools/driver/CMakeLists.txt
+++ clang/tools/driver/CMakeLists.txt
@@ -82,7 +82,7 @@
   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


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

2021-09-20 Thread Shivam Gupta via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfae57a6a9795: [Clang] [Fix] Clang build fails when build 
directory contains space character (authored by Brain Swift 
, committed by xgupta).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109979

Files:
  clang/tools/driver/CMakeLists.txt


Index: clang/tools/driver/CMakeLists.txt
===
--- clang/tools/driver/CMakeLists.txt
+++ clang/tools/driver/CMakeLists.txt
@@ -82,7 +82,7 @@
   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)


Index: clang/tools/driver/CMakeLists.txt
===
--- clang/tools/driver/CMakeLists.txt
+++ clang/tools/driver/CMakeLists.txt
@@ -82,7 +82,7 @@
   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


[PATCH] D110260: [ORC] Minor renaming and typo fixes (NFC)

2021-09-23 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta added a comment.

Although this patch is correct, running  ./LLJITWithTargetProcessControl result 
in segmentation fault.

PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash 
backtrace.
Stack dump:
0.  Program arguments: ./LLJITWithTargetProcessControl
#0 0x7fdee365ab73 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) 
(/home/xgupta/llvm/llvm-upstream/build/bin/../lib/libLLVMSupport.so.14git+0x1f6b73)
#1 0x7fdee365892e llvm::sys::RunSignalHandlers() 
(/home/xgupta/llvm/llvm-upstream/build/bin/../lib/libLLVMSupport.so.14git+0x1f492e)
#2 0x7fdee365b03a SignalHandler(int) Signals.cpp:0:0
#3 0x7fdee3c16870 __restore_rt sigaction.c:0:0
#4 0x7fdee461a9e4 
llvm::orc::EPCIndirectionUtils::Create(llvm::orc::ExecutorProcessControl&) 
(/home/xgupta/llvm/llvm-upstream/build/bin/../lib/libLLVMOrcJIT.so.14git+0xfb9e4)
#5 0x00208781 main (./LLJITWithTargetProcessControl+0x208781)
#6 0x7fdee2f48b25 __libc_start_main (/usr/lib/libc.so.6+0x27b25)
#7 0x00207fde _start (./LLJITWithTargetProcessControl+0x207fde)
[1]52081 segmentation fault (core dumped)  ./LLJITWithTargetProcessControl


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110260

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


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

2021-09-23 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta accepted this revision.
xgupta added a comment.

I can push this for you @fcambus.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110041

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


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

2021-09-23 Thread Shivam Gupta via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7f5ca8cc2158: [clang] Use portable "#!/usr/bin/env 
bash" shebang for tools and utils. (authored by fcambus, committed by 
xgupta).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110041

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


Index: clang/utils/make-ast-dump-check.sh
===
--- clang/utils/make-ast-dump-check.sh
+++ 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.
Index: clang/tools/diag-build/diag-build.sh
===
--- clang/tools/diag-build/diag-build.sh
+++ 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.
 #


Index: clang/utils/make-ast-dump-check.sh
===
--- clang/utils/make-ast-dump-check.sh
+++ 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.
Index: clang/tools/diag-build/diag-build.sh
===
--- clang/tools/diag-build/diag-build.sh
+++ 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.
 #
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D110260: [ORC] Minor renaming and typo fixes (NFC)

2021-09-23 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta accepted this revision.
xgupta added a comment.
This revision is now accepted and ready to land.

In D110260#3018110 , @sgraenitz wrote:

> Thanks @xgupta for your note! The parameter passed to 
> `EPCIndirectionUtils::Create()` in the example was referencing a moved-from 
> value. This caused the segfault. Unfortunately, the examples don't have good 
> test coverage so far.

Yeah we need testcases, now it says

JIT session error: Symbols not found: [ return1 ]
JIT session error: Failed to materialize symbols: { (main, { foo_body }) }
Unable to lazily compile function. Exiting.

Anyways the current patch LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110260

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


[PATCH] D110260: [ORC] Minor renaming and typo fixes (NFC)

2021-09-23 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta added a comment.

In D110260#3018555 , @sgraenitz wrote:

> Interesting, it does work for me now on macOS with both, shared libs on and 
> off. Can you please check if you get something like this as well:
>
>   ➜ nm bin/LLJITWithExecutorProcessControl | grep return1
>   00014c10 T _return1

nothing return, I am arch linux (an rolling release distribution which has all 
the latest packages) and building LLVM with shared libs config.
 cmake ../llvm -DLLVM_TARGETS_TO_BUILD="X86"  -DCMAKE_BUILD_TYPE=Release 
-DLLVM_BUILD_TOOLS=ON -DLLVM_USE_LINKER=lld -DBUILD_SHARED_LIBS=ON 
-DCMAKE_C_COMPILER=/usr/local/bin/clang \
 -DCMAKE_CXX_COMPILER=/usr/local/bin/clang++ -DCMAKE_EXPORT_COMPILE_COMMANDS=ON 
-DLLVM_BUILD_EXAMPLES=ON


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110260

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


[PATCH] D110260: [ORC] Minor renaming and typo fixes (NFC)

2021-09-23 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta added a comment.

Problem is fixed with D110345 , Thank you 
very much for quick fixes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110260

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


[PATCH] D110257: [CFE][Codegen] Do not break the contiguity of static allocas.

2021-09-24 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta added a comment.

Nice work.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110257

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


[PATCH] D110257: [CFE][Codegen] Do not break the contiguity of static allocas.

2021-09-28 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta added a comment.

nice work


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110257

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


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

2021-09-29 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta accepted this revision.
xgupta added a comment.
This revision is now accepted and ready to land.

LG, Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110715

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


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

2021-09-29 Thread Shivam Gupta via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7a7caf97012f: [clang] Fix library name (libsupc++) in the 
admonition note. (authored by fcambus, committed by xgupta).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110715

Files:
  clang/docs/Toolchain.rst


Index: clang/docs/Toolchain.rst
===
--- clang/docs/Toolchain.rst
+++ clang/docs/Toolchain.rst
@@ -312,7 +312,7 @@
 
 .. 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++``.
 


Index: clang/docs/Toolchain.rst
===
--- clang/docs/Toolchain.rst
+++ clang/docs/Toolchain.rst
@@ -312,7 +312,7 @@
 
 .. 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


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

2021-09-29 Thread Shivam Gupta via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG01641f665f5a: [clang] Fix sentence in the usage section of 
ThinLTO docs. (authored by fcambus, committed by xgupta).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110750

Files:
  clang/docs/ThinLTO.rst


Index: clang/docs/ThinLTO.rst
===
--- clang/docs/ThinLTO.rst
+++ clang/docs/ThinLTO.rst
@@ -87,7 +87,7 @@
 
 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:


Index: clang/docs/ThinLTO.rst
===
--- clang/docs/ThinLTO.rst
+++ clang/docs/ThinLTO.rst
@@ -87,7 +87,7 @@
 
 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


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

2021-09-29 Thread Shivam Gupta via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG97a0ba475d10: [clang] Update Clang version from 13 to 14 in 
scan-build.1. (authored by fcambus, committed by xgupta).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110763

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


Index: clang/tools/scan-build/man/scan-build.1
===
--- clang/tools/scan-build/man/scan-build.1
+++ 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


Index: clang/tools/scan-build/man/scan-build.1
===
--- clang/tools/scan-build/man/scan-build.1
+++ 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


[PATCH] D110836: [CMake] Fix typo in error message for LLD in bootstrap builds.

2021-09-30 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta accepted this revision.
xgupta added a comment.
This revision is now accepted and ready to land.

LGTM, Thanks!  And @fcambus If you want to continue contributing to the 
llvm-project, I would suggest you ask for commit access so you can directly 
commit typo fixes without opening revisions. Instructions are here 
-https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110836

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


[PATCH] D95737: [NFC][Docs] Fix RAVFrontendAction doc's CMakelists.txt for Shared build

2021-02-13 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta added a comment.

Thank @awarzynski for reviewing and explaining the details. I somehow missed 
it. Should be fixed by  
https://github.com/llvm/llvm-project/commit/d1ef9a63a68850bbe8cd8877f69c41833804c8dc


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95737

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


[PATCH] D104198: [Matrix] Add documentation for compound assignment and type conversion of matrix types

2021-06-26 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta added inline comments.



Comment at: clang/docs/LanguageExtensions.rst:539
+.. code-block:: c++
+  typedef float m4x4_t __attribute__((matrix_type(4, 4)));
+

This is incorrect ig.

I get warning message :

Warning, treated as error:
/home/user/llvm-project/clang/docs/LanguageExtensions.rst:538:Error in 
"code-block" directive:
maximum 1 argument(s) allowed, 6 supplied.
 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104198

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


[PATCH] D104198: [Matrix] Add documentation for compound assignment and type conversion of matrix types

2021-06-26 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta added inline comments.



Comment at: clang/docs/LanguageExtensions.rst:538
+
+.. code-block:: c++
+  typedef float m4x4_t __attribute__((matrix_type(4, 4)));

oh just an blank line is needed :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104198

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


[PATCH] D104971: [Matrix] Minor fixes with language extension docs

2021-06-26 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta accepted this revision.
xgupta added a comment.
This revision is now accepted and ready to land.

In D104971#2842293 , @SaurabhJha 
wrote:

> This is a light patch that probably does not require a review and I created a 
> patch anyway.
>
> Would it be appropriate to get this into main using `arc land` if this is 
> approved? I saw this https://reviews.llvm.org/D78867 which advises against 
> `arc land` but could not find anything related to that in the main docs.

I follow 
https://www.llvm.org/docs/Phabricator.html#committing-someone-s-change-from-phabricator
which says `git push https://github.com/llvm/llvm-project.git HEAD:main`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104971

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


[PATCH] D104971: [Matrix] Minor fixes with language extension docs

2021-06-26 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta added a comment.

btw you should use [Docs] or [NFC]  for this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104971

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


[PATCH] D104981: [clang-tidy] Add -line-filter to run-clang-tidy.py

2021-06-27 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta added reviewers: njames93, kbobyrev.
xgupta added a comment.

Assuming this is your first patch, I add two reviewers for this patch who touch 
this file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104981

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


[PATCH] D104604: [clang] NFC: add line break at the end of if expressions

2021-06-30 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta added a comment.

It seems you need someone to commit this patch? If so you need to share your 
name and email address. So that someone with commit access can commit it for 
you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104604

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


[PATCH] D105049: [NFC] Remove extra semicolons in clang/lib/APINotes/APINotesFormat.h

2021-06-30 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta added a comment.

> These result in warnings while building and don't need to be there.

What are the warnings you get, I run `make clangAPINotes` didn't get any. I am 
on a7ed55f64c5fdce9af3257458779402fb9de1f8b 
 (
[AMDGPU] Simplify getReservedNumSGPRs) and using clang version 13.0.0 
(328377307ad2da961b3be0f2bbf1814a6f1f4ed3 
).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105049

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


[PATCH] D105185: [AIX] Add _AIX73 version macro

2021-06-30 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta accepted this revision.
xgupta added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: clang/lib/Basic/Targets/OSTargets.h:704
+if (OsVersion >= std::make_pair(7, 3))
+  Builder.defineMacro("_AIX73");
 

Seems this line need formatting?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105185

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


[PATCH] D105185: [AIX] Add _AIX73 version macro

2021-06-30 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta added inline comments.



Comment at: clang/lib/Basic/Targets/OSTargets.h:704
+if (OsVersion >= std::make_pair(7, 3))
+  Builder.defineMacro("_AIX73");
 

Jake-Egan wrote:
> xgupta wrote:
> > Seems this line need formatting?
> I originally had it matching the format of the other _AIX macro definitions, 
> but clang-format modified it to this.
I think clang-format is there to maintain consistency in the codebase. You can 
ignore it if it is doing the opposite.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105185

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


[PATCH] D105185: [AIX] Add _AIX73 version macro

2021-06-30 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta added inline comments.



Comment at: clang/lib/Basic/Targets/OSTargets.h:704
+if (OsVersion >= std::make_pair(7, 3))
+  Builder.defineMacro("_AIX73");
 

Jake-Egan wrote:
> xgupta wrote:
> > Jake-Egan wrote:
> > > xgupta wrote:
> > > > Seems this line need formatting?
> > > I originally had it matching the format of the other _AIX macro 
> > > definitions, but clang-format modified it to this.
> > I think clang-format is there to maintain consistency in the codebase. You 
> > can ignore it if it is doing the opposite.
> Do you suggest that I revise the formatting then?
Yeah, I think so, neglect clang-format. But you can wait for other reviewer's 
comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105185

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


[PATCH] D105408: [clang-format] Pass a TextDiagnosticPrinter when we can not create tempory file.

2021-07-04 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta added subscribers: MyDeveloperDay, xgupta.
xgupta added a reviewer: MyDeveloperDay.
xgupta added a comment.

Thanks for the patch @Et7f3! I tested it locally and can reproduce it with cat 
folder/file.c
int main()
{
return 0;
}
And indeed the patch also solved the crash issue and emit a correct error 
message but I am not sure about its implementation, I think @MyDeveloperDay can 
best review this patch.

There is a nit in the patch summary, `clang-format -i root/file.c` should be 
`clang-format -i folder/file.c`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105408

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


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

2021-11-26 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta accepted this revision.
xgupta added a comment.
This revision is now accepted and ready to land.

LGTM, thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114632

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


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

2021-11-26 Thread Shivam Gupta via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa3b099b68c0c: [Docs] Removed /Zd flag still mentioned in 
documentation (authored by BHUMITRAM, committed by xgupta).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114632

Files:
  clang/docs/UsersManual.rst


Index: clang/docs/UsersManual.rst
===
--- clang/docs/UsersManual.rst
+++ clang/docs/UsersManual.rst
@@ -3716,7 +3716,6 @@
   /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


Index: clang/docs/UsersManual.rst
===
--- clang/docs/UsersManual.rst
+++ clang/docs/UsersManual.rst
@@ -3716,7 +3716,6 @@
   /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


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

2023-01-26 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta created this revision.
xgupta added reviewers: nickdesaulniers, aaron.ballman.
Herald added a project: All.
xgupta requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

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) {}
}


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142609

Files:
  clang/lib/Sema/SemaExpr.cpp


Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -13593,18 +13593,21 @@
 Diag(Loc, diag::warn_enum_constant_in_bool_context);
 
   // Diagnose cases where the user write a logical and/or but probably meant a
-  // bitwise one.  We do this when the LHS is a non-bool integer and the RHS
-  // is a constant.
-  if (!EnumConstantInBoolContext && LHS.get()->getType()->isIntegerType() &&
-  !LHS.get()->getType()->isBooleanType() &&
-  RHS.get()->getType()->isIntegerType() && !RHS.get()->isValueDependent() 
&&
+  // bitwise one.  We do this when one of the operand is a non-bool integer and
+  // the other is a constant.
+  if (!EnumConstantInBoolContext &&
+  ((RHS.get()->getType()->isIntegerType() && 
!RHS.get()->getType()->isBooleanType() &&
+  LHS.get()->getType()->isIntegerType() && !LHS.get()->isValueDependent()) 
||
+  ( RHS.get()->getType()->isIntegerType() && 
!RHS.get()->getType()->isBooleanType() &&
+  LHS.get()->getType()->isIntegerType() && 
!LHS.get()->isValueDependent())) &&
   // Don't warn in macros or template instantiations.
   !Loc.isMacroID() && !inTemplateInstantiation()) {
-// If the RHS can be constant folded, and if it constant folds to something
+// If the operand 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.
+// Parens on the operand are ignored.
 Expr::EvalResult EVResult;
+
 if (RHS.get()->EvaluateAsInt(EVResult, Context)) {
   llvm::APSInt Result = EVResult.Val.getInt();
   if ((getLangOpts().Bool && !RHS.get()->getType()->isBooleanType() &&
@@ -13626,6 +13629,28 @@
  RHS.get()->getEndLoc()));
   }
 }
+
+if (LHS.get()->EvaluateAsInt(EVResult, Context)) {
+  llvm::APSInt Result = EVResult.Val.getInt();
+  if ((getLangOpts().Bool && !LHS.get()->getType()->isBooleanType() &&
+   !LHS.get()->getExprLoc().isMacroID()) ||
+  (Result != 0 && Result != 1)) {
+Diag(Loc, diag::warn_logical_instead_of_bitwise)
+<< LHS.get()->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 "kNonZero && foo() " with "Foo()"
+  Diag(Loc, diag::note_logical_instead_of_bitwise_remove_constant)
+  << FixItHint::CreateRemoval(
+ SourceRange(getLocForEndOfToken(RHS.get()->getEndLoc()),
+ LHS.get()->getEndLoc()));
+  }
+}
   }
 
   if (!Context.getLangOpts().CPlusPlus) {


Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -13593,18 +13593,21 @@
 Diag(Loc, diag::warn_enum_constant_in_bool_context);
 
   // Diagnose cases where the user write a logical and/or but probably meant a
-  // bitwise one.  We do this when the LHS is a non-bool integer and the RHS
-  // is a constant.
-  if (!EnumConstantInBoolContext && LHS.get()->getType()->isIntegerType() &&
-  !LHS.get()->getType()->isBooleanType() &&
-  RHS.get()->getType()->isIntegerType() && !RHS.get()->isValueDependent() &&
+  // bitwise one.  We do this when one of the operand is a non-bool integer and
+  // the other is a constant.
+  if (!EnumConstantInBoolContext &&
+  ((RHS.get()->getType()->isIntegerType() && !RHS.get()->getType()->isBooleanType() &&
+  LHS.get()->getType()->isIntegerType() && !LHS.get()->isValueDependent()) ||
+  ( RHS.get()->getType()->isIntegerType() && !RHS.get()->getType()->isBooleanType() &&
+  LHS.get()->getType()->isIntegerType() && !LHS.get()->isValueDependent())) &&
   // Don't warn in macros or template instantiations.
   !Loc.isMacroID() && !inTemplateInstantiation()) {
-// If the RHS can be constant folded, and if it constant folds to something

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

2023-01-26 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta updated this revision to Diff 492374.
xgupta added a comment.

add test cases


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142609

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Sema/exprs.c
  clang/test/SemaCXX/expressions.cpp

Index: clang/test/SemaCXX/expressions.cpp
===
--- clang/test/SemaCXX/expressions.cpp
+++ clang/test/SemaCXX/expressions.cpp
@@ -44,6 +44,9 @@
   return x && 4; // expected-warning {{use of logical '&&' with constant operand}} \
// expected-note {{use '&' for a bitwise operation}} \
// expected-note {{remove constant to silence this warning}}
+  return 4 && x; // expected-warning {{use of logical '&&' with constant operand}} \
+   // expected-note {{use '&' for a bitwise operation}} \
+   // expected-note {{remove constant to silence this warning}}
 
   return x && sizeof(int) == 4;  // no warning, RHS is logical op.
   return x && true;
@@ -66,6 +69,8 @@
// expected-note {{use '|' for a bitwise operation}}
   return x || 5; // expected-warning {{use of logical '||' with constant operand}} \
// expected-note {{use '|' for a bitwise operation}}
+  return 5 || x; // expected-warning {{use of logical '||' with constant operand}} \
+   // expected-note {{use '|' for a bitwise operation}}
   return x && 0; // expected-warning {{use of logical '&&' with constant operand}} \
// expected-note {{use '&' for a bitwise operation}} \
// expected-note {{remove constant to silence this warning}}
Index: clang/test/Sema/exprs.c
===
--- clang/test/Sema/exprs.c
+++ clang/test/Sema/exprs.c
@@ -212,6 +212,10 @@
  // expected-note {{use '&' for a bitwise operation}} \
  // expected-note {{remove constant to silence this warning}}
 
+  return 4 && x; // expected-warning {{use of logical '&&' with constant operand}} \
+ // expected-note {{use '&' for a bitwise operation}} \
+ // expected-note {{remove constant to silence this warning}}
+
   return x && sizeof(int) == 4;  // no warning, RHS is logical op.
   
   // no warning, this is an idiom for "true" in old C style.
@@ -223,6 +227,9 @@
   // expected-note {{use '|' for a bitwise operation}}
   return x || 5; // expected-warning {{use of logical '||' with constant operand}} \
  // expected-note {{use '|' for a bitwise operation}}
+  return 5 || x; // expected-warning {{use of logical '||' with constant operand}} \
+ // expected-note {{use '|' for a bitwise operation}}
+
   return x && 0;
   return x && 1;
   return x && -1; // expected-warning {{use of logical '&&' with constant operand}} \
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -13593,18 +13593,21 @@
 Diag(Loc, diag::warn_enum_constant_in_bool_context);
 
   // Diagnose cases where the user write a logical and/or but probably meant a
-  // bitwise one.  We do this when the LHS is a non-bool integer and the RHS
-  // is a constant.
-  if (!EnumConstantInBoolContext && LHS.get()->getType()->isIntegerType() &&
-  !LHS.get()->getType()->isBooleanType() &&
-  RHS.get()->getType()->isIntegerType() && !RHS.get()->isValueDependent() &&
+  // bitwise one.  We do this when one of the operand is a non-bool integer and
+  // the other is a constant.
+  if (!EnumConstantInBoolContext &&
+  ((RHS.get()->getType()->isIntegerType() && !RHS.get()->getType()->isBooleanType() &&
+  LHS.get()->getType()->isIntegerType() && !LHS.get()->isValueDependent()) ||
+  ( RHS.get()->getType()->isIntegerType() && !RHS.get()->getType()->isBooleanType() &&
+  LHS.get()->getType()->isIntegerType() && !LHS.get()->isValueDependent())) &&
   // Don't warn in macros or template instantiations.
   !Loc.isMacroID() && !inTemplateInstantiation()) {
-// If the RHS can be constant folded, and if it constant folds to something
+// If the operand 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.
+// Parens on the operand are ignored.
 Expr::EvalResult EVResult;
+
 if (RHS.get()->EvaluateAsInt(EVResult, Context)) {
   llvm::APSInt Result = EVResult.Val.getInt();
   if ((getLangOpts().Bool && !RHS.get()->getType()->isBooleanType() &&
@@ -13626,6 +13629,28 @@
  RHS.get()->getEndLoc()));
   }
 }
+
+if (LHS.get()->EvaluateAsInt(EVResult, Contex

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

2023-01-26 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta added a comment.

WIP && TODO- Fixed test

Failed Tests (7):

  Clang :: C/drs/dr4xx.c
  Clang :: Modules/explicit-build-extra-files.cpp
  Clang :: Parser/cxx2a-concept-declaration.cpp
  Clang :: SemaCXX/expressions.cpp
  Clang :: SemaCXX/warn-unsequenced.cpp
  Clang :: SemaObjC/unguarded-availability.m
  Clang :: SemaTemplate/dependent-expr.cpp


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142609

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


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

2023-01-28 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta updated this revision to Diff 492995.
xgupta added a comment.

update test cases


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142609

Files:
  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

Index: clang/test/SemaTemplate/dependent-expr.cpp
===
--- clang/test/SemaTemplate/dependent-expr.cpp
+++ clang/test/SemaTemplate/dependent-expr.cpp
@@ -43,7 +43,9 @@
 
 namespace PR7724 {
   template int myMethod()
-  { return 2 && sizeof(OT); }
+  { return 2 && sizeof(OT); } // expected-warning {{use of logical '&&' with constant operand}} \
+  // expected-note {{use '&' for a bitwise operation}} \
+  // expected-note {{remove constant to silence this warning}}
 }
 
 namespace test4 {
Index: clang/test/SemaCXX/warn-unsequenced.cpp
===
--- clang/test/SemaCXX/warn-unsequenced.cpp
+++ clang/test/SemaCXX/warn-unsequenced.cpp
@@ -76,15 +76,37 @@
 
   (xs[2] && (a = 0)) + a; // cxx11-warning {{unsequenced modification and access to 'a'}}
   // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
-  (0 && (a = 0)) + a; // ok
+
+  (0 && (a = 0)) + a; // cxx11-warning {{use of logical '&&' with constant operand}}
+  // cxx11-note@-1 {{use '&' for a bitwise operation}}
+  // cxx11-note@-2 {{remove constant to silence this warning}}
+  // cxx17-warning@-3 {{use of logical '&&' with constant operand}}
+  // cxx17-note@-4 {{use '&' for a bitwise operation}}
+  // cxx17-note@-5 {{remove constant to silence this warning}}
+
   (1 && (a = 0)) + a; // cxx11-warning {{unsequenced modification and access to 'a'}}
   // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
+  // cxx11-warning@-2 {{use of logical '&&' with constant operand}}
+  // cxx11-note@-3 {{use '&' for a bitwise operation}}
+  // cxx11-note@-4 {{remove constant to silence this warning}}
+  // cxx17-warning@-5 {{use of logical '&&' with constant operand}}
+  // cxx17-note@-6 {{use '&' for a bitwise operation}}
+  // cxx17-note@-7 {{remove constant to silence this warning}}
+
 
   (xs[3] || (a = 0)) + a; // cxx11-warning {{unsequenced modification and access to 'a'}}
   // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
   (0 || (a = 0)) + a; // cxx11-warning {{unsequenced modification and access to 'a'}}
   // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
-  (1 || (a = 0)) + a; // ok
+  // cxx11-warning@-2 {{use of logical '||' with constant operand}}
+  // cxx11-note@-3 {{use '|' for a bitwise operation}}
+  // cxx17-warning@-4 {{use of logical '||' with constant operand}}
+  // cxx17-note@-5 {{use '|' for a bitwise operation}}
+  (1 || (a = 0)) + a; // cxx11-warning {{use of logical '||' with constant operand}}
+  // cxx11-note@-1 {{use '|' for a bitwise operation}}
+  // cxx17-warning@-2 {{use of logical '||' with constant operand}}
+  // cxx17-note@-3 {{use '|' for a bitwise operation}}
+
 
   (xs[4] ? a : ++a) + a; // cxx11-warning {{unsequenced modification and access to 'a'}}
  // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
Index: clang/test/SemaCXX/expressions.cpp
===
--- clang/test/SemaCXX/expressions.cpp
+++ clang/test/SemaCXX/expressions.cpp
@@ -44,6 +44,9 @@
   return x && 4; // expected-warning {{use of logical '&&' with constant operand}} \
// expected-note {{use '&' for a bitwise operation}} \
// expected-note {{remove constant to silence this warning}}
+  return 4 && x; // expected-warning {{use of logical '&&' with constant operand}} \
+   // expected-note {{use '&' for a bitwise operation}} \
+   // expected-note {{remove constant to silence this warning}}
 
   return x && sizeof(int) == 4;  // no warning, RHS is logical op.
   return x && true;
@@ -66,6 +69,8 @@
// expected-note {{use '|' for a bitwise operation}}
   return x || 5; // expected-warning {{use of logical '||' with constant operand}} \
// expec

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

2023-01-28 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta created this revision.
xgupta added reviewers: aaron.ballman, dblaikie.
Herald added a project: All.
xgupta requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142826

Files:
  clang/include/clang/Basic/DiagnosticGroups.td


Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -992,6 +992,7 @@
 EmptyInitStatement,
 StringConcatation,
 FUseLdPath,
+TypeLimits,
   ]>;
 
 def Most : DiagGroup<"most", [


Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -992,6 +992,7 @@
 EmptyInitStatement,
 StringConcatation,
 FUseLdPath,
+TypeLimits,
   ]>;
 
 def Most : DiagGroup<"most", [
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2023-01-30 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta updated this revision to Diff 493477.
xgupta added a comment.

address comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142826

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/test/Sema/tautological-constant-compare.c


Index: clang/test/Sema/tautological-constant-compare.c
===
--- clang/test/Sema/tautological-constant-compare.c
+++ 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 -Wno-type-limits -verify=silent %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wextra 
-Wno-sign-compare -Wno-type-limits -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
Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -992,6 +992,7 @@
 EmptyInitStatement,
 StringConcatation,
 FUseLdPath,
+TypeLimits,
   ]>;
 
 def Most : DiagGroup<"most", [


Index: clang/test/Sema/tautological-constant-compare.c
===
--- clang/test/Sema/tautological-constant-compare.c
+++ 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 -Wno-type-limits -verify=silent %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wextra -Wno-sign-compare -Wno-type-limits -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
Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -992,6 +992,7 @@
 EmptyInitStatement,
 StringConcatation,
 FUseLdPath,
+TypeLimits,
   ]>;
 
 def Most : DiagGroup<"most", [
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2023-01-30 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta updated this revision to Diff 493479.
xgupta added a comment.

update release note


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142826

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


Index: clang/test/Sema/tautological-constant-compare.c
===
--- clang/test/Sema/tautological-constant-compare.c
+++ 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 -Wno-type-limits -verify=silent %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wextra 
-Wno-sign-compare -Wno-type-limits -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
Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -992,6 +992,7 @@
 EmptyInitStatement,
 StringConcatation,
 FUseLdPath,
+TypeLimits,
   ]>;
 
 def Most : DiagGroup<"most", [
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -42,6 +42,9 @@
 Clang |release| because of the opportunity they pose for disruption to existing
 code bases.
 
+- -Wtype-limits added to -Wextra for GCC compatibility. This fixes
+  `Issue 58375 `_.
+
 What's New in Clang |release|?
 ==
 Some of the major new features and improvements to Clang are listed


Index: clang/test/Sema/tautological-constant-compare.c
===
--- clang/test/Sema/tautological-constant-compare.c
+++ 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 -Wno-type-limits -verify=silent %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wextra -Wno-sign-compare -Wno-type-limits -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
Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -992,6 +992,7 @@
 EmptyInitStatement,
 StringConcatation,
 FUseLdPath,
+TypeLimits,
   ]>;
 
 def Most : DiagGroup<"most", [
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -42,6 +42,9 @@
 Clang |release| because of the opportunity they pose for disruption to existing
 code bases.
 
+- -Wtype-limits added to -Wextra for GCC compatibility. This fixes
+  `Issue 58375 `_.
+
 What's New in Clang |release|?
 ==
 Some of the major new features and improvements to Clang are listed
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2023-01-30 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta added a comment.

In D142826#4090415 , @aaron.ballman 
wrote:

> Heh, I literally started working on this on Friday afternoon. :-D

Yeah, I saw someone asking about it on discord on Sunday. so thought to look.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142826

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


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

2023-01-31 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta updated this revision to Diff 493649.
xgupta added a comment.

address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142826

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

Index: clang/test/Sema/tautological-constant-compare.c
===
--- clang/test/Sema/tautological-constant-compare.c
+++ 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 -verify %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wextra -Wno-sign-compare -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
@@ -28,7 +28,7 @@
   if (c > 255) // expected-warning {{comparison 'unsigned char' > 255 is always false}}
   return;
 #else
-  if (c > 255)
+  if (c > 255) // expected-warning {{result of comparison 'unsigned char' > 255 is always false}}
   return;
 #endif
 
@@ -194,9 +194,9 @@
 return 0;
   if (s < 32767)
 return 0;
-  if (s <= 32767)
+  if (s <= 32767) // expected-warning {{result of comparison 'short' <= 32767 is always true}}
 return 0;
-  if (s > 32767)
+  if (s > 32767) // expected-warning {{result of comparison 'short' > 32767 is always false}}
 return 0;
   if (s >= 32767)
 return 0;
@@ -205,13 +205,13 @@
 return 0;
   if (32767 != s)
 return 0;
-  if (32767 < s)
+  if (32767 < s) // expected-warning {{result of comparison 32767 < 'short' is always false}}
 return 0;
   if (32767 <= s)
 return 0;
   if (32767 > s)
 return 0;
-  if (32767 >= s)
+  if (32767 >= s) // expected-warning {{result of comparison 32767 >= 'short' is always true}}
 return 0;
 
   // FIXME: assumes two's complement
@@ -219,13 +219,13 @@
 return 0;
   if (s != -32768)
 return 0;
-  if (s < -32768)
+  if (s < -32768) // expected-warning {{result of comparison 'short' < -32768 is always false}}
 return 0;
   if (s <= -32768)
 return 0;
   if (s > -32768)
 return 0;
-  if (s >= -32768)
+  if (s >= -32768) // expected-warning {{result of comparison 'short' >= -32768 is always true}}
 return 0;
 
   if (-32768 == s)
@@ -234,9 +234,9 @@
 return 0;
   if (-32768 < s)
 return 0;
-  if (-32768 <= s)
+  if (-32768 <= s) // expected-warning {{result of comparison -32768 <= 'short' is always true}}
 return 0;
-  if (-32768 > s)
+  if (-32768 > s) // expected-warning {{result of comparison -32768 > 'short' is always false}}
 return 0;
   if (-32768 >= s)
 return 0;
@@ -272,13 +272,13 @@
 return 0;
   if (s != -32768L)
 return 0;
-  if (s < -32768L)
+  if (s < -32768L) // expected-warning {{esult of comparison 'short' < -32768 is always false}}
 return 0;
   if (s <= -32768L)
 return 0;
   if (s > -32768L)
 return 0;
-  if (s >= -32768L)
+  if (s >= -32768L) // expected-warning {{esult of comparison 'short' >= -32768 is always true}}
 return 0;
 
   if (-32768L == s)
@@ -287,9 +287,9 @@
 return 0;
   if (-32768L < s)
 return 0;
-  if (-32768L <= s)
+  if (-32768L <= s) // expected-warning {{result of comparison -32768 <= 'short' is always true}}
 return 0;
-  if (-32768L > s)
+  if (-32768L > s) // expected-warning {{result of comparison -32768 > 'short' is always false}}
 return 0;
   if (-32768L >= s)
 return 0;
@@ -382,9 +382,9 @@
   return 0;
   if (us < 65535)
   return 0;
-  if (us <= 65535)
+  if (us <= 65535) // expected-warning {{result of comparison 'unsigned short' <= 65535 is always true}}
   return 0;
-  if (us > 65535)
+  if (us > 65535) // expected-warning {{result of comparison 'unsigned short' > 65535 is always false}}
   return 0;
   if (us >= 65535)
   return 0;
@@ -393,13 +393,13 @@
   return 0;
   if (65535 != us)
   return 0;
-  if (65535 < us)
+  if (65535 < us) // expected-warning {{result of comparison 65535 < 'unsigned short' is always false}}
   return 0;
   if (65535 <= us)
   return 0;
   if (65535 > us)
   return 0;
-  if (65535 >= us)
+  if (65535 >= us) // expected-warning {{result of

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

2023-01-31 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta updated this revision to Diff 493810.
xgupta added a comment.

address comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142826

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


Index: clang/test/Sema/tautological-constant-compare.c
===
--- clang/test/Sema/tautological-constant-compare.c
+++ 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
Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -992,6 +992,7 @@
 EmptyInitStatement,
 StringConcatation,
 FUseLdPath,
+TypeLimits,
   ]>;
 
 def Most : DiagGroup<"most", [
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -58,6 +58,9 @@
   inside a namespace. This fixes
   `Issue 59446 `_.
 
+- ``-Wtype-limits`` was added to ``-Wextra`` for GCC compatibility. This fixes
+  `Issue 58375 `_.
+
 Improvements to Clang's diagnostics
 ^^^
 


Index: clang/test/Sema/tautological-constant-compare.c
===
--- clang/test/Sema/tautological-constant-compare.c
+++ 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
Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -992,6 +992,7 @@
 EmptyInitStatement,
 StringConcatation,
 FUseLdPath,
+TypeLimits,
   ]>;
 
 def Most : DiagGroup<"most", [
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -58,6 +58,9 @@
   inside a namespace. This fixes
   `Issue 59446 `_.
 
+- ``-Wtype-limits`` was added to ``-Wextra`` for GCC compatibility. This fixes
+  `Issue 58375 `_.
+
 Improvements to Clang's diagnostics
 ^^^
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2023-02-01 Thread Shivam Gupta via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG95668c0d97e6: [Clang] Add -Wtype-limits to -Wextra for GCC 
compatibility (authored by xgupta).

Changed prior to commit:
  https://reviews.llvm.org/D142826?vs=493810&id=493924#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142826

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


Index: clang/test/Sema/tautological-constant-compare.c
===
--- clang/test/Sema/tautological-constant-compare.c
+++ 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
Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -992,6 +992,7 @@
 EmptyInitStatement,
 StringConcatation,
 FUseLdPath,
+TypeLimits,
   ]>;
 
 def Most : DiagGroup<"most", [
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -61,6 +61,9 @@
   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


Index: clang/test/Sema/tautological-constant-compare.c
===
--- clang/test/Sema/tautological-constant-compare.c
+++ 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
Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -992,6 +992,7 @@
 EmptyInitStatement,
 StringConcatation,
 FUseLdPath,
+TypeLimits,
   ]>;
 
 def Most : DiagGroup<"most", [
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -61,6 +61,9 @@
   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

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

2023-02-01 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta added a comment.

In D142826#4096348 , @aaron.ballman 
wrote:

> LGTM, thank you!

Thank you for reviewing and helping it to commit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142826

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


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

2023-02-01 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta added a comment.

In D142826#4098076 , @hctim wrote:

> Hey, looks like this broke the x86_64-linux sanitizer buildbot: 
> https://lab.llvm.org/buildbot/#/builders/37/builds/19910
>
> You can reproduce the bot using the instructions at 
> https://github.com/google/sanitizers/wiki/SanitizerBotReproduceBuild 
> (substitute `buildbot_fast.sh` for `buildbot_cmake.sh` to get the right one, 
> but I don't think using the official buildscript is necessary. This looks 
> like a 2-stage compile is not currently `-Wextra -Werror` clean:
>
>   
> /b/sanitizer-x86_64-linux/build/llvm-project/llvm/lib/ProfileData/InstrProfReader.cpp:177:41:
>  error: result of comparison 'uint64_t' (aka 'unsigned long') > 
> 18446744073709551615 is always false 
> [-Werror,-Wtautological-type-limit-compare]
> if (uint64_t(Buffer->getBufferSize()) > 
> std::numeric_limits::max())
> ~ ^ 
> 
>   
> /b/sanitizer-x86_64-linux/build/llvm-project/llvm/lib/ProfileData/InstrProfReader.cpp:227:41:
>  error: result of comparison 'uint64_t' (aka 'unsigned long') > 
> 18446744073709551615 is always false 
> [-Werror,-Wtautological-type-limit-compare]
> if (uint64_t(Buffer->getBufferSize()) > 
> std::numeric_limits::max())
> ~ ^ 
> 
>
> I tried to whack-a-mole those two bugs (see my two commits on 
> https://lab.llvm.org/buildbot/#/builders/37/builds/19926), but there's more 
> latent bugs hanging around.
>
> Probably worth reverting this and the warnings need to be fixed inside 
> clang/llvm first, then we can make it the default.

Sure, revert this for time being. will check later today.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142826

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


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

2023-02-03 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta updated this revision to Diff 494629.
xgupta added a comment.

clang-format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142609

Files:
  clang/lib/Sema/SemaExpr.cpp


Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -13600,19 +13600,18 @@
 Diag(Loc, diag::warn_enum_constant_in_bool_context);
 
   // Diagnose cases where the user write a logical and/or but probably meant a
-  // bitwise one.  We do this when one of the operand is a non-bool integer and
-  // the other is a constant.
-  if (!EnumConstantInBoolContext &&
-  LHS.get()->getType()->isIntegerType() &&
-!LHS.get()->getType()->isBooleanType() &&
-RHS.get()->getType()->isIntegerType() &&
-!RHS.get()->isValueDependent() &&
+  // bitwise one.  We do this when the LHS is a non-bool integer and the RHS
+  // is a constant.
+  if (!EnumConstantInBoolContext && LHS.get()->getType()->isIntegerType() &&
+  !LHS.get()->getType()->isBooleanType() &&
+  RHS.get()->getType()->isIntegerType() && !RHS.get()->isValueDependent() 
&&
   // Don't warn in macros or template instantiations.
   !Loc.isMacroID() && !inTemplateInstantiation()) {
-// If the operand 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 operand 
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 (RHS.get()->EvaluateAsInt(EVResult, Context)) {
@@ -13636,25 +13635,21 @@
  RHS.get()->getEndLoc()));
   }
 }
-}
-
+  }
   // Diagnose cases where the user write a logical and/or but probably meant a
-  // bitwise one.  We do this when one of the operand is a non-bool integer and
-  // the other is a constant.
-  if (!EnumConstantInBoolContext &&
-  RHS.get()->getType()->isIntegerType() &&
-!RHS.get()->getType()->isBooleanType() &&
-LHS.get()->getType()->isIntegerType() &&
-!LHS.get()->isValueDependent() &&
+  // bitwise one.  We do this when the RHS is a non-bool integer and the LHS
+  // is a constant.
+  if (!EnumConstantInBoolContext && RHS.get()->getType()->isIntegerType() &&
+  !RHS.get()->getType()->isBooleanType() &&
+  LHS.get()->getType()->isIntegerType() && !LHS.get()->isValueDependent() 
&&
   // Don't warn in macros or template instantiations.
   !Loc.isMacroID() && !inTemplateInstantiation()) {
-// If the operand 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 operand 
are
-// ignored.
+// If the LHS 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 LHS are ignored.
 Expr::EvalResult EVResult;
 
-
 if (LHS.get()->EvaluateAsInt(EVResult, Context)) {
   llvm::APSInt Result = EVResult.Val.getInt();
   if ((getLangOpts().Bool && !LHS.get()->getType()->isBooleanType() &&
@@ -13669,7 +13664,7 @@
SourceRange(Loc, getLocForEndOfToken(Loc)),
Opc == BO_LAnd ? "&" : "|");
 if (Opc == BO_LAnd)
-  // Suggest replacing "kNonZero && foo() " with "Foo()"
+  // Suggest replacing "kNonZero" && Foo() with "Foo()"
   Diag(Loc, diag::note_logical_instead_of_bitwise_remove_constant)
   << FixItHint::CreateRemoval(
  SourceRange(getLocForEndOfToken(RHS.get()->getEndLoc()),


Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -13600,19 +13600,18 @@
 Diag(Loc, diag::warn_enum_constant_in_bool_context);
 
   // Diagnose cases where the user write a logical and/or but probably meant a
-  // bitwise one.  We do this when one of the operand is a non-bool integer and
-  // the other is a constant.
-  if (!EnumConstantInBoolContext &&
-  LHS.get()->getType()->isIntegerType() &&
-!LHS.get()->getType()->isBooleanType() &&
-RHS.get()->getType()->isIntegerType() &&
-!RHS.get()->isValueDependent() &&
+  // bitwise one.  We do this when the LHS is a non-bool integer and the RHS
+  // is a constant.
+  if (!EnumConstantInBoolContext && LHS.get()->getType()->isIntegerType() &&
+

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

2023-02-03 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta updated this revision to Diff 494631.
xgupta added a comment.

remov blank


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142609

Files:
  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

Index: clang/test/SemaTemplate/dependent-expr.cpp
===
--- clang/test/SemaTemplate/dependent-expr.cpp
+++ clang/test/SemaTemplate/dependent-expr.cpp
@@ -43,7 +43,9 @@
 
 namespace PR7724 {
   template int myMethod()
-  { return 2 && sizeof(OT); }
+  { return 2 && sizeof(OT); } // expected-warning {{use of logical '&&' with constant operand}} \
+  // expected-note {{use '&' for a bitwise operation}} \
+  // expected-note {{remove constant to silence this warning}}
 }
 
 namespace test4 {
Index: clang/test/SemaCXX/warn-unsequenced.cpp
===
--- clang/test/SemaCXX/warn-unsequenced.cpp
+++ clang/test/SemaCXX/warn-unsequenced.cpp
@@ -76,15 +76,37 @@
 
   (xs[2] && (a = 0)) + a; // cxx11-warning {{unsequenced modification and access to 'a'}}
   // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
-  (0 && (a = 0)) + a; // ok
+
+  (0 && (a = 0)) + a; // cxx11-warning {{use of logical '&&' with constant operand}}
+  // cxx11-note@-1 {{use '&' for a bitwise operation}}
+  // cxx11-note@-2 {{remove constant to silence this warning}}
+  // cxx17-warning@-3 {{use of logical '&&' with constant operand}}
+  // cxx17-note@-4 {{use '&' for a bitwise operation}}
+  // cxx17-note@-5 {{remove constant to silence this warning}}
+
   (1 && (a = 0)) + a; // cxx11-warning {{unsequenced modification and access to 'a'}}
   // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
+  // cxx11-warning@-2 {{use of logical '&&' with constant operand}}
+  // cxx11-note@-3 {{use '&' for a bitwise operation}}
+  // cxx11-note@-4 {{remove constant to silence this warning}}
+  // cxx17-warning@-5 {{use of logical '&&' with constant operand}}
+  // cxx17-note@-6 {{use '&' for a bitwise operation}}
+  // cxx17-note@-7 {{remove constant to silence this warning}}
+
 
   (xs[3] || (a = 0)) + a; // cxx11-warning {{unsequenced modification and access to 'a'}}
   // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
   (0 || (a = 0)) + a; // cxx11-warning {{unsequenced modification and access to 'a'}}
   // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
-  (1 || (a = 0)) + a; // ok
+  // cxx11-warning@-2 {{use of logical '||' with constant operand}}
+  // cxx11-note@-3 {{use '|' for a bitwise operation}}
+  // cxx17-warning@-4 {{use of logical '||' with constant operand}}
+  // cxx17-note@-5 {{use '|' for a bitwise operation}}
+  (1 || (a = 0)) + a; // cxx11-warning {{use of logical '||' with constant operand}}
+  // cxx11-note@-1 {{use '|' for a bitwise operation}}
+  // cxx17-warning@-2 {{use of logical '||' with constant operand}}
+  // cxx17-note@-3 {{use '|' for a bitwise operation}}
+
 
   (xs[4] ? a : ++a) + a; // cxx11-warning {{unsequenced modification and access to 'a'}}
  // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
Index: clang/test/SemaCXX/expressions.cpp
===
--- clang/test/SemaCXX/expressions.cpp
+++ clang/test/SemaCXX/expressions.cpp
@@ -44,6 +44,9 @@
   return x && 4; // expected-warning {{use of logical '&&' with constant operand}} \
// expected-note {{use '&' for a bitwise operation}} \
// expected-note {{remove constant to silence this warning}}
+  return 4 && x; // expected-warning {{use of logical '&&' with constant operand}} \
+   // expected-note {{use '&' for a bitwise operation}} \
+   // expected-note {{remove constant to silence this warning}}
 
   return x && sizeof(int) == 4;  // no warning, RHS is logical op.
   return x && true;
@@ -66,6 +69,8 @@
// expected-note {{use '|' for a bitwise operation}}
   return x || 5; // expected-warning {{use of logical '||' with constant operand}} \
// expected-no

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

2023-02-03 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:13611-13653
 if (RHS.get()->EvaluateAsInt(EVResult, Context)) {
   llvm::APSInt Result = EVResult.Val.getInt();
   if ((getLangOpts().Bool && !RHS.get()->getType()->isBooleanType() &&
!RHS.get()->getExprLoc().isMacroID()) ||
   (Result != 0 && Result != 1)) {
 Diag(Loc, diag::warn_logical_instead_of_bitwise)
 << RHS.get()->getSourceRange() << (Opc == BO_LAnd ? "&&" : "||");

nickdesaulniers wrote:
> There seems to be a lot of duplication between the two; should we move these 
> into a static function that's called twice? Perhaps Op1 and Op2 would be 
> better identifiers than LHS RHS in that case?
I have tried many ways, but couldn't figure out a way to do it with function, 
unrelated test cases started failing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142609

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


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

2023-02-06 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta updated this revision to Diff 495116.
xgupta added a comment.

use function to avoid code duplication


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142609

Files:
  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

Index: clang/test/SemaTemplate/dependent-expr.cpp
===
--- clang/test/SemaTemplate/dependent-expr.cpp
+++ clang/test/SemaTemplate/dependent-expr.cpp
@@ -43,7 +43,9 @@
 
 namespace PR7724 {
   template int myMethod()
-  { return 2 && sizeof(OT); }
+  { return 2 && sizeof(OT); } // expected-warning {{use of logical '&&' with constant operand}} \
+  // expected-note {{use '&' for a bitwise operation}} \
+  // expected-note {{remove constant to silence this warning}}
 }
 
 namespace test4 {
Index: clang/test/SemaCXX/warn-unsequenced.cpp
===
--- clang/test/SemaCXX/warn-unsequenced.cpp
+++ clang/test/SemaCXX/warn-unsequenced.cpp
@@ -76,15 +76,37 @@
 
   (xs[2] && (a = 0)) + a; // cxx11-warning {{unsequenced modification and access to 'a'}}
   // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
-  (0 && (a = 0)) + a; // ok
+
+  (0 && (a = 0)) + a; // cxx11-warning {{use of logical '&&' with constant operand}}
+  // cxx11-note@-1 {{use '&' for a bitwise operation}}
+  // cxx11-note@-2 {{remove constant to silence this warning}}
+  // cxx17-warning@-3 {{use of logical '&&' with constant operand}}
+  // cxx17-note@-4 {{use '&' for a bitwise operation}}
+  // cxx17-note@-5 {{remove constant to silence this warning}}
+
   (1 && (a = 0)) + a; // cxx11-warning {{unsequenced modification and access to 'a'}}
   // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
+  // cxx11-warning@-2 {{use of logical '&&' with constant operand}}
+  // cxx11-note@-3 {{use '&' for a bitwise operation}}
+  // cxx11-note@-4 {{remove constant to silence this warning}}
+  // cxx17-warning@-5 {{use of logical '&&' with constant operand}}
+  // cxx17-note@-6 {{use '&' for a bitwise operation}}
+  // cxx17-note@-7 {{remove constant to silence this warning}}
+
 
   (xs[3] || (a = 0)) + a; // cxx11-warning {{unsequenced modification and access to 'a'}}
   // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
   (0 || (a = 0)) + a; // cxx11-warning {{unsequenced modification and access to 'a'}}
   // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
-  (1 || (a = 0)) + a; // ok
+  // cxx11-warning@-2 {{use of logical '||' with constant operand}}
+  // cxx11-note@-3 {{use '|' for a bitwise operation}}
+  // cxx17-warning@-4 {{use of logical '||' with constant operand}}
+  // cxx17-note@-5 {{use '|' for a bitwise operation}}
+  (1 || (a = 0)) + a; // cxx11-warning {{use of logical '||' with constant operand}}
+  // cxx11-note@-1 {{use '|' for a bitwise operation}}
+  // cxx17-warning@-2 {{use of logical '||' with constant operand}}
+  // cxx17-note@-3 {{use '|' for a bitwise operation}}
+
 
   (xs[4] ? a : ++a) + a; // cxx11-warning {{unsequenced modification and access to 'a'}}
  // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
Index: clang/test/SemaCXX/expressions.cpp
===
--- clang/test/SemaCXX/expressions.cpp
+++ clang/test/SemaCXX/expressions.cpp
@@ -44,6 +44,9 @@
   return x && 4; // expected-warning {{use of logical '&&' with constant operand}} \
// expected-note {{use '&' for a bitwise operation}} \
// expected-note {{remove constant to silence this warning}}
+  return 4 && x; // expected-warning {{use of logical '&&' with constant operand}} \
+   // expected-note {{use '&' for a bitwise operation}} \
+   // expected-note {{remove constant to silence this warning}}
 
   return x && sizeof(int) == 4;  // no warning, RHS is logical op.
   return x && true;
@@ -66,6 +69,8 @@
// expected-note {{use '|' for a bitwise operation}}
   return x || 5; // expected-warning {{use of logical '||'

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

2023-02-06 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta updated this revision to Diff 495122.
xgupta added a comment.

remove old code


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142609

Files:
  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

Index: clang/test/SemaTemplate/dependent-expr.cpp
===
--- clang/test/SemaTemplate/dependent-expr.cpp
+++ clang/test/SemaTemplate/dependent-expr.cpp
@@ -43,7 +43,9 @@
 
 namespace PR7724 {
   template int myMethod()
-  { return 2 && sizeof(OT); }
+  { return 2 && sizeof(OT); } // expected-warning {{use of logical '&&' with constant operand}} \
+  // expected-note {{use '&' for a bitwise operation}} \
+  // expected-note {{remove constant to silence this warning}}
 }
 
 namespace test4 {
Index: clang/test/SemaCXX/warn-unsequenced.cpp
===
--- clang/test/SemaCXX/warn-unsequenced.cpp
+++ clang/test/SemaCXX/warn-unsequenced.cpp
@@ -76,15 +76,37 @@
 
   (xs[2] && (a = 0)) + a; // cxx11-warning {{unsequenced modification and access to 'a'}}
   // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
-  (0 && (a = 0)) + a; // ok
+
+  (0 && (a = 0)) + a; // cxx11-warning {{use of logical '&&' with constant operand}}
+  // cxx11-note@-1 {{use '&' for a bitwise operation}}
+  // cxx11-note@-2 {{remove constant to silence this warning}}
+  // cxx17-warning@-3 {{use of logical '&&' with constant operand}}
+  // cxx17-note@-4 {{use '&' for a bitwise operation}}
+  // cxx17-note@-5 {{remove constant to silence this warning}}
+
   (1 && (a = 0)) + a; // cxx11-warning {{unsequenced modification and access to 'a'}}
   // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
+  // cxx11-warning@-2 {{use of logical '&&' with constant operand}}
+  // cxx11-note@-3 {{use '&' for a bitwise operation}}
+  // cxx11-note@-4 {{remove constant to silence this warning}}
+  // cxx17-warning@-5 {{use of logical '&&' with constant operand}}
+  // cxx17-note@-6 {{use '&' for a bitwise operation}}
+  // cxx17-note@-7 {{remove constant to silence this warning}}
+
 
   (xs[3] || (a = 0)) + a; // cxx11-warning {{unsequenced modification and access to 'a'}}
   // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
   (0 || (a = 0)) + a; // cxx11-warning {{unsequenced modification and access to 'a'}}
   // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
-  (1 || (a = 0)) + a; // ok
+  // cxx11-warning@-2 {{use of logical '||' with constant operand}}
+  // cxx11-note@-3 {{use '|' for a bitwise operation}}
+  // cxx17-warning@-4 {{use of logical '||' with constant operand}}
+  // cxx17-note@-5 {{use '|' for a bitwise operation}}
+  (1 || (a = 0)) + a; // cxx11-warning {{use of logical '||' with constant operand}}
+  // cxx11-note@-1 {{use '|' for a bitwise operation}}
+  // cxx17-warning@-2 {{use of logical '||' with constant operand}}
+  // cxx17-note@-3 {{use '|' for a bitwise operation}}
+
 
   (xs[4] ? a : ++a) + a; // cxx11-warning {{unsequenced modification and access to 'a'}}
  // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
Index: clang/test/SemaCXX/expressions.cpp
===
--- clang/test/SemaCXX/expressions.cpp
+++ clang/test/SemaCXX/expressions.cpp
@@ -44,6 +44,9 @@
   return x && 4; // expected-warning {{use of logical '&&' with constant operand}} \
// expected-note {{use '&' for a bitwise operation}} \
// expected-note {{remove constant to silence this warning}}
+  return 4 && x; // expected-warning {{use of logical '&&' with constant operand}} \
+   // expected-note {{use '&' for a bitwise operation}} \
+   // expected-note {{remove constant to silence this warning}}
 
   return x && sizeof(int) == 4;  // no warning, RHS is logical op.
   return x && true;
@@ -66,6 +69,8 @@
// expected-note {{use '|' for a bitwise operation}}
   return x || 5; // expected-warning {{use of logical '||' with constant operand}

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

2023-01-22 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta created this revision.
xgupta added reviewers: aaron.ballman, fahadnayyar.
Herald added a project: All.
xgupta requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142304

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


Index: clang/include/clang/Lex/DirectoryLookup.h
===
--- clang/include/clang/Lex/DirectoryLookup.h
+++ clang/include/clang/Lex/DirectoryLookup.h
@@ -50,7 +50,7 @@
 
   /// 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.


Index: clang/include/clang/Lex/DirectoryLookup.h
===
--- clang/include/clang/Lex/DirectoryLookup.h
+++ clang/include/clang/Lex/DirectoryLookup.h
@@ -50,7 +50,7 @@
 
   /// 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


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

2023-01-23 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta created this revision.
xgupta added reviewers: aaron.ballman, usaxena95.
Herald added a project: All.
xgupta requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142334

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


Index: clang/include/clang/APINotes/Types.h
===
--- clang/include/clang/APINotes/Types.h
+++ clang/include/clang/APINotes/Types.h
@@ -532,7 +532,7 @@
 
 // Mask the bits.
 NullabilityPayload &=
-~(NullabilityKindMask << (index * NullabilityKindSize));
+~(static_castNullabilityKindMask << (index * 
NullabilityKindSize));
 
 // Set the value.
 unsigned kindValue = (static_cast(kind))


Index: clang/include/clang/APINotes/Types.h
===
--- clang/include/clang/APINotes/Types.h
+++ clang/include/clang/APINotes/Types.h
@@ -532,7 +532,7 @@
 
 // Mask the bits.
 NullabilityPayload &=
-~(NullabilityKindMask << (index * NullabilityKindSize));
+~(static_castNullabilityKindMask << (index * NullabilityKindSize));
 
 // Set the value.
 unsigned kindValue = (static_cast(kind))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2023-01-23 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta created this revision.
Herald added a project: All.
xgupta requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142338

Files:
  clang/lib/Sema/SemaType.cpp


Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -7960,7 +7960,7 @@
 CallingConv DefaultCC =
 Context.getDefaultCallingConvention(IsVariadic, IsStatic);
 
-if (CurCC != DefaultCC || DefaultCC == ToCC)
+if (CurCC != DefaultCC)
   return;
 
 if (hasExplicitCallingConv(T))


Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -7960,7 +7960,7 @@
 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


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

2023-01-23 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta updated this revision to Diff 491312.
xgupta added a comment.

address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142334

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


Index: clang/include/clang/APINotes/Types.h
===
--- clang/include/clang/APINotes/Types.h
+++ clang/include/clang/APINotes/Types.h
@@ -482,7 +482,7 @@
 /// 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;


Index: clang/include/clang/APINotes/Types.h
===
--- clang/include/clang/APINotes/Types.h
+++ clang/include/clang/APINotes/Types.h
@@ -482,7 +482,7 @@
 /// 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


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

2023-01-23 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta marked an inline comment as done.
xgupta added inline comments.



Comment at: clang/include/clang/APINotes/Types.h:535
 NullabilityPayload &=
-~(NullabilityKindMask << (index * NullabilityKindSize));
+~(static_castNullabilityKindMask << (index * 
NullabilityKindSize));
 

aaron.ballman wrote:
> I think a cleaner way to solve this is to make `NullabilityKindMask` be 
> 64-bits. None of the other operations need this change, but it seems like it 
> will be a bit more future-proof that way. WDYT?
Yeah, I do agree. Thanks for the suggestion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142334

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


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

2023-01-23 Thread Shivam Gupta via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
xgupta marked an inline comment as done.
Closed by commit rG68b890831615: [Clang[NFC] Fix bitmask for NullabilityPayload 
in Types.h (authored by xgupta).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142334

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


Index: clang/include/clang/APINotes/Types.h
===
--- clang/include/clang/APINotes/Types.h
+++ clang/include/clang/APINotes/Types.h
@@ -482,7 +482,7 @@
 /// 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;


Index: clang/include/clang/APINotes/Types.h
===
--- clang/include/clang/APINotes/Types.h
+++ clang/include/clang/APINotes/Types.h
@@ -482,7 +482,7 @@
 /// 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


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

2023-01-23 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta added a comment.

In D142304#4073573 , @aaron.ballman 
wrote:

> LGTM but can you find a test case that would show we don't regress this in 
> the future?

I haven't found the test case, but I found a commit 

 that increases CharacteristicKind enum's values from 3 to 5. Seems they missed 
updating DirCharacteristic. Do you have suggestions on where/how to add a test 
case for this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142304

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


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

2023-01-23 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta added a comment.

In D142338#4073826 , @tbaeder wrote:

> LGTM, assuming the pre-commit CI failures are unrelated.

Yeah, those 3 test cases should be unrelated, this is an nfc change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142338

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


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

2023-01-23 Thread Shivam Gupta via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG94b9187a7d37: [Clang] Fix a Wbitfield-enum-conversion 
warning in DirectoryLookup.h (authored by xgupta).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142304

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


Index: clang/include/clang/Lex/DirectoryLookup.h
===
--- clang/include/clang/Lex/DirectoryLookup.h
+++ clang/include/clang/Lex/DirectoryLookup.h
@@ -50,7 +50,7 @@
 
   /// 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.


Index: clang/include/clang/Lex/DirectoryLookup.h
===
--- clang/include/clang/Lex/DirectoryLookup.h
+++ clang/include/clang/Lex/DirectoryLookup.h
@@ -50,7 +50,7 @@
 
   /// 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


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

2023-01-23 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta added a comment.

In D142304#4074211 , @aaron.ballman 
wrote:

> I looked through the code base and I think this fix is good but benign (it 
> doesn't look like it'll impact anything that I can see). So LGTM without 
> tests.

Thank you for reviewing the change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142304

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


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

2023-01-23 Thread Shivam Gupta via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG40003af98456: [Clang][NFC] Remove a redundancy check in 
Sema::adjustMemberFunctionCC (authored by xgupta).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142338

Files:
  clang/lib/Sema/SemaType.cpp


Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -7963,7 +7963,7 @@
 CallingConv DefaultCC =
 Context.getDefaultCallingConvention(IsVariadic, IsStatic);
 
-if (CurCC != DefaultCC || DefaultCC == ToCC)
+if (CurCC != DefaultCC)
   return;
 
 if (hasExplicitCallingConv(T))


Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -7963,7 +7963,7 @@
 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


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

2022-06-10 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta updated this revision to Diff 435947.
xgupta added a comment.

Address comments


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

https://reviews.llvm.org/D127496

Files:
  clang/www/get_started.html


Index: clang/www/get_started.html
===
--- clang/www/get_started.html
+++ clang/www/get_started.html
@@ -69,9 +69,13 @@
 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 for release mode. Alternatively if
+you need a debug build, switch Release to Debug. See
+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,


Index: clang/www/get_started.html
===
--- clang/www/get_started.html
+++ clang/www/get_started.html
@@ -69,9 +69,13 @@
 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 for release mode. Alternatively if
+you need a debug build, switch Release to Debug. See
+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


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

2022-06-10 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta added inline comments.



Comment at: clang/www/get_started.html:72
 cd build
+This builds both LLVM and Clang for debug mode and takes a lot of time 
and space. Alternatively -DCMAKE_BUILD_TYPE=Release" can be use to make a 
release build.
 cmake -DLLVM_ENABLE_PROJECTS=clang -G "Unix Makefiles" 
../llvm

aaron.ballman wrote:
> thieta wrote:
> > This isn't correct - invoking cmake without a `CMAKE_BUILD_TYPE` argument 
> > will just print an error. I would fix the command line below to include 
> > `-DCMAKE_BUILD_TYPE=Release` and have a comment saying switch Release to 
> > Debug if you need a debug build.
> +1 to most of this, but I'd have the comment say something along the lines of 
> "See https://llvm.org/docs/CMake.html#frequently-used-cmake-variables for 
> more options".
I hope 'most of this' also includes making changes to the default suggestion of 
 -DCMAKE_BUILD_TYPE :) 


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

https://reviews.llvm.org/D127496

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


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

2022-06-10 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta updated this revision to Diff 435957.

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

https://reviews.llvm.org/D127496

Files:
  clang/www/get_started.html


Index: clang/www/get_started.html
===
--- clang/www/get_started.html
+++ clang/www/get_started.html
@@ -69,9 +69,13 @@
 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,


Index: clang/www/get_started.html
===
--- clang/www/get_started.html
+++ clang/www/get_started.html
@@ -69,9 +69,13 @@
 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


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

2022-06-10 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta added a comment.

Thank you for review! Committed in 
https://reviews.llvm.org/rGa01579ad0a1bde4d90f4fb656f07586c3097428a.


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

https://reviews.llvm.org/D127496

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


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

2022-06-10 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta created this revision.
xgupta added a reviewer: aaron.ballman.
Herald added a project: All.
xgupta requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D127518

Files:
  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


Index: clang/test/SemaCXX/shift.cpp
===
--- clang/test/SemaCXX/shift.cpp
+++ clang/test/SemaCXX/shift.cpp
@@ -41,7 +41,7 @@
 
   int i;
   i = 1 << (WORD_BIT - 2);
-  i = 2 << (WORD_BIT - 1); // expected-warning {{bits to represent, but 'int' 
only has}}
+  i = 2 << (WORD_BIT - 1); // cxx17-warning {{bits to represent, but 'int' 
only has}}
   i = 1 << (WORD_BIT - 1); // expected-warning {{sets the sign bit of the 
shift expression}}
   i = -1 << (WORD_BIT - 1); // cxx17-warning {{shifting a negative signed 
value is undefined}}
   i = -1 << 0; // cxx17-warning {{shifting a negative signed value is 
undefined}}
@@ -53,7 +53,7 @@
   u = 5U << (WORD_BIT - 1);
 
   long long int lli;
-  lli = INT_MIN << 2; // cxx17-warning {{shifting a negative signed value is 
undefined}} cxx2a-warning {{requires 34 bits to represent}}
+  lli = INT_MIN << 2; // cxx17-warning {{shifting a negative signed value is 
undefined}}
   lli = 1LL << (sizeof(long long) * CHAR_BIT - 2);
 }
 
Index: clang/test/SemaCXX/constant-expression-cxx2a.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx2a.cpp
+++ clang/test/SemaCXX/constant-expression-cxx2a.cpp
@@ -530,8 +530,8 @@
   using int32 = __INT32_TYPE__;
   static_assert(uint32(int32(0x1234) << 16) == 0x1234);
   static_assert(uint32(int32(0x1234) << 19) == 0x91a0);
-  static_assert(uint32(int32(0x1234) << 20) == 0x2340); // 
expected-warning {{requires 34 bits}}
-  static_assert(uint32(int32(0x1234) << 24) == 0x3400); // 
expected-warning {{requires 38 bits}}
+  static_assert(uint32(int32(0x1234) << 20) == 0x2340);
+  static_assert(uint32(int32(0x1234) << 24) == 0x3400);
   static_assert(uint32(int32(-1) << 31) == 0x8000);
 
   static_assert(-1 >> 1 == -1);
Index: clang/test/CXX/expr/expr.const/p2-0x.cpp
===
--- clang/test/CXX/expr/expr.const/p2-0x.cpp
+++ clang/test/CXX/expr/expr.const/p2-0x.cpp
@@ -162,9 +162,9 @@
   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}}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -11453,6 +11453,9 @@
 return;
   }
 
+  if (S.getLangOpts().CPlusPlus20)
+return;
+
   S.Diag(Loc, diag::warn_shift_result_gt_typewidth)
 << HexResult.str() << Result.getMinSignedBits() << LHSType
 << Left.getBitWidth() << LHS.get()->getSourceRange()


Index: clang/test/SemaCXX/shift.cpp
=

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

2022-06-13 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta updated this revision to Diff 436557.
xgupta added a comment.

Address comments


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

https://reviews.llvm.org/D127518

Files:
  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


Index: clang/test/SemaCXX/shift.cpp
===
--- clang/test/SemaCXX/shift.cpp
+++ clang/test/SemaCXX/shift.cpp
@@ -41,8 +41,8 @@
 
   int i;
   i = 1 << (WORD_BIT - 2);
-  i = 2 << (WORD_BIT - 1); // expected-warning {{bits to represent, but 'int' 
only has}}
-  i = 1 << (WORD_BIT - 1); // expected-warning {{sets the sign bit of the 
shift expression}}
+  i = 2 << (WORD_BIT - 1); // cxx17-warning {{bits to represent, but 'int' 
only has}}
+  i = 1 << (WORD_BIT - 1); // cxx17-warning {{sets the sign bit of the shift 
expression}}
   i = -1 << (WORD_BIT - 1); // cxx17-warning {{shifting a negative signed 
value is undefined}}
   i = -1 << 0; // cxx17-warning {{shifting a negative signed value is 
undefined}}
   i = 0 << (WORD_BIT - 1);
@@ -53,7 +53,7 @@
   u = 5U << (WORD_BIT - 1);
 
   long long int lli;
-  lli = INT_MIN << 2; // cxx17-warning {{shifting a negative signed value is 
undefined}} cxx2a-warning {{requires 34 bits to represent}}
+  lli = INT_MIN << 2; // cxx17-warning {{shifting a negative signed value is 
undefined}}
   lli = 1LL << (sizeof(long long) * CHAR_BIT - 2);
 }
 
Index: clang/test/SemaCXX/constant-expression-cxx2a.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx2a.cpp
+++ clang/test/SemaCXX/constant-expression-cxx2a.cpp
@@ -530,8 +530,8 @@
   using int32 = __INT32_TYPE__;
   static_assert(uint32(int32(0x1234) << 16) == 0x1234);
   static_assert(uint32(int32(0x1234) << 19) == 0x91a0);
-  static_assert(uint32(int32(0x1234) << 20) == 0x2340); // 
expected-warning {{requires 34 bits}}
-  static_assert(uint32(int32(0x1234) << 24) == 0x3400); // 
expected-warning {{requires 38 bits}}
+  static_assert(uint32(int32(0x1234) << 20) == 0x2340);
+  static_assert(uint32(int32(0x1234) << 24) == 0x3400);
   static_assert(uint32(int32(-1) << 31) == 0x8000);
 
   static_assert(-1 >> 1 == -1);
Index: clang/test/CXX/expr/expr.const/p2-0x.cpp
===
--- clang/test/CXX/expr/expr.const/p2-0x.cpp
+++ clang/test/CXX/expr/expr.const/p2-0x.cpp
@@ -162,9 +162,9 @@
   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}}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -11420,10 +11420,14 @@
 return;
   llvm::APSInt Left = LHSResult.Val.getInt();
 
+  // Don't warn in C++2A mode (and newer), as signed left shifts
+  // always wrap and never overflow.
+  if (S.getLangOpts().CPlusPlus20)
+return;
+
   // 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) {
+  if (Left.isNegative() && !S.g

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

2022-06-14 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta updated this revision to Diff 436746.
xgupta added a comment.

.


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

https://reviews.llvm.org/D127518

Files:
  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


Index: clang/test/SemaCXX/shift.cpp
===
--- clang/test/SemaCXX/shift.cpp
+++ clang/test/SemaCXX/shift.cpp
@@ -41,8 +41,8 @@
 
   int i;
   i = 1 << (WORD_BIT - 2);
-  i = 2 << (WORD_BIT - 1); // expected-warning {{bits to represent, but 'int' 
only has}}
-  i = 1 << (WORD_BIT - 1); // expected-warning {{sets the sign bit of the 
shift expression}}
+  i = 2 << (WORD_BIT - 1); // cxx17-warning {{bits to represent, but 'int' 
only has}}
+  i = 1 << (WORD_BIT - 1); // cxx17-warning {{sets the sign bit of the shift 
expression}}
   i = -1 << (WORD_BIT - 1); // cxx17-warning {{shifting a negative signed 
value is undefined}}
   i = -1 << 0; // cxx17-warning {{shifting a negative signed value is 
undefined}}
   i = 0 << (WORD_BIT - 1);
@@ -53,7 +53,7 @@
   u = 5U << (WORD_BIT - 1);
 
   long long int lli;
-  lli = INT_MIN << 2; // cxx17-warning {{shifting a negative signed value is 
undefined}} cxx2a-warning {{requires 34 bits to represent}}
+  lli = INT_MIN << 2; // cxx17-warning {{shifting a negative signed value is 
undefined}}
   lli = 1LL << (sizeof(long long) * CHAR_BIT - 2);
 }
 
Index: clang/test/SemaCXX/constant-expression-cxx2a.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx2a.cpp
+++ clang/test/SemaCXX/constant-expression-cxx2a.cpp
@@ -530,8 +530,8 @@
   using int32 = __INT32_TYPE__;
   static_assert(uint32(int32(0x1234) << 16) == 0x1234);
   static_assert(uint32(int32(0x1234) << 19) == 0x91a0);
-  static_assert(uint32(int32(0x1234) << 20) == 0x2340); // 
expected-warning {{requires 34 bits}}
-  static_assert(uint32(int32(0x1234) << 24) == 0x3400); // 
expected-warning {{requires 38 bits}}
+  static_assert(uint32(int32(0x1234) << 20) == 0x2340);
+  static_assert(uint32(int32(0x1234) << 24) == 0x3400);
   static_assert(uint32(int32(-1) << 31) == 0x8000);
 
   static_assert(-1 >> 1 == -1);
Index: clang/test/CXX/expr/expr.const/p2-0x.cpp
===
--- clang/test/CXX/expr/expr.const/p2-0x.cpp
+++ clang/test/CXX/expr/expr.const/p2-0x.cpp
@@ -162,9 +162,9 @@
   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}}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -11416,10 +11416,16 @@
 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 sign

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

2022-06-14 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta closed this revision.
xgupta added a comment.

In D127518#3581620 , @aaron.ballman 
wrote:

> LGTM! Please add a release note about the issue that was fixed when landing.

Done, Thank you for reviewing.

Committed in 
https://reviews.llvm.org/rG48e1829874df15fd57e731d4824604f28e177585.


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

https://reviews.llvm.org/D127518

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


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

2022-06-10 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta created this revision.
xgupta added reviewers: thieta, aaron.ballman.
Herald added a project: All.
xgupta requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D127496

Files:
  clang/www/get_started.html


Index: clang/www/get_started.html
===
--- clang/www/get_started.html
+++ clang/www/get_started.html
@@ -69,9 +69,9 @@
 cd llvm-project
 mkdir build (in-tree build is not supported)
 cd build
+This builds both LLVM and Clang for debug mode and takes a lot of time 
and space. Alternatively -DCMAKE_BUILD_TYPE=Release" can be use to make a 
release build.
 cmake -DLLVM_ENABLE_PROJECTS=clang -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,


Index: clang/www/get_started.html
===
--- clang/www/get_started.html
+++ clang/www/get_started.html
@@ -69,9 +69,9 @@
 cd llvm-project
 mkdir build (in-tree build is not supported)
 cd build
+This builds both LLVM and Clang for debug mode and takes a lot of time and space. Alternatively -DCMAKE_BUILD_TYPE=Release" can be use to make a release build.
 cmake -DLLVM_ENABLE_PROJECTS=clang -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


[PATCH] D155457: [clang] Skip tautological comparison if the comparison involves the 'size_t' type

2023-07-18 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta added a comment.

In D155457#4507124 , @aaron.ballman 
wrote:

> In D155457#4507107 , @xgupta wrote:
>
>> In D155457#4506405 , @xbolva00 
>> wrote:
>>
>>> You should add a testcase which uses “expected no diagnostics”.
>>
>> There is some issue writing test
>>
>>   $ cat type-limit-compare.cpp
>>   // RUN: %clang_cc1  -fsyntax-only -Wtautological-type-limit-compare 
>> -verify %s
>>   // expected-no-diagnostics
>>   
>>   #include 
>>   #include 
>>   #include 
>>   
>>   bool foo(uint64_t Size) {
>> if (sizeof(std::size_t) < sizeof(uint64_t) &&
>>Size > 
>> static_cast(std::numeric_limits::max())) // no-warning
>>   return false;
>> return true;
>>   }
>>
>> failed with
>>
>>   $ llvm-project/clang/test/Sema/type-limit-compare.cpp:4:10: fatal error: 
>> 'cstddef' file not found
>>   4 | #include 
>> |  ^
>
> We typically do not include any system headers (STL or otherwise) as part of 
> the compiler tests; that would test whatever is found on the test system 
> instead of a consistent test. Instead, I'd recommend doing:
>
>   namespace std {
>   using size_t = decltype(sizeof(0));
>   }
>
> Similarly, you can replace `uint64_t` with `unsigned long long` and the 
> `numeric_limits` call with `__SIZE_MAX__`

I see, Thanks,  but there is another thing, writing this way compiler emits a 
warning as the check to exclude the warning is based on `size_t` so the test 
case is not passed.

  // RUN: %clang_cc1 %s -fsyntax-only -Wtautological-type-limit-compare -verify
  
  // expected-no-diagnostics
  
  typedef unsigned long long uint64_t;
  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;
  }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155457

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


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

2023-07-18 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta added a comment.

In D142609#4507696 , @nathanchance 
wrote:

> I took the most recent version for a spin against the Linux kernel. The 
> couple of issues that a previous revision of the warning flagged 
> (https://github.com/ClangBuiltLinux/linux/issues/1806, 
> https://github.com/ClangBuiltLinux/linux/issues/1807) are no longer visible 
> (that seems intentional because both of those came from macro expressions) 
> but I see a new one along a similar line as those:
>
> https://elixir.bootlin.com/linux/v6.5-rc2/source/drivers/gpu/drm/v3d/v3d_drv.h#L343
>
>   In file included from drivers/gpu/drm/v3d/v3d_bo.c:25:
>   drivers/gpu/drm/v3d/v3d_drv.h:343:24: warning: use of logical '&&' with 
> constant operand [-Wconstant-logical-operand]
> 343 | if (NSEC_PER_SEC % HZ &&
> | ~ ^
>   drivers/gpu/drm/v3d/v3d_drv.h:343:24: note: use '&' for a bitwise operation
> 343 | if (NSEC_PER_SEC % HZ &&
> |   ^~
> |   &
>   drivers/gpu/drm/v3d/v3d_drv.h:343:24: note: remove constant to silence this 
> warning
>   1 warning generated.
>
> Another minimized example showing how the warning can trigger with different 
> configurations:
>
>   $ cat x.c
>   #define A 1000
>   #define B 300
>   #define C 250
>   #define D 100
>   
>   int bar(void);
>   int baz(void);
>   
>   int foo(void)
>   {
>   if (A % B && bar()) // 1000 % 300 = 100, warning
>   return -3;
>   
>   if (A % C && bar()) // 1000 % 250 = 0, no warning
>   return -2;
>   
>   if (A % D && bar()) // 1000 % 100 = 0, no warning
>   return -1;
>   
>   return baz();
>   }
>   
>   $ clang -Wall -fsyntax-only x.c
>   x.c:11:12: warning: use of logical '&&' with constant operand 
> [-Wconstant-logical-operand]
>  11 | if (A % B && bar())
> | ~ ^
>   x.c:11:12: note: use '&' for a bitwise operation
>  11 | if (A % B && bar())
> |   ^~
> |   &
>   x.c:11:12: note: remove constant to silence this warning
>   1 warning generated.
>
> I am sure we can send a patch making that a boolean expression (although it 
> is duplicated in a few places it seems so multiple patches will be needed) 
> but I figured I would report it just in case there was something that should 
> be changed with the warning, since I see there was already some discussion 
> around not warning for macros and this seems along a similar line.

WDYT @xbolva00,  It is a valid warning or more modification is required in the 
patch?


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

https://reviews.llvm.org/D142609

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


[PATCH] D155457: [clang] Skip tautological comparison if the comparison involves the 'size_t' type

2023-07-18 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta added a comment.

In D155457#4511392 , @aaron.ballman 
wrote:

> Whether `size_t` comes from the system header or whether it's manually 
> deduced from `decltype(sizeof(0))` should make no difference as far as the 
> frontend is concerned; they should resolve to the same type. Can you explain 
> the test failure you're seeing in a bit more detail?



  : 'RUN: at line 1';   /home/shivam/.llvm/llvm-project/build/bin/clang -cc1 
-internal-isystem /home/shivam/.llvm/llvm-project/build/lib/clang/17/include 
-nostdsysteminc 
/home/shivam/.llvm/llvm-project/clang/test/Sema/type-limit-compare.cpp 
-fsyntax-only -Wtautological-type-limit-compare -verify
  --
  Exit Code: 1
  
  Command Output (stderr):
  --
  error: 'warning' diagnostics seen but not expected: 
File /home/shivam/.llvm/llvm-project/clang/test/Sema/type-limit-compare.cpp 
Line 12: result of comparison 'uint64_t' (aka 'unsigned long long') > 
18446744073709551615 is always false
  1 error generated.

I think the issue is with __SIZE_MAX__ vs 
std::numeric_limits::max() but not sure.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155457

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


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

2023-07-18 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta added a comment.

In D142609#4510995 , @aaron.ballman 
wrote:

> In D142609#4510596 , @xbolva00 
> wrote:
>
>> In my opinion it makes sense to adjust that kernel code based on this 
>> warning in the current inplementation state.
>>
>> @aaron.ballman ?
>
> I think that use of macros for any of the constant values in the expression 
> should silence the diagnostic on the assumption that the macro value changes 
> with different configurations and so it's only constant in one configuration 
> mode. Alternatively, I could see an argument to use a different diagnostic 
> group when macros are involved so that users can silence macro-related 
> constant warnings while not losing non-macro cases. WDYT?

IIUC in this patch I am making more like an NFC change and this could be a 
separate issue. WDYT @nickdesaulniers? Please review it so we can commit it 
soon.


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

https://reviews.llvm.org/D142609

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


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

2023-07-18 Thread Shivam Gupta via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdfdfd306cfaf: [Clang] Fix -Wconstant-logical-operand when 
LHS is a constant (authored by shivam-amd).

Changed prior to commit:
  https://reviews.llvm.org/D142609?vs=540922&id=541850#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142609

Files:
  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

Index: clang/test/SemaTemplate/dependent-expr.cpp
===
--- clang/test/SemaTemplate/dependent-expr.cpp
+++ clang/test/SemaTemplate/dependent-expr.cpp
@@ -43,7 +43,9 @@
 
 namespace PR7724 {
   template int myMethod()
-  { return 2 && sizeof(OT); }
+  { return 2 && sizeof(OT); } // expected-warning {{use of logical '&&' with constant operand}} \
+  // expected-note {{use '&' for a bitwise operation}} \
+  // expected-note {{remove constant to silence this warning}}
 }
 
 namespace test4 {
Index: clang/test/SemaCXX/warn-unsequenced.cpp
===
--- clang/test/SemaCXX/warn-unsequenced.cpp
+++ clang/test/SemaCXX/warn-unsequenced.cpp
@@ -76,15 +76,37 @@
 
   (xs[2] && (a = 0)) + a; // cxx11-warning {{unsequenced modification and access to 'a'}}
   // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
-  (0 && (a = 0)) + a; // ok
+
+  (0 && (a = 0)) + a; // cxx11-warning {{use of logical '&&' with constant operand}}
+  // cxx11-note@-1 {{use '&' for a bitwise operation}}
+  // cxx11-note@-2 {{remove constant to silence this warning}}
+  // cxx17-warning@-3 {{use of logical '&&' with constant operand}}
+  // cxx17-note@-4 {{use '&' for a bitwise operation}}
+  // cxx17-note@-5 {{remove constant to silence this warning}}
+
   (1 && (a = 0)) + a; // cxx11-warning {{unsequenced modification and access to 'a'}}
   // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
+  // cxx11-warning@-2 {{use of logical '&&' with constant operand}}
+  // cxx11-note@-3 {{use '&' for a bitwise operation}}
+  // cxx11-note@-4 {{remove constant to silence this warning}}
+  // cxx17-warning@-5 {{use of logical '&&' with constant operand}}
+  // cxx17-note@-6 {{use '&' for a bitwise operation}}
+  // cxx17-note@-7 {{remove constant to silence this warning}}
+
 
   (xs[3] || (a = 0)) + a; // cxx11-warning {{unsequenced modification and access to 'a'}}
   // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
   (0 || (a = 0)) + a; // cxx11-warning {{unsequenced modification and access to 'a'}}
   // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
-  (1 || (a = 0)) + a; // ok
+  // cxx11-warning@-2 {{use of logical '||' with constant operand}}
+  // cxx11-note@-3 {{use '|' for a bitwise operation}}
+  // cxx17-warning@-4 {{use of logical '||' with constant operand}}
+  // cxx17-note@-5 {{use '|' for a bitwise operation}}
+  (1 || (a = 0)) + a; // cxx11-warning {{use of logical '||' with constant operand}}
+  // cxx11-note@-1 {{use '|' for a bitwise operation}}
+  // cxx17-warning@-2 {{use of logical '||' with constant operand}}
+  // cxx17-note@-3 {{use '|' for a bitwise operation}}
+
 
   (xs[4] ? a : ++a) + a; // cxx11-warning {{unsequenced modification and access to 'a'}}
  // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
Index: clang/test/SemaCXX/expressions.cpp
===
--- clang/test/SemaCXX/expressions.cpp
+++ clang/test/SemaCXX/expressions.cpp
@@ -44,6 +44,9 @@
   return x && 4; // expected-warning {{use of logical '&&' with constant operand}} \
// expected-note {{use '&' for a bitwise operation}} \
// expected-note {{remove constant to silence this warning}}
+  return 4 && x; // expected-warning {{use of logical '&&' with constant operand}} \
+   // expected-note {{use '&' for a bitwise operation}} \
+   // expected-note {{remove constant to silence th

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

2023-07-18 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta added a comment.

Thanks, @nickdesaulniers for reviewing and @nathanchance for testing the change.

@aaron.ballman, I also agree with @xbolva00 seems warning in kernel code is 
valid but I also agree with your comment about macro, may be better to track 
the macro-related issue with another GitHub issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142609

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


[PATCH] D155457: [clang] Skip tautological comparison if the comparison involves the 'size_t' type

2023-07-19 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta updated this revision to Diff 541866.
xgupta added a comment.

Add test case


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155457

Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Sema/type-limit-compare.cpp


Index: clang/test/Sema/type-limit-compare.cpp
===
--- /dev/null
+++ clang/test/Sema/type-limit-compare.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 %s -fsyntax-only -Wtautological-type-limit-compare -verify
+
+// expected-no-diagnostics
+
+typedef unsigned long uint64_t;
+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;
+}
+
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -13804,6 +13804,13 @@
   if (InRange && IsEnumConstOrFromMacro(S, Constant))
 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 &&


Index: clang/test/Sema/type-limit-compare.cpp
===
--- /dev/null
+++ clang/test/Sema/type-limit-compare.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 %s -fsyntax-only -Wtautological-type-limit-compare -verify
+
+// expected-no-diagnostics
+
+typedef unsigned long uint64_t;
+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;
+}
+
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -13804,6 +13804,13 @@
   if (InRange && IsEnumConstOrFromMacro(S, Constant))
 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 &&
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D155457: [clang] Skip tautological comparison if the comparison involves the 'size_t' type

2023-07-19 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta added a comment.

In D155457#4511652 , @aaron.ballman 
wrote:

> In the x86 compilation: `sizeof(std::size_t) < sizeof(uint64_t)` is true, so 
> we test the other expression; because `Size` is greater than `__SIZE_MAX__` 
> the function returns false and the second static assertion fails as expected.
> In the x64 compilation: `sizeof(std::size_t) < sizeof(uint64_t)` is false 
> (first static assertion fails) so we shouldn't even be evaluating the RHS of 
> the `&&` to see if it's tautological because it can't contribute to the 
> expression result, right?

Yes, I agree with both statements but what is odd in current behavior?

It seems to me uint64_t is unsigned long in , not unsigned long long 
so the new test added in this patch (with `typedef unsigned long uint64_t`) is 
now passing.

Behavior when the patch is applied-

  $ ./bin/clang++ -Wall -fsyntax-only test.cpp -m64  -Wtype-limits 
  test.cpp:8:11: warning: result of comparison 'uint64_t' (aka 'unsigned long 
long') > 18446744073709551615 is always false 
[-Wtautological-type-limit-compare]
  8 |  Size > static_cast(__SIZE_MAX__)) // no-warning
|   ^ ~~~
  test.cpp:13:15: error: static assertion failed due to requirement 
'sizeof(unsigned long) < sizeof(unsigned long long)': 
 13 | static_assert(sizeof(std::size_t) < sizeof(uint64_t), "");
|   ^~
  test.cpp:13:35: note: expression evaluates to '8 < 8'
 13 | static_assert(sizeof(std::size_t) < sizeof(uint64_t), "");
|   ^~
  1 warning and 1 error generated.

  $ ./bin/clang++ -Wall -fsyntax-only test1.cpp -m64  -Wtype-limits 
  test1.cpp:12:15: error: static assertion failed due to requirement 
'sizeof(unsigned long) < sizeof(unsigned long)': 
 12 | static_assert(sizeof(std::size_t) < sizeof(uint64_t), "");
|   ^~
  test1.cpp:12:35: note: expression evaluates to '8 < 8'
 12 | static_assert(sizeof(std::size_t) < sizeof(uint64_t), "");
|   ^~
  1 error generated.

where test.cpp using wrapper and test1.cpp is using standard headers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155457

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


[PATCH] D155457: [clang] Skip tautological comparison if the comparison involves the 'size_t' type

2023-07-21 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta updated this revision to Diff 542846.
xgupta added a comment.

update test for Windows system


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155457

Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Sema/type-limit-compare.cpp


Index: clang/test/Sema/type-limit-compare.cpp
===
--- /dev/null
+++ 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;
+}
+
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -13804,6 +13804,13 @@
   if (InRange && IsEnumConstOrFromMacro(S, Constant))
 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 &&


Index: clang/test/Sema/type-limit-compare.cpp
===
--- /dev/null
+++ 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;
+}
+
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -13804,6 +13804,13 @@
   if (InRange && IsEnumConstOrFromMacro(S, Constant))
 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 &&
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D155457: [clang] Skip tautological comparison if the comparison involves the 'size_t' type

2023-07-21 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta added a comment.

Just normal ping, @aaron.ballman, can please take a look, pre-merge checks are 
also passing now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155457

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


[PATCH] D144135: [clang-tidy] Add performance-enum-size check

2023-07-22 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta added a comment.

This LGTM, but can't officially accept the patch so please wait for another 
reviewer to accept it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144135

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


[PATCH] D142800: [Clang][Diagnostic] Add `-Wcomparison-op-parentheses` to warn on chained comparisons

2023-07-22 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta added a comment.

Wanted to point out that there is a clang-tidy check in review doing the 
similar thing - https://reviews.llvm.org/D144429.


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

https://reviews.llvm.org/D142800

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


[PATCH] D144748: [clang-tidy] Add bugprone-empty-catch check

2023-07-23 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta added a comment.

Other than these three points everything looks good to me.




Comment at: clang-tools-extra/clang-tidy/bugprone/EmptyCatchCheck.cpp:71
+
+bool EmptyCatchCheck::isLanguageVersionSupported(
+const LangOptions &LangOpts) const {

This can be defined in the header file itself like other checks.



Comment at: clang-tools-extra/clang-tidy/bugprone/EmptyCatchCheck.cpp:76
+
+std::optional EmptyCatchCheck::getCheckTraversalKind() const {
+  return TK_IgnoreUnlessSpelledInSource;

This can be defined in the header file itself like other checks.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone/empty-catch.cpp:3
+// RUN: -config="{CheckOptions: [{key: 
bugprone-empty-catch.AllowEmptyCatchForExceptions, value: 
'::SafeException;WarnException'}, \
+// RUN:{key: bugprone-empty-catch.IgnoreCatchWithKeywords, value: 
'@IGNORE;@TODO'}]}"
+

If TODO is in default then it does not require to be in value here, right?
I tested without that, it gives the warning. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144748

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


[PATCH] D101037: [clang-tidy] Change shebang from python to python3

2023-07-23 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta closed this revision.
xgupta added a comment.
Herald added a reviewer: njames93.
Herald added a subscriber: PiotrZSL.
Herald added a project: All.

https://reviews.llvm.org/rG475440703238ca32adab6c3fe5e0039c3f96d1a5 committed 
the remaining shebang change from python to python3.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101037

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


[PATCH] D144748: [clang-tidy] Add bugprone-empty-catch check

2023-07-23 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta accepted this revision.
xgupta added a comment.
This revision is now accepted and ready to land.

LGTM, but we can wait for a couple of before committing in case other reviewers 
have more review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144748

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


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

2023-07-23 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta updated this revision to Diff 543282.
xgupta added a comment.

Rebase and address one last comment.

I think now it will be fine to commit?


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

https://reviews.llvm.org/D97567

Files:
  clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
  clang-tools-extra/test/clang-tidy/checkers/performance/for-range-copy.cpp
  
clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-initialization.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-initialization.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-initialization.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-initialization.cpp
@@ -843,3 +843,36 @@
 }
 
 void instantiatePositiveSingleTemplateType() { positiveSingleTemplateType(); }
+
+struct Struct {
+  ExpensiveToCopyType Member;
+};
+
+void positiveConstMemberExpr() {
+  Struct Orig;
+  auto UC = Orig;
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: local copy 'UC'
+  // CHECK-FIXES: const auto& UC = Orig;
+  const auto &ConstRef = UC.Member;
+  auto MemberCopy = UC.Member;
+  bool b = UC.Member.constMethod();
+  useByValue(UC.Member);
+  useAsConstReference(UC.Member);
+  useByValue(UC.Member);
+}
+
+void negativeNonConstMemberExpr() {
+  Struct Orig;
+  {
+auto Copy = Orig;
+Copy.Member.nonConstMethod();
+  }
+  {
+auto Copy = Orig;
+mutate(Copy.Member);
+  }
+  {
+auto Copy = Orig;
+mutate(&Copy.Member);
+  }
+}
Index: clang-tools-extra/test/clang-tidy/checkers/performance/for-range-copy.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/performance/for-range-copy.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/performance/for-range-copy.cpp
@@ -296,3 +296,37 @@
 // SS : createView(*ValueReturningIterator())) {
   }
 }
+
+void positiveConstMemberExpr() {
+  struct Struct {
+Mutable Member;
+  };
+  for (Struct SS : View>()) {
+// CHECK-MESSAGES: [[@LINE-1]]:15: warning: loop variable is copied
+// CHECK-FIXES: for (const Struct& SS : View>()) {
+auto MemberCopy = SS.Member;
+const auto &ConstRef = SS.Member;
+bool b = SS.Member.constMethod();
+use(SS.Member);
+useByConstValue(SS.Member);
+useByValue(SS.Member);
+  }
+}
+
+void negativeNonConstMemberExpr() {
+  struct Struct {
+Mutable Member;
+  };
+  for (Struct SS : View>()) {
+SS.Member.setBool(true);
+  }
+  for (Struct SS : View>()) {
+SS.Member[1];
+  }
+  for (Struct SS : View>()) {
+mutate(SS.Member);
+  }
+  for (Struct SS : View>()) {
+mutate(&SS.Member);
+  }
+}
\ No newline at end of file
Index: clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
===
--- clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
+++ clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
@@ -43,14 +43,18 @@
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)),
+  findAll(expr(anyOf(cxxMemberCallExpr(ConstMethodCallee,
+on(DeclRefToVarOrMemberExprOfVar)),
  cxxOperatorCallExpr(ConstMethodCallee,
- hasArgument(0, DeclRefToVar),
+ hasArgument(0, DeclRefToVarOrMemberExprOfVar),
   Stmt, Context);
   SmallPtrSet DeclRefs;
   extractNodesByIdTo(Matches, "declRef", DeclRefs);
@@ -62,21 +66,22 @@
   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)),
+   

[PATCH] D82784: [clang-tidy] For `run-clang-tidy.py` do not treat `allow_enabling_alpha_checkers` as a none value.

2023-07-23 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta closed this revision.
xgupta added a comment.
Herald added subscribers: wangpc, PiotrZSL, carlosgalvezp.
Herald added a reviewer: njames93.
Herald added projects: clang-tools-extra, All.

This was committed in 
https://github.com/llvm/llvm-project/commit/03ded5497a2f458b6af054fa7bac0da0240e7b7a.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82784

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


[PATCH] D78223: [clang-tidy] performance-range-for-copy only for copy.

2023-07-23 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta added a comment.
Herald added subscribers: PiotrZSL, carlosgalvezp.
Herald added a project: All.

Reverse ping, this patch was never gets committed after being accepted.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D78223

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


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

2023-07-23 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta updated this revision to Diff 543287.
xgupta added a comment.

Added release note and fix unit test case


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97567

Files:
  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

Index: clang-tools-extra/unittests/clang-tidy/DeclRefExprUtilsTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/DeclRefExprUtilsTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/DeclRefExprUtilsTest.cpp
@@ -114,8 +114,8 @@
   (void)*⌖
   S copy1 = /*const*/target;
   S copy2(/*const*/target);
-  useInt(target.int_member);
-  useIntConstRef(target.int_member);
+  useInt(/*const*/target.int_member);
+  useIntConstRef(/*const*/target.int_member);
   useIntPtr(target.ptr_member);
   useIntConstPtr(&target.int_member);
 }
@@ -140,8 +140,8 @@
   (void)*⌖
   S copy1 = /*const*/target;
   S copy2(/*const*/target);
-  useInt(target.int_member);
-  useIntConstRef(target.int_member);
+  useInt(/*const*/target.int_member);
+  useIntConstRef(/*const*/target.int_member);
   useIntPtr(target.ptr_member);
   useIntConstPtr(&target.int_member);
 }
@@ -172,8 +172,8 @@
   (void)*⌖
   S copy1 = /*const*/target;
   S copy2(/*const*/target);
-  useInt(target.int_member);
-  useIntConstRef(target.int_member);
+  useInt(/*const*/target.int_member);
+  useIntConstRef(/*const*/target.int_member);
   useIntPtr(target.ptr_member);
   useIntConstPtr(&target.int_member);
 }
@@ -199,8 +199,8 @@
   (void)*⌖
   S copy1 = /*const*/target;
   S copy2(/*const*/target);
-  useInt(target.int_member);
-  useIntConstRef(target.int_member);
+  useInt(/*const*/target.int_member);
+  useIntConstRef(/*const*/target.int_member);
   useIntPtr(target.ptr_member);
   useIntConstPtr(&target.int_member);
 }
Index: clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-initialization.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-initialization.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-initialization.cpp
@@ -843,3 +843,36 @@
 }
 
 void instantiatePositiveSingleTemplateType() { positiveSingleTemplateType(); }
+
+struct Struct {
+  ExpensiveToCopyType Member;
+};
+
+void positiveConstMemberExpr() {
+  Struct Orig;
+  auto UC = Orig;
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: local copy 'UC'
+  // CHECK-FIXES: const auto& UC = Orig;
+  const auto &ConstRef = UC.Member;
+  auto MemberCopy = UC.Member;
+  bool b = UC.Member.constMethod();
+  useByValue(UC.Member);
+  useAsConstReference(UC.Member);
+  useByValue(UC.Member);
+}
+
+void negativeNonConstMemberExpr() {
+  Struct Orig;
+  {
+auto Copy = Orig;
+Copy.Member.nonConstMethod();
+  }
+  {
+auto Copy = Orig;
+mutate(Copy.Member);
+  }
+  {
+auto Copy = Orig;
+mutate(&Copy.Member);
+  }
+}
Index: clang-tools-extra/test/clang-tidy/checkers/performance/for-range-copy.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/performance/for-range-copy.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/performance/for-range-copy.cpp
@@ -296,3 +296,37 @@
 // SS : createView(*ValueReturningIterator())) {
   }
 }
+
+void positiveConstMemberExpr() {
+  struct Struct {
+Mutable Member;
+  };
+  for (Struct SS : View>()) {
+// CHECK-MESSAGES: [[@LINE-1]]:15: warning: loop variable is copied
+// CHECK-FIXES: for (const Struct& SS : View>()) {
+auto MemberCopy = SS.Member;
+const auto &ConstRef = SS.Member;
+bool b = SS.Member.constMethod();
+use(SS.Member);
+useByConstValue(SS.Member);
+useByValue(SS.Member);
+  }
+}
+
+void negativeNonConstMemberExpr() {
+  struct Struct {
+Mutable Member;
+  };
+  for (Struct SS : View>()) {
+SS.Member.setBool(true);
+  }
+  for (Struct SS : View>()) {
+SS.Member[1];
+  }
+  for (Struct SS : View>()) {
+mutate(SS.Member);
+  }
+  for (Struct SS : View>()) {
+mutate(&SS.Member);
+  }
+}
\ No newline at end of file
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -520,6 +520,17 @@
   support unscoped enumerations through instances and fixed usage of anonymous
   structs or classes.
 
+- Improved :doc:`performance-unneces

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

2023-07-23 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta updated this revision to Diff 543299.
xgupta added a comment.

Update release note


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97567

Files:
  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

Index: clang-tools-extra/unittests/clang-tidy/DeclRefExprUtilsTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/DeclRefExprUtilsTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/DeclRefExprUtilsTest.cpp
@@ -114,8 +114,8 @@
   (void)*⌖
   S copy1 = /*const*/target;
   S copy2(/*const*/target);
-  useInt(target.int_member);
-  useIntConstRef(target.int_member);
+  useInt(/*const*/target.int_member);
+  useIntConstRef(/*const*/target.int_member);
   useIntPtr(target.ptr_member);
   useIntConstPtr(&target.int_member);
 }
@@ -140,8 +140,8 @@
   (void)*⌖
   S copy1 = /*const*/target;
   S copy2(/*const*/target);
-  useInt(target.int_member);
-  useIntConstRef(target.int_member);
+  useInt(/*const*/target.int_member);
+  useIntConstRef(/*const*/target.int_member);
   useIntPtr(target.ptr_member);
   useIntConstPtr(&target.int_member);
 }
@@ -172,8 +172,8 @@
   (void)*⌖
   S copy1 = /*const*/target;
   S copy2(/*const*/target);
-  useInt(target.int_member);
-  useIntConstRef(target.int_member);
+  useInt(/*const*/target.int_member);
+  useIntConstRef(/*const*/target.int_member);
   useIntPtr(target.ptr_member);
   useIntConstPtr(&target.int_member);
 }
@@ -199,8 +199,8 @@
   (void)*⌖
   S copy1 = /*const*/target;
   S copy2(/*const*/target);
-  useInt(target.int_member);
-  useIntConstRef(target.int_member);
+  useInt(/*const*/target.int_member);
+  useIntConstRef(/*const*/target.int_member);
   useIntPtr(target.ptr_member);
   useIntConstPtr(&target.int_member);
 }
Index: clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-initialization.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-initialization.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-initialization.cpp
@@ -843,3 +843,36 @@
 }
 
 void instantiatePositiveSingleTemplateType() { positiveSingleTemplateType(); }
+
+struct Struct {
+  ExpensiveToCopyType Member;
+};
+
+void positiveConstMemberExpr() {
+  Struct Orig;
+  auto UC = Orig;
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: local copy 'UC'
+  // CHECK-FIXES: const auto& UC = Orig;
+  const auto &ConstRef = UC.Member;
+  auto MemberCopy = UC.Member;
+  bool b = UC.Member.constMethod();
+  useByValue(UC.Member);
+  useAsConstReference(UC.Member);
+  useByValue(UC.Member);
+}
+
+void negativeNonConstMemberExpr() {
+  Struct Orig;
+  {
+auto Copy = Orig;
+Copy.Member.nonConstMethod();
+  }
+  {
+auto Copy = Orig;
+mutate(Copy.Member);
+  }
+  {
+auto Copy = Orig;
+mutate(&Copy.Member);
+  }
+}
Index: clang-tools-extra/test/clang-tidy/checkers/performance/for-range-copy.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/performance/for-range-copy.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/performance/for-range-copy.cpp
@@ -296,3 +296,37 @@
 // SS : createView(*ValueReturningIterator())) {
   }
 }
+
+void positiveConstMemberExpr() {
+  struct Struct {
+Mutable Member;
+  };
+  for (Struct SS : View>()) {
+// CHECK-MESSAGES: [[@LINE-1]]:15: warning: loop variable is copied
+// CHECK-FIXES: for (const Struct& SS : View>()) {
+auto MemberCopy = SS.Member;
+const auto &ConstRef = SS.Member;
+bool b = SS.Member.constMethod();
+use(SS.Member);
+useByConstValue(SS.Member);
+useByValue(SS.Member);
+  }
+}
+
+void negativeNonConstMemberExpr() {
+  struct Struct {
+Mutable Member;
+  };
+  for (Struct SS : View>()) {
+SS.Member.setBool(true);
+  }
+  for (Struct SS : View>()) {
+SS.Member[1];
+  }
+  for (Struct SS : View>()) {
+mutate(SS.Member);
+  }
+  for (Struct SS : View>()) {
+mutate(&SS.Member);
+  }
+}
\ No newline at end of file
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -520,6 +520,22 @@
   support unscoped enumerations through instances and fixed usage of anonymous
   structs or classes.
 
+- Improved :doc:`performance-inefficient-vector-operation

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

2023-07-23 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta updated this revision to Diff 543300.
xgupta marked 2 inline comments as done.
xgupta added a comment.

minor update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97567

Files:
  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

Index: clang-tools-extra/unittests/clang-tidy/DeclRefExprUtilsTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/DeclRefExprUtilsTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/DeclRefExprUtilsTest.cpp
@@ -114,8 +114,8 @@
   (void)*⌖
   S copy1 = /*const*/target;
   S copy2(/*const*/target);
-  useInt(target.int_member);
-  useIntConstRef(target.int_member);
+  useInt(/*const*/target.int_member);
+  useIntConstRef(/*const*/target.int_member);
   useIntPtr(target.ptr_member);
   useIntConstPtr(&target.int_member);
 }
@@ -140,8 +140,8 @@
   (void)*⌖
   S copy1 = /*const*/target;
   S copy2(/*const*/target);
-  useInt(target.int_member);
-  useIntConstRef(target.int_member);
+  useInt(/*const*/target.int_member);
+  useIntConstRef(/*const*/target.int_member);
   useIntPtr(target.ptr_member);
   useIntConstPtr(&target.int_member);
 }
@@ -172,8 +172,8 @@
   (void)*⌖
   S copy1 = /*const*/target;
   S copy2(/*const*/target);
-  useInt(target.int_member);
-  useIntConstRef(target.int_member);
+  useInt(/*const*/target.int_member);
+  useIntConstRef(/*const*/target.int_member);
   useIntPtr(target.ptr_member);
   useIntConstPtr(&target.int_member);
 }
@@ -199,8 +199,8 @@
   (void)*⌖
   S copy1 = /*const*/target;
   S copy2(/*const*/target);
-  useInt(target.int_member);
-  useIntConstRef(target.int_member);
+  useInt(/*const*/target.int_member);
+  useIntConstRef(/*const*/target.int_member);
   useIntPtr(target.ptr_member);
   useIntConstPtr(&target.int_member);
 }
Index: clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-initialization.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-initialization.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-initialization.cpp
@@ -843,3 +843,36 @@
 }
 
 void instantiatePositiveSingleTemplateType() { positiveSingleTemplateType(); }
+
+struct Struct {
+  ExpensiveToCopyType Member;
+};
+
+void positiveConstMemberExpr() {
+  Struct Orig;
+  auto UC = Orig;
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: local copy 'UC'
+  // CHECK-FIXES: const auto& UC = Orig;
+  const auto &ConstRef = UC.Member;
+  auto MemberCopy = UC.Member;
+  bool b = UC.Member.constMethod();
+  useByValue(UC.Member);
+  useAsConstReference(UC.Member);
+  useByValue(UC.Member);
+}
+
+void negativeNonConstMemberExpr() {
+  Struct Orig;
+  {
+auto Copy = Orig;
+Copy.Member.nonConstMethod();
+  }
+  {
+auto Copy = Orig;
+mutate(Copy.Member);
+  }
+  {
+auto Copy = Orig;
+mutate(&Copy.Member);
+  }
+}
Index: clang-tools-extra/test/clang-tidy/checkers/performance/for-range-copy.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/performance/for-range-copy.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/performance/for-range-copy.cpp
@@ -296,3 +296,38 @@
 // SS : createView(*ValueReturningIterator())) {
   }
 }
+
+void positiveConstMemberExpr() {
+  struct Struct {
+Mutable Member;
+  };
+  for (Struct SS : View>()) {
+// CHECK-MESSAGES: [[@LINE-1]]:15: warning: loop variable is copied
+// CHECK-FIXES: for (const Struct& SS : View>()) {
+auto MemberCopy = SS.Member;
+const auto &ConstRef = SS.Member;
+bool b = SS.Member.constMethod();
+use(SS.Member);
+useByConstValue(SS.Member);
+useByValue(SS.Member);
+  }
+}
+
+void negativeNonConstMemberExpr() {
+  struct Struct {
+Mutable Member;
+  };
+  for (Struct SS : View>()) {
+SS.Member.setBool(true);
+  }
+  for (Struct SS : View>()) {
+SS.Member[1];
+  }
+  for (Struct SS : View>()) {
+mutate(SS.Member);
+  }
+  for (Struct SS : View>()) {
+mutate(&SS.Member);
+  }
+}
+
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -520,6 +520,22 @@
   support unscoped enumerations through instances and fixed usage of anonymous
   structs or classes.
 
+- Improved :doc:`performance-for-range-copy
+  `
+

  1   2   3   >