[PATCH] D152782: [CodeGen] Remove unused declaration/function GetOrCreateRTTIProxyGlobalVariable

2023-06-14 Thread Kazu Hirata via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8fd80d1d1366: [CodeGen] Remove unused function 
GetOrCreateRTTIProxyGlobalVariable (authored by kazu).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152782

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h


Index: clang/lib/CodeGen/CodeGenModule.h
===
--- clang/lib/CodeGen/CodeGenModule.h
+++ clang/lib/CodeGen/CodeGenModule.h
@@ -590,8 +590,6 @@
   MetadataTypeMap VirtualMetadataIdMap;
   MetadataTypeMap GeneralizedMetadataIdMap;
 
-  llvm::DenseMap RTTIProxyMap;
-
   // Helps squashing blocks of TopLevelStmtDecl into a single llvm::Function
   // when used with -fincremental-extensions.
   std::pair, const TopLevelStmtDecl *>
@@ -1503,9 +1501,6 @@
   std::vector
   getMostBaseClasses(const CXXRecordDecl *RD);
 
-  llvm::GlobalVariable *
-  GetOrCreateRTTIProxyGlobalVariable(llvm::Constant *Addr);
-
   /// Get the declaration of std::terminate for the platform.
   llvm::FunctionCallee getTerminateFn();
 
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -2028,22 +2028,6 @@
   return MostBases.takeVector();
 }
 
-llvm::GlobalVariable *
-CodeGenModule::GetOrCreateRTTIProxyGlobalVariable(llvm::Constant *Addr) {
-  auto It = RTTIProxyMap.find(Addr);
-  if (It != RTTIProxyMap.end())
-return It->second;
-
-  auto *FTRTTIProxy = new llvm::GlobalVariable(
-  TheModule, Addr->getType(),
-  /*isConstant=*/true, llvm::GlobalValue::PrivateLinkage, Addr,
-  "__llvm_rtti_proxy");
-  FTRTTIProxy->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
-
-  RTTIProxyMap[Addr] = FTRTTIProxy;
-  return FTRTTIProxy;
-}
-
 void CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D,
llvm::Function *F) {
   llvm::AttrBuilder B(F->getContext());


Index: clang/lib/CodeGen/CodeGenModule.h
===
--- clang/lib/CodeGen/CodeGenModule.h
+++ clang/lib/CodeGen/CodeGenModule.h
@@ -590,8 +590,6 @@
   MetadataTypeMap VirtualMetadataIdMap;
   MetadataTypeMap GeneralizedMetadataIdMap;
 
-  llvm::DenseMap RTTIProxyMap;
-
   // Helps squashing blocks of TopLevelStmtDecl into a single llvm::Function
   // when used with -fincremental-extensions.
   std::pair, const TopLevelStmtDecl *>
@@ -1503,9 +1501,6 @@
   std::vector
   getMostBaseClasses(const CXXRecordDecl *RD);
 
-  llvm::GlobalVariable *
-  GetOrCreateRTTIProxyGlobalVariable(llvm::Constant *Addr);
-
   /// Get the declaration of std::terminate for the platform.
   llvm::FunctionCallee getTerminateFn();
 
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -2028,22 +2028,6 @@
   return MostBases.takeVector();
 }
 
-llvm::GlobalVariable *
-CodeGenModule::GetOrCreateRTTIProxyGlobalVariable(llvm::Constant *Addr) {
-  auto It = RTTIProxyMap.find(Addr);
-  if (It != RTTIProxyMap.end())
-return It->second;
-
-  auto *FTRTTIProxy = new llvm::GlobalVariable(
-  TheModule, Addr->getType(),
-  /*isConstant=*/true, llvm::GlobalValue::PrivateLinkage, Addr,
-  "__llvm_rtti_proxy");
-  FTRTTIProxy->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
-
-  RTTIProxyMap[Addr] = FTRTTIProxy;
-  return FTRTTIProxy;
-}
-
 void CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D,
llvm::Function *F) {
   llvm::AttrBuilder B(F->getContext());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D152782: [CodeGen] Remove unused declaration/function GetOrCreateRTTIProxyGlobalVariable

2023-06-13 Thread Kazu Hirata via Phabricator via cfe-commits
kazu created this revision.
Herald added a project: All.
kazu requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The last use removed by:

  commit 46f366494f3ca8cc98daa6fb4f29c7c446c176b6
  Author: Fangrui Song 
  Date:   Sat May 20 08:24:20 2023 -0700

This patch also removes RTTIProxyMap, which becomes unused once I
remove GetOrCreateRTTIProxyGlobalVariable.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152782

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h


Index: clang/lib/CodeGen/CodeGenModule.h
===
--- clang/lib/CodeGen/CodeGenModule.h
+++ clang/lib/CodeGen/CodeGenModule.h
@@ -590,8 +590,6 @@
   MetadataTypeMap VirtualMetadataIdMap;
   MetadataTypeMap GeneralizedMetadataIdMap;
 
-  llvm::DenseMap RTTIProxyMap;
-
   // Helps squashing blocks of TopLevelStmtDecl into a single llvm::Function
   // when used with -fincremental-extensions.
   std::pair, const TopLevelStmtDecl *>
@@ -1503,9 +1501,6 @@
   std::vector
   getMostBaseClasses(const CXXRecordDecl *RD);
 
-  llvm::GlobalVariable *
-  GetOrCreateRTTIProxyGlobalVariable(llvm::Constant *Addr);
-
   /// Get the declaration of std::terminate for the platform.
   llvm::FunctionCallee getTerminateFn();
 
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -2028,22 +2028,6 @@
   return MostBases.takeVector();
 }
 
-llvm::GlobalVariable *
-CodeGenModule::GetOrCreateRTTIProxyGlobalVariable(llvm::Constant *Addr) {
-  auto It = RTTIProxyMap.find(Addr);
-  if (It != RTTIProxyMap.end())
-return It->second;
-
-  auto *FTRTTIProxy = new llvm::GlobalVariable(
-  TheModule, Addr->getType(),
-  /*isConstant=*/true, llvm::GlobalValue::PrivateLinkage, Addr,
-  "__llvm_rtti_proxy");
-  FTRTTIProxy->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
-
-  RTTIProxyMap[Addr] = FTRTTIProxy;
-  return FTRTTIProxy;
-}
-
 void CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D,
llvm::Function *F) {
   llvm::AttrBuilder B(F->getContext());


Index: clang/lib/CodeGen/CodeGenModule.h
===
--- clang/lib/CodeGen/CodeGenModule.h
+++ clang/lib/CodeGen/CodeGenModule.h
@@ -590,8 +590,6 @@
   MetadataTypeMap VirtualMetadataIdMap;
   MetadataTypeMap GeneralizedMetadataIdMap;
 
-  llvm::DenseMap RTTIProxyMap;
-
   // Helps squashing blocks of TopLevelStmtDecl into a single llvm::Function
   // when used with -fincremental-extensions.
   std::pair, const TopLevelStmtDecl *>
@@ -1503,9 +1501,6 @@
   std::vector
   getMostBaseClasses(const CXXRecordDecl *RD);
 
-  llvm::GlobalVariable *
-  GetOrCreateRTTIProxyGlobalVariable(llvm::Constant *Addr);
-
   /// Get the declaration of std::terminate for the platform.
   llvm::FunctionCallee getTerminateFn();
 
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -2028,22 +2028,6 @@
   return MostBases.takeVector();
 }
 
-llvm::GlobalVariable *
-CodeGenModule::GetOrCreateRTTIProxyGlobalVariable(llvm::Constant *Addr) {
-  auto It = RTTIProxyMap.find(Addr);
-  if (It != RTTIProxyMap.end())
-return It->second;
-
-  auto *FTRTTIProxy = new llvm::GlobalVariable(
-  TheModule, Addr->getType(),
-  /*isConstant=*/true, llvm::GlobalValue::PrivateLinkage, Addr,
-  "__llvm_rtti_proxy");
-  FTRTTIProxy->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
-
-  RTTIProxyMap[Addr] = FTRTTIProxy;
-  return FTRTTIProxy;
-}
-
 void CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D,
llvm::Function *F) {
   llvm::AttrBuilder B(F->getContext());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D152634: [Sema] Remove unused isNonTypeNestedNameSpecifier

2023-06-13 Thread Kazu Hirata via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGee72e2b3939a: [Sema] Remove unused 
isNonTypeNestedNameSpecifier (authored by kazu).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152634

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaCXXScopeSpec.cpp


Index: clang/lib/Sema/SemaCXXScopeSpec.cpp
===
--- clang/lib/Sema/SemaCXXScopeSpec.cpp
+++ clang/lib/Sema/SemaCXXScopeSpec.cpp
@@ -415,51 +415,6 @@
   return nullptr;
 }
 
-bool Sema::isNonTypeNestedNameSpecifier(Scope *S, CXXScopeSpec ,
-NestedNameSpecInfo ) {
-  QualType ObjectType = GetTypeFromParser(IdInfo.ObjectType);
-  LookupResult Found(*this, IdInfo.Identifier, IdInfo.IdentifierLoc,
- LookupNestedNameSpecifierName);
-
-  // Determine where to perform name lookup
-  DeclContext *LookupCtx = nullptr;
-  bool isDependent = false;
-  if (!ObjectType.isNull()) {
-// This nested-name-specifier occurs in a member access expression, e.g.,
-// x->B::f, and we are looking into the type of the object.
-assert(!SS.isSet() && "ObjectType and scope specifier cannot coexist");
-LookupCtx = computeDeclContext(ObjectType);
-isDependent = ObjectType->isDependentType();
-  } else if (SS.isSet()) {
-// This nested-name-specifier occurs after another nested-name-specifier,
-// so long into the context associated with the prior 
nested-name-specifier.
-LookupCtx = computeDeclContext(SS, false);
-isDependent = isDependentScopeSpecifier(SS);
-Found.setContextRange(SS.getRange());
-  }
-
-  if (LookupCtx) {
-// Perform "qualified" name lookup into the declaration context we
-// computed, which is either the type of the base of a member access
-// expression or the declaration context associated with a prior
-// nested-name-specifier.
-
-// The declaration context must be complete.
-if (!LookupCtx->isDependentContext() &&
-RequireCompleteDeclContext(SS, LookupCtx))
-  return false;
-
-LookupQualifiedName(Found, LookupCtx);
-  } else if (isDependent) {
-return false;
-  } else {
-LookupName(Found, S);
-  }
-  Found.suppressDiagnostics();
-
-  return Found.getAsSingle();
-}
-
 namespace {
 
 // Callback to only accept typo corrections that can be a valid C++ member
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -6994,9 +6994,6 @@
 }
   };
 
-  bool isNonTypeNestedNameSpecifier(Scope *S, CXXScopeSpec ,
-NestedNameSpecInfo );
-
   bool BuildCXXNestedNameSpecifier(Scope *S,
NestedNameSpecInfo ,
bool EnteringContext,


Index: clang/lib/Sema/SemaCXXScopeSpec.cpp
===
--- clang/lib/Sema/SemaCXXScopeSpec.cpp
+++ clang/lib/Sema/SemaCXXScopeSpec.cpp
@@ -415,51 +415,6 @@
   return nullptr;
 }
 
-bool Sema::isNonTypeNestedNameSpecifier(Scope *S, CXXScopeSpec ,
-NestedNameSpecInfo ) {
-  QualType ObjectType = GetTypeFromParser(IdInfo.ObjectType);
-  LookupResult Found(*this, IdInfo.Identifier, IdInfo.IdentifierLoc,
- LookupNestedNameSpecifierName);
-
-  // Determine where to perform name lookup
-  DeclContext *LookupCtx = nullptr;
-  bool isDependent = false;
-  if (!ObjectType.isNull()) {
-// This nested-name-specifier occurs in a member access expression, e.g.,
-// x->B::f, and we are looking into the type of the object.
-assert(!SS.isSet() && "ObjectType and scope specifier cannot coexist");
-LookupCtx = computeDeclContext(ObjectType);
-isDependent = ObjectType->isDependentType();
-  } else if (SS.isSet()) {
-// This nested-name-specifier occurs after another nested-name-specifier,
-// so long into the context associated with the prior nested-name-specifier.
-LookupCtx = computeDeclContext(SS, false);
-isDependent = isDependentScopeSpecifier(SS);
-Found.setContextRange(SS.getRange());
-  }
-
-  if (LookupCtx) {
-// Perform "qualified" name lookup into the declaration context we
-// computed, which is either the type of the base of a member access
-// expression or the declaration context associated with a prior
-// nested-name-specifier.
-
-// The declaration context must be complete.
-if (!LookupCtx->isDependentContext() &&
-RequireCompleteDeclContext(SS, LookupCtx))
-  return false;
-
-LookupQualifiedName(Found, LookupCtx);
-  } else if (isDependent) {
-return false;
-  } else {
-LookupName(Found, S);
-  }
-  Found.suppressDiagnostics();
-
-  return Found.getAsSingle();
-}
-
 

[PATCH] D152634: [Sema] Remove unused isNonTypeNestedNameSpecifier

2023-06-10 Thread Kazu Hirata via Phabricator via cfe-commits
kazu created this revision.
Herald added a project: All.
kazu requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The last use was removed by:

  commit 04f131da0b19abff611773c03be9bafb53c753ce
  Author: Richard Smith 
  Date:   Fri Jan 24 15:14:25 2020 -0800


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152634

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaCXXScopeSpec.cpp


Index: clang/lib/Sema/SemaCXXScopeSpec.cpp
===
--- clang/lib/Sema/SemaCXXScopeSpec.cpp
+++ clang/lib/Sema/SemaCXXScopeSpec.cpp
@@ -415,51 +415,6 @@
   return nullptr;
 }
 
-bool Sema::isNonTypeNestedNameSpecifier(Scope *S, CXXScopeSpec ,
-NestedNameSpecInfo ) {
-  QualType ObjectType = GetTypeFromParser(IdInfo.ObjectType);
-  LookupResult Found(*this, IdInfo.Identifier, IdInfo.IdentifierLoc,
- LookupNestedNameSpecifierName);
-
-  // Determine where to perform name lookup
-  DeclContext *LookupCtx = nullptr;
-  bool isDependent = false;
-  if (!ObjectType.isNull()) {
-// This nested-name-specifier occurs in a member access expression, e.g.,
-// x->B::f, and we are looking into the type of the object.
-assert(!SS.isSet() && "ObjectType and scope specifier cannot coexist");
-LookupCtx = computeDeclContext(ObjectType);
-isDependent = ObjectType->isDependentType();
-  } else if (SS.isSet()) {
-// This nested-name-specifier occurs after another nested-name-specifier,
-// so long into the context associated with the prior 
nested-name-specifier.
-LookupCtx = computeDeclContext(SS, false);
-isDependent = isDependentScopeSpecifier(SS);
-Found.setContextRange(SS.getRange());
-  }
-
-  if (LookupCtx) {
-// Perform "qualified" name lookup into the declaration context we
-// computed, which is either the type of the base of a member access
-// expression or the declaration context associated with a prior
-// nested-name-specifier.
-
-// The declaration context must be complete.
-if (!LookupCtx->isDependentContext() &&
-RequireCompleteDeclContext(SS, LookupCtx))
-  return false;
-
-LookupQualifiedName(Found, LookupCtx);
-  } else if (isDependent) {
-return false;
-  } else {
-LookupName(Found, S);
-  }
-  Found.suppressDiagnostics();
-
-  return Found.getAsSingle();
-}
-
 namespace {
 
 // Callback to only accept typo corrections that can be a valid C++ member
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -6994,9 +6994,6 @@
 }
   };
 
-  bool isNonTypeNestedNameSpecifier(Scope *S, CXXScopeSpec ,
-NestedNameSpecInfo );
-
   bool BuildCXXNestedNameSpecifier(Scope *S,
NestedNameSpecInfo ,
bool EnteringContext,


Index: clang/lib/Sema/SemaCXXScopeSpec.cpp
===
--- clang/lib/Sema/SemaCXXScopeSpec.cpp
+++ clang/lib/Sema/SemaCXXScopeSpec.cpp
@@ -415,51 +415,6 @@
   return nullptr;
 }
 
-bool Sema::isNonTypeNestedNameSpecifier(Scope *S, CXXScopeSpec ,
-NestedNameSpecInfo ) {
-  QualType ObjectType = GetTypeFromParser(IdInfo.ObjectType);
-  LookupResult Found(*this, IdInfo.Identifier, IdInfo.IdentifierLoc,
- LookupNestedNameSpecifierName);
-
-  // Determine where to perform name lookup
-  DeclContext *LookupCtx = nullptr;
-  bool isDependent = false;
-  if (!ObjectType.isNull()) {
-// This nested-name-specifier occurs in a member access expression, e.g.,
-// x->B::f, and we are looking into the type of the object.
-assert(!SS.isSet() && "ObjectType and scope specifier cannot coexist");
-LookupCtx = computeDeclContext(ObjectType);
-isDependent = ObjectType->isDependentType();
-  } else if (SS.isSet()) {
-// This nested-name-specifier occurs after another nested-name-specifier,
-// so long into the context associated with the prior nested-name-specifier.
-LookupCtx = computeDeclContext(SS, false);
-isDependent = isDependentScopeSpecifier(SS);
-Found.setContextRange(SS.getRange());
-  }
-
-  if (LookupCtx) {
-// Perform "qualified" name lookup into the declaration context we
-// computed, which is either the type of the base of a member access
-// expression or the declaration context associated with a prior
-// nested-name-specifier.
-
-// The declaration context must be complete.
-if (!LookupCtx->isDependentContext() &&
-RequireCompleteDeclContext(SS, LookupCtx))
-  return false;
-
-LookupQualifiedName(Found, LookupCtx);
-  } else if (isDependent) {
-return false;
-  } else {
-LookupName(Found, S);
-  }
-  

[PATCH] D151786: [Tooling] Remove unused function setRestoreWorkingDir

2023-05-31 Thread Kazu Hirata via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5a0d53ce4148: [Tooling] Remove unused function 
setRestoreWorkingDir (authored by kazu).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151786

Files:
  clang/include/clang/Tooling/Tooling.h
  clang/lib/Tooling/Tooling.cpp


Index: clang/lib/Tooling/Tooling.cpp
===
--- clang/lib/Tooling/Tooling.cpp
+++ clang/lib/Tooling/Tooling.cpp
@@ -542,13 +542,11 @@
 
   // Remember the working directory in case we need to restore it.
   std::string InitialWorkingDir;
-  if (RestoreCWD) {
-if (auto CWD = OverlayFileSystem->getCurrentWorkingDirectory()) {
-  InitialWorkingDir = std::move(*CWD);
-} else {
-  llvm::errs() << "Could not get working directory: "
-   << CWD.getError().message() << "\n";
-}
+  if (auto CWD = OverlayFileSystem->getCurrentWorkingDirectory()) {
+InitialWorkingDir = std::move(*CWD);
+  } else {
+llvm::errs() << "Could not get working directory: "
+ << CWD.getError().message() << "\n";
   }
 
   for (llvm::StringRef File : AbsolutePaths) {
@@ -662,10 +660,6 @@
   return run();
 }
 
-void ClangTool::setRestoreWorkingDir(bool RestoreCWD) {
-  this->RestoreCWD = RestoreCWD;
-}
-
 void ClangTool::setPrintErrorMessage(bool PrintErrorMessage) {
   this->PrintErrorMessage = PrintErrorMessage;
 }
Index: clang/include/clang/Tooling/Tooling.h
===
--- clang/include/clang/Tooling/Tooling.h
+++ clang/include/clang/Tooling/Tooling.h
@@ -361,11 +361,6 @@
   /// append them to ASTs.
   int buildASTs(std::vector> );
 
-  /// Sets whether working directory should be restored after calling run(). By
-  /// default, working directory is restored. However, it could be useful to
-  /// turn this off when running on multiple threads to avoid the raciness.
-  void setRestoreWorkingDir(bool RestoreCWD);
-
   /// Sets whether an error message should be printed out if an action fails. 
By
   /// default, if an action fails, a message is printed out to stderr.
   void setPrintErrorMessage(bool PrintErrorMessage);
@@ -395,7 +390,6 @@
 
   DiagnosticConsumer *DiagConsumer = nullptr;
 
-  bool RestoreCWD = true;
   bool PrintErrorMessage = true;
 };
 


Index: clang/lib/Tooling/Tooling.cpp
===
--- clang/lib/Tooling/Tooling.cpp
+++ clang/lib/Tooling/Tooling.cpp
@@ -542,13 +542,11 @@
 
   // Remember the working directory in case we need to restore it.
   std::string InitialWorkingDir;
-  if (RestoreCWD) {
-if (auto CWD = OverlayFileSystem->getCurrentWorkingDirectory()) {
-  InitialWorkingDir = std::move(*CWD);
-} else {
-  llvm::errs() << "Could not get working directory: "
-   << CWD.getError().message() << "\n";
-}
+  if (auto CWD = OverlayFileSystem->getCurrentWorkingDirectory()) {
+InitialWorkingDir = std::move(*CWD);
+  } else {
+llvm::errs() << "Could not get working directory: "
+ << CWD.getError().message() << "\n";
   }
 
   for (llvm::StringRef File : AbsolutePaths) {
@@ -662,10 +660,6 @@
   return run();
 }
 
-void ClangTool::setRestoreWorkingDir(bool RestoreCWD) {
-  this->RestoreCWD = RestoreCWD;
-}
-
 void ClangTool::setPrintErrorMessage(bool PrintErrorMessage) {
   this->PrintErrorMessage = PrintErrorMessage;
 }
Index: clang/include/clang/Tooling/Tooling.h
===
--- clang/include/clang/Tooling/Tooling.h
+++ clang/include/clang/Tooling/Tooling.h
@@ -361,11 +361,6 @@
   /// append them to ASTs.
   int buildASTs(std::vector> );
 
-  /// Sets whether working directory should be restored after calling run(). By
-  /// default, working directory is restored. However, it could be useful to
-  /// turn this off when running on multiple threads to avoid the raciness.
-  void setRestoreWorkingDir(bool RestoreCWD);
-
   /// Sets whether an error message should be printed out if an action fails. By
   /// default, if an action fails, a message is printed out to stderr.
   void setPrintErrorMessage(bool PrintErrorMessage);
@@ -395,7 +390,6 @@
 
   DiagnosticConsumer *DiagConsumer = nullptr;
 
-  bool RestoreCWD = true;
   bool PrintErrorMessage = true;
 };
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D151608: [Sema] Remove unused function getFloat128Identifier

2023-05-31 Thread Kazu Hirata 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 rGa88f496f8f3b: [Sema] Remove unused function 
getFloat128Identifier (authored by kazu).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151608

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/Sema.cpp


Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -219,7 +219,7 @@
   ArgumentPackSubstitutionIndex(-1), CurrentInstantiationScope(nullptr),
   DisableTypoCorrection(false), TyposCorrected(0), AnalysisWarnings(*this),
   ThreadSafetyDeclCache(nullptr), VarDataSharingAttributesStack(nullptr),
-  CurScope(nullptr), Ident_super(nullptr), Ident___float128(nullptr) {
+  CurScope(nullptr), Ident_super(nullptr) {
   assert(pp.TUKind == TUKind);
   TUScope = nullptr;
   isConstantEvaluatedOverride = false;
@@ -2686,12 +2686,6 @@
   return Ident_super;
 }
 
-IdentifierInfo *Sema::getFloat128Identifier() const {
-  if (!Ident___float128)
-Ident___float128 = ("__float128");
-  return Ident___float128;
-}
-
 void Sema::PushCapturedRegionScope(Scope *S, CapturedDecl *CD, RecordDecl *RD,
CapturedRegionKind K,
unsigned OpenMPCaptureLevel) {
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -13764,7 +13764,6 @@
   Scope *CurScope;
 
   mutable IdentifierInfo *Ident_super;
-  mutable IdentifierInfo *Ident___float128;
 
   /// Nullability type specifiers.
   IdentifierInfo *Ident__Nonnull = nullptr;
@@ -13813,7 +13812,6 @@
   }
 
   IdentifierInfo *getSuperIdentifier() const;
-  IdentifierInfo *getFloat128Identifier() const;
 
   ObjCContainerDecl *getObjCDeclContext() const;
 


Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -219,7 +219,7 @@
   ArgumentPackSubstitutionIndex(-1), CurrentInstantiationScope(nullptr),
   DisableTypoCorrection(false), TyposCorrected(0), AnalysisWarnings(*this),
   ThreadSafetyDeclCache(nullptr), VarDataSharingAttributesStack(nullptr),
-  CurScope(nullptr), Ident_super(nullptr), Ident___float128(nullptr) {
+  CurScope(nullptr), Ident_super(nullptr) {
   assert(pp.TUKind == TUKind);
   TUScope = nullptr;
   isConstantEvaluatedOverride = false;
@@ -2686,12 +2686,6 @@
   return Ident_super;
 }
 
-IdentifierInfo *Sema::getFloat128Identifier() const {
-  if (!Ident___float128)
-Ident___float128 = ("__float128");
-  return Ident___float128;
-}
-
 void Sema::PushCapturedRegionScope(Scope *S, CapturedDecl *CD, RecordDecl *RD,
CapturedRegionKind K,
unsigned OpenMPCaptureLevel) {
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -13764,7 +13764,6 @@
   Scope *CurScope;
 
   mutable IdentifierInfo *Ident_super;
-  mutable IdentifierInfo *Ident___float128;
 
   /// Nullability type specifiers.
   IdentifierInfo *Ident__Nonnull = nullptr;
@@ -13813,7 +13812,6 @@
   }
 
   IdentifierInfo *getSuperIdentifier() const;
-  IdentifierInfo *getFloat128Identifier() const;
 
   ObjCContainerDecl *getObjCDeclContext() const;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D151786: [Tooling] Remove unused function setRestoreWorkingDir

2023-05-31 Thread Kazu Hirata via Phabricator via cfe-commits
kazu created this revision.
Herald added a project: All.
kazu requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The last use was removed by:

  commit 146ec74a8382dc820809d0a2bf4b918d0b5e6603
  Author: Jan Svoboda 
  Date:   Fri Sep 10 10:24:16 2021 +0200

Once I remove the function, RestoreCWD is always true, so this patch
removes the variable and propagates the constant.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151786

Files:
  clang/include/clang/Tooling/Tooling.h
  clang/lib/Tooling/Tooling.cpp


Index: clang/lib/Tooling/Tooling.cpp
===
--- clang/lib/Tooling/Tooling.cpp
+++ clang/lib/Tooling/Tooling.cpp
@@ -542,13 +542,11 @@
 
   // Remember the working directory in case we need to restore it.
   std::string InitialWorkingDir;
-  if (RestoreCWD) {
-if (auto CWD = OverlayFileSystem->getCurrentWorkingDirectory()) {
-  InitialWorkingDir = std::move(*CWD);
-} else {
-  llvm::errs() << "Could not get working directory: "
-   << CWD.getError().message() << "\n";
-}
+  if (auto CWD = OverlayFileSystem->getCurrentWorkingDirectory()) {
+InitialWorkingDir = std::move(*CWD);
+  } else {
+llvm::errs() << "Could not get working directory: "
+ << CWD.getError().message() << "\n";
   }
 
   for (llvm::StringRef File : AbsolutePaths) {
@@ -662,10 +660,6 @@
   return run();
 }
 
-void ClangTool::setRestoreWorkingDir(bool RestoreCWD) {
-  this->RestoreCWD = RestoreCWD;
-}
-
 void ClangTool::setPrintErrorMessage(bool PrintErrorMessage) {
   this->PrintErrorMessage = PrintErrorMessage;
 }
Index: clang/include/clang/Tooling/Tooling.h
===
--- clang/include/clang/Tooling/Tooling.h
+++ clang/include/clang/Tooling/Tooling.h
@@ -361,11 +361,6 @@
   /// append them to ASTs.
   int buildASTs(std::vector> );
 
-  /// Sets whether working directory should be restored after calling run(). By
-  /// default, working directory is restored. However, it could be useful to
-  /// turn this off when running on multiple threads to avoid the raciness.
-  void setRestoreWorkingDir(bool RestoreCWD);
-
   /// Sets whether an error message should be printed out if an action fails. 
By
   /// default, if an action fails, a message is printed out to stderr.
   void setPrintErrorMessage(bool PrintErrorMessage);
@@ -395,7 +390,6 @@
 
   DiagnosticConsumer *DiagConsumer = nullptr;
 
-  bool RestoreCWD = true;
   bool PrintErrorMessage = true;
 };
 


Index: clang/lib/Tooling/Tooling.cpp
===
--- clang/lib/Tooling/Tooling.cpp
+++ clang/lib/Tooling/Tooling.cpp
@@ -542,13 +542,11 @@
 
   // Remember the working directory in case we need to restore it.
   std::string InitialWorkingDir;
-  if (RestoreCWD) {
-if (auto CWD = OverlayFileSystem->getCurrentWorkingDirectory()) {
-  InitialWorkingDir = std::move(*CWD);
-} else {
-  llvm::errs() << "Could not get working directory: "
-   << CWD.getError().message() << "\n";
-}
+  if (auto CWD = OverlayFileSystem->getCurrentWorkingDirectory()) {
+InitialWorkingDir = std::move(*CWD);
+  } else {
+llvm::errs() << "Could not get working directory: "
+ << CWD.getError().message() << "\n";
   }
 
   for (llvm::StringRef File : AbsolutePaths) {
@@ -662,10 +660,6 @@
   return run();
 }
 
-void ClangTool::setRestoreWorkingDir(bool RestoreCWD) {
-  this->RestoreCWD = RestoreCWD;
-}
-
 void ClangTool::setPrintErrorMessage(bool PrintErrorMessage) {
   this->PrintErrorMessage = PrintErrorMessage;
 }
Index: clang/include/clang/Tooling/Tooling.h
===
--- clang/include/clang/Tooling/Tooling.h
+++ clang/include/clang/Tooling/Tooling.h
@@ -361,11 +361,6 @@
   /// append them to ASTs.
   int buildASTs(std::vector> );
 
-  /// Sets whether working directory should be restored after calling run(). By
-  /// default, working directory is restored. However, it could be useful to
-  /// turn this off when running on multiple threads to avoid the raciness.
-  void setRestoreWorkingDir(bool RestoreCWD);
-
   /// Sets whether an error message should be printed out if an action fails. By
   /// default, if an action fails, a message is printed out to stderr.
   void setPrintErrorMessage(bool PrintErrorMessage);
@@ -395,7 +390,6 @@
 
   DiagnosticConsumer *DiagConsumer = nullptr;
 
-  bool RestoreCWD = true;
   bool PrintErrorMessage = true;
 };
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D151608: [Sema] Remove unused function getFloat128Identifier

2023-05-31 Thread Kazu Hirata via Phabricator via cfe-commits
kazu added a comment.

Please take a look.  Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151608

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


[PATCH] D151607: [AST] Remove unused function removeLocalCVRQualifiers

2023-05-30 Thread Kazu Hirata via Phabricator via cfe-commits
kazu added a comment.

In D151607#4380757 , @erichkeane 
wrote:

> Since this is part of the public API, do we need to publish/alert folks of 
> this?  This could perhaps be in use by someone using libclang/etc, right?

I don't think we guarantee the API stability.  For the *C* API, this is clearly 
documented:

https://llvm.org/docs/DeveloperPolicy.html#c-api-changes

There has been an effort to document something similar about the C++ API:

https://lists.llvm.org/pipermail/llvm-dev/2020-July/143613.html

but I don't know exactly what happened to it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151607

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


[PATCH] D151609: [Driver] Remove unused class ForceSuccessCommand

2023-05-30 Thread Kazu Hirata via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG692f3059fb95: [Driver] Remove unused class 
ForceSuccessCommand (authored by kazu).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151609

Files:
  clang/include/clang/Driver/Job.h
  clang/lib/Driver/Job.cpp


Index: clang/lib/Driver/Job.cpp
===
--- clang/lib/Driver/Job.cpp
+++ clang/lib/Driver/Job.cpp
@@ -449,30 +449,6 @@
   "The CC1Command doesn't support changing the environment vars!");
 }
 
-ForceSuccessCommand::ForceSuccessCommand(
-const Action _, const Tool _,
-ResponseFileSupport ResponseSupport, const char *Executable_,
-const llvm::opt::ArgStringList _, ArrayRef Inputs,
-ArrayRef Outputs)
-: Command(Source_, Creator_, ResponseSupport, Executable_, Arguments_,
-  Inputs, Outputs) {}
-
-void ForceSuccessCommand::Print(raw_ostream , const char *Terminator,
-bool Quote, CrashReportInfo *CrashInfo) const {
-  Command::Print(OS, "", Quote, CrashInfo);
-  OS << " || (exit 0)" << Terminator;
-}
-
-int ForceSuccessCommand::Execute(ArrayRef> Redirects,
- std::string *ErrMsg,
- bool *ExecutionFailed) const {
-  int Status = Command::Execute(Redirects, ErrMsg, ExecutionFailed);
-  (void)Status;
-  if (ExecutionFailed)
-*ExecutionFailed = false;
-  return 0;
-}
-
 void JobList::Print(raw_ostream , const char *Terminator, bool Quote,
 CrashReportInfo *CrashInfo) const {
   for (const auto  : *this)
Index: clang/include/clang/Driver/Job.h
===
--- clang/include/clang/Driver/Job.h
+++ clang/include/clang/Driver/Job.h
@@ -258,23 +258,6 @@
   void setEnvironment(llvm::ArrayRef NewEnvironment) override;
 };
 
-/// Like Command, but always pretends that the wrapped command succeeded.
-class ForceSuccessCommand : public Command {
-public:
-  ForceSuccessCommand(const Action _, const Tool _,
-  ResponseFileSupport ResponseSupport,
-  const char *Executable_,
-  const llvm::opt::ArgStringList _,
-  ArrayRef Inputs,
-  ArrayRef Outputs = std::nullopt);
-
-  void Print(llvm::raw_ostream , const char *Terminator, bool Quote,
- CrashReportInfo *CrashInfo = nullptr) const override;
-
-  int Execute(ArrayRef> Redirects, std::string 
*ErrMsg,
-  bool *ExecutionFailed) const override;
-};
-
 /// JobList - A sequence of jobs to perform.
 class JobList {
 public:


Index: clang/lib/Driver/Job.cpp
===
--- clang/lib/Driver/Job.cpp
+++ clang/lib/Driver/Job.cpp
@@ -449,30 +449,6 @@
   "The CC1Command doesn't support changing the environment vars!");
 }
 
-ForceSuccessCommand::ForceSuccessCommand(
-const Action _, const Tool _,
-ResponseFileSupport ResponseSupport, const char *Executable_,
-const llvm::opt::ArgStringList _, ArrayRef Inputs,
-ArrayRef Outputs)
-: Command(Source_, Creator_, ResponseSupport, Executable_, Arguments_,
-  Inputs, Outputs) {}
-
-void ForceSuccessCommand::Print(raw_ostream , const char *Terminator,
-bool Quote, CrashReportInfo *CrashInfo) const {
-  Command::Print(OS, "", Quote, CrashInfo);
-  OS << " || (exit 0)" << Terminator;
-}
-
-int ForceSuccessCommand::Execute(ArrayRef> Redirects,
- std::string *ErrMsg,
- bool *ExecutionFailed) const {
-  int Status = Command::Execute(Redirects, ErrMsg, ExecutionFailed);
-  (void)Status;
-  if (ExecutionFailed)
-*ExecutionFailed = false;
-  return 0;
-}
-
 void JobList::Print(raw_ostream , const char *Terminator, bool Quote,
 CrashReportInfo *CrashInfo) const {
   for (const auto  : *this)
Index: clang/include/clang/Driver/Job.h
===
--- clang/include/clang/Driver/Job.h
+++ clang/include/clang/Driver/Job.h
@@ -258,23 +258,6 @@
   void setEnvironment(llvm::ArrayRef NewEnvironment) override;
 };
 
-/// Like Command, but always pretends that the wrapped command succeeded.
-class ForceSuccessCommand : public Command {
-public:
-  ForceSuccessCommand(const Action _, const Tool _,
-  ResponseFileSupport ResponseSupport,
-  const char *Executable_,
-  const llvm::opt::ArgStringList _,
-  ArrayRef Inputs,
-  ArrayRef Outputs = std::nullopt);
-
-  void Print(llvm::raw_ostream , const char *Terminator, bool Quote,
- CrashReportInfo *CrashInfo = nullptr) const override;
-
-  int Execute(ArrayRef> Redirects, std::string 

[PATCH] D151607: [AST] Remove unused function removeLocalCVRQualifiers

2023-05-27 Thread Kazu Hirata 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 rGe396c375a108: [AST] Remove unused function 
removeLocalCVRQualifiers (authored by kazu).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151607

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


Index: clang/include/clang/AST/Type.h
===
--- clang/include/clang/AST/Type.h
+++ clang/include/clang/AST/Type.h
@@ -948,7 +948,6 @@
   void removeLocalConst();
   void removeLocalVolatile();
   void removeLocalRestrict();
-  void removeLocalCVRQualifiers(unsigned Mask);
 
   void removeLocalFastQualifiers() { Value.setInt(0); }
   void removeLocalFastQualifiers(unsigned Mask) {
@@ -6781,15 +6780,6 @@
   removeLocalFastQualifiers(Qualifiers::Volatile);
 }
 
-inline void QualType::removeLocalCVRQualifiers(unsigned Mask) {
-  assert(!(Mask & ~Qualifiers::CVRMask) && "mask has non-CVR bits");
-  static_assert((int)Qualifiers::CVRMask == (int)Qualifiers::FastMask,
-"Fast bits differ from CVR bits!");
-
-  // Fast path: we don't need to touch the slow qualifiers.
-  removeLocalFastQualifiers(Mask);
-}
-
 /// Check if this type has any address space qualifier.
 inline bool QualType::hasAddressSpace() const {
   return getQualifiers().hasAddressSpace();


Index: clang/include/clang/AST/Type.h
===
--- clang/include/clang/AST/Type.h
+++ clang/include/clang/AST/Type.h
@@ -948,7 +948,6 @@
   void removeLocalConst();
   void removeLocalVolatile();
   void removeLocalRestrict();
-  void removeLocalCVRQualifiers(unsigned Mask);
 
   void removeLocalFastQualifiers() { Value.setInt(0); }
   void removeLocalFastQualifiers(unsigned Mask) {
@@ -6781,15 +6780,6 @@
   removeLocalFastQualifiers(Qualifiers::Volatile);
 }
 
-inline void QualType::removeLocalCVRQualifiers(unsigned Mask) {
-  assert(!(Mask & ~Qualifiers::CVRMask) && "mask has non-CVR bits");
-  static_assert((int)Qualifiers::CVRMask == (int)Qualifiers::FastMask,
-"Fast bits differ from CVR bits!");
-
-  // Fast path: we don't need to touch the slow qualifiers.
-  removeLocalFastQualifiers(Mask);
-}
-
 /// Check if this type has any address space qualifier.
 inline bool QualType::hasAddressSpace() const {
   return getQualifiers().hasAddressSpace();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D151609: [Driver] Remove unused class ForceSuccessCommand

2023-05-26 Thread Kazu Hirata via Phabricator via cfe-commits
kazu created this revision.
Herald added a project: All.
kazu requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

The last use was removed by:

  commit 6625680a581c5e29c53d9f58d864cc6cd3cd05f6
  Author: Hans Wennborg 
  Date:   Tue Feb 2 14:10:26 2021 +0100


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151609

Files:
  clang/include/clang/Driver/Job.h
  clang/lib/Driver/Job.cpp


Index: clang/lib/Driver/Job.cpp
===
--- clang/lib/Driver/Job.cpp
+++ clang/lib/Driver/Job.cpp
@@ -449,30 +449,6 @@
   "The CC1Command doesn't support changing the environment vars!");
 }
 
-ForceSuccessCommand::ForceSuccessCommand(
-const Action _, const Tool _,
-ResponseFileSupport ResponseSupport, const char *Executable_,
-const llvm::opt::ArgStringList _, ArrayRef Inputs,
-ArrayRef Outputs)
-: Command(Source_, Creator_, ResponseSupport, Executable_, Arguments_,
-  Inputs, Outputs) {}
-
-void ForceSuccessCommand::Print(raw_ostream , const char *Terminator,
-bool Quote, CrashReportInfo *CrashInfo) const {
-  Command::Print(OS, "", Quote, CrashInfo);
-  OS << " || (exit 0)" << Terminator;
-}
-
-int ForceSuccessCommand::Execute(ArrayRef> Redirects,
- std::string *ErrMsg,
- bool *ExecutionFailed) const {
-  int Status = Command::Execute(Redirects, ErrMsg, ExecutionFailed);
-  (void)Status;
-  if (ExecutionFailed)
-*ExecutionFailed = false;
-  return 0;
-}
-
 void JobList::Print(raw_ostream , const char *Terminator, bool Quote,
 CrashReportInfo *CrashInfo) const {
   for (const auto  : *this)
Index: clang/include/clang/Driver/Job.h
===
--- clang/include/clang/Driver/Job.h
+++ clang/include/clang/Driver/Job.h
@@ -258,23 +258,6 @@
   void setEnvironment(llvm::ArrayRef NewEnvironment) override;
 };
 
-/// Like Command, but always pretends that the wrapped command succeeded.
-class ForceSuccessCommand : public Command {
-public:
-  ForceSuccessCommand(const Action _, const Tool _,
-  ResponseFileSupport ResponseSupport,
-  const char *Executable_,
-  const llvm::opt::ArgStringList _,
-  ArrayRef Inputs,
-  ArrayRef Outputs = std::nullopt);
-
-  void Print(llvm::raw_ostream , const char *Terminator, bool Quote,
- CrashReportInfo *CrashInfo = nullptr) const override;
-
-  int Execute(ArrayRef> Redirects, std::string 
*ErrMsg,
-  bool *ExecutionFailed) const override;
-};
-
 /// JobList - A sequence of jobs to perform.
 class JobList {
 public:


Index: clang/lib/Driver/Job.cpp
===
--- clang/lib/Driver/Job.cpp
+++ clang/lib/Driver/Job.cpp
@@ -449,30 +449,6 @@
   "The CC1Command doesn't support changing the environment vars!");
 }
 
-ForceSuccessCommand::ForceSuccessCommand(
-const Action _, const Tool _,
-ResponseFileSupport ResponseSupport, const char *Executable_,
-const llvm::opt::ArgStringList _, ArrayRef Inputs,
-ArrayRef Outputs)
-: Command(Source_, Creator_, ResponseSupport, Executable_, Arguments_,
-  Inputs, Outputs) {}
-
-void ForceSuccessCommand::Print(raw_ostream , const char *Terminator,
-bool Quote, CrashReportInfo *CrashInfo) const {
-  Command::Print(OS, "", Quote, CrashInfo);
-  OS << " || (exit 0)" << Terminator;
-}
-
-int ForceSuccessCommand::Execute(ArrayRef> Redirects,
- std::string *ErrMsg,
- bool *ExecutionFailed) const {
-  int Status = Command::Execute(Redirects, ErrMsg, ExecutionFailed);
-  (void)Status;
-  if (ExecutionFailed)
-*ExecutionFailed = false;
-  return 0;
-}
-
 void JobList::Print(raw_ostream , const char *Terminator, bool Quote,
 CrashReportInfo *CrashInfo) const {
   for (const auto  : *this)
Index: clang/include/clang/Driver/Job.h
===
--- clang/include/clang/Driver/Job.h
+++ clang/include/clang/Driver/Job.h
@@ -258,23 +258,6 @@
   void setEnvironment(llvm::ArrayRef NewEnvironment) override;
 };
 
-/// Like Command, but always pretends that the wrapped command succeeded.
-class ForceSuccessCommand : public Command {
-public:
-  ForceSuccessCommand(const Action _, const Tool _,
-  ResponseFileSupport ResponseSupport,
-  const char *Executable_,
-  const llvm::opt::ArgStringList _,
-  ArrayRef Inputs,
-  ArrayRef Outputs = std::nullopt);
-
-  void Print(llvm::raw_ostream , const char *Terminator, bool Quote,
- CrashReportInfo *CrashInfo = 

[PATCH] D151608: [Sema] Remove unused function getFloat128Identifier

2023-05-26 Thread Kazu Hirata via Phabricator via cfe-commits
kazu created this revision.
Herald added a project: All.
kazu requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The last use was removed by:

  commit bb1ea2d6139a72340b426e114510c46d938645a6
  Author: Nemanja Ivanovic 
  Date:   Mon May 9 08:52:33 2016 +


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151608

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/Sema.cpp


Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -219,7 +219,7 @@
   ArgumentPackSubstitutionIndex(-1), CurrentInstantiationScope(nullptr),
   DisableTypoCorrection(false), TyposCorrected(0), AnalysisWarnings(*this),
   ThreadSafetyDeclCache(nullptr), VarDataSharingAttributesStack(nullptr),
-  CurScope(nullptr), Ident_super(nullptr), Ident___float128(nullptr) {
+  CurScope(nullptr), Ident_super(nullptr) {
   assert(pp.TUKind == TUKind);
   TUScope = nullptr;
   isConstantEvaluatedOverride = false;
@@ -2685,12 +2685,6 @@
   return Ident_super;
 }
 
-IdentifierInfo *Sema::getFloat128Identifier() const {
-  if (!Ident___float128)
-Ident___float128 = ("__float128");
-  return Ident___float128;
-}
-
 void Sema::PushCapturedRegionScope(Scope *S, CapturedDecl *CD, RecordDecl *RD,
CapturedRegionKind K,
unsigned OpenMPCaptureLevel) {
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -13764,7 +13764,6 @@
   Scope *CurScope;
 
   mutable IdentifierInfo *Ident_super;
-  mutable IdentifierInfo *Ident___float128;
 
   /// Nullability type specifiers.
   IdentifierInfo *Ident__Nonnull = nullptr;
@@ -13813,7 +13812,6 @@
   }
 
   IdentifierInfo *getSuperIdentifier() const;
-  IdentifierInfo *getFloat128Identifier() const;
 
   ObjCContainerDecl *getObjCDeclContext() const;
 


Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -219,7 +219,7 @@
   ArgumentPackSubstitutionIndex(-1), CurrentInstantiationScope(nullptr),
   DisableTypoCorrection(false), TyposCorrected(0), AnalysisWarnings(*this),
   ThreadSafetyDeclCache(nullptr), VarDataSharingAttributesStack(nullptr),
-  CurScope(nullptr), Ident_super(nullptr), Ident___float128(nullptr) {
+  CurScope(nullptr), Ident_super(nullptr) {
   assert(pp.TUKind == TUKind);
   TUScope = nullptr;
   isConstantEvaluatedOverride = false;
@@ -2685,12 +2685,6 @@
   return Ident_super;
 }
 
-IdentifierInfo *Sema::getFloat128Identifier() const {
-  if (!Ident___float128)
-Ident___float128 = ("__float128");
-  return Ident___float128;
-}
-
 void Sema::PushCapturedRegionScope(Scope *S, CapturedDecl *CD, RecordDecl *RD,
CapturedRegionKind K,
unsigned OpenMPCaptureLevel) {
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -13764,7 +13764,6 @@
   Scope *CurScope;
 
   mutable IdentifierInfo *Ident_super;
-  mutable IdentifierInfo *Ident___float128;
 
   /// Nullability type specifiers.
   IdentifierInfo *Ident__Nonnull = nullptr;
@@ -13813,7 +13812,6 @@
   }
 
   IdentifierInfo *getSuperIdentifier() const;
-  IdentifierInfo *getFloat128Identifier() const;
 
   ObjCContainerDecl *getObjCDeclContext() const;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D151607: [AST] Remove unused function removeLocalCVRQualifiers

2023-05-26 Thread Kazu Hirata via Phabricator via cfe-commits
kazu created this revision.
Herald added a project: All.
kazu requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The last use was removed by:

  commit 0eb06cb3aa2700508c20da28f22ff91e7b82a436
  Author: Roy Jacobson 
  Date:   Tue Mar 14 21:25:54 2023 +0200


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151607

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


Index: clang/include/clang/AST/Type.h
===
--- clang/include/clang/AST/Type.h
+++ clang/include/clang/AST/Type.h
@@ -948,7 +948,6 @@
   void removeLocalConst();
   void removeLocalVolatile();
   void removeLocalRestrict();
-  void removeLocalCVRQualifiers(unsigned Mask);
 
   void removeLocalFastQualifiers() { Value.setInt(0); }
   void removeLocalFastQualifiers(unsigned Mask) {
@@ -6781,15 +6780,6 @@
   removeLocalFastQualifiers(Qualifiers::Volatile);
 }
 
-inline void QualType::removeLocalCVRQualifiers(unsigned Mask) {
-  assert(!(Mask & ~Qualifiers::CVRMask) && "mask has non-CVR bits");
-  static_assert((int)Qualifiers::CVRMask == (int)Qualifiers::FastMask,
-"Fast bits differ from CVR bits!");
-
-  // Fast path: we don't need to touch the slow qualifiers.
-  removeLocalFastQualifiers(Mask);
-}
-
 /// Check if this type has any address space qualifier.
 inline bool QualType::hasAddressSpace() const {
   return getQualifiers().hasAddressSpace();


Index: clang/include/clang/AST/Type.h
===
--- clang/include/clang/AST/Type.h
+++ clang/include/clang/AST/Type.h
@@ -948,7 +948,6 @@
   void removeLocalConst();
   void removeLocalVolatile();
   void removeLocalRestrict();
-  void removeLocalCVRQualifiers(unsigned Mask);
 
   void removeLocalFastQualifiers() { Value.setInt(0); }
   void removeLocalFastQualifiers(unsigned Mask) {
@@ -6781,15 +6780,6 @@
   removeLocalFastQualifiers(Qualifiers::Volatile);
 }
 
-inline void QualType::removeLocalCVRQualifiers(unsigned Mask) {
-  assert(!(Mask & ~Qualifiers::CVRMask) && "mask has non-CVR bits");
-  static_assert((int)Qualifiers::CVRMask == (int)Qualifiers::FastMask,
-"Fast bits differ from CVR bits!");
-
-  // Fast path: we don't need to touch the slow qualifiers.
-  removeLocalFastQualifiers(Mask);
-}
-
 /// Check if this type has any address space qualifier.
 inline bool QualType::hasAddressSpace() const {
   return getQualifiers().hasAddressSpace();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D150506: Migrate {starts,ends}with_insensitive to {starts,ends}_with_insensitive (NFC)

2023-05-16 Thread Kazu Hirata 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 rGed1539c6ad3d: Migrate {starts,ends}with_insensitive to 
{starts,ends}_with_insensitive (NFC) (authored by kazu).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150506

Files:
  
clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp
  clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/CompileCommands.cpp
  clang-tools-extra/clangd/InlayHints.cpp
  clang/lib/Analysis/RetainSummaryManager.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/OffloadBundler.cpp
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Format/Format.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp
  clang/lib/StaticAnalyzer/Checkers/Iterator.cpp
  clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
  lld/COFF/Driver.cpp
  lld/COFF/DriverUtils.cpp
  lld/Common/Args.cpp
  lld/ELF/ScriptParser.cpp
  lld/MinGW/Driver.cpp
  lld/tools/lld/lld.cpp

Index: lld/tools/lld/lld.cpp
===
--- lld/tools/lld/lld.cpp
+++ lld/tools/lld/lld.cpp
@@ -136,7 +136,7 @@
 
   // Deduct the flavor from argv[0].
   StringRef arg0 = path::filename(v[0]);
-  if (arg0.endswith_insensitive(".exe"))
+  if (arg0.ends_with_insensitive(".exe"))
 arg0 = arg0.drop_back(4);
   return parseProgname(arg0);
 }
Index: lld/MinGW/Driver.cpp
===
--- lld/MinGW/Driver.cpp
+++ lld/MinGW/Driver.cpp
@@ -437,7 +437,7 @@
   for (auto *a : args) {
 switch (a->getOption().getID()) {
 case OPT_INPUT:
-  if (StringRef(a->getValue()).endswith_insensitive(".def"))
+  if (StringRef(a->getValue()).ends_with_insensitive(".def"))
 add("-def:" + StringRef(a->getValue()));
   else
 add(prefix + StringRef(a->getValue()));
Index: lld/ELF/ScriptParser.cpp
===
--- lld/ELF/ScriptParser.cpp
+++ lld/ELF/ScriptParser.cpp
@@ -1228,24 +1228,24 @@
 static std::optional parseInt(StringRef tok) {
   // Hexadecimal
   uint64_t val;
-  if (tok.startswith_insensitive("0x")) {
+  if (tok.starts_with_insensitive("0x")) {
 if (!to_integer(tok.substr(2), val, 16))
   return std::nullopt;
 return val;
   }
-  if (tok.endswith_insensitive("H")) {
+  if (tok.ends_with_insensitive("H")) {
 if (!to_integer(tok.drop_back(), val, 16))
   return std::nullopt;
 return val;
   }
 
   // Decimal
-  if (tok.endswith_insensitive("K")) {
+  if (tok.ends_with_insensitive("K")) {
 if (!to_integer(tok.drop_back(), val, 10))
   return std::nullopt;
 return val * 1024;
   }
-  if (tok.endswith_insensitive("M")) {
+  if (tok.ends_with_insensitive("M")) {
 if (!to_integer(tok.drop_back(), val, 10))
   return std::nullopt;
 return val * 1024 * 1024;
Index: lld/Common/Args.cpp
===
--- lld/Common/Args.cpp
+++ lld/Common/Args.cpp
@@ -87,7 +87,7 @@
 }
 
 StringRef lld::args::getFilenameWithoutExe(StringRef path) {
-  if (path.endswith_insensitive(".exe"))
+  if (path.ends_with_insensitive(".exe"))
 return sys::path::stem(path);
   return sys::path::filename(path);
 }
Index: lld/COFF/DriverUtils.cpp
===
--- lld/COFF/DriverUtils.cpp
+++ lld/COFF/DriverUtils.cpp
@@ -270,13 +270,13 @@
 ctx.config.manifest = Configuration::No;
 return;
   }
-  if (!arg.startswith_insensitive("embed"))
+  if (!arg.starts_with_insensitive("embed"))
 fatal("invalid option " + arg);
   ctx.config.manifest = Configuration::Embed;
   arg = arg.substr(strlen("embed"));
   if (arg.empty())
 return;
-  if (!arg.startswith_insensitive(",id="))
+  if (!arg.starts_with_insensitive(",id="))
 fatal("invalid option " + arg);
   arg = arg.substr(strlen(",id="));
   if (arg.getAsInteger(0, ctx.config.manifestID))
@@ -294,12 +294,12 @@
 arg = arg.ltrim();
 if (arg.empty())
   return;
-if (arg.startswith_insensitive("level=")) {
+if (arg.starts_with_insensitive("level=")) {
   arg = arg.substr(strlen("level="));
   std::tie(ctx.config.manifestLevel, arg) = arg.split(" ");
   continue;
 }
-if (arg.startswith_insensitive("uiaccess=")) {
+if (arg.starts_with_insensitive("uiaccess=")) {
   arg = arg.substr(strlen("uiaccess="));
   std::tie(ctx.config.manifestUIAccess, arg) = arg.split(" ");
   continue;
@@ -904,14 +904,14 @@
   SmallVector tokens;
   

[PATCH] D150506: Migrate {starts,ends}with_insensitive to {starts,ends}_with_insensitive (NFC)

2023-05-13 Thread Kazu Hirata via Phabricator via cfe-commits
kazu created this revision.
Herald added subscribers: cfe-commits, PiotrZSL, luke, steakhal, carlosgalvezp, 
frasercrmck, martong, luismarques, apazos, sameer.abuasal, s.egerton, Jim, 
kadircet, jocewei, PkmX, arphaman, the_o, brucehoult, MartinMosbeck, rogfer01, 
edward-jones, zzheng, jrtc27, niosHD, sabuasal, simoncook, johnrusso, rbar, 
asb, arichardson, emaste.
Herald added a reviewer: MaskRay.
Herald added a reviewer: NoQ.
Herald added a reviewer: njames93.
Herald added projects: All, clang, clang-format.
Herald added reviewers: rymiel, HazardyKnusperkeks, owenpan, MyDeveloperDay.
kazu requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: jplehr, pcwang-thead, sstefan1.
Herald added a project: clang-tools-extra.

This patch migrates uses of StringRef::{starts,ends}with_insensitive
to StringRef::{starts,ends}_with_insensitive so that we can use names
similar to those used in std::string_view.

Note that the llvm/ directory has migrated in commit
6c3ea866e93003e16fc55d3b5cedd3bc371d1fde 
.

I'll post a separate patch to deprecate
StringRef::{starts,ends}with_insensitive.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150506

Files:
  
clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp
  clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/CompileCommands.cpp
  clang-tools-extra/clangd/InlayHints.cpp
  clang/lib/Analysis/RetainSummaryManager.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/OffloadBundler.cpp
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Format/Format.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp
  clang/lib/StaticAnalyzer/Checkers/Iterator.cpp
  clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
  lld/COFF/Driver.cpp
  lld/COFF/DriverUtils.cpp
  lld/Common/Args.cpp
  lld/ELF/ScriptParser.cpp
  lld/MinGW/Driver.cpp
  lld/tools/lld/lld.cpp

Index: lld/tools/lld/lld.cpp
===
--- lld/tools/lld/lld.cpp
+++ lld/tools/lld/lld.cpp
@@ -136,7 +136,7 @@
 
   // Deduct the flavor from argv[0].
   StringRef arg0 = path::filename(v[0]);
-  if (arg0.endswith_insensitive(".exe"))
+  if (arg0.ends_with_insensitive(".exe"))
 arg0 = arg0.drop_back(4);
   return parseProgname(arg0);
 }
Index: lld/MinGW/Driver.cpp
===
--- lld/MinGW/Driver.cpp
+++ lld/MinGW/Driver.cpp
@@ -437,7 +437,7 @@
   for (auto *a : args) {
 switch (a->getOption().getID()) {
 case OPT_INPUT:
-  if (StringRef(a->getValue()).endswith_insensitive(".def"))
+  if (StringRef(a->getValue()).ends_with_insensitive(".def"))
 add("-def:" + StringRef(a->getValue()));
   else
 add(prefix + StringRef(a->getValue()));
Index: lld/ELF/ScriptParser.cpp
===
--- lld/ELF/ScriptParser.cpp
+++ lld/ELF/ScriptParser.cpp
@@ -1227,24 +1227,24 @@
 static std::optional parseInt(StringRef tok) {
   // Hexadecimal
   uint64_t val;
-  if (tok.startswith_insensitive("0x")) {
+  if (tok.starts_with_insensitive("0x")) {
 if (!to_integer(tok.substr(2), val, 16))
   return std::nullopt;
 return val;
   }
-  if (tok.endswith_insensitive("H")) {
+  if (tok.ends_with_insensitive("H")) {
 if (!to_integer(tok.drop_back(), val, 16))
   return std::nullopt;
 return val;
   }
 
   // Decimal
-  if (tok.endswith_insensitive("K")) {
+  if (tok.ends_with_insensitive("K")) {
 if (!to_integer(tok.drop_back(), val, 10))
   return std::nullopt;
 return val * 1024;
   }
-  if (tok.endswith_insensitive("M")) {
+  if (tok.ends_with_insensitive("M")) {
 if (!to_integer(tok.drop_back(), val, 10))
   return std::nullopt;
 return val * 1024 * 1024;
Index: lld/Common/Args.cpp
===
--- lld/Common/Args.cpp
+++ lld/Common/Args.cpp
@@ -87,7 +87,7 @@
 }
 
 StringRef lld::args::getFilenameWithoutExe(StringRef path) {
-  if (path.endswith_insensitive(".exe"))
+  if (path.ends_with_insensitive(".exe"))
 return sys::path::stem(path);
   return sys::path::filename(path);
 }
Index: lld/COFF/DriverUtils.cpp
===
--- lld/COFF/DriverUtils.cpp
+++ lld/COFF/DriverUtils.cpp
@@ -270,13 +270,13 @@
 ctx.config.manifest = Configuration::No;
 return;
   }
-  if (!arg.startswith_insensitive("embed"))
+  if (!arg.starts_with_insensitive("embed"))
 fatal("invalid option " + arg);
   ctx.config.manifest = Configuration::Embed;
   arg = 

[PATCH] D146104: Use *{Map,Set}::contains (NFC)

2023-03-15 Thread Kazu Hirata 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 rG8bdf38785888: Use *{Map,Set}::contains (NFC) (authored by 
kazu).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146104

Files:
  bolt/include/bolt/Core/BinaryFunction.h
  clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
  clang/lib/AST/ASTContext.cpp
  clang/lib/Lex/Lexer.cpp
  clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
  llvm/include/llvm/Support/CommandLine.h
  llvm/lib/CodeGen/FixupStatepointCallerSaved.cpp
  llvm/lib/IR/DebugInfoMetadata.cpp
  llvm/lib/Support/CommandLine.cpp
  llvm/lib/Transforms/Scalar/GVNSink.cpp
  llvm/tools/llvm-exegesis/lib/Analysis.cpp
  llvm/utils/UnicodeData/UnicodeNameMappingGenerator.cpp
  mlir/lib/AsmParser/Parser.cpp
  mlir/lib/Dialect/GPU/TransformOps/GPUTransformOps.cpp
  mlir/lib/Dialect/SCF/Utils/AffineCanonicalizationUtils.cpp

Index: mlir/lib/Dialect/SCF/Utils/AffineCanonicalizationUtils.cpp
===
--- mlir/lib/Dialect/SCF/Utils/AffineCanonicalizationUtils.cpp
+++ mlir/lib/Dialect/SCF/Utils/AffineCanonicalizationUtils.cpp
@@ -152,7 +152,7 @@
   // Find all iteration variables among `minOp`'s operands add constrain them.
   for (Value operand : op->getOperands()) {
 // Skip duplicate ivs.
-if (llvm::is_contained(allIvs, operand))
+if (allIvs.contains(operand))
   continue;
 
 // If `operand` is an iteration variable: Find corresponding loop
Index: mlir/lib/Dialect/GPU/TransformOps/GPUTransformOps.cpp
===
--- mlir/lib/Dialect/GPU/TransformOps/GPUTransformOps.cpp
+++ mlir/lib/Dialect/GPU/TransformOps/GPUTransformOps.cpp
@@ -124,7 +124,7 @@
 
   DenseSet seen;
   for (Attribute map : forallOp.getMapping()->getValue()) {
-if (llvm::is_contained(seen, map)) {
+if (seen.contains(map)) {
   return failureHelper(transformOp, forallOp,
"duplicated attribute, cannot map different loops "
"to the same processor");
Index: mlir/lib/AsmParser/Parser.cpp
===
--- mlir/lib/AsmParser/Parser.cpp
+++ mlir/lib/AsmParser/Parser.cpp
@@ -389,7 +389,7 @@
 const char *bufBegin = state.lex.getBufferBegin();
 const char *it = loc.getPointer() - 1;
 for (; it > bufBegin && *it != '\n'; --it)
-  if (!llvm::is_contained(StringRef(" \t\r"), *it))
+  if (!StringRef(" \t\r").contains(*it))
 return true;
 return false;
   };
Index: llvm/utils/UnicodeData/UnicodeNameMappingGenerator.cpp
===
--- llvm/utils/UnicodeData/UnicodeNameMappingGenerator.cpp
+++ llvm/utils/UnicodeData/UnicodeNameMappingGenerator.cpp
@@ -361,9 +361,8 @@
 char32_t Codepoint = Entry.first;
 const std::string  = Entry.second;
 // Ignore names which are not valid.
-if (Name.empty() || !llvm::all_of(Name, [](char C) {
-  return llvm::is_contained(Letters, C);
-})) {
+if (Name.empty() ||
+!llvm::all_of(Name, [](char C) { return Letters.contains(C); })) {
   continue;
 }
 printf("%06x: %s\n", static_cast(Codepoint), Name.c_str());
Index: llvm/tools/llvm-exegesis/lib/Analysis.cpp
===
--- llvm/tools/llvm-exegesis/lib/Analysis.cpp
+++ llvm/tools/llvm-exegesis/lib/Analysis.cpp
@@ -28,7 +28,7 @@
 template  void writeEscaped(raw_ostream , const StringRef S);
 
 template <> void writeEscaped(raw_ostream , const StringRef S) {
-  if (!llvm::is_contained(S, kCsvSep)) {
+  if (!S.contains(kCsvSep)) {
 OS << S;
   } else {
 // Needs escaping.
Index: llvm/lib/Transforms/Scalar/GVNSink.cpp
===
--- llvm/lib/Transforms/Scalar/GVNSink.cpp
+++ llvm/lib/Transforms/Scalar/GVNSink.cpp
@@ -154,7 +154,7 @@
 
   void restrictToBlocks(SmallSetVector ) {
 for (auto II = Insts.begin(); II != Insts.end();) {
-  if (!llvm::is_contained(Blocks, (*II)->getParent())) {
+  if (!Blocks.contains((*II)->getParent())) {
 ActiveBlocks.remove((*II)->getParent());
 II = Insts.erase(II);
   } else {
@@ -272,7 +272,7 @@
 auto VI = Values.begin();
 while (BI != Blocks.end()) {
   assert(VI != Values.end());
-  if (!llvm::is_contained(NewBlocks, *BI)) {
+  if (!NewBlocks.contains(*BI)) {
 BI = Blocks.erase(BI);
 VI = Values.erase(VI);
   } else {
Index: llvm/lib/Support/CommandLine.cpp
===
--- llvm/lib/Support/CommandLine.cpp
+++ llvm/lib/Support/CommandLine.cpp
@@ -2757,7 +2757,7 @@
   initCommonOptions();
   auto  = 

[PATCH] D146104: Use *{Map,Set}::contains (NFC)

2023-03-14 Thread Kazu Hirata via Phabricator via cfe-commits
kazu created this revision.
Herald added subscribers: PiotrZSL, Moerafaat, zero9178, steakhal, bzcheeseman, 
ayermolo, sdasgup3, carlosgalvezp, wenzhicui, wrengr, cota, teijeong, 
rdzhabarov, tatianashp, msifontes, jurahul, Kayjukh, grosul1, martong, Joonsoo, 
liufengdb, aartbik, mgester, arpith-jacob, csigg, antiagainst, shauheen, 
rriddle, mehdi_amini, thopre, hiraditya.
Herald added a reviewer: bondhugula.
Herald added a reviewer: rafauler.
Herald added a reviewer: Amir.
Herald added a reviewer: maksfb.
Herald added a reviewer: ThomasRaoux.
Herald added a reviewer: NoQ.
Herald added a reviewer: njames93.
Herald added a project: All.
kazu requested review of this revision.
Herald added a reviewer: nicolasvasilache.
Herald added subscribers: cfe-commits, llvm-commits, yota9, 
stephenneuendorffer, nicolasvasilache.
Herald added a reviewer: herhut.
Herald added a reviewer: dcaballe.
Herald added projects: clang, MLIR, LLVM, clang-tools-extra.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146104

Files:
  bolt/include/bolt/Core/BinaryFunction.h
  clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
  clang/lib/AST/ASTContext.cpp
  clang/lib/Lex/Lexer.cpp
  clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
  llvm/include/llvm/Support/CommandLine.h
  llvm/lib/CodeGen/FixupStatepointCallerSaved.cpp
  llvm/lib/IR/DebugInfoMetadata.cpp
  llvm/lib/Support/CommandLine.cpp
  llvm/lib/Transforms/Scalar/GVNSink.cpp
  llvm/tools/llvm-exegesis/lib/Analysis.cpp
  llvm/utils/UnicodeData/UnicodeNameMappingGenerator.cpp
  mlir/lib/AsmParser/Parser.cpp
  mlir/lib/Dialect/GPU/TransformOps/GPUTransformOps.cpp
  mlir/lib/Dialect/SCF/Utils/AffineCanonicalizationUtils.cpp

Index: mlir/lib/Dialect/SCF/Utils/AffineCanonicalizationUtils.cpp
===
--- mlir/lib/Dialect/SCF/Utils/AffineCanonicalizationUtils.cpp
+++ mlir/lib/Dialect/SCF/Utils/AffineCanonicalizationUtils.cpp
@@ -152,7 +152,7 @@
   // Find all iteration variables among `minOp`'s operands add constrain them.
   for (Value operand : op->getOperands()) {
 // Skip duplicate ivs.
-if (llvm::is_contained(allIvs, operand))
+if (allIvs.contains(operand))
   continue;
 
 // If `operand` is an iteration variable: Find corresponding loop
Index: mlir/lib/Dialect/GPU/TransformOps/GPUTransformOps.cpp
===
--- mlir/lib/Dialect/GPU/TransformOps/GPUTransformOps.cpp
+++ mlir/lib/Dialect/GPU/TransformOps/GPUTransformOps.cpp
@@ -115,7 +115,7 @@
 
   DenseSet seen;
   for (Attribute map : forallOp.getMapping()->getValue()) {
-if (llvm::is_contained(seen, map)) {
+if (seen.contains(map)) {
   return failureHelper(transformOp, forallOp,
"duplicated attribute, cannot map different loops "
"to the same processor");
Index: mlir/lib/AsmParser/Parser.cpp
===
--- mlir/lib/AsmParser/Parser.cpp
+++ mlir/lib/AsmParser/Parser.cpp
@@ -389,7 +389,7 @@
 const char *bufBegin = state.lex.getBufferBegin();
 const char *it = loc.getPointer() - 1;
 for (; it > bufBegin && *it != '\n'; --it)
-  if (!llvm::is_contained(StringRef(" \t\r"), *it))
+  if (!StringRef(" \t\r").contains(*it))
 return true;
 return false;
   };
Index: llvm/utils/UnicodeData/UnicodeNameMappingGenerator.cpp
===
--- llvm/utils/UnicodeData/UnicodeNameMappingGenerator.cpp
+++ llvm/utils/UnicodeData/UnicodeNameMappingGenerator.cpp
@@ -361,9 +361,8 @@
 char32_t Codepoint = Entry.first;
 const std::string  = Entry.second;
 // Ignore names which are not valid.
-if (Name.empty() || !llvm::all_of(Name, [](char C) {
-  return llvm::is_contained(Letters, C);
-})) {
+if (Name.empty() ||
+!llvm::all_of(Name, [](char C) { return Letters.contains(C); })) {
   continue;
 }
 printf("%06x: %s\n", static_cast(Codepoint), Name.c_str());
Index: llvm/tools/llvm-exegesis/lib/Analysis.cpp
===
--- llvm/tools/llvm-exegesis/lib/Analysis.cpp
+++ llvm/tools/llvm-exegesis/lib/Analysis.cpp
@@ -28,7 +28,7 @@
 template  void writeEscaped(raw_ostream , const StringRef S);
 
 template <> void writeEscaped(raw_ostream , const StringRef S) {
-  if (!llvm::is_contained(S, kCsvSep)) {
+  if (!S.contains(kCsvSep)) {
 OS << S;
   } else {
 // Needs escaping.
Index: llvm/lib/Transforms/Scalar/GVNSink.cpp
===
--- llvm/lib/Transforms/Scalar/GVNSink.cpp
+++ llvm/lib/Transforms/Scalar/GVNSink.cpp
@@ -154,7 +154,7 @@
 
   void restrictToBlocks(SmallSetVector ) {
 for (auto II = Insts.begin(); II != Insts.end();) {
-  if (!llvm::is_contained(Blocks, (*II)->getParent())) {
+  if 

[PATCH] D142857: [clang] Remove clang::Optional

2023-01-29 Thread Kazu Hirata 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 rG125f4457a54a: [clang] Remove clang::Optional (authored by 
kazu).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142857

Files:
  clang/include/clang/Basic/LLVM.h


Index: clang/include/clang/Basic/LLVM.h
===
--- clang/include/clang/Basic/LLVM.h
+++ clang/include/clang/Basic/LLVM.h
@@ -19,9 +19,6 @@
 // dependencies.
 // Casting.h has complex templates that cannot be easily forward declared.
 #include "llvm/Support/Casting.h"
-// None.h includes an enumerator that is desired & cannot be forward declared
-// without a definition of NoneType.
-#include "llvm/ADT/None.h"
 // Add this header as a workaround to prevent `too few template arguments for
 // class template 'SmallVector'` building error with build compilers like XL.
 #include "llvm/ADT/SmallVector.h"
@@ -37,7 +34,6 @@
   template class SmallString;
   template class SmallVector;
   template class SmallVectorImpl;
-  template  using Optional = std::optional;
   template  class Expected;
 
   template
@@ -69,7 +65,6 @@
   // ADT's.
   using llvm::ArrayRef;
   using llvm::MutableArrayRef;
-  using llvm::Optional;
   using llvm::OwningArrayRef;
   using llvm::SaveAndRestore;
   using llvm::SmallString;


Index: clang/include/clang/Basic/LLVM.h
===
--- clang/include/clang/Basic/LLVM.h
+++ clang/include/clang/Basic/LLVM.h
@@ -19,9 +19,6 @@
 // dependencies.
 // Casting.h has complex templates that cannot be easily forward declared.
 #include "llvm/Support/Casting.h"
-// None.h includes an enumerator that is desired & cannot be forward declared
-// without a definition of NoneType.
-#include "llvm/ADT/None.h"
 // Add this header as a workaround to prevent `too few template arguments for
 // class template 'SmallVector'` building error with build compilers like XL.
 #include "llvm/ADT/SmallVector.h"
@@ -37,7 +34,6 @@
   template class SmallString;
   template class SmallVector;
   template class SmallVectorImpl;
-  template  using Optional = std::optional;
   template  class Expected;
 
   template
@@ -69,7 +65,6 @@
   // ADT's.
   using llvm::ArrayRef;
   using llvm::MutableArrayRef;
-  using llvm::Optional;
   using llvm::OwningArrayRef;
   using llvm::SaveAndRestore;
   using llvm::SmallString;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D142857: [clang] Remove clang::Optional

2023-01-29 Thread Kazu Hirata via Phabricator via cfe-commits
kazu created this revision.
Herald added a project: All.
kazu requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142857

Files:
  clang/include/clang/Basic/LLVM.h


Index: clang/include/clang/Basic/LLVM.h
===
--- clang/include/clang/Basic/LLVM.h
+++ clang/include/clang/Basic/LLVM.h
@@ -19,9 +19,6 @@
 // dependencies.
 // Casting.h has complex templates that cannot be easily forward declared.
 #include "llvm/Support/Casting.h"
-// None.h includes an enumerator that is desired & cannot be forward declared
-// without a definition of NoneType.
-#include "llvm/ADT/None.h"
 // Add this header as a workaround to prevent `too few template arguments for
 // class template 'SmallVector'` building error with build compilers like XL.
 #include "llvm/ADT/SmallVector.h"
@@ -37,7 +34,6 @@
   template class SmallString;
   template class SmallVector;
   template class SmallVectorImpl;
-  template  using Optional = std::optional;
   template  class Expected;
 
   template
@@ -69,7 +65,6 @@
   // ADT's.
   using llvm::ArrayRef;
   using llvm::MutableArrayRef;
-  using llvm::Optional;
   using llvm::OwningArrayRef;
   using llvm::SaveAndRestore;
   using llvm::SmallString;


Index: clang/include/clang/Basic/LLVM.h
===
--- clang/include/clang/Basic/LLVM.h
+++ clang/include/clang/Basic/LLVM.h
@@ -19,9 +19,6 @@
 // dependencies.
 // Casting.h has complex templates that cannot be easily forward declared.
 #include "llvm/Support/Casting.h"
-// None.h includes an enumerator that is desired & cannot be forward declared
-// without a definition of NoneType.
-#include "llvm/ADT/None.h"
 // Add this header as a workaround to prevent `too few template arguments for
 // class template 'SmallVector'` building error with build compilers like XL.
 #include "llvm/ADT/SmallVector.h"
@@ -37,7 +34,6 @@
   template class SmallString;
   template class SmallVector;
   template class SmallVectorImpl;
-  template  using Optional = std::optional;
   template  class Expected;
 
   template
@@ -69,7 +65,6 @@
   // ADT's.
   using llvm::ArrayRef;
   using llvm::MutableArrayRef;
-  using llvm::Optional;
   using llvm::OwningArrayRef;
   using llvm::SaveAndRestore;
   using llvm::SmallString;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141798: Drop the ZeroBehavior parameter from countLeadingZeros and the like (NFC)

2023-01-19 Thread Kazu Hirata via Phabricator via cfe-commits
kazu added a comment.

In D141798#4065025 , @RKSimon wrote:

> @kazu Thanks for dealing with this!
>
> I'd like to build on this and create llvm variants of the C++20  
> countl_zero/countr_zero/countl_one/countr_one template functions similar to 
> what I did for popcount in D132407  (and 
> have MathExtras.h reuse it) - I just wanted to ensure you hadn't already 
> started anything similar?

I just uploaded:

https://reviews.llvm.org/D142078


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141798

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


[PATCH] D141798: Drop the ZeroBehavior parameter from countLeadingZeros and the like (NFC)

2023-01-18 Thread Kazu Hirata via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
kazu marked 2 inline comments as done.
Closed by commit rG83d56fb17a4d: Drop the ZeroBehavior parameter from 
countLeadingZeros and the like (NFC) (authored by kazu).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141798

Files:
  llvm/include/llvm/Support/MathExtras.h
  llvm/lib/Target/AMDGPU/AMDGPUCallLowering.cpp
  llvm/lib/Target/AMDGPU/SIISelLowering.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVMatInt.cpp
  llvm/lib/Transforms/IPO/LowerTypeTests.cpp
  llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
  mlir/lib/Bytecode/Reader/BytecodeReader.cpp

Index: mlir/lib/Bytecode/Reader/BytecodeReader.cpp
===
--- mlir/lib/Bytecode/Reader/BytecodeReader.cpp
+++ mlir/lib/Bytecode/Reader/BytecodeReader.cpp
@@ -281,8 +281,7 @@
 // here because we only care about the first byte, and so that be actually
 // get ctz intrinsic calls when possible (the `uint8_t` overload uses a loop
 // implementation).
-uint32_t numBytes =
-llvm::countTrailingZeros(result, llvm::ZB_Undefined);
+uint32_t numBytes = llvm::countTrailingZeros(result);
 assert(numBytes > 0 && numBytes <= 7 &&
"unexpected number of trailing zeros in varint encoding");
 
Index: llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
===
--- llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
+++ llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
@@ -259,8 +259,7 @@
 if (I < B.size())
   BitsUsed |= B[I];
   if (BitsUsed != 0xff)
-return (MinByte + I) * 8 +
-   countTrailingZeros(uint8_t(~BitsUsed), ZB_Undefined);
+return (MinByte + I) * 8 + countTrailingZeros(uint8_t(~BitsUsed));
 }
   } else {
 // Find a free (Size/8) byte region in each member of Used.
Index: llvm/lib/Transforms/IPO/LowerTypeTests.cpp
===
--- llvm/lib/Transforms/IPO/LowerTypeTests.cpp
+++ llvm/lib/Transforms/IPO/LowerTypeTests.cpp
@@ -172,7 +172,7 @@
 
   BSI.AlignLog2 = 0;
   if (Mask != 0)
-BSI.AlignLog2 = countTrailingZeros(Mask, ZB_Undefined);
+BSI.AlignLog2 = countTrailingZeros(Mask);
 
   // Build the compressed bitset while normalizing the offsets against the
   // computed alignment.
Index: llvm/lib/Target/RISCV/MCTargetDesc/RISCVMatInt.cpp
===
--- llvm/lib/Target/RISCV/MCTargetDesc/RISCVMatInt.cpp
+++ llvm/lib/Target/RISCV/MCTargetDesc/RISCVMatInt.cpp
@@ -180,7 +180,7 @@
   // or ADDIW. If there are trailing zeros, try generating a sign extended
   // constant with no trailing zeros and use a final SLLI to restore them.
   if ((Val & 0xfff) != 0 && (Val & 1) == 0 && Res.size() >= 2) {
-unsigned TrailingZeros = countTrailingZeros((uint64_t)Val, ZB_Undefined);
+unsigned TrailingZeros = countTrailingZeros((uint64_t)Val);
 int64_t ShiftedVal = Val >> TrailingZeros;
 // If we can use C.LI+C.SLLI instead of LUI+ADDI(W) prefer that since
 // its more compressible. But only if LUI+ADDI(W) isn't fusable.
@@ -202,7 +202,7 @@
   if (Val > 0 && Res.size() > 2) {
 assert(ActiveFeatures[RISCV::Feature64Bit] &&
"Expected RV32 to only need 2 instructions");
-unsigned LeadingZeros = countLeadingZeros((uint64_t)Val, ZB_Undefined);
+unsigned LeadingZeros = countLeadingZeros((uint64_t)Val);
 uint64_t ShiftedVal = (uint64_t)Val << LeadingZeros;
 // Fill in the bits that will be shifted out with 1s. An example where this
 // helps is trailing one masks with 32 or more ones. This will generate
Index: llvm/lib/Target/AMDGPU/SIISelLowering.cpp
===
--- llvm/lib/Target/AMDGPU/SIISelLowering.cpp
+++ llvm/lib/Target/AMDGPU/SIISelLowering.cpp
@@ -2451,8 +2451,7 @@
   unsigned PsInputBits = Info->getPSInputAddr() & Info->getPSInputEnable();
   if ((PsInputBits & 0x7F) == 0 ||
   ((PsInputBits & 0xF) == 0 && (PsInputBits >> 11 & 1)))
-Info->markPSInputEnabled(
-countTrailingZeros(Info->getPSInputAddr(), ZB_Undefined));
+Info->markPSInputEnabled(countTrailingZeros(Info->getPSInputAddr()));
 }
   } else if (IsKernel) {
 assert(Info->hasWorkGroupIDX() && Info->hasWorkItemIDX());
Index: llvm/lib/Target/AMDGPU/AMDGPUCallLowering.cpp
===
--- llvm/lib/Target/AMDGPU/AMDGPUCallLowering.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPUCallLowering.cpp
@@ -701,8 +701,7 @@
   if ((PsInputBits & 0x7F) == 0 ||
   ((PsInputBits & 0xF) == 0 &&
(PsInputBits >> 11 & 1)))
-Info->markPSInputEnabled(
-  

[PATCH] D141798: Drop the ZeroBehavior parameter from countLeadingZeros and the like (NFC)

2023-01-18 Thread Kazu Hirata via Phabricator via cfe-commits
kazu marked an inline comment as done.
kazu added inline comments.



Comment at: llvm/include/llvm/Support/MathExtras.h:225
 ///
 /// \param ZB the behavior on an input of 0. Only ZB_Max and ZB_Undefined are
 ///   valid arguments.

jrtc27 wrote:
> A bunch of functions still have this documentation, but these are now the 
> only possible values, so this seems redundant
I've adjusted the redundant comments on two functions - `findFirstSet` and 
`findLastSet`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141798

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


[PATCH] D141798: Drop the ZeroBehavior parameter from countLeadingZeros and the like (NFC)

2023-01-18 Thread Kazu Hirata via Phabricator via cfe-commits
kazu updated this revision to Diff 490363.
kazu added a comment.

I've adjusted comments for findFirstSet and findLastSet to reflect the
fact that ZeroBehavior now takes only two values -- ZB_Undefined and
ZB_Max.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141798

Files:
  llvm/include/llvm/Support/MathExtras.h
  llvm/lib/Target/AMDGPU/AMDGPUCallLowering.cpp
  llvm/lib/Target/AMDGPU/SIISelLowering.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVMatInt.cpp
  llvm/lib/Transforms/IPO/LowerTypeTests.cpp
  llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
  mlir/lib/Bytecode/Reader/BytecodeReader.cpp

Index: mlir/lib/Bytecode/Reader/BytecodeReader.cpp
===
--- mlir/lib/Bytecode/Reader/BytecodeReader.cpp
+++ mlir/lib/Bytecode/Reader/BytecodeReader.cpp
@@ -281,8 +281,7 @@
 // here because we only care about the first byte, and so that be actually
 // get ctz intrinsic calls when possible (the `uint8_t` overload uses a loop
 // implementation).
-uint32_t numBytes =
-llvm::countTrailingZeros(result, llvm::ZB_Undefined);
+uint32_t numBytes = llvm::countTrailingZeros(result);
 assert(numBytes > 0 && numBytes <= 7 &&
"unexpected number of trailing zeros in varint encoding");
 
Index: llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
===
--- llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
+++ llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
@@ -259,8 +259,7 @@
 if (I < B.size())
   BitsUsed |= B[I];
   if (BitsUsed != 0xff)
-return (MinByte + I) * 8 +
-   countTrailingZeros(uint8_t(~BitsUsed), ZB_Undefined);
+return (MinByte + I) * 8 + countTrailingZeros(uint8_t(~BitsUsed));
 }
   } else {
 // Find a free (Size/8) byte region in each member of Used.
Index: llvm/lib/Transforms/IPO/LowerTypeTests.cpp
===
--- llvm/lib/Transforms/IPO/LowerTypeTests.cpp
+++ llvm/lib/Transforms/IPO/LowerTypeTests.cpp
@@ -172,7 +172,7 @@
 
   BSI.AlignLog2 = 0;
   if (Mask != 0)
-BSI.AlignLog2 = countTrailingZeros(Mask, ZB_Undefined);
+BSI.AlignLog2 = countTrailingZeros(Mask);
 
   // Build the compressed bitset while normalizing the offsets against the
   // computed alignment.
Index: llvm/lib/Target/RISCV/MCTargetDesc/RISCVMatInt.cpp
===
--- llvm/lib/Target/RISCV/MCTargetDesc/RISCVMatInt.cpp
+++ llvm/lib/Target/RISCV/MCTargetDesc/RISCVMatInt.cpp
@@ -180,7 +180,7 @@
   // or ADDIW. If there are trailing zeros, try generating a sign extended
   // constant with no trailing zeros and use a final SLLI to restore them.
   if ((Val & 0xfff) != 0 && (Val & 1) == 0 && Res.size() >= 2) {
-unsigned TrailingZeros = countTrailingZeros((uint64_t)Val, ZB_Undefined);
+unsigned TrailingZeros = countTrailingZeros((uint64_t)Val);
 int64_t ShiftedVal = Val >> TrailingZeros;
 // If we can use C.LI+C.SLLI instead of LUI+ADDI(W) prefer that since
 // its more compressible. But only if LUI+ADDI(W) isn't fusable.
@@ -202,7 +202,7 @@
   if (Val > 0 && Res.size() > 2) {
 assert(ActiveFeatures[RISCV::Feature64Bit] &&
"Expected RV32 to only need 2 instructions");
-unsigned LeadingZeros = countLeadingZeros((uint64_t)Val, ZB_Undefined);
+unsigned LeadingZeros = countLeadingZeros((uint64_t)Val);
 uint64_t ShiftedVal = (uint64_t)Val << LeadingZeros;
 // Fill in the bits that will be shifted out with 1s. An example where this
 // helps is trailing one masks with 32 or more ones. This will generate
Index: llvm/lib/Target/AMDGPU/SIISelLowering.cpp
===
--- llvm/lib/Target/AMDGPU/SIISelLowering.cpp
+++ llvm/lib/Target/AMDGPU/SIISelLowering.cpp
@@ -2451,8 +2451,7 @@
   unsigned PsInputBits = Info->getPSInputAddr() & Info->getPSInputEnable();
   if ((PsInputBits & 0x7F) == 0 ||
   ((PsInputBits & 0xF) == 0 && (PsInputBits >> 11 & 1)))
-Info->markPSInputEnabled(
-countTrailingZeros(Info->getPSInputAddr(), ZB_Undefined));
+Info->markPSInputEnabled(countTrailingZeros(Info->getPSInputAddr()));
 }
   } else if (IsKernel) {
 assert(Info->hasWorkGroupIDX() && Info->hasWorkItemIDX());
Index: llvm/lib/Target/AMDGPU/AMDGPUCallLowering.cpp
===
--- llvm/lib/Target/AMDGPU/AMDGPUCallLowering.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPUCallLowering.cpp
@@ -701,8 +701,7 @@
   if ((PsInputBits & 0x7F) == 0 ||
   ((PsInputBits & 0xF) == 0 &&
(PsInputBits >> 11 & 1)))
-Info->markPSInputEnabled(
-  countTrailingZeros(Info->getPSInputAddr(), ZB_Undefined));
+

[PATCH] D141798: Drop the ZeroBehavior parameter from countLeadingZeros and the like (NFC)

2023-01-18 Thread Kazu Hirata via Phabricator via cfe-commits
kazu marked an inline comment as done.
kazu added a comment.

Please take a look.  Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141798

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


[PATCH] D141798: Remove ZeroBehavior of countLeadingZeros and the like (NFC)

2023-01-18 Thread Kazu Hirata via Phabricator via cfe-commits
kazu marked an inline comment as done.
kazu added a comment.

In D141798#4055050 , @barannikov88 
wrote:

> It would be nice to have comments reflecting the new behavior in the case of 
> 0 / max value.

I've added comments to all four functions -- 
count{Leading,Trailing}{Zeros,Ones}.




Comment at: llvm/include/llvm/Support/MathExtras.h:212
 /// Only unsigned integral types are allowed.
-///
-/// \param ZB the behavior on an input of 0. Only ZB_Max and ZB_Undefined are
-///   valid arguments.
-template  T findFirstSet(T Val, ZeroBehavior ZB = ZB_Max) {
-  if (ZB == ZB_Max && Val == 0)
+template  T findFirstSet(T Val) {
+  if (Val == 0)

craig.topper wrote:
> Note, x86 does not have an efficient instruction for find first set with zero 
> returning -1. It will require a cmov to handle zero.
The new iteration of the patch leaves findFirstSet and findLastSet untouched.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141798

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


[PATCH] D141798: Remove ZeroBehavior of countLeadingZeros and the like (NFC)

2023-01-18 Thread Kazu Hirata via Phabricator via cfe-commits
kazu updated this revision to Diff 490348.
kazu added a comment.

Updated the patch to leave findFirstSet and findLastSet untouched.

Added a comment about the behavior on 0/max input.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141798

Files:
  llvm/include/llvm/Support/MathExtras.h
  llvm/lib/Target/AMDGPU/AMDGPUCallLowering.cpp
  llvm/lib/Target/AMDGPU/SIISelLowering.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVMatInt.cpp
  llvm/lib/Transforms/IPO/LowerTypeTests.cpp
  llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
  mlir/lib/Bytecode/Reader/BytecodeReader.cpp

Index: mlir/lib/Bytecode/Reader/BytecodeReader.cpp
===
--- mlir/lib/Bytecode/Reader/BytecodeReader.cpp
+++ mlir/lib/Bytecode/Reader/BytecodeReader.cpp
@@ -281,8 +281,7 @@
 // here because we only care about the first byte, and so that be actually
 // get ctz intrinsic calls when possible (the `uint8_t` overload uses a loop
 // implementation).
-uint32_t numBytes =
-llvm::countTrailingZeros(result, llvm::ZB_Undefined);
+uint32_t numBytes = llvm::countTrailingZeros(result);
 assert(numBytes > 0 && numBytes <= 7 &&
"unexpected number of trailing zeros in varint encoding");
 
Index: llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
===
--- llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
+++ llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
@@ -259,8 +259,7 @@
 if (I < B.size())
   BitsUsed |= B[I];
   if (BitsUsed != 0xff)
-return (MinByte + I) * 8 +
-   countTrailingZeros(uint8_t(~BitsUsed), ZB_Undefined);
+return (MinByte + I) * 8 + countTrailingZeros(uint8_t(~BitsUsed));
 }
   } else {
 // Find a free (Size/8) byte region in each member of Used.
Index: llvm/lib/Transforms/IPO/LowerTypeTests.cpp
===
--- llvm/lib/Transforms/IPO/LowerTypeTests.cpp
+++ llvm/lib/Transforms/IPO/LowerTypeTests.cpp
@@ -172,7 +172,7 @@
 
   BSI.AlignLog2 = 0;
   if (Mask != 0)
-BSI.AlignLog2 = countTrailingZeros(Mask, ZB_Undefined);
+BSI.AlignLog2 = countTrailingZeros(Mask);
 
   // Build the compressed bitset while normalizing the offsets against the
   // computed alignment.
Index: llvm/lib/Target/RISCV/MCTargetDesc/RISCVMatInt.cpp
===
--- llvm/lib/Target/RISCV/MCTargetDesc/RISCVMatInt.cpp
+++ llvm/lib/Target/RISCV/MCTargetDesc/RISCVMatInt.cpp
@@ -180,7 +180,7 @@
   // or ADDIW. If there are trailing zeros, try generating a sign extended
   // constant with no trailing zeros and use a final SLLI to restore them.
   if ((Val & 0xfff) != 0 && (Val & 1) == 0 && Res.size() >= 2) {
-unsigned TrailingZeros = countTrailingZeros((uint64_t)Val, ZB_Undefined);
+unsigned TrailingZeros = countTrailingZeros((uint64_t)Val);
 int64_t ShiftedVal = Val >> TrailingZeros;
 // If we can use C.LI+C.SLLI instead of LUI+ADDI(W) prefer that since
 // its more compressible. But only if LUI+ADDI(W) isn't fusable.
@@ -202,7 +202,7 @@
   if (Val > 0 && Res.size() > 2) {
 assert(ActiveFeatures[RISCV::Feature64Bit] &&
"Expected RV32 to only need 2 instructions");
-unsigned LeadingZeros = countLeadingZeros((uint64_t)Val, ZB_Undefined);
+unsigned LeadingZeros = countLeadingZeros((uint64_t)Val);
 uint64_t ShiftedVal = (uint64_t)Val << LeadingZeros;
 // Fill in the bits that will be shifted out with 1s. An example where this
 // helps is trailing one masks with 32 or more ones. This will generate
Index: llvm/lib/Target/AMDGPU/SIISelLowering.cpp
===
--- llvm/lib/Target/AMDGPU/SIISelLowering.cpp
+++ llvm/lib/Target/AMDGPU/SIISelLowering.cpp
@@ -2451,8 +2451,7 @@
   unsigned PsInputBits = Info->getPSInputAddr() & Info->getPSInputEnable();
   if ((PsInputBits & 0x7F) == 0 ||
   ((PsInputBits & 0xF) == 0 && (PsInputBits >> 11 & 1)))
-Info->markPSInputEnabled(
-countTrailingZeros(Info->getPSInputAddr(), ZB_Undefined));
+Info->markPSInputEnabled(countTrailingZeros(Info->getPSInputAddr()));
 }
   } else if (IsKernel) {
 assert(Info->hasWorkGroupIDX() && Info->hasWorkItemIDX());
Index: llvm/lib/Target/AMDGPU/AMDGPUCallLowering.cpp
===
--- llvm/lib/Target/AMDGPU/AMDGPUCallLowering.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPUCallLowering.cpp
@@ -701,8 +701,7 @@
   if ((PsInputBits & 0x7F) == 0 ||
   ((PsInputBits & 0xF) == 0 &&
(PsInputBits >> 11 & 1)))
-Info->markPSInputEnabled(
-  countTrailingZeros(Info->getPSInputAddr(), ZB_Undefined));
+

[PATCH] D141798: Remove ZeroBehavior of countLeadingZeros and the like (NFC)

2023-01-15 Thread Kazu Hirata via Phabricator via cfe-commits
kazu created this revision.
Herald added subscribers: Moerafaat, zero9178, bzcheeseman, kosarev, sdasgup3, 
wenzhicui, wrengr, ormris, foad, cota, teijeong, frasercrmck, rdzhabarov, 
tatianashp, msifontes, jurahul, Kayjukh, grosul1, Joonsoo, kerbowa, liufengdb, 
aartbik, mgester, arpith-jacob, csigg, antiagainst, shauheen, rriddle, 
mehdi_amini, luismarques, apazos, sameer.abuasal, pengfei, s.egerton, Jim, 
jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, 
zzheng, jrtc27, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, hiraditya, 
arichardson, jvesely, arsenm.
Herald added a project: All.
kazu requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, pcwang-thead, 
stephenneuendorffer, nicolasvasilache, MaskRay.
Herald added projects: clang, MLIR, LLVM.

This patch removes ZeroBehavior from bit counting functions like
countLeadingZeros and findFirstSet.  ZeroBehavior specifies the
behavior when the input to count{Leading,Trailing}Zeros is zero and
when the input to count{Leading,Trailing}Ones is all ones.

ZeroBehavior was first introduced on May 24, 2013 in commit
eb91eac9fb866ab1243366d2e238b9961895612d.  While that patch did not
state the intention, I would guess ZeroBehavior was for performance
reasons.  The x86 machines around that time required a conditional
branch to implement countLeadingZero that returns the
std::numeric_limits::digits on zero:

  testedi, edi
  je  .LBB0_2
  bsr eax, edi
  xor eax, 31

.LBB1_2:

  mov eax, 32

That is, we can remove the conditional branch if we don't care about
the behavior on zero.

IIUC, Intel's Haswell architecture, launched on June 4, 2013,
introduced several bit manipulation instructions, including lzcnt and
tzcnt, which eliminated the need for the conditional branch.

I think it's time to retire ZeroBehavior as its utility is very
limited.  If you care about compilation speed, you should build LLVM
with an appropriate -march= to take advantage of lzcnt and tzcnt.
Even if not, modern host compilers should be able to optimize away
quite a few conditional branches because the input is often known to
be nonzero from dominating conditional branches.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141798

Files:
  clang/lib/CodeGen/SwiftCallingConv.cpp
  llvm/include/llvm/Support/MathExtras.h
  llvm/lib/Target/AMDGPU/AMDGPUCallLowering.cpp
  llvm/lib/Target/AMDGPU/SIISelLowering.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVMatInt.cpp
  llvm/lib/Transforms/IPO/LowerTypeTests.cpp
  llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
  mlir/lib/Bytecode/Reader/BytecodeReader.cpp

Index: mlir/lib/Bytecode/Reader/BytecodeReader.cpp
===
--- mlir/lib/Bytecode/Reader/BytecodeReader.cpp
+++ mlir/lib/Bytecode/Reader/BytecodeReader.cpp
@@ -281,8 +281,7 @@
 // here because we only care about the first byte, and so that be actually
 // get ctz intrinsic calls when possible (the `uint8_t` overload uses a loop
 // implementation).
-uint32_t numBytes =
-llvm::countTrailingZeros(result, llvm::ZB_Undefined);
+uint32_t numBytes = llvm::countTrailingZeros(result);
 assert(numBytes > 0 && numBytes <= 7 &&
"unexpected number of trailing zeros in varint encoding");
 
Index: llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
===
--- llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
+++ llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
@@ -259,8 +259,7 @@
 if (I < B.size())
   BitsUsed |= B[I];
   if (BitsUsed != 0xff)
-return (MinByte + I) * 8 +
-   countTrailingZeros(uint8_t(~BitsUsed), ZB_Undefined);
+return (MinByte + I) * 8 + countTrailingZeros(uint8_t(~BitsUsed));
 }
   } else {
 // Find a free (Size/8) byte region in each member of Used.
Index: llvm/lib/Transforms/IPO/LowerTypeTests.cpp
===
--- llvm/lib/Transforms/IPO/LowerTypeTests.cpp
+++ llvm/lib/Transforms/IPO/LowerTypeTests.cpp
@@ -172,7 +172,7 @@
 
   BSI.AlignLog2 = 0;
   if (Mask != 0)
-BSI.AlignLog2 = countTrailingZeros(Mask, ZB_Undefined);
+BSI.AlignLog2 = countTrailingZeros(Mask);
 
   // Build the compressed bitset while normalizing the offsets against the
   // computed alignment.
Index: llvm/lib/Target/RISCV/MCTargetDesc/RISCVMatInt.cpp
===
--- llvm/lib/Target/RISCV/MCTargetDesc/RISCVMatInt.cpp
+++ llvm/lib/Target/RISCV/MCTargetDesc/RISCVMatInt.cpp
@@ -111,7 +111,7 @@
 
   // Val might now be valid for LUI without needing a shift.
   if (!isInt<32>(Val)) {
-ShiftAmount = findFirstSet((uint64_t)Val, ZB_Undefined);
+ShiftAmount = findFirstSet((uint64_t)Val);
 Val >>= ShiftAmount;
 
 // If the remaining bits don't fit in 12 bits, we might be able to reduce the
@@ 

[PATCH] D140332: [ADT] Alias llvm::Optional to std::optional

2022-12-20 Thread Kazu Hirata via Phabricator via cfe-commits
kazu added a comment.

Thank you for this patch!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140332

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


[PATCH] D139229: Use CTAD on llvm::SaveAndRestore

2022-12-02 Thread Kazu Hirata via Phabricator via cfe-commits
kazu added a comment.

In D139229#3967666 , @jansvoboda11 
wrote:

> Sorry for the noise, didn't realize this will trigger Herald rules. Wanted to 
> check with @kazu if this looks fine in principle and if it should be split up 
> into multiple commits (e.g. per project).

I'm personally OK with one giant patch if it is purely mechanical.

I am OK with CTAD also.  IIUC, CTAD variables are sort of the best of both 
worlds -- `auto` and fully-specified types like `SaveRestore`.  It's a 
bit more descriptive than `auto` but less verbose than fully-specified types.

@MaskRay @dblaikie Any thoughts?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139229

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


[PATCH] D138539: Use std::nullopt_t instead of NoneType (NFC)

2022-11-23 Thread Kazu Hirata 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 rG34bcadc38c22: Use std::nullopt_t instead of NoneType (NFC) 
(authored by kazu).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138539

Files:
  bolt/lib/Profile/DataAggregator.cpp
  bolt/lib/Profile/YAMLProfileWriter.cpp
  clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
  clang-tools-extra/clangd/support/ThreadsafeFS.h
  clang/include/clang/Analysis/Analyses/PostOrderCFGView.h
  clang/include/clang/Basic/DirectoryEntry.h
  clang/include/clang/Basic/FileEntry.h
  clang/include/clang/Sema/Template.h
  clang/lib/AST/ExprConstant.cpp
  clang/lib/Tooling/Transformer/Parsing.cpp
  lldb/include/lldb/Utility/Timeout.h
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
  llvm/include/llvm/ADT/ArrayRef.h
  llvm/include/llvm/ADT/Optional.h
  llvm/include/llvm/ADT/StringMapEntry.h
  llvm/include/llvm/ADT/StringSet.h
  llvm/include/llvm/FuzzMutate/OpDescriptor.h
  llvm/include/llvm/Support/SMLoc.h
  llvm/lib/CodeGen/MIRParser/MILexer.cpp
  llvm/lib/Support/Optional.cpp
  mlir/include/mlir/IR/OpDefinition.h
  mlir/include/mlir/IR/OperationSupport.h
  mlir/include/mlir/Support/Timing.h
  mlir/lib/Support/Timing.cpp

Index: mlir/lib/Support/Timing.cpp
===
--- mlir/lib/Support/Timing.cpp
+++ mlir/lib/Support/Timing.cpp
@@ -50,7 +50,7 @@
   llvm::sys::SmartRWMutex identifierMutex;
 
   /// A thread local cache of identifiers to reduce lock contention.
-  ThreadLocalCache *>>
+  ThreadLocalCache *>>
   localIdentifierCache;
 
   TimingManagerImpl() : identifiers(identifierAllocator) {}
Index: mlir/include/mlir/Support/Timing.h
===
--- mlir/include/mlir/Support/Timing.h
+++ mlir/include/mlir/Support/Timing.h
@@ -43,7 +43,7 @@
 /// This is a POD type with pointer size, so it should be passed around by
 /// value. The underlying data is owned by the `TimingManager`.
 class TimingIdentifier {
-  using EntryType = llvm::StringMapEntry;
+  using EntryType = llvm::StringMapEntry;
 
 public:
   TimingIdentifier(const TimingIdentifier &) = default;
Index: mlir/include/mlir/IR/OperationSupport.h
===
--- mlir/include/mlir/IR/OperationSupport.h
+++ mlir/include/mlir/IR/OperationSupport.h
@@ -490,7 +490,7 @@
   using size_type = size_t;
 
   NamedAttrList() : dictionarySorted({}, true) {}
-  NamedAttrList(llvm::NoneType none) : NamedAttrList() {}
+  NamedAttrList(std::nullopt_t none) : NamedAttrList() {}
   NamedAttrList(ArrayRef attributes);
   NamedAttrList(DictionaryAttr attributes);
   NamedAttrList(const_iterator inStart, const_iterator inEnd);
@@ -759,7 +759,7 @@
 class OpPrintingFlags {
 public:
   OpPrintingFlags();
-  OpPrintingFlags(llvm::NoneType) : OpPrintingFlags() {}
+  OpPrintingFlags(std::nullopt_t) : OpPrintingFlags() {}
 
   /// Enables the elision of large elements attributes by printing a lexically
   /// valid but otherwise meaningless form instead of the element data. The
Index: mlir/include/mlir/IR/OpDefinition.h
===
--- mlir/include/mlir/IR/OpDefinition.h
+++ mlir/include/mlir/IR/OpDefinition.h
@@ -41,7 +41,7 @@
   OptionalParseResult(ParseResult result) : impl(result) {}
   OptionalParseResult(const InFlightDiagnostic &)
   : OptionalParseResult(failure()) {}
-  OptionalParseResult(llvm::NoneType) : impl(llvm::None) {}
+  OptionalParseResult(std::nullopt_t) : impl(llvm::None) {}
 
   /// Returns true if we contain a valid ParseResult value.
   bool has_value() const { return impl.has_value(); }
Index: llvm/lib/Support/Optional.cpp
===
--- llvm/lib/Support/Optional.cpp
+++ llvm/lib/Support/Optional.cpp
@@ -9,6 +9,6 @@
 #include "llvm/ADT/Optional.h"
 #include "llvm/Support/raw_ostream.h"
 
-llvm::raw_ostream ::operator<<(raw_ostream , NoneType) {
+llvm::raw_ostream ::operator<<(raw_ostream , std::nullopt_t) {
   return OS << "None";
 }
Index: llvm/lib/CodeGen/MIRParser/MILexer.cpp
===
--- llvm/lib/CodeGen/MIRParser/MILexer.cpp
+++ llvm/lib/CodeGen/MIRParser/MILexer.cpp
@@ -33,7 +33,7 @@
   const char *End = nullptr;
 
 public:
-  Cursor(NoneType) {}
+  Cursor(std::nullopt_t) {}
 
   explicit Cursor(StringRef Str) {
 Ptr = Str.data();
Index: llvm/include/llvm/Support/SMLoc.h
===
--- llvm/include/llvm/Support/SMLoc.h
+++ llvm/include/llvm/Support/SMLoc.h
@@ -50,7 +50,7 @@
   SMLoc Start, End;
 
   SMRange() = default;
-  SMRange(NoneType) {}
+  

[PATCH] D138539: Use std::nullopt_t instead of NoneType (NFC)

2022-11-22 Thread Kazu Hirata via Phabricator via cfe-commits
kazu created this revision.
Herald added subscribers: Moerafaat, zero9178, bzcheeseman, ayermolo, sdasgup3, 
carlosgalvezp, wenzhicui, wrengr, cota, teijeong, rdzhabarov, tatianashp, 
msifontes, jurahul, Kayjukh, grosul1, Joonsoo, liufengdb, aartbik, mgester, 
arpith-jacob, antiagainst, shauheen, rriddle, mehdi_amini, kadircet, arphaman, 
hiraditya.
Herald added a reviewer: rriddle.
Herald added a reviewer: rafauler.
Herald added a reviewer: Amir.
Herald added a reviewer: maksfb.
Herald added a reviewer: NoQ.
Herald added a reviewer: njames93.
Herald added a project: All.
kazu requested review of this revision.
Herald added subscribers: cfe-commits, llvm-commits, lldb-commits, yota9, 
stephenneuendorffer, nicolasvasilache.
Herald added projects: clang, LLDB, MLIR, LLVM, clang-tools-extra.

This patch replaces those occurrences of NoneType that would trigger
an error if the definition of NoneType were missing in None.h.

To keep this patch focused, I am deliberately not replacing None with
std::nullopt in this patch or updating comments.  They will be
addressed in subsequent patches.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D138539

Files:
  bolt/lib/Profile/DataAggregator.cpp
  bolt/lib/Profile/YAMLProfileWriter.cpp
  clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
  clang-tools-extra/clangd/support/ThreadsafeFS.h
  clang/include/clang/Analysis/Analyses/PostOrderCFGView.h
  clang/include/clang/Basic/DirectoryEntry.h
  clang/include/clang/Basic/FileEntry.h
  clang/include/clang/Sema/Template.h
  clang/lib/AST/ExprConstant.cpp
  clang/lib/Tooling/Transformer/Parsing.cpp
  lldb/include/lldb/Utility/Timeout.h
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
  llvm/include/llvm/ADT/ArrayRef.h
  llvm/include/llvm/ADT/Optional.h
  llvm/include/llvm/ADT/StringMapEntry.h
  llvm/include/llvm/ADT/StringSet.h
  llvm/include/llvm/FuzzMutate/OpDescriptor.h
  llvm/include/llvm/Support/SMLoc.h
  llvm/lib/CodeGen/MIRParser/MILexer.cpp
  llvm/lib/Support/Optional.cpp
  mlir/include/mlir/IR/OpDefinition.h
  mlir/include/mlir/IR/OperationSupport.h
  mlir/include/mlir/Support/Timing.h
  mlir/lib/Support/Timing.cpp

Index: mlir/lib/Support/Timing.cpp
===
--- mlir/lib/Support/Timing.cpp
+++ mlir/lib/Support/Timing.cpp
@@ -50,7 +50,7 @@
   llvm::sys::SmartRWMutex identifierMutex;
 
   /// A thread local cache of identifiers to reduce lock contention.
-  ThreadLocalCache *>>
+  ThreadLocalCache *>>
   localIdentifierCache;
 
   TimingManagerImpl() : identifiers(identifierAllocator) {}
Index: mlir/include/mlir/Support/Timing.h
===
--- mlir/include/mlir/Support/Timing.h
+++ mlir/include/mlir/Support/Timing.h
@@ -43,7 +43,7 @@
 /// This is a POD type with pointer size, so it should be passed around by
 /// value. The underlying data is owned by the `TimingManager`.
 class TimingIdentifier {
-  using EntryType = llvm::StringMapEntry;
+  using EntryType = llvm::StringMapEntry;
 
 public:
   TimingIdentifier(const TimingIdentifier &) = default;
Index: mlir/include/mlir/IR/OperationSupport.h
===
--- mlir/include/mlir/IR/OperationSupport.h
+++ mlir/include/mlir/IR/OperationSupport.h
@@ -490,7 +490,7 @@
   using size_type = size_t;
 
   NamedAttrList() : dictionarySorted({}, true) {}
-  NamedAttrList(llvm::NoneType none) : NamedAttrList() {}
+  NamedAttrList(std::nullopt_t none) : NamedAttrList() {}
   NamedAttrList(ArrayRef attributes);
   NamedAttrList(DictionaryAttr attributes);
   NamedAttrList(const_iterator inStart, const_iterator inEnd);
@@ -759,7 +759,7 @@
 class OpPrintingFlags {
 public:
   OpPrintingFlags();
-  OpPrintingFlags(llvm::NoneType) : OpPrintingFlags() {}
+  OpPrintingFlags(std::nullopt_t) : OpPrintingFlags() {}
 
   /// Enables the elision of large elements attributes by printing a lexically
   /// valid but otherwise meaningless form instead of the element data. The
Index: mlir/include/mlir/IR/OpDefinition.h
===
--- mlir/include/mlir/IR/OpDefinition.h
+++ mlir/include/mlir/IR/OpDefinition.h
@@ -41,7 +41,7 @@
   OptionalParseResult(ParseResult result) : impl(result) {}
   OptionalParseResult(const InFlightDiagnostic &)
   : OptionalParseResult(failure()) {}
-  OptionalParseResult(llvm::NoneType) : impl(llvm::None) {}
+  OptionalParseResult(std::nullopt_t) : impl(llvm::None) {}
 
   /// Returns true if we contain a valid ParseResult value.
   bool has_value() const { return impl.has_value(); }
Index: llvm/lib/Support/Optional.cpp

[PATCH] D138464: Return None instead of Optional() (NFC)

2022-11-21 Thread Kazu Hirata 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 rG6ba4b62af8df: Return None instead of OptionalT() 
(NFC) (authored by kazu).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138464

Files:
  clang/include/clang/AST/ASTImporterSharedState.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/ASTMatchers/Dynamic/Parser.cpp
  clang/lib/ASTMatchers/Dynamic/VariantValue.cpp
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/Driver/ToolChains/AVR.cpp
  clang/lib/Driver/ToolChains/Arch/CSKY.cpp
  llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
  llvm/lib/CodeGen/SelectOptimize.cpp
  llvm/lib/DebugInfo/PDB/DIA/DIADataStream.cpp
  llvm/lib/IR/BasicBlock.cpp
  llvm/lib/LineEditor/LineEditor.cpp
  llvm/lib/MC/MCSubtargetInfo.cpp
  llvm/lib/Object/Archive.cpp
  llvm/lib/Support/Z3Solver.cpp
  llvm/lib/TableGen/Record.cpp
  llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
  llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp
  llvm/lib/Target/PowerPC/PPCFastISel.cpp
  llvm/lib/Target/WebAssembly/Utils/WebAssemblyTypeUtilities.cpp
  mlir/lib/Dialect/Vector/Transforms/VectorTransforms.cpp
  mlir/lib/Dialect/Vector/Utils/VectorUtils.cpp

Index: mlir/lib/Dialect/Vector/Utils/VectorUtils.cpp
===
--- mlir/lib/Dialect/Vector/Utils/VectorUtils.cpp
+++ mlir/lib/Dialect/Vector/Utils/VectorUtils.cpp
@@ -77,7 +77,7 @@
 Optional> mlir::shapeRatio(ArrayRef superShape,
ArrayRef subShape) {
   if (superShape.size() < subShape.size()) {
-return Optional>();
+return None;
   }
 
   // Starting from the end, compute the integer divisors.
Index: mlir/lib/Dialect/Vector/Transforms/VectorTransforms.cpp
===
--- mlir/lib/Dialect/Vector/Transforms/VectorTransforms.cpp
+++ mlir/lib/Dialect/Vector/Transforms/VectorTransforms.cpp
@@ -157,7 +157,7 @@
   if (isInt) {
 if (kind == CombiningKind::MINF || kind == CombiningKind::MAXF)
   // Only valid for floating point types.
-  return Optional();
+  return None;
 mul = rewriter.create(loc, x, y);
   } else {
 // Float case.
@@ -166,7 +166,7 @@
 kind == CombiningKind::MAXSI || kind == CombiningKind::OR ||
 kind == CombiningKind::XOR)
   // Only valid for integer types.
-  return Optional();
+  return None;
 // Special case for fused multiply-add.
 if (acc && acc.getType().isa() && kind == CombiningKind::ADD) {
   return Optional(rewriter.create(loc, x, y, acc));
Index: llvm/lib/Target/WebAssembly/Utils/WebAssemblyTypeUtilities.cpp
===
--- llvm/lib/Target/WebAssembly/Utils/WebAssemblyTypeUtilities.cpp
+++ llvm/lib/Target/WebAssembly/Utils/WebAssemblyTypeUtilities.cpp
@@ -39,7 +39,7 @@
 return wasm::ValType::FUNCREF;
   if (Type == "externref")
 return wasm::ValType::EXTERNREF;
-  return Optional();
+  return None;
 }
 
 WebAssembly::BlockType WebAssembly::parseBlockType(StringRef Type) {
Index: llvm/lib/Target/PowerPC/PPCFastISel.cpp
===
--- llvm/lib/Target/PowerPC/PPCFastISel.cpp
+++ llvm/lib/Target/PowerPC/PPCFastISel.cpp
@@ -226,7 +226,7 @@
 case CmpInst::FCMP_OLE:
 case CmpInst::FCMP_ONE:
 default:
-  return Optional();
+  return None;
 
 case CmpInst::FCMP_OEQ:
 case CmpInst::ICMP_EQ:
Index: llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp
===
--- llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp
+++ llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp
@@ -3535,7 +3535,7 @@
   unsigned FirstOne = A.getBitWidth() - A.countLeadingZeros() - 1;
   unsigned LastOne = A.countTrailingZeros();
   if (A.countPopulation() != (FirstOne - LastOne + 1))
-return Optional>();
+return None;
   return std::make_pair(FirstOne, LastOne);
 }
 
Index: llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
===
--- llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
+++ llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
@@ -2608,7 +2608,7 @@
   }
 
   if (Res == std::make_pair(-1, -1))
-return Optional>();
+return None;
 
   return Optional>(Res);
 }
Index: llvm/lib/TableGen/Record.cpp
===
--- llvm/lib/TableGen/Record.cpp
+++ llvm/lib/TableGen/Record.cpp
@@ -2648,9 +2648,9 @@
 Record::getValueAsOptionalString(StringRef FieldName) const {
   const RecordVal *R = getValue(FieldName);
   if (!R || !R->getValue())
-return llvm::Optional();
+return llvm::None;
   if (isa(R->getValue()))
-return llvm::Optional();
+return llvm::None;
 
   if 

[PATCH] D138466: Don't use Optional::getPointer (NFC)

2022-11-21 Thread Kazu Hirata 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 rG1f914944b6c9: Dont use Optional::getPointer (NFC) 
(authored by kazu).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138466

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/index/Serialization.h
  clang-tools-extra/clangd/tool/ClangdMain.cpp
  clang-tools-extra/pseudo/tool/ClangPseudo.cpp
  clang/include/clang/Basic/DarwinSDKInfo.h
  clang/include/clang/Basic/TargetInfo.h
  clang/include/clang/Sema/CodeCompleteConsumer.h
  clang/lib/Frontend/ASTUnit.cpp
  clang/lib/Sema/SemaCUDA.cpp
  llvm/include/llvm/MC/MCObjectFileInfo.h
  llvm/lib/CodeGen/ExpandMemCmp.cpp
  llvm/lib/CodeGen/SafeStack.cpp
  llvm/lib/CodeGen/ShadowStackGCLowering.cpp
  llvm/lib/DebugInfo/PDB/Native/NativeTypeUDT.cpp
  llvm/lib/Support/ToolOutputFile.cpp
  llvm/lib/Transforms/Scalar/LoopFlatten.cpp
  llvm/lib/Transforms/Scalar/LoopInstSimplify.cpp
  llvm/lib/Transforms/Scalar/LoopRotation.cpp
  llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp
  llvm/lib/Transforms/Scalar/LowerConstantIntrinsics.cpp
  llvm/lib/Transforms/Scalar/PartiallyInlineLibCalls.cpp
  llvm/lib/Transforms/Scalar/ScalarizeMaskedMemIntrin.cpp
  llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
  llvm/tools/llvm-dwp/llvm-dwp.cpp

Index: llvm/tools/llvm-dwp/llvm-dwp.cpp
===
--- llvm/tools/llvm-dwp/llvm-dwp.cpp
+++ llvm/tools/llvm-dwp/llvm-dwp.cpp
@@ -195,7 +195,7 @@
 OS = ();
   } else {
 BOS.emplace(OutFile.os());
-OS = BOS.getPointer();
+OS = &*BOS;
   }
 
   std::unique_ptr MS(TheTarget->createMCObjectStreamer(
Index: llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
===
--- llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
+++ llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
@@ -3217,8 +3217,8 @@
   AR.MSSA->verifyMemorySSA();
   }
   if (!unswitchLoop(L, AR.DT, AR.LI, AR.AC, AR.AA, AR.TTI, Trivial, NonTrivial,
-UnswitchCB, , MSSAU ? MSSAU.getPointer() : nullptr,
-PSI, AR.BFI, DestroyLoopCB))
+UnswitchCB, , MSSAU ? &*MSSAU : nullptr, PSI, AR.BFI,
+DestroyLoopCB))
 return PreservedAnalyses::all();
 
   if (AR.MSSA && VerifyMemorySSA)
Index: llvm/lib/Transforms/Scalar/ScalarizeMaskedMemIntrin.cpp
===
--- llvm/lib/Transforms/Scalar/ScalarizeMaskedMemIntrin.cpp
+++ llvm/lib/Transforms/Scalar/ScalarizeMaskedMemIntrin.cpp
@@ -873,7 +873,7 @@
 for (BasicBlock  : llvm::make_early_inc_range(F)) {
   bool ModifiedDTOnIteration = false;
   MadeChange |= optimizeBlock(BB, ModifiedDTOnIteration, TTI, DL,
-  DTU ? DTU.getPointer() : nullptr);
+  DTU ? &*DTU : nullptr);
 
   // Restart BB iteration if the dominator tree of the Function was changed
   if (ModifiedDTOnIteration)
Index: llvm/lib/Transforms/Scalar/PartiallyInlineLibCalls.cpp
===
--- llvm/lib/Transforms/Scalar/PartiallyInlineLibCalls.cpp
+++ llvm/lib/Transforms/Scalar/PartiallyInlineLibCalls.cpp
@@ -139,7 +139,7 @@
   case LibFunc_sqrt:
 if (TTI->haveFastSqrt(Call->getType()) &&
 optimizeSQRT(Call, CalledFunc, *CurrBB, BB, TTI,
- DTU ? DTU.getPointer() : nullptr))
+ DTU ? &*DTU : nullptr))
   break;
 continue;
   default:
Index: llvm/lib/Transforms/Scalar/LowerConstantIntrinsics.cpp
===
--- llvm/lib/Transforms/Scalar/LowerConstantIntrinsics.cpp
+++ llvm/lib/Transforms/Scalar/LowerConstantIntrinsics.cpp
@@ -143,10 +143,10 @@
   break;
 }
 HasDeadBlocks |= replaceConditionalBranchesOnConstant(
-II, NewValue, DTU ? DTU.getPointer() : nullptr);
+II, NewValue, DTU ? &*DTU : nullptr);
   }
   if (HasDeadBlocks)
-removeUnreachableBlocks(F, DTU ? DTU.getPointer() : nullptr);
+removeUnreachableBlocks(F, DTU ? &*DTU : nullptr);
   return !Worklist.empty();
 }
 
Index: llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp
===
--- llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp
+++ llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp
@@ -721,8 +721,8 @@
   if (AR.MSSA)
 MSSAU = MemorySSAUpdater(AR.MSSA);
   bool DeleteCurrentLoop = false;
-  if (!simplifyLoopCFG(L, AR.DT, AR.LI, AR.SE,
-   MSSAU ? MSSAU.getPointer() : nullptr, DeleteCurrentLoop))
+  

[PATCH] D138466: Don't use Optional::getPointer (NFC)

2022-11-21 Thread Kazu Hirata via Phabricator via cfe-commits
kazu added a comment.

Thanks for the review!

In D138466#3942622 , @MaskRay wrote:

> `getPointer` asserts `hasValue`, so `&*` is safe,

Yes.  `operator*` also asserts `hasVal` via `value()`, so we maintain the same 
level of safety.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138466

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


[PATCH] D138464: Return None instead of Optional() (NFC)

2022-11-21 Thread Kazu Hirata via Phabricator via cfe-commits
kazu added a comment.

Thanks for the review!

In D138464#3942626 , @MaskRay wrote:

> We have `return llvm::None;` and `return None;`. Shall we always prefer 
> `llvm::None`?

Either one is OK (to me).  I can deprecate `None` in my personal tree, and get 
a warning for both `llvm::None` and `None`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138464

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


[PATCH] D138466: Don't use Optional::getPointer (NFC)

2022-11-21 Thread Kazu Hirata via Phabricator via cfe-commits
kazu created this revision.
Herald added subscribers: kadircet, arphaman, javed.absar, hiraditya.
Herald added a project: All.
kazu requested review of this revision.
Herald added projects: clang, LLVM, clang-tools-extra.
Herald added subscribers: cfe-commits, llvm-commits.

Since std::optional does not offer getPointer(), this patch replaces
X.getPointer() with &*X to make the migration from llvm::Optional to
std::optional easier.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D138466

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/index/Serialization.h
  clang-tools-extra/clangd/tool/ClangdMain.cpp
  clang-tools-extra/pseudo/tool/ClangPseudo.cpp
  clang/include/clang/Basic/DarwinSDKInfo.h
  clang/include/clang/Basic/TargetInfo.h
  clang/include/clang/Sema/CodeCompleteConsumer.h
  clang/lib/Frontend/ASTUnit.cpp
  clang/lib/Sema/SemaCUDA.cpp
  llvm/include/llvm/MC/MCObjectFileInfo.h
  llvm/lib/CodeGen/ExpandMemCmp.cpp
  llvm/lib/CodeGen/SafeStack.cpp
  llvm/lib/CodeGen/ShadowStackGCLowering.cpp
  llvm/lib/DebugInfo/PDB/Native/NativeTypeUDT.cpp
  llvm/lib/Support/ToolOutputFile.cpp
  llvm/lib/Transforms/Scalar/LoopFlatten.cpp
  llvm/lib/Transforms/Scalar/LoopInstSimplify.cpp
  llvm/lib/Transforms/Scalar/LoopRotation.cpp
  llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp
  llvm/lib/Transforms/Scalar/LowerConstantIntrinsics.cpp
  llvm/lib/Transforms/Scalar/PartiallyInlineLibCalls.cpp
  llvm/lib/Transforms/Scalar/ScalarizeMaskedMemIntrin.cpp
  llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
  llvm/tools/llvm-dwp/llvm-dwp.cpp

Index: llvm/tools/llvm-dwp/llvm-dwp.cpp
===
--- llvm/tools/llvm-dwp/llvm-dwp.cpp
+++ llvm/tools/llvm-dwp/llvm-dwp.cpp
@@ -195,7 +195,7 @@
 OS = ();
   } else {
 BOS.emplace(OutFile.os());
-OS = BOS.getPointer();
+OS = &*BOS;
   }
 
   std::unique_ptr MS(TheTarget->createMCObjectStreamer(
Index: llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
===
--- llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
+++ llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
@@ -3217,8 +3217,8 @@
   AR.MSSA->verifyMemorySSA();
   }
   if (!unswitchLoop(L, AR.DT, AR.LI, AR.AC, AR.AA, AR.TTI, Trivial, NonTrivial,
-UnswitchCB, , MSSAU ? MSSAU.getPointer() : nullptr,
-PSI, AR.BFI, DestroyLoopCB))
+UnswitchCB, , MSSAU ? &*MSSAU : nullptr, PSI, AR.BFI,
+DestroyLoopCB))
 return PreservedAnalyses::all();
 
   if (AR.MSSA && VerifyMemorySSA)
Index: llvm/lib/Transforms/Scalar/ScalarizeMaskedMemIntrin.cpp
===
--- llvm/lib/Transforms/Scalar/ScalarizeMaskedMemIntrin.cpp
+++ llvm/lib/Transforms/Scalar/ScalarizeMaskedMemIntrin.cpp
@@ -873,7 +873,7 @@
 for (BasicBlock  : llvm::make_early_inc_range(F)) {
   bool ModifiedDTOnIteration = false;
   MadeChange |= optimizeBlock(BB, ModifiedDTOnIteration, TTI, DL,
-  DTU ? DTU.getPointer() : nullptr);
+  DTU ? &*DTU : nullptr);
 
   // Restart BB iteration if the dominator tree of the Function was changed
   if (ModifiedDTOnIteration)
Index: llvm/lib/Transforms/Scalar/PartiallyInlineLibCalls.cpp
===
--- llvm/lib/Transforms/Scalar/PartiallyInlineLibCalls.cpp
+++ llvm/lib/Transforms/Scalar/PartiallyInlineLibCalls.cpp
@@ -139,7 +139,7 @@
   case LibFunc_sqrt:
 if (TTI->haveFastSqrt(Call->getType()) &&
 optimizeSQRT(Call, CalledFunc, *CurrBB, BB, TTI,
- DTU ? DTU.getPointer() : nullptr))
+ DTU ? &*DTU : nullptr))
   break;
 continue;
   default:
Index: llvm/lib/Transforms/Scalar/LowerConstantIntrinsics.cpp
===
--- llvm/lib/Transforms/Scalar/LowerConstantIntrinsics.cpp
+++ llvm/lib/Transforms/Scalar/LowerConstantIntrinsics.cpp
@@ -143,10 +143,10 @@
   break;
 }
 HasDeadBlocks |= replaceConditionalBranchesOnConstant(
-II, NewValue, DTU ? DTU.getPointer() : nullptr);
+II, NewValue, DTU ? &*DTU : nullptr);
   }
   if (HasDeadBlocks)
-removeUnreachableBlocks(F, DTU ? DTU.getPointer() : nullptr);
+removeUnreachableBlocks(F, DTU ? &*DTU : nullptr);
   return !Worklist.empty();
 }
 
Index: llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp
===
--- 

[PATCH] D138464: Return None instead of Optional() (NFC)

2022-11-21 Thread Kazu Hirata via Phabricator via cfe-commits
kazu created this revision.
Herald added subscribers: Moerafaat, zero9178, bzcheeseman, ThomasRaoux, 
pmatos, asb, sdasgup3, wenzhicui, wrengr, jsetoain, cota, teijeong, rdzhabarov, 
tatianashp, msifontes, jurahul, Kayjukh, grosul1, Joonsoo, liufengdb, aartbik, 
mgester, arpith-jacob, antiagainst, shauheen, rriddle, mehdi_amini, Jim, 
martong, kbarton, hiraditya, jgravelle-google, sbc100, nemanjai, dylanmckay, 
dschuff.
Herald added a reviewer: shafik.
Herald added a reviewer: aartbik.
Herald added a project: All.
kazu requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, stephenneuendorffer, 
nicolasvasilache, MaskRay, aheejin.
Herald added a reviewer: nicolasvasilache.
Herald added a reviewer: dcaballe.
Herald added projects: clang, MLIR, LLVM.

This patch replaces:

  return Optional();

with:

  return None;

to make the migration from llvm::Optional to std::optional easier.
Specifically, I can deprecate None (in my source tree, that is) to
identify all the instances of None that should be replaced with
std::nullopt.

Note that "return None" far outnumbers "return Optional();".  There
are more than 2000 instances of "return None" in our source tree.

All of the instances in this patch come from functions that return
Optional except Archive::findSym and ASTNodeImporter::import, where
we return Expected>.  Note that we can construct
Expected> from any parameter convertible to Optional,
which None certainly is.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D138464

Files:
  clang/include/clang/AST/ASTImporterSharedState.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/ASTMatchers/Dynamic/Parser.cpp
  clang/lib/ASTMatchers/Dynamic/VariantValue.cpp
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/Driver/ToolChains/AVR.cpp
  clang/lib/Driver/ToolChains/Arch/CSKY.cpp
  llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
  llvm/lib/CodeGen/SelectOptimize.cpp
  llvm/lib/DebugInfo/PDB/DIA/DIADataStream.cpp
  llvm/lib/IR/BasicBlock.cpp
  llvm/lib/LineEditor/LineEditor.cpp
  llvm/lib/MC/MCSubtargetInfo.cpp
  llvm/lib/Object/Archive.cpp
  llvm/lib/Support/Z3Solver.cpp
  llvm/lib/TableGen/Record.cpp
  llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
  llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp
  llvm/lib/Target/PowerPC/PPCFastISel.cpp
  llvm/lib/Target/WebAssembly/Utils/WebAssemblyTypeUtilities.cpp
  mlir/lib/Dialect/Vector/Transforms/VectorTransforms.cpp
  mlir/lib/Dialect/Vector/Utils/VectorUtils.cpp

Index: mlir/lib/Dialect/Vector/Utils/VectorUtils.cpp
===
--- mlir/lib/Dialect/Vector/Utils/VectorUtils.cpp
+++ mlir/lib/Dialect/Vector/Utils/VectorUtils.cpp
@@ -77,7 +77,7 @@
 Optional> mlir::shapeRatio(ArrayRef superShape,
ArrayRef subShape) {
   if (superShape.size() < subShape.size()) {
-return Optional>();
+return None;
   }
 
   // Starting from the end, compute the integer divisors.
Index: mlir/lib/Dialect/Vector/Transforms/VectorTransforms.cpp
===
--- mlir/lib/Dialect/Vector/Transforms/VectorTransforms.cpp
+++ mlir/lib/Dialect/Vector/Transforms/VectorTransforms.cpp
@@ -157,7 +157,7 @@
   if (isInt) {
 if (kind == CombiningKind::MINF || kind == CombiningKind::MAXF)
   // Only valid for floating point types.
-  return Optional();
+  return None;
 mul = rewriter.create(loc, x, y);
   } else {
 // Float case.
@@ -166,7 +166,7 @@
 kind == CombiningKind::MAXSI || kind == CombiningKind::OR ||
 kind == CombiningKind::XOR)
   // Only valid for integer types.
-  return Optional();
+  return None;
 // Special case for fused multiply-add.
 if (acc && acc.getType().isa() && kind == CombiningKind::ADD) {
   return Optional(rewriter.create(loc, x, y, acc));
Index: llvm/lib/Target/WebAssembly/Utils/WebAssemblyTypeUtilities.cpp
===
--- llvm/lib/Target/WebAssembly/Utils/WebAssemblyTypeUtilities.cpp
+++ llvm/lib/Target/WebAssembly/Utils/WebAssemblyTypeUtilities.cpp
@@ -39,7 +39,7 @@
 return wasm::ValType::FUNCREF;
   if (Type == "externref")
 return wasm::ValType::EXTERNREF;
-  return Optional();
+  return None;
 }
 
 WebAssembly::BlockType WebAssembly::parseBlockType(StringRef Type) {
Index: llvm/lib/Target/PowerPC/PPCFastISel.cpp
===
--- llvm/lib/Target/PowerPC/PPCFastISel.cpp
+++ llvm/lib/Target/PowerPC/PPCFastISel.cpp
@@ -226,7 +226,7 @@
 case CmpInst::FCMP_OLE:
 case CmpInst::FCMP_ONE:
 default:
-  return Optional();
+  return None;
 
 case CmpInst::FCMP_OEQ:
 case CmpInst::ICMP_EQ:
Index: 

[PATCH] D138376: Use None consistently (NFC)

2022-11-20 Thread Kazu Hirata 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 rG1fa870b1bd6c: Use None consistently (NFC) (authored by kazu).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138376

Files:
  bolt/include/bolt/Core/BinaryContext.h
  bolt/include/bolt/Core/BinaryFunction.h
  bolt/include/bolt/Core/MCPlusBuilder.h
  bolt/lib/Core/BinaryContext.cpp
  bolt/lib/Core/MCPlusBuilder.cpp
  bolt/lib/Profile/BoltAddressTranslation.cpp
  bolt/lib/Profile/DataAggregator.cpp
  bolt/lib/Profile/DataReader.cpp
  bolt/lib/Rewrite/RewriteInstance.cpp
  bolt/lib/Target/X86/X86MCPlusBuilder.cpp
  bolt/lib/Utils/Utils.cpp
  clang/lib/Driver/ToolChains/HLSL.cpp
  lldb/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.cpp
  llvm/include/llvm/Analysis/InlineAdvisor.h
  llvm/include/llvm/Analysis/ObjCARCAnalysisUtils.h
  llvm/include/llvm/IR/DebugInfoMetadata.h
  llvm/lib/CodeGen/RemoveRedundantDebugValues.cpp
  llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
  llvm/unittests/DebugInfo/DWARF/DWARFExpressionCopyBytesTest.cpp
  llvm/unittests/IR/MetadataTest.cpp
  mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp

Index: mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
===
--- mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
+++ mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
@@ -312,12 +312,12 @@
   if (parser.parseOperand(*chunkSize) || parser.parseColonType(chunkType))
 return failure();
 } else {
-  chunkSize = llvm::NoneType::None;
+  chunkSize = llvm::None;
 }
 break;
   case ClauseScheduleKind::Auto:
   case ClauseScheduleKind::Runtime:
-chunkSize = llvm::NoneType::None;
+chunkSize = llvm::None;
   }
 
   // If there is a comma, we have one or more modifiers..
Index: llvm/unittests/IR/MetadataTest.cpp
===
--- llvm/unittests/IR/MetadataTest.cpp
+++ llvm/unittests/IR/MetadataTest.cpp
@@ -3683,9 +3683,9 @@
   DILocalVariable *VarB =
   DILocalVariable::get(Context, Scope, "B", File, 7, Type, 3, Flags, 8, nullptr);
 
-  DebugVariable DebugVariableA(VarA, NoneType(), nullptr);
-  DebugVariable DebugVariableInlineA(VarA, NoneType(), InlinedLoc);
-  DebugVariable DebugVariableB(VarB, NoneType(), nullptr);
+  DebugVariable DebugVariableA(VarA, None, nullptr);
+  DebugVariable DebugVariableInlineA(VarA, None, InlinedLoc);
+  DebugVariable DebugVariableB(VarB, None, nullptr);
   DebugVariable DebugVariableFragB(VarB, {{16, 16}}, nullptr);
 
   DebugVariableMap.insert({DebugVariableA, 2});
Index: llvm/unittests/DebugInfo/DWARF/DWARFExpressionCopyBytesTest.cpp
===
--- llvm/unittests/DebugInfo/DWARF/DWARFExpressionCopyBytesTest.cpp
+++ llvm/unittests/DebugInfo/DWARF/DWARFExpressionCopyBytesTest.cpp
@@ -159,7 +159,7 @@
 return Instr;
   }
 }
-return NoneType();
+return None;
   };
 
   std::unique_ptr Ctx = DWARFContext::create(E);
Index: llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
===
--- llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
+++ llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
@@ -428,8 +428,7 @@
   VariableMap;
   for (auto  : *BB) {
 if (DbgValueInst *DVI = dyn_cast()) {
-  DebugVariable Key(DVI->getVariable(),
-NoneType(),
+  DebugVariable Key(DVI->getVariable(), None,
 DVI->getDebugLoc()->getInlinedAt());
   auto VMI = VariableMap.find(Key);
   auto *DAI = dyn_cast(DVI);
@@ -490,7 +489,7 @@
   DenseSet SeenDefForAggregate;
   // Returns the DebugVariable for DVI with no fragment info.
   auto GetAggregateVariable = [](DbgValueInst *DVI) {
-return DebugVariable(DVI->getVariable(), NoneType(),
+return DebugVariable(DVI->getVariable(), None,
  DVI->getDebugLoc()->getInlinedAt());
   };
 
Index: llvm/lib/CodeGen/RemoveRedundantDebugValues.cpp
===
--- llvm/lib/CodeGen/RemoveRedundantDebugValues.cpp
+++ llvm/lib/CodeGen/RemoveRedundantDebugValues.cpp
@@ -89,7 +89,7 @@
 
   for (auto  : MBB) {
 if (MI.isDebugValue()) {
-  DebugVariable Var(MI.getDebugVariable(), NoneType(),
+  DebugVariable Var(MI.getDebugVariable(), None,
 MI.getDebugLoc()->getInlinedAt());
   auto VMI = VariableMap.find(Var);
   // Just stop tracking this variable, until we cover DBG_VALUE_LIST.
Index: llvm/include/llvm/IR/DebugInfoMetadata.h
===
--- llvm/include/llvm/IR/DebugInfoMetadata.h
+++ llvm/include/llvm/IR/DebugInfoMetadata.h
@@ -3675,8 +3675,7 @@
 
   DebugVariable(const DILocalVariable *Var, const 

[PATCH] D138376: Use None consistently (NFC)

2022-11-19 Thread Kazu Hirata via Phabricator via cfe-commits
kazu created this revision.
Herald added subscribers: Moerafaat, zero9178, mtrofin, bzcheeseman, ayermolo, 
sdasgup3, wenzhicui, wrengr, cota, teijeong, rdzhabarov, tatianashp, msifontes, 
jurahul, Kayjukh, grosul1, Joonsoo, liufengdb, aartbik, mgester, arpith-jacob, 
antiagainst, shauheen, rriddle, mehdi_amini, pengfei, hiraditya.
Herald added a reviewer: rafauler.
Herald added a reviewer: Amir.
Herald added a reviewer: maksfb.
Herald added a project: All.
kazu requested review of this revision.
Herald added subscribers: llvm-commits, lldb-commits, cfe-commits, yota9, 
stephenneuendorffer, nicolasvasilache, MaskRay.
Herald added a reviewer: nicolasvasilache.
Herald added projects: clang, LLDB, MLIR, LLVM.

This patch replaces NoneType() and NoneType::None with None in
preparation for migration from llvm::Optional to std::optional.

In the std::optional world, we are not guranteed to be able to
default-construct std::nullopt_t or peek what's inside it, so neither
NoneType() nor NoneType::None has a corresponding expression in the
std::optional world.

Once we consistently use None, we should even be able to replace the
contents of llvm/include/llvm/ADT/None.h with something like:

  using NoneType = std::nullopt_t;
  inline constexpr std::nullopt_t None = std::nullopt;

to ease the migration from llvm::Optional to std::optional.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D138376

Files:
  bolt/include/bolt/Core/BinaryContext.h
  bolt/include/bolt/Core/BinaryFunction.h
  bolt/include/bolt/Core/MCPlusBuilder.h
  bolt/lib/Core/BinaryContext.cpp
  bolt/lib/Core/MCPlusBuilder.cpp
  bolt/lib/Profile/BoltAddressTranslation.cpp
  bolt/lib/Profile/DataAggregator.cpp
  bolt/lib/Profile/DataReader.cpp
  bolt/lib/Rewrite/RewriteInstance.cpp
  bolt/lib/Target/X86/X86MCPlusBuilder.cpp
  bolt/lib/Utils/Utils.cpp
  clang/lib/Driver/ToolChains/HLSL.cpp
  lldb/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.cpp
  llvm/include/llvm/Analysis/InlineAdvisor.h
  llvm/include/llvm/Analysis/ObjCARCAnalysisUtils.h
  llvm/include/llvm/IR/DebugInfoMetadata.h
  llvm/lib/CodeGen/RemoveRedundantDebugValues.cpp
  llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
  llvm/unittests/DebugInfo/DWARF/DWARFExpressionCopyBytesTest.cpp
  llvm/unittests/IR/MetadataTest.cpp
  mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp

Index: mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
===
--- mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
+++ mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
@@ -312,12 +312,12 @@
   if (parser.parseOperand(*chunkSize) || parser.parseColonType(chunkType))
 return failure();
 } else {
-  chunkSize = llvm::NoneType::None;
+  chunkSize = llvm::None;
 }
 break;
   case ClauseScheduleKind::Auto:
   case ClauseScheduleKind::Runtime:
-chunkSize = llvm::NoneType::None;
+chunkSize = llvm::None;
   }
 
   // If there is a comma, we have one or more modifiers..
Index: llvm/unittests/IR/MetadataTest.cpp
===
--- llvm/unittests/IR/MetadataTest.cpp
+++ llvm/unittests/IR/MetadataTest.cpp
@@ -3683,9 +3683,9 @@
   DILocalVariable *VarB =
   DILocalVariable::get(Context, Scope, "B", File, 7, Type, 3, Flags, 8, nullptr);
 
-  DebugVariable DebugVariableA(VarA, NoneType(), nullptr);
-  DebugVariable DebugVariableInlineA(VarA, NoneType(), InlinedLoc);
-  DebugVariable DebugVariableB(VarB, NoneType(), nullptr);
+  DebugVariable DebugVariableA(VarA, None, nullptr);
+  DebugVariable DebugVariableInlineA(VarA, None, InlinedLoc);
+  DebugVariable DebugVariableB(VarB, None, nullptr);
   DebugVariable DebugVariableFragB(VarB, {{16, 16}}, nullptr);
 
   DebugVariableMap.insert({DebugVariableA, 2});
Index: llvm/unittests/DebugInfo/DWARF/DWARFExpressionCopyBytesTest.cpp
===
--- llvm/unittests/DebugInfo/DWARF/DWARFExpressionCopyBytesTest.cpp
+++ llvm/unittests/DebugInfo/DWARF/DWARFExpressionCopyBytesTest.cpp
@@ -159,7 +159,7 @@
 return Instr;
   }
 }
-return NoneType();
+return None;
   };
 
   std::unique_ptr Ctx = DWARFContext::create(E);
Index: llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
===
--- llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
+++ llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
@@ -428,8 +428,7 @@
   VariableMap;
   for (auto  : *BB) {
 if (DbgValueInst *DVI = dyn_cast()) {
-  DebugVariable Key(DVI->getVariable(),
-NoneType(),
+  DebugVariable Key(DVI->getVariable(), None,
 DVI->getDebugLoc()->getInlinedAt());
   auto VMI = VariableMap.find(Key);
   auto *DAI = dyn_cast(DVI);
@@ -490,7 +489,7 @@
   DenseSet SeenDefForAggregate;
   // Returns the DebugVariable for DVI with no fragment info.
   auto GetAggregateVariable = 

[PATCH] D129883: [HLSL] Support cbuffer/tbuffer for hlsl.

2022-09-21 Thread Kazu Hirata via Phabricator via cfe-commits
kazu added a comment.

In D129883#3806507 , @python3kgae 
wrote:

> In D129883#3806393 , @kazu wrote:
>
>> This patch seems to cause several warnings:
>>
>>   clang/include/clang/AST/Decl.h:4696:15: error: 'getSourceRange' overrides 
>> a member function but is not marked 'override' [-Werror,-Wsuggest-override]
>>   clang/lib/Parse/ParseHLSL.cpp:76:20: error: unused variable 'Loc' 
>> [-Werror,-Wunused-variable]
>>   clang/lib/CodeGen/CGDecl.cpp:48:11: error: enumeration value 'HLSLBuffer' 
>> not handled in switch [-Werror,-Wswitch]
>>
>> I could fix the first two, but I don't know what should be done for the last 
>> one.  Would you mind taking a look?
>>
>> FWIW, I'm using clang-14.0.0.6 as the hot compiler with a cmake flag 
>> `-DLLVM_ENABLE_WERROR=On`.
>
> Fixed with 
> https://github.com/llvm/llvm-project/commit/a7e3de2450f5b62e7dfe8999443f15be5dfec0b0
> Thanks for the help.
> I will switch to clang in the future.

Thank you so much for fixing this quickly!

By the way, after your fix, I am getting:

  clang/tools/libclang/CIndex.cpp:6648:11: error: enumeration value 
'HLSLBuffer' not handled in switch [-Werror,-Wswitch]

Sorry for not listing all the warnings in my first message.  (I thought I 
listed them all...) Should we add something like this?

  case Decl::HLSLBuffer:
return clang_getNullCursor();


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129883

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


[PATCH] D129883: [HLSL] Support cbuffer/tbuffer for hlsl.

2022-09-21 Thread Kazu Hirata via Phabricator via cfe-commits
kazu added a comment.

This patch seems to cause several warnings:

  clang/include/clang/AST/Decl.h:4696:15: error: 'getSourceRange' overrides a 
member function but is not marked 'override' [-Werror,-Wsuggest-override]
  clang/lib/Parse/ParseHLSL.cpp:76:20: error: unused variable 'Loc' 
[-Werror,-Wunused-variable]
  clang/lib/CodeGen/CGDecl.cpp:48:11: error: enumeration value 'HLSLBuffer' not 
handled in switch [-Werror,-Wswitch]

I could fix the first two, but I don't know what should be done for the last 
one.  Would you mind taking a look?

FWIW, I'm using clang-14.0.0.6 as the hot compiler with a cmake flag 
`-DLLVM_ENABLE_WERROR=On`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129883

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


[PATCH] D131368: [Basic] Deprecate MapEntryOptionalStorage::{hasValue,getValue}

2022-08-08 Thread Kazu Hirata 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 rG8e207e4c096e: [Basic] Deprecate 
MapEntryOptionalStorage::{hasValue,getValue} (authored by kazu).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131368

Files:
  clang/include/clang/Basic/DirectoryEntry.h


Index: clang/include/clang/Basic/DirectoryEntry.h
===
--- clang/include/clang/Basic/DirectoryEntry.h
+++ clang/include/clang/Basic/DirectoryEntry.h
@@ -131,13 +131,15 @@
   void reset() { MaybeRef = optional_none_tag(); }
 
   bool has_value() const { return MaybeRef.hasOptionalValue(); }
-  bool hasValue() const { return MaybeRef.hasOptionalValue(); }
+  LLVM_DEPRECATED("Use has_value instead.", "has_value") bool hasValue() const 
{
+return MaybeRef.hasOptionalValue();
+  }
 
   RefTy () & {
 assert(has_value());
 return MaybeRef;
   }
-  RefTy () & {
+  LLVM_DEPRECATED("Use value instead.", "value") RefTy () & {
 assert(has_value());
 return MaybeRef;
   }
@@ -145,6 +147,7 @@
 assert(has_value());
 return MaybeRef;
   }
+  LLVM_DEPRECATED("Use value instead.", "value")
   RefTy const () const & {
 assert(has_value());
 return MaybeRef;
@@ -153,7 +156,7 @@
 assert(has_value());
 return std::move(MaybeRef);
   }
-  RefTy &() && {
+  LLVM_DEPRECATED("Use value instead.", "value") RefTy &() && {
 assert(has_value());
 return std::move(MaybeRef);
   }


Index: clang/include/clang/Basic/DirectoryEntry.h
===
--- clang/include/clang/Basic/DirectoryEntry.h
+++ clang/include/clang/Basic/DirectoryEntry.h
@@ -131,13 +131,15 @@
   void reset() { MaybeRef = optional_none_tag(); }
 
   bool has_value() const { return MaybeRef.hasOptionalValue(); }
-  bool hasValue() const { return MaybeRef.hasOptionalValue(); }
+  LLVM_DEPRECATED("Use has_value instead.", "has_value") bool hasValue() const {
+return MaybeRef.hasOptionalValue();
+  }
 
   RefTy () & {
 assert(has_value());
 return MaybeRef;
   }
-  RefTy () & {
+  LLVM_DEPRECATED("Use value instead.", "value") RefTy () & {
 assert(has_value());
 return MaybeRef;
   }
@@ -145,6 +147,7 @@
 assert(has_value());
 return MaybeRef;
   }
+  LLVM_DEPRECATED("Use value instead.", "value")
   RefTy const () const & {
 assert(has_value());
 return MaybeRef;
@@ -153,7 +156,7 @@
 assert(has_value());
 return std::move(MaybeRef);
   }
-  RefTy &() && {
+  LLVM_DEPRECATED("Use value instead.", "value") RefTy &() && {
 assert(has_value());
 return std::move(MaybeRef);
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D131368: [Basic] Deprecate MapEntryOptionalStorage::{hasValue,getValue}

2022-08-08 Thread Kazu Hirata via Phabricator via cfe-commits
kazu added a comment.

In D131368#3708542 , @dblaikie wrote:

> Sounds good - I'd be probably OK with removing these outright as they're so 
> niche/generally only for use by `llvm::Optional` anyway - but not much harm 
> in keeping them around for the same period the other more visible APIs are 
> deprecated and cleaning it all up together later/then.

Yeah, I was actually sitting on the fence, wondering whether I should just 
remove them now as they are internal details of `llvm::Optional` as you point 
out.  I think I'll just remove them in three months or so along with other 
deprecated methods related to `llvm::Optional`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131368

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


[PATCH] D131368: [Basic] Deprecate MapEntryOptionalStorage::{hasValue,getValue}

2022-08-08 Thread Kazu Hirata via Phabricator via cfe-commits
kazu added a comment.

PTAL.  Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131368

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


[PATCH] D131368: [Basic] Deprecate MapEntryOptionalStorage::{hasValue,getValue}

2022-08-08 Thread Kazu Hirata via Phabricator via cfe-commits
kazu updated this revision to Diff 451002.
kazu added a comment.

Updated to use LLVM_DEPRECATED instead of [[deprecated]].


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131368

Files:
  clang/include/clang/Basic/DirectoryEntry.h


Index: clang/include/clang/Basic/DirectoryEntry.h
===
--- clang/include/clang/Basic/DirectoryEntry.h
+++ clang/include/clang/Basic/DirectoryEntry.h
@@ -131,13 +131,15 @@
   void reset() { MaybeRef = optional_none_tag(); }
 
   bool has_value() const { return MaybeRef.hasOptionalValue(); }
-  bool hasValue() const { return MaybeRef.hasOptionalValue(); }
+  LLVM_DEPRECATED("Use has_value instead.", "has_value") bool hasValue() const 
{
+return MaybeRef.hasOptionalValue();
+  }
 
   RefTy () & {
 assert(has_value());
 return MaybeRef;
   }
-  RefTy () & {
+  LLVM_DEPRECATED("Use value instead.", "value") RefTy () & {
 assert(has_value());
 return MaybeRef;
   }
@@ -145,6 +147,7 @@
 assert(has_value());
 return MaybeRef;
   }
+  LLVM_DEPRECATED("Use value instead.", "value")
   RefTy const () const & {
 assert(has_value());
 return MaybeRef;
@@ -153,7 +156,7 @@
 assert(has_value());
 return std::move(MaybeRef);
   }
-  RefTy &() && {
+  LLVM_DEPRECATED("Use value instead.", "value") RefTy &() && {
 assert(has_value());
 return std::move(MaybeRef);
   }


Index: clang/include/clang/Basic/DirectoryEntry.h
===
--- clang/include/clang/Basic/DirectoryEntry.h
+++ clang/include/clang/Basic/DirectoryEntry.h
@@ -131,13 +131,15 @@
   void reset() { MaybeRef = optional_none_tag(); }
 
   bool has_value() const { return MaybeRef.hasOptionalValue(); }
-  bool hasValue() const { return MaybeRef.hasOptionalValue(); }
+  LLVM_DEPRECATED("Use has_value instead.", "has_value") bool hasValue() const {
+return MaybeRef.hasOptionalValue();
+  }
 
   RefTy () & {
 assert(has_value());
 return MaybeRef;
   }
-  RefTy () & {
+  LLVM_DEPRECATED("Use value instead.", "value") RefTy () & {
 assert(has_value());
 return MaybeRef;
   }
@@ -145,6 +147,7 @@
 assert(has_value());
 return MaybeRef;
   }
+  LLVM_DEPRECATED("Use value instead.", "value")
   RefTy const () const & {
 assert(has_value());
 return MaybeRef;
@@ -153,7 +156,7 @@
 assert(has_value());
 return std::move(MaybeRef);
   }
-  RefTy &() && {
+  LLVM_DEPRECATED("Use value instead.", "value") RefTy &() && {
 assert(has_value());
 return std::move(MaybeRef);
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D131368: [Basic] Deprecate MapEntryOptionalStorage::{hasValue,getValue}

2022-08-08 Thread Kazu Hirata via Phabricator via cfe-commits
kazu added a comment.

In D131368#3707265 , @dblaikie wrote:

> Update this to use something like https://reviews.llvm.org/D131381 ?

Great idea!  Will do!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131368

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


[PATCH] D131368: [Basic] Deprecate MapEntryOptionalStorage::{hasValue,getValue}

2022-08-07 Thread Kazu Hirata via Phabricator via cfe-commits
kazu created this revision.
Herald added a project: All.
kazu requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

MapEntryOptionalStorage is an underlying storage class for
OptionalStorage.

This patch deprecates:

  OptionalStorage::hasValue
  OptionalStorage::getValue

as there is no known users of these two methods.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D131368

Files:
  clang/include/clang/Basic/DirectoryEntry.h


Index: clang/include/clang/Basic/DirectoryEntry.h
===
--- clang/include/clang/Basic/DirectoryEntry.h
+++ clang/include/clang/Basic/DirectoryEntry.h
@@ -131,13 +131,15 @@
   void reset() { MaybeRef = optional_none_tag(); }
 
   bool has_value() const { return MaybeRef.hasOptionalValue(); }
-  bool hasValue() const { return MaybeRef.hasOptionalValue(); }
+  [[deprecated("Use has_value instead.")]] bool hasValue() const {
+return MaybeRef.hasOptionalValue();
+  }
 
   RefTy () & {
 assert(has_value());
 return MaybeRef;
   }
-  RefTy () & {
+  [[deprecated("Use value instead.")]] RefTy () & {
 assert(has_value());
 return MaybeRef;
   }
@@ -145,7 +147,7 @@
 assert(has_value());
 return MaybeRef;
   }
-  RefTy const () const & {
+  [[deprecated("Use value instead.")]] RefTy const () const & {
 assert(has_value());
 return MaybeRef;
   }
@@ -153,7 +155,7 @@
 assert(has_value());
 return std::move(MaybeRef);
   }
-  RefTy &() && {
+  [[deprecated("Use value instead.")]] RefTy &() && {
 assert(has_value());
 return std::move(MaybeRef);
   }


Index: clang/include/clang/Basic/DirectoryEntry.h
===
--- clang/include/clang/Basic/DirectoryEntry.h
+++ clang/include/clang/Basic/DirectoryEntry.h
@@ -131,13 +131,15 @@
   void reset() { MaybeRef = optional_none_tag(); }
 
   bool has_value() const { return MaybeRef.hasOptionalValue(); }
-  bool hasValue() const { return MaybeRef.hasOptionalValue(); }
+  [[deprecated("Use has_value instead.")]] bool hasValue() const {
+return MaybeRef.hasOptionalValue();
+  }
 
   RefTy () & {
 assert(has_value());
 return MaybeRef;
   }
-  RefTy () & {
+  [[deprecated("Use value instead.")]] RefTy () & {
 assert(has_value());
 return MaybeRef;
   }
@@ -145,7 +147,7 @@
 assert(has_value());
 return MaybeRef;
   }
-  RefTy const () const & {
+  [[deprecated("Use value instead.")]] RefTy const () const & {
 assert(has_value());
 return MaybeRef;
   }
@@ -153,7 +155,7 @@
 assert(has_value());
 return std::move(MaybeRef);
   }
-  RefTy &() && {
+  [[deprecated("Use value instead.")]] RefTy &() && {
 assert(has_value());
 return std::move(MaybeRef);
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D127799: [StaticAnalyzer] Remove dead code (DO NOT COMMIT)

2022-06-14 Thread Kazu Hirata via Phabricator via cfe-commits
kazu created this revision.
Herald added subscribers: abrachet, manas, ASDenysPetrov, martong, dkrupp, 
donat.nagy, Szelethus, a.sidorin, zzheng, szepet, baloghadamsoftware.
Herald added a project: All.
kazu requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

DO NOT COMMIT!  This untested patch deletes dead code under
clang/lib/StaticAnalyzer, including debug functions.  Please
intelligently choose what to actually remove.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D127799

Files:
  clang/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp
  clang/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
  clang/lib/StaticAnalyzer/Checkers/CheckerDocumentation.cpp
  clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
  clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/Iterator.h
  clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
  clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/MoveChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/ObjCContainersChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
  clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/TaintTesterChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp
  clang/lib/StaticAnalyzer/Core/BugReporter.cpp
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/lib/StaticAnalyzer/Core/RegionStore.cpp
  clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp

Index: clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
===
--- clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
+++ clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
@@ -352,7 +352,6 @@
 
 private:
   void storeTopLevelDecls(DeclGroupRef DG);
-  std::string getFunctionName(const Decl *D);
 
   /// Check if we should skip (not analyze) the given function.
   AnalysisMode getModeForDecl(Decl *D, AnalysisMode Mode);
Index: clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -1352,10 +1352,6 @@
   S, SVB.evalUnaryOp(State, S->getOpcode(), Op, S->getType()));
 }
 
-SVal VisitSymExpr(SymbolRef S) { return nonloc::SymbolVal(S); }
-
-SVal VisitMemRegion(const MemRegion *R) { return loc::MemRegionVal(R); }
-
 SVal VisitNonLocSymbolVal(nonloc::SymbolVal V) {
   // Simplification is much more costly than computing complexity.
   // For high complexity, it may be not worth it.
Index: clang/lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- clang/lib/StaticAnalyzer/Core/RegionStore.cpp
+++ clang/lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -107,8 +107,6 @@
 return P.getOpaqueValue() == X.P.getOpaqueValue() &&
Data == X.Data;
   }
-
-  LLVM_DUMP_METHOD void dump() const;
 };
 } // end anonymous namespace
 
@@ -136,7 +134,6 @@
 } // namespace llvm
 
 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
-void BindingKey::dump() const { llvm::errs() << *this; }
 #endif
 
 //===--===//
@@ -255,8 +252,6 @@
   Out << NL;
 }
   }
-
-  LLVM_DUMP_METHOD void dump() const { printJson(llvm::errs()); }
 };
 } // end anonymous namespace
 
@@ -732,10 +727,6 @@
 return true;
   }
 
-  bool AddToWorkList(const MemRegion *R) {
-return static_cast(this)->AddToWorkList(R);
-  }
-
   void RunWorkList() {
 while (!WL.empty()) {
   WorkListElement E = WL.pop_back_val();
@@ -746,7 +737,6 @@
   }
 
   void VisitAddedToCluster(const MemRegion *baseR, const ClusterBindings ) {}
-  void VisitCluster(const MemRegion *baseR, const ClusterBindings *C) {}
 
   void VisitCluster(const MemRegion *BaseR, const ClusterBindings *C,
 bool Flag) {
Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -954,8 +954,6 @@
   LLVM_NODISCARD inline ProgramStateRef
   markDisequal(RangeSet::Factory , ProgramStateRef State,
EquivalenceClass Other) const;
-  LLVM_NODISCARD static inline ClassSet
-  getDisequalClasses(ProgramStateRef State, SymbolRef Sym);
   LLVM_NODISCARD inline ClassSet
   

[PATCH] D112356: [NFC] Tidy up spelling, grammar, and inconsistencies in clang-tidy documentation

2021-10-23 Thread Kazu Hirata 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 rG5de69e16ea9a: [clang-tidy] Tidy up spelling, grammar, and 
inconsistencies in documentation… (authored by salman-javed-nz, committed by 
kazu).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112356

Files:
  clang-tools-extra/docs/clang-tidy/Contributing.rst
  clang-tools-extra/docs/clang-tidy/checks/abseil-duration-conversion-cast.rst
  clang-tools-extra/docs/clang-tidy/checks/abseil-no-internal-dependencies.rst
  clang-tools-extra/docs/clang-tidy/checks/abseil-string-find-str-contains.rst
  clang-tools-extra/docs/clang-tidy/checks/android-cloexec-open.rst
  clang-tools-extra/docs/clang-tidy/checks/android-cloexec-pipe2.rst
  clang-tools-extra/docs/clang-tidy/checks/boost-use-to-string.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone-branch-clone.rst
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-easily-swappable-parameters.rst
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-implicit-widening-of-multiplication-result.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone-macro-parentheses.rst
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-misplaced-operator-in-strlen-in-alloc.rst
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-not-null-terminated-result.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone-sizeof-expression.rst
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-suspicious-string-compare.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone-too-small-loop-variable.rst
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-unhandled-exception-at-new.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone-virtual-near-miss.rst
  clang-tools-extra/docs/clang-tidy/checks/cert-dcl21-cpp.rst
  clang-tools-extra/docs/clang-tidy/checks/cert-err09-cpp.rst
  clang-tools-extra/docs/clang-tidy/checks/cert-oop11-cpp.rst
  clang-tools-extra/docs/clang-tidy/checks/concurrency-mt-unsafe.rst
  clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-init-variables.rst
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-narrowing-conversions.rst
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-special-member-functions.rst
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-virtual-class-destructor.rst
  clang-tools-extra/docs/clang-tidy/checks/hicpp-multiway-paths-covered.rst
  clang-tools-extra/docs/clang-tidy/checks/hicpp-signed-bitwise.rst
  clang-tools-extra/docs/clang-tidy/checks/misc-static-assert.rst
  
clang-tools-extra/docs/clang-tidy/checks/misc-throw-by-value-catch-by-reference.rst
  clang-tools-extra/docs/clang-tidy/checks/modernize-avoid-bind.rst
  clang-tools-extra/docs/clang-tidy/checks/modernize-avoid-c-arrays.rst
  clang-tools-extra/docs/clang-tidy/checks/modernize-loop-convert.rst
  clang-tools-extra/docs/clang-tidy/checks/modernize-pass-by-value.rst
  
clang-tools-extra/docs/clang-tidy/checks/modernize-replace-disallow-copy-and-assign-macro.rst
  clang-tools-extra/docs/clang-tidy/checks/modernize-use-auto.rst
  clang-tools-extra/docs/clang-tidy/checks/modernize-use-default-member-init.rst
  clang-tools-extra/docs/clang-tidy/checks/modernize-use-noexcept.rst
  clang-tools-extra/docs/clang-tidy/checks/modernize-use-nullptr.rst
  
clang-tools-extra/docs/clang-tidy/checks/objc-nsinvocation-argument-lifetime.rst
  clang-tools-extra/docs/clang-tidy/checks/openmp-exception-escape.rst
  clang-tools-extra/docs/clang-tidy/checks/openmp-use-default-none.rst
  clang-tools-extra/docs/clang-tidy/checks/performance-inefficient-algorithm.rst
  clang-tools-extra/docs/clang-tidy/checks/readability-const-return-type.rst
  clang-tools-extra/docs/clang-tidy/checks/readability-data-pointer.rst
  clang-tools-extra/docs/clang-tidy/checks/readability-else-after-return.rst
  
clang-tools-extra/docs/clang-tidy/checks/readability-function-cognitive-complexity.rst
  clang-tools-extra/docs/clang-tidy/checks/readability-identifier-length.rst
  clang-tools-extra/docs/clang-tidy/checks/readability-identifier-naming.rst
  clang-tools-extra/docs/clang-tidy/checks/readability-magic-numbers.rst
  clang-tools-extra/docs/clang-tidy/checks/readability-qualified-auto.rst
  clang-tools-extra/docs/clang-tidy/checks/readability-redundant-declaration.rst
  clang-tools-extra/docs/clang-tidy/checks/readability-string-compare.rst
  
clang-tools-extra/docs/clang-tidy/checks/readability-suspicious-call-argument.rst
  clang-tools-extra/docs/clang-tidy/index.rst

Index: clang-tools-extra/docs/clang-tidy/index.rst
===
--- clang-tools-extra/docs/clang-tidy/index.rst
+++ clang-tools-extra/docs/clang-tidy/index.rst
@@ -91,7 +91,7 @@
 Clang diagnostics are treated in a similar way as check diagnostics. Clang
 diagnostics are displayed by :program:`clang-tidy` and can be filtered out 

[PATCH] D112356: [NFC] Tidy up spelling, grammar, and inconsistencies in clang-tidy documentation

2021-10-23 Thread Kazu Hirata via Phabricator via cfe-commits
kazu accepted this revision.
kazu added a comment.
This revision is now accepted and ready to land.

LGTM.  Thanks for fixing the docs!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112356

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


[PATCH] D112336: [Serialization] Fix a uniqueness check

2021-10-22 Thread Kazu Hirata via Phabricator via cfe-commits
kazu created this revision.
kazu added a reviewer: rsmith.
kazu requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The function is intended to maintain uniqueness of two sets -- Found
and Data.  Now, we can reach the for loop shown in the patch only when
Found.empty().  This means that we never execute the body of the for
loop.

The patch fixes the problem by replacing Found with Data.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112336

Files:
  clang/lib/Serialization/ASTReaderInternals.h


Index: clang/lib/Serialization/ASTReaderInternals.h
===
--- clang/lib/Serialization/ASTReaderInternals.h
+++ clang/lib/Serialization/ASTReaderInternals.h
@@ -62,7 +62,7 @@
   // Just use a linear scan unless we have more than a few IDs.
   if (Found.empty() && !Data.empty()) {
 if (Data.size() <= 4) {
-  for (auto I : Found)
+  for (auto I : Data)
 if (I == ID)
   return;
   Data.push_back(ID);


Index: clang/lib/Serialization/ASTReaderInternals.h
===
--- clang/lib/Serialization/ASTReaderInternals.h
+++ clang/lib/Serialization/ASTReaderInternals.h
@@ -62,7 +62,7 @@
   // Just use a linear scan unless we have more than a few IDs.
   if (Found.empty() && !Data.empty()) {
 if (Data.size() <= 4) {
-  for (auto I : Found)
+  for (auto I : Data)
 if (I == ID)
   return;
   Data.push_back(ID);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D84473: Dump Accumulator

2020-07-28 Thread Kazu Hirata via Phabricator via cfe-commits
kazu updated this revision to Diff 281344.
kazu added a comment.

Spun off the llvm-readobj bit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84473

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  llvm/include/llvm/Analysis/DumpAccumulator.h
  llvm/include/llvm/InitializePasses.h
  llvm/lib/Analysis/CMakeLists.txt
  llvm/lib/Analysis/DumpAccumulator.cpp
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Passes/PassRegistry.def
  llvm/test/Other/new-pm-defaults.ll

Index: llvm/test/Other/new-pm-defaults.ll
===
--- llvm/test/Other/new-pm-defaults.ll
+++ llvm/test/Other/new-pm-defaults.ll
@@ -92,6 +92,8 @@
 ; CHECK-O-NEXT: Starting llvm::Module pass manager run.
 ; CHECK-O-NEXT: Running pass: PassManager<{{.*}}Module{{.*}}>
 ; CHECK-O-NEXT: Starting llvm::Module pass manager run.
+; CHECK-O-NEXT: RequireAnalysisPass
+; CHECK-O-NEXT: Running analysis: DumpAccumulator
 ; CHECK-O-NEXT: Running pass: ForceFunctionAttrsPass
 ; CHECK-EP-PIPELINE-START-NEXT: Running pass: NoOpModulePass
 ; CHECK-O-NEXT: Running pass: PassManager<{{.*}}Module{{.*}}>
Index: llvm/lib/Passes/PassRegistry.def
===
--- llvm/lib/Passes/PassRegistry.def
+++ llvm/lib/Passes/PassRegistry.def
@@ -28,6 +28,7 @@
 MODULE_ANALYSIS("pass-instrumentation", PassInstrumentationAnalysis(PIC))
 MODULE_ANALYSIS("asan-globals-md", ASanGlobalsMetadataAnalysis())
 MODULE_ANALYSIS("inline-advisor", InlineAdvisorAnalysis())
+MODULE_ANALYSIS("dump-accumulator", DumpAccumulator())
 
 #ifndef MODULE_ALIAS_ANALYSIS
 #define MODULE_ALIAS_ANALYSIS(NAME, CREATE_PASS)   \
Index: llvm/lib/Passes/PassBuilder.cpp
===
--- llvm/lib/Passes/PassBuilder.cpp
+++ llvm/lib/Passes/PassBuilder.cpp
@@ -31,6 +31,7 @@
 #include "llvm/Analysis/DemandedBits.h"
 #include "llvm/Analysis/DependenceAnalysis.h"
 #include "llvm/Analysis/DominanceFrontier.h"
+#include "llvm/Analysis/DumpAccumulator.h"
 #include "llvm/Analysis/FunctionPropertiesAnalysis.h"
 #include "llvm/Analysis/GlobalsModRef.h"
 #include "llvm/Analysis/IVUsers.h"
@@ -255,6 +256,10 @@
 cl::Hidden,
 cl::desc("Enable inline deferral during PGO"));
 
+cl::opt EnableDumpAccumulator("enable-dump-accumulator", cl::init(true),
+cl::Hidden,
+cl::desc("Enable the dump accumulator."));
+
 PipelineTuningOptions::PipelineTuningOptions() {
   LoopInterleaving = true;
   LoopVectorization = true;
@@ -1241,6 +1246,8 @@
 
   ModulePassManager MPM(DebugLogging);
 
+  MPM.addPass(RequireAnalysisPass());
+
   // Force any function attributes we want the rest of the pipeline to observe.
   MPM.addPass(ForceFunctionAttrsPass());
 
Index: llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
===
--- llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -29,6 +29,7 @@
 #include "llvm/ADT/Triple.h"
 #include "llvm/ADT/Twine.h"
 #include "llvm/Analysis/ConstantFolding.h"
+#include "llvm/Analysis/DumpAccumulator.h"
 #include "llvm/Analysis/EHPersonalities.h"
 #include "llvm/Analysis/OptimizationRemarkEmitter.h"
 #include "llvm/BinaryFormat/COFF.h"
@@ -106,6 +107,7 @@
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Compiler.h"
+#include "llvm/Support/Compression.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/Format.h"
 #include "llvm/Support/MathExtras.h"
@@ -246,6 +248,7 @@
   MachineFunctionPass::getAnalysisUsage(AU);
   AU.addRequired();
   AU.addRequired();
+  AU.addUsedIfAvailable();
 }
 
 bool AsmPrinter::doInitialization(Module ) {
@@ -1757,6 +1760,20 @@
 }
   }
 
+  if (auto *DumpAccumulatorAnalysis =
+  getAnalysisIfAvailable()) {
+auto *DS = OutStreamer->getContext().getELFSection(
+".llvm_dump", ELF::SHT_NOTE, ELF::SHF_STRINGS);
+OutStreamer->SwitchSection(DS);
+std::string  = DumpAccumulatorAnalysis->GetResult(M)->Message;
+SmallVector Compressed;
+Error E = zlib::compress(Out.c_str(), Compressed);
+assert(!E);
+OutStreamer->emitULEB128IntValue(Out.size());
+OutStreamer->emitULEB128IntValue(Compressed.size());
+OutStreamer->emitBytes({Compressed.data(), Compressed.size()});
+  }
+
   // Allow the target to emit any magic that it wants at the end of the file,
   // after everything else has gone out.
   emitEndOfAsmFile(M);
Index: llvm/lib/Analysis/DumpAccumulator.cpp
===
--- /dev/null
+++ llvm/lib/Analysis/DumpAccumulator.cpp
@@ -0,0 +1,30 @@
+//===- DumpAccumulator.cpp - Dumping infrastructure 

[PATCH] D84473: Dump Accumulator

2020-07-28 Thread Kazu Hirata via Phabricator via cfe-commits
kazu added a comment.

In D84473#2178167 , @jhenderson wrote:

> Could the llvm-readobj bit be spun off into a separate review, please. As 
> things stand it doesn't have any of its own testing, which should be added at 
> the same time as adding support in the tool itself. The new option is also 
> lacking any documentation in the llvm-readobj and llvm-readelf docs.

Sure.  I'll split the compiler and llvm-readobj bits and check in the former 
first.  I'll come up with documentation for the llvm-readobj bit.  Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84473

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


[PATCH] D84473: Dump Accumulator

2020-07-27 Thread Kazu Hirata via Phabricator via cfe-commits
kazu marked an inline comment as done.
kazu added inline comments.



Comment at: llvm/include/llvm/Analysis/DumpAccumulator.h:43
+//
+// Note that ThinLTO is not supported yet.
+//

mtrofin wrote:
> I'd clarify that transferring the data from pre-link thinlto to post-link 
> isn't supported, but one could use this in post-link, correct?
We don't add DumpAccumulator to the post-link ThinLTO pipeline yet.

Note that we add DumpAccumulator in buildPerModuleDefaultPipeline, but 
post-link ThinLTO doesn't call the function.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84473



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


[PATCH] D84473: Dump Accumulator

2020-07-23 Thread Kazu Hirata via Phabricator via cfe-commits
kazu created this revision.
kazu added reviewers: davidxl, mtrofin, wmi.
kazu added a project: LLVM.
Herald added subscribers: cfe-commits, rupprecht, MaskRay, hiraditya, mgorny.
Herald added a reviewer: jhenderson.
Herald added a project: clang.

This patch adds a utility called DumpAccumulator.

DumpAccumulator allows you to dump arbitrary text messages into a special
section called .llvm_dump.  The linker then concatenates these messages into
the identically named section in the final executable.

This utility makes it easy to collect information from optimization
passes of interest in a build environment that caches compilation.

See llvm/include/llvm/Analysis/DumpAccumulator.h for usage.

The original implementation is from Mircea Trofin, and I generalized it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84473

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  llvm/include/llvm/Analysis/DumpAccumulator.h
  llvm/include/llvm/InitializePasses.h
  llvm/lib/Analysis/CMakeLists.txt
  llvm/lib/Analysis/DumpAccumulator.cpp
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Passes/PassRegistry.def
  llvm/test/Other/new-pm-defaults.ll
  llvm/tools/llvm-readobj/ObjDumper.cpp
  llvm/tools/llvm-readobj/ObjDumper.h
  llvm/tools/llvm-readobj/llvm-readobj.cpp

Index: llvm/tools/llvm-readobj/llvm-readobj.cpp
===
--- llvm/tools/llvm-readobj/llvm-readobj.cpp
+++ llvm/tools/llvm-readobj/llvm-readobj.cpp
@@ -362,6 +362,10 @@
 clEnumVal(GNU, "GNU readelf style")),
  cl::init(LLVM));
 
+  // --llvm-dump
+  cl::opt LLVMDumpSection("llvm-dump", cl::desc("Print .llvm-dump"),
+cl::init(false));
+
   cl::extrahelp
   HelpResponse("\nPass @FILE as argument to read options from FILE.\n");
 } // namespace opts
@@ -487,6 +491,8 @@
 Dumper->printSymbols(opts::Symbols, opts::DynamicSymbols);
   if (!opts::StringDump.empty())
 Dumper->printSectionsAsString(Obj, opts::StringDump);
+  if (opts::LLVMDumpSection)
+Dumper->printLLVMDumpSection(Obj);
   if (!opts::HexDump.empty())
 Dumper->printSectionsAsHex(Obj, opts::HexDump);
   if (opts::HashTable)
Index: llvm/tools/llvm-readobj/ObjDumper.h
===
--- llvm/tools/llvm-readobj/ObjDumper.h
+++ llvm/tools/llvm-readobj/ObjDumper.h
@@ -100,6 +100,7 @@
 
   void printSectionsAsString(const object::ObjectFile *Obj,
  ArrayRef Sections);
+  void printLLVMDumpSection(const object::ObjectFile *Obj);
   void printSectionsAsHex(const object::ObjectFile *Obj,
   ArrayRef Sections);
 
Index: llvm/tools/llvm-readobj/ObjDumper.cpp
===
--- llvm/tools/llvm-readobj/ObjDumper.cpp
+++ llvm/tools/llvm-readobj/ObjDumper.cpp
@@ -15,8 +15,10 @@
 #include "Error.h"
 #include "llvm-readobj.h"
 #include "llvm/Object/ObjectFile.h"
+#include "llvm/Support/Compression.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/FormatVariadic.h"
+#include "llvm/Support/LEB128.h"
 #include "llvm/Support/ScopedPrinter.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
@@ -80,6 +82,45 @@
   return Ret;
 }
 
+void ObjDumper::printLLVMDumpSection(const object::ObjectFile *Obj) {
+  auto Sections = getSectionRefsByNameOrIndex(Obj, {".llvm_dump"});
+  if (Sections.size() != 1) {
+reportWarning(createError(".llvm_dump section not found"),
+  Obj->getFileName());
+return;
+  }
+  auto Section = Sections[0];
+  StringRef SectionContent =
+  unwrapOrError(Obj->getFileName(), Section.getContents());
+
+  StringRef Current = SectionContent;
+  unsigned Read = 0;
+  auto ReadNumber = [&]() {
+uint64_t V =
+decodeULEB128(reinterpret_cast(Current.data()), );
+Current = Current.substr(Read);
+return V;
+  };
+  while (Current.size() > 0) {
+uint64_t UncompressedSize = ReadNumber();
+std::unique_ptr Uncompressed(new char[UncompressedSize]);
+uint64_t CompressedSize = ReadNumber();
+if (CompressedSize > Current.size()) {
+  reportWarning(
+  createError(
+  "Expecting a larger compressed buffer than available data"),
+  Obj->getFileName());
+}
+if (auto E =
+zlib::uncompress(Current, Uncompressed.get(), UncompressedSize)) {
+  reportWarning(createError("Error decompressing"), Obj->getFileName());
+}
+Current = Current.substr(CompressedSize);
+StringRef Message(Uncompressed.get(), UncompressedSize);
+W.startLine() << Message << "\n";
+  }
+}
+
 void ObjDumper::printSectionsAsString(const object::ObjectFile *Obj,
   ArrayRef Sections) {
   bool First = true;
Index: llvm/test/Other/new-pm-defaults.ll
===
---