[clang] ca4af13 - [clang] Don't use Optional::getValue (NFC)

2022-06-20 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-06-20T22:59:26-07:00
New Revision: ca4af13e480e856f8f889c1e145308fc4eb69816

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

LOG: [clang] Don't use Optional::getValue (NFC)

Added: 


Modified: 
clang/include/clang/Sema/Lookup.h
clang/lib/AST/ASTContext.cpp
clang/lib/Analysis/BodyFarm.cpp
clang/lib/Analysis/CalledOnceCheck.cpp
clang/lib/Analysis/ReachableCode.cpp
clang/lib/Basic/TargetID.cpp
clang/lib/Basic/Targets/AMDGPU.cpp
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/CGHLSLRuntime.cpp
clang/lib/CodeGen/CGObjC.cpp
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
clang/lib/CodeGen/CodeGenFunction.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/CodeGen/TargetInfo.cpp
clang/lib/Driver/Driver.cpp
clang/lib/Driver/ToolChains/AMDGPU.cpp
clang/lib/Driver/ToolChains/AVR.cpp
clang/lib/Driver/ToolChains/HIPAMD.cpp
clang/lib/Driver/ToolChains/HLSL.cpp
clang/lib/Driver/ToolChains/Hexagon.cpp
clang/lib/Frontend/ASTUnit.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Lex/DependencyDirectivesScanner.cpp
clang/lib/Lex/PPDirectives.cpp
clang/lib/Parse/ParseOpenMP.cpp
clang/lib/Sema/SemaAvailability.cpp
clang/lib/Sema/SemaChecking.cpp
clang/lib/Sema/SemaCodeComplete.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/lib/Sema/SemaExprCXX.cpp
clang/lib/Sema/SemaLambda.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Sema/SemaOverload.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp
clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
clang/lib/StaticAnalyzer/Core/CallDescription.cpp
clang/lib/StaticAnalyzer/Core/CallEvent.cpp
clang/lib/StaticAnalyzer/Core/Environment.cpp
clang/lib/StaticAnalyzer/Core/RegionStore.cpp
clang/lib/Support/RISCVVIntrinsicUtils.cpp
clang/tools/libclang/CXType.cpp
clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
clang/utils/TableGen/RISCVVEmitter.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/Lookup.h 
b/clang/include/clang/Sema/Lookup.h
index 54fe7081b710..1f43ff0b5aaf 100644
--- a/clang/include/clang/Sema/Lookup.h
+++ b/clang/include/clang/Sema/Lookup.h
@@ -495,7 +495,7 @@ class LookupResult {
   if (ResultKind == Ambiguous) {
 (void)WasAmbiguous;
 assert(WasAmbiguous);
-Ambiguity = SavedAK.getValue();
+Ambiguity = *SavedAK;
   } else if (Paths) {
 deletePaths(Paths);
 Paths = nullptr;

diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 4cafa7a0df96..b4b02da0c351 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -2833,8 +2833,7 @@ bool ASTContext::hasUniqueObjectRepresentations(QualType 
Ty) const {
 Optional StructSize =
 structHasUniqueObjectRepresentations(*this, Record);
 
-return StructSize &&
-   StructSize.getValue() == static_cast(getTypeSize(Ty));
+return StructSize && *StructSize == static_cast(getTypeSize(Ty));
   }
 
   // FIXME: More cases to handle here (list by rsmith):

diff  --git a/clang/lib/Analysis/BodyFarm.cpp b/clang/lib/Analysis/BodyFarm.cpp
index 95bed548c567..3587cf4678af 100644
--- a/clang/lib/Analysis/BodyFarm.cpp
+++ b/clang/lib/Analysis/BodyFarm.cpp
@@ -737,7 +737,7 @@ Stmt *BodyFarm::getBody(const FunctionDecl *D) {
 
   if (FF) { Val = FF(C, D); }
   else if (Injector) { Val = Injector->getBody(D); }
-  return Val.getValue();
+  return *Val;
 }
 
 static const ObjCIvarDecl *findBackingIvar(const ObjCPropertyDecl *Prop) {
@@ -900,5 +900,5 @@ Stmt *BodyFarm::getBody(const ObjCMethodDecl *D) {
 
   Val = createObjCPropertyGetter(C, D);
 
-  return Val.getValue();
+  return *Val;
 }

diff  --git a/clang/lib/Analysis/CalledOnceCheck.cpp 
b/clang/lib/Analysis/CalledOnceCheck.cpp
index 661f7b999f2b..c1d1d7b89ec7 100644
--- a/clang/lib/Analysis/CalledOnceCheck.cpp
+++ b/clang/lib/Analysis/CalledOnceCheck.cpp
@@ -1065,7 +1065,7 @@ class CalledOnceChecker : public 
ConstStmtVisitor {
 // 'swift_async' goes first and overrides anything else.
 if (auto ConventionalAsync =
 isConventionalSwiftAsync(Function, ParamIndex)) {
-  return ConventionalAsync.getValue();
+  return *ConventionalAsync;
 }
 
 return shouldBeCalledOnce(Function->getParamDecl(ParamIndex)) ||
@@ -1082,7 +1082,7 @@ class CalledOnceChecker : public 
ConstStmtVisitor {
 
 // 'swift_async' goes first and overrides anything else.
 if (auto ConventionalAsync = isConventionalSwiftAsync(Method, ParamIndex)) 
{
-  return ConventionalAsync.getValue();
+ 

[PATCH] D128048: Add a new clang option "-ftime-trace-path"

2022-06-20 Thread Whitney Tsang via Phabricator via cfe-commits
Whitney added inline comments.



Comment at: clang/include/clang/Driver/Options.td:2832
+def ftime_trace_path : Joined<["-"], "ftime-trace-path=">, Group,
+  HelpText<"Path which stores the output files of time profiler">,
+  Flags<[CC1Option, CoreOption]>,

jamieschmeiser wrote:
> which specifies the output files for -ftime-trace
What do you think of "which specifies the output directory for -ftime-trace"? 
As from your example, this option doesn't specify a file, instead it specifies 
a directory.



Comment at: clang/include/clang/Frontend/FrontendOptions.h:502
 
+  /// Path which stores the output files of time profiler.
+  std::string TimeTracePath;

Please update this comment according too. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128048

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


[PATCH] D126266: Mark the file entry invalid, until reread. Invalidate SLocEntry cache, readd it on reread. Do not use translateFile, because it pulls in parts of the pch.

2022-06-20 Thread Tapasweni Pathak via Phabricator via cfe-commits
tapaswenipathak updated this revision to Diff 438550.
tapaswenipathak added a comment.

omit an unrelated change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126266

Files:
  clang/include/clang/Basic/FileEntry.h
  clang/include/clang/Basic/FileManager.h
  clang/include/clang/Basic/SourceManager.h
  clang/lib/Basic/FileManager.cpp
  clang/lib/Basic/SourceManager.cpp
  clang/unittests/Basic/FileManagerTest.cpp
  clang/unittests/Basic/SourceManagerTest.cpp

Index: clang/unittests/Basic/SourceManagerTest.cpp
===
--- clang/unittests/Basic/SourceManagerTest.cpp
+++ clang/unittests/Basic/SourceManagerTest.cpp
@@ -26,6 +26,14 @@
 
 using namespace clang;
 
+void clang::SourceManagerTestHelper(SourceManager , FileManager ) {
+  FileID mainFileID = SourceMgr.getMainFileID();
+  const SrcMgr::ContentCache *Cache =
+&(SourceMgr.getSLocEntry(mainFileID).getFile().getContentCache());
+  //EXPECT_FALSE(Cache->Buffer);
+  ASSERT_TRUE(FileMgr.FileEntriesToReread.empty());
+}
+
 namespace {
 
 // The test fixture.
@@ -51,6 +59,36 @@
   IntrusiveRefCntPtr Target;
 };
 
+// Test for invalidate cache success, making the file entry invalid, until
+// reread
+TEST_F(SourceManagerTest, invalidateCacheSuccess) {
+  const char *Source = "int x;";
+
+  std::unique_ptr Buf =
+  llvm::MemoryBuffer::getMemBuffer(Source);
+  const FileEntry *SourceFile =
+  FileMgr.getVirtualFile("mainFile.cpp", Buf->getBufferSize(), 0);
+
+  FileID mainFileID = SourceMgr.createFileID(std::move(Buf));
+  SourceMgr.overrideFileContents(SourceFile, std::move(Buf));
+  SourceMgr.setMainFileID(mainFileID);
+
+  SourceMgr.invalidateCache(mainFileID);
+
+  EXPECT_FALSE(SourceFile->isValid());
+  EXPECT_FALSE(mainFileID.isInvalid());
+
+  const SrcMgr::ContentCache *Cache =
+&(SourceMgr.getSLocEntry(mainFileID).getFile().getContentCache());
+
+  EXPECT_EQ(SourceMgr.getNonBuiltinFilenameForID(mainFileID), None);
+  //EXPECT_EQ(SourceMgr.getBufferDataIfLoaded(mainFileID), None);
+
+  EXPECT_FALSE(Cache->IsBufferInvalid);
+
+  SourceManagerTestHelper(SourceMgr, FileMgr);
+}
+
 TEST_F(SourceManagerTest, isBeforeInTranslationUnit) {
   const char *source =
 "#define M(x) [x]\n"
Index: clang/unittests/Basic/FileManagerTest.cpp
===
--- clang/unittests/Basic/FileManagerTest.cpp
+++ clang/unittests/Basic/FileManagerTest.cpp
@@ -18,6 +18,10 @@
 using namespace llvm;
 using namespace clang;
 
+void clang::FileManagerTestHelper(FileManager ){
+  ASSERT_TRUE(!manager.FileEntriesToReread.empty());
+}
+
 namespace {
 
 // Used to create a fake file system for running the tests with such
@@ -99,6 +103,29 @@
   FileManager manager;
 };
 
+// If file entry valid, mark the file entry invalid, until reread.
+TEST_F(FileManagerTest, invalidateCacheSuccess) {
+  auto statCache = std::make_unique();
+  statCache->InjectFile("file.cpp", 42);
+
+  manager.setStatCache(std::move(statCache));
+  manager.getVirtualFile("file.cpp", 100, 0);
+  auto file = manager.getFile("file.cpp");
+
+  // Check for file null assertion success
+  //manager.invalidateCache(NULL);
+
+  auto FileRef = manager.getFileRef("file.cpp");
+
+  ASSERT_FALSE(!FileRef);
+
+  FileEntry *FileEntryObj = const_cast(>getFileEntry());
+  manager.invalidateCache(FileEntryObj);
+  FileManagerTestHelper(manager);
+
+  ASSERT_FALSE(FileEntryObj->isValid());
+}
+
 // When a virtual file is added, its getDir() field has correct name.
 TEST_F(FileManagerTest, getVirtualFileSetsTheDirFieldCorrectly) {
   FileEntryRef file = manager.getVirtualFileRef("foo.cpp", 42, 0);
Index: clang/lib/Basic/SourceManager.cpp
===
--- clang/lib/Basic/SourceManager.cpp
+++ clang/lib/Basic/SourceManager.cpp
@@ -358,6 +358,25 @@
   return false;
 }
 
+void SourceManager::invalidateCache(FileID FID) {
+  const FileEntry* Entry = getFileEntryForID(FID);
+  if (!Entry)
+return;
+  if (ContentCache * = FileInfos[Entry]) {
+E->setBuffer(nullptr);
+E = 0;
+  }
+  if (!FID.isInvalid()) {
+const SrcMgr::SLocEntry& SLocE = getSLocEntry(FID);
+if (SLocE.isFile()) {
+  SrcMgr::ContentCache& CC =
+const_cast(SLocE.getFile().getContentCache());
+  CC.setBuffer(nullptr);
+}
+  }
+  getFileManager().invalidateCache(const_cast(Entry));
+}
+
 void SourceManager::initializeForReplay(const SourceManager ) {
   assert(MainFileID.isInvalid() && "expected uninitialized SourceManager");
 
Index: clang/lib/Basic/FileManager.cpp
===
--- clang/lib/Basic/FileManager.cpp
+++ clang/lib/Basic/FileManager.cpp
@@ -635,6 +635,12 @@
   return std::error_code();
 }
 
+void FileManager::invalidateCache(FileEntry *Entry) {
+  assert(Entry && "Cannot invalidate a NULL FileEntry");
+  

[PATCH] D126461: [RISCV] Extract and store new vl of vleff/vlsegff iff destination isn't null

2022-06-20 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

In D126461#3596761 , @reames wrote:

> Despite the comments above, the purpose of this patch remains unclear.
>
> Per the draft spec, the relevant wording is:
> "These instructions execute as a regular load except that they will only take 
> a trap caused by a synchronous exception
> on element 0. If element 0 raises an exception, vl is not modied, and the 
> trap is taken. If an element > 0 raises an
> exception, the corresponding trap is not taken, and the vector length vl is 
> reduced to the index of the element that would
> have raised an exception."
>
> Working through the scenario in this patch with the destination being null, 
> the expected result is for a trap to be generated (provided null is unmapped 
> of course), and VL not to be modified.  In order for this change to make any 
> difference in runtime behavior, the value passed must be null (or otherwise 
> guaranteed to fault).  It seems very odd to me that we are modifying code 
> which only runs after an instruction which is guaranteed to fault.  Is there 
> an assumed runtime here which is e.g. restarting execution?

`dst` in the patch description is not the pointer being loaded, it's the 
pointer of where to store the new_vl. That is only thing being checked for null 
in this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126461

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


[PATCH] D128235: [RISCV] Add support for the Zawrs extension

2022-06-20 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: llvm/test/MC/RISCV/zawrs-invalid.s:4
+# WRS doesn't take immediates
+wrs 1 # CHECK: :[[@LINE]]:5: error: invalid operand for instruction
+

`[[@LINE]]` is a deprecated FileCheck feature.

Use `[[#@LINE]]`

Note: you can place negative tests with the positive test file. Search `.ifndef 
err`.


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

https://reviews.llvm.org/D128235

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


[PATCH] D126266: Mark the file entry invalid, until reread. Invalidate SLocEntry cache, readd it on reread. Do not use translateFile, because it pulls in parts of the pch.

2022-06-20 Thread Tapasweni Pathak via Phabricator via cfe-commits
tapaswenipathak updated this revision to Diff 438541.
tapaswenipathak added a comment.

fix for build failure:

  cmdline: git reset --hard
  stderr: 'fatal: Unable to create 
'/var/lib/buildkite-agent/builds/llvm-project-fork/.git/index.lock': File 
exists.

https://buildkite.com/llvm-project/diff-checks/builds/110904#01818451-4c05-49bb-9f93-ea6d0480f9ec

could be temporary, or could be because i didn't run a git pull for a few days.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126266

Files:
  clang/include/clang/Basic/FileEntry.h
  clang/include/clang/Basic/FileManager.h
  clang/include/clang/Basic/SourceManager.h
  clang/lib/Basic/FileManager.cpp
  clang/lib/Basic/SourceManager.cpp
  clang/lib/Lex/PPDirectives.cpp
  clang/unittests/Basic/FileManagerTest.cpp
  clang/unittests/Basic/SourceManagerTest.cpp

Index: clang/unittests/Basic/SourceManagerTest.cpp
===
--- clang/unittests/Basic/SourceManagerTest.cpp
+++ clang/unittests/Basic/SourceManagerTest.cpp
@@ -26,6 +26,14 @@
 
 using namespace clang;
 
+void clang::SourceManagerTestHelper(SourceManager , FileManager ) {
+  FileID mainFileID = SourceMgr.getMainFileID();
+  const SrcMgr::ContentCache *Cache =
+&(SourceMgr.getSLocEntry(mainFileID).getFile().getContentCache());
+  //EXPECT_FALSE(Cache->Buffer);
+  ASSERT_TRUE(FileMgr.FileEntriesToReread.empty());
+}
+
 namespace {
 
 // The test fixture.
@@ -51,6 +59,36 @@
   IntrusiveRefCntPtr Target;
 };
 
+// Test for invalidate cache success, making the file entry invalid, until
+// reread
+TEST_F(SourceManagerTest, invalidateCacheSuccess) {
+  const char *Source = "int x;";
+
+  std::unique_ptr Buf =
+  llvm::MemoryBuffer::getMemBuffer(Source);
+  const FileEntry *SourceFile =
+  FileMgr.getVirtualFile("mainFile.cpp", Buf->getBufferSize(), 0);
+
+  FileID mainFileID = SourceMgr.createFileID(std::move(Buf));
+  SourceMgr.overrideFileContents(SourceFile, std::move(Buf));
+  SourceMgr.setMainFileID(mainFileID);
+
+  SourceMgr.invalidateCache(mainFileID);
+
+  EXPECT_FALSE(SourceFile->isValid());
+  EXPECT_FALSE(mainFileID.isInvalid());
+
+  const SrcMgr::ContentCache *Cache =
+&(SourceMgr.getSLocEntry(mainFileID).getFile().getContentCache());
+
+  EXPECT_EQ(SourceMgr.getNonBuiltinFilenameForID(mainFileID), None);
+  //EXPECT_EQ(SourceMgr.getBufferDataIfLoaded(mainFileID), None);
+
+  EXPECT_FALSE(Cache->IsBufferInvalid);
+
+  SourceManagerTestHelper(SourceMgr, FileMgr);
+}
+
 TEST_F(SourceManagerTest, isBeforeInTranslationUnit) {
   const char *source =
 "#define M(x) [x]\n"
Index: clang/unittests/Basic/FileManagerTest.cpp
===
--- clang/unittests/Basic/FileManagerTest.cpp
+++ clang/unittests/Basic/FileManagerTest.cpp
@@ -18,6 +18,10 @@
 using namespace llvm;
 using namespace clang;
 
+void clang::FileManagerTestHelper(FileManager ){
+  ASSERT_TRUE(!manager.FileEntriesToReread.empty());
+}
+
 namespace {
 
 // Used to create a fake file system for running the tests with such
@@ -99,6 +103,29 @@
   FileManager manager;
 };
 
+// If file entry valid, mark the file entry invalid, until reread.
+TEST_F(FileManagerTest, invalidateCacheSuccess) {
+  auto statCache = std::make_unique();
+  statCache->InjectFile("file.cpp", 42);
+
+  manager.setStatCache(std::move(statCache));
+  manager.getVirtualFile("file.cpp", 100, 0);
+  auto file = manager.getFile("file.cpp");
+
+  // Check for file null assertion success
+  //manager.invalidateCache(NULL);
+
+  auto FileRef = manager.getFileRef("file.cpp");
+
+  ASSERT_FALSE(!FileRef);
+
+  FileEntry *FileEntryObj = const_cast(>getFileEntry());
+  manager.invalidateCache(FileEntryObj);
+  FileManagerTestHelper(manager);
+
+  ASSERT_FALSE(FileEntryObj->isValid());
+}
+
 // When a virtual file is added, its getDir() field has correct name.
 TEST_F(FileManagerTest, getVirtualFileSetsTheDirFieldCorrectly) {
   FileEntryRef file = manager.getVirtualFileRef("foo.cpp", 42, 0);
Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -821,7 +821,8 @@
 ConstSearchDirIterator *CurDirArg, SmallVectorImpl *SearchPath,
 SmallVectorImpl *RelativePath,
 ModuleMap::KnownHeader *SuggestedModule, bool *IsMapped,
-bool *IsFrameworkFound, bool SkipCache) {
+bool *IsFrameworkFound, bool SkipCache, bool OpenFile,
+   bool CacheFailures) {
   ConstSearchDirIterator CurDirLocal = nullptr;
   ConstSearchDirIterator  = CurDirArg ? *CurDirArg : CurDirLocal;
 
@@ -900,7 +901,7 @@
   Optional FE = HeaderInfo.LookupFile(
   Filename, FilenameLoc, isAngled, FromDir, , Includers, SearchPath,
   RelativePath, RequestingModule, SuggestedModule, IsMapped,
-  IsFrameworkFound, SkipCache, BuildSystemModule);
+  

[PATCH] D128235: [RISCV] Add support for the Zawrs extension

2022-06-20 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

> Context not available.

See `-U99` on 
https://llvm.org/docs/Phabricator.html#requesting-a-review-via-the-web-interface
 or use `arc diff` (PHP 8 may need 
https://discourse.llvm.org/t/arcanist-deprecation-errors-on-php-8/63231)




Comment at: llvm/test/MC/RISCV/zawrs-valid.s:2
+# RUN: llvm-mc %s -triple=riscv32 -mattr=+zawrs \
+# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ %s
+# RUN: llvm-mc %s -triple=riscv64 -mattr=+zawrs \

The convention is to use `--check-prefix` is there is only one prefix.



Comment at: llvm/test/MC/RISCV/zawrs-valid.s:12
+
+# CHECK-S-OBJ: wrs
+wrs

Append `{{$}}` to make the test stricter.


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

https://reviews.llvm.org/D128235

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


[PATCH] D126266: Mark the file entry invalid, until reread. Invalidate SLocEntry cache, readd it on reread. Do not use translateFile, because it pulls in parts of the pch.

2022-06-20 Thread Tapasweni Pathak via Phabricator via cfe-commits
tapaswenipathak updated this revision to Diff 438535.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126266

Files:
  clang/include/clang/Basic/FileEntry.h
  clang/include/clang/Basic/FileManager.h
  clang/include/clang/Basic/SourceManager.h
  clang/lib/Basic/FileManager.cpp
  clang/lib/Basic/SourceManager.cpp
  clang/unittests/Basic/FileManagerTest.cpp
  clang/unittests/Basic/SourceManagerTest.cpp

Index: clang/unittests/Basic/SourceManagerTest.cpp
===
--- clang/unittests/Basic/SourceManagerTest.cpp
+++ clang/unittests/Basic/SourceManagerTest.cpp
@@ -26,6 +26,14 @@
 
 using namespace clang;
 
+void clang::SourceManagerTestHelper(SourceManager , FileManager ) {
+  FileID mainFileID = SourceMgr.getMainFileID();
+  const SrcMgr::ContentCache *Cache =
+&(SourceMgr.getSLocEntry(mainFileID).getFile().getContentCache());
+  //EXPECT_FALSE(Cache->Buffer);
+  ASSERT_TRUE(FileMgr.FileEntriesToReread.empty());
+}
+
 namespace {
 
 // The test fixture.
@@ -51,6 +59,36 @@
   IntrusiveRefCntPtr Target;
 };
 
+// Test for invalidate cache success, making the file entry invalid, until
+// reread
+TEST_F(SourceManagerTest, invalidateCacheSuccess) {
+  const char *Source = "int x;";
+
+  std::unique_ptr Buf =
+  llvm::MemoryBuffer::getMemBuffer(Source);
+  const FileEntry *SourceFile =
+  FileMgr.getVirtualFile("mainFile.cpp", Buf->getBufferSize(), 0);
+
+  FileID mainFileID = SourceMgr.createFileID(std::move(Buf));
+  SourceMgr.overrideFileContents(SourceFile, std::move(Buf));
+  SourceMgr.setMainFileID(mainFileID);
+
+  SourceMgr.invalidateCache(mainFileID);
+
+  EXPECT_FALSE(SourceFile->isValid());
+  EXPECT_FALSE(mainFileID.isInvalid());
+
+  const SrcMgr::ContentCache *Cache =
+&(SourceMgr.getSLocEntry(mainFileID).getFile().getContentCache());
+
+  EXPECT_EQ(SourceMgr.getNonBuiltinFilenameForID(mainFileID), None);
+  //EXPECT_EQ(SourceMgr.getBufferDataIfLoaded(mainFileID), None);
+
+  EXPECT_FALSE(Cache->IsBufferInvalid);
+
+  SourceManagerTestHelper(SourceMgr, FileMgr);
+}
+
 TEST_F(SourceManagerTest, isBeforeInTranslationUnit) {
   const char *source =
 "#define M(x) [x]\n"
Index: clang/unittests/Basic/FileManagerTest.cpp
===
--- clang/unittests/Basic/FileManagerTest.cpp
+++ clang/unittests/Basic/FileManagerTest.cpp
@@ -18,6 +18,10 @@
 using namespace llvm;
 using namespace clang;
 
+void clang::FileManagerTestHelper(FileManager ){
+  ASSERT_TRUE(!manager.FileEntriesToReread.empty());
+}
+
 namespace {
 
 // Used to create a fake file system for running the tests with such
@@ -99,6 +103,29 @@
   FileManager manager;
 };
 
+// If file entry valid, mark the file entry invalid, until reread.
+TEST_F(FileManagerTest, invalidateCacheSuccess) {
+  auto statCache = std::make_unique();
+  statCache->InjectFile("file.cpp", 42);
+
+  manager.setStatCache(std::move(statCache));
+  manager.getVirtualFile("file.cpp", 100, 0);
+  auto file = manager.getFile("file.cpp");
+
+  // Check for file null assertion success
+  //manager.invalidateCache(NULL);
+
+  auto FileRef = manager.getFileRef("file.cpp");
+
+  ASSERT_FALSE(!FileRef);
+
+  FileEntry *FileEntryObj = const_cast(>getFileEntry());
+  manager.invalidateCache(FileEntryObj);
+  FileManagerTestHelper(manager);
+
+  ASSERT_FALSE(FileEntryObj->isValid());
+}
+
 // When a virtual file is added, its getDir() field has correct name.
 TEST_F(FileManagerTest, getVirtualFileSetsTheDirFieldCorrectly) {
   FileEntryRef file = manager.getVirtualFileRef("foo.cpp", 42, 0);
Index: clang/lib/Basic/SourceManager.cpp
===
--- clang/lib/Basic/SourceManager.cpp
+++ clang/lib/Basic/SourceManager.cpp
@@ -358,6 +358,25 @@
   return false;
 }
 
+void SourceManager::invalidateCache(FileID FID) {
+  const FileEntry* Entry = getFileEntryForID(FID);
+  if (!Entry)
+return;
+  if (ContentCache * = FileInfos[Entry]) {
+E->setBuffer(nullptr);
+E = 0;
+  }
+  if (!FID.isInvalid()) {
+const SrcMgr::SLocEntry& SLocE = getSLocEntry(FID);
+if (SLocE.isFile()) {
+  SrcMgr::ContentCache& CC =
+const_cast(SLocE.getFile().getContentCache());
+  CC.setBuffer(nullptr);
+}
+  }
+  getFileManager().invalidateCache(const_cast(Entry));
+}
+
 void SourceManager::initializeForReplay(const SourceManager ) {
   assert(MainFileID.isInvalid() && "expected uninitialized SourceManager");
 
Index: clang/lib/Basic/FileManager.cpp
===
--- clang/lib/Basic/FileManager.cpp
+++ clang/lib/Basic/FileManager.cpp
@@ -635,6 +635,12 @@
   return std::error_code();
 }
 
+void FileManager::invalidateCache(FileEntry *Entry) {
+  assert(Entry && "Cannot invalidate a NULL FileEntry");
+  FileEntriesToReread.insert(Entry->getLastRef());
+  

[clang] d66cbc5 - Don't use Optional::hasValue (NFC)

2022-06-20 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-06-20T20:26:05-07:00
New Revision: d66cbc565adbea8b7362349e527ac7aa2c75788f

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

LOG: Don't use Optional::hasValue (NFC)

Added: 


Modified: 
clang/include/clang/APINotes/Types.h
clang/include/clang/Basic/DarwinSDKInfo.h
clang/lib/Lex/MacroInfo.cpp
lldb/tools/lldb-vscode/FifoFiles.cpp
llvm/include/llvm/DebugInfo/GSYM/FunctionInfo.h
llvm/include/llvm/ProfileData/MemProf.h
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
llvm/lib/ObjectYAML/ELFYAML.cpp
llvm/lib/Target/SystemZ/SystemZISelLowering.h
llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp
llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
llvm/tools/llvm-cov/CodeCoverage.cpp
mlir/include/mlir/TableGen/CodeGenHelpers.h
mlir/lib/Analysis/Presburger/IntegerRelation.cpp
mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp
mlir/lib/Dialect/Affine/Analysis/Utils.cpp
mlir/lib/Dialect/Affine/Transforms/LoopFusion.cpp
mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp

Removed: 




diff  --git a/clang/include/clang/APINotes/Types.h 
b/clang/include/clang/APINotes/Types.h
index cd02db3da185c..ed5250f3d5b4e 100644
--- a/clang/include/clang/APINotes/Types.h
+++ b/clang/include/clang/APINotes/Types.h
@@ -440,8 +440,7 @@ class ParamInfo : public VariableInfo {
   }
   void
   setRetainCountConvention(llvm::Optional Value) {
-RawRetainCountConvention =
-Value.hasValue() ? static_cast(Value.getValue()) + 1 : 0;
+RawRetainCountConvention = Value ? static_cast(*Value) + 1 : 0;
 assert(getRetainCountConvention() == Value && "bitfield too small");
   }
 
@@ -559,8 +558,7 @@ class FunctionInfo : public CommonEntityInfo {
   }
   void
   setRetainCountConvention(llvm::Optional Value) {
-RawRetainCountConvention =
-Value.hasValue() ? static_cast(Value.getValue()) + 1 : 0;
+RawRetainCountConvention = Value ? static_cast(*Value) + 1 : 0;
 assert(getRetainCountConvention() == Value && "bitfield too small");
   }
 

diff  --git a/clang/include/clang/Basic/DarwinSDKInfo.h 
b/clang/include/clang/Basic/DarwinSDKInfo.h
index df16827debfc0..728bbc17c3acb 100644
--- a/clang/include/clang/Basic/DarwinSDKInfo.h
+++ b/clang/include/clang/Basic/DarwinSDKInfo.h
@@ -142,8 +142,7 @@ class DarwinSDKInfo {
 auto Mapping = VersionMappings.find(Kind.Value);
 if (Mapping == VersionMappings.end())
   return nullptr;
-return Mapping->getSecond().hasValue() ? Mapping->getSecond().getPointer()
-   : nullptr;
+return Mapping->getSecond() ? Mapping->getSecond().getPointer() : nullptr;
   }
 
   static Optional

diff  --git a/clang/lib/Lex/MacroInfo.cpp b/clang/lib/Lex/MacroInfo.cpp
index f5702130d1819..4a8127d29a459 100644
--- a/clang/lib/Lex/MacroInfo.cpp
+++ b/clang/lib/Lex/MacroInfo.cpp
@@ -201,8 +201,7 @@ MacroDirective::DefInfo MacroDirective::getDefinition() {
   Optional isPublic;
   for (; MD; MD = MD->getPrevious()) {
 if (DefMacroDirective *DefMD = dyn_cast(MD))
-  return DefInfo(DefMD, UndefLoc,
- !isPublic.hasValue() || isPublic.getValue());
+  return DefInfo(DefMD, UndefLoc, !isPublic || *isPublic);
 
 if (UndefMacroDirective *UndefMD = dyn_cast(MD)) {
   UndefLoc = UndefMD->getLocation();

diff  --git a/lldb/tools/lldb-vscode/FifoFiles.cpp 
b/lldb/tools/lldb-vscode/FifoFiles.cpp
index e37f2020d8f19..b97455ba953fb 100644
--- a/lldb/tools/lldb-vscode/FifoFiles.cpp
+++ b/lldb/tools/lldb-vscode/FifoFiles.cpp
@@ -61,8 +61,7 @@ Expected 
FifoFileIO::ReadJSON(std::chrono::milliseconds timeout) {
 if (!buffer.empty())
   line = buffer;
   }));
-  if (future->wait_for(timeout) == std::future_status::timeout ||
-  !line.hasValue())
+  if (future->wait_for(timeout) == std::future_status::timeout || !line)
 return createStringError(inconvertibleErrorCode(),
  "Timed out trying to get messages from the " +
  m_other_endpoint_name);

diff  --git a/llvm/include/llvm/DebugInfo/GSYM/FunctionInfo.h 
b/llvm/include/llvm/DebugInfo/GSYM/FunctionInfo.h
index ed41d2b5b9d4c..a41b2fe2a6e76 100644
--- a/llvm/include/llvm/DebugInfo/GSYM/FunctionInfo.h
+++ b/llvm/include/llvm/DebugInfo/GSYM/FunctionInfo.h
@@ -102,9 +102,7 @@ struct FunctionInfo {
   /// debug info, we might end up with multiple FunctionInfo objects for the
   /// same range and we need to be able to tell which one is the better object
   /// to use.
-  bool hasRichInfo() const {
-return OptLineTable.hasValue() || Inline.hasValue();
-  }
+  bool hasRichInfo() const { return OptLineTable || Inline; }
 
   /// Query if a FunctionInfo object is valid.
   ///

diff 

[clang-tools-extra] 0916d96 - Don't use Optional::hasValue (NFC)

2022-06-20 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-06-20T20:17:57-07:00
New Revision: 0916d96d12fda355933a8f66ed2a1ccc855cab9c

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

LOG: Don't use Optional::hasValue (NFC)

Added: 


Modified: 
clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp
clang-tools-extra/clangd/CodeComplete.cpp
clang-tools-extra/clangd/Quality.cpp
clang-tools-extra/clangd/TUScheduler.cpp
clang-tools-extra/clangd/tool/Check.cpp
clang/include/clang/APINotes/Types.h
clang/include/clang/AST/Type.h
clang/lib/AST/ExprCXX.cpp
clang/lib/ASTMatchers/ASTMatchFinder.cpp
clang/lib/Lex/HeaderSearch.cpp
clang/lib/Sema/SemaExprCXX.cpp
clang/lib/StaticAnalyzer/Core/CallEvent.cpp
clang/lib/StaticAnalyzer/Core/RegionStore.cpp
clang/lib/Tooling/Syntax/BuildTree.cpp
clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
flang/lib/Lower/IO.cpp
flang/lib/Optimizer/Dialect/FIROps.cpp
lldb/source/Interpreter/CommandInterpreter.cpp
lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp
lldb/source/Symbol/CompileUnit.cpp
llvm/include/llvm/Analysis/InlineAdvisor.h
llvm/include/llvm/Analysis/ObjCARCUtil.h
llvm/include/llvm/DebugInfo/CodeView/TypeCollection.h
llvm/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h
llvm/lib/Analysis/ScalarEvolution.cpp
llvm/lib/Bitcode/Reader/BitcodeAnalyzer.cpp
llvm/lib/CodeGen/ExpandMemCmp.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/lib/CodeGen/ShadowStackGCLowering.cpp
llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp
llvm/lib/IR/ConstantFold.cpp
llvm/lib/IR/DebugInfoMetadata.cpp
llvm/lib/IR/VectorBuilder.cpp
llvm/lib/IR/Verifier.cpp
llvm/lib/MC/MCDwarf.cpp
llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
llvm/lib/Target/ARM/ARMISelLowering.cpp
llvm/lib/Target/Hexagon/MCTargetDesc/HexagonShuffler.cpp
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/lib/Transforms/IPO/AttributorAttributes.cpp
llvm/lib/Transforms/IPO/IROutliner.cpp
llvm/lib/Transforms/Scalar/LoopFlatten.cpp
llvm/lib/Transforms/Scalar/LoopInstSimplify.cpp
llvm/lib/Transforms/Scalar/PartiallyInlineLibCalls.cpp
llvm/lib/Transforms/Scalar/ScalarizeMaskedMemIntrin.cpp
mlir/include/mlir/Dialect/SPIRV/IR/SPIRVBase.td
mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp
mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp
mlir/lib/TableGen/AttrOrTypeDef.cpp
mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp
index 200528b1c061d..1efd88d7cbb95 100644
--- a/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp
@@ -799,7 +799,7 @@ void NotNullTerminatedResultCheck::check(
 Optional AreSafeFunctionsWanted;
 
 Preprocessor::macro_iterator It = PP->macro_begin();
-while (It != PP->macro_end() && !AreSafeFunctionsWanted.hasValue()) {
+while (It != PP->macro_end() && !AreSafeFunctionsWanted) {
   if (It->first->getName() == "__STDC_WANT_LIB_EXT1__") {
 const auto *MI = PP->getMacroInfo(It->first);
 // PP->getMacroInfo() returns nullptr if macro has no definition.

diff  --git a/clang-tools-extra/clangd/CodeComplete.cpp 
b/clang-tools-extra/clangd/CodeComplete.cpp
index eaf570da88da8..fbd7488c07d21 100644
--- a/clang-tools-extra/clangd/CodeComplete.cpp
+++ b/clang-tools-extra/clangd/CodeComplete.cpp
@@ -375,7 +375,7 @@ struct CodeCompletionBuilder {
   std::move(*Spelled),
   Includes.shouldInsertInclude(*ResolvedDeclaring, *ResolvedInserted));
 };
-bool ShouldInsert = C.headerToInsertIfAllowed(Opts).hasValue();
+bool ShouldInsert = C.headerToInsertIfAllowed(Opts).has_value();
 // Calculate include paths and edits for all possible headers.
 for (const auto  : C.RankedIncludeHeaders) {
   if (auto ToInclude = Inserted(Inc)) {

diff  --git a/clang-tools-extra/clangd/Quality.cpp 
b/clang-tools-extra/clangd/Quality.cpp
index 42eee14d28f42..0024e63955334 100644
--- a/clang-tools-extra/clangd/Quality.cpp
+++ b/clang-tools-extra/clangd/Quality.cpp
@@ -378,7 +378,7 @@ wordMatching(llvm::StringRef Name, const 

[clang-tools-extra] 064a08c - Don't use Optional::hasValue (NFC)

2022-06-20 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-06-20T20:05:16-07:00
New Revision: 064a08cd955019da9130f1109bfa534e79b8ec7c

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

LOG: Don't use Optional::hasValue (NFC)

Added: 


Modified: 
clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.cpp
clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
clang-tools-extra/clangd/TUScheduler.cpp
clang-tools-extra/clangd/refactor/tweaks/DumpAST.cpp
clang/include/clang/ASTMatchers/Dynamic/VariantValue.h
clang/include/clang/Basic/DirectoryEntry.h
clang/include/clang/Basic/FileEntry.h
clang/include/clang/Lex/Preprocessor.h
clang/include/clang/Sema/Sema.h
clang/lib/ASTMatchers/Dynamic/Marshallers.h
clang/lib/CodeGen/CGExprScalar.cpp
clang/lib/CodeGen/CoverageMappingGen.cpp
clang/lib/Lex/PPMacroExpansion.cpp
clang/lib/Sema/SemaTemplateDeduction.cpp
clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
flang/include/flang/Lower/ComponentPath.h
lld/wasm/Writer.cpp
lldb/include/lldb/Core/DataFileCache.h
lldb/source/API/SBMemoryRegionInfo.cpp
lldb/source/Breakpoint/BreakpointID.cpp
llvm/include/llvm/Analysis/LazyCallGraph.h
llvm/include/llvm/CodeGen/SelectionDAGAddressAnalysis.h
llvm/include/llvm/DebugInfo/DWARF/DWARFDebugFrame.h
llvm/include/llvm/IR/DebugInfoMetadata.h
llvm/include/llvm/IR/Function.h
llvm/include/llvm/ObjectYAML/ELFYAML.h
llvm/include/llvm/Support/Alignment.h
llvm/lib/Analysis/ProfileSummaryInfo.cpp
llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
llvm/lib/IR/LLVMContext.cpp
llvm/lib/ObjectYAML/COFFEmitter.cpp
llvm/lib/Remarks/RemarkLinker.cpp
llvm/lib/Remarks/RemarkParser.cpp
llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
llvm/lib/Target/AMDGPU/AMDGPUIGroupLP.cpp
llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp
llvm/tools/llvm-reduce/deltas/ReduceGlobalObjects.cpp
mlir/include/mlir/Analysis/DataFlowAnalysis.h
mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td
mlir/include/mlir/IR/Diagnostics.h
mlir/include/mlir/Support/StorageUniquer.h
mlir/include/mlir/Tools/PDLL/AST/Diagnostic.h
mlir/lib/Conversion/VectorToGPU/VectorToGPU.cpp
mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp
mlir/lib/Dialect/Affine/IR/AffineOps.cpp
mlir/lib/Dialect/Vector/Utils/VectorUtils.cpp
mlir/lib/IR/AsmPrinter.cpp
mlir/lib/IR/MLIRContext.cpp
mlir/lib/Support/Timing.cpp
mlir/lib/TableGen/Pattern.cpp
mlir/test/lib/Dialect/Test/TestDialect.cpp
mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.cpp 
b/clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.cpp
index 4eaf8bc6f392f..f7b4c3ef57938 100644
--- a/clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.cpp
+++ b/clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.cpp
@@ -66,7 +66,7 @@ getFileExtension(StringRef FileName, const FileExtensionsSet 
) {
 
 bool isFileExtension(StringRef FileName,
  const FileExtensionsSet ) {
-  return getFileExtension(FileName, FileExtensions).hasValue();
+  return getFileExtension(FileName, FileExtensions).has_value();
 }
 
 } // namespace utils

diff  --git a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp 
b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
index ce31f366cf174..2684b0de53bdb 100644
--- a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
+++ b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
@@ -530,7 +530,7 @@ class 
DirectoryBasedGlobalCompilationDatabase::BroadcastThread {
   bool blockUntilIdle(Deadline Timeout) {
 std::unique_lock Lock(Mu);
 return wait(Lock, CV, Timeout,
-[&] { return Queue.empty() && !ActiveTask.hasValue(); });
+[&] { return Queue.empty() && !ActiveTask; });
   }
 
   ~BroadcastThread() {

diff  --git a/clang-tools-extra/clangd/TUScheduler.cpp 
b/clang-tools-extra/clangd/TUScheduler.cpp
index f60fbfaa479f9..4bdcf0f3c80cd 100644
--- a/clang-tools-extra/clangd/TUScheduler.cpp
+++ b/clang-tools-extra/clangd/TUScheduler.cpp
@@ -1196,7 +1196,7 @@ std::shared_ptr 
ASTWorker::getPossiblyStalePreamble(
 
 void ASTWorker::waitForFirstPreamble() const {
   std::unique_lock Lock(Mutex);
-  PreambleCV.wait(Lock, [this] { return LatestPreamble.hasValue() || Done; });
+  PreambleCV.wait(Lock, [this] { return LatestPreamble || Done; });
 }
 
 tooling::CompileCommand ASTWorker::getCurrentCompileCommand() const {

diff  --git a/clang-tools-extra/clangd/refactor/tweaks/DumpAST.cpp 

[clang] 064a08c - Don't use Optional::hasValue (NFC)

2022-06-20 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-06-20T20:05:16-07:00
New Revision: 064a08cd955019da9130f1109bfa534e79b8ec7c

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

LOG: Don't use Optional::hasValue (NFC)

Added: 


Modified: 
clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.cpp
clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
clang-tools-extra/clangd/TUScheduler.cpp
clang-tools-extra/clangd/refactor/tweaks/DumpAST.cpp
clang/include/clang/ASTMatchers/Dynamic/VariantValue.h
clang/include/clang/Basic/DirectoryEntry.h
clang/include/clang/Basic/FileEntry.h
clang/include/clang/Lex/Preprocessor.h
clang/include/clang/Sema/Sema.h
clang/lib/ASTMatchers/Dynamic/Marshallers.h
clang/lib/CodeGen/CGExprScalar.cpp
clang/lib/CodeGen/CoverageMappingGen.cpp
clang/lib/Lex/PPMacroExpansion.cpp
clang/lib/Sema/SemaTemplateDeduction.cpp
clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
flang/include/flang/Lower/ComponentPath.h
lld/wasm/Writer.cpp
lldb/include/lldb/Core/DataFileCache.h
lldb/source/API/SBMemoryRegionInfo.cpp
lldb/source/Breakpoint/BreakpointID.cpp
llvm/include/llvm/Analysis/LazyCallGraph.h
llvm/include/llvm/CodeGen/SelectionDAGAddressAnalysis.h
llvm/include/llvm/DebugInfo/DWARF/DWARFDebugFrame.h
llvm/include/llvm/IR/DebugInfoMetadata.h
llvm/include/llvm/IR/Function.h
llvm/include/llvm/ObjectYAML/ELFYAML.h
llvm/include/llvm/Support/Alignment.h
llvm/lib/Analysis/ProfileSummaryInfo.cpp
llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
llvm/lib/IR/LLVMContext.cpp
llvm/lib/ObjectYAML/COFFEmitter.cpp
llvm/lib/Remarks/RemarkLinker.cpp
llvm/lib/Remarks/RemarkParser.cpp
llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
llvm/lib/Target/AMDGPU/AMDGPUIGroupLP.cpp
llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp
llvm/tools/llvm-reduce/deltas/ReduceGlobalObjects.cpp
mlir/include/mlir/Analysis/DataFlowAnalysis.h
mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td
mlir/include/mlir/IR/Diagnostics.h
mlir/include/mlir/Support/StorageUniquer.h
mlir/include/mlir/Tools/PDLL/AST/Diagnostic.h
mlir/lib/Conversion/VectorToGPU/VectorToGPU.cpp
mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp
mlir/lib/Dialect/Affine/IR/AffineOps.cpp
mlir/lib/Dialect/Vector/Utils/VectorUtils.cpp
mlir/lib/IR/AsmPrinter.cpp
mlir/lib/IR/MLIRContext.cpp
mlir/lib/Support/Timing.cpp
mlir/lib/TableGen/Pattern.cpp
mlir/test/lib/Dialect/Test/TestDialect.cpp
mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.cpp 
b/clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.cpp
index 4eaf8bc6f392f..f7b4c3ef57938 100644
--- a/clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.cpp
+++ b/clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.cpp
@@ -66,7 +66,7 @@ getFileExtension(StringRef FileName, const FileExtensionsSet 
) {
 
 bool isFileExtension(StringRef FileName,
  const FileExtensionsSet ) {
-  return getFileExtension(FileName, FileExtensions).hasValue();
+  return getFileExtension(FileName, FileExtensions).has_value();
 }
 
 } // namespace utils

diff  --git a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp 
b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
index ce31f366cf174..2684b0de53bdb 100644
--- a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
+++ b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
@@ -530,7 +530,7 @@ class 
DirectoryBasedGlobalCompilationDatabase::BroadcastThread {
   bool blockUntilIdle(Deadline Timeout) {
 std::unique_lock Lock(Mu);
 return wait(Lock, CV, Timeout,
-[&] { return Queue.empty() && !ActiveTask.hasValue(); });
+[&] { return Queue.empty() && !ActiveTask; });
   }
 
   ~BroadcastThread() {

diff  --git a/clang-tools-extra/clangd/TUScheduler.cpp 
b/clang-tools-extra/clangd/TUScheduler.cpp
index f60fbfaa479f9..4bdcf0f3c80cd 100644
--- a/clang-tools-extra/clangd/TUScheduler.cpp
+++ b/clang-tools-extra/clangd/TUScheduler.cpp
@@ -1196,7 +1196,7 @@ std::shared_ptr 
ASTWorker::getPossiblyStalePreamble(
 
 void ASTWorker::waitForFirstPreamble() const {
   std::unique_lock Lock(Mutex);
-  PreambleCV.wait(Lock, [this] { return LatestPreamble.hasValue() || Done; });
+  PreambleCV.wait(Lock, [this] { return LatestPreamble || Done; });
 }
 
 tooling::CompileCommand ASTWorker::getCurrentCompileCommand() const {

diff  --git a/clang-tools-extra/clangd/refactor/tweaks/DumpAST.cpp 

[PATCH] D128235: [RISCV] Add support for the Zawrs extension

2022-06-20 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/test/Driver/riscv-arch.c:585
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-ZAWRS-GOOD %s
+// RV32-ZHINX-GOOD: "-target-feature" "+zawrs"
+

This doesn't match the RUN line



Comment at: clang/test/Driver/riscv-arch.c:589
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV64-ZAWRS-GOOD %s
+// RV64-ZHINX-GOOD: "-target-feature" "+zawrs"

This doesn't match the RUN line



Comment at: clang/test/Preprocessor/riscv-target-features.c:444
+// RUN: | FileCheck --check-prefix=CHECK-ZAWRS %s
+// CHECK-COMBINE-INTO-ZKS: __riscv_zawrs 1

This CHECK directive doesn't match the RUN line


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

https://reviews.llvm.org/D128235

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


[PATCH] D128235: [RISCV] Add support for the Zawrs extension

2022-06-20 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD added a comment.

Looks like the patch application failed, might need to rebase.


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

https://reviews.llvm.org/D128235

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


[PATCH] D128235: [RISCV] Add support for the Zawrs extension

2022-06-20 Thread Palmer Dabbelt via Phabricator via cfe-commits
palmer-dabbelt updated this revision to Diff 438515.
palmer-dabbelt added a comment.
Herald added a subscriber: jdoerfert.

- Fix a whitespace issue
- Fix the name of RISCVInstrInfoZawrs.td
- Call the #define __riscv_zawrs instead of __riscv_wrs, to match the others
- Add tests in clang/test/Driver/riscv-arch.c, 
clang/test/Preprocessor/riscv-target-features.c, 
llvm/test/CodeGen/RISCV/attributes.ll

The clang tests aren't running for me, presumably because clang isn't building 
locally.  Also hoping to rely on CI for that one, but I'm not entirely sure.


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

https://reviews.llvm.org/D128235

Files:
  clang/lib/Basic/Targets/RISCV.cpp
  clang/test/Driver/riscv-arch.c
  clang/test/Preprocessor/riscv-target-features.c
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/RISCV.td
  llvm/lib/Target/RISCV/RISCVInstrInfo.td
  llvm/lib/Target/RISCV/RISCVInstrInfoZawrs.td
  llvm/lib/Target/RISCV/RISCVSubtarget.h
  llvm/test/CodeGen/RISCV/attributes.ll
  llvm/test/MC/RISCV/zawrs-invalid.s
  llvm/test/MC/RISCV/zawrs-valid.s

Index: llvm/test/MC/RISCV/zawrs-valid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/zawrs-valid.s
@@ -0,0 +1,16 @@
+# RUN: llvm-mc %s -triple=riscv32 -mattr=+zawrs \
+# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ %s
+# RUN: llvm-mc %s -triple=riscv64 -mattr=+zawrs \
+# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ %s
+# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+zawrs < %s \
+# RUN: | llvm-objdump --mattr=+zawrs -d -r - \
+# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ %s
+# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+zawrs < %s \
+# RUN: | llvm-objdump --mattr=+zawrs -d -r - \
+# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ %s
+
+# CHECK-S-OBJ: wrs
+wrs
+
+# CHECK-S-OBJ: wrs t0
+wrs t0
Index: llvm/test/MC/RISCV/zawrs-invalid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/zawrs-invalid.s
@@ -0,0 +1,8 @@
+# RUN: not llvm-mc -triple riscv64 -mattr=+a < %s 2>&1 | FileCheck %s
+
+# WRS doesn't take immediates
+wrs 1 # CHECK: :[[@LINE]]:5: error: invalid operand for instruction
+
+# WRS only takes at most a single register
+wrs t0, 1 # CHECK: :[[@LINE]]:9: error: invalid operand for instruction
+wrs t0, t0 # CHECK: :[[@LINE]]:9: error: invalid operand for instruction
Index: llvm/test/CodeGen/RISCV/attributes.ll
===
--- llvm/test/CodeGen/RISCV/attributes.ll
+++ llvm/test/CodeGen/RISCV/attributes.ll
@@ -36,6 +36,7 @@
 ; RUN: llc -mtriple=riscv32 -mattr=+zkn,+zkr,+zkt %s -o - | FileCheck --check-prefix=RV32COMBINEINTOZK %s
 ; RUN: llc -mtriple=riscv32 -mattr=+zbkb,+zbkc,+zbkx,+zkne,+zknd,+zknh %s -o - | FileCheck --check-prefix=RV32COMBINEINTOZKN %s
 ; RUN: llc -mtriple=riscv32 -mattr=+zbkb,+zbkc,+zbkx,+zksed,+zksh %s -o - | FileCheck --check-prefix=RV32COMBINEINTOZKS %s
+; RUN: llc -mtriple=riscv32 -mattr=+zawrs %s -o - | FileCheck --check-prefix=RV32ZAWRS %s
 ; RUN: llc -mtriple=riscv64 -mattr=+m %s -o - | FileCheck --check-prefix=RV64M %s
 ; RUN: llc -mtriple=riscv64 -mattr=+a %s -o - | FileCheck --check-prefix=RV64A %s
 ; RUN: llc -mtriple=riscv64 -mattr=+f %s -o - | FileCheck --check-prefix=RV64F %s
@@ -72,6 +73,7 @@
 ; RUN: llc -mtriple=riscv64 -mattr=+zkn,+zkr,+zkt %s -o - | FileCheck --check-prefix=RV64COMBINEINTOZK %s
 ; RUN: llc -mtriple=riscv64 -mattr=+zbkb,+zbkc,+zbkx,+zkne,+zknd,+zknh %s -o - | FileCheck --check-prefix=RV64COMBINEINTOZKN %s
 ; RUN: llc -mtriple=riscv64 -mattr=+zbkb,+zbkc,+zbkx,+zksed,+zksh %s -o - | FileCheck --check-prefix=RV64COMBINEINTOZKS %s
+; RUN: llc -mtriple=riscv64 -mattr=+zawrs %s -o - | FileCheck --check-prefix=RV64ZAWRS %s
 
 ; RV32M: .attribute 5, "rv32i2p0_m2p0"
 ; RV32A: .attribute 5, "rv32i2p0_a2p0"
@@ -109,6 +111,7 @@
 ; RV32COMBINEINTOZK: .attribute 5, "rv32i2p0_zbkb1p0_zbkc1p0_zbkx1p0_zk1p0_zkn1p0_zknd1p0_zkne1p0_zknh1p0_zkr1p0_zkt1p0"
 ; RV32COMBINEINTOZKN: .attribute 5, "rv32i2p0_zbkb1p0_zbkc1p0_zbkx1p0_zkn1p0_zknd1p0_zkne1p0_zknh1p0"
 ; RV32COMBINEINTOZKS: .attribute 5, "rv32i2p0_zbkb1p0_zbkc1p0_zbkx1p0_zks1p0_zksed1p0_zksh1p0"
+; RV32ZAWRS: .attribute 5, "rv32i2p0_zawrs1p0"
 
 ; RV64M: .attribute 5, "rv64i2p0_m2p0"
 ; RV64A: .attribute 5, "rv64i2p0_a2p0"
@@ -146,6 +149,7 @@
 ; RV64COMBINEINTOZK: .attribute 5, "rv64i2p0_zbkb1p0_zbkc1p0_zbkx1p0_zk1p0_zkn1p0_zknd1p0_zkne1p0_zknh1p0_zkr1p0_zkt1p0"
 ; RV64COMBINEINTOZKN: .attribute 5, "rv64i2p0_zbkb1p0_zbkc1p0_zbkx1p0_zkn1p0_zknd1p0_zkne1p0_zknh1p0"
 ; RV64COMBINEINTOZKS: .attribute 5, "rv64i2p0_zbkb1p0_zbkc1p0_zbkx1p0_zks1p0_zksed1p0_zksh1p0"
+; RV64ZAWRS: .attribute 5, "rv64i2p0_zawrs1p0"
 
 define i32 @addi(i32 %a) {
   %1 = add i32 %a, 1
Index: llvm/lib/Target/RISCV/RISCVSubtarget.h
===
--- llvm/lib/Target/RISCV/RISCVSubtarget.h
+++ 

[PATCH] D128134: [Driver] Pass -X to ld for riscv64-fuchsia

2022-06-20 Thread Brad Smith via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7c5957aedb75: [Driver] Pass -X to ld for riscv64-fuchsia 
(authored by brad).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128134

Files:
  clang/lib/Driver/ToolChains/Fuchsia.cpp
  clang/test/Driver/fuchsia.c


Index: clang/test/Driver/fuchsia.c
===
--- clang/test/Driver/fuchsia.c
+++ clang/test/Driver/fuchsia.c
@@ -43,6 +43,7 @@
 // CHECK: "--hash-style=gnu"
 // CHECK-AARCH64: "--fix-cortex-a53-843419"
 // CHECK: "-dynamic-linker" "ld.so.1"
+// CHECK-RISCV64: "-X"
 // CHECK: Scrt1.o
 // CHECK-NOT: crti.o
 // CHECK-NOT: crtbegin.o
Index: clang/lib/Driver/ToolChains/Fuchsia.cpp
===
--- clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -114,6 +114,9 @@
 CmdArgs.push_back(Args.MakeArgString(Dyld));
   }
 
+  if (ToolChain.getArch() == llvm::Triple::riscv64)
+CmdArgs.push_back("-X");
+
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
 


Index: clang/test/Driver/fuchsia.c
===
--- clang/test/Driver/fuchsia.c
+++ clang/test/Driver/fuchsia.c
@@ -43,6 +43,7 @@
 // CHECK: "--hash-style=gnu"
 // CHECK-AARCH64: "--fix-cortex-a53-843419"
 // CHECK: "-dynamic-linker" "ld.so.1"
+// CHECK-RISCV64: "-X"
 // CHECK: Scrt1.o
 // CHECK-NOT: crti.o
 // CHECK-NOT: crtbegin.o
Index: clang/lib/Driver/ToolChains/Fuchsia.cpp
===
--- clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -114,6 +114,9 @@
 CmdArgs.push_back(Args.MakeArgString(Dyld));
   }
 
+  if (ToolChain.getArch() == llvm::Triple::riscv64)
+CmdArgs.push_back("-X");
+
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 7c5957a - [Driver] Pass -X to ld for riscv64-fuchsia

2022-06-20 Thread Brad Smith via cfe-commits

Author: Brad Smith
Date: 2022-06-20T21:05:01-04:00
New Revision: 7c5957aedb75f381cd9996f9eba96f3add16a721

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

LOG: [Driver] Pass -X to ld for riscv64-fuchsia

D127826, add support for Fuchsia which uses lld on riscv64

Reviewed By: MaskRay, phosek

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Fuchsia.cpp
clang/test/Driver/fuchsia.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Fuchsia.cpp 
b/clang/lib/Driver/ToolChains/Fuchsia.cpp
index e81c40c74fdbf..03ff9fe894c88 100644
--- a/clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ b/clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -114,6 +114,9 @@ void fuchsia::Linker::ConstructJob(Compilation , const 
JobAction ,
 CmdArgs.push_back(Args.MakeArgString(Dyld));
   }
 
+  if (ToolChain.getArch() == llvm::Triple::riscv64)
+CmdArgs.push_back("-X");
+
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
 

diff  --git a/clang/test/Driver/fuchsia.c b/clang/test/Driver/fuchsia.c
index 996f5862bbd47..99c43f4cecabd 100644
--- a/clang/test/Driver/fuchsia.c
+++ b/clang/test/Driver/fuchsia.c
@@ -43,6 +43,7 @@
 // CHECK: "--hash-style=gnu"
 // CHECK-AARCH64: "--fix-cortex-a53-843419"
 // CHECK: "-dynamic-linker" "ld.so.1"
+// CHECK-RISCV64: "-X"
 // CHECK: Scrt1.o
 // CHECK-NOT: crti.o
 // CHECK-NOT: crtbegin.o



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


[PATCH] D128235: [RISCV] Add support for the Zawrs extension

2022-06-20 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD added a comment.

- I think we will need some test coverage under 
`llvm/test/CodeGen/RISCV/attributes.ll` and 
`llvm/test/MC/RISCV/attribute-arch.s` if the extension is existing in the arch 
string.
- Since macro is added, we need some test coverage under 
`clang/test/Preprocessor/riscv-target-features.c`
- There is also some test case for error handling under 
`clang/test/Driver/riscv-arch.c`, maybe add some there too?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128235

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


[PATCH] D128235: [RISCV] Add support for the Zawrs extension

2022-06-20 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD added a comment.

In D128235#3597645 , @palmer-dabbelt 
wrote:

> I've never touched LLVM before, so I have no idea if I'm even in the right 
> place here...

Yes, you are in the right place.
All LLVM patches go through the Phabricator.
A patch goes in when at least one person accepts it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128235

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


[PATCH] D128235: [RISCV] Add support for the Zawrs extension

2022-06-20 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD added inline comments.



Comment at: llvm/lib/Target/RISCV/RISCVInstrInfoZawrs.td:1
+//===-- RISCVInstrInfoM.td - RISC-V 'M' instructions ---*- tablegen 
-*-===//
+//

This doesn't match the filename.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128235

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


[PATCH] D128235: [RISCV] Add support for the Zawrs extension

2022-06-20 Thread Palmer Dabbelt via Phabricator via cfe-commits
palmer-dabbelt added a comment.

I've never touched LLVM before, so I have no idea if I'm even in the right 
place here...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128235

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


[PATCH] D128235: [RISCV] Add support for the Zawrs extension

2022-06-20 Thread Palmer Dabbelt via Phabricator via cfe-commits
palmer-dabbelt created this revision.
palmer-dabbelt added reviewers: reames, asb.
Herald added subscribers: sunshaoce, VincentWu, luke957, StephenFan, vkmr, 
frasercrmck, evandro, luismarques, apazos, sameer.abuasal, s.egerton, Jim, 
benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, 
edward-jones, zzheng, jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, 
simoncook, johnrusso, rbar, hiraditya, arichardson.
Herald added a project: All.
palmer-dabbelt requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, pcwang-thead, eopXD, 
MaskRay.
Herald added projects: clang, LLVM.

This extension contains a single instruction, wrs, which waits for the
current reservation set to be modified by a remote agent.

Signed-off-by: Palmer Dabbelt 

---

This is still some sort of very early draft and I'm not sure what the
rules are in LLVM land for merging that sort of code.  It's a fast track
extension so it should be done soon, but it's been drifting around a bit
as part of that process so this might not be sane right now.  I'm really
just doing this to check the box on LLVM support, which is just
assembler support due to the nature of the WRS instruction.

I also haven't gotten clang-format working yet, but I'm hoping something
in the CI will help with that.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128235

Files:
  clang/lib/Basic/Targets/RISCV.cpp
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/RISCV.td
  llvm/lib/Target/RISCV/RISCVInstrInfo.td
  llvm/lib/Target/RISCV/RISCVInstrInfoZawrs.td
  llvm/lib/Target/RISCV/RISCVSubtarget.h
  llvm/test/MC/RISCV/zawrs-invalid.s
  llvm/test/MC/RISCV/zawrs-valid.s

Index: llvm/test/MC/RISCV/zawrs-valid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/zawrs-valid.s
@@ -0,0 +1,16 @@
+# RUN: llvm-mc %s -triple=riscv32 -mattr=+zawrs \
+# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ %s
+# RUN: llvm-mc %s -triple=riscv64 -mattr=+zawrs \
+# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ %s
+# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+zawrs < %s \
+# RUN: | llvm-objdump --mattr=+zawrs -d -r - \
+# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ %s
+# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+zawrs < %s \
+# RUN: | llvm-objdump --mattr=+zawrs -d -r - \
+# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ %s
+
+# CHECK-S-OBJ: wrs
+wrs
+
+# CHECK-S-OBJ: wrs t0
+wrs t0
Index: llvm/test/MC/RISCV/zawrs-invalid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/zawrs-invalid.s
@@ -0,0 +1,8 @@
+# RUN: not llvm-mc -triple riscv64 -mattr=+a < %s 2>&1 | FileCheck %s
+
+# WRS doesn't take immediates
+wrs 1 # CHECK: :[[@LINE]]:5: error: invalid operand for instruction
+
+# WRS only takes at most a single register
+wrs t0, 1 # CHECK: :[[@LINE]]:9: error: invalid operand for instruction
+wrs t0, t0 # CHECK: :[[@LINE]]:9: error: invalid operand for instruction
Index: llvm/lib/Target/RISCV/RISCVSubtarget.h
===
--- llvm/lib/Target/RISCV/RISCVSubtarget.h
+++ llvm/lib/Target/RISCV/RISCVSubtarget.h
@@ -86,6 +86,7 @@
   bool HasStdExtZks = false;
   bool HasStdExtZkt = false;
   bool HasStdExtZk = false;
+  bool HasStdExtZawrs = false;
   bool HasRV64 = false;
   bool IsRV32E = false;
   bool EnableLinkerRelax = false;
@@ -177,6 +178,7 @@
   bool hasStdExtZksed() const { return HasStdExtZksed; }
   bool hasStdExtZksh() const { return HasStdExtZksh; }
   bool hasStdExtZkr() const { return HasStdExtZkr; }
+  bool hasStdExtZawrs() const { return HasStdExtZawrs; }
   bool is64Bit() const { return HasRV64; }
   bool isRV32E() const { return IsRV32E; }
   bool enableLinkerRelax() const { return EnableLinkerRelax; }
Index: llvm/lib/Target/RISCV/RISCVInstrInfoZawrs.td
===
--- /dev/null
+++ llvm/lib/Target/RISCV/RISCVInstrInfoZawrs.td
@@ -0,0 +1,21 @@
+//===-- RISCVInstrInfoM.td - RISC-V 'M' 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 'Zawrs', Wait
+// Reservation Set, extension.
+//
+//===--===//
+
+let Predicates = [HasStdExtZawrs], hasSideEffects = 1, mayStore = 0, mayLoad = 0 in {
+  def WRS : RVInstI<0b000, OPC_SYSTEM, (outs), (ins GPR:$rs1), "wrs", "$rs1">, Sched<[]> {
+let rd = 0;
+let imm12 = 0x010;
+  }
+}
+
+def : InstAlias<"wrs", (WRS X0)>;
Index: llvm/lib/Target/RISCV/RISCVInstrInfo.td

[PATCH] D126364: Fix interaction of pragma FENV_ACCESS with other pragmas

2022-06-20 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126364

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


[clang] 5ba0a95 - [Clang][VE] Add missing intrinsics

2022-06-20 Thread Kazushi Marukawa via cfe-commits

Author: Kazushi (Jam) Marukawa
Date: 2022-06-21T07:30:36+09:00
New Revision: 5ba0a9571b3ee3bc76f65e16549012a440d5a0fb

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

LOG: [Clang][VE] Add missing intrinsics

Add missing intrinsics and tests for them.  An expanding  macro
from _vel_pack_f32p to __builtin_ve_vl_pack_f32p and others is
already defined in clang/lib/Headers/velintrin.h.

Reviewed By: efocht

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

Added: 


Modified: 
clang/include/clang/Basic/BuiltinsVE.def
clang/test/CodeGen/VE/ve-velintrin.c

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsVE.def 
b/clang/include/clang/Basic/BuiltinsVE.def
index 29b2bd203ef0f..3bffb241d8dc6 100644
--- a/clang/include/clang/Basic/BuiltinsVE.def
+++ b/clang/include/clang/Basic/BuiltinsVE.def
@@ -15,6 +15,16 @@
 #   define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) BUILTIN(ID, TYPE, ATTRS)
 #endif
 
+// The format of this database is decribed in clang/Basic/Builtins.def.
+
+BUILTIN(__builtin_ve_vl_pack_f32p, "ULifC*fC*", "n")
+BUILTIN(__builtin_ve_vl_pack_f32a, "ULifC*", "n")
+
+BUILTIN(__builtin_ve_vl_extract_vm512u, "V256bV512b", "n")
+BUILTIN(__builtin_ve_vl_extract_vm512l, "V256bV512b", "n")
+BUILTIN(__builtin_ve_vl_insert_vm512u, "V512bV512bV256b", "n")
+BUILTIN(__builtin_ve_vl_insert_vm512l, "V512bV512bV256b", "n")
+
 // Use generated BUILTIN definitions
 #include "clang/Basic/BuiltinsVEVL.gen.def"
 

diff  --git a/clang/test/CodeGen/VE/ve-velintrin.c 
b/clang/test/CodeGen/VE/ve-velintrin.c
index 1a9aea66ea01e..f9942751fff9c 100644
--- a/clang/test/CodeGen/VE/ve-velintrin.c
+++ b/clang/test/CodeGen/VE/ve-velintrin.c
@@ -1,7 +1,7 @@
 // REQUIRES: ve-registered-target
 
-// RUN: %clang_cc1 -no-opaque-pointers -S -emit-llvm -triple 
ve-unknown-linux-gnu \
-// RUN:   -ffreestanding %s -o - | FileCheck %s
+// RUN: %clang_cc1 -S -emit-llvm -triple ve-unknown-linux-gnu \
+// RUN:   -no-opaque-pointers -ffreestanding %s -o - | FileCheck %s
 
 #include 
 
@@ -8811,3 +8811,48 @@ test_svob() {
   // CHECK: call void @llvm.ve.vl.svob()
   _vel_svob();
 }
+
+void __attribute__((noinline))
+test_pack_f32p(float* p1, float* p2) {
+  // CHECK-LABEL: @test_pack_f32p
+  // CHECK: %[[VAR1:[A-Za-z0-9.]+]] = bitcast float* %{{.*}} to i8*
+  // CHECK: %[[VAR2:[A-Za-z0-9.]+]] = bitcast float* %{{.*}} to i8*
+  // CHECK-NEXT: call i64 @llvm.ve.vl.pack.f32p(i8* %[[VAR1]], i8* %[[VAR2]])
+  v1 = _vel_pack_f32p(p1, p2);
+}
+
+void __attribute__((noinline))
+test_pack_f32a(float* p) {
+  // CHECK-LABEL: @test_pack_f32a
+  // CHECK: %[[VAR3:[A-Za-z0-9.]+]] = bitcast float* %{{.*}} to i8*
+  // CHECK-NEXT: call i64 @llvm.ve.vl.pack.f32a(i8* %[[VAR3]])
+  v1 = _vel_pack_f32a(p);
+}
+
+void __attribute__((noinline))
+test_extract_vm512u() {
+  // CHECK-LABEL: @test_extract_vm512u
+  // CHECK: call <256 x i1> @llvm.ve.vl.extract.vm512u(<512 x i1> %{{.*}})
+  vm1 = _vel_extract_vm512u(vm1_512);
+}
+
+void __attribute__((noinline))
+test_extract_vm512l() {
+  // CHECK-LABEL: @test_extract_vm512l
+  // CHECK: call <256 x i1> @llvm.ve.vl.extract.vm512l(<512 x i1> %{{.*}})
+  vm1 = _vel_extract_vm512l(vm1_512);
+}
+
+void __attribute__((noinline))
+test_insert_vm512u() {
+  // CHECK-LABEL: @test_insert_vm512u
+  // CHECK: call <512 x i1> @llvm.ve.vl.insert.vm512u(<512 x i1> %{{.*}}, <256 
x i1> %{{.*}})
+  vm1_512 = _vel_insert_vm512u(vm1_512, vm1);
+}
+
+void __attribute__((noinline))
+test_insert_vm512l() {
+  // CHECK-LABEL: @test_insert_vm512l
+  // CHECK: call <512 x i1> @llvm.ve.vl.insert.vm512l(<512 x i1> %{{.*}}, <256 
x i1> %{{.*}})
+  vm1_512 = _vel_insert_vm512l(vm1_512, vm1);
+}



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


[PATCH] D128120: [Clang][VE] Add missing intrinsics

2022-06-20 Thread Kazushi Marukawa via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5ba0a9571b3e: [Clang][VE] Add missing intrinsics (authored 
by kaz7).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128120

Files:
  clang/include/clang/Basic/BuiltinsVE.def
  clang/test/CodeGen/VE/ve-velintrin.c


Index: clang/test/CodeGen/VE/ve-velintrin.c
===
--- clang/test/CodeGen/VE/ve-velintrin.c
+++ clang/test/CodeGen/VE/ve-velintrin.c
@@ -1,7 +1,7 @@
 // REQUIRES: ve-registered-target
 
-// RUN: %clang_cc1 -no-opaque-pointers -S -emit-llvm -triple 
ve-unknown-linux-gnu \
-// RUN:   -ffreestanding %s -o - | FileCheck %s
+// RUN: %clang_cc1 -S -emit-llvm -triple ve-unknown-linux-gnu \
+// RUN:   -no-opaque-pointers -ffreestanding %s -o - | FileCheck %s
 
 #include 
 
@@ -8811,3 +8811,48 @@
   // CHECK: call void @llvm.ve.vl.svob()
   _vel_svob();
 }
+
+void __attribute__((noinline))
+test_pack_f32p(float* p1, float* p2) {
+  // CHECK-LABEL: @test_pack_f32p
+  // CHECK: %[[VAR1:[A-Za-z0-9.]+]] = bitcast float* %{{.*}} to i8*
+  // CHECK: %[[VAR2:[A-Za-z0-9.]+]] = bitcast float* %{{.*}} to i8*
+  // CHECK-NEXT: call i64 @llvm.ve.vl.pack.f32p(i8* %[[VAR1]], i8* %[[VAR2]])
+  v1 = _vel_pack_f32p(p1, p2);
+}
+
+void __attribute__((noinline))
+test_pack_f32a(float* p) {
+  // CHECK-LABEL: @test_pack_f32a
+  // CHECK: %[[VAR3:[A-Za-z0-9.]+]] = bitcast float* %{{.*}} to i8*
+  // CHECK-NEXT: call i64 @llvm.ve.vl.pack.f32a(i8* %[[VAR3]])
+  v1 = _vel_pack_f32a(p);
+}
+
+void __attribute__((noinline))
+test_extract_vm512u() {
+  // CHECK-LABEL: @test_extract_vm512u
+  // CHECK: call <256 x i1> @llvm.ve.vl.extract.vm512u(<512 x i1> %{{.*}})
+  vm1 = _vel_extract_vm512u(vm1_512);
+}
+
+void __attribute__((noinline))
+test_extract_vm512l() {
+  // CHECK-LABEL: @test_extract_vm512l
+  // CHECK: call <256 x i1> @llvm.ve.vl.extract.vm512l(<512 x i1> %{{.*}})
+  vm1 = _vel_extract_vm512l(vm1_512);
+}
+
+void __attribute__((noinline))
+test_insert_vm512u() {
+  // CHECK-LABEL: @test_insert_vm512u
+  // CHECK: call <512 x i1> @llvm.ve.vl.insert.vm512u(<512 x i1> %{{.*}}, <256 
x i1> %{{.*}})
+  vm1_512 = _vel_insert_vm512u(vm1_512, vm1);
+}
+
+void __attribute__((noinline))
+test_insert_vm512l() {
+  // CHECK-LABEL: @test_insert_vm512l
+  // CHECK: call <512 x i1> @llvm.ve.vl.insert.vm512l(<512 x i1> %{{.*}}, <256 
x i1> %{{.*}})
+  vm1_512 = _vel_insert_vm512l(vm1_512, vm1);
+}
Index: clang/include/clang/Basic/BuiltinsVE.def
===
--- clang/include/clang/Basic/BuiltinsVE.def
+++ clang/include/clang/Basic/BuiltinsVE.def
@@ -15,6 +15,16 @@
 #   define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) BUILTIN(ID, TYPE, ATTRS)
 #endif
 
+// The format of this database is decribed in clang/Basic/Builtins.def.
+
+BUILTIN(__builtin_ve_vl_pack_f32p, "ULifC*fC*", "n")
+BUILTIN(__builtin_ve_vl_pack_f32a, "ULifC*", "n")
+
+BUILTIN(__builtin_ve_vl_extract_vm512u, "V256bV512b", "n")
+BUILTIN(__builtin_ve_vl_extract_vm512l, "V256bV512b", "n")
+BUILTIN(__builtin_ve_vl_insert_vm512u, "V512bV512bV256b", "n")
+BUILTIN(__builtin_ve_vl_insert_vm512l, "V512bV512bV256b", "n")
+
 // Use generated BUILTIN definitions
 #include "clang/Basic/BuiltinsVEVL.gen.def"
 


Index: clang/test/CodeGen/VE/ve-velintrin.c
===
--- clang/test/CodeGen/VE/ve-velintrin.c
+++ clang/test/CodeGen/VE/ve-velintrin.c
@@ -1,7 +1,7 @@
 // REQUIRES: ve-registered-target
 
-// RUN: %clang_cc1 -no-opaque-pointers -S -emit-llvm -triple ve-unknown-linux-gnu \
-// RUN:   -ffreestanding %s -o - | FileCheck %s
+// RUN: %clang_cc1 -S -emit-llvm -triple ve-unknown-linux-gnu \
+// RUN:   -no-opaque-pointers -ffreestanding %s -o - | FileCheck %s
 
 #include 
 
@@ -8811,3 +8811,48 @@
   // CHECK: call void @llvm.ve.vl.svob()
   _vel_svob();
 }
+
+void __attribute__((noinline))
+test_pack_f32p(float* p1, float* p2) {
+  // CHECK-LABEL: @test_pack_f32p
+  // CHECK: %[[VAR1:[A-Za-z0-9.]+]] = bitcast float* %{{.*}} to i8*
+  // CHECK: %[[VAR2:[A-Za-z0-9.]+]] = bitcast float* %{{.*}} to i8*
+  // CHECK-NEXT: call i64 @llvm.ve.vl.pack.f32p(i8* %[[VAR1]], i8* %[[VAR2]])
+  v1 = _vel_pack_f32p(p1, p2);
+}
+
+void __attribute__((noinline))
+test_pack_f32a(float* p) {
+  // CHECK-LABEL: @test_pack_f32a
+  // CHECK: %[[VAR3:[A-Za-z0-9.]+]] = bitcast float* %{{.*}} to i8*
+  // CHECK-NEXT: call i64 @llvm.ve.vl.pack.f32a(i8* %[[VAR3]])
+  v1 = _vel_pack_f32a(p);
+}
+
+void __attribute__((noinline))
+test_extract_vm512u() {
+  // CHECK-LABEL: @test_extract_vm512u
+  // CHECK: call <256 x i1> @llvm.ve.vl.extract.vm512u(<512 x i1> %{{.*}})
+  vm1 = _vel_extract_vm512u(vm1_512);
+}
+
+void __attribute__((noinline))
+test_extract_vm512l() {
+  // CHECK-LABEL: @test_extract_vm512l
+  // 

[PATCH] D127313: [libc++] Implement P0618R0 (Deprecating )

2022-06-20 Thread Nikolas Klauser via Phabricator via cfe-commits
philnik updated this revision to Diff 438486.
philnik added a comment.

- Try to fix CI


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127313

Files:
  libcxx/docs/ReleaseNotes.rst
  libcxx/docs/Status/Cxx17Papers.csv
  libcxx/include/codecvt
  libcxx/include/locale
  libcxx/src/locale.cpp
  
libcxx/test/libcxx/localization/locales/locale.convenience/conversions/conversions.string/ctor_move.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_mode.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf16.pass.cpp
  
libcxx/test/std/localization/locale.stdcvt/codecvt_utf16_always_noconv.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf16_encoding.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf16_in.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf16_length.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf16_max_length.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf16_out.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf16_unshift.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf8.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_always_noconv.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_encoding.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_in.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_length.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_max_length.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_out.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_unshift.pass.cpp
  
libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_always_noconv.pass.cpp
  
libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_encoding.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_in.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_length.pass.cpp
  
libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_max_length.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_out.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_unshift.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/depr.verify.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/ctor.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/depr.verify.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/overflow.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/pbackfail.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/rdbuf.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/seekoff.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/state.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/test.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/underflow.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/converted.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/ctor_codecvt.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/ctor_codecvt_state.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/ctor_copy.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/ctor_err_string.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/depr.verify.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/from_bytes.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/state.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/to_bytes.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/types.pass.cpp
  libcxx/test/support/platform_support.h

Index: libcxx/test/support/platform_support.h
===
--- libcxx/test/support/platform_support.h
+++ libcxx/test/support/platform_support.h
@@ -14,6 +14,8 @@
 #ifndef PLATFORM_SUPPORT_H
 #define PLATFORM_SUPPORT_H
 
+#include "test_macros.h"
+
 // locale names
 #define LOCALE_en_US   "en_US"
 #define LOCALE_en_US_UTF_8 "en_US.UTF-8"
@@ -88,14 +90,19 @@
 #endif
 }
 
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
 #ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
 inline
 

[PATCH] D127593: [clang] Fix trivially copyable for copy constructor and copy assignment operator

2022-06-20 Thread Stephan Bergmann via Phabricator via cfe-commits
sberg added a comment.

In D127593#3596883 , @royjacobson 
wrote:

> In D127593#3596601 , @sberg wrote:
>
>> Is it intended that a deleted copy assignment op as in `struct S { void 
>> operator =(S &) = delete; };` (though, somewhat oddly, not in `struct S { 
>> void operator =(S) = delete; };`) is now marked as trivial?
>>
>> I think that's the root cause why a build of PDFium with clang-cl against 
>> the MSVC standard library started to fail for me now, effectively 
>> complaining that `__is_trivially_assignable(std::pair &, 
>> std::pair const &)` is false (as expected) while 
>> `__has_trivial_assign(std::pair)` is (unexpectedly) true.
>
> I don't see it on godbolt trunk: https://godbolt.org/z/KPfxWqnhd.

You'd only see it when compiling with Clang against MSVC's ``, where 
`std::pair` has a deleted copy assignment op (something I approximated with the 
`struct S` above).  https://godbolt.org/z/bbEqvosvP shows how the behavior 
changed in Clang trunk. (Interestingly, the behavior is different between MSVC 
and GCC, and Clang now changed from matching the MSVC behavior to matching the 
GCC one.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127593

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


[PATCH] D127641: [clang-cl][MSVC] Enable /Zc:alignedNew for C++17 and /Zc:sizedDealloc by default

2022-06-20 Thread Stephen Long via Phabricator via cfe-commits
steplong added a comment.

It looks like misc-new-delete-overloads.cpp is failing on line 20:

   1 // RUN: %check_clang_tidy %s misc-new-delete-overloads %t
   2
   3 typedef decltype(sizeof(int)) size_t;
   4
   5 struct S {
   6   // CHECK-MESSAGES: :[[@LINE+1]]:9: warning: declaration of 'operator 
new' has no matching declaration of 'operator delete' at the same scope 
[misc-new-delete-overloads]
   7   void *operator new(size_t size) noexcept;
   8   // CHECK-MESSAGES: :[[@LINE+1]]:9: warning: declaration of 'operator 
new[]' has no matching declaration of 'operator delete[]' at the same scope
   9   void *operator new[](size_t size) noexcept;
  10 };
  11
  12 // CHECK-MESSAGES: :[[@LINE+1]]:7: warning: declaration of 'operator new' 
has no matching declaration of 'operator delete' at the same scope
  13 void *operator new(size_t size) noexcept(false);
  14
  15 struct T {
  16   // Sized deallocations are not enabled by default, and so this 
new/delete pair
  17   // does not match. However, we expect only one warning, for the new, 
because
  18   // the operator delete is a placement delete and we do not warn on 
mismatching
  19   // placement operations.
  20   // CHECK-MESSAGES: :[[@LINE+1]]:9: warning: declaration of 'operator 
new' has no matching declaration of 'operator delete' at the same scope
  21   void *operator new(size_t size) noexcept;
  22   void operator delete(void *ptr, size_t) noexcept; // ok only if sized 
deallocation is enabled
  23 };

On Line 16, it says sized deallocations are not enabled by default, but this 
patch turns it on by default for MSVC.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127641

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


[PATCH] D128223: [clang] Linkage of static locals may require inspecting visibility

2022-06-20 Thread Chris Bowler via Phabricator via cfe-commits
cebowleratibm created this revision.
cebowleratibm added a reviewer: daltenty.
Herald added a project: All.
cebowleratibm requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

An assertion failure was encountered after https://reviews.llvm.org/D126340:

llvm/clang/lib/AST/Decl.cpp:1510: clang::LinkageInfo 
clang::LinkageComputer::getLVForDecl(const clang::NamedDecl *, 
clang::LVComputationKind): Assertion `D->getCachedLinkage() == LV.getLinkage()' 
failed.

See chromium bug 
 for a 
reproducer.

Note D126340  was reverted and re-landed.  
The original problem can still be reproduced using the appropriate options as 
outlined in the new test.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128223

Files:
  clang/lib/AST/Decl.cpp
  clang/test/CodeGenCXX/linkage-static-local-crash.cpp


Index: clang/test/CodeGenCXX/linkage-static-local-crash.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/linkage-static-local-crash.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix 
-mdefault-visibility-export-mapping=explicit -fvisibility-inlines-hidden 
-emit-llvm %s -o - | FileCheck %s
+
+struct C {
+  template  
+  __attribute__((__visibility__("hidden"))) 
+  static int& f() {
+static int g = 42;
+return g;
+  }
+};
+
+template
+void foo(T i) { C::f(); }
+
+void bar() {
+  foo([]{});
+}
+
+// CHECK: @"_ZZN1C1fIZ3barvE3$_0EERivE1g" = internal global i32 42, align 4
Index: clang/lib/AST/Decl.cpp
===
--- clang/lib/AST/Decl.cpp
+++ clang/lib/AST/Decl.cpp
@@ -1349,19 +1349,24 @@
 // If a function is hidden by -fvisibility-inlines-hidden option and
 // is not explicitly attributed as a hidden function,
 // we should not make static local variables in the function hidden.
-LV = getLVForDecl(FD, computation);
-if (isa(D) && useInlineVisibilityHidden(FD) &&
-!LV.isVisibilityExplicit() &&
-!Context.getLangOpts().VisibilityInlinesHiddenStaticLocalVar) {
+bool mayBeVisible = 
+isa(D) && useInlineVisibilityHidden(FD) &&
+!Context.getLangOpts().VisibilityInlinesHiddenStaticLocalVar;
+LVComputationKind nestedComputation =
+mayBeVisible
+? LVComputationKind(computation.getExplicitVisibilityKind())
+: computation;
+LV = getLVForDecl(FD, nestedComputation);
+if (mayBeVisible && !LV.isVisibilityExplicit()) {
   assert(cast(D)->isStaticLocal());
   // If this was an implicitly hidden inline method, check again for
   // explicit visibility on the parent class, and use that for static 
locals
   // if present.
   if (const auto *MD = dyn_cast(FD))
-LV = getLVForDecl(MD->getParent(), computation);
+LV = getLVForDecl(MD->getParent(), nestedComputation);
   if (!LV.isVisibilityExplicit()) {
 Visibility globalVisibility =
-computation.isValueVisibility()
+nestedComputation.isValueVisibility()
 ? Context.getLangOpts().getValueVisibilityMode()
 : Context.getLangOpts().getTypeVisibilityMode();
 return LinkageInfo(VisibleNoLinkage, globalVisibility,


Index: clang/test/CodeGenCXX/linkage-static-local-crash.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/linkage-static-local-crash.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix -mdefault-visibility-export-mapping=explicit -fvisibility-inlines-hidden -emit-llvm %s -o - | FileCheck %s
+
+struct C {
+  template  
+  __attribute__((__visibility__("hidden"))) 
+  static int& f() {
+static int g = 42;
+return g;
+  }
+};
+
+template
+void foo(T i) { C::f(); }
+
+void bar() {
+  foo([]{});
+}
+
+// CHECK: @"_ZZN1C1fIZ3barvE3$_0EERivE1g" = internal global i32 42, align 4
Index: clang/lib/AST/Decl.cpp
===
--- clang/lib/AST/Decl.cpp
+++ clang/lib/AST/Decl.cpp
@@ -1349,19 +1349,24 @@
 // If a function is hidden by -fvisibility-inlines-hidden option and
 // is not explicitly attributed as a hidden function,
 // we should not make static local variables in the function hidden.
-LV = getLVForDecl(FD, computation);
-if (isa(D) && useInlineVisibilityHidden(FD) &&
-!LV.isVisibilityExplicit() &&
-!Context.getLangOpts().VisibilityInlinesHiddenStaticLocalVar) {
+bool mayBeVisible = 
+isa(D) && useInlineVisibilityHidden(FD) &&
+!Context.getLangOpts().VisibilityInlinesHiddenStaticLocalVar;
+LVComputationKind nestedComputation =
+mayBeVisible
+? LVComputationKind(computation.getExplicitVisibilityKind())
+: computation;
+LV = getLVForDecl(FD, 

[PATCH] D128207: [clang-doc][NFC] Fix reference invalidation assertion failure.

2022-06-20 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

Is there a test that can be added so this doesn’t regress?

Also, I wonder if `assign` could/should add logic to be resilient to this.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D128207

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


[clang] ad7ce1e - Don't use Optional::hasValue (NFC)

2022-06-20 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-06-20T11:49:10-07:00
New Revision: ad7ce1e7696148d093b96a6262ebc8fd5e216187

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

LOG: Don't use Optional::hasValue (NFC)

Added: 


Modified: 
clang/lib/CodeGen/CodeGenFunction.h
clang/lib/Driver/Driver.cpp
clang/lib/Sema/SemaTemplateInstantiate.cpp
clang/lib/Sema/TreeTransform.h
lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
llvm/lib/ExecutionEngine/Orc/IndirectionUtils.cpp
llvm/lib/IR/Attributes.cpp
llvm/lib/Remarks/YAMLRemarkSerializer.cpp
llvm/lib/Target/MSP430/MSP430TargetMachine.cpp
llvm/lib/Target/RISCV/RISCVTargetMachine.cpp
llvm/lib/Transforms/IPO/OpenMPOpt.cpp
mlir/lib/Analysis/IntRangeAnalysis.cpp
mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp
mlir/lib/Conversion/FuncToLLVM/FuncToLLVM.cpp
mlir/lib/Dialect/Affine/Transforms/LoopFusion.cpp
mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp
mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenFunction.h 
b/clang/lib/CodeGen/CodeGenFunction.h
index 938db2a887c59..a7de87b552d28 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -1529,10 +1529,7 @@ class CodeGenFunction : public CodeGenTypeCache {
 
   /// Get the profiler's count for the given statement.
   uint64_t getProfileCount(const Stmt *S) {
-Optional Count = PGO.getStmtCount(S);
-if (!Count.hasValue())
-  return 0;
-return *Count;
+return PGO.getStmtCount(S).value_or(0);
   }
 
   /// Set the profiler's current count.

diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index cbde26668b78c..167c726c53919 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -3282,8 +3282,7 @@ class OffloadingActionBuilder final {
   DDep, CudaDeviceActions[I]->getType());
 }
 
-if (!CompileDeviceOnly || !BundleOutput.hasValue() ||
-BundleOutput.getValue()) {
+if (!CompileDeviceOnly || !BundleOutput || *BundleOutput) {
   // Create HIP fat binary with a special "link" action.
   CudaFatBinary = C.MakeAction(CudaDeviceActions,
   types::TY_HIP_FATBIN);
@@ -3383,8 +3382,7 @@ class OffloadingActionBuilder final {
   // in a fat binary for mixed host-device compilation. For device-only
   // compilation, creates a fat binary.
   OffloadAction::DeviceDependences DDeps;
-  if (!CompileDeviceOnly || !BundleOutput.hasValue() ||
-  BundleOutput.getValue()) {
+  if (!CompileDeviceOnly || !BundleOutput || *BundleOutput) {
 auto *TopDeviceLinkAction = C.MakeAction(
 Actions,
 CompileDeviceOnly ? types::TY_HIP_FATBIN : types::TY_Object);

diff  --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp 
b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index 62478e7129695..8e59c449ae656 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -1996,8 +1996,7 @@ 
TemplateInstantiator::TransformExprRequirement(concepts::ExprRequirement *Req) {
   TransRetReq.emplace(TPL);
 }
   }
-  assert(TransRetReq.hasValue() &&
- "All code paths leading here must set TransRetReq");
+  assert(TransRetReq && "All code paths leading here must set TransRetReq");
   if (Expr *E = TransExpr.dyn_cast())
 return RebuildExprRequirement(E, Req->isSimple(), Req->getNoexceptLoc(),
   std::move(*TransRetReq));

diff  --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 03f147480421a..ef09352551044 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -12634,8 +12634,7 @@ 
TreeTransform::TransformExprRequirement(concepts::ExprRequirement *Req)
   return nullptr;
 TransRetReq.emplace(TPL);
   }
-  assert(TransRetReq.hasValue() &&
- "All code paths leading here must set TransRetReq");
+  assert(TransRetReq && "All code paths leading here must set TransRetReq");
   if (Expr *E = TransExpr.dyn_cast())
 return getDerived().RebuildExprRequirement(E, Req->isSimple(),
Req->getNoexceptLoc(),

diff  --git a/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp 
b/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
index 58e581fce728d..16d84fb01f610 100644
--- a/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
+++ b/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
@@ -698,8 +698,7 @@ SymbolFileBreakpad::ParseWinUnwindPlan(const Bookmark 
,
 
   LineIterator It(*m_objfile_sp, Record::StackWin, 

[clang-tools-extra] 5413bf1 - Don't use Optional::hasValue (NFC)

2022-06-20 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-06-20T11:33:56-07:00
New Revision: 5413bf1bac2abb9e06901686cdc959e92940143a

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

LOG: Don't use Optional::hasValue (NFC)

Added: 


Modified: 
clang-tools-extra/clang-tidy/ClangTidyProfiling.cpp
clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
clang-tools-extra/clang-tidy/bugprone/SuspiciousMemoryComparisonCheck.cpp
clang-tools-extra/clang-tidy/bugprone/UncheckedOptionalAccessCheck.cpp
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
clang-tools-extra/clangd/ClangdLSPServer.cpp
clang-tools-extra/clangd/ClangdServer.cpp
clang-tools-extra/clangd/CodeComplete.cpp
clang-tools-extra/clangd/IncludeFixer.cpp
clang-tools-extra/clangd/Protocol.cpp
clang-tools-extra/clangd/SemanticSelection.cpp
clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
clang-tools-extra/clangd/tool/Check.cpp
clang-tools-extra/pseudo/lib/DirectiveTree.cpp
clang-tools-extra/pseudo/lib/Forest.cpp
clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
clang/lib/Lex/PPDirectives.cpp
clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
flang/include/flang/Lower/IterationSpace.h
flang/lib/Lower/Bridge.cpp
flang/lib/Lower/ConvertExpr.cpp
flang/lib/Lower/IO.cpp
flang/lib/Optimizer/CodeGen/CodeGen.cpp
flang/lib/Optimizer/CodeGen/TargetRewrite.cpp
flang/lib/Optimizer/Support/InternalNames.cpp
lld/COFF/Driver.cpp
lld/ELF/Driver.cpp
lld/ELF/InputFiles.cpp
lld/ELF/LinkerScript.cpp
lld/wasm/Driver.cpp
lld/wasm/InputFiles.cpp
lld/wasm/Writer.cpp
lldb/source/Breakpoint/BreakpointIDList.cpp
lldb/source/Commands/CommandObjectFrame.cpp
lldb/source/Core/Debugger.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/source/Plugins/Process/POSIX/NativeProcessELF.cpp
lldb/source/Plugins/Process/minidump/MinidumpParser.cpp
lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
lldb/source/Utility/SelectHelper.cpp
llvm/include/llvm/DebugInfo/DWARF/DWARFDebugFrame.h
llvm/include/llvm/IR/IRBuilder.h
llvm/lib/Analysis/IRSimilarityIdentifier.cpp
llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
llvm/lib/DWARFLinker/DWARFLinker.cpp
llvm/lib/DebugInfo/CodeView/ContinuationRecordBuilder.cpp
llvm/lib/DebugInfo/CodeView/SymbolSerializer.cpp
llvm/lib/DebugInfo/PDB/Native/InputFile.cpp
llvm/lib/IR/Function.cpp
llvm/lib/IR/IntrinsicInst.cpp
llvm/lib/ObjectYAML/ELFYAML.cpp
llvm/lib/Target/Mips/MipsTargetStreamer.h
llvm/lib/Transforms/IPO/IROutliner.cpp
llvm/lib/Transforms/IPO/OpenMPOpt.cpp
llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
llvm/utils/TableGen/GlobalISelEmitter.cpp
mlir/lib/Analysis/Presburger/Simplex.cpp
mlir/lib/Dialect/Affine/Transforms/LoopFusion.cpp
mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp
mlir/lib/Dialect/Affine/Utils/Utils.cpp

mlir/lib/Dialect/Bufferization/Transforms/FuncBufferizableOpInterfaceImpl.cpp
mlir/lib/Dialect/Bufferization/Transforms/OneShotModuleBufferize.cpp
mlir/lib/Dialect/Vector/Utils/VectorUtils.cpp
mlir/lib/Tools/lsp-server-support/Protocol.cpp
mlir/test/lib/IR/TestSymbolUses.cpp
mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp
mlir/tools/mlir-tblgen/RewriterGen.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/ClangTidyProfiling.cpp 
b/clang-tools-extra/clang-tidy/ClangTidyProfiling.cpp
index b107dd7385c65..6c5d86a69821b 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyProfiling.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyProfiling.cpp
@@ -53,7 +53,7 @@ void ClangTidyProfiling::printAsJSON(llvm::raw_ostream ) {
 }
 
 void ClangTidyProfiling::storeProfileData() {
-  assert(Storage.hasValue() && "We should have a filename.");
+  assert(Storage && "We should have a filename.");
 
   llvm::SmallString<256> OutputDirectory(Storage->StoreFilename);
   llvm::sys::path::remove_filename(OutputDirectory);
@@ -80,7 +80,7 @@ 
ClangTidyProfiling::ClangTidyProfiling(llvm::Optional Storage)
 ClangTidyProfiling::~ClangTidyProfiling() {
   TG.emplace("clang-tidy", "clang-tidy checks profiling", Records);
 
-  if (!Storage.hasValue())
+  if (!Storage)
 printUserFriendlyTable(llvm::errs());
   else
 storeProfileData();

diff  --git 

[clang] 5413bf1 - Don't use Optional::hasValue (NFC)

2022-06-20 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-06-20T11:33:56-07:00
New Revision: 5413bf1bac2abb9e06901686cdc959e92940143a

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

LOG: Don't use Optional::hasValue (NFC)

Added: 


Modified: 
clang-tools-extra/clang-tidy/ClangTidyProfiling.cpp
clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
clang-tools-extra/clang-tidy/bugprone/SuspiciousMemoryComparisonCheck.cpp
clang-tools-extra/clang-tidy/bugprone/UncheckedOptionalAccessCheck.cpp
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
clang-tools-extra/clangd/ClangdLSPServer.cpp
clang-tools-extra/clangd/ClangdServer.cpp
clang-tools-extra/clangd/CodeComplete.cpp
clang-tools-extra/clangd/IncludeFixer.cpp
clang-tools-extra/clangd/Protocol.cpp
clang-tools-extra/clangd/SemanticSelection.cpp
clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
clang-tools-extra/clangd/tool/Check.cpp
clang-tools-extra/pseudo/lib/DirectiveTree.cpp
clang-tools-extra/pseudo/lib/Forest.cpp
clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
clang/lib/Lex/PPDirectives.cpp
clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
flang/include/flang/Lower/IterationSpace.h
flang/lib/Lower/Bridge.cpp
flang/lib/Lower/ConvertExpr.cpp
flang/lib/Lower/IO.cpp
flang/lib/Optimizer/CodeGen/CodeGen.cpp
flang/lib/Optimizer/CodeGen/TargetRewrite.cpp
flang/lib/Optimizer/Support/InternalNames.cpp
lld/COFF/Driver.cpp
lld/ELF/Driver.cpp
lld/ELF/InputFiles.cpp
lld/ELF/LinkerScript.cpp
lld/wasm/Driver.cpp
lld/wasm/InputFiles.cpp
lld/wasm/Writer.cpp
lldb/source/Breakpoint/BreakpointIDList.cpp
lldb/source/Commands/CommandObjectFrame.cpp
lldb/source/Core/Debugger.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/source/Plugins/Process/POSIX/NativeProcessELF.cpp
lldb/source/Plugins/Process/minidump/MinidumpParser.cpp
lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
lldb/source/Utility/SelectHelper.cpp
llvm/include/llvm/DebugInfo/DWARF/DWARFDebugFrame.h
llvm/include/llvm/IR/IRBuilder.h
llvm/lib/Analysis/IRSimilarityIdentifier.cpp
llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
llvm/lib/DWARFLinker/DWARFLinker.cpp
llvm/lib/DebugInfo/CodeView/ContinuationRecordBuilder.cpp
llvm/lib/DebugInfo/CodeView/SymbolSerializer.cpp
llvm/lib/DebugInfo/PDB/Native/InputFile.cpp
llvm/lib/IR/Function.cpp
llvm/lib/IR/IntrinsicInst.cpp
llvm/lib/ObjectYAML/ELFYAML.cpp
llvm/lib/Target/Mips/MipsTargetStreamer.h
llvm/lib/Transforms/IPO/IROutliner.cpp
llvm/lib/Transforms/IPO/OpenMPOpt.cpp
llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
llvm/utils/TableGen/GlobalISelEmitter.cpp
mlir/lib/Analysis/Presburger/Simplex.cpp
mlir/lib/Dialect/Affine/Transforms/LoopFusion.cpp
mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp
mlir/lib/Dialect/Affine/Utils/Utils.cpp

mlir/lib/Dialect/Bufferization/Transforms/FuncBufferizableOpInterfaceImpl.cpp
mlir/lib/Dialect/Bufferization/Transforms/OneShotModuleBufferize.cpp
mlir/lib/Dialect/Vector/Utils/VectorUtils.cpp
mlir/lib/Tools/lsp-server-support/Protocol.cpp
mlir/test/lib/IR/TestSymbolUses.cpp
mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp
mlir/tools/mlir-tblgen/RewriterGen.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/ClangTidyProfiling.cpp 
b/clang-tools-extra/clang-tidy/ClangTidyProfiling.cpp
index b107dd7385c65..6c5d86a69821b 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyProfiling.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyProfiling.cpp
@@ -53,7 +53,7 @@ void ClangTidyProfiling::printAsJSON(llvm::raw_ostream ) {
 }
 
 void ClangTidyProfiling::storeProfileData() {
-  assert(Storage.hasValue() && "We should have a filename.");
+  assert(Storage && "We should have a filename.");
 
   llvm::SmallString<256> OutputDirectory(Storage->StoreFilename);
   llvm::sys::path::remove_filename(OutputDirectory);
@@ -80,7 +80,7 @@ 
ClangTidyProfiling::ClangTidyProfiling(llvm::Optional Storage)
 ClangTidyProfiling::~ClangTidyProfiling() {
   TG.emplace("clang-tidy", "clang-tidy checks profiling", Records);
 
-  if (!Storage.hasValue())
+  if (!Storage)
 printUserFriendlyTable(llvm::errs());
   else
 storeProfileData();

diff  --git 

[clang] 452db15 - [clang] Don't use Optional::hasValue (NFC)

2022-06-20 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-06-20T10:51:34-07:00
New Revision: 452db157c963b2897a0882e3bb05ef845b9e4015

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

LOG: [clang] Don't use Optional::hasValue (NFC)

Added: 


Modified: 
clang/include/clang/APINotes/Types.h
clang/include/clang/AST/ASTContext.h
clang/include/clang/AST/TypeProperties.td
clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h
clang/lib/ARCMigrate/Transforms.cpp
clang/lib/AST/ComputeDependence.cpp
clang/lib/AST/Interp/ByteCodeExprGen.h
clang/lib/ASTMatchers/Dynamic/Parser.cpp
clang/lib/Analysis/ReachableCode.cpp
clang/lib/CodeGen/BackendUtil.cpp
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/lib/CodeGen/CoverageMappingGen.cpp
clang/lib/DirectoryWatcher/DirectoryScanner.cpp
clang/lib/Driver/ToolChains/AVR.cpp
clang/lib/Lex/PPDirectives.cpp
clang/lib/Lex/PPMacroExpansion.cpp
clang/lib/Lex/TokenLexer.cpp
clang/lib/Parse/ParseOpenMP.cpp
clang/lib/Sema/SemaCUDA.cpp
clang/lib/Sema/SemaCodeComplete.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaDeclObjC.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Sema/SemaOverload.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/lib/StaticAnalyzer/Checkers/GTestChecker.cpp
clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
clang/lib/StaticAnalyzer/Checkers/StringChecker.cpp
clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp
clang/lib/StaticAnalyzer/Core/BugReporter.cpp
clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
clang/lib/StaticAnalyzer/Core/CallDescription.cpp
clang/lib/StaticAnalyzer/Core/CallEvent.cpp
clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
clang/lib/StaticAnalyzer/Core/RegionStore.cpp
clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
clang/lib/Tooling/Transformer/Stencil.cpp
clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
clang/utils/TableGen/RISCVVEmitter.cpp

Removed: 




diff  --git a/clang/include/clang/APINotes/Types.h 
b/clang/include/clang/APINotes/Types.h
index 0df710152e7a9..f00e41b7c9558 100644
--- a/clang/include/clang/APINotes/Types.h
+++ b/clang/include/clang/APINotes/Types.h
@@ -676,7 +676,7 @@ class TagInfo : public CommonTypeInfo {
 if (!HasFlagEnum && HasFlagEnum)
   setFlagEnum(RHS.isFlagEnum());
 
-if (!EnumExtensibility.hasValue())
+if (!EnumExtensibility)
   EnumExtensibility = RHS.EnumExtensibility;
 
 return *this;
@@ -706,7 +706,7 @@ class TypedefInfo : public CommonTypeInfo {
 
   TypedefInfo |=(const TypedefInfo ) {
 static_cast(*this) |= RHS;
-if (!SwiftWrapper.hasValue())
+if (!SwiftWrapper)
   SwiftWrapper = RHS.SwiftWrapper;
 return *this;
   }

diff  --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index fe22930e0fb11..7db6af9cb87d6 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -2554,7 +2554,7 @@ class ASTContext : public RefCountedBase {
bool IsParam) const {
 auto SubTnullability = SubT->getNullability(*this);
 auto SuperTnullability = SuperT->getNullability(*this);
-if (SubTnullability.hasValue() == SuperTnullability.hasValue()) {
+if (SubTnullability.has_value() == SuperTnullability.has_value()) {
   // Neither has nullability; return true
   if (!SubTnullability)
 return true;

diff  --git a/clang/include/clang/AST/TypeProperties.td 
b/clang/include/clang/AST/TypeProperties.td
index 54d89d43a66a7..c46b0bd68cadc 100644
--- a/clang/include/clang/AST/TypeProperties.td
+++ b/clang/include/clang/AST/TypeProperties.td
@@ -671,7 +671,7 @@ let Class = TemplateSpecializationType in {
 
   def : Creator<[{
 QualType result;
-if (!underlyingType.hasValue()) {
+if (!underlyingType) {
   result = ctx.getCanonicalTemplateSpecializationType(templateName,
   templateArguments);
 } else {

diff  --git 
a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h
index e4878d4e01564..250ba4f528968 100644
--- 
a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h
+++ 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h
@@ -129,7 +129,7 @@ class SMTConstraintManager : public 
clang::ento::SimpleConstraintManager {
 
   // Constraints are unsatisfiable
   Optional isSat = Solver->check();
-  if 

[PATCH] D127641: [clang-cl][MSVC] Enable /Zc:alignedNew for C++17 and /Zc:sizedDealloc by default

2022-06-20 Thread Stephen Long via Phabricator via cfe-commits
steplong updated this revision to Diff 438437.
steplong added a comment.

- Remove DEFAULT from test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127641

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/cl-zc.cpp


Index: clang/test/Driver/cl-zc.cpp
===
--- clang/test/Driver/cl-zc.cpp
+++ clang/test/Driver/cl-zc.cpp
@@ -1,6 +1,19 @@
 // Note: %s must be preceded by --, otherwise it may be interpreted as a
 // command-line option, e.g. on Mac where %s is commonly under /Users.
 
+// RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck -check-prefix=SIZED-DEALLOC %s
+// RUN: %clang_cl /c -### -fms-compatibility-version=18 -- %s 2>&1 | FileCheck 
-check-prefix=SIZED-DEALLOC-OFF %s
+// SIZED-DEALLOC: "-fsized-deallocation"
+// SIZED-DEALLOC-OFF-NOT: "-fsized-deallocation"
+
+// RUN: %clang_cl /c /std:c++11 -### -- %s 2>&1 | FileCheck 
-check-prefix=ALIGNED-NEW-BEFORE-CPP17 %s
+// RUN: %clang_cl /c /std:c++14 -### -- %s 2>&1 | FileCheck 
-check-prefix=ALIGNED-NEW-BEFORE-CPP17 %s
+// RUN: %clang_cl /c /std:c++17 -### -- %s 2>&1 | FileCheck 
-check-prefix=ALIGNED-NEW-CPP17ONWARDS %s
+// RUN: %clang_cl /c /std:c++20 -### -- %s 2>&1 | FileCheck 
-check-prefix=ALIGNED-NEW-CPP17ONWARDS %s
+// RUN: %clang_cl /c /std:c++latest -### -- %s 2>&1 | FileCheck 
-check-prefix=ALIGNED-NEW-CPP17ONWARDS %s
+// ALIGNED-NEW-BEFORE-CPP17-NOT: "-faligned-allocation"
+// ALIGNED-NEW-CPP17ONWARDS: "-faligned-allocation"
+
 // RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck 
-check-prefix=TRIGRAPHS-DEFAULT %s
 // cc1 will disable trigraphs for -fms-compatibility as long as -ftrigraphs
 // isn't explicitly passed.
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6470,6 +6470,7 @@
 }
 CmdArgs.push_back(LanguageStandard.data());
   }
+  bool IsCPP17Onwards = false;
   if (ImplyVCPPCXXVer) {
 StringRef LanguageStandard;
 if (const Arg *StdArg = Args.getLastArg(options::OPT__SLASH_std)) {
@@ -6493,6 +6494,9 @@
 }
 
 CmdArgs.push_back(LanguageStandard.data());
+
+IsCPP17Onwards =
+LanguageStandard != "-std=c++11" && LanguageStandard != "-std=c++14";
   }
 
   Args.addOptInFlag(CmdArgs, options::OPT_fborland_extensions,
@@ -6622,9 +6626,15 @@
 options::OPT_fno_relaxed_template_template_args);
 
   // -fsized-deallocation is off by default, as it is an ABI-breaking change 
for
-  // most platforms.
-  Args.addOptInFlag(CmdArgs, options::OPT_fsized_deallocation,
-options::OPT_fno_sized_deallocation);
+  // most platforms. MSVC turns on /Zc:sizedDealloc by default, starting in
+  // MSVC 2015.
+  if (IsWindowsMSVC && IsMSVC2015Compatible &&
+  !Args.getLastArg(options::OPT_fsized_deallocation,
+   options::OPT_fno_sized_deallocation))
+CmdArgs.push_back("-fsized-deallocation");
+  else
+Args.addOptInFlag(CmdArgs, options::OPT_fsized_deallocation,
+  options::OPT_fno_sized_deallocation);
 
   // -faligned-allocation is on by default in C++17 onwards and otherwise off
   // by default.
@@ -6635,6 +6645,8 @@
   CmdArgs.push_back("-fno-aligned-allocation");
 else
   CmdArgs.push_back("-faligned-allocation");
+  } else if (IsCPP17Onwards) {
+CmdArgs.push_back("-faligned-allocation");
   }
 
   // The default new alignment can be specified using a dedicated option or via


Index: clang/test/Driver/cl-zc.cpp
===
--- clang/test/Driver/cl-zc.cpp
+++ clang/test/Driver/cl-zc.cpp
@@ -1,6 +1,19 @@
 // Note: %s must be preceded by --, otherwise it may be interpreted as a
 // command-line option, e.g. on Mac where %s is commonly under /Users.
 
+// RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck -check-prefix=SIZED-DEALLOC %s
+// RUN: %clang_cl /c -### -fms-compatibility-version=18 -- %s 2>&1 | FileCheck -check-prefix=SIZED-DEALLOC-OFF %s
+// SIZED-DEALLOC: "-fsized-deallocation"
+// SIZED-DEALLOC-OFF-NOT: "-fsized-deallocation"
+
+// RUN: %clang_cl /c /std:c++11 -### -- %s 2>&1 | FileCheck -check-prefix=ALIGNED-NEW-BEFORE-CPP17 %s
+// RUN: %clang_cl /c /std:c++14 -### -- %s 2>&1 | FileCheck -check-prefix=ALIGNED-NEW-BEFORE-CPP17 %s
+// RUN: %clang_cl /c /std:c++17 -### -- %s 2>&1 | FileCheck -check-prefix=ALIGNED-NEW-CPP17ONWARDS %s
+// RUN: %clang_cl /c /std:c++20 -### -- %s 2>&1 | FileCheck -check-prefix=ALIGNED-NEW-CPP17ONWARDS %s
+// RUN: %clang_cl /c /std:c++latest -### -- %s 2>&1 | FileCheck -check-prefix=ALIGNED-NEW-CPP17ONWARDS %s
+// ALIGNED-NEW-BEFORE-CPP17-NOT: "-faligned-allocation"
+// ALIGNED-NEW-CPP17ONWARDS: "-faligned-allocation"
+
 // RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck -check-prefix=TRIGRAPHS-DEFAULT %s
 // cc1 will 

[PATCH] D128183: [clang][dataflow] Extend flow condition in the body of a do/while loop

2022-06-20 Thread Stanislav Gatev via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
sgatev marked an inline comment as done.
Closed by commit rGe363c5963dc3: [clang][dataflow] Extend flow condition in the 
body of a do/while loop (authored by sgatev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128183

Files:
  clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
  clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
  clang/unittests/Analysis/FlowSensitive/TransferTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -3628,25 +3628,81 @@
 void target(bool Foo) {
   while (Foo) {
 (void)0;
-// [[while_branch]]
+// [[loop_body]]
   }
+  (void)0;
+  // [[after_loop]]
 }
   )";
-  runDataflow(Code,
-  [](llvm::ArrayRef<
- std::pair>>
- Results,
- ASTContext ) {
-ASSERT_THAT(Results, ElementsAre(Pair("while_branch", _)));
-const Environment  = Results[0].second.Env;
+  runDataflow(
+  Code, [](llvm::ArrayRef<
+   std::pair>>
+   Results,
+   ASTContext ) {
+ASSERT_THAT(Results,
+ElementsAre(Pair("after_loop", _), Pair("loop_body", _)));
+const Environment  = Results[1].second.Env;
+const Environment  = Results[0].second.Env;
 
-const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo");
-ASSERT_THAT(FooDecl, NotNull());
+const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo");
+ASSERT_THAT(FooDecl, NotNull());
 
-BoolValue  =
-*cast(Env.getValue(*FooDecl, SkipPast::None));
-EXPECT_TRUE(Env.flowConditionImplies(FooVal));
-  });
+BoolValue  =
+*cast(LoopBodyEnv.getValue(*FooDecl, SkipPast::None));
+EXPECT_TRUE(LoopBodyEnv.flowConditionImplies(LoopBodyFooVal));
+
+BoolValue  =
+*cast(AfterLoopEnv.getValue(*FooDecl, SkipPast::None));
+EXPECT_TRUE(AfterLoopEnv.flowConditionImplies(
+AfterLoopEnv.makeNot(AfterLoopFooVal)));
+  });
+}
+
+TEST_F(TransferTest, DoWhileStmtBranchExtendsFlowCondition) {
+  std::string Code = R"(
+void target(bool Foo) {
+  bool Bar = true;
+  do {
+(void)0;
+// [[loop_body]]
+Bar = false;
+  } while (Foo);
+  (void)0;
+  // [[after_loop]]
+}
+  )";
+  runDataflow(
+  Code, [](llvm::ArrayRef<
+   std::pair>>
+   Results,
+   ASTContext ) {
+ASSERT_THAT(Results,
+ElementsAre(Pair("after_loop", _), Pair("loop_body", _)));
+const Environment  = Results[1].second.Env;
+const Environment  = Results[0].second.Env;
+
+const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo");
+ASSERT_THAT(FooDecl, NotNull());
+
+const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar");
+ASSERT_THAT(BarDecl, NotNull());
+
+BoolValue  =
+*cast(LoopBodyEnv.getValue(*FooDecl, SkipPast::None));
+BoolValue  =
+*cast(LoopBodyEnv.getValue(*BarDecl, SkipPast::None));
+EXPECT_TRUE(LoopBodyEnv.flowConditionImplies(
+LoopBodyEnv.makeOr(LoopBodyBarVal, LoopBodyFooVal)));
+
+BoolValue  =
+*cast(AfterLoopEnv.getValue(*FooDecl, SkipPast::None));
+BoolValue  =
+*cast(AfterLoopEnv.getValue(*BarDecl, SkipPast::None));
+EXPECT_TRUE(AfterLoopEnv.flowConditionImplies(
+AfterLoopEnv.makeNot(AfterLoopFooVal)));
+EXPECT_TRUE(AfterLoopEnv.flowConditionImplies(
+AfterLoopEnv.makeNot(AfterLoopBarVal)));
+  });
 }
 
 TEST_F(TransferTest, ForStmtBranchExtendsFlowCondition) {
@@ -3654,25 +3710,34 @@
 void target(bool Foo) {
   for (; Foo;) {
 (void)0;
-// [[for_branch]]
+// [[loop_body]]
   }
+  (void)0;
+  // [[after_loop]]
 }
   )";
-  runDataflow(Code,
-  [](llvm::ArrayRef<
- std::pair>>
- Results,
- ASTContext ) {
-ASSERT_THAT(Results, ElementsAre(Pair("for_branch", _)));
-const Environment  = Results[0].second.Env;
+  runDataflow(
+  Code, [](llvm::ArrayRef<
+   std::pair>>
+   Results,
+   ASTContext ) {
+ASSERT_THAT(Results,
+ElementsAre(Pair("after_loop", _), Pair("loop_body", _)));
+const Environment  = Results[1].second.Env;
+   

[clang] e363c59 - [clang][dataflow] Extend flow condition in the body of a do/while loop

2022-06-20 Thread Stanislav Gatev via cfe-commits

Author: Stanislav Gatev
Date: 2022-06-20T17:31:00Z
New Revision: e363c5963dc3ad5d9492d3f37055ad56a84411a5

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

LOG: [clang][dataflow] Extend flow condition in the body of a do/while loop

Extend flow condition in the body of a do/while loop.

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

Reviewed-by: gribozavr2, xazax.hun

Added: 


Modified: 
clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
clang/unittests/Analysis/FlowSensitive/TransferTest.cpp

Removed: 




diff  --git a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp 
b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
index 4759932a696f1..e8d3a4e6d4505 100644
--- a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -87,8 +87,13 @@ static Value *mergeDistinctValues(QualType Type, Value *Val1,
   // have mutually exclusive conditions.
   if (auto *Expr1 = dyn_cast(Val1)) {
 auto *Expr2 = cast(Val2);
-return (Env1.makeAnd(Env1.getFlowConditionToken(), *Expr1),
-Env1.makeAnd(Env2.getFlowConditionToken(), *Expr2));
+auto  = MergedEnv.makeAtomicBoolValue();
+MergedEnv.addToFlowCondition(MergedEnv.makeOr(
+MergedEnv.makeAnd(Env1.getFlowConditionToken(),
+  MergedEnv.makeIff(MergedVal, *Expr1)),
+MergedEnv.makeAnd(Env2.getFlowConditionToken(),
+  MergedEnv.makeIff(MergedVal, *Expr2;
+return 
   }
 
   // FIXME: add unit tests that cover this statement.

diff  --git a/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp 
b/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
index a1ce2f6912574..68e897e035962 100644
--- a/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
+++ b/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
@@ -89,6 +89,12 @@ class TerminatorVisitor : public 
ConstStmtVisitor {
 extendFlowCondition(*Cond);
   }
 
+  void VisitDoStmt(const DoStmt *S) {
+auto *Cond = S->getCond();
+assert(Cond != nullptr);
+extendFlowCondition(*Cond);
+  }
+
   void VisitForStmt(const ForStmt *S) {
 auto *Cond = S->getCond();
 assert(Cond != nullptr);

diff  --git a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp 
b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
index 29a45a315074d..3a8e2ac8588a5 100644
--- a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -3628,25 +3628,81 @@ TEST_F(TransferTest, 
WhileStmtBranchExtendsFlowCondition) {
 void target(bool Foo) {
   while (Foo) {
 (void)0;
-// [[while_branch]]
+// [[loop_body]]
   }
+  (void)0;
+  // [[after_loop]]
 }
   )";
-  runDataflow(Code,
-  [](llvm::ArrayRef<
- std::pair>>
- Results,
- ASTContext ) {
-ASSERT_THAT(Results, ElementsAre(Pair("while_branch", _)));
-const Environment  = Results[0].second.Env;
+  runDataflow(
+  Code, [](llvm::ArrayRef<
+   std::pair>>
+   Results,
+   ASTContext ) {
+ASSERT_THAT(Results,
+ElementsAre(Pair("after_loop", _), Pair("loop_body", _)));
+const Environment  = Results[1].second.Env;
+const Environment  = Results[0].second.Env;
 
-const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo");
-ASSERT_THAT(FooDecl, NotNull());
+const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo");
+ASSERT_THAT(FooDecl, NotNull());
 
-BoolValue  =
-*cast(Env.getValue(*FooDecl, SkipPast::None));
-EXPECT_TRUE(Env.flowConditionImplies(FooVal));
-  });
+BoolValue  =
+*cast(LoopBodyEnv.getValue(*FooDecl, SkipPast::None));
+EXPECT_TRUE(LoopBodyEnv.flowConditionImplies(LoopBodyFooVal));
+
+BoolValue  =
+*cast(AfterLoopEnv.getValue(*FooDecl, SkipPast::None));
+EXPECT_TRUE(AfterLoopEnv.flowConditionImplies(
+AfterLoopEnv.makeNot(AfterLoopFooVal)));
+  });
+}
+
+TEST_F(TransferTest, DoWhileStmtBranchExtendsFlowCondition) {
+  std::string Code = R"(
+void target(bool Foo) {
+  bool Bar = true;
+  do {
+(void)0;
+// [[loop_body]]
+Bar = false;
+  } while (Foo);
+  (void)0;
+  // [[after_loop]]
+}
+  )";
+  runDataflow(
+  Code, [](llvm::ArrayRef<
+   std::pair>>
+   Results,
+

[PATCH] D127270: [clang-format] Add space in placement new expression

2022-06-20 Thread omar ahmed via Phabricator via cfe-commits
omarahmed marked 3 inline comments as done and an inline comment as not done.
omarahmed added inline comments.



Comment at: clang/lib/Format/TokenAnnotator.cpp:3396
  spaceRequiredBeforeParens(Right);
+if (Style.SpaceBeforeParens == FormatStyle::SBPO_Custom &&
+Left.isOneOf(tok::kw_new, tok::kw_delete) &&

HazardyKnusperkeks wrote:
> omarahmed wrote:
> > MyDeveloperDay wrote:
> > > shouldn't the very first part of this be? 
> > > 
> > > 
> > > ```
> > > if (Style.SpaceBeforeParensOptions.AfterPlacementOperator != 
> > > FormatStyle::SpaceBeforeParensCustom::APO_Leave)
> > > {
> > > 
> > > 
> > > 
> > > }
> > > ```
> > > 
> > > i.e. don't we want a zero change if someone says "Leave"
> > The current code logic, when we do not enter this suggested condition, will 
> > switch to [this 
> > condition](https://github.com/llvm/llvm-project/blob/c2bb2e5973acd24c45c1823e95e8e33003c59484/clang/lib/Format/TokenAnnotator.cpp#L3580).
> >  And will not leave the code as it is, but will change it.
> > 
> > I have thought of getting rid of this condition entirely, but it handles 
> > the default situation suggested here, not only for cpp but for other 
> > languages like js:
> > >>As I understand, the default behavior for when the user didn't use 
> > >>`SBPO_Custom` is to add a space in placement operators based on [this 
> > >>issue](https://github.com/llvm/llvm-project/issues/54703). And, at the 
> > >>same time, the default behavior should be `APO_Never` when we have 
> > >>`SBPO_Custom` so that we handle other code that depends on that. the 
> > >>existing tests confirm this understanding. So, the current logic was 
> > >>added based on this understanding.
> > 
> > I tried to add an extra condition to [this 
> > condition](https://github.com/llvm/llvm-project/blob/c2bb2e5973acd24c45c1823e95e8e33003c59484/clang/lib/Format/TokenAnnotator.cpp#L3580)
> >  to support the main logic that we are pursuing. so that it would be like 
> > that:
> > ```
> > if (Style.SpaceBeforeParensOptions.AfterPlacementOperator != 
> > FormatStyle::SpaceBeforeParensCustom::APO_Leave && 
> > Left.isOneOf(tok::kw_new, tok::kw_delete))
> > ```
> > But that wouldn't fix the leave situation, as it will be also at the end, 
> > reach [this 
> > part](https://github.com/llvm/llvm-project/blob/c2bb2e5973acd24c45c1823e95e8e33003c59484/clang/lib/Format/TokenAnnotator.cpp#L3598)
> >  which will  
> > ```
> > return false
> > ``` 
> > and force no space.
> > 
> > I think all of that was raised because all current 
> > "SpaceBeforeParanthesesOptions" are either true or false and this is the 
> > only enum
> > 
> > However, I completely agree with this logic which is to begin our checking 
> > for leave. But I think we should refactor all the 
> > "spaceBeforeParenthesesOptions" conditions to handle this and do that after 
> > all the options have been transformed to enums.
> > 
> `SpaceBeforeParensOptions` should always be expanded, regardless of 
> `SpaceBeforeParens`, as far as I remember. `SpaceBeforeParens` is only for 
> the one configuring clang-format, the code that formats should always and 
> only check `SpaceBeforeParensOptions`.
But in general, doesn't that could create some kind of conflict like if someone 
used a specific option in `SpaceBeforeParens ` and then defined inside 
`SpaceBeforeParensOptions ` some rules that could conflict with 
`SpaceBeforeParens `, what should be the priority between them?




Comment at: clang/lib/Format/TokenAnnotator.cpp:3396
  spaceRequiredBeforeParens(Right);
+if (Style.SpaceBeforeParens == FormatStyle::SBPO_Custom &&
+Left.isOneOf(tok::kw_new, tok::kw_delete) &&

omarahmed wrote:
> HazardyKnusperkeks wrote:
> > omarahmed wrote:
> > > MyDeveloperDay wrote:
> > > > shouldn't the very first part of this be? 
> > > > 
> > > > 
> > > > ```
> > > > if (Style.SpaceBeforeParensOptions.AfterPlacementOperator != 
> > > > FormatStyle::SpaceBeforeParensCustom::APO_Leave)
> > > > {
> > > > 
> > > > 
> > > > 
> > > > }
> > > > ```
> > > > 
> > > > i.e. don't we want a zero change if someone says "Leave"
> > > The current code logic, when we do not enter this suggested condition, 
> > > will switch to [this 
> > > condition](https://github.com/llvm/llvm-project/blob/c2bb2e5973acd24c45c1823e95e8e33003c59484/clang/lib/Format/TokenAnnotator.cpp#L3580).
> > >  And will not leave the code as it is, but will change it.
> > > 
> > > I have thought of getting rid of this condition entirely, but it handles 
> > > the default situation suggested here, not only for cpp but for other 
> > > languages like js:
> > > >>As I understand, the default behavior for when the user didn't use 
> > > >>`SBPO_Custom` is to add a space in placement operators based on [this 
> > > >>issue](https://github.com/llvm/llvm-project/issues/54703). And, at the 
> > > >>same time, the default behavior should be `APO_Never` when we 

[PATCH] D127270: [clang-format] Add space in placement new expression

2022-06-20 Thread omar ahmed via Phabricator via cfe-commits
omarahmed added inline comments.



Comment at: clang/docs/tools/dump_format_style.py:317
   pass
+  elif state == State.InNestedEnum:
+if line.startswith('///'):

MyDeveloperDay wrote:
> Can you show us a screenshot of how these changes will look in HTML?
{F23524556}


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127270

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


[PATCH] D127270: [clang-format] Add space in placement new expression

2022-06-20 Thread omar ahmed via Phabricator via cfe-commits
omarahmed updated this revision to Diff 438433.
omarahmed added a comment.

- Add version for nestedEnums and nestedFields
- Make tests valid


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127270

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/tools/dump_format_style.py
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -10130,6 +10130,42 @@
 "void delete(link p);\n",
 format("void new (link p);\n"
"void delete (link p);\n"));
+
+  FormatStyle AfterPlacementOperator = getLLVMStyle();
+  AfterPlacementOperator.SpaceBeforeParens = FormatStyle::SBPO_Custom;
+  EXPECT_EQ(
+  AfterPlacementOperator.SpaceBeforeParensOptions.AfterPlacementOperator,
+  FormatStyle::SpaceBeforeParensCustom::APO_Never);
+  verifyFormat("struct A {\n"
+   "  int *a;\n"
+   "  A(int *p) : a(new(p) int) {\n"
+   "new(p) int;\n"
+   "int *b = new(p) int;\n"
+   "int *c = new(p) int(3);\n"
+   "delete(b);\n"
+   "  }\n"
+   "};",
+   AfterPlacementOperator);
+  verifyFormat("void operator new(void *foo) ATTRIB;", AfterPlacementOperator);
+
+  AfterPlacementOperator.SpaceBeforeParensOptions.AfterPlacementOperator =
+  FormatStyle::SpaceBeforeParensCustom::APO_Always;
+  verifyFormat("struct A {\n"
+   "  int *a;\n"
+   "  A(int *p) : a(new (p) int) {\n"
+   "new (p) int;\n"
+   "int *b = new (p) int;\n"
+   "int *c = new (p) int(3);\n"
+   "delete (b);\n"
+   "  }\n"
+   "};",
+   AfterPlacementOperator);
+  verifyFormat("void operator new(void *foo) ATTRIB;", AfterPlacementOperator);
+
+  AfterPlacementOperator.SpaceBeforeParensOptions.AfterPlacementOperator =
+  FormatStyle::SpaceBeforeParensCustom::APO_Leave;
+  EXPECT_EQ("new (buf) int;", format("new (buf) int;", AfterPlacementOperator));
+  EXPECT_EQ("new(buf) int;", format("new(buf) int;", AfterPlacementOperator));
 }
 
 TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) {
@@ -20308,6 +20344,24 @@
   SpaceBeforeParens,
   FormatStyle::SBPO_ControlStatementsExceptControlMacros);
 
+  Style.SpaceBeforeParens = FormatStyle::SBPO_Custom;
+  Style.SpaceBeforeParensOptions.AfterPlacementOperator =
+  FormatStyle::SpaceBeforeParensCustom::APO_Always;
+  CHECK_PARSE("SpaceBeforeParensOptions:\n"
+  "  AfterPlacementOperator: Never",
+  SpaceBeforeParensOptions.AfterPlacementOperator,
+  FormatStyle::SpaceBeforeParensCustom::APO_Never);
+
+  CHECK_PARSE("SpaceBeforeParensOptions:\n"
+  "  AfterPlacementOperator: Always",
+  SpaceBeforeParensOptions.AfterPlacementOperator,
+  FormatStyle::SpaceBeforeParensCustom::APO_Always);
+
+  CHECK_PARSE("SpaceBeforeParensOptions:\n"
+  "  AfterPlacementOperator: Leave",
+  SpaceBeforeParensOptions.AfterPlacementOperator,
+  FormatStyle::SpaceBeforeParensCustom::APO_Leave);
+
   Style.ColumnLimit = 123;
   FormatStyle BaseStyle = getLLVMStyle();
   CHECK_PARSE("BasedOnStyle: LLVM", ColumnLimit, BaseStyle.ColumnLimit);
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3393,6 +3393,18 @@
 if (Left.is(TT_IfMacro))
   return Style.SpaceBeforeParensOptions.AfterIfMacros ||
  spaceRequiredBeforeParens(Right);
+if (Style.SpaceBeforeParens == FormatStyle::SBPO_Custom &&
+Left.isOneOf(tok::kw_new, tok::kw_delete) &&
+Right.isNot(TT_OverloadedOperatorLParen) &&
+!(Line.MightBeFunctionDecl && Left.is(TT_FunctionDeclarationName))) {
+  if (Style.SpaceBeforeParensOptions.AfterPlacementOperator ==
+  FormatStyle::SpaceBeforeParensCustom::APO_Always ||
+  (Style.SpaceBeforeParensOptions.AfterPlacementOperator ==
+   FormatStyle::SpaceBeforeParensCustom::APO_Leave &&
+   Right.hasWhitespaceBefore()))
+return true;
+  return false;
+}
 if (Line.Type == LT_ObjCDecl)
   return true;
 if (Left.is(tok::semi))
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -936,6 +936,7 @@
Spacing.AfterFunctionDeclarationName);
 IO.mapOptional("AfterIfMacros", 

[PATCH] D127641: [clang-cl][MSVC] Enable /Zc:alignedNew for C++17 and /Zc:sizedDealloc by default

2022-06-20 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

lgtm

(If you like, consider dropping the "-DEFAULT" part from the new filecheck 
prefixes. I don't think they really add much value.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127641

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


[PATCH] D128183: [clang][dataflow] Extend flow condition in the body of a do/while loop

2022-06-20 Thread Stanislav Gatev via Phabricator via cfe-commits
sgatev marked an inline comment as done.
sgatev added inline comments.



Comment at: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp:3700
+EXPECT_TRUE(AfterLoopEnv.flowConditionImplies(
+AfterLoopEnv.makeNot(AfterLoopFooVal)));
+  });

gribozavr2 wrote:
> Can we infer that after the loop bar is false?
Yes!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128183

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


[PATCH] D128183: [clang][dataflow] Extend flow condition in the body of a do/while loop

2022-06-20 Thread Stanislav Gatev via Phabricator via cfe-commits
sgatev updated this revision to Diff 438427.
sgatev added a comment.

Address comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128183

Files:
  clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
  clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
  clang/unittests/Analysis/FlowSensitive/TransferTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -3628,25 +3628,81 @@
 void target(bool Foo) {
   while (Foo) {
 (void)0;
-// [[while_branch]]
+// [[loop_body]]
   }
+  (void)0;
+  // [[after_loop]]
 }
   )";
-  runDataflow(Code,
-  [](llvm::ArrayRef<
- std::pair>>
- Results,
- ASTContext ) {
-ASSERT_THAT(Results, ElementsAre(Pair("while_branch", _)));
-const Environment  = Results[0].second.Env;
+  runDataflow(
+  Code, [](llvm::ArrayRef<
+   std::pair>>
+   Results,
+   ASTContext ) {
+ASSERT_THAT(Results,
+ElementsAre(Pair("after_loop", _), Pair("loop_body", _)));
+const Environment  = Results[1].second.Env;
+const Environment  = Results[0].second.Env;
 
-const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo");
-ASSERT_THAT(FooDecl, NotNull());
+const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo");
+ASSERT_THAT(FooDecl, NotNull());
 
-BoolValue  =
-*cast(Env.getValue(*FooDecl, SkipPast::None));
-EXPECT_TRUE(Env.flowConditionImplies(FooVal));
-  });
+BoolValue  =
+*cast(LoopBodyEnv.getValue(*FooDecl, SkipPast::None));
+EXPECT_TRUE(LoopBodyEnv.flowConditionImplies(LoopBodyFooVal));
+
+BoolValue  =
+*cast(AfterLoopEnv.getValue(*FooDecl, SkipPast::None));
+EXPECT_TRUE(AfterLoopEnv.flowConditionImplies(
+AfterLoopEnv.makeNot(AfterLoopFooVal)));
+  });
+}
+
+TEST_F(TransferTest, DoWhileStmtBranchExtendsFlowCondition) {
+  std::string Code = R"(
+void target(bool Foo) {
+  bool Bar = true;
+  do {
+(void)0;
+// [[loop_body]]
+Bar = false;
+  } while (Foo);
+  (void)0;
+  // [[after_loop]]
+}
+  )";
+  runDataflow(
+  Code, [](llvm::ArrayRef<
+   std::pair>>
+   Results,
+   ASTContext ) {
+ASSERT_THAT(Results,
+ElementsAre(Pair("after_loop", _), Pair("loop_body", _)));
+const Environment  = Results[1].second.Env;
+const Environment  = Results[0].second.Env;
+
+const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo");
+ASSERT_THAT(FooDecl, NotNull());
+
+const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar");
+ASSERT_THAT(BarDecl, NotNull());
+
+BoolValue  =
+*cast(LoopBodyEnv.getValue(*FooDecl, SkipPast::None));
+BoolValue  =
+*cast(LoopBodyEnv.getValue(*BarDecl, SkipPast::None));
+EXPECT_TRUE(LoopBodyEnv.flowConditionImplies(
+LoopBodyEnv.makeOr(LoopBodyBarVal, LoopBodyFooVal)));
+
+BoolValue  =
+*cast(AfterLoopEnv.getValue(*FooDecl, SkipPast::None));
+BoolValue  =
+*cast(AfterLoopEnv.getValue(*BarDecl, SkipPast::None));
+EXPECT_TRUE(AfterLoopEnv.flowConditionImplies(
+AfterLoopEnv.makeNot(AfterLoopFooVal)));
+EXPECT_TRUE(AfterLoopEnv.flowConditionImplies(
+AfterLoopEnv.makeNot(AfterLoopBarVal)));
+  });
 }
 
 TEST_F(TransferTest, ForStmtBranchExtendsFlowCondition) {
@@ -3654,25 +3710,34 @@
 void target(bool Foo) {
   for (; Foo;) {
 (void)0;
-// [[for_branch]]
+// [[loop_body]]
   }
+  (void)0;
+  // [[after_loop]]
 }
   )";
-  runDataflow(Code,
-  [](llvm::ArrayRef<
- std::pair>>
- Results,
- ASTContext ) {
-ASSERT_THAT(Results, ElementsAre(Pair("for_branch", _)));
-const Environment  = Results[0].second.Env;
+  runDataflow(
+  Code, [](llvm::ArrayRef<
+   std::pair>>
+   Results,
+   ASTContext ) {
+ASSERT_THAT(Results,
+ElementsAre(Pair("after_loop", _), Pair("loop_body", _)));
+const Environment  = Results[1].second.Env;
+const Environment  = Results[0].second.Env;
 
-const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo");
-ASSERT_THAT(FooDecl, NotNull());
+const ValueDecl *FooDecl 

[PATCH] D128190: [WinEH] Apply funclet operand bundles to nounwind intrinsics that lower to function calls

2022-06-20 Thread Stefan Gränitz via Phabricator via cfe-commits
sgraenitz added a comment.

Running `check-llvm` and `check-clang` locally found no more failing tests. The 
issue is not limited to pre-ISel intrinsics (anymore) and I have to re-phrase a 
few comments. Apart from that, is there any more feedback? Thanks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128190

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


[PATCH] D128190: [WinEH] Apply funclet operand bundles to nounwind intrinsics that lower to function calls

2022-06-20 Thread Stefan Gränitz via Phabricator via cfe-commits
sgraenitz updated this revision to Diff 438425.
sgraenitz added a comment.

Add missing `objc_sync_exit` to fix failing test 
Transforms/PreISelIntrinsicLowering/objc-arc.ll


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128190

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/test/CodeGenObjCXX/arc-exceptions-seh.mm
  llvm/include/llvm/IR/IntrinsicInst.h
  llvm/lib/CodeGen/PreISelIntrinsicLowering.cpp
  llvm/lib/IR/IntrinsicInst.cpp
  llvm/lib/Transforms/Utils/InlineFunction.cpp
  llvm/test/CodeGen/X86/win64-funclet-preisel-intrinsics.ll
  llvm/test/Feature/OperandBundles/inliner-funclet-wineh.ll

Index: llvm/test/Feature/OperandBundles/inliner-funclet-wineh.ll
===
--- /dev/null
+++ llvm/test/Feature/OperandBundles/inliner-funclet-wineh.ll
@@ -0,0 +1,55 @@
+; RUN: opt -S -always-inline -mtriple=x86_64-windows-msvc < %s | FileCheck %s
+
+; WinEH doesn't require funclet tokens on nounwind intrinsics per se. ObjC++ ARC
+; intrinsics are a special case, because they are subject to pre-ISel lowering.
+; They appear as regular function calls for subsequent passes, like WinEHPrepare
+; which would consider them implausible instrucitons and mark them unreachable.
+; Affected EH funclets would get truncated silently, which causes unpredictable
+; crashes at runtime.
+;
+; Thus, when we target WinEH and generate calls to pre-ISel intrinsics from EH
+; funclets, we emit funclet tokens explicitly.
+;
+; The inliner has to propagate funclet tokens to such intrinsics, if they get
+; inlined into EH funclets.
+
+define void @inlined_fn(ptr %ex) #1 {
+entry:
+  call void @llvm.objc.storeStrong(ptr %ex, ptr null)
+  ret void
+}
+
+define void @test_catch_with_inline() personality ptr @__CxxFrameHandler3 {
+entry:
+  %exn.slot = alloca ptr, align 8
+  %ex = alloca ptr, align 8
+  invoke void @opaque() to label %invoke.cont unwind label %catch.dispatch
+
+catch.dispatch:
+  %0 = catchswitch within none [label %catch] unwind to caller
+
+invoke.cont:
+  unreachable
+
+catch:
+  %1 = catchpad within %0 [ptr null, i32 64, ptr %exn.slot]
+  call void @inlined_fn(ptr %ex) [ "funclet"(token %1) ]
+  catchret from %1 to label %catchret.dest
+
+catchret.dest:
+  ret void
+}
+
+declare void @opaque()
+declare void @llvm.objc.storeStrong(ptr, ptr) #0
+declare i32 @__CxxFrameHandler3(...)
+
+attributes #0 = { nounwind }
+attributes #1 = { alwaysinline }
+
+; CHECK-LABEL:  define void @test_catch_with_inline()
+; ...
+; CHECK:catch:
+; CHECK-NEXT: %1 = catchpad within %0 [ptr null, i32 64, ptr %exn.slot]
+; CHECK-NEXT: call void @llvm.objc.storeStrong(ptr %ex, ptr null) [ "funclet"(token %1) ]
+; CHECK-NEXT: catchret from %1 to label %catchret.dest
Index: llvm/test/CodeGen/X86/win64-funclet-preisel-intrinsics.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/win64-funclet-preisel-intrinsics.ll
@@ -0,0 +1,68 @@
+; RUN: llc -mtriple=x86_64-windows-msvc < %s | FileCheck %s
+
+; Reduced IR generated from ObjC++ source:
+;
+; @class Ety;
+; void opaque(void);
+; void test_catch(void) {
+;   @try {
+; opaque();
+;   } @catch (Ety *ex) {
+; // Destroy ex when leaving catchpad. This emits calls to two intrinsic
+; // functions, llvm.objc.retain and llvm.objc.storeStrong, but only one
+; // is required to trigger the funclet truncation.
+;   }
+; }
+
+define void @test_catch() personality ptr @__CxxFrameHandler3 {
+entry:
+  %exn.slot = alloca ptr, align 8
+  %ex2 = alloca ptr, align 8
+  invoke void @opaque() to label %invoke.cont unwind label %catch.dispatch
+
+catch.dispatch:
+  %0 = catchswitch within none [label %catch] unwind to caller
+
+invoke.cont:
+  unreachable
+
+catch:
+  %1 = catchpad within %0 [ptr null, i32 64, ptr %exn.slot]
+  call void @llvm.objc.storeStrong(ptr %ex2, ptr null) [ "funclet"(token %1) ]
+  catchret from %1 to label %catchret.dest
+
+catchret.dest:
+  ret void
+}
+
+declare void @opaque()
+declare void @llvm.objc.storeStrong(ptr, ptr) #0
+declare i32 @__CxxFrameHandler3(...)
+
+attributes #0 = { nounwind }
+
+; llvm.objc.storeStrong is a Pre-ISel intrinsic, which used to cause truncations
+; when it occurred in SEH funclets like catchpads:
+; CHECK: # %catch
+; CHECK: pushq   %rbp
+; CHECK: .seh_pushreg %rbp
+;...
+; CHECK: .seh_endprologue
+;
+; At this point the code used to be truncated (and sometimes terminated with an
+; int3 opcode):
+; CHECK-NOT: int3
+;
+; Instead, the call to objc_storeStrong should be emitted:
+; CHECK: leaq	-24(%rbp), %rcx
+; CHECK: xorl	%edx, %edx
+; CHECK: callq	objc_storeStrong
+;...
+; 
+; This is the end of the funclet:
+; CHECK: popq	%rbp
+; CHECK: retq# CATCHRET
+;...
+;  

[PATCH] D127593: [clang] Fix trivially copyable for copy constructor and copy assignment operator

2022-06-20 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson added a comment.

In D127593#3596601 , @sberg wrote:

> Is it intended that a deleted copy assignment op as in `struct S { void 
> operator =(S &) = delete; };` (though, somewhat oddly, not in `struct S { 
> void operator =(S) = delete; };`) is now marked as trivial?
>
> I think that's the root cause why a build of PDFium with clang-cl against the 
> MSVC standard library started to fail for me now, effectively complaining 
> that `__is_trivially_assignable(std::pair &, std::pair 
> const &)` is false (as expected) while 
> `__has_trivial_assign(std::pair)` is (unexpectedly) true.

I don't see it on godbolt trunk: https://godbolt.org/z/KPfxWqnhd.
Did you mean other traits maybe?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127593

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


[PATCH] D127890: [Docs] Update clang & llvm release notes for HLSL

2022-06-20 Thread Chris Bieneman via Phabricator via cfe-commits
beanz updated this revision to Diff 438419.
beanz added a comment.

Updates based on feeback from @MaskRay. Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127890

Files:
  clang/docs/ReleaseNotes.rst
  llvm/docs/ReleaseNotes.rst


Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -110,6 +110,16 @@
 
 * ...
 
+Changes to the DirectX Backend
+--
+
+* DirectX has been added as an experimental target. Specify
+  ``-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=DirectX`` in your CMake configuration
+  to enable it. The target is not packaged in pre-built binaries.
+* The DirectX backend supports the ``dxil`` architecture which is based on LLVM
+  3.6 IR encoded as bitcode and is the format used for DirectX GPU Shader
+  programs.
+
 Changes to the Hexagon Backend
 --
 
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -68,6 +68,12 @@
 
   Randomizing structure layout is a C-only feature.
 
+- Experimental support for HLSL has been added. The implementation is
+  incomplete and highly experimental. For more information about the ongoing
+  work to support HLSL see the `documentation
+  `_, or the `GitHub project
+  `_.
+
 Bug Fixes
 -
 - ``CXXNewExpr::getArraySize()`` previously returned a ``llvm::Optional``


Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -110,6 +110,16 @@
 
 * ...
 
+Changes to the DirectX Backend
+--
+
+* DirectX has been added as an experimental target. Specify
+  ``-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=DirectX`` in your CMake configuration
+  to enable it. The target is not packaged in pre-built binaries.
+* The DirectX backend supports the ``dxil`` architecture which is based on LLVM
+  3.6 IR encoded as bitcode and is the format used for DirectX GPU Shader
+  programs.
+
 Changes to the Hexagon Backend
 --
 
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -68,6 +68,12 @@
 
   Randomizing structure layout is a C-only feature.
 
+- Experimental support for HLSL has been added. The implementation is
+  incomplete and highly experimental. For more information about the ongoing
+  work to support HLSL see the `documentation
+  `_, or the `GitHub project
+  `_.
+
 Bug Fixes
 -
 - ``CXXNewExpr::getArraySize()`` previously returned a ``llvm::Optional``
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D126461: [RISCV] Extract and store new vl of vleff/vlsegff iff destination isn't null

2022-06-20 Thread Zakk Chen via Phabricator via cfe-commits
khchen added a comment.

Could you please purpose this implement in rvv-intrinsc-doc first?
I think this feature need to have discussion because store to nullptr is UB but 
we are making it as defined behavior only for these intrinsics.
Personally I like they have consistent behavior and in document side we just 
make a note for users that vl should not be a null pointer.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126461

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


[PATCH] D126461: [RISCV] Extract and store new vl of vleff/vlsegff iff destination isn't null

2022-06-20 Thread Philip Reames via Phabricator via cfe-commits
reames requested changes to this revision.
reames added a comment.
This revision now requires changes to proceed.

Despite the comments above, the purpose of this patch remains unclear.

Per the draft spec, the relevant wording is:
"These instructions execute as a regular load except that they will only take a 
trap caused by a synchronous exception
on element 0. If element 0 raises an exception, vl is not modied, and the trap 
is taken. If an element > 0 raises an
exception, the corresponding trap is not taken, and the vector length vl is 
reduced to the index of the element that would
have raised an exception."

Working through the scenario in this patch with the destination being null, the 
expected result is for a trap to be generated (provided null is unmapped of 
course), and VL not to be modified.  In order for this change to make any 
difference in runtime behavior, the value passed must be null (or otherwise 
guaranteed to fault).  It seems very odd to me that we are modifying code which 
only runs after an instruction which is guaranteed to fault.  Is there an 
assumed runtime here which is e.g. restarting execution?

Presumably, the actual IR instruction returns the unmodified VL in the faulting 
first access case.  (If it doesn't, that's a bug we should fix.)

The last point, and it's a critical one, is that the outparam for new_vl does 
not have to be null if dest is.  Given that, I think the entire prior 
discussion on motivation here is off base.  Unless you can point to something 
in the intrinsic docs which says *explicitly* that the new_vl param to the 
intrinsic can be null when the dest is known to fault, I think we should 
strongly reject this patch.  Even if you can, I think we should first ask if 
that's a bug in the intrinsic spec.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126461

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


[PATCH] D127313: [libc++] Implement P0618R0 (Deprecating )

2022-06-20 Thread Nikolas Klauser via Phabricator via cfe-commits
philnik updated this revision to Diff 438407.
philnik added a comment.

- Try to fix CI


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127313

Files:
  libcxx/docs/ReleaseNotes.rst
  libcxx/docs/Status/Cxx17Papers.csv
  libcxx/include/codecvt
  libcxx/include/locale
  libcxx/src/locale.cpp
  
libcxx/test/libcxx/localization/locales/locale.convenience/conversions/conversions.string/ctor_move.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_mode.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf16.pass.cpp
  
libcxx/test/std/localization/locale.stdcvt/codecvt_utf16_always_noconv.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf16_encoding.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf16_in.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf16_length.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf16_max_length.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf16_out.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf16_unshift.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf8.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_always_noconv.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_encoding.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_in.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_length.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_max_length.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_out.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_unshift.pass.cpp
  
libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_always_noconv.pass.cpp
  
libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_encoding.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_in.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_length.pass.cpp
  
libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_max_length.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_out.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_unshift.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/depr.verify.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/ctor.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/depr.verify.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/overflow.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/pbackfail.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/rdbuf.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/seekoff.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/state.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/test.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/underflow.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/converted.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/ctor_codecvt.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/ctor_codecvt_state.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/ctor_copy.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/ctor_err_string.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/depr.verify.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/from_bytes.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/state.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/to_bytes.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/types.pass.cpp
  libcxx/test/support/platform_support.h

Index: libcxx/test/support/platform_support.h
===
--- libcxx/test/support/platform_support.h
+++ libcxx/test/support/platform_support.h
@@ -14,6 +14,8 @@
 #ifndef PLATFORM_SUPPORT_H
 #define PLATFORM_SUPPORT_H
 
+#include "test_macros.h"
+
 // locale names
 #define LOCALE_en_US   "en_US"
 #define LOCALE_en_US_UTF_8 "en_US.UTF-8"
@@ -92,8 +94,11 @@
 inline
 std::wstring get_wide_temp_file_name()
 {
+TEST_DIAGNOSTIC_PUSH

[PATCH] D128183: [clang][dataflow] Extend flow condition in the body of a do/while loop

2022-06-20 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 accepted this revision.
gribozavr2 added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp:3700
+EXPECT_TRUE(AfterLoopEnv.flowConditionImplies(
+AfterLoopEnv.makeNot(AfterLoopFooVal)));
+  });

Can we infer that after the loop bar is false?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128183

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


[PATCH] D128197: [clangd] Handle initializers that contain =

2022-06-20 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
kadircet marked an inline comment as done.
Closed by commit rG1c92e06ded2d: [clangd] Handle initializers that contain = 
(authored by kadircet).

Changed prior to commit:
  https://reviews.llvm.org/D128197?vs=438369=438392#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128197

Files:
  clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
  clang-tools-extra/clangd/unittests/tweaks/DefineOutlineTests.cpp


Index: clang-tools-extra/clangd/unittests/tweaks/DefineOutlineTests.cpp
===
--- clang-tools-extra/clangd/unittests/tweaks/DefineOutlineTests.cpp
+++ clang-tools-extra/clangd/unittests/tweaks/DefineOutlineTests.cpp
@@ -116,6 +116,11 @@
   "void foo(int x, int y = 5, int = 2, int (*foo)(int) = nullptr) ;",
   "void foo(int x, int y , int , int (*foo)(int) ) {}",
   },
+  {
+  "struct Bar{Bar();}; void fo^o(Bar x = {}) {}",
+  "struct Bar{Bar();}; void foo(Bar x = {}) ;",
+  "void foo(Bar x ) {}",
+  },
   // Constructors
   {
   R"cpp(
Index: clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
@@ -187,26 +187,30 @@
   // Get rid of default arguments, since they should not be specified in
   // out-of-line definition.
   for (const auto *PVD : FD->parameters()) {
-if (PVD->hasDefaultArg()) {
-  // Deletion range initially spans the initializer, excluding the `=`.
-  auto DelRange = 
CharSourceRange::getTokenRange(PVD->getDefaultArgRange());
-  // Get all tokens before the default argument.
-  auto Tokens = TokBuf.expandedTokens(PVD->getSourceRange())
-.take_while([, ](const syntax::Token ) 
{
-  return SM.isBeforeInTranslationUnit(
-  Tok.location(), DelRange.getBegin());
-});
-  // Find the last `=` before the default arg.
+if (!PVD->hasDefaultArg())
+  continue;
+// Deletion range spans the initializer, usually excluding the `=`.
+auto DelRange = CharSourceRange::getTokenRange(PVD->getDefaultArgRange());
+// Get all tokens before the default argument.
+auto Tokens = TokBuf.expandedTokens(PVD->getSourceRange())
+  .take_while([, ](const syntax::Token ) {
+return SM.isBeforeInTranslationUnit(
+Tok.location(), DelRange.getBegin());
+  });
+if (TokBuf.expandedTokens(DelRange.getAsRange()).front().kind() !=
+tok::equal) {
+  // Find the last `=` if it isn't included in the initializer, and update
+  // the DelRange to include it.
   auto Tok =
   llvm::find_if(llvm::reverse(Tokens), [](const syntax::Token ) {
 return Tok.kind() == tok::equal;
   });
   assert(Tok != Tokens.rend());
   DelRange.setBegin(Tok->location());
-  if (auto Err =
-  DeclarationCleanups.add(tooling::Replacement(SM, DelRange, "")))
-Errors = llvm::joinErrors(std::move(Errors), std::move(Err));
 }
+if (auto Err =
+DeclarationCleanups.add(tooling::Replacement(SM, DelRange, "")))
+  Errors = llvm::joinErrors(std::move(Errors), std::move(Err));
   }
 
   auto DelAttr = [&](const Attr *A) {


Index: clang-tools-extra/clangd/unittests/tweaks/DefineOutlineTests.cpp
===
--- clang-tools-extra/clangd/unittests/tweaks/DefineOutlineTests.cpp
+++ clang-tools-extra/clangd/unittests/tweaks/DefineOutlineTests.cpp
@@ -116,6 +116,11 @@
   "void foo(int x, int y = 5, int = 2, int (*foo)(int) = nullptr) ;",
   "void foo(int x, int y , int , int (*foo)(int) ) {}",
   },
+  {
+  "struct Bar{Bar();}; void fo^o(Bar x = {}) {}",
+  "struct Bar{Bar();}; void foo(Bar x = {}) ;",
+  "void foo(Bar x ) {}",
+  },
   // Constructors
   {
   R"cpp(
Index: clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
@@ -187,26 +187,30 @@
   // Get rid of default arguments, since they should not be specified in
   // out-of-line definition.
   for (const auto *PVD : FD->parameters()) {
-if (PVD->hasDefaultArg()) {
-  // Deletion range initially spans the initializer, excluding the `=`.
-  auto DelRange = CharSourceRange::getTokenRange(PVD->getDefaultArgRange());
-  // Get all tokens before the default 

[clang-tools-extra] 1c92e06 - [clangd] Handle initializers that contain =

2022-06-20 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2022-06-20T16:42:54+02:00
New Revision: 1c92e06ded2da33f9ad00305af281e47cf9c584f

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

LOG: [clangd] Handle initializers that contain =

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

Added: 


Modified: 
clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
clang-tools-extra/clangd/unittests/tweaks/DefineOutlineTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp 
b/clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
index 0bbf3274b3a62..298546aed3be9 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
+++ b/clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
@@ -187,26 +187,30 @@ getFunctionSourceCode(const FunctionDecl *FD, 
llvm::StringRef TargetNamespace,
   // Get rid of default arguments, since they should not be specified in
   // out-of-line definition.
   for (const auto *PVD : FD->parameters()) {
-if (PVD->hasDefaultArg()) {
-  // Deletion range initially spans the initializer, excluding the `=`.
-  auto DelRange = 
CharSourceRange::getTokenRange(PVD->getDefaultArgRange());
-  // Get all tokens before the default argument.
-  auto Tokens = TokBuf.expandedTokens(PVD->getSourceRange())
-.take_while([, ](const syntax::Token ) 
{
-  return SM.isBeforeInTranslationUnit(
-  Tok.location(), DelRange.getBegin());
-});
-  // Find the last `=` before the default arg.
+if (!PVD->hasDefaultArg())
+  continue;
+// Deletion range spans the initializer, usually excluding the `=`.
+auto DelRange = CharSourceRange::getTokenRange(PVD->getDefaultArgRange());
+// Get all tokens before the default argument.
+auto Tokens = TokBuf.expandedTokens(PVD->getSourceRange())
+  .take_while([, ](const syntax::Token ) {
+return SM.isBeforeInTranslationUnit(
+Tok.location(), DelRange.getBegin());
+  });
+if (TokBuf.expandedTokens(DelRange.getAsRange()).front().kind() !=
+tok::equal) {
+  // Find the last `=` if it isn't included in the initializer, and update
+  // the DelRange to include it.
   auto Tok =
   llvm::find_if(llvm::reverse(Tokens), [](const syntax::Token ) {
 return Tok.kind() == tok::equal;
   });
   assert(Tok != Tokens.rend());
   DelRange.setBegin(Tok->location());
-  if (auto Err =
-  DeclarationCleanups.add(tooling::Replacement(SM, DelRange, "")))
-Errors = llvm::joinErrors(std::move(Errors), std::move(Err));
 }
+if (auto Err =
+DeclarationCleanups.add(tooling::Replacement(SM, DelRange, "")))
+  Errors = llvm::joinErrors(std::move(Errors), std::move(Err));
   }
 
   auto DelAttr = [&](const Attr *A) {

diff  --git a/clang-tools-extra/clangd/unittests/tweaks/DefineOutlineTests.cpp 
b/clang-tools-extra/clangd/unittests/tweaks/DefineOutlineTests.cpp
index 3131e2063716b..e3954e6b2faff 100644
--- a/clang-tools-extra/clangd/unittests/tweaks/DefineOutlineTests.cpp
+++ b/clang-tools-extra/clangd/unittests/tweaks/DefineOutlineTests.cpp
@@ -116,6 +116,11 @@ TEST_F(DefineOutlineTest, ApplyTest) {
   "void foo(int x, int y = 5, int = 2, int (*foo)(int) = nullptr) ;",
   "void foo(int x, int y , int , int (*foo)(int) ) {}",
   },
+  {
+  "struct Bar{Bar();}; void fo^o(Bar x = {}) {}",
+  "struct Bar{Bar();}; void foo(Bar x = {}) ;",
+  "void foo(Bar x ) {}",
+  },
   // Constructors
   {
   R"cpp(



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


[PATCH] D127873: [clang-format] Fix misplacemnt of `*` in declaration of pointer to struct

2022-06-20 Thread Jack Huang via Phabricator via cfe-commits
jackhong12 added inline comments.



Comment at: clang/lib/Format/TokenAnnotator.cpp:2328
+}
+
 if (PrevToken->Tok.isLiteral() ||

HazardyKnusperkeks wrote:
> MyDeveloperDay wrote:
> > Thank you I wish more of the clauses were commented like this
> +1
I'm not sure where I also need to add comments.


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

https://reviews.llvm.org/D127873

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


[PATCH] D127593: [clang] Fix trivially copyable for copy constructor and copy assignment operator

2022-06-20 Thread Stephan Bergmann via Phabricator via cfe-commits
sberg added a comment.

Is it intended that a deleted copy assignment op as in `struct S { void 
operator =(S &) = delete; };` (though, somewhat oddly, not in `struct S { void 
operator =(S) = delete; };`) is now marked as trivial?

I think that's the root cause why a build of PDFium with clang-cl against the 
MSVC standard library started to fail for me now, effectively complaining that 
`__is_trivially_assignable(std::pair &, std::pair const &)` 
is false (as expected) while `__has_trivial_assign(std::pair)` is 
(unexpectedly) true.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127593

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


[PATCH] D126859: [clangd] Validate clang-tidy CheckOptions in clangd config

2022-06-20 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 438388.
njames93 added a comment.

Reuse implementation from D127446 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126859

Files:
  clang-tools-extra/clangd/ConfigCompile.cpp
  clang-tools-extra/clangd/TidyProvider.cpp
  clang-tools-extra/clangd/TidyProvider.h
  clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp

Index: clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
===
--- clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
+++ clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
@@ -338,7 +338,9 @@
   EXPECT_EQ(
   Conf.Diagnostics.ClangTidy.Checks,
   "bugprone-use-after-move,llvm-*,-llvm-include-order,-readability-*");
-  EXPECT_THAT(Diags.Diagnostics, IsEmpty());
+  EXPECT_THAT(Diags.Diagnostics,
+  ElementsAre(diagMessage(
+  "unknown clang-tidy option 'example-check.ExampleOption'")));
 #else // !CLANGD_TIDY_CHECKS
   EXPECT_EQ(Conf.Diagnostics.ClangTidy.Checks, "llvm-*,-readability-*");
   EXPECT_THAT(
@@ -346,7 +348,9 @@
   ElementsAre(
   diagMessage(
   "clang-tidy check 'bugprone-use-after-move' was not found"),
-  diagMessage("clang-tidy check 'llvm-include-order' was not found")));
+  diagMessage("clang-tidy check 'llvm-include-order' was not found"),
+  diagMessage(
+  "unknown clang-tidy option 'example-check.ExampleOption'")));
 #endif
 }
 
@@ -355,6 +359,15 @@
   Tidy.Add.emplace_back("unknown-check");
   Tidy.Remove.emplace_back("*");
   Tidy.Remove.emplace_back("llvm-includeorder");
+#if CLANGD_TIDY_CHECKS
+  StringRef IncludeOrderMessage =
+  "clang-tidy check 'llvm-includeorder' was not found; did you mean "
+  "'llvm-include-order'";
+#else // !CLANGD_TIDY_CHECKS
+  StringRef IncludeOrderMessage =
+  "clang-tidy check 'llvm-includeorder' was not found";
+#endif
+
   EXPECT_TRUE(compileAndApply());
   // Ensure bad checks are stripped from the glob.
   EXPECT_EQ(Conf.Diagnostics.ClangTidy.Checks, "-*");
@@ -363,9 +376,49 @@
   ElementsAre(
   AllOf(diagMessage("clang-tidy check 'unknown-check' was not found"),
 diagKind(llvm::SourceMgr::DK_Warning)),
-  AllOf(
-  diagMessage("clang-tidy check 'llvm-includeorder' was not found"),
-  diagKind(llvm::SourceMgr::DK_Warning;
+  AllOf(diagMessage(IncludeOrderMessage),
+diagKind(llvm::SourceMgr::DK_Warning;
+}
+
+TEST_F(ConfigCompileTests, TidyBadOptions) {
+  auto  = Frag.Diagnostics.ClangTidy;
+  Tidy.CheckOptions.emplace_back(
+  std::make_pair(std::string("BadGlobal"), std::string("true")));
+  Tidy.CheckOptions.emplace_back(
+  std::make_pair(std::string("StrictModes"), std::string("true")));
+  Tidy.CheckOptions.emplace_back(std::make_pair(
+  std::string("readability-braces-around-statements.ShortStatementsLines"),
+  std::string("1")));
+  Tidy.CheckOptions.emplace_back(std::make_pair(
+  std::string("readability-braces-around-statements.ShortStatementLines"),
+  std::string("1")));
+  EXPECT_TRUE(compileAndApply());
+#if CLANGD_TIDY_CHECKS
+  EXPECT_THAT(
+  Diags.Diagnostics,
+  ElementsAre(
+  diagMessage("unknown clang-tidy option 'BadGlobal'"),
+  diagMessage("unknown clang-tidy option 'StrictModes'; did you mean "
+  "'StrictMode'"),
+  diagMessage(
+  "unknown clang-tidy option "
+  "'readability-braces-around-statements.ShortStatementsLines'; "
+  "did you mean "
+  "'readability-braces-around-statements.ShortStatementLines'")));
+#else // !CLANGD_TIDY_CHECKS
+  EXPECT_THAT(
+  Diags.Diagnostics,
+  ElementsAre(
+  diagMessage("unknown clang-tidy option 'BadGlobal'"),
+  diagMessage("unknown clang-tidy option 'StrictModes'; did you mean "
+  "'StrictMode'"),
+  diagMessage(
+  "unknown clang-tidy option "
+  "'readability-braces-around-statements.ShortStatementsLines'"),
+  diagMessage(
+  "unknown clang-tidy option "
+  "'readability-braces-around-statements.ShortStatementLines'")));
+#endif
 }
 
 TEST_F(ConfigCompileTests, ExternalServerNeedsTrusted) {
Index: clang-tools-extra/clangd/TidyProvider.h
===
--- clang-tools-extra/clangd/TidyProvider.h
+++ clang-tools-extra/clangd/TidyProvider.h
@@ -58,7 +58,11 @@
 
 /// Returns if \p Check is a registered clang-tidy check
 /// \pre \p must not be empty, must not contain '*' or ',' or start with '-'.
-bool isRegisteredTidyCheck(llvm::StringRef Check);
+bool isRegisteredTidyCheck(llvm::StringRef Check,
+   llvm::StringRef 

[PATCH] D127856: [clangd] Support multiline semantic tokens

2022-06-20 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:948
+} else {
+  // If a tokens length is past the end of the line, it should be treated 
as
+  // if the token ends at the end of the line and will not wrap onto the

sammccall wrote:
> sammccall wrote:
> > This wording is hard for me to follow. I think it's saying:
> > 
> > "If the token spans a line break, truncate it to avoid this"
> It seems it would be better to split into one token per line, rather than 
> simply truncating.
> 
> Is truncation for simplicity or is there a reason to prefer it?
> 
> FWIW I think this wouldn't be too hard to implement if you reordered the 
> tokenType/tokenModifiers above so this part is the last step, and just copied 
> the whole SemanticToken object from the back of the Result. But on the other 
> hand it's not terribly important, either.
> 
> At least I think we should have a comment for the truncate/split tradeoff.
> This wording is hard for me to follow. I think it's saying:

It is actually from LSP  changed into a simpler version, I don't think we need 
references to LSP in here.

> Is truncation for simplicity or is there a reason to prefer it?

Yeah I didn't want to do a loop, as in theory there can be many lines not just 
two. Also we need to take care of the `Last` and delta calculations for the 
following tokens.
But it isn't as bad, i suppose. Changed into splitting.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127856

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


[PATCH] D127856: [clangd] Support multiline semantic tokens

2022-06-20 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 438387.
kadircet added a comment.

Split highlights into multiple tokens rather than trimming


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127856

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/SemanticHighlighting.h
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp

Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -944,7 +944,7 @@
   )");
   Tokens.front().Modifiers |= unsigned(HighlightingModifier::Declaration);
   Tokens.front().Modifiers |= unsigned(HighlightingModifier::Readonly);
-  auto Results = toSemanticTokens(Tokens);
+  auto Results = toSemanticTokens(Tokens, /*Code=*/"");
 
   ASSERT_THAT(Results, SizeIs(3));
   EXPECT_EQ(Results[0].tokenType, unsigned(HighlightingKind::Variable));
@@ -972,13 +972,15 @@
   auto Before = toSemanticTokens(tokens(R"(
 [[foo]] [[bar]] [[baz]]
 [[one]] [[two]] [[three]]
-  )"));
+  )"),
+ /*Code=*/"");
   EXPECT_THAT(diffTokens(Before, Before), IsEmpty());
 
   auto After = toSemanticTokens(tokens(R"(
 [[foo]] [[hello]] [[world]] [[baz]]
 [[one]] [[two]] [[three]]
-  )"));
+  )"),
+/*Code=*/"");
 
   // Replace [bar, baz] with [hello, world, baz]
   auto Diff = diffTokens(Before, After);
@@ -1000,6 +1002,30 @@
   EXPECT_EQ(3u, Diff.front().tokens[2].length);
 }
 
+TEST(SemanticHighlighting, MultilineTokens) {
+  llvm::StringRef AnnotatedCode = R"cpp(
+[[fo
+o
+o]] [[bar]])cpp";
+  auto Toks = toSemanticTokens(tokens(AnnotatedCode),
+   Annotations(AnnotatedCode).code());
+  ASSERT_THAT(Toks, SizeIs(4));
+  // foo
+  EXPECT_EQ(Toks[0].deltaLine, 1u);
+  EXPECT_EQ(Toks[0].deltaStart, 0u);
+  EXPECT_EQ(Toks[0].length, 2u);
+  EXPECT_EQ(Toks[1].deltaLine, 1u);
+  EXPECT_EQ(Toks[1].deltaStart, 0u);
+  EXPECT_EQ(Toks[1].length, 1u);
+  EXPECT_EQ(Toks[2].deltaLine, 1u);
+  EXPECT_EQ(Toks[2].deltaStart, 0u);
+  EXPECT_EQ(Toks[2].length, 1u);
+
+  // bar
+  EXPECT_EQ(Toks[3].deltaLine, 0u);
+  EXPECT_EQ(Toks[3].deltaStart, 2u);
+  EXPECT_EQ(Toks[3].length, 3u);
+}
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/SemanticHighlighting.h
===
--- clang-tools-extra/clangd/SemanticHighlighting.h
+++ clang-tools-extra/clangd/SemanticHighlighting.h
@@ -21,6 +21,7 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_SEMANTICHIGHLIGHTING_H
 
 #include "Protocol.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/raw_ostream.h"
 
 namespace clang {
@@ -101,7 +102,8 @@
 // main AST.
 std::vector getSemanticHighlightings(ParsedAST );
 
-std::vector toSemanticTokens(llvm::ArrayRef);
+std::vector toSemanticTokens(llvm::ArrayRef,
+llvm::StringRef Code);
 llvm::StringRef toSemanticTokenType(HighlightingKind Kind);
 llvm::StringRef toSemanticTokenModifier(HighlightingModifier Modifier);
 std::vector diffTokens(llvm::ArrayRef Before,
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -30,7 +30,9 @@
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Casting.h"
+#include "llvm/Support/Error.h"
 #include 
 
 namespace clang {
@@ -918,33 +920,64 @@
 }
 
 std::vector
-toSemanticTokens(llvm::ArrayRef Tokens) {
+toSemanticTokens(llvm::ArrayRef Tokens,
+ llvm::StringRef Code) {
   assert(std::is_sorted(Tokens.begin(), Tokens.end()));
   std::vector Result;
-  const HighlightingToken *Last = nullptr;
+  llvm::Optional Last;
   for (const HighlightingToken  : Tokens) {
 Result.emplace_back();
-SemanticToken  = Result.back();
+SemanticToken *Out = ();
 // deltaStart/deltaLine are relative if possible.
 if (Last) {
-  assert(Tok.R.start.line >= Last->R.start.line);
-  Out.deltaLine = Tok.R.start.line - Last->R.start.line;
-  if (Out.deltaLine == 0) {
+  assert(Tok.R.start.line >= Last->R.end.line);
+  Out->deltaLine = Tok.R.start.line - Last->R.end.line;
+  if (Out->deltaLine == 0) {
 assert(Tok.R.start.character >= Last->R.start.character);
-Out.deltaStart = Tok.R.start.character - Last->R.start.character;
+Out->deltaStart = Tok.R.start.character - Last->R.start.character;
   } else {
-Out.deltaStart = 

[PATCH] D128207: [clang-doc][NFC] Fix reference invalidation assertion failure.

2022-06-20 Thread liushuai wang via Phabricator via cfe-commits
MTC created this revision.
MTC added reviewers: dexonsmith, mehdi_amini.
MTC added a project: clang-tools-extra.
Herald added subscribers: jsji, usaxena95, pengfei, kadircet, arphaman.
Herald added a project: All.
MTC requested review of this revision.
Herald added subscribers: cfe-commits, ilya-biryukov.

Fix the assertion failure caused by reference invalidation in `SmallString`. It 
seems that this bug was not caught when adding the assertion, see 
https://reviews.llvm.org/D91744.

We can reproduce this bug trivially through the following usage.

  $ clang-doc  --format=html test.cpp
  Emiting docs in html format.
  clang-doc: llvm-project/llvm/include/llvm/ADT/SmallVector.h:173: void 
llvm::SmallVectorTemplateCommon 
>::assertSafeToReferenceAfterResize(const void*, size_t) [with T = char; 
 = void; size_t = long unsigned int]: Assertion 
`isSafeToReferenceAfterResize(Elt, NewSize) && "Attempting to reference an 
element of the vector in an operation " "that invalidates it"' failed.
   #0 0x55ce4806b843 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) 
llvm-project/llvm/lib/Support/Unix/Signals.inc:569:22
   #1 0x55ce4806b8fa PrintStackTraceSignalHandler(void*) 
llvm-project/llvm/lib/Support/Unix/Signals.inc:636:1
   #2 0x55ce4806989a llvm::sys::RunSignalHandlers() 
llvm-project/llvm/lib/Support/Signals.cpp:103:20
   #3 0x55ce4806b277 SignalHandler(int) 
llvm-project/llvm/lib/Support/Unix/Signals.inc:407:1
   #4 0x7f72a4533730 __restore_rt 
(/lib/x86_64-linux-gnu/libpthread.so.0+0x12730)
   #5 0x7f72a3e1a7bb raise 
/build/glibc-fWwxX8/glibc-2.28/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
   #6 0x7f72a3e05535 abort 
/build/glibc-fWwxX8/glibc-2.28/stdlib/abort.c:81:7
   #7 0x7f72a3e0540f _nl_load_domain 
/build/glibc-fWwxX8/glibc-2.28/intl/loadmsgcat.c:1177:9
   #8 0x7f72a3e13102 (/lib/x86_64-linux-gnu/libc.so.6+0x30102)
   #9 0x55ce47f76f1a llvm::SmallVectorTemplateCommon::assertSafeToReferenceAfterResize(void const*, unsigned long) 
llvm-project/llvm/include/llvm/ADT/SmallVector.h:171:5
  #10 0x55ce47f79efc llvm::SmallVectorTemplateCommon::assertSafeToReferenceAfterClear(char const*, char const*) 
llvm-project/llvm/include/llvm/ADT/SmallVector.h:187:47
  #11 0x55ce47f743ed void llvm::SmallVectorImpl::assign(char const*, char const*) 
llvm-project/llvm/include/llvm/ADT/SmallVector.h:713:5
  #12 0x55ce47f6c587 llvm::SmallString<128u>::assign(llvm::StringRef) 
llvm-project/llvm/include/llvm/ADT/SmallString.h:53:3
  #13 0x55ce47f64338 llvm::SmallString<128u>::operator=(llvm::StringRef) 
llvm-project/llvm/include/llvm/ADT/SmallString.h:279:13
  #14 0x55ce47f4ab4c main 
llvm-project/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp:226:28
  #15 0x7f72a3e0709b __libc_start_main 
/build/glibc-fWwxX8/glibc-2.28/csu/../csu/libc-start.c:342:3
  #16 0x55ce47f4963a _start (./bin/clang-doc+0x54563a)
  [1]1443196 abort (core dumped)  ./bin/clang-doc --format=html test.cpp


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D128207

Files:
  clang-tools-extra/clang-doc/tool/ClangDocMain.cpp


Index: clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
===
--- clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
+++ clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
@@ -222,7 +222,7 @@
 std::string ClangDocPath = GetExecutablePath(argv[0], MainAddr);
 llvm::SmallString<128> AssetsPath;
 llvm::sys::path::native(ClangDocPath, AssetsPath);
-AssetsPath = llvm::sys::path::parent_path(AssetsPath);
+AssetsPath = std::string(llvm::sys::path::parent_path(AssetsPath));
 llvm::sys::path::append(AssetsPath, "..", "share", "clang");
 llvm::SmallString<128> DefaultStylesheet;
 llvm::sys::path::native(AssetsPath, DefaultStylesheet);


Index: clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
===
--- clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
+++ clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
@@ -222,7 +222,7 @@
 std::string ClangDocPath = GetExecutablePath(argv[0], MainAddr);
 llvm::SmallString<128> AssetsPath;
 llvm::sys::path::native(ClangDocPath, AssetsPath);
-AssetsPath = llvm::sys::path::parent_path(AssetsPath);
+AssetsPath = std::string(llvm::sys::path::parent_path(AssetsPath));
 llvm::sys::path::append(AssetsPath, "..", "share", "clang");
 llvm::SmallString<128> DefaultStylesheet;
 llvm::sys::path::native(AssetsPath, DefaultStylesheet);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D128206: [Clang] Allow multiple comma separated arguments to `--offload-arch=`

2022-06-20 Thread Ye Luo via Phabricator via cfe-commits
ye-luo accepted this revision.
ye-luo added a comment.
This revision is now accepted and ready to land.

LGTM. This allows me to write concise compile lines.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128206

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


[PATCH] D128206: [Clang] Allow multiple comma separated arguments to `--offload-arch=`

2022-06-20 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 created this revision.
jhuber6 added reviewers: tra, yaxunl, jdoerfert, JonChesterfield, ye-luo.
Herald added a project: All.
jhuber6 requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1, MaskRay.
Herald added a project: clang.

This patch updates the `--[no-]offload-arch` command line arguments to
allow the user to pass in many architectures in a single argument rather
than specifying it multiple times. This means that the following command
line,

  clang foo.cu --offload-arch=sm_70 --offload-arch=sm_80

can become:

  clang foo.cu --offload-arch=sm_70,sm_80


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128206

Files:
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/cuda-bindings.cu
  clang/test/Driver/openmp-offload-gpu-new.c


Index: clang/test/Driver/openmp-offload-gpu-new.c
===
--- clang/test/Driver/openmp-offload-gpu-new.c
+++ clang/test/Driver/openmp-offload-gpu-new.c
@@ -51,6 +51,8 @@
 // CHECK-TEMP-BINDINGS: "x86_64-unknown-linux-gnu" - "Offload::Packager", 
inputs: ["[[DEVICE_OBJ:.+]]"], output: "[[BINARY:.+.out]]"
 
 // RUN:   %clang -### --target=x86_64-unknown-linux-gnu -ccc-print-bindings 
-fopenmp -fopenmp-targets=nvptx64-nvidia-cuda --offload-arch=sm_52 
--offload-arch=sm_70 -nogpulib %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-ARCH-BINDINGS
+// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -ccc-print-bindings 
-fopenmp -fopenmp-targets=nvptx64-nvidia-cuda --offload-arch=sm_52,sm_70 
-nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-ARCH-BINDINGS
+// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -ccc-print-bindings 
-fopenmp -fopenmp-targets=nvptx64-nvidia-cuda 
--offload-arch=sm_52,sm_70,sm_35,sm_80 --no-offload-arch=sm_35,sm_80 -nogpulib 
%s 2>&1 | FileCheck %s --check-prefix=CHECK-ARCH-BINDINGS
 // CHECK-ARCH-BINDINGS: "x86_64-unknown-linux-gnu" - "clang", inputs: 
["[[INPUT:.*]]"], output: "[[HOST_BC:.*]]"
 // CHECK-ARCH-BINDINGS: "nvptx64-nvidia-cuda" - "clang", inputs: ["[[INPUT]]", 
"[[HOST_BC]]"], output: "[[DEVICE_BC_SM_52:.*]]"
 // CHECK-ARCH-BINDINGS: "nvptx64-nvidia-cuda" - "NVPTX::Assembler", inputs: 
["[[DEVICE_BC_SM_52]]"], output: "[[DEVICE_OBJ_SM_52:.*]]"
Index: clang/test/Driver/cuda-bindings.cu
===
--- clang/test/Driver/cuda-bindings.cu
+++ clang/test/Driver/cuda-bindings.cu
@@ -40,6 +40,7 @@
 // Test two gpu architectures with complete compilation.
 //
 // RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings 
--cuda-gpu-arch=sm_30 --cuda-gpu-arch=sm_35 %s 2>&1 \
+// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings 
--offload-arch=sm_30,sm_35 %s 2>&1 \
 // RUN: | FileCheck -check-prefix=BIN2 %s
 // BIN2: # "nvptx64-nvidia-cuda" - "clang",{{.*}} output:
 // BIN2-NOT: cuda-bindings-device-cuda-nvptx64
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -2973,7 +2973,7 @@
  << "--offload";
   }
 
-  // Collect all cuda_gpu_arch parameters, removing duplicates.
+  // Collect all offload arch parameters, removing duplicates.
   std::set GpuArchs;
   bool Error = false;
   for (Arg *A : Args) {
@@ -2982,21 +2982,22 @@
   continue;
 A->claim();
 
-StringRef ArchStr = A->getValue();
-if (A->getOption().matches(options::OPT_no_offload_arch_EQ) &&
-ArchStr == "all") {
-  GpuArchs.clear();
-  continue;
+for (StringRef ArchStr : llvm::split(A->getValue(), ",")) {
+  if (A->getOption().matches(options::OPT_no_offload_arch_EQ) &&
+  ArchStr == "all") {
+GpuArchs.clear();
+  } else {
+ArchStr = getCanonicalOffloadArch(ArchStr);
+if (ArchStr.empty()) {
+  Error = true;
+} else if (A->getOption().matches(options::OPT_offload_arch_EQ))
+  GpuArchs.insert(ArchStr);
+else if (A->getOption().matches(options::OPT_no_offload_arch_EQ))
+  GpuArchs.erase(ArchStr);
+else
+  llvm_unreachable("Unexpected option.");
+  }
 }
-ArchStr = getCanonicalOffloadArch(ArchStr);
-if (ArchStr.empty()) {
-  Error = true;
-} else if (A->getOption().matches(options::OPT_offload_arch_EQ))
-  GpuArchs.insert(ArchStr);
-else if (A->getOption().matches(options::OPT_no_offload_arch_EQ))
-  GpuArchs.erase(ArchStr);
-else
-  llvm_unreachable("Unexpected option.");
   }
 
   auto & = getConflictOffloadArchCombination(GpuArchs);
@@ -4356,14 +4357,15 @@
   llvm::DenseSet Archs;
   for (auto  : Args) {
 if (Arg->getOption().matches(options::OPT_offload_arch_EQ)) {
-  Archs.insert(

[PATCH] D128204: [clangd] Add fix-it for inserting IWYU pragma: keep

2022-06-20 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added reviewers: sammccall, kadircet, kbobyrev.
Herald added subscribers: usaxena95, arphaman.
Herald added a project: All.
njames93 requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

Since IncludeCleaner has some support for IWYU keep pragmas, we can suggest it 
as a fix-it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128204

Files:
  clang-tools-extra/clangd/IncludeCleaner.cpp
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp


Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -1792,7 +1792,7 @@
 
 TEST(DiagnosticsTest, IncludeCleaner) {
   Annotations Test(R"cpp(
-$fix[[  $diag[[#include "unused.h"]]
+$fix[[  $diag[[#include "unused.h"]]$insert[[]]
 ]]
   #include "used.h"
 
@@ -1831,11 +1831,13 @@
   auto AST = TU.build();
   EXPECT_THAT(
   *AST.getDiagnostics(),
-  UnorderedElementsAre(AllOf(
-  Diag(Test.range("diag"),
-   "included header unused.h is not used directly"),
-  withTag(DiagnosticTag::Unnecessary), diagSource(Diag::Clangd),
-  withFix(Fix(Test.range("fix"), "", "remove #include directive");
+  UnorderedElementsAre(
+  AllOf(Diag(Test.range("diag"),
+ "included header unused.h is not used directly"),
+withTag(DiagnosticTag::Unnecessary), diagSource(Diag::Clangd),
+withFix(Fix(Test.range("fix"), "", "remove #include 
directive"),
+Fix(Test.range("insert"), " // IWYU pragma: keep",
+"add pragma keep directive");
   auto  = AST.getDiagnostics()->front();
   EXPECT_EQ(getDiagnosticDocURI(Diag.Source, Diag.ID, Diag.Name),
 std::string("https://clangd.llvm.org/guides/include-cleaner;));
Index: clang-tools-extra/clangd/IncludeCleaner.cpp
===
--- clang-tools-extra/clangd/IncludeCleaner.cpp
+++ clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -506,6 +506,13 @@
 D.Fixes.back().Edits.emplace_back();
 D.Fixes.back().Edits.back().range.start.line = Inc->HashLine;
 D.Fixes.back().Edits.back().range.end.line = Inc->HashLine + 1;
+// Add a fix to append IWYU pragma: keep
+D.Fixes.emplace_back();
+D.Fixes.back().Message = "add pragma keep directive";
+D.Fixes.back().Edits.emplace_back();
+D.Fixes.back().Edits.back().newText = " // IWYU pragma: keep";
+D.Fixes.back().Edits.back().range.start =
+D.Fixes.back().Edits.back().range.end = D.Range.end;
 D.InsideMainFile = true;
 Result.push_back(std::move(D));
   }


Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -1792,7 +1792,7 @@
 
 TEST(DiagnosticsTest, IncludeCleaner) {
   Annotations Test(R"cpp(
-$fix[[  $diag[[#include "unused.h"]]
+$fix[[  $diag[[#include "unused.h"]]$insert[[]]
 ]]
   #include "used.h"
 
@@ -1831,11 +1831,13 @@
   auto AST = TU.build();
   EXPECT_THAT(
   *AST.getDiagnostics(),
-  UnorderedElementsAre(AllOf(
-  Diag(Test.range("diag"),
-   "included header unused.h is not used directly"),
-  withTag(DiagnosticTag::Unnecessary), diagSource(Diag::Clangd),
-  withFix(Fix(Test.range("fix"), "", "remove #include directive");
+  UnorderedElementsAre(
+  AllOf(Diag(Test.range("diag"),
+ "included header unused.h is not used directly"),
+withTag(DiagnosticTag::Unnecessary), diagSource(Diag::Clangd),
+withFix(Fix(Test.range("fix"), "", "remove #include directive"),
+Fix(Test.range("insert"), " // IWYU pragma: keep",
+"add pragma keep directive");
   auto  = AST.getDiagnostics()->front();
   EXPECT_EQ(getDiagnosticDocURI(Diag.Source, Diag.ID, Diag.Name),
 std::string("https://clangd.llvm.org/guides/include-cleaner;));
Index: clang-tools-extra/clangd/IncludeCleaner.cpp
===
--- clang-tools-extra/clangd/IncludeCleaner.cpp
+++ clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -506,6 +506,13 @@
 D.Fixes.back().Edits.emplace_back();
 D.Fixes.back().Edits.back().range.start.line = Inc->HashLine;
 D.Fixes.back().Edits.back().range.end.line = Inc->HashLine + 1;
+// Add a fix to append IWYU pragma: keep
+D.Fixes.emplace_back();
+D.Fixes.back().Message = "add pragma keep directive";
+D.Fixes.back().Edits.emplace_back();
+

[PATCH] D128202: [clangd] Include "final" when printing class declaration

2022-06-20 Thread Tom Praschan via Phabricator via cfe-commits
tom-anders added inline comments.



Comment at: clang/lib/AST/DeclPrinter.cpp:1010
 
+  if (D->isEffectivelyFinal()) {
+  Out << " final";

sammccall wrote:
> isEffectivelyFinal returns true for
> `struct X { ~X() final; }`
> 
> I don't think we want to print `struct X final {}` in that case.
> 
> Probably want to replicate the check for FinalAttr instead?
Agreed. Would probably make sense to add a `bool hasFinalAttribute() const` to 
`CXXRecordDecl`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128202

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


[PATCH] D126559: [MSVC] Fix pragma alloc_text failing for C files

2022-06-20 Thread Stephen Long via Phabricator via cfe-commits
steplong added a comment.

Hmm, it looks like MSVC is accepting:

  extern "C" {
  static void foo();
  }
  
  static int foo();
  #pragma alloc_text("s", foo)
  static void foo() {}

Ignoring the `pragma alloc_text`, it looks like GCC compiles the following 
`foo` with C linkage vs LLVM which compiles with C++ linkage (foo's name is 
mangled):

  extern "C" {
  static int foo();
  }
  
  static int foo();
  static int foo() {
return 3;
  }
  
  int bar() {
return foo();
  }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126559

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


[PATCH] D128202: [clangd] Include "final" when printing class declaration

2022-06-20 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang/lib/AST/DeclPrinter.cpp:1010
 
+  if (D->isEffectivelyFinal()) {
+  Out << " final";

isEffectivelyFinal returns true for
`struct X { ~X() final; }`

I don't think we want to print `struct X final {}` in that case.

Probably want to replicate the check for FinalAttr instead?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128202

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


[PATCH] D105494: [clang] Introduce a union inside ProgramPoint.

2022-06-20 Thread Sam Elliott via Phabricator via cfe-commits
lenary added a comment.
Herald added a project: All.

This change looks fine to me (though clang-format wants a reasonable change). 
I'm not familiar with the clang static analyzer, so I'm not sure I can +2 this, 
but hopefully this message will act as a ping for the existing reviewers?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105494

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


[PATCH] D128202: [clangd] Include "final" when printing class declaration

2022-06-20 Thread Tom Praschan via Phabricator via cfe-commits
tom-anders created this revision.
Herald added subscribers: usaxena95, kadircet, arphaman.
Herald added a project: All.
tom-anders requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added projects: clang, clang-tools-extra.

Fixes https://github.com/clangd/clangd/issues/1184


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128202

Files:
  clang-tools-extra/clangd/unittests/HoverTests.cpp
  clang/lib/AST/DeclPrinter.cpp


Index: clang/lib/AST/DeclPrinter.cpp
===
--- clang/lib/AST/DeclPrinter.cpp
+++ clang/lib/AST/DeclPrinter.cpp
@@ -1007,6 +1007,10 @@
 }
   }
 
+  if (D->isEffectivelyFinal()) {
+  Out << " final";
+  }
+
   if (D->isCompleteDefinition()) {
 // Print the base classes
 if (D->getNumBases()) {
Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -198,7 +198,7 @@
 typename = char,
 int = 0,
 bool Q = false,
-class... Ts> class Foo {};
+class... Ts> class Foo final {};
   template  class T>
   [[F^oo]] foo;
   )cpp",
@@ -209,7 +209,7 @@
  HI.Definition =
  R"cpp(template  class C, typename = 
char, int = 0,
   bool Q = false, class... Ts>
-class Foo {})cpp";
+class Foo final {})cpp";
  HI.TemplateParameters = {
  {{"template  class"},
   std::string("C"),


Index: clang/lib/AST/DeclPrinter.cpp
===
--- clang/lib/AST/DeclPrinter.cpp
+++ clang/lib/AST/DeclPrinter.cpp
@@ -1007,6 +1007,10 @@
 }
   }
 
+  if (D->isEffectivelyFinal()) {
+  Out << " final";
+  }
+
   if (D->isCompleteDefinition()) {
 // Print the base classes
 if (D->getNumBases()) {
Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -198,7 +198,7 @@
 typename = char,
 int = 0,
 bool Q = false,
-class... Ts> class Foo {};
+class... Ts> class Foo final {};
   template  class T>
   [[F^oo]] foo;
   )cpp",
@@ -209,7 +209,7 @@
  HI.Definition =
  R"cpp(template  class C, typename = char, int = 0,
   bool Q = false, class... Ts>
-class Foo {})cpp";
+class Foo final {})cpp";
  HI.TemplateParameters = {
  {{"template  class"},
   std::string("C"),
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D125728: [WebAssembly] Update supported features in -mcpu=generic

2022-06-20 Thread Alex Bradbury via Phabricator via cfe-commits
asb added a comment.

One thing that's not ideal about this test case is that it still passes if you 
delete the changes to WebAssembly.cpp. At least for RISC-V, selecting the -mcpu 
also emits the relevant `-target-feature +foo` for features supported by that 
CPU, which doesn't seem to happen here. Haven't been able to trace through to 
see if that's due to us doing something obviously different in the RISC-V case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125728

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


[PATCH] D128119: [clang] enforce instantiation of constexpr template functions

2022-06-20 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

This also seems to fix https://github.com/llvm/llvm-project/issues/37522 and 
https://github.com/llvm/llvm-project/issues/55315


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

https://reviews.llvm.org/D128119

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


[PATCH] D128197: [clangd] Handle initializers that contain =

2022-06-20 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp:192
+  continue;
+// Deletion range initially spans the initializer, excluding the `=`.
+auto DelRange = CharSourceRange::getTokenRange(PVD->getDefaultArgRange());

nit: usually excluding the `=`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128197

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


[PATCH] D128197: [clangd] Handle initializers that contain =

2022-06-20 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: usaxena95, arphaman.
Herald added a project: All.
kadircet requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128197

Files:
  clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
  clang-tools-extra/clangd/unittests/tweaks/DefineOutlineTests.cpp


Index: clang-tools-extra/clangd/unittests/tweaks/DefineOutlineTests.cpp
===
--- clang-tools-extra/clangd/unittests/tweaks/DefineOutlineTests.cpp
+++ clang-tools-extra/clangd/unittests/tweaks/DefineOutlineTests.cpp
@@ -116,6 +116,11 @@
   "void foo(int x, int y = 5, int = 2, int (*foo)(int) = nullptr) ;",
   "void foo(int x, int y , int , int (*foo)(int) ) {}",
   },
+  {
+  "struct Bar{Bar();}; void fo^o(Bar x = {}) {}",
+  "struct Bar{Bar();}; void foo(Bar x = {}) ;",
+  "void foo(Bar x ) {}",
+  },
   // Constructors
   {
   R"cpp(
Index: clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
@@ -187,26 +187,30 @@
   // Get rid of default arguments, since they should not be specified in
   // out-of-line definition.
   for (const auto *PVD : FD->parameters()) {
-if (PVD->hasDefaultArg()) {
-  // Deletion range initially spans the initializer, excluding the `=`.
-  auto DelRange = 
CharSourceRange::getTokenRange(PVD->getDefaultArgRange());
-  // Get all tokens before the default argument.
-  auto Tokens = TokBuf.expandedTokens(PVD->getSourceRange())
-.take_while([, ](const syntax::Token ) 
{
-  return SM.isBeforeInTranslationUnit(
-  Tok.location(), DelRange.getBegin());
-});
-  // Find the last `=` before the default arg.
+if (!PVD->hasDefaultArg())
+  continue;
+// Deletion range initially spans the initializer, excluding the `=`.
+auto DelRange = CharSourceRange::getTokenRange(PVD->getDefaultArgRange());
+// Get all tokens before the default argument.
+auto Tokens = TokBuf.expandedTokens(PVD->getSourceRange())
+  .take_while([, ](const syntax::Token ) {
+return SM.isBeforeInTranslationUnit(
+Tok.location(), DelRange.getBegin());
+  });
+if (TokBuf.expandedTokens(DelRange.getAsRange()).front().kind() !=
+tok::equal) {
+  // Find the last `=` if it isn't included in the initializer, and update
+  // the DelRange to include it.
   auto Tok =
   llvm::find_if(llvm::reverse(Tokens), [](const syntax::Token ) {
 return Tok.kind() == tok::equal;
   });
   assert(Tok != Tokens.rend());
   DelRange.setBegin(Tok->location());
-  if (auto Err =
-  DeclarationCleanups.add(tooling::Replacement(SM, DelRange, "")))
-Errors = llvm::joinErrors(std::move(Errors), std::move(Err));
 }
+if (auto Err =
+DeclarationCleanups.add(tooling::Replacement(SM, DelRange, "")))
+  Errors = llvm::joinErrors(std::move(Errors), std::move(Err));
   }
 
   auto DelAttr = [&](const Attr *A) {


Index: clang-tools-extra/clangd/unittests/tweaks/DefineOutlineTests.cpp
===
--- clang-tools-extra/clangd/unittests/tweaks/DefineOutlineTests.cpp
+++ clang-tools-extra/clangd/unittests/tweaks/DefineOutlineTests.cpp
@@ -116,6 +116,11 @@
   "void foo(int x, int y = 5, int = 2, int (*foo)(int) = nullptr) ;",
   "void foo(int x, int y , int , int (*foo)(int) ) {}",
   },
+  {
+  "struct Bar{Bar();}; void fo^o(Bar x = {}) {}",
+  "struct Bar{Bar();}; void foo(Bar x = {}) ;",
+  "void foo(Bar x ) {}",
+  },
   // Constructors
   {
   R"cpp(
Index: clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
@@ -187,26 +187,30 @@
   // Get rid of default arguments, since they should not be specified in
   // out-of-line definition.
   for (const auto *PVD : FD->parameters()) {
-if (PVD->hasDefaultArg()) {
-  // Deletion range initially spans the initializer, excluding the `=`.
-  auto DelRange = CharSourceRange::getTokenRange(PVD->getDefaultArgRange());
-  // Get all tokens before the default argument.
-  auto Tokens = 

[PATCH] D127246: [LinkerWrapper] Rework the linker wrapper and use owning binaries

2022-06-20 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

Is anyone up to review this? I'm mostly looking for some feedback on the 
interfaces I've built. If no one has time to look into it I can probably just 
land without review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127246

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


[PATCH] D127363: [Lex] Fix for char32_t literal truncation on 16 bit architectures

2022-06-20 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang/lib/Lex/LiteralSupport.cpp:1600
 
-  llvm::APInt LitVal(PP.getTargetInfo().getIntWidth(), 0);
+  llvm::APInt LitVal(PP.getTargetInfo().getChar32Width(), 0);
 

tahonermann wrote:
> I don't think this is quite right. For the code that follows this change to 
> work as intended and issue the "Character constant too long for its type" 
> diagnostic, the width needs to match that of `int`. This is required for 
> multicharacter literals (they have type `int`) so that an appropriate 
> diagnostic is issued for `'x'` for targets that have a 32-bit int (or for 
> `'xxx'` for targets that have a 16-bit int)`.
> 
> Additionally, the type of a character constant in C is `int`.
> 
> I think what is needed is something like:
>   unsigned BitWidth = getCharWidth(Kind, PP.getTargetInfo());
>   if (IsMultiChar || !PP.getLangOpts().CPlusPlus)
> BitWidth = PP.getTargetInfo().getIntWidth();
>   llvm::APInt LitVal(BitWidth, 0);
Thanks for pointing this out.

My reading of https://eel.is/c++draft/lex.ccon#2 is that a multi-char char 
literal with a L/u8/u/U prefix is not `int` but the respective character types, 
so the conditions here are even a little *more* complicated than you suggest :-(


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127363

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


[PATCH] D122215: [WebAssembly] Initial support for reference type externref in clang

2022-06-20 Thread Alex Bradbury via Phabricator via cfe-commits
asb added a comment.

I've left one minor comment. My other suggestion would be to absorb in the 
semantic restrictions work from here 
.




Comment at: llvm/lib/IR/Type.cpp:307
 
+Type *Type::getWasm_ExternrefTy(LLVMContext ) {
+  // pointer to opaque struct in addrspace(10)

With the move to opaque pointers, I think this and getWasm_FuncRefTy could be 
updated to just return a pointer to addrspace 10 and 20 respectively?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122215

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


[PATCH] D122385: [clang][deps] Fix clang-cl output argument parsing

2022-06-20 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 438367.
jansvoboda11 added a comment.

Code review feedback


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122385

Files:
  clang/test/ClangScanDeps/cl-output.c
  clang/tools/clang-scan-deps/ClangScanDeps.cpp

Index: clang/tools/clang-scan-deps/ClangScanDeps.cpp
===
--- clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -462,27 +462,31 @@
   llvm::sys::path::stem(Args[0]).contains_insensitive("clang-cl") ||
   llvm::is_contained(Args, "--driver-mode=cl");
 
-  // Reverse scan, starting at the end or at the element before "--".
-  auto R = std::make_reverse_iterator(FlagsEnd);
-  for (auto I = R, E = Args.rend(); I != E; ++I) {
+  for (auto I = Args.begin(); I < FlagsEnd; ++I) {
 StringRef Arg = *I;
 if (ClangCLMode) {
   // Ignore arguments that are preceded by "-Xclang".
-  if ((I + 1) != E && I[1] == "-Xclang")
+  if (Arg == "-Xclang") {
+++I;
 continue;
-  if (LastO.empty()) {
-// With clang-cl, the output obj file can be specified with
-// "/opath", "/o path", "/Fopath", and the dash counterparts.
-// Also, clang-cl adds ".obj" extension if none is found.
-if ((Arg == "-o" || Arg == "/o") && I != R)
-  LastO = I[-1]; // Next argument (reverse iterator)
-else if (Arg.startswith("/Fo") || Arg.startswith("-Fo"))
-  LastO = Arg.drop_front(3).str();
-else if (Arg.startswith("/o") || Arg.startswith("-o"))
-  LastO = Arg.drop_front(2).str();
-
-if (!LastO.empty() && !llvm::sys::path::has_extension(LastO))
-  LastO.append(".obj");
+  }
+
+  // With clang-cl, the output obj file can be specified with
+  // "/opath", "/o path", "/Fopath", and the dash counterparts.
+  // Also, clang-cl adds ".obj" extension if none is found.
+  StringRef CurrentO;
+  if ((Arg == "/o" || Arg == "-o") && I + 1 < FlagsEnd)
+CurrentO = *++I;
+  else if (Arg.startswith("/Fo") || Arg.startswith("-Fo"))
+CurrentO = Arg.drop_front(3);
+  else if (Arg.startswith("/o") || Arg.startswith("-o"))
+CurrentO = Arg.drop_front(2);
+
+  if (!CurrentO.empty()) {
+if (!llvm::sys::path::has_extension(CurrentO))
+  LastO = (CurrentO + ".obj").str();
+else
+  LastO = CurrentO.str();
   }
 }
 if (Arg == "-resource-dir")
Index: clang/test/ClangScanDeps/cl-output.c
===
--- /dev/null
+++ clang/test/ClangScanDeps/cl-output.c
@@ -0,0 +1,93 @@
+// This test checks that the output path is correctly deduced/recognized in clang-cl mode.
+
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+
+//--- deduce-cdb.json.template
+[{
+  "file": "DIR/test.c",
+  "directory": "DIR",
+  "command": "clang --driver-mode=cl /c -- DIR/test.c"
+},{
+  "file": "DIR/test.c",
+  "directory": "DIR",
+  "command": "clang-cl /c -- DIR/test.c"
+}]
+
+//--- recognize-cdb.json.template
+[{
+  "file": "DIR/test.c",
+  "directory": "DIR",
+  "command": "clang-cl /c -o DIR/test.o -- DIR/test.c"
+},{
+  "file": "DIR/test.c",
+  "directory": "DIR",
+  "command": "clang-cl /c /o DIR/test.o -- DIR/test.c"
+},{
+  "file": "DIR/test.c",
+  "directory": "DIR",
+  "command": "clang-cl /c -oDIR/test.o -- DIR/test.c"
+},{
+  "file": "DIR/test.c",
+  "directory": "DIR",
+  "command": "clang-cl /c /oDIR/test.o -- DIR/test.c"
+},{
+  "file": "DIR/test.c",
+  "directory": "DIR",
+  "command": "clang-cl /c -FoDIR/test.o -- DIR/test.c"
+},{
+  "file": "DIR/test.c",
+  "directory": "DIR",
+  "command": "clang-cl /c /FoDIR/test.o -- DIR/test.c"
+}]
+
+//--- last-arg-cdb.json.template
+[{
+  "file": "DIR/test.c",
+  "directory": "DIR",
+  "command": "clang-cl /c -o DIR/test.o -o DIR/last.o -- DIR/test.c"
+},{
+  "file": "DIR/test.c",
+  "directory": "DIR",
+  "command": "clang-cl /c /o /opt/test.o -- DIR/test.c"
+}]
+
+//--- test.c
+
+// Check that missing output path is deduced (with both clang-cl executable and driver mode flag):
+//
+// RUN: sed -e "s|DIR|%/t|g" %t/deduce-cdb.json.template > %t/deduce-cdb.json
+// RUN: clang-scan-deps -compilation-database %t/deduce-cdb.json -j 1 > %t/deduce-result.d
+// RUN: cat %t/deduce-result.d | sed 's:\?:/:g' | FileCheck %s -DPREFIX=%/t --check-prefix=CHECK-DEDUCE
+// CHECK-DEDUCE:  test.obj:
+// CHECK-DEDUCE-NEXT:   [[PREFIX]]/test.c
+// CHECK-DEDUCE-NEXT: test.obj:
+// 

[PATCH] D126461: [RISCV] Extract and store new vl of vleff/vlsegff iff destination isn't null

2022-06-20 Thread Wang Pengcheng via Phabricator via cfe-commits
pcwang-thead added a comment.

Ping. Any comments?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126461

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


[PATCH] D127184: [clangd] Add to header map

2022-06-20 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Apologies for not getting to this before vacation, and thanks Nathan for 
looking at this. (I'll leave for you to stamp)

This is fine with me as-is, but I think this mapping shouldn't be our 
*preferred* way to solve this problem, and should eventually go away.

We also have a mapping of **symbol** names to headers (StdSymbols.inc). This is 
obviously more portable, both in the sense that it works when editing using 
e.g. MS STL etc, and that the results don't reflect quirks of the stdlib you're 
using.
The reason this mapping fails for `std::ranges::transform` is that the mapping 
file was extracted from an old C++17 cppreference dump. The cppreference format 
has changed so to run it on a newer dump it'd need some updates.




Comment at: clang-tools-extra/clangd/index/CanonicalIncludes.cpp:197
   {"bits/basic_string.tcc", ""},
+  {"bits/boost_concept_check.h", ""},
   {"bits/char_traits.h", ""},

nridge wrote:
> The choice of `` is pretty random here, as is already the case for 
> `bits/concept_check.h`.
> 
> Given that these headers don't declare any standard symbols, only symbols 
> which are pure libstdc++ implementation details, maybe we should just omit 
> them from the list?
< Given that these headers don't declare any standard symbols, only symbols 
which are pure libstdc++ implementation details, maybe we should just omit them 
from the list?

+1


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127184

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


[PATCH] D128190: [WinEH] Apply funclet operand bundles to nounwind intrinsics that lower to function calls

2022-06-20 Thread Stefan Gränitz via Phabricator via cfe-commits
sgraenitz created this revision.
sgraenitz added reviewers: rnk, theraven, DHowett-MSFT.
Herald added subscribers: jsji, pengfei, hiraditya.
Herald added a project: All.
sgraenitz requested review of this revision.
Herald added projects: clang, LLVM.
Herald added a subscriber: cfe-commits.

WinEHPrepare marks any function call from EH funclets as unreachable, if it's 
not a nounwind intrinsic and has no proper funclet bundle operand. This affects 
ARC intrinsics on Windows, because they are lowered to regular function calls 
in the PreISelIntrinsicLowering pass. It caused silent binary truncations and 
crashes during unwinding with the GNUstep ObjC runtime: 
https://github.com/gnustep/libobjc2/issues/222

This patch adds a new function `llvm::IntrinsicInst::mayLowerToFunctionCall()` 
that aims to collect all affected intrinsic IDs.

- Clang CodeGen uses it to determine whether or not it must emit a funclet 
bundle operand.
- PreISelIntrinsicLowering asserts that the function returns true for all ObjC 
runtime calls it lowers.
- LLVM uses it to determine whether or not a funclet bundle operand must be 
propagated to inlined call sites.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128190

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/test/CodeGenObjCXX/arc-exceptions-seh.mm
  llvm/include/llvm/IR/IntrinsicInst.h
  llvm/lib/CodeGen/PreISelIntrinsicLowering.cpp
  llvm/lib/IR/IntrinsicInst.cpp
  llvm/lib/Transforms/Utils/InlineFunction.cpp
  llvm/test/CodeGen/X86/win64-funclet-preisel-intrinsics.ll
  llvm/test/Feature/OperandBundles/inliner-funclet-wineh.ll

Index: llvm/test/Feature/OperandBundles/inliner-funclet-wineh.ll
===
--- /dev/null
+++ llvm/test/Feature/OperandBundles/inliner-funclet-wineh.ll
@@ -0,0 +1,55 @@
+; RUN: opt -S -always-inline -mtriple=x86_64-windows-msvc < %s | FileCheck %s
+
+; WinEH doesn't require funclet tokens on nounwind intrinsics per se. ObjC++ ARC
+; intrinsics are a special case, because they are subject to pre-ISel lowering.
+; They appear as regular function calls for subsequent passes, like WinEHPrepare
+; which would consider them implausible instrucitons and mark them unreachable.
+; Affected EH funclets would get truncated silently, which causes unpredictable
+; crashes at runtime.
+;
+; Thus, when we target WinEH and generate calls to pre-ISel intrinsics from EH
+; funclets, we emit funclet tokens explicitly.
+;
+; The inliner has to propagate funclet tokens to such intrinsics, if they get
+; inlined into EH funclets.
+
+define void @inlined_fn(ptr %ex) #1 {
+entry:
+  call void @llvm.objc.storeStrong(ptr %ex, ptr null)
+  ret void
+}
+
+define void @test_catch_with_inline() personality ptr @__CxxFrameHandler3 {
+entry:
+  %exn.slot = alloca ptr, align 8
+  %ex = alloca ptr, align 8
+  invoke void @opaque() to label %invoke.cont unwind label %catch.dispatch
+
+catch.dispatch:
+  %0 = catchswitch within none [label %catch] unwind to caller
+
+invoke.cont:
+  unreachable
+
+catch:
+  %1 = catchpad within %0 [ptr null, i32 64, ptr %exn.slot]
+  call void @inlined_fn(ptr %ex) [ "funclet"(token %1) ]
+  catchret from %1 to label %catchret.dest
+
+catchret.dest:
+  ret void
+}
+
+declare void @opaque()
+declare void @llvm.objc.storeStrong(ptr, ptr) #0
+declare i32 @__CxxFrameHandler3(...)
+
+attributes #0 = { nounwind }
+attributes #1 = { alwaysinline }
+
+; CHECK-LABEL:  define void @test_catch_with_inline()
+; ...
+; CHECK:catch:
+; CHECK-NEXT: %1 = catchpad within %0 [ptr null, i32 64, ptr %exn.slot]
+; CHECK-NEXT: call void @llvm.objc.storeStrong(ptr %ex, ptr null) [ "funclet"(token %1) ]
+; CHECK-NEXT: catchret from %1 to label %catchret.dest
Index: llvm/test/CodeGen/X86/win64-funclet-preisel-intrinsics.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/win64-funclet-preisel-intrinsics.ll
@@ -0,0 +1,68 @@
+; RUN: llc -mtriple=x86_64-windows-msvc < %s | FileCheck %s
+
+; Reduced IR generated from ObjC++ source:
+;
+; @class Ety;
+; void opaque(void);
+; void test_catch(void) {
+;   @try {
+; opaque();
+;   } @catch (Ety *ex) {
+; // Destroy ex when leaving catchpad. This emits calls to two intrinsic
+; // functions, llvm.objc.retain and llvm.objc.storeStrong, but only one
+; // is required to trigger the funclet truncation.
+;   }
+; }
+
+define void @test_catch() personality ptr @__CxxFrameHandler3 {
+entry:
+  %exn.slot = alloca ptr, align 8
+  %ex2 = alloca ptr, align 8
+  invoke void @opaque() to label %invoke.cont unwind label %catch.dispatch
+
+catch.dispatch:
+  %0 = catchswitch within none [label %catch] unwind to caller
+
+invoke.cont:
+  unreachable
+
+catch:
+  %1 = catchpad within %0 [ptr null, i32 64, ptr %exn.slot]
+  call void @llvm.objc.storeStrong(ptr %ex2, ptr null) [ "funclet"(token %1) ]
+  catchret from %1 to label 

[PATCH] D125885: [clang-tidy] bugprone-argument-comment: Ignore calls to user-defined literals

2022-06-20 Thread Nathan James via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG541a50e20702: [clang-tidy] bugprone-argument-comment: Ignore 
calls to user-defined literals (authored by jspam, committed by njames93).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125885

Files:
  clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-argument-comment-literals.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-argument-comment-literals.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/bugprone-argument-comment-literals.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/bugprone-argument-comment-literals.cpp
@@ -29,7 +29,7 @@
 void i(const char *c);
 void j(int a, int b, int c);
 
-double operator"" _km(long double);
+double operator"" _km(long double value);
 
 void test() {
   A a;
@@ -171,6 +171,8 @@
   g((1));
   // FIXME But we should not add argument comments here.
   g(_Generic(0, int : 0));
+
+  402.0_km;
 }
 
 void f(bool _with_underscores_);
Index: clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
@@ -60,7 +60,7 @@
 
 void ArgumentCommentCheck::registerMatchers(MatchFinder *Finder) {
   Finder->addMatcher(
-  callExpr(unless(cxxOperatorCallExpr()),
+  callExpr(unless(cxxOperatorCallExpr()), unless(userDefinedLiteral()),
// NewCallback's arguments relate to the pointed function,
// don't check them against NewCallback's parameter names.
// FIXME: Make this configurable.


Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-argument-comment-literals.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-argument-comment-literals.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-argument-comment-literals.cpp
@@ -29,7 +29,7 @@
 void i(const char *c);
 void j(int a, int b, int c);
 
-double operator"" _km(long double);
+double operator"" _km(long double value);
 
 void test() {
   A a;
@@ -171,6 +171,8 @@
   g((1));
   // FIXME But we should not add argument comments here.
   g(_Generic(0, int : 0));
+
+  402.0_km;
 }
 
 void f(bool _with_underscores_);
Index: clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
@@ -60,7 +60,7 @@
 
 void ArgumentCommentCheck::registerMatchers(MatchFinder *Finder) {
   Finder->addMatcher(
-  callExpr(unless(cxxOperatorCallExpr()),
+  callExpr(unless(cxxOperatorCallExpr()), unless(userDefinedLiteral()),
// NewCallback's arguments relate to the pointed function,
// don't check them against NewCallback's parameter names.
// FIXME: Make this configurable.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 541a50e - [clang-tidy] bugprone-argument-comment: Ignore calls to user-defined literals

2022-06-20 Thread Nathan James via cfe-commits

Author: Joachim Priesner
Date: 2022-06-20T13:30:30+01:00
New Revision: 541a50e20702a8046fe5076742611354cb6dd0f3

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

LOG: [clang-tidy] bugprone-argument-comment: Ignore calls to user-defined 
literals

Without this change, code such as "f(/*param=*/1_op)" will check the
comment twice, once for the parameter of f (correct) and once for
the parameter of operator""_op (likely incorrect). The change removes
only the second check.

Reviewed By: njames93, LegalizeAdulthood

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone-argument-comment-literals.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
index 3836e4cf3990d..396b36d6e9afe 100644
--- a/clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
@@ -60,7 +60,7 @@ void 
ArgumentCommentCheck::storeOptions(ClangTidyOptions::OptionMap ) {
 
 void ArgumentCommentCheck::registerMatchers(MatchFinder *Finder) {
   Finder->addMatcher(
-  callExpr(unless(cxxOperatorCallExpr()),
+  callExpr(unless(cxxOperatorCallExpr()), unless(userDefinedLiteral()),
// NewCallback's arguments relate to the pointed function,
// don't check them against NewCallback's parameter names.
// FIXME: Make this configurable.

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone-argument-comment-literals.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone-argument-comment-literals.cpp
index d1f98bd0857bb..d576c187b101f 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone-argument-comment-literals.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone-argument-comment-literals.cpp
@@ -29,7 +29,7 @@ void h(double b);
 void i(const char *c);
 void j(int a, int b, int c);
 
-double operator"" _km(long double);
+double operator"" _km(long double value);
 
 void test() {
   A a;
@@ -171,6 +171,8 @@ void test() {
   g((1));
   // FIXME But we should not add argument comments here.
   g(_Generic(0, int : 0));
+
+  402.0_km;
 }
 
 void f(bool _with_underscores_);



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


[PATCH] D128043: [flang][driver] Add support for `-O{0|1|2|3}`

2022-06-20 Thread Peixin Qiao via Phabricator via cfe-commits
peixin added a comment.

OK. This seems not to be related to this patch. 
https://buildkite.com/llvm-project/premerge-checks/builds/98446#0181715d-812b-4d2a-b5d0-5c1283d78b5f
 I also see these failures in another review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128043

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


[PATCH] D128043: [flang][driver] Add support for `-O{0|1|2|3}`

2022-06-20 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added a comment.

In D128043#3596096 , @peixin wrote:

> The CI failed.

Thanks - I didn't notice any failures related to this change. Did I miss 
anything?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128043

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


[PATCH] D127856: [clangd] Support multiline semantic tokens

2022-06-20 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

(My first reaction was that this belongs in semanticHighlights() rather than 
toSemanticTokens, but I think you got it right - the single-line restriction is 
pretty unnatural from clang's point of view, and cuts across tokens generated 
in different places).




Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:948
+} else {
+  // If a tokens length is past the end of the line, it should be treated 
as
+  // if the token ends at the end of the line and will not wrap onto the

This wording is hard for me to follow. I think it's saying:

"If the token spans a line break, truncate it to avoid this"



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:948
+} else {
+  // If a tokens length is past the end of the line, it should be treated 
as
+  // if the token ends at the end of the line and will not wrap onto the

sammccall wrote:
> This wording is hard for me to follow. I think it's saying:
> 
> "If the token spans a line break, truncate it to avoid this"
It seems it would be better to split into one token per line, rather than 
simply truncating.

Is truncation for simplicity or is there a reason to prefer it?

FWIW I think this wouldn't be too hard to implement if you reordered the 
tokenType/tokenModifiers above so this part is the last step, and just copied 
the whole SemanticToken object from the back of the Result. But on the other 
hand it's not terribly important, either.

At least I think we should have a comment for the truncate/split tradeoff.



Comment at: clang-tools-extra/clangd/SemanticHighlighting.h:90
   uint32_t Modifiers = 0;
   Range R;
 

I think this deserves a comment like:

```
// This is clang's token bounds, which may span multiple lines.
// This may be split/truncated to a single line when required by LSP.
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127856

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


[PATCH] D127655: [AArch64] Define __FP_FAST_FMA[F]

2022-06-20 Thread Jolanta Jensen via Phabricator via cfe-commits
jolanta.jensen updated this revision to Diff 438344.
jolanta.jensen added a comment.

Removing an unnecessary test change from aarch64-target-features.c 
as init-aarch64.c provides enough coverage.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127655

Files:
  clang/lib/Basic/Targets/AArch64.cpp
  clang/test/Preprocessor/init-aarch64.c


Index: clang/test/Preprocessor/init-aarch64.c
===
--- clang/test/Preprocessor/init-aarch64.c
+++ clang/test/Preprocessor/init-aarch64.c
@@ -104,18 +104,20 @@
 // AARCH64-NEXT: #define __FLT_MIN_EXP__ (-125)
 // AARCH64-NEXT: #define __FLT_MIN__ 1.17549435e-38F
 // AARCH64-NEXT: #define __FLT_RADIX__ 2
+// AARCH64-NEXT: #define __FP_FAST_FMA 1
+// AARCH64-NEXT: #define __FP_FAST_FMAF 1
 // AARCH64-NEXT: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
 // AARCH64-NEXT: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
 // AARCH64-NEXT: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
 // AARCH64-NEXT: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1
 // AARCH64_CXX-NEXT: #define __GLIBCXX_BITSIZE_INT_N_0 128
 // AARCH64_CXX-NEXT: #define __GLIBCXX_TYPE_INT_N_0 __int128
-// AARCH64-NEXT: #define __INT16_C_SUFFIX__ 
+// AARCH64-NEXT: #define __INT16_C_SUFFIX__
 // AARCH64-NEXT: #define __INT16_FMTd__ "hd"
 // AARCH64-NEXT: #define __INT16_FMTi__ "hi"
 // AARCH64-NEXT: #define __INT16_MAX__ 32767
 // AARCH64-NEXT: #define __INT16_TYPE__ short
-// AARCH64-NEXT: #define __INT32_C_SUFFIX__ 
+// AARCH64-NEXT: #define __INT32_C_SUFFIX__
 // AARCH64-NEXT: #define __INT32_FMTd__ "d"
 // AARCH64-NEXT: #define __INT32_FMTi__ "i"
 // AARCH64-NEXT: #define __INT32_MAX__ 2147483647
@@ -125,7 +127,7 @@
 // AARCH64-NEXT: #define __INT64_FMTi__ "li"
 // AARCH64-NEXT: #define __INT64_MAX__ 9223372036854775807L
 // AARCH64-NEXT: #define __INT64_TYPE__ long int
-// AARCH64-NEXT: #define __INT8_C_SUFFIX__ 
+// AARCH64-NEXT: #define __INT8_C_SUFFIX__
 // AARCH64-NEXT: #define __INT8_FMTd__ "hhd"
 // AARCH64-NEXT: #define __INT8_FMTi__ "hhi"
 // AARCH64-NEXT: #define __INT8_MAX__ 127
@@ -253,7 +255,7 @@
 // AARCH64-NEXT: #define __STDC_UTF_32__ 1
 // AARCH64_C: #define __STDC_VERSION__ 201710L
 // AARCH64-NEXT: #define __STDC__ 1
-// AARCH64-NEXT: #define __UINT16_C_SUFFIX__ 
+// AARCH64-NEXT: #define __UINT16_C_SUFFIX__
 // AARCH64-NEXT: #define __UINT16_FMTX__ "hX"
 // AARCH64-NEXT: #define __UINT16_FMTo__ "ho"
 // AARCH64-NEXT: #define __UINT16_FMTu__ "hu"
@@ -274,7 +276,7 @@
 // AARCH64-NEXT: #define __UINT64_FMTx__ "lx"
 // AARCH64-NEXT: #define __UINT64_MAX__ 18446744073709551615UL
 // AARCH64-NEXT: #define __UINT64_TYPE__ long unsigned int
-// AARCH64-NEXT: #define __UINT8_C_SUFFIX__ 
+// AARCH64-NEXT: #define __UINT8_C_SUFFIX__
 // AARCH64-NEXT: #define __UINT8_FMTX__ "hhX"
 // AARCH64-NEXT: #define __UINT8_FMTo__ "hho"
 // AARCH64-NEXT: #define __UINT8_FMTu__ "hhu"
@@ -344,7 +346,7 @@
 // AARCH64-NEXT: #define __UINT_LEAST8_FMTx__ "hhx"
 // AARCH64-NEXT: #define __UINT_LEAST8_MAX__ 255
 // AARCH64-NEXT: #define __UINT_LEAST8_TYPE__ unsigned char
-// AARCH64-NEXT: #define __USER_LABEL_PREFIX__ 
+// AARCH64-NEXT: #define __USER_LABEL_PREFIX__
 // AARCH64-NEXT: #define __VERSION__ "{{.*}}"
 // AARCH64-NEXT: #define __WCHAR_MAX__ 4294967295U
 // AARCH64-NEXT: #define __WCHAR_TYPE__ unsigned int
Index: clang/lib/Basic/Targets/AArch64.cpp
===
--- clang/lib/Basic/Targets/AArch64.cpp
+++ clang/lib/Basic/Targets/AArch64.cpp
@@ -485,6 +485,10 @@
   Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4");
   Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8");
 
+  // Allow detection of fast FMA support.
+  Builder.defineMacro("__FP_FAST_FMA", "1");
+  Builder.defineMacro("__FP_FAST_FMAF", "1");
+
   if (Opts.VScaleMin && Opts.VScaleMin == Opts.VScaleMax) {
 Builder.defineMacro("__ARM_FEATURE_SVE_BITS", Twine(Opts.VScaleMin * 128));
 Builder.defineMacro("__ARM_FEATURE_SVE_VECTOR_OPERATORS");


Index: clang/test/Preprocessor/init-aarch64.c
===
--- clang/test/Preprocessor/init-aarch64.c
+++ clang/test/Preprocessor/init-aarch64.c
@@ -104,18 +104,20 @@
 // AARCH64-NEXT: #define __FLT_MIN_EXP__ (-125)
 // AARCH64-NEXT: #define __FLT_MIN__ 1.17549435e-38F
 // AARCH64-NEXT: #define __FLT_RADIX__ 2
+// AARCH64-NEXT: #define __FP_FAST_FMA 1
+// AARCH64-NEXT: #define __FP_FAST_FMAF 1
 // AARCH64-NEXT: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
 // AARCH64-NEXT: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
 // AARCH64-NEXT: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
 // AARCH64-NEXT: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1
 // AARCH64_CXX-NEXT: #define __GLIBCXX_BITSIZE_INT_N_0 128
 // AARCH64_CXX-NEXT: #define __GLIBCXX_TYPE_INT_N_0 __int128
-// AARCH64-NEXT: #define __INT16_C_SUFFIX__ 
+// AARCH64-NEXT: #define 

[PATCH] D128043: [flang][driver] Add support for `-O{0|1|2|3}`

2022-06-20 Thread Peixin Qiao via Phabricator via cfe-commits
peixin added a comment.

The CI failed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128043

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


[PATCH] D127812: [AArch64] Function multiversioning support added.

2022-06-20 Thread Pavel Iliin via Phabricator via cfe-commits
ilinpv added inline comments.



Comment at: clang/docs/ClangCommandLineReference.rst:1086
 
+.. option:: -mno-fmv
+

xbolva00 wrote:
> ilinpv wrote:
> > MaskRay wrote:
> > > This file is auto-generated. Don't touch it.
> > It looked out of sync with options td files:
> > 
> > ```
> > +.. option:: -gen-reproducer=, -fno-crash-diagnostics (equivalent to 
> > -gen-reproducer=off)
> > +
> > +Emit reproducer on (option: off, crash (default), error, always)
> > +
> > 
> > +.. option:: -print-diagnostic-options, --print-diagnostic-options
> > +
> > +Print all of Clang's warning options
> > +
> > 
> > +.. option:: -fdriver-only
> > +
> > +Only run the driver.
> > +
> > 
> > ...
> > ```
> But it needs to be manually autogenerated..
Done https://reviews.llvm.org/D128116, thanks to @MaskRay 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127812

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


[PATCH] D128183: [clang][dataflow] Extend flow condition in the body of a do/while loop

2022-06-20 Thread Stanislav Gatev via Phabricator via cfe-commits
sgatev created this revision.
sgatev added reviewers: ymandel, xazax.hun, gribozavr2.
Herald added subscribers: martong, tschuett, rnkovacs.
Herald added a project: All.
sgatev requested review of this revision.
Herald added a project: clang.

Extend flow condition in the body of a do/while loop.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128183

Files:
  clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
  clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
  clang/unittests/Analysis/FlowSensitive/TransferTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -3628,25 +3628,77 @@
 void target(bool Foo) {
   while (Foo) {
 (void)0;
-// [[while_branch]]
+// [[loop_body]]
   }
+  (void)0;
+  // [[after_loop]]
 }
   )";
-  runDataflow(Code,
-  [](llvm::ArrayRef<
- std::pair>>
- Results,
- ASTContext ) {
-ASSERT_THAT(Results, ElementsAre(Pair("while_branch", _)));
-const Environment  = Results[0].second.Env;
+  runDataflow(
+  Code, [](llvm::ArrayRef<
+   std::pair>>
+   Results,
+   ASTContext ) {
+ASSERT_THAT(Results,
+ElementsAre(Pair("after_loop", _), Pair("loop_body", _)));
+const Environment  = Results[1].second.Env;
+const Environment  = Results[0].second.Env;
 
-const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo");
-ASSERT_THAT(FooDecl, NotNull());
+const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo");
+ASSERT_THAT(FooDecl, NotNull());
 
-BoolValue  =
-*cast(Env.getValue(*FooDecl, SkipPast::None));
-EXPECT_TRUE(Env.flowConditionImplies(FooVal));
-  });
+BoolValue  =
+*cast(LoopBodyEnv.getValue(*FooDecl, SkipPast::None));
+EXPECT_TRUE(LoopBodyEnv.flowConditionImplies(LoopBodyFooVal));
+
+BoolValue  =
+*cast(AfterLoopEnv.getValue(*FooDecl, SkipPast::None));
+EXPECT_TRUE(AfterLoopEnv.flowConditionImplies(
+AfterLoopEnv.makeNot(AfterLoopFooVal)));
+  });
+}
+
+TEST_F(TransferTest, DoWhileStmtBranchExtendsFlowCondition) {
+  std::string Code = R"(
+void target(bool Foo) {
+  bool Bar = true;
+  do {
+(void)0;
+// [[loop_body]]
+Bar = false;
+  } while (Foo);
+  (void)0;
+  // [[after_loop]]
+}
+  )";
+  runDataflow(
+  Code, [](llvm::ArrayRef<
+   std::pair>>
+   Results,
+   ASTContext ) {
+ASSERT_THAT(Results,
+ElementsAre(Pair("after_loop", _), Pair("loop_body", _)));
+const Environment  = Results[1].second.Env;
+const Environment  = Results[0].second.Env;
+
+const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo");
+ASSERT_THAT(FooDecl, NotNull());
+
+const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar");
+ASSERT_THAT(BarDecl, NotNull());
+
+BoolValue  =
+*cast(LoopBodyEnv.getValue(*FooDecl, SkipPast::None));
+BoolValue  =
+*cast(LoopBodyEnv.getValue(*BarDecl, SkipPast::None));
+EXPECT_TRUE(LoopBodyEnv.flowConditionImplies(
+LoopBodyEnv.makeOr(LoopBodyBarVal, LoopBodyFooVal)));
+
+BoolValue  =
+*cast(AfterLoopEnv.getValue(*FooDecl, SkipPast::None));
+EXPECT_TRUE(AfterLoopEnv.flowConditionImplies(
+AfterLoopEnv.makeNot(AfterLoopFooVal)));
+  });
 }
 
 TEST_F(TransferTest, ForStmtBranchExtendsFlowCondition) {
@@ -3654,25 +3706,34 @@
 void target(bool Foo) {
   for (; Foo;) {
 (void)0;
-// [[for_branch]]
+// [[loop_body]]
   }
+  (void)0;
+  // [[after_loop]]
 }
   )";
-  runDataflow(Code,
-  [](llvm::ArrayRef<
- std::pair>>
- Results,
- ASTContext ) {
-ASSERT_THAT(Results, ElementsAre(Pair("for_branch", _)));
-const Environment  = Results[0].second.Env;
+  runDataflow(
+  Code, [](llvm::ArrayRef<
+   std::pair>>
+   Results,
+   ASTContext ) {
+ASSERT_THAT(Results,
+ElementsAre(Pair("after_loop", _), Pair("loop_body", _)));
+const Environment  = Results[1].second.Env;
+const Environment  = Results[0].second.Env;
 
-const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo");
-ASSERT_THAT(FooDecl, NotNull());
+const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo");
+

[PATCH] D128182: [NFC] Switch FloatModeKind enum class to use bitmask enums

2022-06-20 Thread Jolanta Jensen via Phabricator via cfe-commits
jolanta.jensen created this revision.
Herald added a project: All.
jolanta.jensen requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Using bitmask enums simplifies and clarifies the code.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128182

Files:
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/Basic/Targets/X86.h


Index: clang/lib/Basic/Targets/X86.h
===
--- clang/lib/Basic/Targets/X86.h
+++ clang/lib/Basic/Targets/X86.h
@@ -14,6 +14,7 @@
 #define LLVM_CLANG_LIB_BASIC_TARGETS_X86_H
 
 #include "OSTargets.h"
+#include "clang/Basic/BitmaskEnum.h"
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Basic/TargetOptions.h"
 #include "llvm/ADT/Triple.h"
@@ -419,8 +420,8 @@
 
 // Use fpret for all types.
 RealTypeUsesObjCFPRetMask =
-((1 << (int)FloatModeKind::Float) | (1 << (int)FloatModeKind::Double) |
- (1 << (int)FloatModeKind::LongDouble));
+(int)(FloatModeKind::Float | FloatModeKind::Double |
+  FloatModeKind::LongDouble);
 
 // x86-32 has atomics up to 8 bytes
 MaxAtomicPromoteWidth = 64;
@@ -699,7 +700,7 @@
 "64-i64:64-f80:128-n8:16:32:64-S128");
 
 // Use fpret only for long double.
-RealTypeUsesObjCFPRetMask = (1 << (int)FloatModeKind::LongDouble);
+RealTypeUsesObjCFPRetMask = (int)FloatModeKind::LongDouble;
 
 // Use fp2ret for _Complex long double.
 ComplexLongDoubleUsesFP2Ret = true;
Index: clang/include/clang/Basic/TargetInfo.h
===
--- clang/include/clang/Basic/TargetInfo.h
+++ clang/include/clang/Basic/TargetInfo.h
@@ -15,6 +15,7 @@
 #define LLVM_CLANG_BASIC_TARGETINFO_H
 
 #include "clang/Basic/AddressSpaces.h"
+#include "clang/Basic/BitmaskEnum.h"
 #include "clang/Basic/CodeGenOptions.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/LangOptions.h"
@@ -52,14 +53,14 @@
 namespace Builtin { struct Info; }
 
 enum class FloatModeKind {
-  NoFloat = 255,
-  Half = 0,
-  Float,
-  Double,
-  LongDouble,
-  Float128,
-  Ibm128,
-  Last = Ibm128
+  NoFloat = 0,
+  Half = 1 << 0,
+  Float = 1 << 1,
+  Double = 1 << 2,
+  LongDouble = 1 << 3,
+  Float128 = 1 << 4,
+  Ibm128 = 1 << 5,
+  LLVM_MARK_AS_BITMASK_ENUM(Ibm128)
 };
 
 /// Fields controlling how types are laid out in memory; these may need to
@@ -221,7 +222,8 @@
   mutable VersionTuple PlatformMinVersion;
 
   unsigned HasAlignMac68kSupport : 1;
-  unsigned RealTypeUsesObjCFPRetMask : (int)FloatModeKind::Last + 1;
+  unsigned RealTypeUsesObjCFPRetMask
+  : (int)FloatModeKind::LLVM_BITMASK_LARGEST_ENUMERATOR;
   unsigned ComplexLongDoubleUsesFP2Ret : 1;
 
   unsigned HasBuiltinMSVaList : 1;
@@ -890,9 +892,8 @@
   /// Check whether the given real type should use the "fpret" flavor of
   /// Objective-C message passing on this target.
   bool useObjCFPRetForRealType(FloatModeKind T) const {
-assert(T <= FloatModeKind::Last &&
-   "T value is larger than RealTypeUsesObjCFPRetMask can handle");
-return RealTypeUsesObjCFPRetMask & (1 << (int)T);
+int val = llvm::BitmaskEnumDetail::Underlying(T);
+return RealTypeUsesObjCFPRetMask & val;
   }
 
   /// Check whether _Complex long double should use the "fp2ret" flavor


Index: clang/lib/Basic/Targets/X86.h
===
--- clang/lib/Basic/Targets/X86.h
+++ clang/lib/Basic/Targets/X86.h
@@ -14,6 +14,7 @@
 #define LLVM_CLANG_LIB_BASIC_TARGETS_X86_H
 
 #include "OSTargets.h"
+#include "clang/Basic/BitmaskEnum.h"
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Basic/TargetOptions.h"
 #include "llvm/ADT/Triple.h"
@@ -419,8 +420,8 @@
 
 // Use fpret for all types.
 RealTypeUsesObjCFPRetMask =
-((1 << (int)FloatModeKind::Float) | (1 << (int)FloatModeKind::Double) |
- (1 << (int)FloatModeKind::LongDouble));
+(int)(FloatModeKind::Float | FloatModeKind::Double |
+  FloatModeKind::LongDouble);
 
 // x86-32 has atomics up to 8 bytes
 MaxAtomicPromoteWidth = 64;
@@ -699,7 +700,7 @@
 "64-i64:64-f80:128-n8:16:32:64-S128");
 
 // Use fpret only for long double.
-RealTypeUsesObjCFPRetMask = (1 << (int)FloatModeKind::LongDouble);
+RealTypeUsesObjCFPRetMask = (int)FloatModeKind::LongDouble;
 
 // Use fp2ret for _Complex long double.
 ComplexLongDoubleUsesFP2Ret = true;
Index: clang/include/clang/Basic/TargetInfo.h
===
--- clang/include/clang/Basic/TargetInfo.h
+++ clang/include/clang/Basic/TargetInfo.h
@@ -15,6 +15,7 @@
 #define LLVM_CLANG_BASIC_TARGETINFO_H
 
 #include "clang/Basic/AddressSpaces.h"
+#include "clang/Basic/BitmaskEnum.h"
 #include "clang/Basic/CodeGenOptions.h"
 #include "clang/Basic/LLVM.h"
 #include 

[PATCH] D128120: [Clang][VE] Add missing intrinsics

2022-06-20 Thread Erich Focht via Phabricator via cfe-commits
efocht accepted this revision.
efocht added a comment.
This revision is now accepted and ready to land.

Looks ok for me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128120

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


[PATCH] D127643: [Static Analyzer] Structured bindings to data members

2022-06-20 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

I missed this commit because it was not tagged by "[analyzer]".
What is the community preference about tagging CSA commits?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127643

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


[PATCH] D128166: ManagedStatic: Destroy from destructor

2022-06-20 Thread Nicolai Hähnle via Phabricator via cfe-commits
nhaehnle created this revision.
Herald added a reviewer: deadalnix.
Herald added subscribers: bzcheeseman, ayermolo, sdasgup3, wenzhicui, wrengr, 
dcaballe, cota, teijeong, rdzhabarov, tatianashp, msifontes, jurahul, Kayjukh, 
grosul1, jvesely, Joonsoo, liufengdb, aartbik, mgester, arpith-jacob, 
antiagainst, shauheen, rriddle, mehdi_amini, mstorsjo, hiraditya, mgorny.
Herald added a reviewer: bollu.
Herald added a reviewer: MaskRay.
Herald added a reviewer: rafauler.
Herald added a reviewer: Amir.
Herald added a reviewer: maksfb.
Herald added a project: All.
nhaehnle requested review of this revision.
Herald added subscribers: lldb-commits, cfe-commits, yota9, StephenFan, 
stephenneuendorffer, nicolasvasilache.
Herald added projects: clang, LLDB, MLIR, LLVM.

This allows LLVM to be safely loaded and unloaded as a shared library
without leaking memory:

Consider the scenario where shared library Foo links against LLVM as
a shared library, and Foo may be loaded and unloaded multiple times
in the same process. Should Foo call llvm_shutdown or not? If it does
not, and LLVM is also loaded and unloaded multiple times, then
memory is leaked. If it does call llvm_shutdown and LLVM *isn't*
also unloaded, the state of LLVM's global statics is corrupted because
while the ManagedStatics may be re-initialized, *other* global
constructors aren't re-run.

Keep in mind that Foo itself may use ManagedStatic. If Foo is unloaded
but LLVM isn't, those statics should be destroyed.

The safe solution is to skip llvm_shutdown() altogether and destroy
managed statics from their destructor.

LLD relies on being able to call _exit() and still get some side-effects
of managed static destructors. We make this expectation much more
explicit.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128166

Files:
  bolt/tools/driver/llvm-bolt.cpp
  bolt/tools/merge-fdata/merge-fdata.cpp
  clang/include/clang/Frontend/CompilerInstance.h
  clang/tools/clang-repl/ClangRepl.cpp
  clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
  clang/unittests/Interpreter/InterpreterTest.cpp
  clang/utils/TableGen/TableGen.cpp
  libclc/utils/prepare-builtins.cpp
  lld/Common/ErrorHandler.cpp
  lldb/tools/driver/Driver.cpp
  lldb/tools/lldb-test/lldb-test.cpp
  lldb/unittests/Utility/LogTest.cpp
  lldb/utils/TableGen/LLDBTableGen.cpp
  llvm/docs/ProgrammersManual.rst
  llvm/examples/BrainF/BrainFDriver.cpp
  llvm/examples/HowToUseJIT/HowToUseJIT.cpp
  llvm/include/llvm-c/Core.h
  llvm/include/llvm/ADT/Statistic.h
  llvm/include/llvm/PassRegistry.h
  llvm/include/llvm/Support/DynamicLibrary.h
  llvm/include/llvm/Support/FastShutdown.h
  llvm/include/llvm/Support/InitLLVM.h
  llvm/include/llvm/Support/ManagedStatic.h
  llvm/lib/IR/Core.cpp
  llvm/lib/IR/Pass.cpp
  llvm/lib/IR/PassRegistry.cpp
  llvm/lib/Support/CMakeLists.txt
  llvm/lib/Support/FastShutdown.cpp
  llvm/lib/Support/InitLLVM.cpp
  llvm/lib/Support/ManagedStatic.cpp
  llvm/lib/Support/Parallel.cpp
  llvm/lib/Support/Statistic.cpp
  llvm/lib/Support/Unix/DynamicLibrary.inc
  llvm/lib/Support/Unix/Signals.inc
  llvm/lib/Support/Windows/DynamicLibrary.inc
  llvm/tools/gold/gold-plugin.cpp
  llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp
  llvm/unittests/ExecutionEngine/ExecutionEngineTest.cpp
  llvm/unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp
  llvm/utils/KillTheDoctor/KillTheDoctor.cpp
  mlir/tools/mlir-vulkan-runner/mlir-vulkan-runner.cpp
  polly/lib/External/isl/interface/extract_interface.cc

Index: polly/lib/External/isl/interface/extract_interface.cc
===
--- polly/lib/External/isl/interface/extract_interface.cc
+++ polly/lib/External/isl/interface/extract_interface.cc
@@ -587,7 +587,6 @@
 
 	delete sema;
 	delete Clang;
-	llvm::llvm_shutdown();
 
 	if (Diags.hasErrorOccurred())
 		return EXIT_FAILURE;
Index: mlir/tools/mlir-vulkan-runner/mlir-vulkan-runner.cpp
===
--- mlir/tools/mlir-vulkan-runner/mlir-vulkan-runner.cpp
+++ mlir/tools/mlir-vulkan-runner/mlir-vulkan-runner.cpp
@@ -61,7 +61,6 @@
 }
 
 int main(int argc, char **argv) {
-  llvm::llvm_shutdown_obj x;
   registerPassManagerCLOptions();
 
   llvm::InitLLVM y(argc, argv);
Index: llvm/utils/KillTheDoctor/KillTheDoctor.cpp
===
--- llvm/utils/KillTheDoctor/KillTheDoctor.cpp
+++ llvm/utils/KillTheDoctor/KillTheDoctor.cpp
@@ -297,7 +297,6 @@
   // Print a stack trace if we signal out.
   sys::PrintStackTraceOnErrorSignal(argv[0]);
   PrettyStackTraceProgram X(argc, argv);
-  llvm_shutdown_obj Y;  // Call llvm_shutdown() on exit.
 
   ToolName = argv[0];
 
Index: llvm/unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp
===
--- llvm/unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp
+++ 

[PATCH] D128048: Add a new clang option "-ftime-trace-path"

2022-06-20 Thread dongjunduo via Phabricator via cfe-commits
dongjunduo added a comment.

In D128048#3591829 , @Whitney wrote:

> Can you please add some test cases?

I have found that new-option unit tests are not included in `clang/test` or 
`clang/unit-tests`. Could u tell me where I should write the test cases?




Comment at: clang/tools/driver/cc1_main.cpp:257
   if (llvm::timeTraceProfilerEnabled()) {
-SmallString<128> Path(Clang->getFrontendOpts().OutputFile);
-llvm::sys::path::replace_extension(Path, "json");
+SmallString<128> Path(Clang->getFrontendOpts().TimeTracePath);
+
Path.append(llvm::sys::path::filename(Clang->getFrontendOpts().OutputFile));

Whitney wrote:
> What happens when TimeTracePath is not given? Ideally the originally behavior 
> is not changed. 
The originally behavior has been restored : ) 

Time-trace file "*.json" may be saved by following the origin logic if 
"-ftime-trace-path" is not be specified.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128048

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


[PATCH] D128048: Add a new clang option "-ftime-trace-path"

2022-06-20 Thread dongjunduo via Phabricator via cfe-commits
dongjunduo updated this revision to Diff 438303.
dongjunduo marked an inline comment as done.
dongjunduo added a comment.

[Clang] change unclear help text pf "-ftime-trace-path"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128048

Files:
  clang/include/clang/Driver/Options.td
  clang/include/clang/Frontend/FrontendOptions.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/tools/driver/cc1_main.cpp


Index: clang/tools/driver/cc1_main.cpp
===
--- clang/tools/driver/cc1_main.cpp
+++ clang/tools/driver/cc1_main.cpp
@@ -255,7 +255,16 @@
 
   if (llvm::timeTraceProfilerEnabled()) {
 SmallString<128> Path(Clang->getFrontendOpts().OutputFile);
-llvm::sys::path::replace_extension(Path, "json");
+if (Clang->getFrontendOpts().TimeTracePath.empty()) {
+  // replace the suffix to '.json' directly
+  llvm::sys::path::replace_extension(Path, "json");
+} else {
+  // change path prefix to the aim path, then add suffix '.json'
+  Path.assign(Clang->getFrontendOpts().TimeTracePath);
+  Path.append(
+  llvm::sys::path::filename(Clang->getFrontendOpts().OutputFile));
+  Path.append(".json");
+}
 if (auto profilerOutput = Clang->createOutputFile(
 Path.str(), /*Binary=*/false, /*RemoveFileOnSignal=*/false,
 /*useTemporary=*/false)) {
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6183,6 +6183,7 @@
   Args.AddLastArg(CmdArgs, options::OPT_ftime_report_EQ);
   Args.AddLastArg(CmdArgs, options::OPT_ftime_trace);
   Args.AddLastArg(CmdArgs, options::OPT_ftime_trace_granularity_EQ);
+  Args.AddLastArg(CmdArgs, options::OPT_ftime_trace_path);
   Args.AddLastArg(CmdArgs, options::OPT_ftrapv);
   Args.AddLastArg(CmdArgs, options::OPT_malign_double);
   Args.AddLastArg(CmdArgs, options::OPT_fno_temp_file);
Index: clang/include/clang/Frontend/FrontendOptions.h
===
--- clang/include/clang/Frontend/FrontendOptions.h
+++ clang/include/clang/Frontend/FrontendOptions.h
@@ -499,6 +499,9 @@
   /// Minimum time granularity (in microseconds) traced by time profiler.
   unsigned TimeTraceGranularity;
 
+  /// Path which stores the output files of time profiler.
+  std::string TimeTracePath;
+
 public:
   FrontendOptions()
   : DisableFree(false), RelocatablePCH(false), ShowHelp(false),
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2828,6 +2828,10 @@
   HelpText<"Minimum time granularity (in microseconds) traced by time 
profiler">,
   Flags<[CC1Option, CoreOption]>,
   MarshallingInfoInt, "500u">;
+def ftime_trace_path : Joined<["-"], "ftime-trace-path=">, Group,
+  HelpText<"Path which specifies the output files for -ftime-trace">,
+  Flags<[CC1Option, CoreOption]>,
+  MarshallingInfoString>;
 def fproc_stat_report : Joined<["-"], "fproc-stat-report">, Group,
   HelpText<"Print subprocess statistics">;
 def fproc_stat_report_EQ : Joined<["-"], "fproc-stat-report=">, Group,


Index: clang/tools/driver/cc1_main.cpp
===
--- clang/tools/driver/cc1_main.cpp
+++ clang/tools/driver/cc1_main.cpp
@@ -255,7 +255,16 @@
 
   if (llvm::timeTraceProfilerEnabled()) {
 SmallString<128> Path(Clang->getFrontendOpts().OutputFile);
-llvm::sys::path::replace_extension(Path, "json");
+if (Clang->getFrontendOpts().TimeTracePath.empty()) {
+  // replace the suffix to '.json' directly
+  llvm::sys::path::replace_extension(Path, "json");
+} else {
+  // change path prefix to the aim path, then add suffix '.json'
+  Path.assign(Clang->getFrontendOpts().TimeTracePath);
+  Path.append(
+  llvm::sys::path::filename(Clang->getFrontendOpts().OutputFile));
+  Path.append(".json");
+}
 if (auto profilerOutput = Clang->createOutputFile(
 Path.str(), /*Binary=*/false, /*RemoveFileOnSignal=*/false,
 /*useTemporary=*/false)) {
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6183,6 +6183,7 @@
   Args.AddLastArg(CmdArgs, options::OPT_ftime_report_EQ);
   Args.AddLastArg(CmdArgs, options::OPT_ftime_trace);
   Args.AddLastArg(CmdArgs, options::OPT_ftime_trace_granularity_EQ);
+  Args.AddLastArg(CmdArgs, options::OPT_ftime_trace_path);
   Args.AddLastArg(CmdArgs, options::OPT_ftrapv);
   Args.AddLastArg(CmdArgs, options::OPT_malign_double);
   Args.AddLastArg(CmdArgs, 

[PATCH] D127873: [clang-format] Fix misplacemnt of `*` in declaration of pointer to struct

2022-06-20 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks accepted this revision.
HazardyKnusperkeks added inline comments.



Comment at: clang/lib/Format/TokenAnnotator.cpp:2328
+}
+
 if (PrevToken->Tok.isLiteral() ||

MyDeveloperDay wrote:
> Thank you I wish more of the clauses were commented like this
+1



Comment at: clang/unittests/Format/FormatTest.cpp:10439
+   Style);
+  verifyFormat("union {\n"
+   "}* ptr;",

Bonus points for the union. It often gets forgotten.


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

https://reviews.llvm.org/D127873

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


[PATCH] D97204: [RFC] Clang 64-bit source locations

2022-06-20 Thread Sam Elliott via Phabricator via cfe-commits
lenary added a comment.
Herald added a project: All.

Some of this patch set has been broken by https://reviews.llvm.org/D125403 and 
https://reviews.llvm.org/D125952 - which are size optimisations for PCH 
encodings of source locations. The biggest issue is new line 90 of 
`clang/include/clang/Serialization/SourceLocationEncoding.h` in the first patch.

I see the mini-patches in @simon_tatham's last comment have not unblocked this 
patch as much as was hoped, but maybe this comment can act as a reverse-ping?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97204

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


[clang] 8c3fa31 - [OpenCL][TableGen] Fix type extension guard emission

2022-06-20 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2022-06-20T10:07:34+01:00
New Revision: 8c3fa31701c4b874138c52266e7ab96818092f47

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

LOG: [OpenCL][TableGen] Fix type extension guard emission

For certain cases (such as for the double subtype of AGenType), the
OpenCLBuiltinFileEmitterBase would not emit the extension #if-guard.
Fix that by looking at the extension of the actual type instead of the
argument type (which could be a GenType that does not carry any
extension information).

Added: 


Modified: 
clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp

Removed: 




diff  --git a/clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp 
b/clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
index dca9970444a73..cddbd7b17c5f6 100644
--- a/clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
+++ b/clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
@@ -1082,7 +1082,7 @@ void OpenCLBuiltinFileEmitterBase::expandTypesInSignature(
 // If the type requires an extension, add a TypeExtMap entry mapping
 // the full type name to the extension.
 StringRef Ext =
-Arg->getValueAsDef("Extension")->getValueAsString("ExtName");
+Type->getValueAsDef("Extension")->getValueAsString("ExtName");
 if (!Ext.empty() && TypeExtMap.find(FullType) == TypeExtMap.end()) {
   TypeExtMap.insert({FullType, Ext});
 }



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


[libunwind] 8df257a - [libunwind] Ensure test/libunwind_01.pass is not completely inlined

2022-06-20 Thread Alex Richardson via cfe-commits

Author: Alex Richardson
Date: 2022-06-20T09:05:49Z
New Revision: 8df257a6d0b0b32e05e89874eff4c8ddd2a2a2a9

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

LOG: [libunwind] Ensure test/libunwind_01.pass is not completely inlined

By adding noinline and calling fprintf before returning we ensure that
every function will have a distinct call frame and that the return address
will always be saved instead of saving the target in main as the result.

Before this change all backtraces were always backtrace -> main -> _start,
i.e. always exactly three entries. This happenend because all calls were
inlined in main() and the test just happenend to pass because there is at
least _start before main.

I found this while fixing some bugs in libunwind for CHERI and noticed that
the test was passing even though the code was completely broken.

Obtained from: https://github.com/CTSRD-CHERI/llvm-project

Reviewed By: #libunwind, ldionne, MaskRay

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

Added: 


Modified: 
libunwind/test/libunwind_01.pass.cpp

Removed: 




diff  --git a/libunwind/test/libunwind_01.pass.cpp 
b/libunwind/test/libunwind_01.pass.cpp
index bbfaffd153cc2..4661ac9df8219 100644
--- a/libunwind/test/libunwind_01.pass.cpp
+++ b/libunwind/test/libunwind_01.pass.cpp
@@ -15,6 +15,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 void backtrace(int lower_bound) {
@@ -24,9 +25,17 @@ void backtrace(int lower_bound) {
   unw_cursor_t cursor;
   unw_init_local(, );
 
+  char buffer[1024];
+  unw_word_t offset = 0;
+
   int n = 0;
   do {
-++n;
+n++;
+if (unw_get_proc_name(, buffer, sizeof(buffer), ) == 0) {
+  fprintf(stderr, "Frame %d: %s+%p\n", n, buffer, (void*)offset);
+} else {
+  fprintf(stderr, "Frame %d: Could not get name for cursor\n", n);
+}
 if (n > 100) {
   abort();
 }
@@ -37,18 +46,24 @@ void backtrace(int lower_bound) {
   }
 }
 
-void test1(int i) {
+__attribute__((noinline)) void test1(int i) {
+  fprintf(stderr, "starting %s\n", __func__);
   backtrace(i);
+  fprintf(stderr, "finished %s\n", __func__); // ensure return address is saved
 }
 
-void test2(int i, int j) {
+__attribute__((noinline)) void test2(int i, int j) {
+  fprintf(stderr, "starting %s\n", __func__);
   backtrace(i);
   test1(j);
+  fprintf(stderr, "finished %s\n", __func__); // ensure return address is saved
 }
 
-void test3(int i, int j, int k) {
+__attribute__((noinline)) void test3(int i, int j, int k) {
+  fprintf(stderr, "starting %s\n", __func__);
   backtrace(i);
   test2(j, k);
+  fprintf(stderr, "finished %s\n", __func__); // ensure return address is saved
 }
 
 void test_no_info() {
@@ -142,9 +157,9 @@ void test_fpreg_get_set() {}
 #endif
 
 int main(int, char**) {
-  test1(1);
-  test2(1, 2);
-  test3(1, 2, 3);
+  test1(3);
+  test2(3, 4);
+  test3(3, 4, 5);
   test_no_info();
   test_reg_names();
   test_reg_get_set();



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


[PATCH] D125349: [clang][sema] Generate builtin operator overloads for (volatile) _Atomic types

2022-06-20 Thread Jan Svoboda via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb02d970b4335: [clang][sema] Generate builtin operator 
overloads for (volatile) _Atomic types (authored by jansvoboda11).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125349

Files:
  clang/include/clang/AST/Type.h
  clang/lib/Sema/SemaOverload.cpp
  clang/test/CodeGenCXX/atomic-builtin-compound-assignment-overload.cpp
  clang/test/SemaCXX/atomic-builtin-compound-assignment-overload.cpp

Index: clang/test/SemaCXX/atomic-builtin-compound-assignment-overload.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/atomic-builtin-compound-assignment-overload.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -std=gnu++98 -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+_Atomic unsigned an_atomic_uint;
+
+enum { an_enum_value = 1 };
+
+void enum1() { an_atomic_uint += an_enum_value; }
+
+void enum2() { an_atomic_uint |= an_enum_value; }
+
+volatile _Atomic unsigned an_volatile_atomic_uint;
+
+void enum3() { an_volatile_atomic_uint += an_enum_value; }
+
+void enum4() { an_volatile_atomic_uint |= an_enum_value; }
Index: clang/test/CodeGenCXX/atomic-builtin-compound-assignment-overload.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/atomic-builtin-compound-assignment-overload.cpp
@@ -0,0 +1,55 @@
+// RUN: %clang_cc1 -std=gnu++11 -emit-llvm -triple=x86_64-linux-gnu -o - %s | FileCheck %s
+
+_Atomic unsigned an_atomic_uint;
+
+enum { an_enum_value = 1 };
+
+// CHECK-LABEL: define {{.*}}void @_Z5enum1v()
+void enum1() {
+  an_atomic_uint += an_enum_value;
+  // CHECK: atomicrmw add ptr
+}
+
+// CHECK-LABEL: define {{.*}}void @_Z5enum2v()
+void enum2() {
+  an_atomic_uint |= an_enum_value;
+  // CHECK: atomicrmw or ptr
+}
+
+// CHECK-LABEL: define {{.*}}void @_Z5enum3RU7_Atomicj({{.*}})
+void enum3(_Atomic unsigned _atomic_uint_param) {
+  an_atomic_uint_param += an_enum_value;
+  // CHECK: atomicrmw add ptr
+}
+
+// CHECK-LABEL: define {{.*}}void @_Z5enum4RU7_Atomicj({{.*}})
+void enum4(_Atomic unsigned _atomic_uint_param) {
+  an_atomic_uint_param |= an_enum_value;
+  // CHECK: atomicrmw or ptr
+}
+
+volatile _Atomic unsigned an_volatile_atomic_uint;
+
+// CHECK-LABEL: define {{.*}}void @_Z5enum5v()
+void enum5() {
+  an_volatile_atomic_uint += an_enum_value;
+  // CHECK: atomicrmw add ptr
+}
+
+// CHECK-LABEL: define {{.*}}void @_Z5enum6v()
+void enum6() {
+  an_volatile_atomic_uint |= an_enum_value;
+  // CHECK: atomicrmw or ptr
+}
+
+// CHECK-LABEL: define {{.*}}void @_Z5enum7RVU7_Atomicj({{.*}})
+void enum7(volatile _Atomic unsigned _volatile_atomic_uint_param) {
+  an_volatile_atomic_uint_param += an_enum_value;
+  // CHECK: atomicrmw add ptr
+}
+
+// CHECK-LABEL: define {{.*}}void @_Z5enum8RVU7_Atomicj({{.*}})
+void enum8(volatile _Atomic unsigned _volatile_atomic_uint_param) {
+  an_volatile_atomic_uint_param |= an_enum_value;
+  // CHECK: atomicrmw or ptr
+}
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -8200,6 +8200,49 @@
 return VRQuals;
 }
 
+// Note: We're currently only handling qualifiers that are meaningful for the
+// LHS of compound assignment overloading.
+static void forAllQualifierCombinationsImpl(
+QualifiersAndAtomic Available, QualifiersAndAtomic Applied,
+llvm::function_ref Callback) {
+  // _Atomic
+  if (Available.hasAtomic()) {
+Available.removeAtomic();
+forAllQualifierCombinationsImpl(Available, Applied.withAtomic(), Callback);
+forAllQualifierCombinationsImpl(Available, Applied, Callback);
+return;
+  }
+
+  // volatile
+  if (Available.hasVolatile()) {
+Available.removeVolatile();
+assert(!Applied.hasVolatile());
+forAllQualifierCombinationsImpl(Available, Applied.withVolatile(),
+Callback);
+forAllQualifierCombinationsImpl(Available, Applied, Callback);
+return;
+  }
+
+  Callback(Applied);
+}
+
+static void forAllQualifierCombinations(
+QualifiersAndAtomic Quals,
+llvm::function_ref Callback) {
+  return forAllQualifierCombinationsImpl(Quals, QualifiersAndAtomic(),
+ Callback);
+}
+
+static QualType makeQualifiedLValueReferenceType(QualType Base,
+ QualifiersAndAtomic Quals,
+ Sema ) {
+  if (Quals.hasAtomic())
+Base = S.Context.getAtomicType(Base);
+  if (Quals.hasVolatile())
+Base = S.Context.getVolatileType(Base);
+  return S.Context.getLValueReferenceType(Base);
+}
+
 namespace {
 
 /// Helper class to manage the addition of builtin operator overload
@@ -8210,7 +8253,7 

[clang] b02d970 - [clang][sema] Generate builtin operator overloads for (volatile) _Atomic types

2022-06-20 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2022-06-20T11:03:29+02:00
New Revision: b02d970b4335561940dd584f6e6497ab684c788d

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

LOG: [clang][sema] Generate builtin operator overloads for (volatile) _Atomic 
types

We observed a failed assert in overloaded compound-assignment operator 
resolution:

```
Assertion failed: (Result.isInvalid() && "C++ binary operator overloading is 
missing candidates!"), function CreateOverloadedBinOp, file SemaOverload.cpp, 
line 13944.
...
frame #4: clang` clang::Sema::CreateOverloadedBinOp(..., Opc=BO_OrAssign, ..., 
PerformADL=true, AllowRewrittenCandidates=false, ...) at SemaOverload.cpp:13943
frame #5: clang` BuildOverloadedBinOp(..., Opc=BO_OrAssign, ...) at 
SemaExpr.cpp:15228
frame #6: clang` clang::Sema::BuildBinOp(..., Opc=BO_OrAssign, ...) at 
SemaExpr.cpp:15330
frame #7: clang` clang::Sema::ActOnBinOp(..., Kind=pipeequal, ...) at 
SemaExpr.cpp:15187
frame #8: clang` clang::Parser::ParseRHSOfBinaryExpression(..., 
MinPrec=Assignment) at ParseExpr.cpp:629
frame #9: clang` clang::Parser::ParseAssignmentExpression(..., 
isTypeCast=NotTypeCast) at ParseExpr.cpp:176
frame #10: clang` clang::Parser::ParseExpression(... isTypeCast=NotTypeCast) at 
ParseExpr.cpp:124
frame #11: clang` clang::Parser::ParseExprStatement(...) at ParseStmt.cpp:464
```

A simple reproducer is:

```
_Atomic unsigned an_atomic_uint;

enum { an_enum_value = 1 };

void enum1() { an_atomic_uint += an_enum_value; }
```

This patch fixes the issue by generating builtin operator overloads for 
(volatile) _Atomic types.

Reviewed By: aaron.ballman

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

Added: 
clang/test/CodeGenCXX/atomic-builtin-compound-assignment-overload.cpp
clang/test/SemaCXX/atomic-builtin-compound-assignment-overload.cpp

Modified: 
clang/include/clang/AST/Type.h
clang/lib/Sema/SemaOverload.cpp

Removed: 




diff  --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 5784839f4f961..1f8086301f66e 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -265,16 +265,31 @@ class Qualifiers {
   bool hasOnlyConst() const { return Mask == Const; }
   void removeConst() { Mask &= ~Const; }
   void addConst() { Mask |= Const; }
+  Qualifiers withConst() const {
+Qualifiers Qs = *this;
+Qs.addConst();
+return Qs;
+  }
 
   bool hasVolatile() const { return Mask & Volatile; }
   bool hasOnlyVolatile() const { return Mask == Volatile; }
   void removeVolatile() { Mask &= ~Volatile; }
   void addVolatile() { Mask |= Volatile; }
+  Qualifiers withVolatile() const {
+Qualifiers Qs = *this;
+Qs.addVolatile();
+return Qs;
+  }
 
   bool hasRestrict() const { return Mask & Restrict; }
   bool hasOnlyRestrict() const { return Mask == Restrict; }
   void removeRestrict() { Mask &= ~Restrict; }
   void addRestrict() { Mask |= Restrict; }
+  Qualifiers withRestrict() const {
+Qualifiers Qs = *this;
+Qs.addRestrict();
+return Qs;
+  }
 
   bool hasCVRQualifiers() const { return getCVRQualifiers(); }
   unsigned getCVRQualifiers() const { return Mask & CVRMask; }
@@ -609,6 +624,47 @@ class Qualifiers {
   static const uint32_t AddressSpaceShift = 9;
 };
 
+class QualifiersAndAtomic {
+  Qualifiers Quals;
+  bool HasAtomic;
+
+public:
+  QualifiersAndAtomic() : HasAtomic(false) {}
+  QualifiersAndAtomic(Qualifiers Quals, bool HasAtomic)
+  : Quals(Quals), HasAtomic(HasAtomic) {}
+
+  operator Qualifiers() const { return Quals; }
+
+  bool hasVolatile() const { return Quals.hasVolatile(); }
+  bool hasConst() const { return Quals.hasConst(); }
+  bool hasRestrict() const { return Quals.hasRestrict(); }
+  bool hasAtomic() const { return HasAtomic; }
+
+  void addVolatile() { Quals.addVolatile(); }
+  void addConst() { Quals.addConst(); }
+  void addRestrict() { Quals.addRestrict(); }
+  void addAtomic() { HasAtomic = true; }
+
+  void removeVolatile() { Quals.removeVolatile(); }
+  void removeConst() { Quals.removeConst(); }
+  void removeRestrict() { Quals.removeRestrict(); }
+  void removeAtomic() { HasAtomic = false; }
+
+  QualifiersAndAtomic withVolatile() {
+return {Quals.withVolatile(), HasAtomic};
+  }
+  QualifiersAndAtomic withConst() { return {Quals.withConst(), HasAtomic}; }
+  QualifiersAndAtomic withRestrict() {
+return {Quals.withRestrict(), HasAtomic};
+  }
+  QualifiersAndAtomic withAtomic() { return {Quals, true}; }
+
+  QualifiersAndAtomic +=(Qualifiers RHS) {
+Quals += RHS;
+return *this;
+  }
+};
+
 /// A std::pair-like structure for storing a qualified type split
 /// into its local qualifiers and its locally-unqualified type.
 struct SplitQualType {

diff  --git a/clang/lib/Sema/SemaOverload.cpp 

[PATCH] D125349: [clang][sema] Generate builtin operator overloads for (volatile) _Atomic types

2022-06-20 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 438296.
jansvoboda11 added a comment.

Extract function for building type


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125349

Files:
  clang/include/clang/AST/Type.h
  clang/lib/Sema/SemaOverload.cpp
  clang/test/CodeGenCXX/atomic-builtin-compound-assignment-overload.cpp
  clang/test/SemaCXX/atomic-builtin-compound-assignment-overload.cpp

Index: clang/test/SemaCXX/atomic-builtin-compound-assignment-overload.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/atomic-builtin-compound-assignment-overload.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -std=gnu++98 -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+_Atomic unsigned an_atomic_uint;
+
+enum { an_enum_value = 1 };
+
+void enum1() { an_atomic_uint += an_enum_value; }
+
+void enum2() { an_atomic_uint |= an_enum_value; }
+
+volatile _Atomic unsigned an_volatile_atomic_uint;
+
+void enum3() { an_volatile_atomic_uint += an_enum_value; }
+
+void enum4() { an_volatile_atomic_uint |= an_enum_value; }
Index: clang/test/CodeGenCXX/atomic-builtin-compound-assignment-overload.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/atomic-builtin-compound-assignment-overload.cpp
@@ -0,0 +1,55 @@
+// RUN: %clang_cc1 -std=gnu++11 -emit-llvm -triple=x86_64-linux-gnu -o - %s | FileCheck %s
+
+_Atomic unsigned an_atomic_uint;
+
+enum { an_enum_value = 1 };
+
+// CHECK-LABEL: define {{.*}}void @_Z5enum1v()
+void enum1() {
+  an_atomic_uint += an_enum_value;
+  // CHECK: atomicrmw add ptr
+}
+
+// CHECK-LABEL: define {{.*}}void @_Z5enum2v()
+void enum2() {
+  an_atomic_uint |= an_enum_value;
+  // CHECK: atomicrmw or ptr
+}
+
+// CHECK-LABEL: define {{.*}}void @_Z5enum3RU7_Atomicj({{.*}})
+void enum3(_Atomic unsigned _atomic_uint_param) {
+  an_atomic_uint_param += an_enum_value;
+  // CHECK: atomicrmw add ptr
+}
+
+// CHECK-LABEL: define {{.*}}void @_Z5enum4RU7_Atomicj({{.*}})
+void enum4(_Atomic unsigned _atomic_uint_param) {
+  an_atomic_uint_param |= an_enum_value;
+  // CHECK: atomicrmw or ptr
+}
+
+volatile _Atomic unsigned an_volatile_atomic_uint;
+
+// CHECK-LABEL: define {{.*}}void @_Z5enum5v()
+void enum5() {
+  an_volatile_atomic_uint += an_enum_value;
+  // CHECK: atomicrmw add ptr
+}
+
+// CHECK-LABEL: define {{.*}}void @_Z5enum6v()
+void enum6() {
+  an_volatile_atomic_uint |= an_enum_value;
+  // CHECK: atomicrmw or ptr
+}
+
+// CHECK-LABEL: define {{.*}}void @_Z5enum7RVU7_Atomicj({{.*}})
+void enum7(volatile _Atomic unsigned _volatile_atomic_uint_param) {
+  an_volatile_atomic_uint_param += an_enum_value;
+  // CHECK: atomicrmw add ptr
+}
+
+// CHECK-LABEL: define {{.*}}void @_Z5enum8RVU7_Atomicj({{.*}})
+void enum8(volatile _Atomic unsigned _volatile_atomic_uint_param) {
+  an_volatile_atomic_uint_param |= an_enum_value;
+  // CHECK: atomicrmw or ptr
+}
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -8200,6 +8200,49 @@
 return VRQuals;
 }
 
+// Note: We're currently only handling qualifiers that are meaningful for the
+// LHS of compound assignment overloading.
+static void forAllQualifierCombinationsImpl(
+QualifiersAndAtomic Available, QualifiersAndAtomic Applied,
+llvm::function_ref Callback) {
+  // _Atomic
+  if (Available.hasAtomic()) {
+Available.removeAtomic();
+forAllQualifierCombinationsImpl(Available, Applied.withAtomic(), Callback);
+forAllQualifierCombinationsImpl(Available, Applied, Callback);
+return;
+  }
+
+  // volatile
+  if (Available.hasVolatile()) {
+Available.removeVolatile();
+assert(!Applied.hasVolatile());
+forAllQualifierCombinationsImpl(Available, Applied.withVolatile(),
+Callback);
+forAllQualifierCombinationsImpl(Available, Applied, Callback);
+return;
+  }
+
+  Callback(Applied);
+}
+
+static void forAllQualifierCombinations(
+QualifiersAndAtomic Quals,
+llvm::function_ref Callback) {
+  return forAllQualifierCombinationsImpl(Quals, QualifiersAndAtomic(),
+ Callback);
+}
+
+static QualType makeQualifiedLValueReferenceType(QualType Base,
+ QualifiersAndAtomic Quals,
+ Sema ) {
+  if (Quals.hasAtomic())
+Base = S.Context.getAtomicType(Base);
+  if (Quals.hasVolatile())
+Base = S.Context.getVolatileType(Base);
+  return S.Context.getLValueReferenceType(Base);
+}
+
 namespace {
 
 /// Helper class to manage the addition of builtin operator overload
@@ -8210,7 +8253,7 @@
   // Common instance state available to all overload candidate addition methods.
   Sema 
   ArrayRef Args;
-  Qualifiers 

  1   2   >