[clang] [clang] Warn about deprecated volatile-qualified return types (PR #137899)

2025-05-10 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`sanitizer-x86_64-linux-fast` running on `sanitizer-buildbot4` while building 
`clang` at step 2 "annotate".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/169/builds/11290


Here is the relevant piece of the build log for the reference

```
Step 2 (annotate) failure: 'python 
../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py'
 (failure)
...
llvm-lit: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520:
 note: using lld-link: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/lld-link
llvm-lit: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520:
 note: using ld64.lld: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/ld64.lld
llvm-lit: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520:
 note: using wasm-ld: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/wasm-ld
llvm-lit: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520:
 note: using ld.lld: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/ld.lld
llvm-lit: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520:
 note: using lld-link: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/lld-link
llvm-lit: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520:
 note: using ld64.lld: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/ld64.lld
llvm-lit: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520:
 note: using wasm-ld: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/wasm-ld
llvm-lit: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/main.py:72:
 note: The test suite configuration requested an individual test timeout of 0 
seconds but a timeout of 900 seconds was requested on the command line. Forcing 
timeout to be 900 seconds.
-- Testing: 89527 tests, 88 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90
FAIL: LLVM :: ExecutionEngine/JITLink/x86-64/COFF_nolibrary_search.s (62881 of 
89527)
 TEST 'LLVM :: 
ExecutionEngine/JITLink/x86-64/COFF_nolibrary_search.s' FAILED 

Exit Code: 1

Command Output (stderr):
--
rm -rf 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/test/ExecutionEngine/JITLink/x86-64/Output/COFF_nolibrary_search.s.tmp
 && mkdir -p 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/test/ExecutionEngine/JITLink/x86-64/Output/COFF_nolibrary_search.s.tmp
 # RUN: at line 1
+ rm -rf 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/test/ExecutionEngine/JITLink/x86-64/Output/COFF_nolibrary_search.s.tmp
+ mkdir -p 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/test/ExecutionEngine/JITLink/x86-64/Output/COFF_nolibrary_search.s.tmp
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/yaml2obj 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/ExecutionEngine/JITLink/x86-64/Inputs/COFF_weak_nolibrary_serach_def.yaml
 -o 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/test/ExecutionEngine/JITLink/x86-64/Output/COFF_nolibrary_search.s.tmp/COFF_weak.o
 # RUN: at line 2
+ /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/yaml2obj 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/ExecutionEngine/JITLink/x86-64/Inputs/COFF_weak_nolibrary_serach_def.yaml
 -o 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/test/ExecutionEngine/JITLink/x86-64/Output/COFF_nolibrary_search.s.tmp/COFF_weak.o
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/llvm-mc 
-filetype=obj -triple=x86_64-windows-msvc 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/ExecutionEngine/JITLink/x86-64/COFF_nolibrary_search.s
 -o 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/test/ExecutionEngine/JITLink/x86-64/Output/COFF_nolibrary_search.s.tmp/COFF_main.o
 # RUN: at line 3
+ /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/llvm-mc 
-filetype=obj -triple=x86_64-windows-msvc 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/ExecutionEngine/JITLink/x86-64/COFF_nolibrary_search.s
 -o 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/test/ExecutionEngine/JITLink/x86-64/Output/COFF_nolibrary_search.s.tmp/COFF_main.o
not 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/llvm-jitlink
 -noexec -abs __ImageBase=0xfff0  -slab-allocate 100Kb -slab-address 
0xfff0 -slab-page-size 4096  
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/test/ExecutionEngine/JITLink/x86-6

[clang] 802d8d9 - [Clang] Don't ditch typo-corrected lookup result (#139374)

2025-05-10 Thread via cfe-commits

Author: Younan Zhang
Date: 2025-05-10T20:44:45+08:00
New Revision: 802d8d90776b476ca8f257ab2e4fa2db185c6b69

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

LOG: [Clang] Don't ditch typo-corrected lookup result (#139374)

For a member function call like 'foo.bar()', there are two
typo-correction points after parsing the dot. The first occurs in
ParseOptionalCXXScopeSpecifier, which tries to annotate the template
name following any scope specifiers.

If the template name bar is not found within 'foo', the parser was
previously instructed to drop any function templates found outside of
the scope. This was intended to prevent ambiguity in expressions like
'foo->bar < 7', as explained in commit 50a3cddd. However, it's
unnecessary to discard typo-corrected results that were strictly
resolved within the scope 'foo'.

We won't perform a second typo-correction in ParseUnqualifiedId after
the name being annotated.

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaTemplate.cpp
clang/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 1d0896f585fb4..e362ec595a3bb 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -517,7 +517,10 @@ Improvements to Clang's diagnostics
 
 - Improved the ``-Wtautological-overlap-compare`` diagnostics to warn about 
overlapping and non-overlapping ranges involving character literals and 
floating-point literals. 
   The warning message for non-overlapping cases has also been improved 
(#GH13473).
-  
+
+- Fixed a duplicate diagnostic when performing typo correction on function 
template
+  calls with explicit template arguments. (#GH139226)
+
 Improvements to Clang's time-trace
 --
 

diff  --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 2ba69c87d95e3..7940340064eda 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -523,6 +523,9 @@ bool Sema::LookupTemplateName(LookupResult &Found, Scope 
*S, CXXScopeSpec &SS,
   if (Found.isAmbiguous()) {
 Found.clear();
   } else if (!Found.empty()) {
+// Do not erase the typo-corrected result to avoid duplicated
+// diagnostics.
+AllowFunctionTemplatesInLookup = true;
 Found.setLookupName(Corrected.getCorrection());
 if (LookupCtx) {
   std::string CorrectedStr(Corrected.getAsString(getLangOpts()));

diff  --git a/clang/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp 
b/clang/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp
index e3599db18350b..3633ef1c293e2 100644
--- a/clang/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp
+++ b/clang/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp
@@ -98,3 +98,16 @@ namespace PR11856 {
 }
   }
 }
+
+namespace GH139226 {
+
+struct Foo {
+  template  void LookupWithID(); // expected-note {{declared here}}
+};
+
+void test(Foo &f) {
+  f.LookupWithId();
+  // expected-error@-1 {{did you mean 'LookupWithID'}}
+}
+
+}



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


[clang] [Clang] Don't ditch typo-corrected lookup result (PR #139374)

2025-05-10 Thread Younan Zhang via cfe-commits

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


[clang] [CIR] Cleanup support for C functions (PR #136854)

2025-05-10 Thread Sirui Mu via cfe-commits

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

LGTM

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


[clang] [StaticAnalyzer] Handle `__builtin_bit_cast` (PR #139188)

2025-05-10 Thread Balazs Benics via cfe-commits

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

LGTM.

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


[clang] [StaticAnalyzer] Handle `__builtin_bit_cast` (PR #139188)

2025-05-10 Thread Balazs Benics via cfe-commits


@@ -282,15 +282,48 @@ ProgramStateRef ExprEngine::handleLValueBitCast(
 void ExprEngine::VisitCast(const CastExpr *CastE, const Expr *Ex,
ExplodedNode *Pred, ExplodedNodeSet &Dst) {
 
-  ExplodedNodeSet dstPreStmt;
-  getCheckerManager().runCheckersForPreStmt(dstPreStmt, Pred, CastE, *this);
-
-  if (CastE->getCastKind() == CK_LValueToRValue ||
-  CastE->getCastKind() == CK_LValueToRValueBitCast) {
-for (ExplodedNode *subExprNode : dstPreStmt) {
-  ProgramStateRef state = subExprNode->getState();
-  const LocationContext *LCtx = subExprNode->getLocationContext();
-  evalLoad(Dst, CastE, CastE, subExprNode, state, state->getSVal(Ex, 
LCtx));
+  ExplodedNodeSet DstPreStmt;
+  getCheckerManager().runCheckersForPreStmt(DstPreStmt, Pred, CastE, *this);
+
+  if (CastE->getCastKind() == CK_LValueToRValue) {
+for (ExplodedNode *Node : DstPreStmt) {
+  ProgramStateRef State = Node->getState();
+  const LocationContext *LCtx = Node->getLocationContext();
+  evalLoad(Dst, CastE, CastE, Node, State, State->getSVal(Ex, LCtx));
+}
+return;
+  }
+  if (CastE->getCastKind() == CK_LValueToRValueBitCast) {
+// Handle `__builtin_bit_cast`:
+ExplodedNodeSet DstEvalLoc;
+
+// Simulate the lvalue-to-rvalue conversion on `Ex`:
+for (ExplodedNode *Node : DstPreStmt) {
+  ProgramStateRef State = Node->getState();
+  const LocationContext *LCtx = Node->getLocationContext();
+  evalLocation(DstEvalLoc, CastE, Ex, Node, State, State->getSVal(Ex, 
LCtx),
+   true);
+}
+// Simulate the operation that actually casts the original value to a new
+// value of the destination type :
+StmtNodeBuilder Bldr(DstEvalLoc, Dst, *currBldrCtx);
+
+for (ExplodedNode *Node : DstEvalLoc) {
+  ProgramStateRef State = Node->getState();
+  const LocationContext *LCtx = Node->getLocationContext();
+  // Although `Ex` is an lvalue, it could have `Loc::ConcreteInt` kind
+  // (e.g., `(int *)123456`).  In such cases, there is no MemRegion
+  // available and we can't get the value to be casted.
+  const MemRegion *MR = State->getSVal(Ex, LCtx).getAsRegion();
+  SVal CastedV = UnknownVal();
+
+  if (MR) {

steakhal wrote:

You could use init ifs here.

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


[clang] [StaticAnalyzer] Handle `__builtin_bit_cast` (PR #139188)

2025-05-10 Thread Balazs Benics via cfe-commits

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


[clang] [StaticAnalyzer] Handle `__builtin_bit_cast` (PR #139188)

2025-05-10 Thread Balazs Benics via cfe-commits


@@ -1,5 +1,5 @@
 // RUN: %clang_analyze_cc1 -triple x86_64-unknown-unknown -verify %s \
-// RUN:   -analyzer-checker=core,debug.ExprInspection
+// RUN:   -analyzer-checker=debug.ExprInspection -analyzer-disable-checker=core

steakhal wrote:

Why do you disable core?
That is not supposed to be disabled. Checkers or the engine may crash if core 
is disabled.

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


[clang] [flang] [llvm] [flang][OpenMP] Pass OpenMP version to getOpenMPDirectiveName (PR #139131)

2025-05-10 Thread Michał Górny via cfe-commits

mgorny wrote:

Filed https://github.com/llvm/llvm-project/pull/139371

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


[clang-tools-extra] [clang-tools-extra] Remove unused local variables (NFC) (PR #139382)

2025-05-10 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clangd

Author: Kazu Hirata (kazutakahirata)


Changes



---
Full diff: https://github.com/llvm/llvm-project/pull/139382.diff


5 Files Affected:

- (modified) clang-tools-extra/clangd/DumpAST.cpp (-1) 
- (modified) clang-tools-extra/clangd/unittests/SerializationTests.cpp (-1) 
- (modified) clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp (-1) 
- (modified) clang-tools-extra/modularize/Modularize.cpp (-2) 
- (modified) clang-tools-extra/modularize/PreprocessorTracker.cpp (-2) 


``diff
diff --git a/clang-tools-extra/clangd/DumpAST.cpp 
b/clang-tools-extra/clangd/DumpAST.cpp
index 584bb1f088380..8f24477ecd3de 100644
--- a/clang-tools-extra/clangd/DumpAST.cpp
+++ b/clang-tools-extra/clangd/DumpAST.cpp
@@ -124,7 +124,6 @@ class DumpVisitor : public RecursiveASTVisitor 
{
 return Result;
   }
   std::string getKind(const TypeLoc &TL) {
-std::string Result;
 if (TL.getTypeLocClass() == TypeLoc::Qualified)
   return "Qualified";
 return TL.getType()->getTypeClassName();
diff --git a/clang-tools-extra/clangd/unittests/SerializationTests.cpp 
b/clang-tools-extra/clangd/unittests/SerializationTests.cpp
index 2a7a6c36d3d17..d18ae478c1653 100644
--- a/clang-tools-extra/clangd/unittests/SerializationTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SerializationTests.cpp
@@ -433,7 +433,6 @@ TEST(SerializationTest, NoCrashOnBadStringTableSize) {
   std::string CorruptStri =
   (llvm::fromHex("") + Stri->Data.drop_front(4)).str();
   Stri->Data = CorruptStri;
-  std::string FileDigest = llvm::fromHex("EED8F5EAF25C453C");
 
   // Try to crash rather than hang on large allocation.
   ScopedMemoryLimit MemLimit(1000 * 1024 * 1024); // 1GB
diff --git a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp 
b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
index 33490de9b0f6c..9431211b03e71 100644
--- a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
+++ b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
@@ -344,7 +344,6 @@ mapInputsToAbsPaths(clang::tooling::CompilationDatabase 
&CDB,
 }
 for (const auto &Cmd : Cmds) {
   llvm::SmallString<256> CDBPath(Cmd.Filename);
-  std::string Directory(Cmd.Directory);
   llvm::sys::fs::make_absolute(Cmd.Directory, CDBPath);
   CDBToAbsPaths[std::string(CDBPath)] = std::string(AbsPath);
 }
diff --git a/clang-tools-extra/modularize/Modularize.cpp 
b/clang-tools-extra/modularize/Modularize.cpp
index 4bb3bae0503ac..38979cb4d6911 100644
--- a/clang-tools-extra/modularize/Modularize.cpp
+++ b/clang-tools-extra/modularize/Modularize.cpp
@@ -360,8 +360,6 @@ getModularizeArgumentsAdjuster(DependencyMap &Dependencies) 
{
 if (int Count = FileDependents.size()) {
   for (int Index = 0; Index < Count; ++Index) {
 NewArgs.push_back("-include");
-std::string File(std::string("\"") + FileDependents[Index] +
- std::string("\""));
 NewArgs.push_back(FileDependents[Index]);
   }
 }
diff --git a/clang-tools-extra/modularize/PreprocessorTracker.cpp 
b/clang-tools-extra/modularize/PreprocessorTracker.cpp
index 85e3aab041e49..0c030f1112204 100644
--- a/clang-tools-extra/modularize/PreprocessorTracker.cpp
+++ b/clang-tools-extra/modularize/PreprocessorTracker.cpp
@@ -381,7 +381,6 @@ static std::string 
getMacroUnexpandedString(clang::SourceRange Range,
   clang::SourceLocation BeginLoc(Range.getBegin());
   const char *BeginPtr = PP.getSourceManager().getCharacterData(BeginLoc);
   size_t Length;
-  std::string Unexpanded;
   if (MI->isFunctionLike()) {
 clang::SourceLocation EndLoc(Range.getEnd());
 const char *EndPtr = PP.getSourceManager().getCharacterData(EndLoc) + 1;
@@ -1328,7 +1327,6 @@ void PreprocessorCallbacks::Defined(const clang::Token 
&MacroNameTok,
   clang::SourceLocation Loc(Range.getBegin());
   clang::IdentifierInfo *II = MacroNameTok.getIdentifierInfo();
   const clang::MacroInfo *MI = MD.getMacroInfo();
-  std::string MacroName = II->getName().str();
   std::string Unexpanded(getSourceString(PP, Range));
   PPTracker.addMacroExpansionInstance(
   PP, PPTracker.getCurrentHeaderHandle(), Loc,

``




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


[clang-tools-extra] [clang-tools-extra] Remove unused local variables (NFC) (PR #139382)

2025-05-10 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-tools-extra

Author: Kazu Hirata (kazutakahirata)


Changes



---
Full diff: https://github.com/llvm/llvm-project/pull/139382.diff


5 Files Affected:

- (modified) clang-tools-extra/clangd/DumpAST.cpp (-1) 
- (modified) clang-tools-extra/clangd/unittests/SerializationTests.cpp (-1) 
- (modified) clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp (-1) 
- (modified) clang-tools-extra/modularize/Modularize.cpp (-2) 
- (modified) clang-tools-extra/modularize/PreprocessorTracker.cpp (-2) 


``diff
diff --git a/clang-tools-extra/clangd/DumpAST.cpp 
b/clang-tools-extra/clangd/DumpAST.cpp
index 584bb1f088380..8f24477ecd3de 100644
--- a/clang-tools-extra/clangd/DumpAST.cpp
+++ b/clang-tools-extra/clangd/DumpAST.cpp
@@ -124,7 +124,6 @@ class DumpVisitor : public RecursiveASTVisitor 
{
 return Result;
   }
   std::string getKind(const TypeLoc &TL) {
-std::string Result;
 if (TL.getTypeLocClass() == TypeLoc::Qualified)
   return "Qualified";
 return TL.getType()->getTypeClassName();
diff --git a/clang-tools-extra/clangd/unittests/SerializationTests.cpp 
b/clang-tools-extra/clangd/unittests/SerializationTests.cpp
index 2a7a6c36d3d17..d18ae478c1653 100644
--- a/clang-tools-extra/clangd/unittests/SerializationTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SerializationTests.cpp
@@ -433,7 +433,6 @@ TEST(SerializationTest, NoCrashOnBadStringTableSize) {
   std::string CorruptStri =
   (llvm::fromHex("") + Stri->Data.drop_front(4)).str();
   Stri->Data = CorruptStri;
-  std::string FileDigest = llvm::fromHex("EED8F5EAF25C453C");
 
   // Try to crash rather than hang on large allocation.
   ScopedMemoryLimit MemLimit(1000 * 1024 * 1024); // 1GB
diff --git a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp 
b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
index 33490de9b0f6c..9431211b03e71 100644
--- a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
+++ b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
@@ -344,7 +344,6 @@ mapInputsToAbsPaths(clang::tooling::CompilationDatabase 
&CDB,
 }
 for (const auto &Cmd : Cmds) {
   llvm::SmallString<256> CDBPath(Cmd.Filename);
-  std::string Directory(Cmd.Directory);
   llvm::sys::fs::make_absolute(Cmd.Directory, CDBPath);
   CDBToAbsPaths[std::string(CDBPath)] = std::string(AbsPath);
 }
diff --git a/clang-tools-extra/modularize/Modularize.cpp 
b/clang-tools-extra/modularize/Modularize.cpp
index 4bb3bae0503ac..38979cb4d6911 100644
--- a/clang-tools-extra/modularize/Modularize.cpp
+++ b/clang-tools-extra/modularize/Modularize.cpp
@@ -360,8 +360,6 @@ getModularizeArgumentsAdjuster(DependencyMap &Dependencies) 
{
 if (int Count = FileDependents.size()) {
   for (int Index = 0; Index < Count; ++Index) {
 NewArgs.push_back("-include");
-std::string File(std::string("\"") + FileDependents[Index] +
- std::string("\""));
 NewArgs.push_back(FileDependents[Index]);
   }
 }
diff --git a/clang-tools-extra/modularize/PreprocessorTracker.cpp 
b/clang-tools-extra/modularize/PreprocessorTracker.cpp
index 85e3aab041e49..0c030f1112204 100644
--- a/clang-tools-extra/modularize/PreprocessorTracker.cpp
+++ b/clang-tools-extra/modularize/PreprocessorTracker.cpp
@@ -381,7 +381,6 @@ static std::string 
getMacroUnexpandedString(clang::SourceRange Range,
   clang::SourceLocation BeginLoc(Range.getBegin());
   const char *BeginPtr = PP.getSourceManager().getCharacterData(BeginLoc);
   size_t Length;
-  std::string Unexpanded;
   if (MI->isFunctionLike()) {
 clang::SourceLocation EndLoc(Range.getEnd());
 const char *EndPtr = PP.getSourceManager().getCharacterData(EndLoc) + 1;
@@ -1328,7 +1327,6 @@ void PreprocessorCallbacks::Defined(const clang::Token 
&MacroNameTok,
   clang::SourceLocation Loc(Range.getBegin());
   clang::IdentifierInfo *II = MacroNameTok.getIdentifierInfo();
   const clang::MacroInfo *MI = MD.getMacroInfo();
-  std::string MacroName = II->getName().str();
   std::string Unexpanded(getSourceString(PP, Range));
   PPTracker.addMacroExpansionInstance(
   PP, PPTracker.getCurrentHeaderHandle(), Loc,

``




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


[clang-tools-extra] [clang-tools-extra] Remove unused local variables (NFC) (PR #139382)

2025-05-10 Thread Kazu Hirata via cfe-commits

https://github.com/kazutakahirata created 
https://github.com/llvm/llvm-project/pull/139382

None

>From 57d89aa1eca3ef2d1a04281d99a092ef98aab980 Mon Sep 17 00:00:00 2001
From: Kazu Hirata 
Date: Mon, 5 May 2025 11:34:38 -0700
Subject: [PATCH] [clang-tools-extra] Remove unused local variables (NFC)

---
 clang-tools-extra/clangd/DumpAST.cpp  | 1 -
 clang-tools-extra/clangd/unittests/SerializationTests.cpp | 1 -
 clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp | 1 -
 clang-tools-extra/modularize/Modularize.cpp   | 2 --
 clang-tools-extra/modularize/PreprocessorTracker.cpp  | 2 --
 5 files changed, 7 deletions(-)

diff --git a/clang-tools-extra/clangd/DumpAST.cpp 
b/clang-tools-extra/clangd/DumpAST.cpp
index 584bb1f088380..8f24477ecd3de 100644
--- a/clang-tools-extra/clangd/DumpAST.cpp
+++ b/clang-tools-extra/clangd/DumpAST.cpp
@@ -124,7 +124,6 @@ class DumpVisitor : public RecursiveASTVisitor 
{
 return Result;
   }
   std::string getKind(const TypeLoc &TL) {
-std::string Result;
 if (TL.getTypeLocClass() == TypeLoc::Qualified)
   return "Qualified";
 return TL.getType()->getTypeClassName();
diff --git a/clang-tools-extra/clangd/unittests/SerializationTests.cpp 
b/clang-tools-extra/clangd/unittests/SerializationTests.cpp
index 2a7a6c36d3d17..d18ae478c1653 100644
--- a/clang-tools-extra/clangd/unittests/SerializationTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SerializationTests.cpp
@@ -433,7 +433,6 @@ TEST(SerializationTest, NoCrashOnBadStringTableSize) {
   std::string CorruptStri =
   (llvm::fromHex("") + Stri->Data.drop_front(4)).str();
   Stri->Data = CorruptStri;
-  std::string FileDigest = llvm::fromHex("EED8F5EAF25C453C");
 
   // Try to crash rather than hang on large allocation.
   ScopedMemoryLimit MemLimit(1000 * 1024 * 1024); // 1GB
diff --git a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp 
b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
index 33490de9b0f6c..9431211b03e71 100644
--- a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
+++ b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
@@ -344,7 +344,6 @@ mapInputsToAbsPaths(clang::tooling::CompilationDatabase 
&CDB,
 }
 for (const auto &Cmd : Cmds) {
   llvm::SmallString<256> CDBPath(Cmd.Filename);
-  std::string Directory(Cmd.Directory);
   llvm::sys::fs::make_absolute(Cmd.Directory, CDBPath);
   CDBToAbsPaths[std::string(CDBPath)] = std::string(AbsPath);
 }
diff --git a/clang-tools-extra/modularize/Modularize.cpp 
b/clang-tools-extra/modularize/Modularize.cpp
index 4bb3bae0503ac..38979cb4d6911 100644
--- a/clang-tools-extra/modularize/Modularize.cpp
+++ b/clang-tools-extra/modularize/Modularize.cpp
@@ -360,8 +360,6 @@ getModularizeArgumentsAdjuster(DependencyMap &Dependencies) 
{
 if (int Count = FileDependents.size()) {
   for (int Index = 0; Index < Count; ++Index) {
 NewArgs.push_back("-include");
-std::string File(std::string("\"") + FileDependents[Index] +
- std::string("\""));
 NewArgs.push_back(FileDependents[Index]);
   }
 }
diff --git a/clang-tools-extra/modularize/PreprocessorTracker.cpp 
b/clang-tools-extra/modularize/PreprocessorTracker.cpp
index 85e3aab041e49..0c030f1112204 100644
--- a/clang-tools-extra/modularize/PreprocessorTracker.cpp
+++ b/clang-tools-extra/modularize/PreprocessorTracker.cpp
@@ -381,7 +381,6 @@ static std::string 
getMacroUnexpandedString(clang::SourceRange Range,
   clang::SourceLocation BeginLoc(Range.getBegin());
   const char *BeginPtr = PP.getSourceManager().getCharacterData(BeginLoc);
   size_t Length;
-  std::string Unexpanded;
   if (MI->isFunctionLike()) {
 clang::SourceLocation EndLoc(Range.getEnd());
 const char *EndPtr = PP.getSourceManager().getCharacterData(EndLoc) + 1;
@@ -1328,7 +1327,6 @@ void PreprocessorCallbacks::Defined(const clang::Token 
&MacroNameTok,
   clang::SourceLocation Loc(Range.getBegin());
   clang::IdentifierInfo *II = MacroNameTok.getIdentifierInfo();
   const clang::MacroInfo *MI = MD.getMacroInfo();
-  std::string MacroName = II->getName().str();
   std::string Unexpanded(getSourceString(PP, Range));
   PPTracker.addMacroExpansionInstance(
   PP, PPTracker.getCurrentHeaderHandle(), Loc,

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


[clang] [llvm] [RISCV][MC] Add support for Q extension (PR #139369)

2025-05-10 Thread Craig Topper via cfe-commits


@@ -0,0 +1,168 @@
+//===-- RISCVInstrInfoF.td - RISC-V 'Q' instructions ---*- tablegen 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file describes the RISC-V instructions from the standard 'Q',
+// Quad-Precision Floating-Point instruction set extension.
+//
+//===--===//
+
+//===--===//
+// Operand and SDNode transformation definitions.
+//===--===//
+
+def QExt : ExtInfo<"", "", [HasStdExtQ], f128, FPR128, FPR32, FPR64, ?, 
FPR128>;
+
+defvar QExts = [QExt];
+defvar QExtsRV64 = [QExt];
+
+//===--===//
+// Instructions
+//===--===//
+
+let Predicates = [HasStdExtQ] in {
+  def FLQ : FPLoad_r<0b100, "flq", FPR128, WriteFLD128>;
+
+  // Operands for stores are in the order srcreg, base, offset rather than
+  // reflecting the order these fields are specified in the instruction
+  // encoding.
+  def FSQ : FPStore_r<0b100, "fsq", FPR128, WriteFST128>;
+}
+
+foreach Ext = QExts in {
+  let SchedRW = [WriteFMA128, ReadFMA128, ReadFMA128, ReadFMA128Addend] in {
+defm FMADD_Q : FPFMA_rrr_frm_m;
+defm FMSUB_Q : FPFMA_rrr_frm_m;
+defm FNMSUB_Q : FPFMA_rrr_frm_m;
+defm FNMADD_Q : FPFMA_rrr_frm_m;
+  }
+
+  let SchedRW = [WriteFAdd128, ReadFAdd128, ReadFAdd128] in {
+defm FADD_Q : FPALU_rr_frm_m<0b011, "fadd.q", Ext>;
+defm FSUB_Q : FPALU_rr_frm_m<0b111, "fsub.q", Ext>;
+  }
+
+  let SchedRW = [WriteFMul128, ReadFMul128, ReadFMul128] in 
+  defm FMUL_Q : FPALU_rr_frm_m<0b0001011, "fmul.q", Ext>;
+
+  let SchedRW = [WriteFDiv128, ReadFDiv128, ReadFDiv128] in 
+  defm FDIV_Q : FPALU_rr_frm_m<0b000, "fdiv.q", Ext>;
+
+  defm FSQRT_Q : FPUnaryOp_r_frm_m<0b010, 0b0, Ext, Ext.PrimaryTy,
+   Ext.PrimaryTy, "fsqrt.q">,
+ Sched<[WriteFSqrt128, ReadFSqrt128]>;
+
+  let SchedRW = [WriteFSGNJ128, ReadFSGNJ128, ReadFSGNJ128],
+  mayRaiseFPException = 0 in {
+defm FSGNJ_Q : FPALU_rr_m<0b0010011, 0b000, "fsgnj.q", Ext>;
+defm FSGNJN_Q : FPALU_rr_m<0b0010011, 0b001, "fsgnjn.q", Ext>;
+defm FSGNJX_Q : FPALU_rr_m<0b0010011, 0b010, "fsgnjx.q", Ext>;
+  }
+
+  let SchedRW = [WriteFMinMax128, ReadFMinMax128, ReadFMinMax128] in {
+defm FMIN_Q : FPALU_rr_m<0b0010111, 0b000, "fmin.q", Ext, Commutable = 1>;
+defm FMAX_Q : FPALU_rr_m<0b0010111, 0b001, "fmax.q", Ext, Commutable = 1>;
+  }
+
+  defm FCVT_S_Q : FPUnaryOp_r_frm_m<0b010, 0b00011, Ext, Ext.F32Ty,
+Ext.PrimaryTy, "fcvt.s.q">,
+  Sched<[WriteFCvtF128ToF32, ReadFCvtF128ToF32]>;
+
+  defm FCVT_Q_S : FPUnaryOp_r_frmlegacy_m<0b0100011, 0b0, Ext,
+  Ext.PrimaryTy, Ext.F32Ty, 
"fcvt.q.s">,
+  Sched<[WriteFCvtF32ToF128, ReadFCvtF32ToF128]>;
+
+  defm FCVT_D_Q : FPUnaryOp_r_frm_m<0b011, 0b00011, Ext, Ext.F64Ty,
+Ext.PrimaryTy, "fcvt.d.q">,
+  Sched<[WriteFCvtF128ToF64, ReadFCvtF128ToF64]>;
+
+  defm FCVT_Q_D : FPUnaryOp_r_frmlegacy_m<0b0100011, 0b1, Ext,
+  Ext.PrimaryTy, Ext.F64Ty, 
"fcvt.q.d">,
+  Sched<[WriteFCvtF64ToF128, ReadFCvtF64ToF128]>;
+
+  let SchedRW = [WriteFCmp128, ReadFCmp128, ReadFCmp128] in {
+defm FEQ_Q : FPCmp_rr_m<0b1010011, 0b010, "feq.q", Ext, Commutable = 1>;
+defm FLT_Q : FPCmp_rr_m<0b1010011, 0b001, "flt.q", Ext>;
+defm FLE_Q : FPCmp_rr_m<0b1010011, 0b000, "fle.q", Ext>;
+  }
+
+  let mayRaiseFPException = 0 in 
+  defm FCLASS_Q : FPUnaryOp_r_m<0b1110011, 0b0, 0b001, Ext, GPR,
+Ext.PrimaryTy, "fclass.q">,
+  Sched<[WriteFClass128, ReadFClass128]>;
+
+  let IsSignExtendingOpW = 1 in 
+  defm FCVT_W_Q : FPUnaryOp_r_frm_m<0b1100011, 0b0, Ext, GPR,
+Ext.PrimaryTy, "fcvt.w.q">,
+  Sched<[WriteFCvtF128ToI32, ReadFCvtF128ToI32]>;
+
+  let IsSignExtendingOpW = 1 in 
+  defm FCVT_WU_Q : FPUnaryOp_r_frm_m<0b1100011, 0b1, Ext, GPR,
+ Ext.PrimaryTy, "fcvt.wu.q">,
+  Sched<[WriteFCvtF128ToI32, ReadFCvtF128ToI32]>;
+
+  let mayRaiseFPException = 0 in 
+  defm FCVT_Q_W : FPUnaryOp_r_frm_m<0b1101011, 0b0, Ext,
+Ext.PrimaryTy, GPR, "fcvt.q.w">,
+  Sched<[WriteFCvtI32ToF128, ReadFCvtI32ToF128]>;
+
+  let mayRaiseFPException = 0 in 
+  def

[clang] [llvm] [RISCV][MC] Add support for Q extension (PR #139369)

2025-05-10 Thread Craig Topper via cfe-commits


@@ -462,6 +474,12 @@ def FPR64C : RISCVRegisterClass<[f64], 64, (add
   (sequence "F%u_D", 8, 9)
 )>;
 
+def FPR128 : RISCVRegisterClass<
+ [f128], 128,

topperc wrote:

Format this the same was as FPR64?

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


[clang] [llvm] [RISCV][MC] Add support for Q extension (PR #139369)

2025-05-10 Thread Craig Topper via cfe-commits


@@ -0,0 +1,168 @@
+//===-- RISCVInstrInfoF.td - RISC-V 'Q' instructions ---*- tablegen 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file describes the RISC-V instructions from the standard 'Q',
+// Quad-Precision Floating-Point instruction set extension.
+//
+//===--===//
+
+//===--===//
+// Operand and SDNode transformation definitions.
+//===--===//
+
+def QExt : ExtInfo<"", "", [HasStdExtQ], f128, FPR128, FPR32, FPR64, ?, 
FPR128>;
+
+defvar QExts = [QExt];
+defvar QExtsRV64 = [QExt];
+
+//===--===//
+// Instructions
+//===--===//
+
+let Predicates = [HasStdExtQ] in {
+  def FLQ : FPLoad_r<0b100, "flq", FPR128, WriteFLD128>;
+
+  // Operands for stores are in the order srcreg, base, offset rather than
+  // reflecting the order these fields are specified in the instruction
+  // encoding.
+  def FSQ : FPStore_r<0b100, "fsq", FPR128, WriteFST128>;
+}
+
+foreach Ext = QExts in {
+  let SchedRW = [WriteFMA128, ReadFMA128, ReadFMA128, ReadFMA128Addend] in {
+defm FMADD_Q : FPFMA_rrr_frm_m;
+defm FMSUB_Q : FPFMA_rrr_frm_m;
+defm FNMSUB_Q : FPFMA_rrr_frm_m;
+defm FNMADD_Q : FPFMA_rrr_frm_m;
+  }
+
+  let SchedRW = [WriteFAdd128, ReadFAdd128, ReadFAdd128] in {
+defm FADD_Q : FPALU_rr_frm_m<0b011, "fadd.q", Ext>;
+defm FSUB_Q : FPALU_rr_frm_m<0b111, "fsub.q", Ext>;
+  }
+
+  let SchedRW = [WriteFMul128, ReadFMul128, ReadFMul128] in 
+  defm FMUL_Q : FPALU_rr_frm_m<0b0001011, "fmul.q", Ext>;
+
+  let SchedRW = [WriteFDiv128, ReadFDiv128, ReadFDiv128] in 
+  defm FDIV_Q : FPALU_rr_frm_m<0b000, "fdiv.q", Ext>;
+
+  defm FSQRT_Q : FPUnaryOp_r_frm_m<0b010, 0b0, Ext, Ext.PrimaryTy,
+   Ext.PrimaryTy, "fsqrt.q">,
+ Sched<[WriteFSqrt128, ReadFSqrt128]>;
+
+  let SchedRW = [WriteFSGNJ128, ReadFSGNJ128, ReadFSGNJ128],
+  mayRaiseFPException = 0 in {
+defm FSGNJ_Q : FPALU_rr_m<0b0010011, 0b000, "fsgnj.q", Ext>;
+defm FSGNJN_Q : FPALU_rr_m<0b0010011, 0b001, "fsgnjn.q", Ext>;
+defm FSGNJX_Q : FPALU_rr_m<0b0010011, 0b010, "fsgnjx.q", Ext>;
+  }
+
+  let SchedRW = [WriteFMinMax128, ReadFMinMax128, ReadFMinMax128] in {
+defm FMIN_Q : FPALU_rr_m<0b0010111, 0b000, "fmin.q", Ext, Commutable = 1>;
+defm FMAX_Q : FPALU_rr_m<0b0010111, 0b001, "fmax.q", Ext, Commutable = 1>;
+  }
+
+  defm FCVT_S_Q : FPUnaryOp_r_frm_m<0b010, 0b00011, Ext, Ext.F32Ty,
+Ext.PrimaryTy, "fcvt.s.q">,
+  Sched<[WriteFCvtF128ToF32, ReadFCvtF128ToF32]>;
+
+  defm FCVT_Q_S : FPUnaryOp_r_frmlegacy_m<0b0100011, 0b0, Ext,
+  Ext.PrimaryTy, Ext.F32Ty, 
"fcvt.q.s">,
+  Sched<[WriteFCvtF32ToF128, ReadFCvtF32ToF128]>;
+
+  defm FCVT_D_Q : FPUnaryOp_r_frm_m<0b011, 0b00011, Ext, Ext.F64Ty,
+Ext.PrimaryTy, "fcvt.d.q">,
+  Sched<[WriteFCvtF128ToF64, ReadFCvtF128ToF64]>;
+
+  defm FCVT_Q_D : FPUnaryOp_r_frmlegacy_m<0b0100011, 0b1, Ext,
+  Ext.PrimaryTy, Ext.F64Ty, 
"fcvt.q.d">,
+  Sched<[WriteFCvtF64ToF128, ReadFCvtF64ToF128]>;
+
+  let SchedRW = [WriteFCmp128, ReadFCmp128, ReadFCmp128] in {
+defm FEQ_Q : FPCmp_rr_m<0b1010011, 0b010, "feq.q", Ext, Commutable = 1>;
+defm FLT_Q : FPCmp_rr_m<0b1010011, 0b001, "flt.q", Ext>;
+defm FLE_Q : FPCmp_rr_m<0b1010011, 0b000, "fle.q", Ext>;
+  }
+
+  let mayRaiseFPException = 0 in 
+  defm FCLASS_Q : FPUnaryOp_r_m<0b1110011, 0b0, 0b001, Ext, GPR,
+Ext.PrimaryTy, "fclass.q">,
+  Sched<[WriteFClass128, ReadFClass128]>;
+
+  let IsSignExtendingOpW = 1 in 
+  defm FCVT_W_Q : FPUnaryOp_r_frm_m<0b1100011, 0b0, Ext, GPR,
+Ext.PrimaryTy, "fcvt.w.q">,
+  Sched<[WriteFCvtF128ToI32, ReadFCvtF128ToI32]>;
+
+  let IsSignExtendingOpW = 1 in 
+  defm FCVT_WU_Q : FPUnaryOp_r_frm_m<0b1100011, 0b1, Ext, GPR,
+ Ext.PrimaryTy, "fcvt.wu.q">,
+  Sched<[WriteFCvtF128ToI32, ReadFCvtF128ToI32]>;
+
+  let mayRaiseFPException = 0 in 
+  defm FCVT_Q_W : FPUnaryOp_r_frm_m<0b1101011, 0b0, Ext,
+Ext.PrimaryTy, GPR, "fcvt.q.w">,
+  Sched<[WriteFCvtI32ToF128, ReadFCvtI32ToF128]>;
+
+  let mayRaiseFPException = 0 in 
+  def

[clang] [llvm] [RISCV][MC] Add support for Q extension (PR #139369)

2025-05-10 Thread Craig Topper via cfe-commits


@@ -0,0 +1,168 @@
+//===-- RISCVInstrInfoF.td - RISC-V 'Q' instructions ---*- tablegen 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file describes the RISC-V instructions from the standard 'Q',
+// Quad-Precision Floating-Point instruction set extension.
+//
+//===--===//
+
+//===--===//
+// Operand and SDNode transformation definitions.
+//===--===//
+
+def QExt : ExtInfo<"", "", [HasStdExtQ], f128, FPR128, FPR32, FPR64, ?, 
FPR128>;
+
+defvar QExts = [QExt];
+defvar QExtsRV64 = [QExt];
+
+//===--===//
+// Instructions
+//===--===//
+
+let Predicates = [HasStdExtQ] in {
+  def FLQ : FPLoad_r<0b100, "flq", FPR128, WriteFLD128>;
+
+  // Operands for stores are in the order srcreg, base, offset rather than
+  // reflecting the order these fields are specified in the instruction
+  // encoding.
+  def FSQ : FPStore_r<0b100, "fsq", FPR128, WriteFST128>;
+}
+
+foreach Ext = QExts in {
+  let SchedRW = [WriteFMA128, ReadFMA128, ReadFMA128, ReadFMA128Addend] in {
+defm FMADD_Q : FPFMA_rrr_frm_m;
+defm FMSUB_Q : FPFMA_rrr_frm_m;
+defm FNMSUB_Q : FPFMA_rrr_frm_m;
+defm FNMADD_Q : FPFMA_rrr_frm_m;
+  }
+
+  let SchedRW = [WriteFAdd128, ReadFAdd128, ReadFAdd128] in {
+defm FADD_Q : FPALU_rr_frm_m<0b011, "fadd.q", Ext>;
+defm FSUB_Q : FPALU_rr_frm_m<0b111, "fsub.q", Ext>;
+  }
+
+  let SchedRW = [WriteFMul128, ReadFMul128, ReadFMul128] in 
+  defm FMUL_Q : FPALU_rr_frm_m<0b0001011, "fmul.q", Ext>;
+
+  let SchedRW = [WriteFDiv128, ReadFDiv128, ReadFDiv128] in 
+  defm FDIV_Q : FPALU_rr_frm_m<0b000, "fdiv.q", Ext>;
+
+  defm FSQRT_Q : FPUnaryOp_r_frm_m<0b010, 0b0, Ext, Ext.PrimaryTy,
+   Ext.PrimaryTy, "fsqrt.q">,
+ Sched<[WriteFSqrt128, ReadFSqrt128]>;
+
+  let SchedRW = [WriteFSGNJ128, ReadFSGNJ128, ReadFSGNJ128],
+  mayRaiseFPException = 0 in {
+defm FSGNJ_Q : FPALU_rr_m<0b0010011, 0b000, "fsgnj.q", Ext>;
+defm FSGNJN_Q : FPALU_rr_m<0b0010011, 0b001, "fsgnjn.q", Ext>;
+defm FSGNJX_Q : FPALU_rr_m<0b0010011, 0b010, "fsgnjx.q", Ext>;
+  }
+
+  let SchedRW = [WriteFMinMax128, ReadFMinMax128, ReadFMinMax128] in {
+defm FMIN_Q : FPALU_rr_m<0b0010111, 0b000, "fmin.q", Ext, Commutable = 1>;
+defm FMAX_Q : FPALU_rr_m<0b0010111, 0b001, "fmax.q", Ext, Commutable = 1>;
+  }
+
+  defm FCVT_S_Q : FPUnaryOp_r_frm_m<0b010, 0b00011, Ext, Ext.F32Ty,
+Ext.PrimaryTy, "fcvt.s.q">,
+  Sched<[WriteFCvtF128ToF32, ReadFCvtF128ToF32]>;
+
+  defm FCVT_Q_S : FPUnaryOp_r_frmlegacy_m<0b0100011, 0b0, Ext,
+  Ext.PrimaryTy, Ext.F32Ty, 
"fcvt.q.s">,
+  Sched<[WriteFCvtF32ToF128, ReadFCvtF32ToF128]>;
+
+  defm FCVT_D_Q : FPUnaryOp_r_frm_m<0b011, 0b00011, Ext, Ext.F64Ty,
+Ext.PrimaryTy, "fcvt.d.q">,
+  Sched<[WriteFCvtF128ToF64, ReadFCvtF128ToF64]>;
+
+  defm FCVT_Q_D : FPUnaryOp_r_frmlegacy_m<0b0100011, 0b1, Ext,
+  Ext.PrimaryTy, Ext.F64Ty, 
"fcvt.q.d">,
+  Sched<[WriteFCvtF64ToF128, ReadFCvtF64ToF128]>;
+
+  let SchedRW = [WriteFCmp128, ReadFCmp128, ReadFCmp128] in {
+defm FEQ_Q : FPCmp_rr_m<0b1010011, 0b010, "feq.q", Ext, Commutable = 1>;
+defm FLT_Q : FPCmp_rr_m<0b1010011, 0b001, "flt.q", Ext>;
+defm FLE_Q : FPCmp_rr_m<0b1010011, 0b000, "fle.q", Ext>;
+  }
+
+  let mayRaiseFPException = 0 in 
+  defm FCLASS_Q : FPUnaryOp_r_m<0b1110011, 0b0, 0b001, Ext, GPR,
+Ext.PrimaryTy, "fclass.q">,
+  Sched<[WriteFClass128, ReadFClass128]>;
+
+  let IsSignExtendingOpW = 1 in 
+  defm FCVT_W_Q : FPUnaryOp_r_frm_m<0b1100011, 0b0, Ext, GPR,
+Ext.PrimaryTy, "fcvt.w.q">,
+  Sched<[WriteFCvtF128ToI32, ReadFCvtF128ToI32]>;
+
+  let IsSignExtendingOpW = 1 in 
+  defm FCVT_WU_Q : FPUnaryOp_r_frm_m<0b1100011, 0b1, Ext, GPR,
+ Ext.PrimaryTy, "fcvt.wu.q">,
+  Sched<[WriteFCvtF128ToI32, ReadFCvtF128ToI32]>;
+
+  let mayRaiseFPException = 0 in 
+  defm FCVT_Q_W : FPUnaryOp_r_frm_m<0b1101011, 0b0, Ext,
+Ext.PrimaryTy, GPR, "fcvt.q.w">,
+  Sched<[WriteFCvtI32ToF128, ReadFCvtI32ToF128]>;
+
+  let mayRaiseFPException = 0 in 
+  def

[clang] [llvm] [RISCV][MC] Add support for Q extension (PR #139369)

2025-05-10 Thread Craig Topper via cfe-commits


@@ -45,6 +45,13 @@ class RISCVReg64
   let SubRegIndices = [sub_32];
 }
 
+def sub_64 : SubRegIndex<64>;
+class RISCVReg128
+: RISCVRegWithSubRegshttps://github.com/llvm/llvm-project/pull/139369
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [RISCV][MC] Add support for Q extension (PR #139369)

2025-05-10 Thread Craig Topper via cfe-commits


@@ -0,0 +1,168 @@
+//===-- RISCVInstrInfoF.td - RISC-V 'Q' instructions ---*- tablegen 
-*-===//

topperc wrote:

File name needs to be updated

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


[clang] [llvm] [RISCV][MC] Add support for Q extension (PR #139369)

2025-05-10 Thread Craig Topper via cfe-commits


@@ -0,0 +1,168 @@
+//===-- RISCVInstrInfoF.td - RISC-V 'Q' instructions ---*- tablegen 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file describes the RISC-V instructions from the standard 'Q',
+// Quad-Precision Floating-Point instruction set extension.
+//
+//===--===//
+
+//===--===//
+// Operand and SDNode transformation definitions.
+//===--===//
+
+def QExt : ExtInfo<"", "", [HasStdExtQ], f128, FPR128, FPR32, FPR64, ?, 
FPR128>;
+
+defvar QExts = [QExt];
+defvar QExtsRV64 = [QExt];
+
+//===--===//
+// Instructions
+//===--===//
+
+let Predicates = [HasStdExtQ] in {
+  def FLQ : FPLoad_r<0b100, "flq", FPR128, WriteFLD128>;
+
+  // Operands for stores are in the order srcreg, base, offset rather than
+  // reflecting the order these fields are specified in the instruction
+  // encoding.
+  def FSQ : FPStore_r<0b100, "fsq", FPR128, WriteFST128>;
+}
+
+foreach Ext = QExts in {
+  let SchedRW = [WriteFMA128, ReadFMA128, ReadFMA128, ReadFMA128Addend] in {
+defm FMADD_Q : FPFMA_rrr_frm_m;
+defm FMSUB_Q : FPFMA_rrr_frm_m;
+defm FNMSUB_Q : FPFMA_rrr_frm_m;
+defm FNMADD_Q : FPFMA_rrr_frm_m;
+  }
+
+  let SchedRW = [WriteFAdd128, ReadFAdd128, ReadFAdd128] in {
+defm FADD_Q : FPALU_rr_frm_m<0b011, "fadd.q", Ext>;
+defm FSUB_Q : FPALU_rr_frm_m<0b111, "fsub.q", Ext>;
+  }
+
+  let SchedRW = [WriteFMul128, ReadFMul128, ReadFMul128] in 
+  defm FMUL_Q : FPALU_rr_frm_m<0b0001011, "fmul.q", Ext>;
+
+  let SchedRW = [WriteFDiv128, ReadFDiv128, ReadFDiv128] in 
+  defm FDIV_Q : FPALU_rr_frm_m<0b000, "fdiv.q", Ext>;
+
+  defm FSQRT_Q : FPUnaryOp_r_frm_m<0b010, 0b0, Ext, Ext.PrimaryTy,
+   Ext.PrimaryTy, "fsqrt.q">,
+ Sched<[WriteFSqrt128, ReadFSqrt128]>;
+
+  let SchedRW = [WriteFSGNJ128, ReadFSGNJ128, ReadFSGNJ128],
+  mayRaiseFPException = 0 in {
+defm FSGNJ_Q : FPALU_rr_m<0b0010011, 0b000, "fsgnj.q", Ext>;
+defm FSGNJN_Q : FPALU_rr_m<0b0010011, 0b001, "fsgnjn.q", Ext>;
+defm FSGNJX_Q : FPALU_rr_m<0b0010011, 0b010, "fsgnjx.q", Ext>;
+  }
+
+  let SchedRW = [WriteFMinMax128, ReadFMinMax128, ReadFMinMax128] in {
+defm FMIN_Q : FPALU_rr_m<0b0010111, 0b000, "fmin.q", Ext, Commutable = 1>;
+defm FMAX_Q : FPALU_rr_m<0b0010111, 0b001, "fmax.q", Ext, Commutable = 1>;
+  }
+
+  defm FCVT_S_Q : FPUnaryOp_r_frm_m<0b010, 0b00011, Ext, Ext.F32Ty,
+Ext.PrimaryTy, "fcvt.s.q">,
+  Sched<[WriteFCvtF128ToF32, ReadFCvtF128ToF32]>;
+
+  defm FCVT_Q_S : FPUnaryOp_r_frmlegacy_m<0b0100011, 0b0, Ext,
+  Ext.PrimaryTy, Ext.F32Ty, 
"fcvt.q.s">,
+  Sched<[WriteFCvtF32ToF128, ReadFCvtF32ToF128]>;
+
+  defm FCVT_D_Q : FPUnaryOp_r_frm_m<0b011, 0b00011, Ext, Ext.F64Ty,
+Ext.PrimaryTy, "fcvt.d.q">,
+  Sched<[WriteFCvtF128ToF64, ReadFCvtF128ToF64]>;
+
+  defm FCVT_Q_D : FPUnaryOp_r_frmlegacy_m<0b0100011, 0b1, Ext,
+  Ext.PrimaryTy, Ext.F64Ty, 
"fcvt.q.d">,
+  Sched<[WriteFCvtF64ToF128, ReadFCvtF64ToF128]>;
+
+  let SchedRW = [WriteFCmp128, ReadFCmp128, ReadFCmp128] in {
+defm FEQ_Q : FPCmp_rr_m<0b1010011, 0b010, "feq.q", Ext, Commutable = 1>;
+defm FLT_Q : FPCmp_rr_m<0b1010011, 0b001, "flt.q", Ext>;
+defm FLE_Q : FPCmp_rr_m<0b1010011, 0b000, "fle.q", Ext>;
+  }
+
+  let mayRaiseFPException = 0 in 
+  defm FCLASS_Q : FPUnaryOp_r_m<0b1110011, 0b0, 0b001, Ext, GPR,
+Ext.PrimaryTy, "fclass.q">,
+  Sched<[WriteFClass128, ReadFClass128]>;
+
+  let IsSignExtendingOpW = 1 in 
+  defm FCVT_W_Q : FPUnaryOp_r_frm_m<0b1100011, 0b0, Ext, GPR,
+Ext.PrimaryTy, "fcvt.w.q">,
+  Sched<[WriteFCvtF128ToI32, ReadFCvtF128ToI32]>;
+
+  let IsSignExtendingOpW = 1 in 
+  defm FCVT_WU_Q : FPUnaryOp_r_frm_m<0b1100011, 0b1, Ext, GPR,
+ Ext.PrimaryTy, "fcvt.wu.q">,
+  Sched<[WriteFCvtF128ToI32, ReadFCvtF128ToI32]>;
+
+  let mayRaiseFPException = 0 in 
+  defm FCVT_Q_W : FPUnaryOp_r_frm_m<0b1101011, 0b0, Ext,

topperc wrote:

I think this should be `FPUnaryOp_r_frmlegacy_m`. No rounding is needed for 
this conversion.

https://github.com/llvm/llvm-project/pul

[clang] [clang][OpenMP] Add error for large expr in collapse clause (PR #138592)

2025-05-10 Thread Amr Hesham via cfe-commits


@@ -15901,6 +15901,13 @@ ExprResult 
SemaOpenMP::VerifyPositiveIntegerConstantInClause(
 << E->getSourceRange();
 return ExprError();
   }
+
+  if (!Result.isRepresentableByInt64()) {

AmrDeveloper wrote:

In our implementation, yes, because we const evaluate the value to APInt and it 
store the value in i64

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


[clang] [clang][OpenMP] Add error for large expr in collapse clause (PR #138592)

2025-05-10 Thread Amr Hesham via cfe-commits

https://github.com/AmrDeveloper updated 
https://github.com/llvm/llvm-project/pull/138592

>From 793bd974b779450a84c72d54237067ab56a59cdc Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Mon, 5 May 2025 23:01:02 +0200
Subject: [PATCH 1/5] [clang][OpenMP] Add error for large expr in collapse

---
 clang/docs/ReleaseNotes.rst  | 2 ++
 clang/include/clang/Basic/DiagnosticSemaKinds.td | 2 ++
 clang/lib/Sema/SemaOpenMP.cpp| 7 +++
 clang/test/OpenMP/simd_collapse_messages.cpp | 4 
 4 files changed, 15 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index e362ec595a3bb..fe4325051fef7 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -521,6 +521,8 @@ Improvements to Clang's diagnostics
 - Fixed a duplicate diagnostic when performing typo correction on function 
template
   calls with explicit template arguments. (#GH139226)
 
+- An error is now emitted when OpenMP ``collapse`` and ``ordered`` clauses has 
expression larger than 64 bit.
+
 Improvements to Clang's time-trace
 --
 
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index ca47cf62324f3..362fc291fd7a2 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -11526,6 +11526,8 @@ def note_omp_collapse_ordered_expr : Note<
   "as specified in %select{'collapse'|'ordered'|'collapse' and 'ordered'}0 
clause%select{||s}0">;
 def err_omp_negative_expression_in_clause : Error<
   "argument to '%0' clause must be a %select{non-negative|strictly positive}1 
integer value">;
+def err_omp_large_expression_in_clause : Error<
+  "argument to '%0' clause cannot have more than 64 bits size">;
 def err_omp_not_integral : Error<
   "expression must have integral or unscoped enumeration "
   "type, not %0">;
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 15d568fcb9cc4..986d3e2cf840a 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -15937,6 +15937,13 @@ ExprResult 
SemaOpenMP::VerifyPositiveIntegerConstantInClause(
 << E->getSourceRange();
 return ExprError();
   }
+
+  if (!Result.isRepresentableByInt64()) {
+Diag(E->getExprLoc(), diag::err_omp_large_expression_in_clause)
+<< getOpenMPClauseNameForDiag(CKind) << E->getSourceRange();
+return ExprError();
+  }
+
   if (CKind == OMPC_collapse && DSAStack->getAssociatedLoops() == 1)
 DSAStack->setAssociatedLoops(Result.getExtValue());
   else if (CKind == OMPC_ordered)
diff --git a/clang/test/OpenMP/simd_collapse_messages.cpp 
b/clang/test/OpenMP/simd_collapse_messages.cpp
index 1ce3bef3535ce..135b48eea739a 100644
--- a/clang/test/OpenMP/simd_collapse_messages.cpp
+++ b/clang/test/OpenMP/simd_collapse_messages.cpp
@@ -43,6 +43,10 @@ T tmain(T argc, S **argv) {
   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
   #pragma omp simd collapse (S) // expected-error {{'S' does not refer to a 
value}}
   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  #pragma omp for collapse (0x) // expected-error {{argument 
to 'collapse' clause cannot have more than 64 bits size}}
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  #pragma omp simd collapse (0x) // expected-error {{argument 
to 'collapse' clause cannot have more than 64 bits size}}
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
 #if __cplusplus <= 199711L
   // expected-error@+4 2 {{integral constant expression}} expected-note@+4 
0+{{constant expression}}
 #else

>From cae8f33914d9d8bfb3b477103c76fe67c0bc8346 Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Wed, 7 May 2025 21:50:46 +0200
Subject: [PATCH 2/5] Add more test cases

---
 clang/test/OpenMP/for_collapse_messages.cpp  | 2 ++
 clang/test/OpenMP/for_simd_collapse_messages.cpp | 2 ++
 clang/test/OpenMP/simd_collapse_messages.cpp | 2 --
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/clang/test/OpenMP/for_collapse_messages.cpp 
b/clang/test/OpenMP/for_collapse_messages.cpp
index 07630ffaaed95..aacf6cb34724a 100644
--- a/clang/test/OpenMP/for_collapse_messages.cpp
+++ b/clang/test/OpenMP/for_collapse_messages.cpp
@@ -49,6 +49,8 @@ T tmain(T argc, S **argv) {
   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
   #pragma omp for collapse (S) // expected-error {{'S' does not refer to a 
value}}
   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  #pragma omp for collapse (0x) // expected-error {{argument 
to 'collapse' clause cannot have more than 64 bits size}}
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
 #if __cplusplus <= 199711L
   // expected-error@+4 2 {{integral constant expression}} expected-note@+4 
0+{{co

[clang] [Driver] Fix _XOPEN_SOURCE definition on Solaris (PR #137141)

2025-05-10 Thread Tom Stellard via cfe-commits

tstellar wrote:

Was there a backport PR created for this change?

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


[clang] [clang][OpenMP] Add error for large expr in collapse clause (PR #138592)

2025-05-10 Thread Amr Hesham via cfe-commits

https://github.com/AmrDeveloper updated 
https://github.com/llvm/llvm-project/pull/138592

>From 793bd974b779450a84c72d54237067ab56a59cdc Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Mon, 5 May 2025 23:01:02 +0200
Subject: [PATCH 1/4] [clang][OpenMP] Add error for large expr in collapse

---
 clang/docs/ReleaseNotes.rst  | 2 ++
 clang/include/clang/Basic/DiagnosticSemaKinds.td | 2 ++
 clang/lib/Sema/SemaOpenMP.cpp| 7 +++
 clang/test/OpenMP/simd_collapse_messages.cpp | 4 
 4 files changed, 15 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index e362ec595a3bb..fe4325051fef7 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -521,6 +521,8 @@ Improvements to Clang's diagnostics
 - Fixed a duplicate diagnostic when performing typo correction on function 
template
   calls with explicit template arguments. (#GH139226)
 
+- An error is now emitted when OpenMP ``collapse`` and ``ordered`` clauses has 
expression larger than 64 bit.
+
 Improvements to Clang's time-trace
 --
 
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index ca47cf62324f3..362fc291fd7a2 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -11526,6 +11526,8 @@ def note_omp_collapse_ordered_expr : Note<
   "as specified in %select{'collapse'|'ordered'|'collapse' and 'ordered'}0 
clause%select{||s}0">;
 def err_omp_negative_expression_in_clause : Error<
   "argument to '%0' clause must be a %select{non-negative|strictly positive}1 
integer value">;
+def err_omp_large_expression_in_clause : Error<
+  "argument to '%0' clause cannot have more than 64 bits size">;
 def err_omp_not_integral : Error<
   "expression must have integral or unscoped enumeration "
   "type, not %0">;
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 15d568fcb9cc4..986d3e2cf840a 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -15937,6 +15937,13 @@ ExprResult 
SemaOpenMP::VerifyPositiveIntegerConstantInClause(
 << E->getSourceRange();
 return ExprError();
   }
+
+  if (!Result.isRepresentableByInt64()) {
+Diag(E->getExprLoc(), diag::err_omp_large_expression_in_clause)
+<< getOpenMPClauseNameForDiag(CKind) << E->getSourceRange();
+return ExprError();
+  }
+
   if (CKind == OMPC_collapse && DSAStack->getAssociatedLoops() == 1)
 DSAStack->setAssociatedLoops(Result.getExtValue());
   else if (CKind == OMPC_ordered)
diff --git a/clang/test/OpenMP/simd_collapse_messages.cpp 
b/clang/test/OpenMP/simd_collapse_messages.cpp
index 1ce3bef3535ce..135b48eea739a 100644
--- a/clang/test/OpenMP/simd_collapse_messages.cpp
+++ b/clang/test/OpenMP/simd_collapse_messages.cpp
@@ -43,6 +43,10 @@ T tmain(T argc, S **argv) {
   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
   #pragma omp simd collapse (S) // expected-error {{'S' does not refer to a 
value}}
   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  #pragma omp for collapse (0x) // expected-error {{argument 
to 'collapse' clause cannot have more than 64 bits size}}
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  #pragma omp simd collapse (0x) // expected-error {{argument 
to 'collapse' clause cannot have more than 64 bits size}}
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
 #if __cplusplus <= 199711L
   // expected-error@+4 2 {{integral constant expression}} expected-note@+4 
0+{{constant expression}}
 #else

>From cae8f33914d9d8bfb3b477103c76fe67c0bc8346 Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Wed, 7 May 2025 21:50:46 +0200
Subject: [PATCH 2/4] Add more test cases

---
 clang/test/OpenMP/for_collapse_messages.cpp  | 2 ++
 clang/test/OpenMP/for_simd_collapse_messages.cpp | 2 ++
 clang/test/OpenMP/simd_collapse_messages.cpp | 2 --
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/clang/test/OpenMP/for_collapse_messages.cpp 
b/clang/test/OpenMP/for_collapse_messages.cpp
index 07630ffaaed95..aacf6cb34724a 100644
--- a/clang/test/OpenMP/for_collapse_messages.cpp
+++ b/clang/test/OpenMP/for_collapse_messages.cpp
@@ -49,6 +49,8 @@ T tmain(T argc, S **argv) {
   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
   #pragma omp for collapse (S) // expected-error {{'S' does not refer to a 
value}}
   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  #pragma omp for collapse (0x) // expected-error {{argument 
to 'collapse' clause cannot have more than 64 bits size}}
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
 #if __cplusplus <= 199711L
   // expected-error@+4 2 {{integral constant expression}} expected-note@+4 
0+{{co

[clang] [llvm] [RISCV][MC] Add support for Q extension (PR #139369)

2025-05-10 Thread Craig Topper via cfe-commits


@@ -0,0 +1,168 @@
+//===-- RISCVInstrInfoF.td - RISC-V 'Q' instructions ---*- tablegen 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file describes the RISC-V instructions from the standard 'Q',
+// Quad-Precision Floating-Point instruction set extension.
+//
+//===--===//
+
+//===--===//
+// Operand and SDNode transformation definitions.
+//===--===//
+
+def QExt : ExtInfo<"", "", [HasStdExtQ], f128, FPR128, FPR32, FPR64, ?, 
FPR128>;
+
+defvar QExts = [QExt];
+defvar QExtsRV64 = [QExt];
+
+//===--===//
+// Instructions
+//===--===//
+
+let Predicates = [HasStdExtQ] in {
+  def FLQ : FPLoad_r<0b100, "flq", FPR128, WriteFLD128>;
+
+  // Operands for stores are in the order srcreg, base, offset rather than
+  // reflecting the order these fields are specified in the instruction
+  // encoding.
+  def FSQ : FPStore_r<0b100, "fsq", FPR128, WriteFST128>;
+}
+
+foreach Ext = QExts in {
+  let SchedRW = [WriteFMA128, ReadFMA128, ReadFMA128, ReadFMA128Addend] in {
+defm FMADD_Q : FPFMA_rrr_frm_m;
+defm FMSUB_Q : FPFMA_rrr_frm_m;
+defm FNMSUB_Q : FPFMA_rrr_frm_m;
+defm FNMADD_Q : FPFMA_rrr_frm_m;
+  }
+
+  let SchedRW = [WriteFAdd128, ReadFAdd128, ReadFAdd128] in {
+defm FADD_Q : FPALU_rr_frm_m<0b011, "fadd.q", Ext>;
+defm FSUB_Q : FPALU_rr_frm_m<0b111, "fsub.q", Ext>;
+  }
+
+  let SchedRW = [WriteFMul128, ReadFMul128, ReadFMul128] in 
+  defm FMUL_Q : FPALU_rr_frm_m<0b0001011, "fmul.q", Ext>;
+
+  let SchedRW = [WriteFDiv128, ReadFDiv128, ReadFDiv128] in 
+  defm FDIV_Q : FPALU_rr_frm_m<0b000, "fdiv.q", Ext>;
+
+  defm FSQRT_Q : FPUnaryOp_r_frm_m<0b010, 0b0, Ext, Ext.PrimaryTy,
+   Ext.PrimaryTy, "fsqrt.q">,
+ Sched<[WriteFSqrt128, ReadFSqrt128]>;
+
+  let SchedRW = [WriteFSGNJ128, ReadFSGNJ128, ReadFSGNJ128],
+  mayRaiseFPException = 0 in {
+defm FSGNJ_Q : FPALU_rr_m<0b0010011, 0b000, "fsgnj.q", Ext>;
+defm FSGNJN_Q : FPALU_rr_m<0b0010011, 0b001, "fsgnjn.q", Ext>;
+defm FSGNJX_Q : FPALU_rr_m<0b0010011, 0b010, "fsgnjx.q", Ext>;
+  }
+
+  let SchedRW = [WriteFMinMax128, ReadFMinMax128, ReadFMinMax128] in {
+defm FMIN_Q : FPALU_rr_m<0b0010111, 0b000, "fmin.q", Ext, Commutable = 1>;
+defm FMAX_Q : FPALU_rr_m<0b0010111, 0b001, "fmax.q", Ext, Commutable = 1>;
+  }
+
+  defm FCVT_S_Q : FPUnaryOp_r_frm_m<0b010, 0b00011, Ext, Ext.F32Ty,
+Ext.PrimaryTy, "fcvt.s.q">,
+  Sched<[WriteFCvtF128ToF32, ReadFCvtF128ToF32]>;
+
+  defm FCVT_Q_S : FPUnaryOp_r_frmlegacy_m<0b0100011, 0b0, Ext,
+  Ext.PrimaryTy, Ext.F32Ty, 
"fcvt.q.s">,
+  Sched<[WriteFCvtF32ToF128, ReadFCvtF32ToF128]>;
+
+  defm FCVT_D_Q : FPUnaryOp_r_frm_m<0b011, 0b00011, Ext, Ext.F64Ty,
+Ext.PrimaryTy, "fcvt.d.q">,
+  Sched<[WriteFCvtF128ToF64, ReadFCvtF128ToF64]>;
+
+  defm FCVT_Q_D : FPUnaryOp_r_frmlegacy_m<0b0100011, 0b1, Ext,
+  Ext.PrimaryTy, Ext.F64Ty, 
"fcvt.q.d">,
+  Sched<[WriteFCvtF64ToF128, ReadFCvtF64ToF128]>;
+
+  let SchedRW = [WriteFCmp128, ReadFCmp128, ReadFCmp128] in {
+defm FEQ_Q : FPCmp_rr_m<0b1010011, 0b010, "feq.q", Ext, Commutable = 1>;
+defm FLT_Q : FPCmp_rr_m<0b1010011, 0b001, "flt.q", Ext>;
+defm FLE_Q : FPCmp_rr_m<0b1010011, 0b000, "fle.q", Ext>;
+  }
+
+  let mayRaiseFPException = 0 in 
+  defm FCLASS_Q : FPUnaryOp_r_m<0b1110011, 0b0, 0b001, Ext, GPR,
+Ext.PrimaryTy, "fclass.q">,
+  Sched<[WriteFClass128, ReadFClass128]>;
+
+  let IsSignExtendingOpW = 1 in 
+  defm FCVT_W_Q : FPUnaryOp_r_frm_m<0b1100011, 0b0, Ext, GPR,
+Ext.PrimaryTy, "fcvt.w.q">,
+  Sched<[WriteFCvtF128ToI32, ReadFCvtF128ToI32]>;
+
+  let IsSignExtendingOpW = 1 in 
+  defm FCVT_WU_Q : FPUnaryOp_r_frm_m<0b1100011, 0b1, Ext, GPR,
+ Ext.PrimaryTy, "fcvt.wu.q">,
+  Sched<[WriteFCvtF128ToI32, ReadFCvtF128ToI32]>;
+
+  let mayRaiseFPException = 0 in 
+  defm FCVT_Q_W : FPUnaryOp_r_frm_m<0b1101011, 0b0, Ext,
+Ext.PrimaryTy, GPR, "fcvt.q.w">,
+  Sched<[WriteFCvtI32ToF128, ReadFCvtI32ToF128]>;
+
+  let mayRaiseFPException = 0 in 
+  def

[clang] [llvm] [RISCV][MC] Add support for Q extension (PR #139369)

2025-05-10 Thread Craig Topper via cfe-commits


@@ -0,0 +1,168 @@
+//===-- RISCVInstrInfoF.td - RISC-V 'Q' instructions ---*- tablegen 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file describes the RISC-V instructions from the standard 'Q',
+// Quad-Precision Floating-Point instruction set extension.
+//
+//===--===//
+
+//===--===//
+// Operand and SDNode transformation definitions.
+//===--===//
+
+def QExt : ExtInfo<"", "", [HasStdExtQ], f128, FPR128, FPR32, FPR64, ?, 
FPR128>;
+
+defvar QExts = [QExt];
+defvar QExtsRV64 = [QExt];
+
+//===--===//
+// Instructions
+//===--===//
+
+let Predicates = [HasStdExtQ] in {
+  def FLQ : FPLoad_r<0b100, "flq", FPR128, WriteFLD128>;
+
+  // Operands for stores are in the order srcreg, base, offset rather than
+  // reflecting the order these fields are specified in the instruction
+  // encoding.
+  def FSQ : FPStore_r<0b100, "fsq", FPR128, WriteFST128>;
+}
+
+foreach Ext = QExts in {
+  let SchedRW = [WriteFMA128, ReadFMA128, ReadFMA128, ReadFMA128Addend] in {
+defm FMADD_Q : FPFMA_rrr_frm_m;
+defm FMSUB_Q : FPFMA_rrr_frm_m;
+defm FNMSUB_Q : FPFMA_rrr_frm_m;
+defm FNMADD_Q : FPFMA_rrr_frm_m;
+  }
+
+  let SchedRW = [WriteFAdd128, ReadFAdd128, ReadFAdd128] in {
+defm FADD_Q : FPALU_rr_frm_m<0b011, "fadd.q", Ext>;
+defm FSUB_Q : FPALU_rr_frm_m<0b111, "fsub.q", Ext>;
+  }
+
+  let SchedRW = [WriteFMul128, ReadFMul128, ReadFMul128] in 
+  defm FMUL_Q : FPALU_rr_frm_m<0b0001011, "fmul.q", Ext>;
+
+  let SchedRW = [WriteFDiv128, ReadFDiv128, ReadFDiv128] in 
+  defm FDIV_Q : FPALU_rr_frm_m<0b000, "fdiv.q", Ext>;
+
+  defm FSQRT_Q : FPUnaryOp_r_frm_m<0b010, 0b0, Ext, Ext.PrimaryTy,
+   Ext.PrimaryTy, "fsqrt.q">,
+ Sched<[WriteFSqrt128, ReadFSqrt128]>;
+
+  let SchedRW = [WriteFSGNJ128, ReadFSGNJ128, ReadFSGNJ128],
+  mayRaiseFPException = 0 in {
+defm FSGNJ_Q : FPALU_rr_m<0b0010011, 0b000, "fsgnj.q", Ext>;
+defm FSGNJN_Q : FPALU_rr_m<0b0010011, 0b001, "fsgnjn.q", Ext>;
+defm FSGNJX_Q : FPALU_rr_m<0b0010011, 0b010, "fsgnjx.q", Ext>;
+  }
+
+  let SchedRW = [WriteFMinMax128, ReadFMinMax128, ReadFMinMax128] in {
+defm FMIN_Q : FPALU_rr_m<0b0010111, 0b000, "fmin.q", Ext, Commutable = 1>;
+defm FMAX_Q : FPALU_rr_m<0b0010111, 0b001, "fmax.q", Ext, Commutable = 1>;
+  }
+
+  defm FCVT_S_Q : FPUnaryOp_r_frm_m<0b010, 0b00011, Ext, Ext.F32Ty,
+Ext.PrimaryTy, "fcvt.s.q">,
+  Sched<[WriteFCvtF128ToF32, ReadFCvtF128ToF32]>;
+
+  defm FCVT_Q_S : FPUnaryOp_r_frmlegacy_m<0b0100011, 0b0, Ext,
+  Ext.PrimaryTy, Ext.F32Ty, 
"fcvt.q.s">,
+  Sched<[WriteFCvtF32ToF128, ReadFCvtF32ToF128]>;
+
+  defm FCVT_D_Q : FPUnaryOp_r_frm_m<0b011, 0b00011, Ext, Ext.F64Ty,
+Ext.PrimaryTy, "fcvt.d.q">,
+  Sched<[WriteFCvtF128ToF64, ReadFCvtF128ToF64]>;
+
+  defm FCVT_Q_D : FPUnaryOp_r_frmlegacy_m<0b0100011, 0b1, Ext,
+  Ext.PrimaryTy, Ext.F64Ty, 
"fcvt.q.d">,
+  Sched<[WriteFCvtF64ToF128, ReadFCvtF64ToF128]>;
+
+  let SchedRW = [WriteFCmp128, ReadFCmp128, ReadFCmp128] in {
+defm FEQ_Q : FPCmp_rr_m<0b1010011, 0b010, "feq.q", Ext, Commutable = 1>;
+defm FLT_Q : FPCmp_rr_m<0b1010011, 0b001, "flt.q", Ext>;
+defm FLE_Q : FPCmp_rr_m<0b1010011, 0b000, "fle.q", Ext>;
+  }
+
+  let mayRaiseFPException = 0 in 
+  defm FCLASS_Q : FPUnaryOp_r_m<0b1110011, 0b0, 0b001, Ext, GPR,
+Ext.PrimaryTy, "fclass.q">,
+  Sched<[WriteFClass128, ReadFClass128]>;
+
+  let IsSignExtendingOpW = 1 in 
+  defm FCVT_W_Q : FPUnaryOp_r_frm_m<0b1100011, 0b0, Ext, GPR,
+Ext.PrimaryTy, "fcvt.w.q">,
+  Sched<[WriteFCvtF128ToI32, ReadFCvtF128ToI32]>;
+
+  let IsSignExtendingOpW = 1 in 
+  defm FCVT_WU_Q : FPUnaryOp_r_frm_m<0b1100011, 0b1, Ext, GPR,
+ Ext.PrimaryTy, "fcvt.wu.q">,
+  Sched<[WriteFCvtF128ToI32, ReadFCvtF128ToI32]>;
+
+  let mayRaiseFPException = 0 in 
+  defm FCVT_Q_W : FPUnaryOp_r_frm_m<0b1101011, 0b0, Ext,
+Ext.PrimaryTy, GPR, "fcvt.q.w">,
+  Sched<[WriteFCvtI32ToF128, ReadFCvtI32ToF128]>;
+
+  let mayRaiseFPException = 0 in 
+  def

[clang-tools-extra] [modularize] Use default member initialization for Location (NFC) (PR #139384)

2025-05-10 Thread Kazu Hirata via cfe-commits

https://github.com/kazutakahirata created 
https://github.com/llvm/llvm-project/pull/139384

None

>From bd95ea0bfe040a615593a1f1847eb84fcbef073e Mon Sep 17 00:00:00 2001
From: Kazu Hirata 
Date: Sat, 10 May 2025 08:20:08 -0700
Subject: [PATCH] [modularize] Use default member initialization for Location
 (NFC)

---
 clang-tools-extra/modularize/Modularize.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/clang-tools-extra/modularize/Modularize.cpp 
b/clang-tools-extra/modularize/Modularize.cpp
index 4bb3bae0503ac..734ee251c4f0b 100644
--- a/clang-tools-extra/modularize/Modularize.cpp
+++ b/clang-tools-extra/modularize/Modularize.cpp
@@ -381,11 +381,11 @@ getModularizeArgumentsAdjuster(DependencyMap 
&Dependencies) {
 // somewhere into Tooling/ in mainline
 struct Location {
   OptionalFileEntryRef File;
-  unsigned Line, Column;
+  unsigned Line = 0, Column = 0;
 
-  Location() : File(), Line(), Column() {}
+  Location() = default;
 
-  Location(SourceManager &SM, SourceLocation Loc) : File(), Line(), Column() {
+  Location(SourceManager &SM, SourceLocation Loc) {
 Loc = SM.getExpansionLoc(Loc);
 if (Loc.isInvalid())
   return;

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


[clang-tools-extra] [modularize] Use default member initialization for Location (NFC) (PR #139384)

2025-05-10 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-tools-extra

Author: Kazu Hirata (kazutakahirata)


Changes



---
Full diff: https://github.com/llvm/llvm-project/pull/139384.diff


1 Files Affected:

- (modified) clang-tools-extra/modularize/Modularize.cpp (+3-3) 


``diff
diff --git a/clang-tools-extra/modularize/Modularize.cpp 
b/clang-tools-extra/modularize/Modularize.cpp
index 4bb3bae0503ac..734ee251c4f0b 100644
--- a/clang-tools-extra/modularize/Modularize.cpp
+++ b/clang-tools-extra/modularize/Modularize.cpp
@@ -381,11 +381,11 @@ getModularizeArgumentsAdjuster(DependencyMap 
&Dependencies) {
 // somewhere into Tooling/ in mainline
 struct Location {
   OptionalFileEntryRef File;
-  unsigned Line, Column;
+  unsigned Line = 0, Column = 0;
 
-  Location() : File(), Line(), Column() {}
+  Location() = default;
 
-  Location(SourceManager &SM, SourceLocation Loc) : File(), Line(), Column() {
+  Location(SourceManager &SM, SourceLocation Loc) {
 Loc = SM.getExpansionLoc(Loc);
 if (Loc.isInvalid())
   return;

``




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


[clang] [llvm] [NVPTX] use untyped loads and stores where ever possible (PR #137698)

2025-05-10 Thread Alex MacLean via cfe-commits

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


[clang-tools-extra] [clang-tools-extra] Remove unused local variables (NFC) (PR #139382)

2025-05-10 Thread Nikita Popov via cfe-commits

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


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


[clang] [NFC][Clang][CodeGen] Remove vestigial assertion (PR #127528)

2025-05-10 Thread Tom Stellard via cfe-commits

tstellar wrote:

@jhuber6 Was the follow-up for this backported too?

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


[clang-tools-extra] 4b6762b - [clang-tools-extra] Remove unused local variables (NFC) (#139382)

2025-05-10 Thread via cfe-commits

Author: Kazu Hirata
Date: 2025-05-10T09:30:54-07:00
New Revision: 4b6762b0d489c65aa8dadfa27f104b76b2b20b76

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

LOG: [clang-tools-extra] Remove unused local variables (NFC) (#139382)

Added: 


Modified: 
clang-tools-extra/clangd/DumpAST.cpp
clang-tools-extra/clangd/unittests/SerializationTests.cpp
clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
clang-tools-extra/modularize/Modularize.cpp
clang-tools-extra/modularize/PreprocessorTracker.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/DumpAST.cpp 
b/clang-tools-extra/clangd/DumpAST.cpp
index 584bb1f088380..8f24477ecd3de 100644
--- a/clang-tools-extra/clangd/DumpAST.cpp
+++ b/clang-tools-extra/clangd/DumpAST.cpp
@@ -124,7 +124,6 @@ class DumpVisitor : public RecursiveASTVisitor 
{
 return Result;
   }
   std::string getKind(const TypeLoc &TL) {
-std::string Result;
 if (TL.getTypeLocClass() == TypeLoc::Qualified)
   return "Qualified";
 return TL.getType()->getTypeClassName();

diff  --git a/clang-tools-extra/clangd/unittests/SerializationTests.cpp 
b/clang-tools-extra/clangd/unittests/SerializationTests.cpp
index 2a7a6c36d3d17..d18ae478c1653 100644
--- a/clang-tools-extra/clangd/unittests/SerializationTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SerializationTests.cpp
@@ -433,7 +433,6 @@ TEST(SerializationTest, NoCrashOnBadStringTableSize) {
   std::string CorruptStri =
   (llvm::fromHex("") + Stri->Data.drop_front(4)).str();
   Stri->Data = CorruptStri;
-  std::string FileDigest = llvm::fromHex("EED8F5EAF25C453C");
 
   // Try to crash rather than hang on large allocation.
   ScopedMemoryLimit MemLimit(1000 * 1024 * 1024); // 1GB

diff  --git a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp 
b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
index 33490de9b0f6c..9431211b03e71 100644
--- a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
+++ b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
@@ -344,7 +344,6 @@ mapInputsToAbsPaths(clang::tooling::CompilationDatabase 
&CDB,
 }
 for (const auto &Cmd : Cmds) {
   llvm::SmallString<256> CDBPath(Cmd.Filename);
-  std::string Directory(Cmd.Directory);
   llvm::sys::fs::make_absolute(Cmd.Directory, CDBPath);
   CDBToAbsPaths[std::string(CDBPath)] = std::string(AbsPath);
 }

diff  --git a/clang-tools-extra/modularize/Modularize.cpp 
b/clang-tools-extra/modularize/Modularize.cpp
index 4bb3bae0503ac..38979cb4d6911 100644
--- a/clang-tools-extra/modularize/Modularize.cpp
+++ b/clang-tools-extra/modularize/Modularize.cpp
@@ -360,8 +360,6 @@ getModularizeArgumentsAdjuster(DependencyMap &Dependencies) 
{
 if (int Count = FileDependents.size()) {
   for (int Index = 0; Index < Count; ++Index) {
 NewArgs.push_back("-include");
-std::string File(std::string("\"") + FileDependents[Index] +
- std::string("\""));
 NewArgs.push_back(FileDependents[Index]);
   }
 }

diff  --git a/clang-tools-extra/modularize/PreprocessorTracker.cpp 
b/clang-tools-extra/modularize/PreprocessorTracker.cpp
index 85e3aab041e49..0c030f1112204 100644
--- a/clang-tools-extra/modularize/PreprocessorTracker.cpp
+++ b/clang-tools-extra/modularize/PreprocessorTracker.cpp
@@ -381,7 +381,6 @@ static std::string 
getMacroUnexpandedString(clang::SourceRange Range,
   clang::SourceLocation BeginLoc(Range.getBegin());
   const char *BeginPtr = PP.getSourceManager().getCharacterData(BeginLoc);
   size_t Length;
-  std::string Unexpanded;
   if (MI->isFunctionLike()) {
 clang::SourceLocation EndLoc(Range.getEnd());
 const char *EndPtr = PP.getSourceManager().getCharacterData(EndLoc) + 1;
@@ -1328,7 +1327,6 @@ void PreprocessorCallbacks::Defined(const clang::Token 
&MacroNameTok,
   clang::SourceLocation Loc(Range.getBegin());
   clang::IdentifierInfo *II = MacroNameTok.getIdentifierInfo();
   const clang::MacroInfo *MI = MD.getMacroInfo();
-  std::string MacroName = II->getName().str();
   std::string Unexpanded(getSourceString(PP, Range));
   PPTracker.addMacroExpansionInstance(
   PP, PPTracker.getCurrentHeaderHandle(), Loc,



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


[clang-tools-extra] [clang-tools-extra] Remove unused local variables (NFC) (PR #139382)

2025-05-10 Thread Kazu Hirata via cfe-commits

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


[clang] [Clang] Demote mixed enumeration arithmetic error to a warning (PR #131811)

2025-05-10 Thread Tom Stellard via cfe-commits

tstellar wrote:

@cor3ntin Were you able to manually create a backport PR for this?

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


[clang] [clang][analysis] Fix flaky clang/test/Analysis/live-stmts.cpp test (2nd attempt) (PR #127406)

2025-05-10 Thread Tom Stellard via cfe-commits

tstellar wrote:

Is there interest in backporting this to the release branch?  If so, can 
someone manually create a PR?

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


[clang] [Clang] Don't ditch typo-corrected lookup result (PR #139374)

2025-05-10 Thread Younan Zhang via cfe-commits

https://github.com/zyn0217 created 
https://github.com/llvm/llvm-project/pull/139374

For a member function call like 'foo.bar()', there are two typo-correction 
points after parsing the dot. The first occurs in 
ParseOptionalCXXScopeSpecifier, which tries to annotate the template name 
following any scope specifiers.

If the template name bar is not found within 'foo', the parser was previously 
instructed to drop any function templates found outside of the scope. This was 
intended to prevent ambiguity in expressions like 'foo->bar < 7', as explained 
in commit 50a3cddd. However, it's unnecessary to discard typo-corrected results 
that were strictly resolved within the scope 'foo'.

We won't perform a second typo-correction in ParseUnqualifiedId after the name 
being annotated.

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

>From 1e359714374418bf51e93d54169557c29bddf7c6 Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Sat, 10 May 2025 18:59:03 +0800
Subject: [PATCH] [Clang] Don't ditch typo-corrected lookup result

For a member function call like 'foo.bar()', there are two
typo-correction points after parsing the dot. The first occurs in
ParseOptionalCXXScopeSpecifier, which tries to annotate the template
name following any scope specifiers.

If the template name bar is not found within 'foo', the parser was
previously instructed to drop any function templates found outside of
the scope. This was intended to prevent ambiguity in expressions
like 'foo->bar < 7', as explained in commit 50a3cddd. However, it's
unnecessary to discard typo-corrected results that were strictly
resolved within the scope 'foo'.

We won't perform a second typo-correction in ParseUnqualifiedId after
the name being annotated.
---
 clang/docs/ReleaseNotes.rst |  5 -
 clang/lib/Sema/SemaTemplate.cpp |  3 +++
 .../basic/basic.lookup/basic.lookup.classref/p1.cpp | 13 +
 3 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 1d0896f585fb4..234c28a143cf1 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -517,7 +517,10 @@ Improvements to Clang's diagnostics
 
 - Improved the ``-Wtautological-overlap-compare`` diagnostics to warn about 
overlapping and non-overlapping ranges involving character literals and 
floating-point literals. 
   The warning message for non-overlapping cases has also been improved 
(#GH13473).
-  
+
+- Fixed a duplicate diagnostic when performing typo correction on function 
template
+  calls with explicit template arguments. Fixes #GH139226.
+
 Improvements to Clang's time-trace
 --
 
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 2ba69c87d95e3..a18b545a5feea 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -523,6 +523,9 @@ bool Sema::LookupTemplateName(LookupResult &Found, Scope 
*S, CXXScopeSpec &SS,
   if (Found.isAmbiguous()) {
 Found.clear();
   } else if (!Found.empty()) {
+// Do not erase the typo-corrected result to avoid duplicating the typo
+// correction in future.
+AllowFunctionTemplatesInLookup = true;
 Found.setLookupName(Corrected.getCorrection());
 if (LookupCtx) {
   std::string CorrectedStr(Corrected.getAsString(getLangOpts()));
diff --git a/clang/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp 
b/clang/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp
index e3599db18350b..3633ef1c293e2 100644
--- a/clang/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp
+++ b/clang/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp
@@ -98,3 +98,16 @@ namespace PR11856 {
 }
   }
 }
+
+namespace GH139226 {
+
+struct Foo {
+  template  void LookupWithID(); // expected-note {{declared here}}
+};
+
+void test(Foo &f) {
+  f.LookupWithId();
+  // expected-error@-1 {{did you mean 'LookupWithID'}}
+}
+
+}

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


[clang] [Clang] Don't ditch typo-corrected lookup result (PR #139374)

2025-05-10 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Younan Zhang (zyn0217)


Changes

For a member function call like 'foo.bar()', there are two 
typo-correction points after parsing the dot. The first occurs in 
ParseOptionalCXXScopeSpecifier, which tries to annotate the template name 
following any scope specifiers.

If the template name bar is not found within 'foo', the parser was previously 
instructed to drop any function templates found outside of the scope. This was 
intended to prevent ambiguity in expressions like 'foo->bar < 7', as 
explained in commit 50a3cddd. However, it's unnecessary to discard 
typo-corrected results that were strictly resolved within the scope 'foo'.

We won't perform a second typo-correction in ParseUnqualifiedId after the name 
being annotated.

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

---
Full diff: https://github.com/llvm/llvm-project/pull/139374.diff


3 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+4-1) 
- (modified) clang/lib/Sema/SemaTemplate.cpp (+3) 
- (modified) clang/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp 
(+13) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 1d0896f585fb4..234c28a143cf1 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -517,7 +517,10 @@ Improvements to Clang's diagnostics
 
 - Improved the ``-Wtautological-overlap-compare`` diagnostics to warn about 
overlapping and non-overlapping ranges involving character literals and 
floating-point literals. 
   The warning message for non-overlapping cases has also been improved 
(#GH13473).
-  
+
+- Fixed a duplicate diagnostic when performing typo correction on function 
template
+  calls with explicit template arguments. Fixes #GH139226.
+
 Improvements to Clang's time-trace
 --
 
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 2ba69c87d95e3..a18b545a5feea 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -523,6 +523,9 @@ bool Sema::LookupTemplateName(LookupResult &Found, Scope 
*S, CXXScopeSpec &SS,
   if (Found.isAmbiguous()) {
 Found.clear();
   } else if (!Found.empty()) {
+// Do not erase the typo-corrected result to avoid duplicating the typo
+// correction in future.
+AllowFunctionTemplatesInLookup = true;
 Found.setLookupName(Corrected.getCorrection());
 if (LookupCtx) {
   std::string CorrectedStr(Corrected.getAsString(getLangOpts()));
diff --git a/clang/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp 
b/clang/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp
index e3599db18350b..3633ef1c293e2 100644
--- a/clang/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp
+++ b/clang/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp
@@ -98,3 +98,16 @@ namespace PR11856 {
 }
   }
 }
+
+namespace GH139226 {
+
+struct Foo {
+  template  void LookupWithID(); // expected-note {{declared here}}
+};
+
+void test(Foo &f) {
+  f.LookupWithId();
+  // expected-error@-1 {{did you mean 'LookupWithID'}}
+}
+
+}

``




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


[clang-tools-extra] [clangd] Add tweak to add pure virtual overrides (PR #139348)

2025-05-10 Thread Younan Zhang via cfe-commits

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


[clang-tools-extra] [clangd] Add tweak to add pure virtual overrides (PR #139348)

2025-05-10 Thread Younan Zhang via cfe-commits


@@ -0,0 +1,366 @@
+//===--- AddPureVirtualOverride.cpp --*- 
C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "refactor/Tweak.h"
+
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/DeclCXX.h"
+#include "clang/AST/Type.h"
+#include "clang/AST/TypeLoc.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Tooling/Core/Replacement.h"
+#include "llvm/ADT/DenseSet.h"
+#include "llvm/Support/FormatVariadic.h"
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+namespace clang {
+namespace clangd {
+namespace {
+
+class OverridePureVirtuals : public Tweak {
+public:
+  const char *id() const final; // defined by REGISTER_TWEAK.
+  bool prepare(const Selection &Sel) override;
+  Expected apply(const Selection &Sel) override;
+  std::string title() const override { return "Override pure virtual methods"; 
}
+  llvm::StringLiteral kind() const override {
+return CodeAction::REFACTOR_KIND;
+  }
+
+private:
+  // Stores the CXXRecordDecl of the class being modified.
+  const CXXRecordDecl *CurrentDecl = nullptr;
+  // Stores pure virtual methods that need overriding, grouped by their 
original
+  // access specifier.
+  std::map>
+  MissingMethodsByAccess;
+  // Stores the source locations of existing access specifiers in CurrentDecl.
+  std::map AccessSpecifierLocations;
+
+  // Helper function to gather information before applying the tweak.
+  void collectMissingPureVirtuals(const Selection &Sel);
+};
+
+REGISTER_TWEAK(OverridePureVirtuals)
+
+// Collects all unique, canonical pure virtual methods from a class and its
+// entire inheritance hierarchy. This function aims to find methods that 
*could*
+// make a derived class abstract if not implemented.
+std::vector
+getAllUniquePureVirtualsFromHierarchy(const CXXRecordDecl *Decl) {
+  std::vector Result;
+  llvm::DenseSet VisitedCanonicalMethods;
+  // We declare it as a std::function because we are going to call it
+  // recursively.
+  std::function Collect;
+
+  Collect = [&](const CXXRecordDecl *CurrentClass) {
+if (!CurrentClass) {
+  return;
+}
+const CXXRecordDecl *Def = CurrentClass->getDefinition();
+if (!Def) {
+  return;
+}
+
+for (const CXXMethodDecl *M : Def->methods()) {
+  // Add if its canonical declaration hasn't been processed yet.
+  // This ensures each distinct pure virtual method signature is collected
+  // once.
+  if (M->isPureVirtual() &&
+  VisitedCanonicalMethods.insert(M->getCanonicalDecl()).second) {
+Result.emplace_back(M); // Store the specific declaration encountered.
+  }
+}
+
+for (const auto &BaseSpec : Def->bases()) {
+  if (const CXXRecordDecl *BaseDef =
+  BaseSpec.getType()->getAsCXXRecordDecl()) {
+Collect(BaseDef); // Recursively collect from base classes.
+  }
+}
+  };
+
+  Collect(Decl);
+  return Result;
+}
+
+// Gets canonical declarations of methods already overridden or implemented in
+// class D.
+std::set
+getImplementedOrOverriddenCanonicals(const CXXRecordDecl *D) {
+  std::set ImplementedSet;
+  for (const CXXMethodDecl *M : D->methods()) {
+// If M provides an implementation for any virtual method it overrides.
+// A method is an "implementation" if it's virtual and not pure.
+// Or if it directly overrides a base method.
+for (const CXXMethodDecl *OverriddenM : M->overridden_methods()) {
+  ImplementedSet.insert(OverriddenM->getCanonicalDecl());
+}
+  }
+  return ImplementedSet;
+}
+
+// Get the location of every colon of the `AccessSpecifier`.
+std::map
+getSpecifierLocations(const CXXRecordDecl *D) {
+  std::map Locs;
+  for (auto *DeclNode : D->decls()) { // Changed to DeclNode to avoid ambiguity
+if (const auto *ASD = llvm::dyn_cast(DeclNode)) {
+  Locs[ASD->getAccess()] = ASD->getColonLoc();
+}
+  }
+  return Locs;
+}
+
+// Check if the current class has any pure virtual method to be implemented.
+bool OverridePureVirtuals::prepare(const Selection &Sel) {
+  const SelectionTree::Node *Node = Sel.ASTSelection.commonAncestor();
+  if (!Node) {
+return false;
+  }
+
+  // Make sure we have a definition.
+  CurrentDecl = Node->ASTNode.get();
+  if (!CurrentDecl || !CurrentDecl->getDefinition()) {
+return false;
+  }
+
+  // A class needs overrides if it's abstract itself, or derives from abstract
+  // bases and hasn't implemented all necessary methods. A simpler check: if it
+  // has any base that is abstract.
+  bool HasAbstractBase = false;
+  for (const auto &Base : CurrentDecl->bases()) {
+if (const CXXRecordDecl *BaseDecl = Base.getType()->getAsCXXRecordDecl()) {
+  if 

[clang-tools-extra] [clangd] Add tweak to add pure virtual overrides (PR #139348)

2025-05-10 Thread Younan Zhang via cfe-commits

https://github.com/zyn0217 commented:

Just a drive-by comment. Thanks for working on it

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


[clang] [Clang] Don't ditch typo-corrected lookup result (PR #139374)

2025-05-10 Thread via cfe-commits

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

Thanks

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


[clang] [Clang] Don't ditch typo-corrected lookup result (PR #139374)

2025-05-10 Thread via cfe-commits


@@ -523,6 +523,9 @@ bool Sema::LookupTemplateName(LookupResult &Found, Scope 
*S, CXXScopeSpec &SS,
   if (Found.isAmbiguous()) {
 Found.clear();
   } else if (!Found.empty()) {
+// Do not erase the typo-corrected result to avoid duplicating the typo
+// correction in future.

cor3ntin wrote:

```suggestion
// Do not erase the typo-corrected result to avoid duplicated 
diagnostics.
```

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


[clang] [Clang] Don't ditch typo-corrected lookup result (PR #139374)

2025-05-10 Thread via cfe-commits

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


[clang] [Clang] Don't ditch typo-corrected lookup result (PR #139374)

2025-05-10 Thread via cfe-commits


@@ -517,7 +517,10 @@ Improvements to Clang's diagnostics
 
 - Improved the ``-Wtautological-overlap-compare`` diagnostics to warn about 
overlapping and non-overlapping ranges involving character literals and 
floating-point literals. 
   The warning message for non-overlapping cases has also been improved 
(#GH13473).
-  
+
+- Fixed a duplicate diagnostic when performing typo correction on function 
template
+  calls with explicit template arguments. Fixes #GH139226.

cor3ntin wrote:

```suggestion
  calls with explicit template arguments. (#GH139226)
```

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


[clang] [Clang] Don't ditch typo-corrected lookup result (PR #139374)

2025-05-10 Thread Younan Zhang via cfe-commits

https://github.com/zyn0217 updated 
https://github.com/llvm/llvm-project/pull/139374

>From 1e359714374418bf51e93d54169557c29bddf7c6 Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Sat, 10 May 2025 18:59:03 +0800
Subject: [PATCH 1/2] [Clang] Don't ditch typo-corrected lookup result

For a member function call like 'foo.bar()', there are two
typo-correction points after parsing the dot. The first occurs in
ParseOptionalCXXScopeSpecifier, which tries to annotate the template
name following any scope specifiers.

If the template name bar is not found within 'foo', the parser was
previously instructed to drop any function templates found outside of
the scope. This was intended to prevent ambiguity in expressions
like 'foo->bar < 7', as explained in commit 50a3cddd. However, it's
unnecessary to discard typo-corrected results that were strictly
resolved within the scope 'foo'.

We won't perform a second typo-correction in ParseUnqualifiedId after
the name being annotated.
---
 clang/docs/ReleaseNotes.rst |  5 -
 clang/lib/Sema/SemaTemplate.cpp |  3 +++
 .../basic/basic.lookup/basic.lookup.classref/p1.cpp | 13 +
 3 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 1d0896f585fb4..234c28a143cf1 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -517,7 +517,10 @@ Improvements to Clang's diagnostics
 
 - Improved the ``-Wtautological-overlap-compare`` diagnostics to warn about 
overlapping and non-overlapping ranges involving character literals and 
floating-point literals. 
   The warning message for non-overlapping cases has also been improved 
(#GH13473).
-  
+
+- Fixed a duplicate diagnostic when performing typo correction on function 
template
+  calls with explicit template arguments. Fixes #GH139226.
+
 Improvements to Clang's time-trace
 --
 
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 2ba69c87d95e3..a18b545a5feea 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -523,6 +523,9 @@ bool Sema::LookupTemplateName(LookupResult &Found, Scope 
*S, CXXScopeSpec &SS,
   if (Found.isAmbiguous()) {
 Found.clear();
   } else if (!Found.empty()) {
+// Do not erase the typo-corrected result to avoid duplicating the typo
+// correction in future.
+AllowFunctionTemplatesInLookup = true;
 Found.setLookupName(Corrected.getCorrection());
 if (LookupCtx) {
   std::string CorrectedStr(Corrected.getAsString(getLangOpts()));
diff --git a/clang/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp 
b/clang/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp
index e3599db18350b..3633ef1c293e2 100644
--- a/clang/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp
+++ b/clang/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp
@@ -98,3 +98,16 @@ namespace PR11856 {
 }
   }
 }
+
+namespace GH139226 {
+
+struct Foo {
+  template  void LookupWithID(); // expected-note {{declared here}}
+};
+
+void test(Foo &f) {
+  f.LookupWithId();
+  // expected-error@-1 {{did you mean 'LookupWithID'}}
+}
+
+}

>From 70f57ea63bf80b9d18d8b7a1334f3042803ab386 Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Sat, 10 May 2025 19:54:40 +0800
Subject: [PATCH 2/2] Address feedback

---
 clang/docs/ReleaseNotes.rst | 2 +-
 clang/lib/Sema/SemaTemplate.cpp | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 234c28a143cf1..e362ec595a3bb 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -519,7 +519,7 @@ Improvements to Clang's diagnostics
   The warning message for non-overlapping cases has also been improved 
(#GH13473).
 
 - Fixed a duplicate diagnostic when performing typo correction on function 
template
-  calls with explicit template arguments. Fixes #GH139226.
+  calls with explicit template arguments. (#GH139226)
 
 Improvements to Clang's time-trace
 --
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index a18b545a5feea..7940340064eda 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -523,8 +523,8 @@ bool Sema::LookupTemplateName(LookupResult &Found, Scope 
*S, CXXScopeSpec &SS,
   if (Found.isAmbiguous()) {
 Found.clear();
   } else if (!Found.empty()) {
-// Do not erase the typo-corrected result to avoid duplicating the typo
-// correction in future.
+// Do not erase the typo-corrected result to avoid duplicated
+// diagnostics.
 AllowFunctionTemplatesInLookup = true;
 Found.setLookupName(Corrected.getCorrection());
 if (LookupCtx) {

___
cfe-commits mailing list
cfe-commi

[clang-tools-extra] [clangd] Add tweak to add pure virtual overrides (PR #139348)

2025-05-10 Thread Marco Maia via cfe-commits

https://github.com/marcogmaia updated 
https://github.com/llvm/llvm-project/pull/139348

>From 76503bd8f5618b710e2909d1303de5d34723 Mon Sep 17 00:00:00 2001
From: Marco Maia 
Date: Sat, 10 May 2025 00:48:39 -0300
Subject: [PATCH 1/2] [clangd] Add tweak to add pure virtual overrides

---
 .../clangd/refactor/tweaks/CMakeLists.txt |   3 +-
 .../refactor/tweaks/OverridePureVirtuals.cpp  | 366 
 .../clangd/unittests/CMakeLists.txt   |   1 +
 .../tweaks/OverridePureVirtualsTests.cpp  | 410 ++
 4 files changed, 779 insertions(+), 1 deletion(-)
 create mode 100644 
clang-tools-extra/clangd/refactor/tweaks/OverridePureVirtuals.cpp
 create mode 100644 
clang-tools-extra/clangd/unittests/tweaks/OverridePureVirtualsTests.cpp

diff --git a/clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt 
b/clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
index 59475b0dfd3d2..1d6e38088ad67 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
+++ b/clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
@@ -14,9 +14,9 @@ set(LLVM_LINK_COMPONENTS
 add_clang_library(clangDaemonTweaks OBJECT
   AddUsing.cpp
   AnnotateHighlightings.cpp
-  DumpAST.cpp
   DefineInline.cpp
   DefineOutline.cpp
+  DumpAST.cpp
   ExpandDeducedType.cpp
   ExpandMacro.cpp
   ExtractFunction.cpp
@@ -24,6 +24,7 @@ add_clang_library(clangDaemonTweaks OBJECT
   MemberwiseConstructor.cpp
   ObjCLocalizeStringLiteral.cpp
   ObjCMemberwiseInitializer.cpp
+  OverridePureVirtuals.cpp
   PopulateSwitch.cpp
   RawStringLiteral.cpp
   RemoveUsingNamespace.cpp
diff --git a/clang-tools-extra/clangd/refactor/tweaks/OverridePureVirtuals.cpp 
b/clang-tools-extra/clangd/refactor/tweaks/OverridePureVirtuals.cpp
new file mode 100644
index 0..b8880433fdd52
--- /dev/null
+++ b/clang-tools-extra/clangd/refactor/tweaks/OverridePureVirtuals.cpp
@@ -0,0 +1,366 @@
+//===--- AddPureVirtualOverride.cpp --*- 
C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "refactor/Tweak.h"
+
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/DeclCXX.h"
+#include "clang/AST/Type.h"
+#include "clang/AST/TypeLoc.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Tooling/Core/Replacement.h"
+#include "llvm/ADT/DenseSet.h"
+#include "llvm/Support/FormatVariadic.h"
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+namespace clang {
+namespace clangd {
+namespace {
+
+class OverridePureVirtuals : public Tweak {
+public:
+  const char *id() const final; // defined by REGISTER_TWEAK.
+  bool prepare(const Selection &Sel) override;
+  Expected apply(const Selection &Sel) override;
+  std::string title() const override { return "Override pure virtual methods"; 
}
+  llvm::StringLiteral kind() const override {
+return CodeAction::REFACTOR_KIND;
+  }
+
+private:
+  // Stores the CXXRecordDecl of the class being modified.
+  const CXXRecordDecl *CurrentDecl = nullptr;
+  // Stores pure virtual methods that need overriding, grouped by their 
original
+  // access specifier.
+  std::map>
+  MissingMethodsByAccess;
+  // Stores the source locations of existing access specifiers in CurrentDecl.
+  std::map AccessSpecifierLocations;
+
+  // Helper function to gather information before applying the tweak.
+  void collectMissingPureVirtuals(const Selection &Sel);
+};
+
+REGISTER_TWEAK(OverridePureVirtuals)
+
+// Collects all unique, canonical pure virtual methods from a class and its
+// entire inheritance hierarchy. This function aims to find methods that 
*could*
+// make a derived class abstract if not implemented.
+std::vector
+getAllUniquePureVirtualsFromHierarchy(const CXXRecordDecl *Decl) {
+  std::vector Result;
+  llvm::DenseSet VisitedCanonicalMethods;
+  // We declare it as a std::function because we are going to call it
+  // recursively.
+  std::function Collect;
+
+  Collect = [&](const CXXRecordDecl *CurrentClass) {
+if (!CurrentClass) {
+  return;
+}
+const CXXRecordDecl *Def = CurrentClass->getDefinition();
+if (!Def) {
+  return;
+}
+
+for (const CXXMethodDecl *M : Def->methods()) {
+  // Add if its canonical declaration hasn't been processed yet.
+  // This ensures each distinct pure virtual method signature is collected
+  // once.
+  if (M->isPureVirtual() &&
+  VisitedCanonicalMethods.insert(M->getCanonicalDecl()).second) {
+Result.emplace_back(M); // Store the specific declaration encountered.
+  }
+}
+
+for (const auto &BaseSpec : Def->bases()) {
+  if (const CXXRecordDecl *BaseDef =
+  BaseSpec.getType()->getAsCXXRecordDecl()) {
+Collect(BaseDef)

[clang-tools-extra] [clangd] Add tweak to add pure virtual overrides (PR #139348)

2025-05-10 Thread Marco Maia via cfe-commits


@@ -0,0 +1,366 @@
+//===--- AddPureVirtualOverride.cpp --*- 
C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "refactor/Tweak.h"
+
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/DeclCXX.h"
+#include "clang/AST/Type.h"
+#include "clang/AST/TypeLoc.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Tooling/Core/Replacement.h"
+#include "llvm/ADT/DenseSet.h"
+#include "llvm/Support/FormatVariadic.h"
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+namespace clang {
+namespace clangd {
+namespace {
+
+class OverridePureVirtuals : public Tweak {
+public:
+  const char *id() const final; // defined by REGISTER_TWEAK.
+  bool prepare(const Selection &Sel) override;
+  Expected apply(const Selection &Sel) override;
+  std::string title() const override { return "Override pure virtual methods"; 
}
+  llvm::StringLiteral kind() const override {
+return CodeAction::REFACTOR_KIND;
+  }
+
+private:
+  // Stores the CXXRecordDecl of the class being modified.
+  const CXXRecordDecl *CurrentDecl = nullptr;
+  // Stores pure virtual methods that need overriding, grouped by their 
original
+  // access specifier.
+  std::map>
+  MissingMethodsByAccess;
+  // Stores the source locations of existing access specifiers in CurrentDecl.
+  std::map AccessSpecifierLocations;
+
+  // Helper function to gather information before applying the tweak.
+  void collectMissingPureVirtuals(const Selection &Sel);
+};
+
+REGISTER_TWEAK(OverridePureVirtuals)
+
+// Collects all unique, canonical pure virtual methods from a class and its
+// entire inheritance hierarchy. This function aims to find methods that 
*could*
+// make a derived class abstract if not implemented.
+std::vector
+getAllUniquePureVirtualsFromHierarchy(const CXXRecordDecl *Decl) {
+  std::vector Result;
+  llvm::DenseSet VisitedCanonicalMethods;
+  // We declare it as a std::function because we are going to call it
+  // recursively.
+  std::function Collect;
+
+  Collect = [&](const CXXRecordDecl *CurrentClass) {
+if (!CurrentClass) {
+  return;
+}
+const CXXRecordDecl *Def = CurrentClass->getDefinition();
+if (!Def) {
+  return;
+}
+
+for (const CXXMethodDecl *M : Def->methods()) {
+  // Add if its canonical declaration hasn't been processed yet.
+  // This ensures each distinct pure virtual method signature is collected
+  // once.
+  if (M->isPureVirtual() &&
+  VisitedCanonicalMethods.insert(M->getCanonicalDecl()).second) {
+Result.emplace_back(M); // Store the specific declaration encountered.
+  }
+}
+
+for (const auto &BaseSpec : Def->bases()) {
+  if (const CXXRecordDecl *BaseDef =
+  BaseSpec.getType()->getAsCXXRecordDecl()) {
+Collect(BaseDef); // Recursively collect from base classes.
+  }
+}
+  };
+
+  Collect(Decl);
+  return Result;
+}
+
+// Gets canonical declarations of methods already overridden or implemented in
+// class D.
+std::set
+getImplementedOrOverriddenCanonicals(const CXXRecordDecl *D) {
+  std::set ImplementedSet;
+  for (const CXXMethodDecl *M : D->methods()) {
+// If M provides an implementation for any virtual method it overrides.
+// A method is an "implementation" if it's virtual and not pure.
+// Or if it directly overrides a base method.
+for (const CXXMethodDecl *OverriddenM : M->overridden_methods()) {
+  ImplementedSet.insert(OverriddenM->getCanonicalDecl());
+}
+  }
+  return ImplementedSet;
+}
+
+// Get the location of every colon of the `AccessSpecifier`.
+std::map
+getSpecifierLocations(const CXXRecordDecl *D) {
+  std::map Locs;
+  for (auto *DeclNode : D->decls()) { // Changed to DeclNode to avoid ambiguity
+if (const auto *ASD = llvm::dyn_cast(DeclNode)) {
+  Locs[ASD->getAccess()] = ASD->getColonLoc();
+}
+  }
+  return Locs;
+}
+
+// Check if the current class has any pure virtual method to be implemented.
+bool OverridePureVirtuals::prepare(const Selection &Sel) {
+  const SelectionTree::Node *Node = Sel.ASTSelection.commonAncestor();
+  if (!Node) {
+return false;
+  }
+
+  // Make sure we have a definition.
+  CurrentDecl = Node->ASTNode.get();
+  if (!CurrentDecl || !CurrentDecl->getDefinition()) {
+return false;
+  }
+
+  // A class needs overrides if it's abstract itself, or derives from abstract
+  // bases and hasn't implemented all necessary methods. A simpler check: if it
+  // has any base that is abstract.
+  bool HasAbstractBase = false;
+  for (const auto &Base : CurrentDecl->bases()) {
+if (const CXXRecordDecl *BaseDecl = Base.getType()->getAsCXXRecordDecl()) {
+  if 

[clang] [clang-format] Fix a bug in annotating binary operator && (PR #138633)

2025-05-10 Thread Pierre Jolivet via cfe-commits

prj- wrote:

Done, cf. https://github.com/llvm/llvm-project/issues/139376.

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


[clang] [libcxx] [llvm] [Clang] Add warnings when mixing different charN_t types (PR #138708)

2025-05-10 Thread via cfe-commits

https://github.com/cor3ntin updated 
https://github.com/llvm/llvm-project/pull/138708

>From c23bf23ddc8e1c8f50a57fcaf74682e86d8ade16 Mon Sep 17 00:00:00 2001
From: Corentin Jabot 
Date: Tue, 6 May 2025 17:14:35 +0200
Subject: [PATCH 1/5] [Clang] Add warnings when mixing different charN_t types

charN_t represent code units of different UTF encodings.
Therefore the values of 2 different charN_t objects do not represent
the same characters.

In order to avoid comparing apples and oranges, we add new warnings to
warn on:
  - Implicit conversions
  - Comparisons
  - Other cases involving arithmetic conversions

We only produce the warning if we cannot establish the comparison
would be safe through constant evaluation.

The new `-Wimplicit-unicode-conversion` warning is enabled by default.

Note that this PR intentionally doesn;t touches char/wchar_t,
but it would be worth considering also warning on extending the new
warnings to these types (in a follow up)

Additionally most arithmetic operations on charN_t
don't really make sense (ie what does it mean to addition code units),
so we could add warnings for that.

Fixes #138526
---
 clang/docs/ReleaseNotes.rst   |   4 +
 clang/include/clang/AST/ASTDiagnostic.h   |   3 +
 clang/include/clang/AST/Type.h|   1 +
 clang/include/clang/Basic/DiagnosticGroups.td |   1 +
 .../clang/Basic/DiagnosticSemaKinds.td|  25 +++
 clang/lib/AST/ASTDiagnostic.cpp   |  29 
 clang/lib/AST/Type.cpp|  14 ++
 clang/lib/Sema/SemaChecking.cpp   |  48 ++
 clang/lib/Sema/SemaExpr.cpp   |  71 
 .../warn-implicit-unicode-conversions.cpp | 155 ++
 llvm/include/llvm/Support/ConvertUTF.h|   4 +
 llvm/lib/Support/ConvertUTFWrapper.cpp|  10 ++
 12 files changed, 365 insertions(+)
 create mode 100644 clang/test/SemaCXX/warn-implicit-unicode-conversions.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 203958dab7430..3a42f43d79fd1 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -503,6 +503,10 @@ Improvements to Clang's diagnostics
 - ``-Wreserved-identifier`` now fires on reserved parameter names in a function
   declaration which is not a definition.
 
+- A new ``-Wimplicit-unicode-conversion`` warns where comparing or implicitly 
converting
+  between different Unicode character types (``char8_t``, ``char16_t``, 
``char32_t``).
+  This warning only triggers in C++ as these types are aliases in C. 
(#GH138526)
+
 Improvements to Clang's time-trace
 --
 
diff --git a/clang/include/clang/AST/ASTDiagnostic.h 
b/clang/include/clang/AST/ASTDiagnostic.h
index ef22249828629..baa410e3e4a03 100644
--- a/clang/include/clang/AST/ASTDiagnostic.h
+++ b/clang/include/clang/AST/ASTDiagnostic.h
@@ -38,6 +38,9 @@ namespace clang {
   /// is initialized before passing it in.
   QualType desugarForDiagnostic(ASTContext &Context, QualType QT,
 bool &ShouldAKA);
+
+  std::string FormatUTFCodeUnitAsCodepoint(unsigned Value, QualType T);
+
 }  // end namespace clang
 
 #endif
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 02a6fb5333538..7fca11fb708cf 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -2524,6 +2524,7 @@ class alignas(TypeAlignment) Type : public 
ExtQualsTypeCommonBase {
   bool isChar16Type() const;
   bool isChar32Type() const;
   bool isAnyCharacterType() const;
+  bool isUnicodeCharacterType() const;
   bool isIntegralType(const ASTContext &Ctx) const;
 
   /// Determine whether this type is an integral or enumeration type.
diff --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 1faf8508121f4..e5b5dbbd07f10 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -111,6 +111,7 @@ def EnumConversion : DiagGroup<"enum-conversion",
 ImplicitEnumEnumCast,
 EnumFloatConversion,
 EnumCompareConditional]>;
+def ImplicitUnicodeConversion : DiagGroup<"implicit-unicode-conversion">;
 def DeprecatedOFast : DiagGroup<"deprecated-ofast">;
 def ObjCSignedCharBoolImplicitIntConversion :
   DiagGroup<"objc-signed-char-bool-implicit-int-conversion">;
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index e5a7cdc14a737..a018f6693cff2 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -4357,6 +4357,26 @@ def warn_address_of_reference_bool_conversion : Warning<
   "code; pointer may be assumed to always convert to true">,
   InGroup;
 
+def warn_impcast_unicode_char_type : Warning<
+  "implicit conversion from %0 to %1 may change th

[clang] [clang] Remove redundant calls to std::unique_ptr::get (NFC) (PR #139399)

2025-05-10 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`sanitizer-x86_64-linux-android` running on `sanitizer-buildbot-android` while 
building `clang` at step 2 "annotate".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/186/builds/8911


Here is the relevant piece of the build log for the reference

```
Step 2 (annotate) failure: 'python 
../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py'
 (failure)
...
[   OK ] AddressSanitizer.AtoiAndFriendsOOBTest (2239 ms)
[ RUN  ] AddressSanitizer.HasFeatureAddressSanitizerTest
[   OK ] AddressSanitizer.HasFeatureAddressSanitizerTest (0 ms)
[ RUN  ] AddressSanitizer.CallocReturnsZeroMem
[   OK ] AddressSanitizer.CallocReturnsZeroMem (11 ms)
[ DISABLED ] AddressSanitizer.DISABLED_TSDTest
[ RUN  ] AddressSanitizer.IgnoreTest
[   OK ] AddressSanitizer.IgnoreTest (0 ms)
[ RUN  ] AddressSanitizer.SignalTest
[   OK ] AddressSanitizer.SignalTest (164 ms)
[ RUN  ] AddressSanitizer.ReallocTest
[   OK ] AddressSanitizer.ReallocTest (39 ms)
[ RUN  ] AddressSanitizer.WrongFreeTest
[   OK ] AddressSanitizer.WrongFreeTest (132 ms)
[ RUN  ] AddressSanitizer.LongJmpTest
[   OK ] AddressSanitizer.LongJmpTest (0 ms)
[ RUN  ] AddressSanitizer.ThreadStackReuseTest
[   OK ] AddressSanitizer.ThreadStackReuseTest (12 ms)
[ DISABLED ] AddressSanitizer.DISABLED_MemIntrinsicUnalignedAccessTest
[ DISABLED ] AddressSanitizer.DISABLED_LargeFunctionSymbolizeTest
[ DISABLED ] AddressSanitizer.DISABLED_MallocFreeUnwindAndSymbolizeTest
[ RUN  ] AddressSanitizer.UseThenFreeThenUseTest
[   OK ] AddressSanitizer.UseThenFreeThenUseTest (112 ms)
[ RUN  ] AddressSanitizer.FileNameInGlobalReportTest
[   OK ] AddressSanitizer.FileNameInGlobalReportTest (107 ms)
[ DISABLED ] AddressSanitizer.DISABLED_StressStackReuseAndExceptionsTest
[ RUN  ] AddressSanitizer.MlockTest
[   OK ] AddressSanitizer.MlockTest (0 ms)
[ DISABLED ] AddressSanitizer.DISABLED_DemoThreadedTest
[ DISABLED ] AddressSanitizer.DISABLED_DemoStackTest
[ DISABLED ] AddressSanitizer.DISABLED_DemoThreadStackTest
[ DISABLED ] AddressSanitizer.DISABLED_DemoUAFLowIn
[ DISABLED ] AddressSanitizer.DISABLED_DemoUAFLowLeft
[ DISABLED ] AddressSanitizer.DISABLED_DemoUAFLowRight
[ DISABLED ] AddressSanitizer.DISABLED_DemoUAFHigh
[ DISABLED ] AddressSanitizer.DISABLED_DemoOOM
[ DISABLED ] AddressSanitizer.DISABLED_DemoDoubleFreeTest
[ DISABLED ] AddressSanitizer.DISABLED_DemoNullDerefTest
[ DISABLED ] AddressSanitizer.DISABLED_DemoFunctionStaticTest
[ DISABLED ] AddressSanitizer.DISABLED_DemoTooMuchMemoryTest
[ RUN  ] AddressSanitizer.LongDoubleNegativeTest
[   OK ] AddressSanitizer.LongDoubleNegativeTest (0 ms)
[--] 19 tests from AddressSanitizer (27868 ms total)

[--] Global test environment tear-down
[==] 22 tests from 2 test suites ran. (27871 ms total)
[  PASSED  ] 22 tests.

  YOU HAVE 1 DISABLED TEST

Step 34 (run instrumented asan tests 
[aarch64/bluejay-userdebug/TQ3A.230805.001]) failure: run instrumented asan 
tests [aarch64/bluejay-userdebug/TQ3A.230805.001] (failure)
...
[ RUN  ] AddressSanitizer.HasFeatureAddressSanitizerTest
[   OK ] AddressSanitizer.HasFeatureAddressSanitizerTest (0 ms)
[ RUN  ] AddressSanitizer.CallocReturnsZeroMem
[   OK ] AddressSanitizer.CallocReturnsZeroMem (11 ms)
[ DISABLED ] AddressSanitizer.DISABLED_TSDTest
[ RUN  ] AddressSanitizer.IgnoreTest
[   OK ] AddressSanitizer.IgnoreTest (0 ms)
[ RUN  ] AddressSanitizer.SignalTest
[   OK ] AddressSanitizer.SignalTest (164 ms)
[ RUN  ] AddressSanitizer.ReallocTest
[   OK ] AddressSanitizer.ReallocTest (39 ms)
[ RUN  ] AddressSanitizer.WrongFreeTest
[   OK ] AddressSanitizer.WrongFreeTest (132 ms)
[ RUN  ] AddressSanitizer.LongJmpTest
[   OK ] AddressSanitizer.LongJmpTest (0 ms)
[ RUN  ] AddressSanitizer.ThreadStackReuseTest
[   OK ] AddressSanitizer.ThreadStackReuseTest (12 ms)
[ DISABLED ] AddressSanitizer.DISABLED_MemIntrinsicUnalignedAccessTest
[ DISABLED ] AddressSanitizer.DISABLED_LargeFunctionSymbolizeTest
[ DISABLED ] AddressSanitizer.DISABLED_MallocFreeUnwindAndSymbolizeTest
[ RUN  ] AddressSanitizer.UseThenFreeThenUseTest
[   OK ] AddressSanitizer.UseThenFreeThenUseTest (112 ms)
[ RUN  ] AddressSanitizer.FileNameInGlobalReportTest
[   OK ] AddressSanitizer.FileNameInGlobalReportTest (107 ms)
[ DISABLED ] AddressSanitizer.DISABLED_StressStackReuseAndExceptionsTest
[ RUN  ] AddressSanitizer.MlockTest
[   OK ] AddressSanitizer.MlockTest (0 ms)
[ DISABLED ] AddressSanitizer.DISABLED_DemoThreadedTest
[ DISABLED ] AddressSanitizer.DISABLED_DemoStackTest
[ DISABLED ] AddressSanitizer.DISABLED_DemoThreadStackTest
[ DISABLED ] AddressSanitizer.DISABLED_DemoUAFLowIn
[ DISABLED ] AddressSanitizer.DISABLED_DemoUAFLowLeft
[ DISABLED ] AddressSanitizer.DISABLED_DemoUAFLowRight
[ DISABLED ] 

[clang] [libcxx] [llvm] [Clang] Add warnings when mixing different charN_t types (PR #138708)

2025-05-10 Thread via cfe-commits


@@ -111,6 +111,7 @@ def EnumConversion : DiagGroup<"enum-conversion",
 ImplicitEnumEnumCast,
 EnumFloatConversion,
 EnumCompareConditional]>;
+def ImplicitUnicodeConversion : DiagGroup<"implicit-unicode-conversion">;

cor3ntin wrote:

character-conversion, added to -Wconversion ( I agree with Aaron that 
"suspicious" would clash with everything else)

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


[clang] [TableGen] Use std::tie to Implment operator< (NFC) (PR #139405)

2025-05-10 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Kazu Hirata (kazutakahirata)


Changes



---
Full diff: https://github.com/llvm/llvm-project/pull/139405.diff


2 Files Affected:

- (modified) clang/utils/TableGen/MveEmitter.cpp (+2-6) 
- (modified) clang/utils/TableGen/NeonEmitter.cpp (+2-5) 


``diff
diff --git a/clang/utils/TableGen/MveEmitter.cpp 
b/clang/utils/TableGen/MveEmitter.cpp
index 95fd658b3bde2..a003b5e632d58 100644
--- a/clang/utils/TableGen/MveEmitter.cpp
+++ b/clang/utils/TableGen/MveEmitter.cpp
@@ -1550,18 +1550,14 @@ struct OutputIntrinsic {
   std::string Name;
   ComparableStringVector ParamValues;
   bool operator<(const OutputIntrinsic &rhs) const {
-if (Name != rhs.Name)
-  return Name < rhs.Name;
-return ParamValues < rhs.ParamValues;
+return std::tie(Name, ParamValues) < std::tie(rhs.Name, rhs.ParamValues);
   }
 };
 struct MergeableGroup {
   std::string Code;
   ComparableStringVector ParamTypes;
   bool operator<(const MergeableGroup &rhs) const {
-if (Code != rhs.Code)
-  return Code < rhs.Code;
-return ParamTypes < rhs.ParamTypes;
+return std::tie(Code, ParamTypes) < std::tie(rhs.Code, rhs.ParamTypes);
   }
 };
 
diff --git a/clang/utils/TableGen/NeonEmitter.cpp 
b/clang/utils/TableGen/NeonEmitter.cpp
index 6b0fa1648e583..b7b2580d72a0e 100644
--- a/clang/utils/TableGen/NeonEmitter.cpp
+++ b/clang/utils/TableGen/NeonEmitter.cpp
@@ -492,11 +492,8 @@ class Intrinsic {
 
   bool operator<(const Intrinsic &Other) const {
 // Sort lexicographically on a three-tuple (ArchGuard, TargetGuard, Name)
-if (ArchGuard != Other.ArchGuard)
-  return ArchGuard < Other.ArchGuard;
-if (TargetGuard != Other.TargetGuard)
-  return TargetGuard < Other.TargetGuard;
-return Name < Other.Name;
+return std::tie(ArchGuard, TargetGuard, Name) <
+   std::tie(Other.ArchGuard, Other.TargetGuard, Other.Name);
   }
 
   ClassKind getClassKind(bool UseClassBIfScalar = false) {

``




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


[clang-tools-extra] [clangd] Add tweak to add pure virtual overrides (PR #139348)

2025-05-10 Thread Marco Maia via cfe-commits

https://github.com/marcogmaia updated 
https://github.com/llvm/llvm-project/pull/139348

>From 76503bd8f5618b710e2909d1303de5d34723 Mon Sep 17 00:00:00 2001
From: Marco Maia 
Date: Sat, 10 May 2025 00:48:39 -0300
Subject: [PATCH 1/6] [clangd] Add tweak to add pure virtual overrides

---
 .../clangd/refactor/tweaks/CMakeLists.txt |   3 +-
 .../refactor/tweaks/OverridePureVirtuals.cpp  | 366 
 .../clangd/unittests/CMakeLists.txt   |   1 +
 .../tweaks/OverridePureVirtualsTests.cpp  | 410 ++
 4 files changed, 779 insertions(+), 1 deletion(-)
 create mode 100644 
clang-tools-extra/clangd/refactor/tweaks/OverridePureVirtuals.cpp
 create mode 100644 
clang-tools-extra/clangd/unittests/tweaks/OverridePureVirtualsTests.cpp

diff --git a/clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt 
b/clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
index 59475b0dfd3d2..1d6e38088ad67 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
+++ b/clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
@@ -14,9 +14,9 @@ set(LLVM_LINK_COMPONENTS
 add_clang_library(clangDaemonTweaks OBJECT
   AddUsing.cpp
   AnnotateHighlightings.cpp
-  DumpAST.cpp
   DefineInline.cpp
   DefineOutline.cpp
+  DumpAST.cpp
   ExpandDeducedType.cpp
   ExpandMacro.cpp
   ExtractFunction.cpp
@@ -24,6 +24,7 @@ add_clang_library(clangDaemonTweaks OBJECT
   MemberwiseConstructor.cpp
   ObjCLocalizeStringLiteral.cpp
   ObjCMemberwiseInitializer.cpp
+  OverridePureVirtuals.cpp
   PopulateSwitch.cpp
   RawStringLiteral.cpp
   RemoveUsingNamespace.cpp
diff --git a/clang-tools-extra/clangd/refactor/tweaks/OverridePureVirtuals.cpp 
b/clang-tools-extra/clangd/refactor/tweaks/OverridePureVirtuals.cpp
new file mode 100644
index 0..b8880433fdd52
--- /dev/null
+++ b/clang-tools-extra/clangd/refactor/tweaks/OverridePureVirtuals.cpp
@@ -0,0 +1,366 @@
+//===--- AddPureVirtualOverride.cpp --*- 
C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "refactor/Tweak.h"
+
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/DeclCXX.h"
+#include "clang/AST/Type.h"
+#include "clang/AST/TypeLoc.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Tooling/Core/Replacement.h"
+#include "llvm/ADT/DenseSet.h"
+#include "llvm/Support/FormatVariadic.h"
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+namespace clang {
+namespace clangd {
+namespace {
+
+class OverridePureVirtuals : public Tweak {
+public:
+  const char *id() const final; // defined by REGISTER_TWEAK.
+  bool prepare(const Selection &Sel) override;
+  Expected apply(const Selection &Sel) override;
+  std::string title() const override { return "Override pure virtual methods"; 
}
+  llvm::StringLiteral kind() const override {
+return CodeAction::REFACTOR_KIND;
+  }
+
+private:
+  // Stores the CXXRecordDecl of the class being modified.
+  const CXXRecordDecl *CurrentDecl = nullptr;
+  // Stores pure virtual methods that need overriding, grouped by their 
original
+  // access specifier.
+  std::map>
+  MissingMethodsByAccess;
+  // Stores the source locations of existing access specifiers in CurrentDecl.
+  std::map AccessSpecifierLocations;
+
+  // Helper function to gather information before applying the tweak.
+  void collectMissingPureVirtuals(const Selection &Sel);
+};
+
+REGISTER_TWEAK(OverridePureVirtuals)
+
+// Collects all unique, canonical pure virtual methods from a class and its
+// entire inheritance hierarchy. This function aims to find methods that 
*could*
+// make a derived class abstract if not implemented.
+std::vector
+getAllUniquePureVirtualsFromHierarchy(const CXXRecordDecl *Decl) {
+  std::vector Result;
+  llvm::DenseSet VisitedCanonicalMethods;
+  // We declare it as a std::function because we are going to call it
+  // recursively.
+  std::function Collect;
+
+  Collect = [&](const CXXRecordDecl *CurrentClass) {
+if (!CurrentClass) {
+  return;
+}
+const CXXRecordDecl *Def = CurrentClass->getDefinition();
+if (!Def) {
+  return;
+}
+
+for (const CXXMethodDecl *M : Def->methods()) {
+  // Add if its canonical declaration hasn't been processed yet.
+  // This ensures each distinct pure virtual method signature is collected
+  // once.
+  if (M->isPureVirtual() &&
+  VisitedCanonicalMethods.insert(M->getCanonicalDecl()).second) {
+Result.emplace_back(M); // Store the specific declaration encountered.
+  }
+}
+
+for (const auto &BaseSpec : Def->bases()) {
+  if (const CXXRecordDecl *BaseDef =
+  BaseSpec.getType()->getAsCXXRecordDecl()) {
+Collect(BaseDef)

[clang-tools-extra] [clangd] Add tweak to add pure virtual overrides (PR #139348)

2025-05-10 Thread Marco Maia via cfe-commits

https://github.com/marcogmaia updated 
https://github.com/llvm/llvm-project/pull/139348

>From 76503bd8f5618b710e2909d1303de5d34723 Mon Sep 17 00:00:00 2001
From: Marco Maia 
Date: Sat, 10 May 2025 00:48:39 -0300
Subject: [PATCH 1/7] [clangd] Add tweak to add pure virtual overrides

---
 .../clangd/refactor/tweaks/CMakeLists.txt |   3 +-
 .../refactor/tweaks/OverridePureVirtuals.cpp  | 366 
 .../clangd/unittests/CMakeLists.txt   |   1 +
 .../tweaks/OverridePureVirtualsTests.cpp  | 410 ++
 4 files changed, 779 insertions(+), 1 deletion(-)
 create mode 100644 
clang-tools-extra/clangd/refactor/tweaks/OverridePureVirtuals.cpp
 create mode 100644 
clang-tools-extra/clangd/unittests/tweaks/OverridePureVirtualsTests.cpp

diff --git a/clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt 
b/clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
index 59475b0dfd3d2..1d6e38088ad67 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
+++ b/clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
@@ -14,9 +14,9 @@ set(LLVM_LINK_COMPONENTS
 add_clang_library(clangDaemonTweaks OBJECT
   AddUsing.cpp
   AnnotateHighlightings.cpp
-  DumpAST.cpp
   DefineInline.cpp
   DefineOutline.cpp
+  DumpAST.cpp
   ExpandDeducedType.cpp
   ExpandMacro.cpp
   ExtractFunction.cpp
@@ -24,6 +24,7 @@ add_clang_library(clangDaemonTweaks OBJECT
   MemberwiseConstructor.cpp
   ObjCLocalizeStringLiteral.cpp
   ObjCMemberwiseInitializer.cpp
+  OverridePureVirtuals.cpp
   PopulateSwitch.cpp
   RawStringLiteral.cpp
   RemoveUsingNamespace.cpp
diff --git a/clang-tools-extra/clangd/refactor/tweaks/OverridePureVirtuals.cpp 
b/clang-tools-extra/clangd/refactor/tweaks/OverridePureVirtuals.cpp
new file mode 100644
index 0..b8880433fdd52
--- /dev/null
+++ b/clang-tools-extra/clangd/refactor/tweaks/OverridePureVirtuals.cpp
@@ -0,0 +1,366 @@
+//===--- AddPureVirtualOverride.cpp --*- 
C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "refactor/Tweak.h"
+
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/DeclCXX.h"
+#include "clang/AST/Type.h"
+#include "clang/AST/TypeLoc.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Tooling/Core/Replacement.h"
+#include "llvm/ADT/DenseSet.h"
+#include "llvm/Support/FormatVariadic.h"
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+namespace clang {
+namespace clangd {
+namespace {
+
+class OverridePureVirtuals : public Tweak {
+public:
+  const char *id() const final; // defined by REGISTER_TWEAK.
+  bool prepare(const Selection &Sel) override;
+  Expected apply(const Selection &Sel) override;
+  std::string title() const override { return "Override pure virtual methods"; 
}
+  llvm::StringLiteral kind() const override {
+return CodeAction::REFACTOR_KIND;
+  }
+
+private:
+  // Stores the CXXRecordDecl of the class being modified.
+  const CXXRecordDecl *CurrentDecl = nullptr;
+  // Stores pure virtual methods that need overriding, grouped by their 
original
+  // access specifier.
+  std::map>
+  MissingMethodsByAccess;
+  // Stores the source locations of existing access specifiers in CurrentDecl.
+  std::map AccessSpecifierLocations;
+
+  // Helper function to gather information before applying the tweak.
+  void collectMissingPureVirtuals(const Selection &Sel);
+};
+
+REGISTER_TWEAK(OverridePureVirtuals)
+
+// Collects all unique, canonical pure virtual methods from a class and its
+// entire inheritance hierarchy. This function aims to find methods that 
*could*
+// make a derived class abstract if not implemented.
+std::vector
+getAllUniquePureVirtualsFromHierarchy(const CXXRecordDecl *Decl) {
+  std::vector Result;
+  llvm::DenseSet VisitedCanonicalMethods;
+  // We declare it as a std::function because we are going to call it
+  // recursively.
+  std::function Collect;
+
+  Collect = [&](const CXXRecordDecl *CurrentClass) {
+if (!CurrentClass) {
+  return;
+}
+const CXXRecordDecl *Def = CurrentClass->getDefinition();
+if (!Def) {
+  return;
+}
+
+for (const CXXMethodDecl *M : Def->methods()) {
+  // Add if its canonical declaration hasn't been processed yet.
+  // This ensures each distinct pure virtual method signature is collected
+  // once.
+  if (M->isPureVirtual() &&
+  VisitedCanonicalMethods.insert(M->getCanonicalDecl()).second) {
+Result.emplace_back(M); // Store the specific declaration encountered.
+  }
+}
+
+for (const auto &BaseSpec : Def->bases()) {
+  if (const CXXRecordDecl *BaseDef =
+  BaseSpec.getType()->getAsCXXRecordDecl()) {
+Collect(BaseDef)

[clang-tools-extra] [clangd] Add tweak to add pure virtual overrides (PR #139348)

2025-05-10 Thread Marco Maia via cfe-commits


@@ -0,0 +1,349 @@
+//===--- AddPureVirtualOverride.cpp --*- 
C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "refactor/Tweak.h"
+
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/DeclCXX.h"
+#include "clang/AST/Type.h"
+#include "clang/AST/TypeLoc.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Tooling/Core/Replacement.h"
+#include "llvm/ADT/DenseSet.h"
+#include "llvm/Support/FormatVariadic.h"
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+namespace clang {
+namespace clangd {
+namespace {
+
+class OverridePureVirtuals : public Tweak {
+public:
+  const char *id() const final; // defined by REGISTER_TWEAK.
+  bool prepare(const Selection &Sel) override;
+  Expected apply(const Selection &Sel) override;
+  std::string title() const override { return "Override pure virtual methods"; 
}
+  llvm::StringLiteral kind() const override {
+return CodeAction::REFACTOR_KIND;
+  }
+
+private:
+  // Stores the CXXRecordDecl of the class being modified.
+  const CXXRecordDecl *CurrentDecl = nullptr;
+  // Stores pure virtual methods that need overriding, grouped by their 
original
+  // access specifier.
+  std::map>
+  MissingMethodsByAccess;
+  // Stores the source locations of existing access specifiers in CurrentDecl.
+  std::map AccessSpecifierLocations;
+
+  // Helper function to gather information before applying the tweak.
+  void collectMissingPureVirtuals(const Selection &Sel);
+};
+
+REGISTER_TWEAK(OverridePureVirtuals)
+
+// Collects all unique, canonical pure virtual methods from a class and its
+// entire inheritance hierarchy. This function aims to find methods that 
*could*
+// make a derived class abstract if not implemented.
+std::vector
+getAllUniquePureVirtualsFromHierarchy(const CXXRecordDecl *Decl) {
+  std::vector Result;
+  llvm::DenseSet VisitedCanonicalMethods;
+  // We declare it as a std::function because we are going to call it
+  // recursively.
+  std::function Collect;
+
+  Collect = [&](const CXXRecordDecl *CurrentClass) {
+if (!CurrentClass) {
+  return;
+}
+const CXXRecordDecl *Def = CurrentClass->getDefinition();
+if (!Def) {
+  return;
+}
+
+for (const CXXMethodDecl *M : Def->methods()) {
+  // Add if its canonical declaration hasn't been processed yet.
+  // This ensures each distinct pure virtual method signature is collected
+  // once.
+  if (M->isPureVirtual() &&
+  VisitedCanonicalMethods.insert(M->getCanonicalDecl()).second) {
+Result.emplace_back(M); // Store the specific declaration encountered.
+  }
+}
+
+for (const auto &BaseSpec : Def->bases()) {
+  if (const CXXRecordDecl *BaseDef =
+  BaseSpec.getType()->getAsCXXRecordDecl()) {
+Collect(BaseDef); // Recursively collect from base classes.
+  }
+}
+  };
+
+  Collect(Decl);
+  return Result;
+}
+
+// Gets canonical declarations of methods already overridden or implemented in
+// class D.
+std::set
+getImplementedOrOverriddenCanonicals(const CXXRecordDecl *D) {
+  std::set ImplementedSet;
+  for (const CXXMethodDecl *M : D->methods()) {
+// If M provides an implementation for any virtual method it overrides.
+// A method is an "implementation" if it's virtual and not pure.
+// Or if it directly overrides a base method.
+for (const CXXMethodDecl *OverriddenM : M->overridden_methods()) {
+  ImplementedSet.insert(OverriddenM->getCanonicalDecl());
+}
+  }
+  return ImplementedSet;
+}
+
+// Get the location of every colon of the `AccessSpecifier`.
+std::map
+getSpecifierLocations(const CXXRecordDecl *D) {
+  std::map Locs;
+  for (auto *DeclNode : D->decls()) { // Changed to DeclNode to avoid ambiguity
+if (const auto *ASD = llvm::dyn_cast(DeclNode)) {
+  Locs[ASD->getAccess()] = ASD->getColonLoc();
+}
+  }
+  return Locs;
+}
+
+// Check if the current class has any pure virtual method to be implemented.
+bool OverridePureVirtuals::prepare(const Selection &Sel) {
+  const SelectionTree::Node *Node = Sel.ASTSelection.commonAncestor();
+  if (!Node) {
+return false;
+  }
+
+  // Make sure we have a definition.
+  CurrentDecl = Node->ASTNode.get();
+  if (!CurrentDecl || !CurrentDecl->getDefinition()) {
+return false;
+  }
+
+  // A class needs overrides if it's abstract itself, or derives from abstract
+  // bases and hasn't implemented all necessary methods. A simpler check: if it
+  // has any base that is abstract.
+  bool HasAbstractBase = false;
+  for (const auto &Base : CurrentDecl->bases()) {
+if (const CXXRecordDecl *BaseDecl = Base.getType()->getAsCXXRecordDecl()) {
+  if 

[clang-tools-extra] [clangd] Add tweak to add pure virtual overrides (PR #139348)

2025-05-10 Thread Marco Maia via cfe-commits

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


[clang-tools-extra] [clangd] Add tweak to add pure virtual overrides (PR #139348)

2025-05-10 Thread Marco Maia via cfe-commits


@@ -0,0 +1,349 @@
+//===--- AddPureVirtualOverride.cpp --*- 
C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "refactor/Tweak.h"
+
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/DeclCXX.h"
+#include "clang/AST/Type.h"
+#include "clang/AST/TypeLoc.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Tooling/Core/Replacement.h"
+#include "llvm/ADT/DenseSet.h"
+#include "llvm/Support/FormatVariadic.h"
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+namespace clang {
+namespace clangd {
+namespace {
+
+class OverridePureVirtuals : public Tweak {
+public:
+  const char *id() const final; // defined by REGISTER_TWEAK.
+  bool prepare(const Selection &Sel) override;
+  Expected apply(const Selection &Sel) override;
+  std::string title() const override { return "Override pure virtual methods"; 
}
+  llvm::StringLiteral kind() const override {
+return CodeAction::REFACTOR_KIND;
+  }
+
+private:
+  // Stores the CXXRecordDecl of the class being modified.
+  const CXXRecordDecl *CurrentDecl = nullptr;
+  // Stores pure virtual methods that need overriding, grouped by their 
original
+  // access specifier.
+  std::map>
+  MissingMethodsByAccess;
+  // Stores the source locations of existing access specifiers in CurrentDecl.
+  std::map AccessSpecifierLocations;
+
+  // Helper function to gather information before applying the tweak.
+  void collectMissingPureVirtuals(const Selection &Sel);
+};
+
+REGISTER_TWEAK(OverridePureVirtuals)
+
+// Collects all unique, canonical pure virtual methods from a class and its
+// entire inheritance hierarchy. This function aims to find methods that 
*could*
+// make a derived class abstract if not implemented.
+std::vector
+getAllUniquePureVirtualsFromHierarchy(const CXXRecordDecl *Decl) {
+  std::vector Result;
+  llvm::DenseSet VisitedCanonicalMethods;
+  // We declare it as a std::function because we are going to call it
+  // recursively.
+  std::function Collect;
+
+  Collect = [&](const CXXRecordDecl *CurrentClass) {
+if (!CurrentClass) {
+  return;
+}
+const CXXRecordDecl *Def = CurrentClass->getDefinition();
+if (!Def) {
+  return;
+}
+
+for (const CXXMethodDecl *M : Def->methods()) {
+  // Add if its canonical declaration hasn't been processed yet.
+  // This ensures each distinct pure virtual method signature is collected
+  // once.
+  if (M->isPureVirtual() &&
+  VisitedCanonicalMethods.insert(M->getCanonicalDecl()).second) {
+Result.emplace_back(M); // Store the specific declaration encountered.
+  }
+}
+
+for (const auto &BaseSpec : Def->bases()) {
+  if (const CXXRecordDecl *BaseDef =
+  BaseSpec.getType()->getAsCXXRecordDecl()) {
+Collect(BaseDef); // Recursively collect from base classes.
+  }
+}
+  };
+
+  Collect(Decl);
+  return Result;
+}
+
+// Gets canonical declarations of methods already overridden or implemented in
+// class D.
+std::set
+getImplementedOrOverriddenCanonicals(const CXXRecordDecl *D) {
+  std::set ImplementedSet;
+  for (const CXXMethodDecl *M : D->methods()) {
+// If M provides an implementation for any virtual method it overrides.
+// A method is an "implementation" if it's virtual and not pure.
+// Or if it directly overrides a base method.
+for (const CXXMethodDecl *OverriddenM : M->overridden_methods()) {
+  ImplementedSet.insert(OverriddenM->getCanonicalDecl());
+}
+  }
+  return ImplementedSet;
+}
+
+// Get the location of every colon of the `AccessSpecifier`.
+std::map
+getSpecifierLocations(const CXXRecordDecl *D) {
+  std::map Locs;
+  for (auto *DeclNode : D->decls()) { // Changed to DeclNode to avoid ambiguity
+if (const auto *ASD = llvm::dyn_cast(DeclNode)) {
+  Locs[ASD->getAccess()] = ASD->getColonLoc();
+}
+  }
+  return Locs;
+}
+
+// Check if the current class has any pure virtual method to be implemented.
+bool OverridePureVirtuals::prepare(const Selection &Sel) {
+  const SelectionTree::Node *Node = Sel.ASTSelection.commonAncestor();
+  if (!Node) {
+return false;
+  }
+
+  // Make sure we have a definition.
+  CurrentDecl = Node->ASTNode.get();
+  if (!CurrentDecl || !CurrentDecl->getDefinition()) {
+return false;
+  }
+
+  // A class needs overrides if it's abstract itself, or derives from abstract
+  // bases and hasn't implemented all necessary methods. A simpler check: if it
+  // has any base that is abstract.
+  bool HasAbstractBase = false;
+  for (const auto &Base : CurrentDecl->bases()) {
+if (const CXXRecordDecl *BaseDecl = Base.getType()->getAsCXXRecordDecl()) {
+  if 

[clang-tools-extra] [clangd] Add tweak to add pure virtual overrides (PR #139348)

2025-05-10 Thread Marco Maia via cfe-commits

https://github.com/marcogmaia commented:

@zwuis I've applied your review, thank you. 

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


[clang-tools-extra] [clangd] Add tweak to add pure virtual overrides (PR #139348)

2025-05-10 Thread Marco Maia via cfe-commits


@@ -0,0 +1,349 @@
+//===--- AddPureVirtualOverride.cpp --*- 
C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "refactor/Tweak.h"
+
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/DeclCXX.h"
+#include "clang/AST/Type.h"
+#include "clang/AST/TypeLoc.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Tooling/Core/Replacement.h"
+#include "llvm/ADT/DenseSet.h"
+#include "llvm/Support/FormatVariadic.h"
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+namespace clang {
+namespace clangd {
+namespace {
+
+class OverridePureVirtuals : public Tweak {
+public:
+  const char *id() const final; // defined by REGISTER_TWEAK.
+  bool prepare(const Selection &Sel) override;
+  Expected apply(const Selection &Sel) override;
+  std::string title() const override { return "Override pure virtual methods"; 
}
+  llvm::StringLiteral kind() const override {
+return CodeAction::REFACTOR_KIND;
+  }
+
+private:
+  // Stores the CXXRecordDecl of the class being modified.
+  const CXXRecordDecl *CurrentDecl = nullptr;
+  // Stores pure virtual methods that need overriding, grouped by their 
original
+  // access specifier.
+  std::map>
+  MissingMethodsByAccess;
+  // Stores the source locations of existing access specifiers in CurrentDecl.
+  std::map AccessSpecifierLocations;
+
+  // Helper function to gather information before applying the tweak.
+  void collectMissingPureVirtuals(const Selection &Sel);
+};
+
+REGISTER_TWEAK(OverridePureVirtuals)
+
+// Collects all unique, canonical pure virtual methods from a class and its
+// entire inheritance hierarchy. This function aims to find methods that 
*could*
+// make a derived class abstract if not implemented.
+std::vector
+getAllUniquePureVirtualsFromHierarchy(const CXXRecordDecl *Decl) {
+  std::vector Result;
+  llvm::DenseSet VisitedCanonicalMethods;
+  // We declare it as a std::function because we are going to call it
+  // recursively.
+  std::function Collect;
+
+  Collect = [&](const CXXRecordDecl *CurrentClass) {
+if (!CurrentClass) {
+  return;
+}
+const CXXRecordDecl *Def = CurrentClass->getDefinition();
+if (!Def) {
+  return;
+}
+
+for (const CXXMethodDecl *M : Def->methods()) {
+  // Add if its canonical declaration hasn't been processed yet.
+  // This ensures each distinct pure virtual method signature is collected
+  // once.
+  if (M->isPureVirtual() &&
+  VisitedCanonicalMethods.insert(M->getCanonicalDecl()).second) {
+Result.emplace_back(M); // Store the specific declaration encountered.
+  }
+}
+
+for (const auto &BaseSpec : Def->bases()) {
+  if (const CXXRecordDecl *BaseDef =
+  BaseSpec.getType()->getAsCXXRecordDecl()) {
+Collect(BaseDef); // Recursively collect from base classes.
+  }
+}
+  };
+
+  Collect(Decl);
+  return Result;
+}
+
+// Gets canonical declarations of methods already overridden or implemented in
+// class D.
+std::set
+getImplementedOrOverriddenCanonicals(const CXXRecordDecl *D) {
+  std::set ImplementedSet;
+  for (const CXXMethodDecl *M : D->methods()) {
+// If M provides an implementation for any virtual method it overrides.
+// A method is an "implementation" if it's virtual and not pure.
+// Or if it directly overrides a base method.
+for (const CXXMethodDecl *OverriddenM : M->overridden_methods()) {
+  ImplementedSet.insert(OverriddenM->getCanonicalDecl());
+}
+  }
+  return ImplementedSet;
+}
+
+// Get the location of every colon of the `AccessSpecifier`.
+std::map
+getSpecifierLocations(const CXXRecordDecl *D) {
+  std::map Locs;
+  for (auto *DeclNode : D->decls()) { // Changed to DeclNode to avoid ambiguity
+if (const auto *ASD = llvm::dyn_cast(DeclNode)) {
+  Locs[ASD->getAccess()] = ASD->getColonLoc();
+}
+  }
+  return Locs;
+}
+
+// Check if the current class has any pure virtual method to be implemented.
+bool OverridePureVirtuals::prepare(const Selection &Sel) {
+  const SelectionTree::Node *Node = Sel.ASTSelection.commonAncestor();
+  if (!Node) {
+return false;
+  }
+
+  // Make sure we have a definition.
+  CurrentDecl = Node->ASTNode.get();
+  if (!CurrentDecl || !CurrentDecl->getDefinition()) {
+return false;
+  }
+
+  // A class needs overrides if it's abstract itself, or derives from abstract
+  // bases and hasn't implemented all necessary methods. A simpler check: if it
+  // has any base that is abstract.
+  bool HasAbstractBase = false;
+  for (const auto &Base : CurrentDecl->bases()) {
+if (const CXXRecordDecl *BaseDecl = Base.getType()->getAsCXXRecordDecl()) {
+  if 

[clang-tools-extra] [clangd] Add tweak to add pure virtual overrides (PR #139348)

2025-05-10 Thread Marco Maia via cfe-commits


@@ -0,0 +1,349 @@
+//===--- AddPureVirtualOverride.cpp --*- 
C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "refactor/Tweak.h"
+
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/DeclCXX.h"
+#include "clang/AST/Type.h"
+#include "clang/AST/TypeLoc.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Tooling/Core/Replacement.h"
+#include "llvm/ADT/DenseSet.h"
+#include "llvm/Support/FormatVariadic.h"
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+namespace clang {
+namespace clangd {
+namespace {
+
+class OverridePureVirtuals : public Tweak {
+public:
+  const char *id() const final; // defined by REGISTER_TWEAK.
+  bool prepare(const Selection &Sel) override;
+  Expected apply(const Selection &Sel) override;
+  std::string title() const override { return "Override pure virtual methods"; 
}
+  llvm::StringLiteral kind() const override {
+return CodeAction::REFACTOR_KIND;
+  }
+
+private:
+  // Stores the CXXRecordDecl of the class being modified.
+  const CXXRecordDecl *CurrentDecl = nullptr;
+  // Stores pure virtual methods that need overriding, grouped by their 
original
+  // access specifier.
+  std::map>
+  MissingMethodsByAccess;
+  // Stores the source locations of existing access specifiers in CurrentDecl.
+  std::map AccessSpecifierLocations;
+
+  // Helper function to gather information before applying the tweak.
+  void collectMissingPureVirtuals(const Selection &Sel);
+};
+
+REGISTER_TWEAK(OverridePureVirtuals)
+
+// Collects all unique, canonical pure virtual methods from a class and its
+// entire inheritance hierarchy. This function aims to find methods that 
*could*
+// make a derived class abstract if not implemented.
+std::vector
+getAllUniquePureVirtualsFromHierarchy(const CXXRecordDecl *Decl) {
+  std::vector Result;
+  llvm::DenseSet VisitedCanonicalMethods;
+  // We declare it as a std::function because we are going to call it
+  // recursively.
+  std::function Collect;

marcogmaia wrote:

Replaced it with a free function.

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


[clang-tools-extra] [clangd] Add tweak to add pure virtual overrides (PR #139348)

2025-05-10 Thread Marco Maia via cfe-commits


@@ -0,0 +1,349 @@
+//===--- AddPureVirtualOverride.cpp --*- 
C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "refactor/Tweak.h"
+
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/DeclCXX.h"
+#include "clang/AST/Type.h"
+#include "clang/AST/TypeLoc.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Tooling/Core/Replacement.h"
+#include "llvm/ADT/DenseSet.h"
+#include "llvm/Support/FormatVariadic.h"
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+namespace clang {
+namespace clangd {
+namespace {
+
+class OverridePureVirtuals : public Tweak {
+public:
+  const char *id() const final; // defined by REGISTER_TWEAK.
+  bool prepare(const Selection &Sel) override;
+  Expected apply(const Selection &Sel) override;
+  std::string title() const override { return "Override pure virtual methods"; 
}
+  llvm::StringLiteral kind() const override {
+return CodeAction::REFACTOR_KIND;
+  }
+
+private:
+  // Stores the CXXRecordDecl of the class being modified.
+  const CXXRecordDecl *CurrentDecl = nullptr;
+  // Stores pure virtual methods that need overriding, grouped by their 
original
+  // access specifier.
+  std::map>
+  MissingMethodsByAccess;
+  // Stores the source locations of existing access specifiers in CurrentDecl.
+  std::map AccessSpecifierLocations;
+
+  // Helper function to gather information before applying the tweak.
+  void collectMissingPureVirtuals(const Selection &Sel);
+};
+
+REGISTER_TWEAK(OverridePureVirtuals)
+
+// Collects all unique, canonical pure virtual methods from a class and its
+// entire inheritance hierarchy. This function aims to find methods that 
*could*
+// make a derived class abstract if not implemented.
+std::vector
+getAllUniquePureVirtualsFromHierarchy(const CXXRecordDecl *Decl) {
+  std::vector Result;
+  llvm::DenseSet VisitedCanonicalMethods;
+  // We declare it as a std::function because we are going to call it
+  // recursively.
+  std::function Collect;
+
+  Collect = [&](const CXXRecordDecl *CurrentClass) {
+if (!CurrentClass) {
+  return;
+}
+const CXXRecordDecl *Def = CurrentClass->getDefinition();
+if (!Def) {
+  return;
+}
+
+for (const CXXMethodDecl *M : Def->methods()) {
+  // Add if its canonical declaration hasn't been processed yet.
+  // This ensures each distinct pure virtual method signature is collected
+  // once.
+  if (M->isPureVirtual() &&
+  VisitedCanonicalMethods.insert(M->getCanonicalDecl()).second) {
+Result.emplace_back(M); // Store the specific declaration encountered.
+  }
+}
+
+for (const auto &BaseSpec : Def->bases()) {
+  if (const CXXRecordDecl *BaseDef =
+  BaseSpec.getType()->getAsCXXRecordDecl()) {
+Collect(BaseDef); // Recursively collect from base classes.
+  }
+}
+  };
+
+  Collect(Decl);
+  return Result;
+}
+
+// Gets canonical declarations of methods already overridden or implemented in
+// class D.
+std::set
+getImplementedOrOverriddenCanonicals(const CXXRecordDecl *D) {
+  std::set ImplementedSet;
+  for (const CXXMethodDecl *M : D->methods()) {
+// If M provides an implementation for any virtual method it overrides.
+// A method is an "implementation" if it's virtual and not pure.
+// Or if it directly overrides a base method.
+for (const CXXMethodDecl *OverriddenM : M->overridden_methods()) {
+  ImplementedSet.insert(OverriddenM->getCanonicalDecl());
+}
+  }
+  return ImplementedSet;
+}
+
+// Get the location of every colon of the `AccessSpecifier`.
+std::map
+getSpecifierLocations(const CXXRecordDecl *D) {
+  std::map Locs;
+  for (auto *DeclNode : D->decls()) { // Changed to DeclNode to avoid ambiguity
+if (const auto *ASD = llvm::dyn_cast(DeclNode)) {
+  Locs[ASD->getAccess()] = ASD->getColonLoc();
+}
+  }
+  return Locs;
+}
+
+// Check if the current class has any pure virtual method to be implemented.
+bool OverridePureVirtuals::prepare(const Selection &Sel) {
+  const SelectionTree::Node *Node = Sel.ASTSelection.commonAncestor();
+  if (!Node) {
+return false;
+  }
+
+  // Make sure we have a definition.
+  CurrentDecl = Node->ASTNode.get();
+  if (!CurrentDecl || !CurrentDecl->getDefinition()) {
+return false;
+  }
+
+  // A class needs overrides if it's abstract itself, or derives from abstract
+  // bases and hasn't implemented all necessary methods. A simpler check: if it
+  // has any base that is abstract.
+  bool HasAbstractBase = false;
+  for (const auto &Base : CurrentDecl->bases()) {
+if (const CXXRecordDecl *BaseDecl = Base.getType()->getAsCXXRecordDecl()) {
+  if 

[clang-tools-extra] [clangd] Add tweak to add pure virtual overrides (PR #139348)

2025-05-10 Thread Marco Maia via cfe-commits


@@ -0,0 +1,349 @@
+//===--- AddPureVirtualOverride.cpp --*- 
C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "refactor/Tweak.h"
+
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/DeclCXX.h"
+#include "clang/AST/Type.h"
+#include "clang/AST/TypeLoc.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Tooling/Core/Replacement.h"
+#include "llvm/ADT/DenseSet.h"
+#include "llvm/Support/FormatVariadic.h"
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+namespace clang {
+namespace clangd {
+namespace {
+
+class OverridePureVirtuals : public Tweak {
+public:
+  const char *id() const final; // defined by REGISTER_TWEAK.
+  bool prepare(const Selection &Sel) override;
+  Expected apply(const Selection &Sel) override;
+  std::string title() const override { return "Override pure virtual methods"; 
}
+  llvm::StringLiteral kind() const override {
+return CodeAction::REFACTOR_KIND;
+  }
+
+private:
+  // Stores the CXXRecordDecl of the class being modified.
+  const CXXRecordDecl *CurrentDecl = nullptr;
+  // Stores pure virtual methods that need overriding, grouped by their 
original
+  // access specifier.
+  std::map>
+  MissingMethodsByAccess;
+  // Stores the source locations of existing access specifiers in CurrentDecl.
+  std::map AccessSpecifierLocations;
+
+  // Helper function to gather information before applying the tweak.
+  void collectMissingPureVirtuals(const Selection &Sel);
+};
+
+REGISTER_TWEAK(OverridePureVirtuals)
+
+// Collects all unique, canonical pure virtual methods from a class and its
+// entire inheritance hierarchy. This function aims to find methods that 
*could*
+// make a derived class abstract if not implemented.
+std::vector
+getAllUniquePureVirtualsFromHierarchy(const CXXRecordDecl *Decl) {
+  std::vector Result;
+  llvm::DenseSet VisitedCanonicalMethods;
+  // We declare it as a std::function because we are going to call it
+  // recursively.
+  std::function Collect;
+
+  Collect = [&](const CXXRecordDecl *CurrentClass) {
+if (!CurrentClass) {
+  return;
+}
+const CXXRecordDecl *Def = CurrentClass->getDefinition();
+if (!Def) {
+  return;
+}
+
+for (const CXXMethodDecl *M : Def->methods()) {
+  // Add if its canonical declaration hasn't been processed yet.
+  // This ensures each distinct pure virtual method signature is collected
+  // once.
+  if (M->isPureVirtual() &&
+  VisitedCanonicalMethods.insert(M->getCanonicalDecl()).second) {
+Result.emplace_back(M); // Store the specific declaration encountered.
+  }
+}
+
+for (const auto &BaseSpec : Def->bases()) {
+  if (const CXXRecordDecl *BaseDef =
+  BaseSpec.getType()->getAsCXXRecordDecl()) {
+Collect(BaseDef); // Recursively collect from base classes.
+  }
+}
+  };
+
+  Collect(Decl);
+  return Result;
+}
+
+// Gets canonical declarations of methods already overridden or implemented in
+// class D.
+std::set
+getImplementedOrOverriddenCanonicals(const CXXRecordDecl *D) {
+  std::set ImplementedSet;
+  for (const CXXMethodDecl *M : D->methods()) {
+// If M provides an implementation for any virtual method it overrides.
+// A method is an "implementation" if it's virtual and not pure.
+// Or if it directly overrides a base method.
+for (const CXXMethodDecl *OverriddenM : M->overridden_methods()) {
+  ImplementedSet.insert(OverriddenM->getCanonicalDecl());
+}
+  }
+  return ImplementedSet;
+}
+
+// Get the location of every colon of the `AccessSpecifier`.
+std::map
+getSpecifierLocations(const CXXRecordDecl *D) {
+  std::map Locs;
+  for (auto *DeclNode : D->decls()) { // Changed to DeclNode to avoid ambiguity
+if (const auto *ASD = llvm::dyn_cast(DeclNode)) {
+  Locs[ASD->getAccess()] = ASD->getColonLoc();
+}
+  }
+  return Locs;
+}
+
+// Check if the current class has any pure virtual method to be implemented.
+bool OverridePureVirtuals::prepare(const Selection &Sel) {
+  const SelectionTree::Node *Node = Sel.ASTSelection.commonAncestor();
+  if (!Node) {
+return false;
+  }
+
+  // Make sure we have a definition.
+  CurrentDecl = Node->ASTNode.get();
+  if (!CurrentDecl || !CurrentDecl->getDefinition()) {
+return false;
+  }
+
+  // A class needs overrides if it's abstract itself, or derives from abstract
+  // bases and hasn't implemented all necessary methods. A simpler check: if it
+  // has any base that is abstract.
+  bool HasAbstractBase = false;
+  for (const auto &Base : CurrentDecl->bases()) {
+if (const CXXRecordDecl *BaseDecl = Base.getType()->getAsCXXRecordDecl()) {
+  if 

[clang-tools-extra] Enforce SL.con.3: Add check to replace operator[] with at() [Cont.] (PR #95220)

2025-05-10 Thread Baranov Victor via cfe-commits
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= 
Message-ID:
In-Reply-To: 


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


[clang] [clang] Add managarm support (PR #139271)

2025-05-10 Thread Brad Smith via cfe-commits

brad0 wrote:

cc @MaskRay 

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


[clang-tools-extra] [clangd] Add tweak to add pure virtual overrides (PR #139348)

2025-05-10 Thread Marco Maia via cfe-commits

https://github.com/marcogmaia updated 
https://github.com/llvm/llvm-project/pull/139348



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[clang] [clang] Add managarm support (PR #139271)

2025-05-10 Thread Fangrui Song via cfe-commits


@@ -228,6 +228,8 @@ static const char *getLDMOption(const llvm::Triple &T, 
const ArgList &Args) {
   return "elf_iamcu";
 return "elf_i386";
   case llvm::Triple::aarch64:
+if (T.isOSManagarm())
+  return "aarch64managarm";

MaskRay wrote:

Is this tested?

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


[clang] [clang] Add managarm support (PR #139271)

2025-05-10 Thread Fangrui Song via cfe-commits


@@ -1622,6 +1622,11 @@
 // RUN: %clang_cc1 -x c -std=c99 -E -dM -ffreestanding 
-triple=amd64-unknown-openbsd < /dev/null | FileCheck -match-full-lines 
-check-prefix OPENBSD-STDC-N %s
 // OPENBSD-STDC-N-NOT:#define __STDC_NO_THREADS__ 1
 //
+// RUN: %clang_cc1 -triple=aarch64-unknown-managarm-mlibc -E -dM < /dev/null | 
FileCheck -match-full-lines -check-prefix MANAGARM %s
+// RUN: %clang_cc1 -triple=riscv64-unknown-managarm-mlibc -E -dM < /dev/null | 
FileCheck -match-full-lines -check-prefix MANAGARM %s
+// RUN: %clang_cc1 -triple=x86_64-unknown-managarm-mlibc -E -dM < /dev/null | 
FileCheck -match-full-lines -check-prefix MANAGARM %s
+// MANAGARM: #define __managarm__ 1
+//

MaskRay wrote:

When you are adding new lines, follow the recommended practice and `s/^\/\/$//`

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


[clang] [clang] Add managarm support (PR #139271)

2025-05-10 Thread Fangrui Song via cfe-commits

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


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


[clang] [clang] Add managarm support (PR #139271)

2025-05-10 Thread Fangrui Song via cfe-commits

MaskRay wrote:

You might want to test two configurations to ensure that -rtlib= -stdlib= 
-unwindlib= defaults do not make the new test fail.

* default
* -DCLANG_DEFAULT_RTLIB=compiler-rt -DCLANG_DEFAULT_UNWINDLIB=libunwind 
-DCLANG_DEFAULT_CXX_STDLIB=libc++


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


[clang] [TableGen] Use std::tie to Implment operator< (NFC) (PR #139405)

2025-05-10 Thread Kazu Hirata via cfe-commits

https://github.com/kazutakahirata created 
https://github.com/llvm/llvm-project/pull/139405

None



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[clang] [libcxx] [llvm] [Clang] Add warnings when mixing different charN_t types (PR #138708)

2025-05-10 Thread via cfe-commits

https://github.com/cor3ntin updated 
https://github.com/llvm/llvm-project/pull/138708

>From c23bf23ddc8e1c8f50a57fcaf74682e86d8ade16 Mon Sep 17 00:00:00 2001
From: Corentin Jabot 
Date: Tue, 6 May 2025 17:14:35 +0200
Subject: [PATCH 1/6] [Clang] Add warnings when mixing different charN_t types

charN_t represent code units of different UTF encodings.
Therefore the values of 2 different charN_t objects do not represent
the same characters.

In order to avoid comparing apples and oranges, we add new warnings to
warn on:
  - Implicit conversions
  - Comparisons
  - Other cases involving arithmetic conversions

We only produce the warning if we cannot establish the comparison
would be safe through constant evaluation.

The new `-Wimplicit-unicode-conversion` warning is enabled by default.

Note that this PR intentionally doesn;t touches char/wchar_t,
but it would be worth considering also warning on extending the new
warnings to these types (in a follow up)

Additionally most arithmetic operations on charN_t
don't really make sense (ie what does it mean to addition code units),
so we could add warnings for that.

Fixes #138526
---
 clang/docs/ReleaseNotes.rst   |   4 +
 clang/include/clang/AST/ASTDiagnostic.h   |   3 +
 clang/include/clang/AST/Type.h|   1 +
 clang/include/clang/Basic/DiagnosticGroups.td |   1 +
 .../clang/Basic/DiagnosticSemaKinds.td|  25 +++
 clang/lib/AST/ASTDiagnostic.cpp   |  29 
 clang/lib/AST/Type.cpp|  14 ++
 clang/lib/Sema/SemaChecking.cpp   |  48 ++
 clang/lib/Sema/SemaExpr.cpp   |  71 
 .../warn-implicit-unicode-conversions.cpp | 155 ++
 llvm/include/llvm/Support/ConvertUTF.h|   4 +
 llvm/lib/Support/ConvertUTFWrapper.cpp|  10 ++
 12 files changed, 365 insertions(+)
 create mode 100644 clang/test/SemaCXX/warn-implicit-unicode-conversions.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 203958dab7430..3a42f43d79fd1 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -503,6 +503,10 @@ Improvements to Clang's diagnostics
 - ``-Wreserved-identifier`` now fires on reserved parameter names in a function
   declaration which is not a definition.
 
+- A new ``-Wimplicit-unicode-conversion`` warns where comparing or implicitly 
converting
+  between different Unicode character types (``char8_t``, ``char16_t``, 
``char32_t``).
+  This warning only triggers in C++ as these types are aliases in C. 
(#GH138526)
+
 Improvements to Clang's time-trace
 --
 
diff --git a/clang/include/clang/AST/ASTDiagnostic.h 
b/clang/include/clang/AST/ASTDiagnostic.h
index ef22249828629..baa410e3e4a03 100644
--- a/clang/include/clang/AST/ASTDiagnostic.h
+++ b/clang/include/clang/AST/ASTDiagnostic.h
@@ -38,6 +38,9 @@ namespace clang {
   /// is initialized before passing it in.
   QualType desugarForDiagnostic(ASTContext &Context, QualType QT,
 bool &ShouldAKA);
+
+  std::string FormatUTFCodeUnitAsCodepoint(unsigned Value, QualType T);
+
 }  // end namespace clang
 
 #endif
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 02a6fb5333538..7fca11fb708cf 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -2524,6 +2524,7 @@ class alignas(TypeAlignment) Type : public 
ExtQualsTypeCommonBase {
   bool isChar16Type() const;
   bool isChar32Type() const;
   bool isAnyCharacterType() const;
+  bool isUnicodeCharacterType() const;
   bool isIntegralType(const ASTContext &Ctx) const;
 
   /// Determine whether this type is an integral or enumeration type.
diff --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 1faf8508121f4..e5b5dbbd07f10 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -111,6 +111,7 @@ def EnumConversion : DiagGroup<"enum-conversion",
 ImplicitEnumEnumCast,
 EnumFloatConversion,
 EnumCompareConditional]>;
+def ImplicitUnicodeConversion : DiagGroup<"implicit-unicode-conversion">;
 def DeprecatedOFast : DiagGroup<"deprecated-ofast">;
 def ObjCSignedCharBoolImplicitIntConversion :
   DiagGroup<"objc-signed-char-bool-implicit-int-conversion">;
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index e5a7cdc14a737..a018f6693cff2 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -4357,6 +4357,26 @@ def warn_address_of_reference_bool_conversion : Warning<
   "code; pointer may be assumed to always convert to true">,
   InGroup;
 
+def warn_impcast_unicode_char_type : Warning<
+  "implicit conversion from %0 to %1 may change th

[clang-tools-extra] [modularize] Use a range-based for loop (NFC) (PR #139398)

2025-05-10 Thread Vitaly Buka via cfe-commits

vitalybuka wrote:

> sanitizer-aarch64-linux-bootstrap-asan

Sorry, this one caused by my zorg changes.

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


[clang] Better diagnostics when assertion fails in `consteval` (PR #130458)

2025-05-10 Thread JJ Marr via cfe-commits

https://github.com/jj-marr updated 
https://github.com/llvm/llvm-project/pull/130458



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[clang] Better diagnostics when assertion fails in `consteval` (PR #130458)

2025-05-10 Thread JJ Marr via cfe-commits


@@ -5975,9 +5975,15 @@ static bool CheckConstexprFunction(EvalInfo &Info, 
SourceLocation CallLoc,
 
Definition->hasAttr(
 return true;
 
-  if (Info.getLangOpts().CPlusPlus11) {
-const FunctionDecl *DiagDecl = Definition ? Definition : Declaration;
+  const FunctionDecl *DiagDecl = Definition ? Definition : Declaration;  
+  if (CallLoc.isMacroID() && (DiagDecl->getName() == "__assert_rtn" ||

jj-marr wrote:

Done for both.

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


[clang] [Clang] Stop changing DC when instantiating dependent friend specializations (PR #139436)

2025-05-10 Thread Younan Zhang via cfe-commits

https://github.com/zyn0217 created 
https://github.com/llvm/llvm-project/pull/139436

Since 346077aa, we began using the primary template's lexical DeclContext for 
template arguments in order to properly instantiate a friend definition.

There is a missed peculiar case, as in a friend template is specialized within 
a dependent context. In this scenario, the primary template is not a 
definition, whereas the specialization is. So the primary template's 
DeclContext doesn't provide any meaningful for instantiation.

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

>From 1756fbcd874097fdea256c2c5986810a011eafed Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Sun, 11 May 2025 12:54:12 +0800
Subject: [PATCH] [Clang] Stop looking for DC from dependent friend
 specializations

Since 346077aa, we began using the primary template's lexical
DeclContext for template arguments in order to properly instantiate
a friend definition.

There is a missed peculiar case, as in a friend template is specialized
within a dependent context. In this scenario, the primary template is
not a definition, whereas the specialization is. So the primary
template's DeclContext doesn't provide any meaningful for instantiation.
---
 clang/docs/ReleaseNotes.rst   |  2 +
 clang/lib/Sema/SemaDeclCXX.cpp|  2 +-
 .../lib/Sema/SemaTemplateInstantiateDecl.cpp  | 12 +++---
 clang/test/SemaTemplate/GH55509.cpp   | 38 +++
 4 files changed, 48 insertions(+), 6 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 1d0896f585fb4..c75ad0be8a8e6 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -576,6 +576,8 @@ Bug Fixes in This Version
   ``#include`` directive. (#GH138094)
 - Fixed a crash during constant evaluation involving invalid lambda captures
   (#GH138832)
+- Fixed a crash when instantiating an invalid dependent friend template 
specialization.
+  (#GH139052)
 
 Bug Fixes to Compiler Builtins
 ^^
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index cbccb567e2adf..d915448d0feb1 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -18740,7 +18740,7 @@ NamedDecl *Sema::ActOnFriendFunctionDecl(Scope *S, 
Declarator &D,
 // a template-id, the function name is not unqualified because these is
 // no name. While the wording requires some reading in-between the
 // lines, GCC, MSVC, and EDG all consider a friend function
-// specialization definitions // to be de facto explicit specialization
+// specialization definitions to be de facto explicit specialization
 // and diagnose them as such.
   } else if (isTemplateId) {
 Diag(NameInfo.getBeginLoc(), diag::err_friend_specialization_def);
diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp 
b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 08b3a423d1526..a8c3b28f8d185 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -5751,14 +5751,16 @@ void Sema::InstantiateFunctionDefinition(SourceLocation 
PointOfInstantiation,
 RebuildTypeSourceInfoForDefaultSpecialMembers();
 SetDeclDefaulted(Function, PatternDecl->getLocation());
   } else {
-NamedDecl *ND = Function;
-DeclContext *DC = ND->getLexicalDeclContext();
+DeclContext *DC = Function->getLexicalDeclContext();
 std::optional> Innermost;
-if (auto *Primary = Function->getPrimaryTemplate();
-Primary &&
+bool NeedDCFromPrimaryTemplate =
 !isGenericLambdaCallOperatorOrStaticInvokerSpecialization(Function) &&
 Function->getTemplateSpecializationKind() !=
-TSK_ExplicitSpecialization) {
+TSK_ExplicitSpecialization &&
+!PatternDecl->getDependentSpecializationInfo();
+
+if (auto *Primary = Function->getPrimaryTemplate();
+Primary && NeedDCFromPrimaryTemplate) {
   auto It = llvm::find_if(Primary->redecls(),
   [](const RedeclarableTemplateDecl *RTD) {
 return cast(RTD)
diff --git a/clang/test/SemaTemplate/GH55509.cpp 
b/clang/test/SemaTemplate/GH55509.cpp
index 773a84305a0cd..f421e5a8fc237 100644
--- a/clang/test/SemaTemplate/GH55509.cpp
+++ b/clang/test/SemaTemplate/GH55509.cpp
@@ -110,3 +110,41 @@ namespace regression2 {
   }
   template void A::f();
 } // namespace regression2
+
+namespace GH139226 {
+
+struct FakeStream {};
+
+template 
+class BinaryTree;
+
+template 
+FakeStream& operator<<(FakeStream& os, BinaryTree& b); // #1
+
+template 
+FakeStream& operator>>(FakeStream& os, BinaryTree& b) {
+  return os;
+}
+
+template 
+struct BinaryTree {
+  T* root{};
+  // This template is described using a DependentSpecializationInfo, and its 
instantiations
+  // are tracked with TSK_ImplicitInstantiation kind.
+  // The primary template is declare

[clang] [Clang] Stop changing DC when instantiating dependent friend specializations (PR #139436)

2025-05-10 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Younan Zhang (zyn0217)


Changes

Since 346077aa, we began using the primary template's lexical DeclContext for 
template arguments in order to properly instantiate a friend definition.

There is a missed peculiar case, as in a friend template is specialized within 
a dependent context. In this scenario, the primary template is not a 
definition, whereas the specialization is. So the primary template's 
DeclContext doesn't provide any meaningful for instantiation.

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

---
Full diff: https://github.com/llvm/llvm-project/pull/139436.diff


4 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+2) 
- (modified) clang/lib/Sema/SemaDeclCXX.cpp (+1-1) 
- (modified) clang/lib/Sema/SemaTemplateInstantiateDecl.cpp (+7-5) 
- (modified) clang/test/SemaTemplate/GH55509.cpp (+38) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 1d0896f585fb4..c75ad0be8a8e6 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -576,6 +576,8 @@ Bug Fixes in This Version
   ``#include`` directive. (#GH138094)
 - Fixed a crash during constant evaluation involving invalid lambda captures
   (#GH138832)
+- Fixed a crash when instantiating an invalid dependent friend template 
specialization.
+  (#GH139052)
 
 Bug Fixes to Compiler Builtins
 ^^
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index cbccb567e2adf..d915448d0feb1 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -18740,7 +18740,7 @@ NamedDecl *Sema::ActOnFriendFunctionDecl(Scope *S, 
Declarator &D,
 // a template-id, the function name is not unqualified because these is
 // no name. While the wording requires some reading in-between the
 // lines, GCC, MSVC, and EDG all consider a friend function
-// specialization definitions // to be de facto explicit specialization
+// specialization definitions to be de facto explicit specialization
 // and diagnose them as such.
   } else if (isTemplateId) {
 Diag(NameInfo.getBeginLoc(), diag::err_friend_specialization_def);
diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp 
b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 08b3a423d1526..a8c3b28f8d185 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -5751,14 +5751,16 @@ void Sema::InstantiateFunctionDefinition(SourceLocation 
PointOfInstantiation,
 RebuildTypeSourceInfoForDefaultSpecialMembers();
 SetDeclDefaulted(Function, PatternDecl->getLocation());
   } else {
-NamedDecl *ND = Function;
-DeclContext *DC = ND->getLexicalDeclContext();
+DeclContext *DC = Function->getLexicalDeclContext();
 std::optional> Innermost;
-if (auto *Primary = Function->getPrimaryTemplate();
-Primary &&
+bool NeedDCFromPrimaryTemplate =
 !isGenericLambdaCallOperatorOrStaticInvokerSpecialization(Function) &&
 Function->getTemplateSpecializationKind() !=
-TSK_ExplicitSpecialization) {
+TSK_ExplicitSpecialization &&
+!PatternDecl->getDependentSpecializationInfo();
+
+if (auto *Primary = Function->getPrimaryTemplate();
+Primary && NeedDCFromPrimaryTemplate) {
   auto It = llvm::find_if(Primary->redecls(),
   [](const RedeclarableTemplateDecl *RTD) {
 return cast(RTD)
diff --git a/clang/test/SemaTemplate/GH55509.cpp 
b/clang/test/SemaTemplate/GH55509.cpp
index 773a84305a0cd..f421e5a8fc237 100644
--- a/clang/test/SemaTemplate/GH55509.cpp
+++ b/clang/test/SemaTemplate/GH55509.cpp
@@ -110,3 +110,41 @@ namespace regression2 {
   }
   template void A::f();
 } // namespace regression2
+
+namespace GH139226 {
+
+struct FakeStream {};
+
+template 
+class BinaryTree;
+
+template 
+FakeStream& operator<<(FakeStream& os, BinaryTree& b); // #1
+
+template 
+FakeStream& operator>>(FakeStream& os, BinaryTree& b) {
+  return os;
+}
+
+template 
+struct BinaryTree {
+  T* root{};
+  // This template is described using a DependentSpecializationInfo, and its 
instantiations
+  // are tracked with TSK_ImplicitInstantiation kind.
+  // The primary template is declared at #1.
+  friend FakeStream& operator<< (FakeStream& os, BinaryTree&) {
+// expected-error@-1 {{friend function specialization cannot be defined}}
+return os;
+  }
+
+  friend FakeStream& operator>> (FakeStream& os, BinaryTree&);
+};
+
+void foo() {
+  FakeStream fakeout;
+  BinaryTree a{};
+  fakeout << a;
+  fakeout >> a;
+}
+
+}

``




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


[clang] [Tooling] Remove a redundant call to std::unique_ptr::get (NFC) (PR #139431)

2025-05-10 Thread Shilei Tian via cfe-commits

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


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


[clang] ac9b778 - [Tooling] Remove a redundant call to std::unique_ptr::get (NFC) (#139431)

2025-05-10 Thread via cfe-commits

Author: Kazu Hirata
Date: 2025-05-10T22:51:06-07:00
New Revision: ac9b7788de773b70229efa7b56d19db20f51fe85

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

LOG: [Tooling] Remove a redundant call to std::unique_ptr::get (NFC) 
(#139431)

Added: 


Modified: 

clang/unittests/Tooling/DependencyScanning/DependencyScanningFilesystemTest.cpp

Removed: 




diff  --git 
a/clang/unittests/Tooling/DependencyScanning/DependencyScanningFilesystemTest.cpp
 
b/clang/unittests/Tooling/DependencyScanning/DependencyScanningFilesystemTest.cpp
index aed793785f7b1..7420743c97a2a 100644
--- 
a/clang/unittests/Tooling/DependencyScanning/DependencyScanningFilesystemTest.cpp
+++ 
b/clang/unittests/Tooling/DependencyScanning/DependencyScanningFilesystemTest.cpp
@@ -197,7 +197,7 @@ TEST(DependencyScanningFilesystem, 
DiagnoseStaleStatFailures) {
   EXPECT_EQ(Path1Exists, false);
 
   std::vector InvalidPaths =
-  SharedCache.getInvalidNegativeStatCachedPaths(*InMemoryFS.get());
+  SharedCache.getInvalidNegativeStatCachedPaths(*InMemoryFS);
 
   EXPECT_EQ(InvalidPaths.size(), 1u);
   ASSERT_STREQ("/path1.suffix", InvalidPaths[0].str().c_str());



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


[clang] [Tooling] Remove a redundant call to std::unique_ptr::get (NFC) (PR #139431)

2025-05-10 Thread Kazu Hirata via cfe-commits

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


[clang] [clang] Use std::tie to implement operator< (NFC) (PR #139438)

2025-05-10 Thread Kazu Hirata via cfe-commits

https://github.com/kazutakahirata created 
https://github.com/llvm/llvm-project/pull/139438

None



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[clang] [clang] Use std::tie to implement operator< (NFC) (PR #139438)

2025-05-10 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-static-analyzer-1

Author: Kazu Hirata (kazutakahirata)


Changes



---
Full diff: https://github.com/llvm/llvm-project/pull/139438.diff


3 Files Affected:

- (modified) clang/include/clang/Driver/Compilation.h (+2-8) 
- (modified) clang/lib/Frontend/FrontendAction.cpp (+1-5) 
- (modified) clang/lib/StaticAnalyzer/Checkers/TestAfterDivZeroChecker.cpp 
(+2-5) 


``diff
diff --git a/clang/include/clang/Driver/Compilation.h 
b/clang/include/clang/Driver/Compilation.h
index 36ae85c424514..26781fc676832 100644
--- a/clang/include/clang/Driver/Compilation.h
+++ b/clang/include/clang/Driver/Compilation.h
@@ -90,14 +90,8 @@ class Compilation {
 : TC(TC), BoundArch(BoundArch), DeviceOffloadKind(DeviceOffloadKind) {}
 
 bool operator<(const TCArgsKey &K) const {
-  if (TC < K.TC)
-return true;
-  else if (TC == K.TC && BoundArch < K.BoundArch)
-return true;
-  else if (TC == K.TC && BoundArch == K.BoundArch &&
-   DeviceOffloadKind < K.DeviceOffloadKind)
-return true;
-  return false;
+  return std::tie(TC, BoundArch, DeviceOffloadKind) <
+ std::tie(K.TC, K.BoundArch, K.DeviceOffloadKind);
 }
   };
   std::map TCArgs;
diff --git a/clang/lib/Frontend/FrontendAction.cpp 
b/clang/lib/Frontend/FrontendAction.cpp
index f09eb9832e692..54a2e3eb297f5 100644
--- a/clang/lib/Frontend/FrontendAction.cpp
+++ b/clang/lib/Frontend/FrontendAction.cpp
@@ -100,11 +100,7 @@ class DeserializedDeclsSourceRangePrinter : public 
ASTConsumer,
 unsigned Column;
 
 bool operator<(const Position &other) const {
-  if (Line < other.Line)
-return true;
-  if (Line > other.Line)
-return false;
-  return Column < other.Column;
+  return std::tie(Line, Column) < std::tie(other.Line, other.Column);
 }
 
 static Position GetBeginSpelling(const SourceManager &SM,
diff --git a/clang/lib/StaticAnalyzer/Checkers/TestAfterDivZeroChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/TestAfterDivZeroChecker.cpp
index 667b19f8120ea..77cec7deffb84 100644
--- a/clang/lib/StaticAnalyzer/Checkers/TestAfterDivZeroChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/TestAfterDivZeroChecker.cpp
@@ -41,11 +41,8 @@ class ZeroState {
   }
 
   bool operator<(const ZeroState &X) const {
-if (BlockID != X.BlockID)
-  return BlockID < X.BlockID;
-if (SFC != X.SFC)
-  return SFC < X.SFC;
-return ZeroSymbol < X.ZeroSymbol;
+return std::tie(BlockID, SFC, ZeroSymbol) <
+   std::tie(X.BlockID, X.SFC, X.ZeroSymbol);
   }
 
   void Profile(llvm::FoldingSetNodeID &ID) const {

``




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


[clang] [Clang] Enable -fextend-lifetimes at -Og (PR #118026)

2025-05-10 Thread Fangrui Song via cfe-commits

MaskRay wrote:

Since the option has been renamed to `-fextend-variable-liveness`, I think you 
want to edit this title and the description to reflect the naming change as 
well. I wanted to check the status the effort and I tried `git log --grep 
fextend-lifetimes` but found nothing, then I realized that the option has been 
renamed :)

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


[clang] [ItaniumMangle] Make sure class types are added to the dictionary of substitution candidates when compiling for older ABIs (PR #138947)

2025-05-10 Thread via cfe-commits

tcwzxx wrote:

> > Given that the mangleCXXRecordDecl function is used outside of the 
> > `MangleVTable` , I think the ABI compatibility logic should be moved to 
> > mangleCXXCtorVTable
> 
> Could you elaborate on how to separate just the ABI compatibility logic from 
> `mangleCXXRecordDecl`?
> 
> Wouldn't you have to move the code to `mangleCXXVTable` and `mangleCXXVTT` 
> too? I'm not sure we want to duplicate code in multiple functions.

This compatibility occurs only here. My last patch wasn't perfect.



```C++
void mangleCXXRecordDecl(const CXXRecordDecl *Record, bool 
DontAddSubstitutionForCompat = false);

void ItaniumMangleContextImpl::mangleCXXCtorVTable(const CXXRecordDecl *RD,
   int64_t Offset,
   const CXXRecordDecl *Type,
   raw_ostream &Out) {
  //  ::= TC   _ 
  CXXNameMangler Mangler(*this, Out);
  Mangler.getStream() << "_ZTC";
  bool CompatibilityForV19   = 
getASTContext().getLangOpts().getClangABICompat() <=
clang::LangOptionsBase::ClangABI::Ver19;
  Mangler.mangleCXXRecordDecl(RD, CompatibilityForV19);
  Mangler.getStream() << Offset;
  Mangler.getStream() << '_';
  Mangler.mangleCXXRecordDecl(Type);
}

```

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


[clang] [clang-format] Fix a bug in annotating binary operator && (PR #138633)

2025-05-10 Thread Owen Pan via cfe-commits

owenca wrote:

> @owenca, I actually think that this introduced a regression that was 
> previously fixed in the nightly snapshot of `clang-format-21`.

It was an incidental "fix" by 91328dbae986dfa93cf2acef0a93361fd5ced66d, which 
caused a regression that's fixed by this patch.

> ```
> $ cat foo.cpp
> template 
> using invoke_result_t = typename std::result_of::type;
> $ clang-format-20 foo.cpp
> template 
> using invoke_result_t = typename std::result_of::type;
> ```

Please open an issue for this.

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


[clang] [flang] [llvm] [openmp] [Clang][OpenMP][LoopTransformations] Add support for "#pragma omp fuse" loop transformation direcrive and "looprange" clause (PR #139293)

2025-05-10 Thread Walter J.T.V via cfe-commits

eZWALT wrote:

I want to notify that the following week I'll be unavailable, so expect this 
patch to be updated on the 20th of May. Thanks for the feedback @alexey-bataev 

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


[clang] [llvm] [RISCV][MC] Add support for Q extension (PR #139369)

2025-05-10 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-risc-v

Author: Iris Shi (el-ev)


Changes

Closes #130217.

https://github.com/riscv/riscv-isa-manual/blob/main/src/q-st-ext.adoc

---

Patch is 62.40 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/139369.diff


35 Files Affected:

- (modified) clang/test/Driver/print-supported-extensions-riscv.c (+1) 
- (modified) clang/test/Driver/riscv-arch.c (+16-10) 
- (modified) clang/test/Preprocessor/riscv-target-features.c (+12) 
- (modified) llvm/docs/RISCVUsage.rst (+1) 
- (modified) llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp (+9) 
- (modified) llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp (+11) 
- (modified) llvm/lib/Target/RISCV/RISCVFeatures.td (+7) 
- (modified) llvm/lib/Target/RISCV/RISCVInstrInfo.td (+1) 
- (modified) llvm/lib/Target/RISCV/RISCVInstrInfoD.td (+4-4) 
- (modified) llvm/lib/Target/RISCV/RISCVInstrInfoF.td (+5-3) 
- (added) llvm/lib/Target/RISCV/RISCVInstrInfoQ.td (+168) 
- (modified) llvm/lib/Target/RISCV/RISCVInstrInfoZfh.td (+29-27) 
- (modified) llvm/lib/Target/RISCV/RISCVRegisterInfo.td (+18) 
- (modified) llvm/lib/Target/RISCV/RISCVSchedGenericOOO.td (+1) 
- (modified) llvm/lib/Target/RISCV/RISCVSchedMIPSP8700.td (+1) 
- (modified) llvm/lib/Target/RISCV/RISCVSchedRocket.td (+1) 
- (modified) llvm/lib/Target/RISCV/RISCVSchedSiFive7.td (+1) 
- (modified) llvm/lib/Target/RISCV/RISCVSchedSiFiveP400.td (+1) 
- (modified) llvm/lib/Target/RISCV/RISCVSchedSiFiveP500.td (+1) 
- (modified) llvm/lib/Target/RISCV/RISCVSchedSiFiveP600.td (+1) 
- (modified) llvm/lib/Target/RISCV/RISCVSchedSpacemitX60.td (+1) 
- (modified) llvm/lib/Target/RISCV/RISCVSchedSyntacoreSCR345.td (+3-3) 
- (modified) llvm/lib/Target/RISCV/RISCVSchedSyntacoreSCR7.td (+1) 
- (modified) llvm/lib/Target/RISCV/RISCVSchedTTAscalonD8.td (+1) 
- (modified) llvm/lib/Target/RISCV/RISCVSchedXiangShanNanHu.td (+1) 
- (modified) llvm/lib/Target/RISCV/RISCVSchedule.td (+126-43) 
- (modified) llvm/lib/Target/RISCV/RISCVSubtarget.h (+3) 
- (modified) llvm/lib/TargetParser/RISCVISAInfo.cpp (+3-2) 
- (modified) llvm/test/CodeGen/RISCV/attributes.ll (+4) 
- (modified) llvm/test/CodeGen/RISCV/features-info.ll (+1) 
- (added) llvm/test/MC/RISCV/rv32q-invalid.s (+21) 
- (added) llvm/test/MC/RISCV/rv64q-invalid.s (+9) 
- (added) llvm/test/MC/RISCV/rv64q-valid.s (+43) 
- (added) llvm/test/MC/RISCV/rvq-valid.s (+184) 
- (modified) llvm/unittests/TargetParser/RISCVISAInfoTest.cpp (+1) 


``diff
diff --git a/clang/test/Driver/print-supported-extensions-riscv.c 
b/clang/test/Driver/print-supported-extensions-riscv.c
index b10850aadddc3..cbadb86f006f4 100644
--- a/clang/test/Driver/print-supported-extensions-riscv.c
+++ b/clang/test/Driver/print-supported-extensions-riscv.c
@@ -10,6 +10,7 @@
 // CHECK-NEXT: a2.1   'A' (Atomic Instructions)
 // CHECK-NEXT: f2.2   'F' (Single-Precision 
Floating-Point)
 // CHECK-NEXT: d2.2   'D' (Double-Precision 
Floating-Point)
+// CHECK-NEXT: q2.2   'Q' (Quad-Precision 
Floating-Point)
 // CHECK-NEXT: c2.0   'C' (Compressed Instructions)
 // CHECK-NEXT: b1.0   'B' (the collection of the 
Zba, Zbb, Zbs extensions)
 // CHECK-NEXT: v1.0   'V' (Vector Extension for 
Application Processors)
diff --git a/clang/test/Driver/riscv-arch.c b/clang/test/Driver/riscv-arch.c
index 018fa25218ea6..32e7c0d44b243 100644
--- a/clang/test/Driver/riscv-arch.c
+++ b/clang/test/Driver/riscv-arch.c
@@ -10,6 +10,8 @@
 // RUN: -fsyntax-only 2>&1 | FileCheck %s
 // RUN: %clang --target=riscv32-unknown-elf -march=rv32imafd -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck %s
+// RUN: %clang --target=riscv32-unknown-elf -march=rv32imafdq -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck %s
 
 // RUN: %clang --target=riscv32-unknown-elf -march=rv32ic -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck %s
@@ -21,6 +23,8 @@
 // RUN: -fsyntax-only 2>&1 | FileCheck %s
 // RUN: %clang --target=riscv32-unknown-elf -march=rv32imafdc -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck %s
+// RUN: %clang --target=riscv32-unknown-elf -march=rv32imafdqc -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck %s
 
 // RUN: %clang --target=riscv32-unknown-elf -march=rv32ia -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck %s
@@ -28,6 +32,8 @@
 // RUN: -fsyntax-only 2>&1 | FileCheck %s
 // RUN: %clang --target=riscv32-unknown-elf -march=rv32iafd -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck %s
+// RUN: %clang --target=riscv32-unknown-elf -march=rv32iafdq -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck %s
 
 // RUN: %clang --target=riscv32-unknown-elf -march=rv32iac -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck %s
@@ -35,6 +41,8 @@
 // RUN: -fsyntax-only 2>&1 | FileCheck %s
 // RUN: %clang --target=riscv32-unknown-elf -march=rv32iafdc -### %s \
 // RUN

[clang] [llvm] [RISCV][MC] Add support for Q extension (PR #139369)

2025-05-10 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-driver

Author: Iris Shi (el-ev)


Changes

Closes #130217.

https://github.com/riscv/riscv-isa-manual/blob/main/src/q-st-ext.adoc

---
Full diff: https://github.com/llvm/llvm-project/pull/139369.diff


35 Files Affected:

- (modified) clang/test/Driver/print-supported-extensions-riscv.c (+1) 
- (modified) clang/test/Driver/riscv-arch.c (+16-10) 
- (modified) clang/test/Preprocessor/riscv-target-features.c (+12) 
- (modified) llvm/docs/RISCVUsage.rst (+1) 
- (modified) llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp (+9) 
- (modified) llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp (+11) 
- (modified) llvm/lib/Target/RISCV/RISCVFeatures.td (+7) 
- (modified) llvm/lib/Target/RISCV/RISCVInstrInfo.td (+1) 
- (modified) llvm/lib/Target/RISCV/RISCVInstrInfoD.td (+4-4) 
- (modified) llvm/lib/Target/RISCV/RISCVInstrInfoF.td (+5-3) 
- (added) llvm/lib/Target/RISCV/RISCVInstrInfoQ.td (+168) 
- (modified) llvm/lib/Target/RISCV/RISCVInstrInfoZfh.td (+29-27) 
- (modified) llvm/lib/Target/RISCV/RISCVRegisterInfo.td (+18) 
- (modified) llvm/lib/Target/RISCV/RISCVSchedGenericOOO.td (+1) 
- (modified) llvm/lib/Target/RISCV/RISCVSchedMIPSP8700.td (+1) 
- (modified) llvm/lib/Target/RISCV/RISCVSchedRocket.td (+1) 
- (modified) llvm/lib/Target/RISCV/RISCVSchedSiFive7.td (+1) 
- (modified) llvm/lib/Target/RISCV/RISCVSchedSiFiveP400.td (+1) 
- (modified) llvm/lib/Target/RISCV/RISCVSchedSiFiveP500.td (+1) 
- (modified) llvm/lib/Target/RISCV/RISCVSchedSiFiveP600.td (+1) 
- (modified) llvm/lib/Target/RISCV/RISCVSchedSpacemitX60.td (+1) 
- (modified) llvm/lib/Target/RISCV/RISCVSchedSyntacoreSCR345.td (+3-3) 
- (modified) llvm/lib/Target/RISCV/RISCVSchedSyntacoreSCR7.td (+1) 
- (modified) llvm/lib/Target/RISCV/RISCVSchedTTAscalonD8.td (+1) 
- (modified) llvm/lib/Target/RISCV/RISCVSchedXiangShanNanHu.td (+1) 
- (modified) llvm/lib/Target/RISCV/RISCVSchedule.td (+126-43) 
- (modified) llvm/lib/Target/RISCV/RISCVSubtarget.h (+3) 
- (modified) llvm/lib/TargetParser/RISCVISAInfo.cpp (+3-2) 
- (modified) llvm/test/CodeGen/RISCV/attributes.ll (+4) 
- (modified) llvm/test/CodeGen/RISCV/features-info.ll (+1) 
- (added) llvm/test/MC/RISCV/rv32q-invalid.s (+21) 
- (added) llvm/test/MC/RISCV/rv64q-invalid.s (+9) 
- (added) llvm/test/MC/RISCV/rv64q-valid.s (+43) 
- (added) llvm/test/MC/RISCV/rvq-valid.s (+184) 
- (modified) llvm/unittests/TargetParser/RISCVISAInfoTest.cpp (+1) 


``diff


  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


``




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


[clang] [llvm] [RISCV][MC] Add support for Q extension (PR #139369)

2025-05-10 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-mc

@llvm/pr-subscribers-clang

Author: Iris Shi (el-ev)


Changes

Closes #130217.

https://github.com/riscv/riscv-isa-manual/blob/main/src/q-st-ext.adoc

---

Patch is 62.40 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/139369.diff


35 Files Affected:

- (modified) clang/test/Driver/print-supported-extensions-riscv.c (+1) 
- (modified) clang/test/Driver/riscv-arch.c (+16-10) 
- (modified) clang/test/Preprocessor/riscv-target-features.c (+12) 
- (modified) llvm/docs/RISCVUsage.rst (+1) 
- (modified) llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp (+9) 
- (modified) llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp (+11) 
- (modified) llvm/lib/Target/RISCV/RISCVFeatures.td (+7) 
- (modified) llvm/lib/Target/RISCV/RISCVInstrInfo.td (+1) 
- (modified) llvm/lib/Target/RISCV/RISCVInstrInfoD.td (+4-4) 
- (modified) llvm/lib/Target/RISCV/RISCVInstrInfoF.td (+5-3) 
- (added) llvm/lib/Target/RISCV/RISCVInstrInfoQ.td (+168) 
- (modified) llvm/lib/Target/RISCV/RISCVInstrInfoZfh.td (+29-27) 
- (modified) llvm/lib/Target/RISCV/RISCVRegisterInfo.td (+18) 
- (modified) llvm/lib/Target/RISCV/RISCVSchedGenericOOO.td (+1) 
- (modified) llvm/lib/Target/RISCV/RISCVSchedMIPSP8700.td (+1) 
- (modified) llvm/lib/Target/RISCV/RISCVSchedRocket.td (+1) 
- (modified) llvm/lib/Target/RISCV/RISCVSchedSiFive7.td (+1) 
- (modified) llvm/lib/Target/RISCV/RISCVSchedSiFiveP400.td (+1) 
- (modified) llvm/lib/Target/RISCV/RISCVSchedSiFiveP500.td (+1) 
- (modified) llvm/lib/Target/RISCV/RISCVSchedSiFiveP600.td (+1) 
- (modified) llvm/lib/Target/RISCV/RISCVSchedSpacemitX60.td (+1) 
- (modified) llvm/lib/Target/RISCV/RISCVSchedSyntacoreSCR345.td (+3-3) 
- (modified) llvm/lib/Target/RISCV/RISCVSchedSyntacoreSCR7.td (+1) 
- (modified) llvm/lib/Target/RISCV/RISCVSchedTTAscalonD8.td (+1) 
- (modified) llvm/lib/Target/RISCV/RISCVSchedXiangShanNanHu.td (+1) 
- (modified) llvm/lib/Target/RISCV/RISCVSchedule.td (+126-43) 
- (modified) llvm/lib/Target/RISCV/RISCVSubtarget.h (+3) 
- (modified) llvm/lib/TargetParser/RISCVISAInfo.cpp (+3-2) 
- (modified) llvm/test/CodeGen/RISCV/attributes.ll (+4) 
- (modified) llvm/test/CodeGen/RISCV/features-info.ll (+1) 
- (added) llvm/test/MC/RISCV/rv32q-invalid.s (+21) 
- (added) llvm/test/MC/RISCV/rv64q-invalid.s (+9) 
- (added) llvm/test/MC/RISCV/rv64q-valid.s (+43) 
- (added) llvm/test/MC/RISCV/rvq-valid.s (+184) 
- (modified) llvm/unittests/TargetParser/RISCVISAInfoTest.cpp (+1) 


``diff
diff --git a/clang/test/Driver/print-supported-extensions-riscv.c 
b/clang/test/Driver/print-supported-extensions-riscv.c
index b10850aadddc3..cbadb86f006f4 100644
--- a/clang/test/Driver/print-supported-extensions-riscv.c
+++ b/clang/test/Driver/print-supported-extensions-riscv.c
@@ -10,6 +10,7 @@
 // CHECK-NEXT: a2.1   'A' (Atomic Instructions)
 // CHECK-NEXT: f2.2   'F' (Single-Precision 
Floating-Point)
 // CHECK-NEXT: d2.2   'D' (Double-Precision 
Floating-Point)
+// CHECK-NEXT: q2.2   'Q' (Quad-Precision 
Floating-Point)
 // CHECK-NEXT: c2.0   'C' (Compressed Instructions)
 // CHECK-NEXT: b1.0   'B' (the collection of the 
Zba, Zbb, Zbs extensions)
 // CHECK-NEXT: v1.0   'V' (Vector Extension for 
Application Processors)
diff --git a/clang/test/Driver/riscv-arch.c b/clang/test/Driver/riscv-arch.c
index 018fa25218ea6..32e7c0d44b243 100644
--- a/clang/test/Driver/riscv-arch.c
+++ b/clang/test/Driver/riscv-arch.c
@@ -10,6 +10,8 @@
 // RUN: -fsyntax-only 2>&1 | FileCheck %s
 // RUN: %clang --target=riscv32-unknown-elf -march=rv32imafd -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck %s
+// RUN: %clang --target=riscv32-unknown-elf -march=rv32imafdq -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck %s
 
 // RUN: %clang --target=riscv32-unknown-elf -march=rv32ic -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck %s
@@ -21,6 +23,8 @@
 // RUN: -fsyntax-only 2>&1 | FileCheck %s
 // RUN: %clang --target=riscv32-unknown-elf -march=rv32imafdc -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck %s
+// RUN: %clang --target=riscv32-unknown-elf -march=rv32imafdqc -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck %s
 
 // RUN: %clang --target=riscv32-unknown-elf -march=rv32ia -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck %s
@@ -28,6 +32,8 @@
 // RUN: -fsyntax-only 2>&1 | FileCheck %s
 // RUN: %clang --target=riscv32-unknown-elf -march=rv32iafd -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck %s
+// RUN: %clang --target=riscv32-unknown-elf -march=rv32iafdq -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck %s
 
 // RUN: %clang --target=riscv32-unknown-elf -march=rv32iac -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck %s
@@ -35,6 +41,8 @@
 // RUN: -fsyntax-only 2>&1 | FileCheck %s
 // RUN: %clang --target=riscv32-unknown-elf -march=rv32iafdc -#

[clang-tools-extra] 0c83a0b - [modularize] Use default member initialization for Location (NFC) (#139384)

2025-05-10 Thread via cfe-commits

Author: Kazu Hirata
Date: 2025-05-10T09:45:56-07:00
New Revision: 0c83a0b7f4279c3ed9e8db14fbebae15145f4df2

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

LOG: [modularize] Use default member initialization for Location (NFC) (#139384)

Added: 


Modified: 
clang-tools-extra/modularize/Modularize.cpp

Removed: 




diff  --git a/clang-tools-extra/modularize/Modularize.cpp 
b/clang-tools-extra/modularize/Modularize.cpp
index 38979cb4d6911..bd180681c9154 100644
--- a/clang-tools-extra/modularize/Modularize.cpp
+++ b/clang-tools-extra/modularize/Modularize.cpp
@@ -379,11 +379,11 @@ getModularizeArgumentsAdjuster(DependencyMap 
&Dependencies) {
 // somewhere into Tooling/ in mainline
 struct Location {
   OptionalFileEntryRef File;
-  unsigned Line, Column;
+  unsigned Line = 0, Column = 0;
 
-  Location() : File(), Line(), Column() {}
+  Location() = default;
 
-  Location(SourceManager &SM, SourceLocation Loc) : File(), Line(), Column() {
+  Location(SourceManager &SM, SourceLocation Loc) {
 Loc = SM.getExpansionLoc(Loc);
 if (Loc.isInvalid())
   return;



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


[clang-tools-extra] [modularize] Use default member initialization for Location (NFC) (PR #139384)

2025-05-10 Thread Shilei Tian via cfe-commits

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


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


[clang-tools-extra] [modularize] Use default member initialization for Location (NFC) (PR #139384)

2025-05-10 Thread Kazu Hirata via cfe-commits

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


[clang] [Clang] Demote mixed enumeration arithmetic error to a warning (PR #131811)

2025-05-10 Thread via cfe-commits

cor3ntin wrote:

@tstellar it slipped my mind, I can do that later today though 

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


[clang-tools-extra] Enforce SL.con.3: Add check to replace operator[] with at() [Cont.] (PR #95220)

2025-05-10 Thread Paul Heidekrüger via cfe-commits

https://github.com/paulhdk updated 
https://github.com/llvm/llvm-project/pull/95220



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[clang-tools-extra] Enforce SL.con.3: Add check to replace operator[] with at() [Cont.] (PR #95220)

2025-05-10 Thread Paul Heidekrüger via cfe-commits


@@ -0,0 +1,50 @@
+.. title:: clang-tidy - 
cppcoreguidelines-pro-bounds-avoid-unchecked-container-accesses
+
+cppcoreguidelines-pro-bounds-avoid-unchecked-container-accesses
+===
+
+Flags calls to ``operator[]`` in STL containers and suggests replacing it with
+safe alternatives.
+
+For example, both
+
+.. code-block:: c++
+
+  std::vector a;
+  int b = a[4];
+
+and
+
+.. code-block:: c++
+
+  std::unique_ptr a;
+  int b = a[0];
+
+will generate a warning.
+
+STL containers with well-defined behavior for ``operator[]`` are excluded from 
this
+check.
+
+This check enforces part of the `SL.con.3
+`
+guideline and is part of the `Bounds Safety (Bounds 4)
+`
+profile from the C++ Core Guidelines.
+
+Options
+---
+
+.. option:: ExcludeClasses
+
+Semicolon-delimited list of class names that should additionally be
+excluded from this check. Default is empty string.
+
+.. option:: FixMode
+
+Determines what fixes are suggested. Either `None` (default), `at` (use 
+``a.at(index)`` if a fitting function exists) or `function` (use a 

paulhdk wrote:

Good catch!

Personally, I prefer lowercase spelling for all three options. Writing 
uppercase after the colon when setting the option via 
`cppcoreguidelines-pro-bounds-avoid-unchecked-container-accesses.FixMode: 
` feels unnatural to me. Feel free to re-open if there's a 
particular reason why uppercase makes more sense here.

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


[clang] [llvm] [RISCV][MC] Add support for Q extension (PR #139369)

2025-05-10 Thread Iris Shi via cfe-commits

https://github.com/el-ev created 
https://github.com/llvm/llvm-project/pull/139369

Closes #130217.

https://github.com/riscv/riscv-isa-manual/blob/main/src/q-st-ext.adoc



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[clang] [llvm] [RISCV][MC] Add support for Q extension (PR #139369)

2025-05-10 Thread Iris Shi via cfe-commits

https://github.com/el-ev updated 
https://github.com/llvm/llvm-project/pull/139369

>From 7ee8af28b85b5ca8200f6ce320f042843a4fa2e6 Mon Sep 17 00:00:00 2001
From: Iris Shi <0...@owo.li>
Date: Sat, 10 May 2025 18:01:57 +0800
Subject: [PATCH] [RISCV][MC] Add support for Q extension

---
 .../Driver/print-supported-extensions-riscv.c |   1 +
 clang/test/Driver/riscv-arch.c|  26 ++-
 .../test/Preprocessor/riscv-target-features.c |  12 ++
 llvm/docs/RISCVUsage.rst  |   1 +
 .../Target/RISCV/AsmParser/RISCVAsmParser.cpp |   9 +
 .../RISCV/Disassembler/RISCVDisassembler.cpp  |  11 ++
 llvm/lib/Target/RISCV/RISCVFeatures.td|   7 +
 llvm/lib/Target/RISCV/RISCVInstrInfo.td   |   1 +
 llvm/lib/Target/RISCV/RISCVInstrInfoD.td  |   6 +-
 llvm/lib/Target/RISCV/RISCVInstrInfoF.td  |   8 +-
 llvm/lib/Target/RISCV/RISCVInstrInfoQ.td  | 168 
 llvm/lib/Target/RISCV/RISCVInstrInfoZfh.td|  20 +-
 llvm/lib/Target/RISCV/RISCVRegisterInfo.td|  18 ++
 llvm/lib/Target/RISCV/RISCVSchedGenericOOO.td |   1 +
 llvm/lib/Target/RISCV/RISCVSchedMIPSP8700.td  |   1 +
 llvm/lib/Target/RISCV/RISCVSchedRocket.td |   1 +
 llvm/lib/Target/RISCV/RISCVSchedSiFive7.td|   1 +
 llvm/lib/Target/RISCV/RISCVSchedSiFiveP400.td |   1 +
 llvm/lib/Target/RISCV/RISCVSchedSiFiveP500.td |   1 +
 llvm/lib/Target/RISCV/RISCVSchedSiFiveP600.td |   1 +
 .../lib/Target/RISCV/RISCVSchedSpacemitX60.td |   1 +
 .../Target/RISCV/RISCVSchedSyntacoreSCR345.td |   3 +-
 .../Target/RISCV/RISCVSchedSyntacoreSCR7.td   |   1 +
 .../lib/Target/RISCV/RISCVSchedTTAscalonD8.td |   1 +
 .../Target/RISCV/RISCVSchedXiangShanNanHu.td  |   1 +
 llvm/lib/Target/RISCV/RISCVSchedule.td|  88 -
 llvm/lib/Target/RISCV/RISCVSubtarget.h|   3 +
 llvm/lib/TargetParser/RISCVISAInfo.cpp|   5 +-
 llvm/test/CodeGen/RISCV/attributes.ll |   4 +
 llvm/test/CodeGen/RISCV/features-info.ll  |   1 +
 llvm/test/MC/RISCV/rv32q-invalid.s|  21 ++
 llvm/test/MC/RISCV/rv64q-invalid.s|   9 +
 llvm/test/MC/RISCV/rv64q-valid.s  |  43 
 llvm/test/MC/RISCV/rvq-valid.s| 184 ++
 .../TargetParser/RISCVISAInfoTest.cpp |   1 +
 35 files changed, 629 insertions(+), 32 deletions(-)
 create mode 100644 llvm/lib/Target/RISCV/RISCVInstrInfoQ.td
 create mode 100644 llvm/test/MC/RISCV/rv32q-invalid.s
 create mode 100644 llvm/test/MC/RISCV/rv64q-invalid.s
 create mode 100644 llvm/test/MC/RISCV/rv64q-valid.s
 create mode 100644 llvm/test/MC/RISCV/rvq-valid.s

diff --git a/clang/test/Driver/print-supported-extensions-riscv.c 
b/clang/test/Driver/print-supported-extensions-riscv.c
index b10850aadddc3..cbadb86f006f4 100644
--- a/clang/test/Driver/print-supported-extensions-riscv.c
+++ b/clang/test/Driver/print-supported-extensions-riscv.c
@@ -10,6 +10,7 @@
 // CHECK-NEXT: a2.1   'A' (Atomic Instructions)
 // CHECK-NEXT: f2.2   'F' (Single-Precision 
Floating-Point)
 // CHECK-NEXT: d2.2   'D' (Double-Precision 
Floating-Point)
+// CHECK-NEXT: q2.2   'Q' (Quad-Precision 
Floating-Point)
 // CHECK-NEXT: c2.0   'C' (Compressed Instructions)
 // CHECK-NEXT: b1.0   'B' (the collection of the 
Zba, Zbb, Zbs extensions)
 // CHECK-NEXT: v1.0   'V' (Vector Extension for 
Application Processors)
diff --git a/clang/test/Driver/riscv-arch.c b/clang/test/Driver/riscv-arch.c
index 018fa25218ea6..32e7c0d44b243 100644
--- a/clang/test/Driver/riscv-arch.c
+++ b/clang/test/Driver/riscv-arch.c
@@ -10,6 +10,8 @@
 // RUN: -fsyntax-only 2>&1 | FileCheck %s
 // RUN: %clang --target=riscv32-unknown-elf -march=rv32imafd -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck %s
+// RUN: %clang --target=riscv32-unknown-elf -march=rv32imafdq -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck %s
 
 // RUN: %clang --target=riscv32-unknown-elf -march=rv32ic -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck %s
@@ -21,6 +23,8 @@
 // RUN: -fsyntax-only 2>&1 | FileCheck %s
 // RUN: %clang --target=riscv32-unknown-elf -march=rv32imafdc -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck %s
+// RUN: %clang --target=riscv32-unknown-elf -march=rv32imafdqc -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck %s
 
 // RUN: %clang --target=riscv32-unknown-elf -march=rv32ia -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck %s
@@ -28,6 +32,8 @@
 // RUN: -fsyntax-only 2>&1 | FileCheck %s
 // RUN: %clang --target=riscv32-unknown-elf -march=rv32iafd -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck %s
+// RUN: %clang --target=riscv32-unknown-elf -march=rv32iafdq -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck %s
 
 // RUN: %clang --target=riscv32-unknown-elf -march=rv32iac -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck %s
@@ -35,6 +41,8 @@
 // RUN: -fsyntax-only 2>&1 | FileCheck %

[clang] [flang] [llvm] [flang][OpenMP] Pass OpenMP version to getOpenMPDirectiveName (PR #139131)

2025-05-10 Thread Michał Górny via cfe-commits

mgorny wrote:

I'm also seeing this failure, so I'm going to revert.

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


[clang] [flang] [llvm] [flang][OpenMP] Pass OpenMP version to getOpenMPDirectiveName (PR #139131)

2025-05-10 Thread Michał Górny via cfe-commits

mgorny wrote:

…or I'll try fixing it first, it seems to be a trivial case of missing include.

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


[clang] Fixed vec_pack_to_short_fp32 in Clang altivec.h (PR #129923)

2025-05-10 Thread John Platts via cfe-commits

https://github.com/johnplatts updated 
https://github.com/llvm/llvm-project/pull/129923

>From 0bfa20f7a2deaf61e04f7418f4571a9d6de4 Mon Sep 17 00:00:00 2001
From: John Platts 
Date: Wed, 5 Mar 2025 13:11:15 -0600
Subject: [PATCH 1/3] Fixed vec_pack_to_short_fp32 in Clang altivec.h

---
 clang/lib/Headers/altivec.h | 10 +++---
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/clang/lib/Headers/altivec.h b/clang/lib/Headers/altivec.h
index 8da65055012f1..45d557238e3d9 100644
--- a/clang/lib/Headers/altivec.h
+++ b/clang/lib/Headers/altivec.h
@@ -7529,13 +7529,9 @@ vec_pack(vector double __a, vector double __b) {
 #ifdef __POWER9_VECTOR__
 static __inline__ vector unsigned short __ATTRS_o_ai
 vec_pack_to_short_fp32(vector float __a, vector float __b) {
-  vector float __resa = __builtin_vsx_xvcvsphp(__a);
-  vector float __resb = __builtin_vsx_xvcvsphp(__b);
-#ifdef __LITTLE_ENDIAN__
-  return (vector unsigned short)vec_mergee(__resa, __resb);
-#else
-  return (vector unsigned short)vec_mergeo(__resa, __resb);
-#endif
+  vector unsigned int __resa = (vector unsigned 
int)__builtin_vsx_xvcvsphp(__a);
+  vector unsigned int __resb = (vector unsigned 
int)__builtin_vsx_xvcvsphp(__b);
+  return vec_pack(__resa, __resb);
 }
 
 #endif

>From 51c05790f7cd38e6db324dcd55b7491118b1c3e2 Mon Sep 17 00:00:00 2001
From: Lei Huang 
Date: Fri, 7 Mar 2025 13:44:52 -0500
Subject: [PATCH 2/3] add additional checks to test for vec_pack_to_short_fp32

---
 clang/test/CodeGen/PowerPC/builtins-ppc-p9vector.c | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/clang/test/CodeGen/PowerPC/builtins-ppc-p9vector.c 
b/clang/test/CodeGen/PowerPC/builtins-ppc-p9vector.c
index b55a522ed2608..68d32ee14c8fa 100644
--- a/clang/test/CodeGen/PowerPC/builtins-ppc-p9vector.c
+++ b/clang/test/CodeGen/PowerPC/builtins-ppc-p9vector.c
@@ -853,10 +853,16 @@ vector unsigned char test73(void) {
 vector unsigned short test74(void) {
 // CHECK-BE: @llvm.ppc.vsx.xvcvsphp(<4 x float>
 // CHECK-BE: @llvm.ppc.vsx.xvcvsphp(<4 x float>
-// CHECK-BE: @llvm.ppc.altivec.vperm
+// CHECK-BE: [[REG0:%[0-9]+]] = call <4 x i32> @llvm.ppc.altivec.vperm
+// CHECK-BE-NEXT: [[REG1:%[0-9]+]] = bitcast <4 x i32> [[REG0]] to <4 x float>
+// CHECK-BE-NEXT: [[REG2:%[0-9]+]] = bitcast <4 x float> [[REG1]] to <8 x i16>
+// CHECK-BE-NEXT: ret <8 x i16> [[REG2]]
 // CHECK: @llvm.ppc.vsx.xvcvsphp(<4 x float>
 // CHECK: @llvm.ppc.vsx.xvcvsphp(<4 x float>
-// CHECK: @llvm.ppc.altivec.vperm
+// CHECK: [[REG0:%[0-9]+]] = call <4 x i32> @llvm.ppc.altivec.vperm
+// CHECK-NEXT: [[REG1:%[0-9]+]] = bitcast <4 x i32> [[REG0]] to <4 x float>
+// CHECK-NEXT: [[REG2:%[0-9]+]] = bitcast <4 x float> [[REG1]] to <8 x i16>
+// CHECK-NEXT: ret <8 x i16> [[REG2]]
   return vec_pack_to_short_fp32(vfa, vfb);
 }
 vector unsigned int test75(void) {

>From 9aed4ea26d7dbe5fa786638eeabcbf7a8f0f51c0 Mon Sep 17 00:00:00 2001
From: John Platts 
Date: Fri, 7 Mar 2025 15:03:35 -0600
Subject: [PATCH 3/3] Updated test to reflect changes made to
 vec_pack_to_short_fp32

---
 clang/test/CodeGen/PowerPC/builtins-ppc-p9vector.c | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/clang/test/CodeGen/PowerPC/builtins-ppc-p9vector.c 
b/clang/test/CodeGen/PowerPC/builtins-ppc-p9vector.c
index 68d32ee14c8fa..824267b98564e 100644
--- a/clang/test/CodeGen/PowerPC/builtins-ppc-p9vector.c
+++ b/clang/test/CodeGen/PowerPC/builtins-ppc-p9vector.c
@@ -854,15 +854,13 @@ vector unsigned short test74(void) {
 // CHECK-BE: @llvm.ppc.vsx.xvcvsphp(<4 x float>
 // CHECK-BE: @llvm.ppc.vsx.xvcvsphp(<4 x float>
 // CHECK-BE: [[REG0:%[0-9]+]] = call <4 x i32> @llvm.ppc.altivec.vperm
-// CHECK-BE-NEXT: [[REG1:%[0-9]+]] = bitcast <4 x i32> [[REG0]] to <4 x float>
-// CHECK-BE-NEXT: [[REG2:%[0-9]+]] = bitcast <4 x float> [[REG1]] to <8 x i16>
-// CHECK-BE-NEXT: ret <8 x i16> [[REG2]]
+// CHECK-BE-NEXT: [[REG1:%[0-9]+]] = bitcast <4 x i32> [[REG0]] to <8 x i16>
+// CHECK-BE-NEXT: ret <8 x i16> [[REG1]]
 // CHECK: @llvm.ppc.vsx.xvcvsphp(<4 x float>
 // CHECK: @llvm.ppc.vsx.xvcvsphp(<4 x float>
 // CHECK: [[REG0:%[0-9]+]] = call <4 x i32> @llvm.ppc.altivec.vperm
-// CHECK-NEXT: [[REG1:%[0-9]+]] = bitcast <4 x i32> [[REG0]] to <4 x float>
-// CHECK-NEXT: [[REG2:%[0-9]+]] = bitcast <4 x float> [[REG1]] to <8 x i16>
-// CHECK-NEXT: ret <8 x i16> [[REG2]]
+// CHECK-NEXT: [[REG1:%[0-9]+]] = bitcast <4 x i32> [[REG0]] to <8 x i16>
+// CHECK-NEXT: ret <8 x i16> [[REG1]]
   return vec_pack_to_short_fp32(vfa, vfb);
 }
 vector unsigned int test75(void) {

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


[clang] abedb5e - [StaticAnalyzer] Remove redundant calls to std::unique_ptr::get (NFC) (#139353)

2025-05-10 Thread via cfe-commits

Author: Kazu Hirata
Date: 2025-05-10T07:27:56-07:00
New Revision: abedb5e351302fff69b0046a4fc034d32c6f2e8a

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

LOG: [StaticAnalyzer] Remove redundant calls to std::unique_ptr::get (NFC) 
(#139353)

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/CheckPlacementNew.cpp
clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
clang/lib/StaticAnalyzer/Core/SVals.cpp
clang/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/CheckPlacementNew.cpp 
b/clang/lib/StaticAnalyzer/Checkers/CheckPlacementNew.cpp
index 3a66b0f11eb2e..839c8bcd90210 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CheckPlacementNew.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/CheckPlacementNew.cpp
@@ -124,7 +124,7 @@ bool PlacementNewChecker::checkPlaceCapacityIsSufficient(
 "requires {1} bytes. Current overhead requires the size of {2} "
 "bytes",
 SizeOfPlaceCI->getValue(), SizeOfTargetCI->getValue(),
-*SizeOfPlaceCI->getValue().get() - SizeOfTargetCI->getValue()));
+*SizeOfPlaceCI->getValue() - SizeOfTargetCI->getValue()));
   else if (IsArrayTypeAllocated &&
SizeOfPlaceCI->getValue() == SizeOfTargetCI->getValue())
 Msg = std::string(llvm::formatv(

diff  --git a/clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
index 4e3919ef01667..637cf87ef8b6d 100644
--- a/clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
@@ -157,9 +157,9 @@ class DeadStoreObs : public LiveVariables::Observer {
   return true;
 // Lazily construct the set that records which VarDecls are in
 // EH code.
-if (!InEH.get()) {
+if (!InEH) {
   InEH.reset(new llvm::DenseSet());
-  EHCodeVisitor V(*InEH.get());
+  EHCodeVisitor V(*InEH);
   V.TraverseStmt(AC->getBody());
 }
 // Treat all VarDecls that occur in EH code as being "always live"
@@ -196,7 +196,7 @@ class DeadStoreObs : public LiveVariables::Observer {
 
 // Compute reachable blocks within the CFG for trivial cases
 // where a bogus dead store can be reported because itself is unreachable.
-if (!reachableCode.get()) {
+if (!reachableCode) {
   reachableCode.reset(new ReachableCode(cfg));
   reachableCode->computeReachableBlocks();
 }

diff  --git a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp 
b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
index 86e2e8f634bfd..40514cb1ba449 100644
--- a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -4050,7 +4050,7 @@ std::string ExprEngine::DumpGraph(ArrayRef Nodes,
   StringRef Filename) {
   std::unique_ptr TrimmedG(G.trim(Nodes));
 
-  if (!TrimmedG.get()) {
+  if (!TrimmedG) {
 llvm::errs() << "warning: Trimmed ExplodedGraph is empty.\n";
 return "";
   }

diff  --git a/clang/lib/StaticAnalyzer/Core/SVals.cpp 
b/clang/lib/StaticAnalyzer/Core/SVals.cpp
index 3ab01a04dcec4..824e4a3630735 100644
--- a/clang/lib/StaticAnalyzer/Core/SVals.cpp
+++ b/clang/lib/StaticAnalyzer/Core/SVals.cpp
@@ -249,9 +249,9 @@ bool SVal::isConstant() const {
 
 bool SVal::isConstant(int I) const {
   if (std::optional LV = getAs())
-return *LV->getValue().get() == I;
+return *LV->getValue() == I;
   if (std::optional NV = getAs())
-return *NV->getValue().get() == I;
+return *NV->getValue() == I;
   return false;
 }
 

diff  --git a/clang/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp 
b/clang/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
index 3c5c992fa8dbc..ee9f90796fead 100644
--- a/clang/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
+++ b/clang/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
@@ -75,7 +75,7 @@ ProgramStateRef 
SimpleConstraintManager::assumeAux(ProgramStateRef State,
   }
 
   case nonloc::ConcreteIntKind: {
-bool b = *Cond.castAs().getValue().get() != 0;
+bool b = *Cond.castAs().getValue() != 0;
 bool isFeasible = b ? Assumption : !Assumption;
 return isFeasible ? State : nullptr;
   }



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


[clang] [llvm] [RISCV][MC] Add support for Q extension (PR #139369)

2025-05-10 Thread Iris Shi via cfe-commits

https://github.com/el-ev updated 
https://github.com/llvm/llvm-project/pull/139369

>From 70a6d632c96de6564eea070d526bbbeaa8df3f08 Mon Sep 17 00:00:00 2001
From: Iris Shi <0...@owo.li>
Date: Sat, 10 May 2025 18:01:57 +0800
Subject: [PATCH] [RISCV][MC] Add support for Q extension

---
 .../Driver/print-supported-extensions-riscv.c |   1 +
 clang/test/Driver/riscv-arch.c|  26 ++-
 .../test/Preprocessor/riscv-target-features.c |  12 ++
 llvm/docs/RISCVUsage.rst  |   1 +
 .../Target/RISCV/AsmParser/RISCVAsmParser.cpp |   9 +
 .../RISCV/Disassembler/RISCVDisassembler.cpp  |  11 ++
 llvm/lib/Target/RISCV/RISCVFeatures.td|   7 +
 llvm/lib/Target/RISCV/RISCVInstrInfo.td   |   1 +
 llvm/lib/Target/RISCV/RISCVInstrInfoD.td  |   6 +-
 llvm/lib/Target/RISCV/RISCVInstrInfoF.td  |   8 +-
 llvm/lib/Target/RISCV/RISCVInstrInfoQ.td  | 168 
 llvm/lib/Target/RISCV/RISCVInstrInfoZfh.td|  20 +-
 llvm/lib/Target/RISCV/RISCVRegisterInfo.td|  18 ++
 llvm/lib/Target/RISCV/RISCVSchedGenericOOO.td |   1 +
 llvm/lib/Target/RISCV/RISCVSchedMIPSP8700.td  |   1 +
 llvm/lib/Target/RISCV/RISCVSchedRocket.td |   1 +
 llvm/lib/Target/RISCV/RISCVSchedSiFive7.td|   1 +
 llvm/lib/Target/RISCV/RISCVSchedSiFiveP400.td |   1 +
 llvm/lib/Target/RISCV/RISCVSchedSiFiveP500.td |   1 +
 llvm/lib/Target/RISCV/RISCVSchedSiFiveP600.td |   1 +
 .../lib/Target/RISCV/RISCVSchedSpacemitX60.td |   1 +
 .../Target/RISCV/RISCVSchedSyntacoreSCR345.td |   3 +-
 .../Target/RISCV/RISCVSchedSyntacoreSCR7.td   |   1 +
 .../lib/Target/RISCV/RISCVSchedTTAscalonD8.td |   1 +
 .../Target/RISCV/RISCVSchedXiangShanNanHu.td  |   1 +
 llvm/lib/Target/RISCV/RISCVSchedule.td|  88 -
 llvm/lib/Target/RISCV/RISCVSubtarget.h|   3 +
 llvm/lib/TargetParser/RISCVISAInfo.cpp|   5 +-
 llvm/test/CodeGen/RISCV/attributes.ll |   4 +
 llvm/test/CodeGen/RISCV/features-info.ll  |   1 +
 llvm/test/MC/RISCV/rv32q-invalid.s|  21 ++
 llvm/test/MC/RISCV/rv64q-invalid.s|   9 +
 llvm/test/MC/RISCV/rv64q-valid.s  |  43 
 llvm/test/MC/RISCV/rvq-valid.s| 184 ++
 .../TargetParser/RISCVISAInfoTest.cpp |   1 +
 35 files changed, 629 insertions(+), 32 deletions(-)
 create mode 100644 llvm/lib/Target/RISCV/RISCVInstrInfoQ.td
 create mode 100644 llvm/test/MC/RISCV/rv32q-invalid.s
 create mode 100644 llvm/test/MC/RISCV/rv64q-invalid.s
 create mode 100644 llvm/test/MC/RISCV/rv64q-valid.s
 create mode 100644 llvm/test/MC/RISCV/rvq-valid.s

diff --git a/clang/test/Driver/print-supported-extensions-riscv.c 
b/clang/test/Driver/print-supported-extensions-riscv.c
index b10850aadddc3..cbadb86f006f4 100644
--- a/clang/test/Driver/print-supported-extensions-riscv.c
+++ b/clang/test/Driver/print-supported-extensions-riscv.c
@@ -10,6 +10,7 @@
 // CHECK-NEXT: a2.1   'A' (Atomic Instructions)
 // CHECK-NEXT: f2.2   'F' (Single-Precision 
Floating-Point)
 // CHECK-NEXT: d2.2   'D' (Double-Precision 
Floating-Point)
+// CHECK-NEXT: q2.2   'Q' (Quad-Precision 
Floating-Point)
 // CHECK-NEXT: c2.0   'C' (Compressed Instructions)
 // CHECK-NEXT: b1.0   'B' (the collection of the 
Zba, Zbb, Zbs extensions)
 // CHECK-NEXT: v1.0   'V' (Vector Extension for 
Application Processors)
diff --git a/clang/test/Driver/riscv-arch.c b/clang/test/Driver/riscv-arch.c
index 018fa25218ea6..32e7c0d44b243 100644
--- a/clang/test/Driver/riscv-arch.c
+++ b/clang/test/Driver/riscv-arch.c
@@ -10,6 +10,8 @@
 // RUN: -fsyntax-only 2>&1 | FileCheck %s
 // RUN: %clang --target=riscv32-unknown-elf -march=rv32imafd -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck %s
+// RUN: %clang --target=riscv32-unknown-elf -march=rv32imafdq -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck %s
 
 // RUN: %clang --target=riscv32-unknown-elf -march=rv32ic -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck %s
@@ -21,6 +23,8 @@
 // RUN: -fsyntax-only 2>&1 | FileCheck %s
 // RUN: %clang --target=riscv32-unknown-elf -march=rv32imafdc -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck %s
+// RUN: %clang --target=riscv32-unknown-elf -march=rv32imafdqc -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck %s
 
 // RUN: %clang --target=riscv32-unknown-elf -march=rv32ia -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck %s
@@ -28,6 +32,8 @@
 // RUN: -fsyntax-only 2>&1 | FileCheck %s
 // RUN: %clang --target=riscv32-unknown-elf -march=rv32iafd -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck %s
+// RUN: %clang --target=riscv32-unknown-elf -march=rv32iafdq -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck %s
 
 // RUN: %clang --target=riscv32-unknown-elf -march=rv32iac -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck %s
@@ -35,6 +41,8 @@
 // RUN: -fsyntax-only 2>&1 | FileCheck %

  1   2   >