[PATCH] D84087: [NFC] Clean up doc comment and implementation for Module::isSubModuleOf.

2020-07-17 Thread Varun Gandhi via Phabricator via cfe-commits
varungandhi-apple updated this revision to Diff 278972.
varungandhi-apple added a comment.

Updated commit message with reviewer information and revision link.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84087

Files:
  clang/include/clang/Basic/Module.h
  clang/lib/Basic/Module.cpp


Index: clang/lib/Basic/Module.cpp
===
--- clang/lib/Basic/Module.cpp
+++ clang/lib/Basic/Module.cpp
@@ -173,14 +173,10 @@
 }
 
 bool Module::isSubModuleOf(const Module *Other) const {
-  const Module *This = this;
-  do {
+  for (const Module *This = this; This != nullptr; This = This->Parent) {
 if (This == Other)
   return true;
-
-This = This->Parent;
-  } while (This);
-
+  }
   return false;
 }
 
Index: clang/include/clang/Basic/Module.h
===
--- clang/include/clang/Basic/Module.h
+++ clang/include/clang/Basic/Module.h
@@ -457,8 +457,12 @@
   /// Determine whether this module is a submodule.
   bool isSubModule() const { return Parent != nullptr; }
 
-  /// Determine whether this module is a submodule of the given other
-  /// module.
+  /// Check if this module is a (possibly transitive) submodule of \p Other.
+  ///
+  /// The 'A is a submodule of B' relation is a partial order based on the
+  /// the parent-child relationship between individual modules.
+  ///
+  /// Returns \c false if \p Other is \c nullptr.
   bool isSubModuleOf(const Module *Other) const;
 
   /// Determine whether this module is a part of a framework,


Index: clang/lib/Basic/Module.cpp
===
--- clang/lib/Basic/Module.cpp
+++ clang/lib/Basic/Module.cpp
@@ -173,14 +173,10 @@
 }
 
 bool Module::isSubModuleOf(const Module *Other) const {
-  const Module *This = this;
-  do {
+  for (const Module *This = this; This != nullptr; This = This->Parent) {
 if (This == Other)
   return true;
-
-This = This->Parent;
-  } while (This);
-
+  }
   return false;
 }
 
Index: clang/include/clang/Basic/Module.h
===
--- clang/include/clang/Basic/Module.h
+++ clang/include/clang/Basic/Module.h
@@ -457,8 +457,12 @@
   /// Determine whether this module is a submodule.
   bool isSubModule() const { return Parent != nullptr; }
 
-  /// Determine whether this module is a submodule of the given other
-  /// module.
+  /// Check if this module is a (possibly transitive) submodule of \p Other.
+  ///
+  /// The 'A is a submodule of B' relation is a partial order based on the
+  /// the parent-child relationship between individual modules.
+  ///
+  /// Returns \c false if \p Other is \c nullptr.
   bool isSubModuleOf(const Module *Other) const;
 
   /// Determine whether this module is a part of a framework,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D84087: [NFC] Clean up doc comment and implementation for Module::isSubModuleOf.

2020-07-17 Thread Varun Gandhi via Phabricator via cfe-commits
varungandhi-apple created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84087

Files:
  clang/include/clang/Basic/Module.h
  clang/lib/Basic/Module.cpp


Index: clang/lib/Basic/Module.cpp
===
--- clang/lib/Basic/Module.cpp
+++ clang/lib/Basic/Module.cpp
@@ -173,14 +173,10 @@
 }
 
 bool Module::isSubModuleOf(const Module *Other) const {
-  const Module *This = this;
-  do {
+  for (const Module *This = this; This != nullptr; This = This->Parent) {
 if (This == Other)
   return true;
-
-This = This->Parent;
-  } while (This);
-
+  }
   return false;
 }
 
Index: clang/include/clang/Basic/Module.h
===
--- clang/include/clang/Basic/Module.h
+++ clang/include/clang/Basic/Module.h
@@ -457,8 +457,12 @@
   /// Determine whether this module is a submodule.
   bool isSubModule() const { return Parent != nullptr; }
 
-  /// Determine whether this module is a submodule of the given other
-  /// module.
+  /// Check if this module is a (possibly transitive) submodule of \p Other.
+  ///
+  /// The 'A is a submodule of B' relation is a partial order based on the
+  /// the parent-child relationship between individual modules.
+  ///
+  /// Returns \c false if \p Other is \c nullptr.
   bool isSubModuleOf(const Module *Other) const;
 
   /// Determine whether this module is a part of a framework,


Index: clang/lib/Basic/Module.cpp
===
--- clang/lib/Basic/Module.cpp
+++ clang/lib/Basic/Module.cpp
@@ -173,14 +173,10 @@
 }
 
 bool Module::isSubModuleOf(const Module *Other) const {
-  const Module *This = this;
-  do {
+  for (const Module *This = this; This != nullptr; This = This->Parent) {
 if (This == Other)
   return true;
-
-This = This->Parent;
-  } while (This);
-
+  }
   return false;
 }
 
Index: clang/include/clang/Basic/Module.h
===
--- clang/include/clang/Basic/Module.h
+++ clang/include/clang/Basic/Module.h
@@ -457,8 +457,12 @@
   /// Determine whether this module is a submodule.
   bool isSubModule() const { return Parent != nullptr; }
 
-  /// Determine whether this module is a submodule of the given other
-  /// module.
+  /// Check if this module is a (possibly transitive) submodule of \p Other.
+  ///
+  /// The 'A is a submodule of B' relation is a partial order based on the
+  /// the parent-child relationship between individual modules.
+  ///
+  /// Returns \c false if \p Other is \c nullptr.
   bool isSubModuleOf(const Module *Other) const;
 
   /// Determine whether this module is a part of a framework,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82470: [OpenMP][IRBuilder] Support allocas in nested parallel regions

2020-07-17 Thread Fady Ghanim via Phabricator via cfe-commits
fghanim accepted this revision.
fghanim added a comment.
This revision is now accepted and ready to land.

Great. Thank you!
LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82470



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


[PATCH] D83398: [OPENMP50]Perform data mapping analysis only for explicitly mapped data.

2020-07-17 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert accepted this revision.
jdoerfert added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83398



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


[PATCH] D81031: [OpenMP] Add Additional Function Attribute Information to OMPKinds.def

2020-07-17 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

In D81031#2159895 , @jhuber6 wrote:

> Fixing errors caused by unused attribute sets. Adding missing attributes to 
> barrier_codegen.cpp.
>
> Should I go ahead and commit this considering the previous was temporarily 
> reverted? Or should I just wait a bit to see if it fails testing again.


If you only did minor modifications and no major problem showed up, the 
previous LGTM still stands. You should (always) run a full make check-all 
locally (or better on a server) to verify no other issues are known.

FWIW, it happens that we break bots and patches get reverted. That is not great 
but also not too bad.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81031



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


[PATCH] D82470: [OpenMP][IRBuilder] Support allocas in nested parallel regions

2020-07-17 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert updated this revision to Diff 278952.
jdoerfert added a comment.

Reuse builder


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82470

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp

Index: llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
===
--- llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
+++ llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
@@ -6,13 +6,14 @@
 //
 //===--===//
 
+#include "llvm/Frontend/OpenMP/OMPConstants.h"
 #include "llvm/Frontend/OpenMP/OMPIRBuilder.h"
 #include "llvm/IR/BasicBlock.h"
 #include "llvm/IR/DIBuilder.h"
 #include "llvm/IR/Function.h"
+#include "llvm/IR/InstIterator.h"
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/Module.h"
-#include "llvm/Frontend/OpenMP/OMPConstants.h"
 #include "llvm/IR/Verifier.h"
 #include "llvm/Transforms/Utils/BasicBlockUtils.h"
 #include "gtest/gtest.h"
@@ -360,9 +361,11 @@
 
   auto FiniCB = [&](InsertPointTy CodeGenIP) { ++NumFinalizationPoints; };
 
+  IRBuilder<>::InsertPoint AllocaIP(&F->getEntryBlock(),
+F->getEntryBlock().getFirstInsertionPt());
   IRBuilder<>::InsertPoint AfterIP =
-  OMPBuilder.CreateParallel(Loc, BodyGenCB, PrivCB, FiniCB, nullptr,
-nullptr, OMP_PROC_BIND_default, false);
+  OMPBuilder.CreateParallel(Loc, AllocaIP, BodyGenCB, PrivCB, FiniCB,
+nullptr, nullptr, OMP_PROC_BIND_default, false);
   EXPECT_EQ(NumBodiesGenerated, 1U);
   EXPECT_EQ(NumPrivatizedVars, 1U);
   EXPECT_EQ(NumFinalizationPoints, 1U);
@@ -400,6 +403,205 @@
   EXPECT_EQ(ForkCI->getArgOperand(3), F->arg_begin());
 }
 
+TEST_F(OpenMPIRBuilderTest, ParallelNested) {
+  using InsertPointTy = OpenMPIRBuilder::InsertPointTy;
+  OpenMPIRBuilder OMPBuilder(*M);
+  OMPBuilder.initialize();
+  F->setName("func");
+  IRBuilder<> Builder(BB);
+
+  OpenMPIRBuilder::LocationDescription Loc({Builder.saveIP(), DL});
+
+  unsigned NumInnerBodiesGenerated = 0;
+  unsigned NumOuterBodiesGenerated = 0;
+  unsigned NumFinalizationPoints = 0;
+
+  auto InnerBodyGenCB = [&](InsertPointTy AllocaIP, InsertPointTy CodeGenIP,
+BasicBlock &ContinuationIP) {
+++NumInnerBodiesGenerated;
+  };
+
+  auto PrivCB = [&](InsertPointTy AllocaIP, InsertPointTy CodeGenIP,
+Value &VPtr, Value *&ReplacementValue) -> InsertPointTy {
+// Trivial copy (=firstprivate).
+Builder.restoreIP(AllocaIP);
+Type *VTy = VPtr.getType()->getPointerElementType();
+Value *V = Builder.CreateLoad(VTy, &VPtr, VPtr.getName() + ".reload");
+ReplacementValue = Builder.CreateAlloca(VTy, 0, VPtr.getName() + ".copy");
+Builder.restoreIP(CodeGenIP);
+Builder.CreateStore(V, ReplacementValue);
+return CodeGenIP;
+  };
+
+  auto FiniCB = [&](InsertPointTy CodeGenIP) { ++NumFinalizationPoints; };
+
+  auto OuterBodyGenCB = [&](InsertPointTy AllocaIP, InsertPointTy CodeGenIP,
+BasicBlock &ContinuationIP) {
+++NumOuterBodiesGenerated;
+Builder.restoreIP(CodeGenIP);
+BasicBlock *CGBB = CodeGenIP.getBlock();
+BasicBlock *NewBB = SplitBlock(CGBB, &*CodeGenIP.getPoint());
+CGBB->getTerminator()->eraseFromParent();
+;
+
+IRBuilder<>::InsertPoint AfterIP = OMPBuilder.CreateParallel(
+InsertPointTy(CGBB, CGBB->end()), AllocaIP, InnerBodyGenCB, PrivCB,
+FiniCB, nullptr, nullptr, OMP_PROC_BIND_default, false);
+
+Builder.restoreIP(AfterIP);
+Builder.CreateBr(NewBB);
+  };
+
+  IRBuilder<>::InsertPoint AllocaIP(&F->getEntryBlock(),
+F->getEntryBlock().getFirstInsertionPt());
+  IRBuilder<>::InsertPoint AfterIP =
+  OMPBuilder.CreateParallel(Loc, AllocaIP, OuterBodyGenCB, PrivCB, FiniCB,
+nullptr, nullptr, OMP_PROC_BIND_default, false);
+
+  EXPECT_EQ(NumInnerBodiesGenerated, 1U);
+  EXPECT_EQ(NumOuterBodiesGenerated, 1U);
+  EXPECT_EQ(NumFinalizationPoints, 2U);
+
+  Builder.restoreIP(AfterIP);
+  Builder.CreateRetVoid();
+
+  OMPBuilder.finalize();
+
+  EXPECT_EQ(M->size(), 5U);
+  for (Function &OutlinedFn : *M) {
+if (F == &OutlinedFn || OutlinedFn.isDeclaration())
+  continue;
+EXPECT_FALSE(verifyModule(*M, &errs()));
+EXPECT_TRUE(OutlinedFn.hasFnAttribute(Attribute::NoUnwind));
+EXPECT_TRUE(OutlinedFn.hasFnAttribute(Attribute::NoRecurse));
+EXPECT_TRUE(OutlinedFn.hasParamAttribute(0, Attribute::NoAlias));
+EXPECT_TRUE(OutlinedFn.hasParamAttribute(1, Attribute::NoAlias));
+
+EXPECT_TRUE(OutlinedFn.hasInternalLinkage());
+EXPECT_EQ(OutlinedFn.arg_size(), 2U);
+
+EXPECT_EQ(OutlinedFn.get

[PATCH] D82118: [clang][module] Improve incomplete-umbrella warning

2020-07-17 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

In D82118#2154310 , @zixuw wrote:

> In D82118#2154280 , @vsapsai wrote:
>
> > Didn't get into details but overall GenModuleActionWrapper approach looks 
> > pretty complicated. Haven't tried to accomplish the same myself, so cannot 
> > say if such complexity is warranted or not.
>
>
> Yes the approach is complicated. But one thing to note is that the 
> `GenModuleActionWrapper`-related facilities are upstreamed from 
> apple/llvm-project. I adopted this approach just because it was available. 
> Haven't explored other ways, but yes there might be a simpler approach.


My concern about this approach is that it doesn't seem to be composable and 
propagating specific frontend actions to building modules looks ad-hoc and 
error-prone. Specifically, from the composition perspective what should we do 
when both indexing 

 and fix-it are enabled? We can claim they should be mutually exclusive but 
don't know if it is applicable in general case. From the perspective of 
propagating other frontend actions to building modules I'm wondering if we need 
to have custom handling for other actions or not. Personally, I haven't checked 
that yet.

>> What happens with fixits in modules when you don't have 
>> GenModuleActionWrapper?
> 
> If the fixit action is not forwarded to the new compiler instance, it will be 
> handled by the 'outer' compiler instance, which has a different source 
> manager that does not see the module files, so the source location cannot be 
> correctly interpreted. From my experiments, the fixit hint is trying to write 
> into the `` file buffer in this test case, when I don't have the 
> action forwarded using `GenModuleActionWrapper`. In this case the fixit 
> rewriter quietly fails because `` cannot be rewritten, but since 
> this is not caught I think there might be cases where the wrong file ends up 
> getting updated.

That doesn't sound good. Though making a source manager support multiple 
compiler instances doesn't look like an easy task (and maybe not worthwhile).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82118



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


[PATCH] D81031: [OpenMP] Add Additional Function Attribute Information to OMPKinds.def

2020-07-17 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 278949.
jhuber6 added a comment.

Fixing errors caused by unused attribute sets. Adding missing attributes to 
barrier_codegen.cpp.

Should I go ahead and commit this considering the previous was temporarily 
reverted? Or should I just wait a bit to see if it fails testing again.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81031

Files:
  clang/test/OpenMP/barrier_codegen.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  llvm/test/Transforms/OpenMP/add_attributes.ll
  llvm/test/Transforms/OpenMP/parallel_deletion.ll

Index: llvm/test/Transforms/OpenMP/parallel_deletion.ll
===
--- llvm/test/Transforms/OpenMP/parallel_deletion.ll
+++ llvm/test/Transforms/OpenMP/parallel_deletion.ll
@@ -393,7 +393,7 @@
 
 define internal void @.omp.reduction.reduction_func(i8* %arg, i8* %arg1) {
 ; CHECK-LABEL: define {{[^@]+}}@.omp.reduction.reduction_func
-; CHECK-SAME: (i8* nocapture nofree nonnull readonly align 8 dereferenceable(8) [[ARG:%.*]], i8* nocapture nofree nonnull readonly align 8 dereferenceable(8) [[ARG1:%.*]]) #10
+; CHECK-SAME: (i8* nocapture nofree nonnull readonly align 8 dereferenceable(8) [[ARG:%.*]], i8* nocapture nofree nonnull readonly align 8 dereferenceable(8) [[ARG1:%.*]]) #{{[0-9]+}}
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:[[TMP:%.*]] = bitcast i8* [[ARG1]] to i32**
 ; CHECK-NEXT:[[TMP2:%.*]] = load i32*, i32** [[TMP]], align 8
Index: llvm/test/Transforms/OpenMP/add_attributes.ll
===
--- llvm/test/Transforms/OpenMP/add_attributes.ll
+++ llvm/test/Transforms/OpenMP/add_attributes.ll
@@ -890,373 +890,373 @@
 ; CHECK: ; Function Attrs: nounwind
 ; CHECK-NEXT: declare dso_local i32 @omp_get_supported_active_levels() #0
 
-; CHECK-NOT: Function Attrs
-; CHECK: declare void @__kmpc_barrier(%struct.ident_t*, i32)
+; CHECK: ; Function Attrs: nounwind
+; CHECK-NEXT: declare void @__kmpc_barrier(%struct.ident_t*, i32) #0
 
-; CHECK: Function Attrs: inaccessiblemem_or_argmemonly
-; CHECK-NEXT: declare i32 @__kmpc_cancel(%struct.ident_t*, i32, i32)
+; CHECK: ; Function Attrs: nounwind
+; CHECK-NEXT: declare i32 @__kmpc_cancel(%struct.ident_t*, i32, i32) #0
 
-; CHECK-NOT: Function Attrs
-; CHECK: declare i32 @__kmpc_cancel_barrier(%struct.ident_t*, i32)
+; CHECK: ; Function Attrs: nounwind
+; CHECK-NEXT: declare i32 @__kmpc_cancel_barrier(%struct.ident_t*, i32) #0
 
-; CHECK-NOT: Function Attrs
-; CHECK: declare void @__kmpc_flush(%struct.ident_t*)
+; CHECK: ; Function Attrs: nounwind
+; CHECK-NEXT: declare void @__kmpc_flush(%struct.ident_t*) #0
 
-; CHECK: Function Attrs: nounwind
-; CHECK-NEXT: declare i32 @__kmpc_global_thread_num(%struct.ident_t*)
+; CHECK: ; Function Attrs: nounwind
+; CHECK-NEXT: declare i32 @__kmpc_global_thread_num(%struct.ident_t*) #0
 
-; CHECK: Function Attrs: nounwind
-; CHECK-NEXT: declare void @__kmpc_fork_call(%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...)
+; CHECK: ; Function Attrs: nounwind
+; CHECK-NEXT: declare void @__kmpc_fork_call(%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) #0
 
-; CHECK-NOT: Function Attrs
-; CHECK: declare i32 @__kmpc_omp_taskwait(%struct.ident_t*, i32)
+; CHECK: ; Function Attrs: nounwind
+; CHECK-NEXT: declare i32 @__kmpc_omp_taskwait(%struct.ident_t*, i32) #0
 
-; CHECK: Function Attrs: inaccessiblemem_or_argmemonly
-; CHECK-NEXT: declare i32 @__kmpc_omp_taskyield(%struct.ident_t*, i32, i32)
+; CHECK: ; Function Attrs: nounwind
+; CHECK-NEXT: declare i32 @__kmpc_omp_taskyield(%struct.ident_t*, i32, i32) #0
 
-; CHECK: Function Attrs: inaccessiblemem_or_argmemonly
-; CHECK-NEXT: declare void @__kmpc_push_num_threads(%struct.ident_t*, i32, i32)
+; CHECK: ; Function Attrs: nounwind
+; CHECK-NEXT: declare void @__kmpc_push_num_threads(%struct.ident_t*, i32, i32) #0
 
-; CHECK: Function Attrs: inaccessiblemem_or_argmemonly
-; CHECK-NEXT: declare void @__kmpc_push_proc_bind(%struct.ident_t*, i32, i32)
+; CHECK: ; Function Attrs: nounwind
+; CHECK-NEXT: declare void @__kmpc_push_proc_bind(%struct.ident_t*, i32, i32) #0
 
-; CHECK: Function Attrs: inaccessiblemem_or_argmemonly
-; CHECK-NEXT: declare void @__kmpc_serialized_parallel(%struct.ident_t*, i32)
+; CHECK: ; Function Attrs: nounwind
+; CHECK-NEXT: declare void @__kmpc_serialized_parallel(%struct.ident_t*, i32) #0
 
-; CHECK: Function Attrs: inaccessiblemem_or_argmemonly
-; CHECK-NEXT: declare void @__kmpc_end_serialized_parallel(%struct.ident_t*, i32)
+; CHECK: ; Function Attrs: nounwind
+; CHECK-NEXT: declare void @__kmpc_end_serialized_parallel(%struct.ident_t*, i32) #0
 
-; CHECK: Function Attrs: inaccessiblemem_or_argmemonly
-; CHECK-NEXT: declare i32 @__kmpc_master(%struct.ident_t*, i32)
+; CHECK: ; Function Attrs: nounwind
+; CHECK-NEXT: declare i32 @__kmpc_master(%struct.ident_t*, i32) #0
 
-; CHECK: Function Attrs: 

[clang] 1050560 - [clang][NFC] Add a missing 'override'

2020-07-17 Thread Logan Smith via cfe-commits

Author: Logan Smith
Date: 2020-07-17T17:35:59-07:00
New Revision: 105056045d9ab0b1a49781a18129ada48893452e

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

LOG: [clang][NFC] Add a missing 'override'

Added: 


Modified: 
clang/unittests/CrossTU/CrossTranslationUnitTest.cpp

Removed: 




diff  --git a/clang/unittests/CrossTU/CrossTranslationUnitTest.cpp 
b/clang/unittests/CrossTU/CrossTranslationUnitTest.cpp
index 5495f27f5b32..4e6fbeee86a3 100644
--- a/clang/unittests/CrossTU/CrossTranslationUnitTest.cpp
+++ b/clang/unittests/CrossTU/CrossTranslationUnitTest.cpp
@@ -29,7 +29,7 @@ class CTUASTConsumer : public clang::ASTConsumer {
   explicit CTUASTConsumer(clang::CompilerInstance &CI, bool *Success)
   : CTU(CI), Success(Success) {}
 
-  void HandleTranslationUnit(ASTContext &Ctx) {
+  void HandleTranslationUnit(ASTContext &Ctx) override {
 auto FindFInTU = [](const TranslationUnitDecl *TU) {
   const FunctionDecl *FD = nullptr;
   for (const Decl *D : TU->decls()) {



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


[PATCH] D84082: [tsan] Allow TSan in the Clang driver for Apple Silicon Macs

2020-07-17 Thread Kuba (Brecka) Mracek via Phabricator via cfe-commits
kubamracek created this revision.
kubamracek added reviewers: dcoughlin, delcypher, yln, arphaman, steven_wu.
kubamracek added a project: Sanitizers.
Herald added subscribers: cfe-commits, Charusso, dexonsmith.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84082

Files:
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/test/Driver/fsanitize.c


Index: clang/test/Driver/fsanitize.c
===
--- clang/test/Driver/fsanitize.c
+++ clang/test/Driver/fsanitize.c
@@ -458,6 +458,10 @@
 
 // RUN: %clang -target x86_64-apple-darwin -fsanitize=thread %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-TSAN-X86-64-DARWIN
 // CHECK-TSAN-X86-64-DARWIN-NOT: unsupported option
+// RUN: %clang -target x86_64-apple-macos -fsanitize=thread %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-TSAN-X86-64-MACOS
+// CHECK-TSAN-X86-64-MACOS-NOT: unsupported option
+// RUN: %clang -target arm64-apple-macos -fsanitize=thread %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-TSAN-ARM64-MACOS
+// CHECK-TSAN-ARM64-MACOS-NOT: unsupported option
 
 // RUN: %clang -target x86_64-apple-iossimulator -fsanitize=thread %s -### 
2>&1 | FileCheck %s --check-prefix=CHECK-TSAN-X86-64-IOSSIMULATOR
 // CHECK-TSAN-X86-64-IOSSIMULATOR-NOT: unsupported option
Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -2713,6 +2713,7 @@
 
 SanitizerMask Darwin::getSupportedSanitizers() const {
   const bool IsX86_64 = getTriple().getArch() == llvm::Triple::x86_64;
+  const bool IsAArch64 = getTriple().getArch() == llvm::Triple::aarch64;
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
   Res |= SanitizerKind::Address;
   Res |= SanitizerKind::PointerCompare;
@@ -2730,9 +2731,8 @@
   && !(isTargetIPhoneOS() && isIPhoneOSVersionLT(5, 0)))
 Res |= SanitizerKind::Vptr;
 
-  if (isTargetMacOS()) {
-if (IsX86_64)
-  Res |= SanitizerKind::Thread;
+  if ((IsX86_64 || IsAArch64) && isTargetMacOS()) {
+Res |= SanitizerKind::Thread;
   } else if (isTargetIOSSimulator() || isTargetTvOSSimulator()) {
 if (IsX86_64)
   Res |= SanitizerKind::Thread;


Index: clang/test/Driver/fsanitize.c
===
--- clang/test/Driver/fsanitize.c
+++ clang/test/Driver/fsanitize.c
@@ -458,6 +458,10 @@
 
 // RUN: %clang -target x86_64-apple-darwin -fsanitize=thread %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TSAN-X86-64-DARWIN
 // CHECK-TSAN-X86-64-DARWIN-NOT: unsupported option
+// RUN: %clang -target x86_64-apple-macos -fsanitize=thread %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TSAN-X86-64-MACOS
+// CHECK-TSAN-X86-64-MACOS-NOT: unsupported option
+// RUN: %clang -target arm64-apple-macos -fsanitize=thread %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TSAN-ARM64-MACOS
+// CHECK-TSAN-ARM64-MACOS-NOT: unsupported option
 
 // RUN: %clang -target x86_64-apple-iossimulator -fsanitize=thread %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TSAN-X86-64-IOSSIMULATOR
 // CHECK-TSAN-X86-64-IOSSIMULATOR-NOT: unsupported option
Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -2713,6 +2713,7 @@
 
 SanitizerMask Darwin::getSupportedSanitizers() const {
   const bool IsX86_64 = getTriple().getArch() == llvm::Triple::x86_64;
+  const bool IsAArch64 = getTriple().getArch() == llvm::Triple::aarch64;
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
   Res |= SanitizerKind::Address;
   Res |= SanitizerKind::PointerCompare;
@@ -2730,9 +2731,8 @@
   && !(isTargetIPhoneOS() && isIPhoneOSVersionLT(5, 0)))
 Res |= SanitizerKind::Vptr;
 
-  if (isTargetMacOS()) {
-if (IsX86_64)
-  Res |= SanitizerKind::Thread;
+  if ((IsX86_64 || IsAArch64) && isTargetMacOS()) {
+Res |= SanitizerKind::Thread;
   } else if (isTargetIOSSimulator() || isTargetTvOSSimulator()) {
 if (IsX86_64)
   Res |= SanitizerKind::Thread;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D81031: [OpenMP] Add Additional Function Attribute Information to OMPKinds.def

2020-07-17 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D81031#2159796 , @leonardchan wrote:

> In D81031#2159646 , @sstefan1 wrote:
>
> > Just in case you haven't seen already, 
> > `clang/test/OpenMP/barrier_codegen.cpp` needs to be updated as well.
>
>
> Also chiming in to say we're seeing these failures on our bots 
> (https://logs.chromium.org/logs/fuchsia/buildbucket/cr-buildbucket.appspot.com/8874490785658285184/+/steps/clang/0/steps/test/0/stdout?format=raw).
>  Could you send out an update?


Very sorry, in an earlier version I had that fixed but for whatever reason it 
got lost somewhere when I did a pull and I didn't notice. What's bizarre is 
that I ran a check-all and it didn't seem to catch it on my end. I'll push an 
update with that fixed and removing the unused attributes ASAP.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81031



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


[PATCH] D83731: Add Debug Info Size to Symbol Status

2020-07-17 Thread walter erquinigo via Phabricator via cfe-commits
wallace accepted this revision.
wallace added inline comments.



Comment at: lldb/test/API/tools/lldb-vscode/module/TestVSCode_module.py:65
+@skipIfWindows
+@ skipUnlessDarwin
+@skipIfRemote  

remove this whitespace


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83731



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


[PATCH] D81031: [OpenMP] Add Additional Function Attribute Information to OMPKinds.def

2020-07-17 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

In D81031#2159646 , @sstefan1 wrote:

> Just in case you haven't seen already, 
> `clang/test/OpenMP/barrier_codegen.cpp` needs to be updated as well.


Also chiming in to say we're seeing these failures on our bots 
(https://logs.chromium.org/logs/fuchsia/buildbucket/cr-buildbucket.appspot.com/8874490785658285184/+/steps/clang/0/steps/test/0/stdout?format=raw).
 Could you send out an update?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81031



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


[PATCH] D83454: [CMake] Make `intrinsics_gen` dependency unconditional.

2020-07-17 Thread Fangrui Song via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG53880b8cb9c6: [CMake] Make `intrinsics_gen` dependency 
unconditional. (authored by michele.scandale, committed by MaskRay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83454

Files:
  clang/CMakeLists.txt
  clang/lib/CodeGen/CMakeLists.txt
  clang/lib/Frontend/CMakeLists.txt
  clang/tools/clang-fuzzer/handle-llvm/CMakeLists.txt
  clang/tools/clang-import-test/CMakeLists.txt
  clang/tools/clang-offload-bundler/CMakeLists.txt
  clang/tools/clang-offload-wrapper/CMakeLists.txt
  clang/tools/driver/CMakeLists.txt
  lld/COFF/CMakeLists.txt
  lld/Common/CMakeLists.txt
  lld/ELF/CMakeLists.txt
  lld/MinGW/CMakeLists.txt
  lld/lib/Core/CMakeLists.txt
  lld/wasm/CMakeLists.txt
  lldb/CMakeLists.txt
  lldb/source/Expression/CMakeLists.txt
  lldb/source/Plugins/ExpressionParser/Clang/CMakeLists.txt
  
lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/CMakeLists.txt

Index: lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/CMakeLists.txt
===
--- lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/CMakeLists.txt
+++ lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/CMakeLists.txt
@@ -1,8 +1,3 @@
-if(NOT LLDB_BUILT_STANDALONE)
-  set(tablegen_deps intrinsics_gen)
-endif()
-
-
 add_lldb_library(lldbPluginRenderScriptRuntime PLUGIN
   RenderScriptRuntime.cpp
   RenderScriptExpressionOpts.cpp
@@ -10,7 +5,7 @@
   RenderScriptScriptGroup.cpp
 
   DEPENDS
-  ${tablegen_deps}
+  intrinsics_gen
 
   LINK_LIBS
 lldbBreakpoint
Index: lldb/source/Plugins/ExpressionParser/Clang/CMakeLists.txt
===
--- lldb/source/Plugins/ExpressionParser/Clang/CMakeLists.txt
+++ lldb/source/Plugins/ExpressionParser/Clang/CMakeLists.txt
@@ -1,7 +1,3 @@
-if(NOT LLDB_BUILT_STANDALONE)
-  set(tablegen_deps intrinsics_gen)
-endif()
-
 add_lldb_library(lldbPluginExpressionParserClang
   ASTResultSynthesizer.cpp
   ASTStructExtractor.cpp
@@ -29,7 +25,7 @@
   NameSearchContext.cpp
 
   DEPENDS
-  ${tablegen_deps}
+  intrinsics_gen
 
   LINK_LIBS
 lldbCore
Index: lldb/source/Expression/CMakeLists.txt
===
--- lldb/source/Expression/CMakeLists.txt
+++ lldb/source/Expression/CMakeLists.txt
@@ -1,7 +1,3 @@
-if(NOT LLDB_BUILT_STANDALONE)
-  set(tablegen_deps intrinsics_gen)
-endif()
-
 add_lldb_library(lldbExpression
   DiagnosticManager.cpp
   DWARFExpression.cpp
@@ -18,7 +14,7 @@
   UtilityFunction.cpp
 
   DEPENDS
-  ${tablegen_deps}
+  intrinsics_gen
 
   LINK_LIBS
 lldbCore
Index: lldb/CMakeLists.txt
===
--- lldb/CMakeLists.txt
+++ lldb/CMakeLists.txt
@@ -64,7 +64,7 @@
 # some of these generated headers. This approach is copied from Clang's main
 # CMakeLists.txt, so it should kept in sync the code in Clang which was added
 # in llvm-svn 308844.
-if(LLVM_ENABLE_MODULES AND NOT LLDB_BUILT_STANDALONE)
+if(LLVM_ENABLE_MODULES)
   list(APPEND LLVM_COMMON_DEPENDS intrinsics_gen)
 endif()
 
Index: lld/wasm/CMakeLists.txt
===
--- lld/wasm/CMakeLists.txt
+++ lld/wasm/CMakeLists.txt
@@ -2,10 +2,6 @@
 tablegen(LLVM Options.inc -gen-opt-parser-defs)
 add_public_tablegen_target(WasmOptionsTableGen)
 
-if(NOT LLD_BUILT_STANDALONE)
-  set(tablegen_deps intrinsics_gen)
-endif()
-
 add_lld_library(lldWasm
   Driver.cpp
   InputChunks.cpp
@@ -37,5 +33,5 @@
 
   DEPENDS
   WasmOptionsTableGen
-  ${tablegen_deps}
+  intrinsics_gen
   )
Index: lld/lib/Core/CMakeLists.txt
===
--- lld/lib/Core/CMakeLists.txt
+++ lld/lib/Core/CMakeLists.txt
@@ -1,7 +1,3 @@
-if(NOT LLD_BUILT_STANDALONE)
-  set(tablegen_deps intrinsics_gen)
-endif()
-
 add_lld_library(lldCore
   DefinedAtom.cpp
   Error.cpp
@@ -24,5 +20,5 @@
   ${LLVM_PTHREAD_LIB}
 
   DEPENDS
-  ${tablegen_deps}
+  intrinsics_gen
   )
Index: lld/MinGW/CMakeLists.txt
===
--- lld/MinGW/CMakeLists.txt
+++ lld/MinGW/CMakeLists.txt
@@ -2,10 +2,6 @@
 tablegen(LLVM Options.inc -gen-opt-parser-defs)
 add_public_tablegen_target(MinGWOptionsTableGen)
 
-if(NOT LLD_BUILT_STANDALONE)
-  set(tablegen_deps intrinsics_gen)
-endif()
-
 add_lld_library(lldMinGW
   Driver.cpp
 
@@ -19,5 +15,5 @@
 
   DEPENDS
   MinGWOptionsTableGen
-  ${tablegen_deps}
+  intrinsics_gen
 )
Index: lld/ELF/CMakeLists.txt
===
--- lld/ELF/CMakeLists.txt
+++ lld/ELF/CMakeLists.txt
@@ -2,10 +2,6 @@
 tablegen(LLVM Options.inc -gen-opt-parser-defs)
 add_public_tablegen_target(ELFOptionsTableGen)
 
-if(NOT LLD_

[clang] 53880b8 - [CMake] Make `intrinsics_gen` dependency unconditional.

2020-07-17 Thread Fangrui Song via cfe-commits

Author: Michele Scandale
Date: 2020-07-17T16:43:17-07:00
New Revision: 53880b8cb9c61e81457d13c0adefe51ff41664fa

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

LOG: [CMake] Make `intrinsics_gen` dependency unconditional.

The `intrinsics_gen` target exists in the CMake exports since r309389
(see LLVMConfig.cmake.in), hence projects can depend on `intrinsics_gen`
even it they are built separately from LLVM.

Reviewed By: MaskRay, JDevlieghere

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

Added: 


Modified: 
clang/CMakeLists.txt
clang/lib/CodeGen/CMakeLists.txt
clang/lib/Frontend/CMakeLists.txt
clang/tools/clang-fuzzer/handle-llvm/CMakeLists.txt
clang/tools/clang-import-test/CMakeLists.txt
clang/tools/clang-offload-bundler/CMakeLists.txt
clang/tools/clang-offload-wrapper/CMakeLists.txt
clang/tools/driver/CMakeLists.txt
lld/COFF/CMakeLists.txt
lld/Common/CMakeLists.txt
lld/ELF/CMakeLists.txt
lld/MinGW/CMakeLists.txt
lld/lib/Core/CMakeLists.txt
lld/wasm/CMakeLists.txt
lldb/CMakeLists.txt
lldb/source/Expression/CMakeLists.txt
lldb/source/Plugins/ExpressionParser/Clang/CMakeLists.txt

lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/CMakeLists.txt

Removed: 




diff  --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index 7f8e0718c2eb..948452661a32 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -531,7 +531,7 @@ list(APPEND LLVM_COMMON_DEPENDS clang-tablegen-targets)
 # Force target to be built as soon as possible. Clang modules builds depend
 # header-wise on it as they ship all headers from the umbrella folders. 
Building
 # an entire module might include header, which depends on intrinsics_gen.
-if(LLVM_ENABLE_MODULES AND NOT CLANG_BUILT_STANDALONE)
+if(LLVM_ENABLE_MODULES)
   list(APPEND LLVM_COMMON_DEPENDS intrinsics_gen)
 endif()
 

diff  --git a/clang/lib/CodeGen/CMakeLists.txt 
b/clang/lib/CodeGen/CMakeLists.txt
index c4bedf34921c..8afd7219fbe1 100644
--- a/clang/lib/CodeGen/CMakeLists.txt
+++ b/clang/lib/CodeGen/CMakeLists.txt
@@ -26,15 +26,6 @@ set(LLVM_LINK_COMPONENTS
   TransformUtils
   )
 
-# In a standard Clang+LLVM build, we need to generate intrinsics before
-# building codegen. In a standalone build, LLVM is already built and we don't
-# need this dependency. Furthermore, LLVM doesn't export it so we can't have
-# this dependency.
-set(codegen_deps intrinsics_gen)
-if (CLANG_BUILT_STANDALONE)
-  set(codegen_deps)
-endif()
-
 if (MSVC)
   set_source_files_properties(CodeGenModule.cpp PROPERTIES COMPILE_FLAGS 
/bigobj)
 endif()
@@ -99,7 +90,7 @@ add_clang_library(clangCodeGen
   VarBypassDetector.cpp
 
   DEPENDS
-  ${codegen_deps}
+  intrinsics_gen
 
   LINK_LIBS
   clangAnalysis

diff  --git a/clang/lib/Frontend/CMakeLists.txt 
b/clang/lib/Frontend/CMakeLists.txt
index 0e23b92e2dea..af5446618b03 100644
--- a/clang/lib/Frontend/CMakeLists.txt
+++ b/clang/lib/Frontend/CMakeLists.txt
@@ -8,11 +8,6 @@ set(LLVM_LINK_COMPONENTS
   Support
   )
 
-set(optional_deps intrinsics_gen)
-if (CLANG_BUILT_STANDALONE)
-  set(optional_deps)
-endif()
-
 add_clang_library(clangFrontend
   ASTConsumers.cpp
   ASTMerge.cpp
@@ -49,7 +44,7 @@ add_clang_library(clangFrontend
 
   DEPENDS
   ClangDriverOptions
-  ${optional_deps}
+  intrinsics_gen
 
   LINK_LIBS
   clangAST

diff  --git a/clang/tools/clang-fuzzer/handle-llvm/CMakeLists.txt 
b/clang/tools/clang-fuzzer/handle-llvm/CMakeLists.txt
index 47f9fdf68f40..9ceb1d331828 100644
--- a/clang/tools/clang-fuzzer/handle-llvm/CMakeLists.txt
+++ b/clang/tools/clang-fuzzer/handle-llvm/CMakeLists.txt
@@ -16,15 +16,9 @@ set(LLVM_LINK_COMPONENTS
   native
 )
 
-# Depend on LLVM IR intrinsic generation.
-set(handle_llvm_deps intrinsics_gen)
-if (CLANG_BUILT_STANDALONE)
-  set(handle_llvm_deps)
-endif()
-
 add_clang_library(clangHandleLLVM
   handle_llvm.cpp
 
   DEPENDS
-  ${handle_llvm_deps}
+  intrinsics_gen
   )

diff  --git a/clang/tools/clang-import-test/CMakeLists.txt 
b/clang/tools/clang-import-test/CMakeLists.txt
index 4ccc2d752aac..e459de8f635f 100644
--- a/clang/tools/clang-import-test/CMakeLists.txt
+++ b/clang/tools/clang-import-test/CMakeLists.txt
@@ -3,14 +3,10 @@ set(LLVM_LINK_COMPONENTS
   Support
   )
 
-if(NOT CLANG_BUILT_STANDALONE)
-  set(tablegen_deps intrinsics_gen)
-endif()
-
 add_clang_executable(clang-import-test
   clang-import-test.cpp
   DEPENDS
-  ${tablegen_deps}
+  intrinsics_gen
   )
 
 set(CLANG_IMPORT_TEST_LIB_DEPS

diff  --git a/clang/tools/clang-offload-bundler/CMakeLists.txt 
b/clang/tools/clang-offload-bundler/CMakeLists.txt
index 4ef099493364..2738bf02e729 100644
--- a/clang/tools/clang-offload-bundler/CMakeLists.txt
+++ b/clang/tools/clang-offload-bundler/CMakeLists.txt
@@ -1,14 +1,10 @@
 

[PATCH] D83061: [OpenMP] Implement TR8 `present` map type modifier in Clang (1/2)

2020-07-17 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny marked 2 inline comments as done.
jdenny added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:7934-7940
+// If any element has the present modifier, then make sure the runtime
+// doesn't attempt to allocate the struct.
+if (CurTypes.end() !=
+llvm::find_if(CurTypes, [](OpenMPOffloadMappingFlags Type) {
+  return Type & OMP_MAP_PRESENT;
+}))
+  Types.back() |= OMP_MAP_PRESENT;

ABataev wrote:
> Why do we need this extra stuff here?
For example:

```
#pragma omp target map(present, tofrom: s.x[0:3])
```

This generates 2 map entries:

  - `s`: 0x1020
  - `s.x`: 0x11003

Without the above change, the 0x1000 is missing from the first entry.  As a 
result, `s` is allocated, and then the presence check for `s.x` incorrectly 
passes at run time.



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

https://reviews.llvm.org/D83061



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


[PATCH] D83494: [libFuzzer] Link libFuzzer's own interceptors when other compiler runtimes are not linked.

2020-07-17 Thread Dokyung Song via Phabricator via cfe-commits
dokyungs marked 4 inline comments as done.
dokyungs added inline comments.



Comment at: compiler-rt/lib/fuzzer/FuzzerInterceptors.cpp:119
+return internal_memcmp(s1, s2, n);
+  ensureFuzzerInited();
+  int result = REAL(memcmp)(s1, s2, n);

morehouse wrote:
> I think `ensureFuzzerInited` is no longer useful here.
Fixed also in `strncmp` and `strstr` interceptors.



Comment at: compiler-rt/test/fuzzer/custom-allocator.test:2
+UNSUPPORTED: freebsd
+RUN: %cpp_compiler -fno-sanitize=all -fno-builtin %S/CustomAllocator.cpp -fPIC 
%ld_flags_rpath_so1 -O0 -shared -o %dynamiclib1
+RUN: %cpp_compiler -fno-sanitize=address %S/CustomAllocatorTest.cpp 
%ld_flags_rpath_exe1 -o %t-NoAsanCustomAllocatorTest

morehouse wrote:
> Why do we need each of these flags?
With all the flags, I designed this test for the recent failure scenario in 
which tcmalloc calls strncmp (+memcmp/strstr) when the fuzzer interceptor 
library is linked into the libFuzzer executable.

As such, we need to turn off ASan (-fno-sanitize=address) when building the 
executable to let the fuzzer interceptor library be linked.

As to the flags used to build the allocator shared library, I wanted to disable 
ASan and Fuzzer (via `-fno-sanitize=all`) because allocator libraries are 
typically not instrumented for OOB/UAF errors or coverage. I also wanted to 
prevent the compiler from optimizing out our calls to strncmp(+memcmp/strstr) 
by giving `-fno-builtin`; calls to these functions must go to the fuzzer 
interceptor library to comply with the scenario.



Comment at: compiler-rt/test/fuzzer/memcmp.test:9
+RUN: %cpp_compiler -fno-sanitize=all -fno-builtin %S/CustomAllocator.cpp -fPIC 
%ld_flags_rpath_so1 -O0 -shared -o %dynamiclib1
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-memcmp %S/MemcmpTest.cpp 
%ld_flags_rpath_exe1 -o %t-NoAsanCustomAllocatorMemcmpTest
+RUN: not %run %t-NoAsanCustomAllocatorMemcmpTest-seed=1 -runs=1000 
  2>&1 | FileCheck %s

morehouse wrote:
> Why is the custom allocator test here useful?
To make sure exercise the path where memcmp is called (i) in the calloc 
context, and (ii) then again in the LLVMFuzzerTestOneInput context. 
%t-NoAsanCustomAllocatorTest only tests (i), and %t-NoAsanMemcmpTest only tests 
(ii).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83494



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


[PATCH] D83494: [libFuzzer] Link libFuzzer's own interceptors when other compiler runtimes are not linked.

2020-07-17 Thread Dokyung Song via Phabricator via cfe-commits
dokyungs updated this revision to Diff 278924.
dokyungs marked 2 inline comments as done.
dokyungs added a comment.

Removed CustomAllocatorTest.cpp. Instead, use EmptyTest.cpp.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83494

Files:
  clang/include/clang/Driver/SanitizerArgs.h
  clang/lib/Driver/SanitizerArgs.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  compiler-rt/lib/fuzzer/CMakeLists.txt
  compiler-rt/lib/fuzzer/FuzzerInterceptors.cpp
  compiler-rt/test/fuzzer/CustomAllocator.cpp
  compiler-rt/test/fuzzer/custom-allocator.test
  compiler-rt/test/fuzzer/memcmp.test
  compiler-rt/test/fuzzer/memcmp64.test
  compiler-rt/test/fuzzer/strcmp.test
  compiler-rt/test/fuzzer/strncmp.test
  compiler-rt/test/fuzzer/strstr.test

Index: compiler-rt/test/fuzzer/strstr.test
===
--- compiler-rt/test/fuzzer/strstr.test
+++ compiler-rt/test/fuzzer/strstr.test
@@ -1,5 +1,12 @@
 UNSUPPORTED: freebsd
 RUN: %cpp_compiler %S/StrstrTest.cpp -o %t-StrstrTest
 RUN: not %run %t-StrstrTest   -seed=1 -runs=200   2>&1 | FileCheck %s
-CHECK: BINGO
 
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-strstr %S/StrstrTest.cpp -o %t-NoAsanStrstrTest
+RUN: not %run %t-NoAsanStrstrTest -seed=1 -runs=200   2>&1 | FileCheck %s
+
+RUN: %cpp_compiler -fno-sanitize=all -fno-builtin %S/CustomAllocator.cpp -fPIC %ld_flags_rpath_so1 -O0 -shared -o %dynamiclib1
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-strstr %S/StrstrTest.cpp %ld_flags_rpath_exe1 -o %t-NoAsanCustomAllocatorStrstrTest
+RUN: not %run %t-NoAsanCustomAllocatorStrstrTest-seed=1 -runs=200   2>&1 | FileCheck %s
+
+CHECK: BINGO
Index: compiler-rt/test/fuzzer/strncmp.test
===
--- compiler-rt/test/fuzzer/strncmp.test
+++ compiler-rt/test/fuzzer/strncmp.test
@@ -1,5 +1,12 @@
 UNSUPPORTED: freebsd
 RUN: %cpp_compiler %S/StrncmpTest.cpp -o %t-StrncmpTest
 RUN: not %run %t-StrncmpTest  -seed=2 -runs=1000   2>&1 | FileCheck %s
-CHECK: BINGO
 
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-strncmp %S/StrncmpTest.cpp -o %t-NoAsanStrncmpTest
+RUN: not %run %t-NoAsanStrncmpTest-seed=2 -runs=1000   2>&1 | FileCheck %s
+
+RUN: %cpp_compiler -fno-sanitize=all -fno-builtin %S/CustomAllocator.cpp -fPIC %ld_flags_rpath_so1 -O0 -shared -o %dynamiclib1
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-strncmp %S/StrncmpTest.cpp %ld_flags_rpath_exe1 -o %t-NoAsanCustomAllocatorStrncmpTest
+RUN: not %run %t-NoAsanCustomAllocatorStrncmpTest-seed=2 -runs=1000   2>&1 | FileCheck %s
+
+CHECK: BINGO
Index: compiler-rt/test/fuzzer/strcmp.test
===
--- compiler-rt/test/fuzzer/strcmp.test
+++ compiler-rt/test/fuzzer/strcmp.test
@@ -1,5 +1,8 @@
 UNSUPPORTED: freebsd
 RUN: %cpp_compiler %S/StrcmpTest.cpp -o %t-StrcmpTest
 RUN: not %run %t-StrcmpTest   -seed=1 -runs=200   2>&1 | FileCheck %s
-CHECK: BINGO
 
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-strcmp %S/StrcmpTest.cpp -o %t-NoAsanStrcmpTest
+RUN: not %run %t-NoAsanStrcmpTest -seed=1 -runs=200   2>&1 | FileCheck %s
+
+CHECK: BINGO
Index: compiler-rt/test/fuzzer/memcmp64.test
===
--- compiler-rt/test/fuzzer/memcmp64.test
+++ compiler-rt/test/fuzzer/memcmp64.test
@@ -1,4 +1,8 @@
 UNSUPPORTED: freebsd
 RUN: %cpp_compiler %S/Memcmp64BytesTest.cpp -o %t-Memcmp64BytesTest
 RUN: not %run %t-Memcmp64BytesTest-seed=1 -runs=100   2>&1 | FileCheck %s
+
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-memcmp %S/Memcmp64BytesTest.cpp -o %t-NoAsanMemcmp64BytesTest
+RUN: not %run %t-NoAsanMemcmp64BytesTest  -seed=1 -runs=100   2>&1 | FileCheck %s
+
 CHECK: BINGO
Index: compiler-rt/test/fuzzer/memcmp.test
===
--- compiler-rt/test/fuzzer/memcmp.test
+++ compiler-rt/test/fuzzer/memcmp.test
@@ -1,4 +1,12 @@
 UNSUPPORTED: freebsd
 RUN: %cpp_compiler %S/MemcmpTest.cpp -o %t-MemcmpTest
 RUN: not %run %t-MemcmpTest   -seed=1 -runs=1000   2>&1 | FileCheck %s
+
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-memcmp %S/MemcmpTest.cpp -o %t-NoAsanMemcmpTest
+RUN: not %run %t-NoAsanMemcmpTest -seed=1 -runs=1000   2>&1 | FileCheck %s
+
+RUN: %cpp_compiler -fno-sanitize=all -fno-builtin %S/CustomAllocator.cpp -fPIC %ld_flags_rpath_so1 -O0 -shared -o %dynamiclib1
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-memcmp %S/MemcmpTest.cpp %ld_flags_rpath_exe1 -o %t-NoAsanCustomAllocatorMemcmpTest
+RUN: not %run %t-NoAsanCustomAllocatorMemcmpTest-seed=1 -runs=1000   2>&1 | FileCheck %s
+
 CHECK: BINGO
Index: compiler-rt/test/fuzzer/custom-allocator.test

[PATCH] D83494: [libFuzzer] Link libFuzzer's own interceptors when other compiler runtimes are not linked.

2020-07-17 Thread Dokyung Song via Phabricator via cfe-commits
dokyungs updated this revision to Diff 278923.
dokyungs added a comment.

Addressed comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83494

Files:
  clang/include/clang/Driver/SanitizerArgs.h
  clang/lib/Driver/SanitizerArgs.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  compiler-rt/lib/fuzzer/CMakeLists.txt
  compiler-rt/lib/fuzzer/FuzzerInterceptors.cpp
  compiler-rt/test/fuzzer/CustomAllocator.cpp
  compiler-rt/test/fuzzer/CustomAllocatorTest.cpp
  compiler-rt/test/fuzzer/custom-allocator.test
  compiler-rt/test/fuzzer/memcmp.test
  compiler-rt/test/fuzzer/memcmp64.test
  compiler-rt/test/fuzzer/strcmp.test
  compiler-rt/test/fuzzer/strncmp.test
  compiler-rt/test/fuzzer/strstr.test

Index: compiler-rt/test/fuzzer/strstr.test
===
--- compiler-rt/test/fuzzer/strstr.test
+++ compiler-rt/test/fuzzer/strstr.test
@@ -1,5 +1,12 @@
 UNSUPPORTED: freebsd
 RUN: %cpp_compiler %S/StrstrTest.cpp -o %t-StrstrTest
 RUN: not %run %t-StrstrTest   -seed=1 -runs=200   2>&1 | FileCheck %s
-CHECK: BINGO
 
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-strstr %S/StrstrTest.cpp -o %t-NoAsanStrstrTest
+RUN: not %run %t-NoAsanStrstrTest -seed=1 -runs=200   2>&1 | FileCheck %s
+
+RUN: %cpp_compiler -fno-sanitize=all -fno-builtin %S/CustomAllocator.cpp -fPIC %ld_flags_rpath_so1 -O0 -shared -o %dynamiclib1
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-strstr %S/StrstrTest.cpp %ld_flags_rpath_exe1 -o %t-NoAsanCustomAllocatorStrstrTest
+RUN: not %run %t-NoAsanCustomAllocatorStrstrTest-seed=1 -runs=200   2>&1 | FileCheck %s
+
+CHECK: BINGO
Index: compiler-rt/test/fuzzer/strncmp.test
===
--- compiler-rt/test/fuzzer/strncmp.test
+++ compiler-rt/test/fuzzer/strncmp.test
@@ -1,5 +1,12 @@
 UNSUPPORTED: freebsd
 RUN: %cpp_compiler %S/StrncmpTest.cpp -o %t-StrncmpTest
 RUN: not %run %t-StrncmpTest  -seed=2 -runs=1000   2>&1 | FileCheck %s
-CHECK: BINGO
 
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-strncmp %S/StrncmpTest.cpp -o %t-NoAsanStrncmpTest
+RUN: not %run %t-NoAsanStrncmpTest-seed=2 -runs=1000   2>&1 | FileCheck %s
+
+RUN: %cpp_compiler -fno-sanitize=all -fno-builtin %S/CustomAllocator.cpp -fPIC %ld_flags_rpath_so1 -O0 -shared -o %dynamiclib1
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-strncmp %S/StrncmpTest.cpp %ld_flags_rpath_exe1 -o %t-NoAsanCustomAllocatorStrncmpTest
+RUN: not %run %t-NoAsanCustomAllocatorStrncmpTest-seed=2 -runs=1000   2>&1 | FileCheck %s
+
+CHECK: BINGO
Index: compiler-rt/test/fuzzer/strcmp.test
===
--- compiler-rt/test/fuzzer/strcmp.test
+++ compiler-rt/test/fuzzer/strcmp.test
@@ -1,5 +1,8 @@
 UNSUPPORTED: freebsd
 RUN: %cpp_compiler %S/StrcmpTest.cpp -o %t-StrcmpTest
 RUN: not %run %t-StrcmpTest   -seed=1 -runs=200   2>&1 | FileCheck %s
-CHECK: BINGO
 
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-strcmp %S/StrcmpTest.cpp -o %t-NoAsanStrcmpTest
+RUN: not %run %t-NoAsanStrcmpTest -seed=1 -runs=200   2>&1 | FileCheck %s
+
+CHECK: BINGO
Index: compiler-rt/test/fuzzer/memcmp64.test
===
--- compiler-rt/test/fuzzer/memcmp64.test
+++ compiler-rt/test/fuzzer/memcmp64.test
@@ -1,4 +1,8 @@
 UNSUPPORTED: freebsd
 RUN: %cpp_compiler %S/Memcmp64BytesTest.cpp -o %t-Memcmp64BytesTest
 RUN: not %run %t-Memcmp64BytesTest-seed=1 -runs=100   2>&1 | FileCheck %s
+
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-memcmp %S/Memcmp64BytesTest.cpp -o %t-NoAsanMemcmp64BytesTest
+RUN: not %run %t-NoAsanMemcmp64BytesTest  -seed=1 -runs=100   2>&1 | FileCheck %s
+
 CHECK: BINGO
Index: compiler-rt/test/fuzzer/memcmp.test
===
--- compiler-rt/test/fuzzer/memcmp.test
+++ compiler-rt/test/fuzzer/memcmp.test
@@ -1,4 +1,12 @@
 UNSUPPORTED: freebsd
 RUN: %cpp_compiler %S/MemcmpTest.cpp -o %t-MemcmpTest
 RUN: not %run %t-MemcmpTest   -seed=1 -runs=1000   2>&1 | FileCheck %s
+
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-memcmp %S/MemcmpTest.cpp -o %t-NoAsanMemcmpTest
+RUN: not %run %t-NoAsanMemcmpTest -seed=1 -runs=1000   2>&1 | FileCheck %s
+
+RUN: %cpp_compiler -fno-sanitize=all -fno-builtin %S/CustomAllocator.cpp -fPIC %ld_flags_rpath_so1 -O0 -shared -o %dynamiclib1
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-memcmp %S/MemcmpTest.cpp %ld_flags_rpath_exe1 -o %t-NoAsanCustomAllocatorMemcmpTest
+RUN: not %run %t-NoAsanCustomAllocatorMemcmpTest-seed=1 -runs=1000   2>&1 | FileCheck %s
+
 CHECK: BINGO
Index: compiler-rt/test/fuzzer/custom-allocator.test
==

[PATCH] D83731: Add Debug Info Size to Symbol Status

2020-07-17 Thread Yifan Shen via Phabricator via cfe-commits
aelitashen updated this revision to Diff 278922.
aelitashen added a comment.

Add TODO comment for Linux, Use ostringstream for Debug Info Size message.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83731

Files:
  clang/tools/clang-format/git-clang-format
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
  lldb/test/API/tools/lldb-vscode/module/TestVSCode_module.py
  lldb/tools/lldb-vscode/JSONUtils.cpp

Index: lldb/tools/lldb-vscode/JSONUtils.cpp
===
--- lldb/tools/lldb-vscode/JSONUtils.cpp
+++ lldb/tools/lldb-vscode/JSONUtils.cpp
@@ -7,6 +7,8 @@
 //===--===//
 
 #include 
+#include 
+#include 
 
 #include "llvm/ADT/Optional.h"
 #include "llvm/Support/FormatAdapters.h"
@@ -327,6 +329,50 @@
   return llvm::json::Value(std::move(object));
 }
 
+static uint64_t GetDebugInfoSizeInSection(lldb::SBSection section) {
+  uint64_t debug_info_size = 0;
+  llvm::StringRef section_name(section.GetName());
+  if (section_name.startswith(".debug") || section_name.startswith("__debug") ||
+  section_name.startswith(".apple") || section_name.startswith("__apple"))
+debug_info_size += section.GetFileByteSize();
+  size_t num_sub_sections = section.GetNumSubSections();
+  for (size_t i = 0; i < num_sub_sections; i++) {
+debug_info_size +=
+GetDebugInfoSizeInSection(section.GetSubSectionAtIndex(i));
+  }
+  return debug_info_size;
+}
+
+static uint64_t GetDebugInfoSize(lldb::SBModule module) {
+  uint64_t debug_info_size = 0;
+  size_t num_sections = module.GetNumSections();
+  for (size_t i = 0; i < num_sections; i++) {
+debug_info_size += GetDebugInfoSizeInSection(module.GetSectionAtIndex(i));
+  }
+  return debug_info_size;
+}
+
+static std::string ConvertDebugInfoSizeToString(uint64_t debug_info) {
+  std::ostringstream oss;
+  oss << "(";
+  oss << std::fixed << std::setprecision(1);
+
+  if (debug_info < 1024) {
+oss << debug_info << "B";
+  } else if (debug_info < 1024 * 1024) {
+double kb = double(debug_info) / 1024.0;
+oss << kb << "KB";
+  } else if (debug_info < 1024 * 1024 * 1024) {
+double mb = double(debug_info) / (1024.0 * 1024.0);
+oss << mb << "MB";
+  } else {
+double gb = double(debug_info) / (1024.0 * 1024.0 * 1024.0);
+oss << gb << "GB";
+;
+  }
+  oss << ")";
+  return oss.str();
+}
 llvm::json::Value CreateModule(lldb::SBModule &module) {
   llvm::json::Object object;
   if (!module.IsValid())
@@ -339,9 +385,15 @@
   std::string module_path(module_path_arr);
   object.try_emplace("path", module_path);
   if (module.GetNumCompileUnits() > 0) {
-object.try_emplace("symbolStatus", "Symbols loaded.");
+std::string symbol_str = "Symbols loaded.";
+uint64_t debug_info = GetDebugInfoSize(module);
+if (debug_info > 0) {
+  symbol_str += ConvertDebugInfoSizeToString(debug_info);
+}
+object.try_emplace("symbolStatus", symbol_str);
 char symbol_path_arr[PATH_MAX];
-module.GetSymbolFileSpec().GetPath(symbol_path_arr, sizeof(symbol_path_arr));
+module.GetSymbolFileSpec().GetPath(symbol_path_arr,
+   sizeof(symbol_path_arr));
 std::string symbol_path(symbol_path_arr);
 object.try_emplace("symbolFilePath", symbol_path);
   } else {
@@ -352,8 +404,9 @@
   object.try_emplace("addressRange", loaded_addr);
   std::string version_str;
   uint32_t version_nums[3];
-  uint32_t num_versions = module.GetVersion(version_nums, sizeof(version_nums)/sizeof(uint32_t));
-  for (uint32_t i=0; ihttps://llvm.org/LICENSE.txt for license information.
-# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-#
-#======#
-
-r"""
-clang-format git integration
-
-
-This file provides a clang-format integration for git. Put it somewhere in your
-path and ensure that it is executable. Then, "git clang-format" will invoke
-clang-format on the changes in current files or a specific commit.
-
-For further details, run:
-git clang-format -h
-
-Requires Python 2.7 or Python 3
-"""
-
-from __future__ import absolute_import, division, print_function
-import argparse
-import collections
-import contextlib
-import errno
-import os
-import re
-import subprocess
-import sys
-
-usage = 'git clang-format [OPTIONS] [] [] [--] [...]'
-
-desc = '''
-If zero or one commits are given, run clang-format on all lines that differ
-between the working directory and , which defaults to HEAD.  Changes are
-only applied to the working directory.
-
-If two commits are given (requires --diff), run clang-format on all lines in the
-second  that differ from the first .
-
-The following git-config settings set the default of the corresponding option:
-  clangFormat.binary
-  clangFormat.com

[PATCH] D81031: [OpenMP] Add Additional Function Attribute Information to OMPKinds.def

2020-07-17 Thread Stefan Stipanovic via Phabricator via cfe-commits
sstefan1 added a comment.

Just in case you haven't seen already, `clang/test/OpenMP/barrier_codegen.cpp` 
needs to be updated as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81031



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


[PATCH] D83731: Add Debug Info Size to Symbol Status

2020-07-17 Thread walter erquinigo via Phabricator via cfe-commits
wallace requested changes to this revision.
wallace added a comment.
This revision now requires changes to proceed.

The logic looks very good, just some final comments and the code will be high 
quality




Comment at: lldb/test/API/tools/lldb-vscode/module/TestVSCode_module.py:66
+@skipIfRemote
+def test_module_event(self):
+# Mac or linux.

With you current Makefile, this test will fail on Linux, as the Makefile will 
expect a .dsym file to be created. Simply put @ skipUnlessDarwin back here, and 
add this comment
  #TODO: Update the Makefile so that this test runs on Linux

Once this is committed, I'll work on make this test pass on Linux



Comment at: lldb/test/API/tools/lldb-vscode/module/TestVSCode_module.py:67-73
+# Mac or linux.
+
+# On mac, if we load a.out as our symbol file, we will use DWARF with 
.o files and we will
+# have debug symbols, but we won't see any debug info size because all 
of the DWARF
+# sections are in .o files.
+
+# On other platforms, we expect a.out to have debug info, so we will 
expect a size.

The common way to write function comments is with ''', like this
  '''
Mac or linux.

On mac, if we load a.out as our symbol file, we will use DWARF with .o 
files and we will
have debug symbols, but we won't see any debug info size because all of the 
DWARF
sections are in .o files.

On other platforms, we expect a.out to have debug info, so we will expect a 
size.
  '''

That way you don't need to type that many #



Comment at: lldb/test/API/tools/lldb-vscode/module/TestVSCode_module.py:81-84
+# Darwin only test with dSYM file.
+
+# On mac, if we load a.out.dSYM as our symbol file, we will have debug 
symbols and we
+# will have DWARF sections added to the module, so we will expect a 
size.

same here about the comment



Comment at: lldb/tools/lldb-vscode/JSONUtils.cpp:333
+  llvm::StringRef section_name(section.GetName());
+  if (section_name.startswith(".debug") || section_name.startswith("__debug")
+  || section_name.startswith(".apple") || 
section_name.startswith("__apple"))

apply the format change it suggests, i.e start the second line with ||



Comment at: lldb/tools/lldb-vscode/JSONUtils.cpp:353
+
+static std::string ConvertDebugInfoSize(uint64_t debug_info) {
+  char debug_info_size[32];

ConvertDebugInfoSizeToString is a better name



Comment at: lldb/tools/lldb-vscode/JSONUtils.cpp:354-368
+  char debug_info_size[32];
+  if (debug_info < 1024) {
+snprintf(debug_info_size, sizeof(debug_info_size), " (%" PRIu64 "B)",
+ debug_info);
+  } else if (debug_info < 1024 * 1024) {
+double kb = double(debug_info) / 1024.0;
+snprintf(debug_info_size, sizeof(debug_info_size), " (%.1fKB)", kb);

a more modern way to implement this is

  #include 
  #include 
   ...
  std::ostringstream oss;
  oss << "(";
  oss << std::fixed << std::setprecision(1);

  if (debug_info < 1024) {
oss << debug_info << "B";
  } else if (debug_info < 1024 * 1024) {
double kb = double(debug_info) / 1024.0;
oss << kb << "KB";
  } else if (debug_info < 1024 * 1024 * 1024) {
double mb = double(debug_info) / (1024.0 * 1024.0);
oss << mb << "MB";
  } else {
double gb = double(debug_info) / (1024.0 * 1024.0 * 1024.0);
oss << gb << "GB";;
  }
  oss << ")";
  return oss.str();

It's actually safer, as you don't need to specify the array size of your 
debug_info_size_buffer



Comment at: lldb/tools/lldb-vscode/JSONUtils.cpp:385-386
+if (debug_info > 0) {
+  std::string debug_info_size = ConvertDebugInfoSize(debug_info);
+  symbol_str = symbol_str + debug_info_size;
+}

  symbol_str += ConvertDebugInfoSizeToString(debug_info);
is more concise


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83731



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


[PATCH] D83061: [OpenMP] Implement TR8 `present` map type modifier in Clang (1/2)

2020-07-17 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny marked 4 inline comments as done.
jdenny added inline comments.



Comment at: clang/lib/Parse/ParseOpenMP.cpp:3067-3068
+  unsigned Type = getOpenMPSimpleClauseType(OMPC_map, PP.getSpelling(Tok));
+  if (Type < OMPC_MAP_MODIFIER_unknown)
+return OMPC_MAP_MODIFIER_unknown;
+  return static_cast(Type);

ABataev wrote:
> Why do we need this?
When called with `OMPC_map`, `getOpenMPSimpleClauseType` can return either an 
`OpenMPMapModifierKind` or `OpenMPMapClauseKind` depending on `Tok`.  Thus, 
without this change, both `isMapModifier` and `isMapType` can return either of 
those despite the difference in their names and documentation.

I found that, when `Parser::parseMapTypeModifiers` ignores `present` as if it's 
not a modifier because OpenMP < 5.1, then `isMapType` later returns 
`OMPC_MAP_MODIFIER_present` and causes the following assert to fail in 
`Sema::ActOnOpenMPVarListClause`:

```
assert(0 <= ExtraModifier && ExtraModifier <= OMPC_MAP_unknown &&
   "Unexpected map modifier.");
```

To me, the most obvious solution is to fix `isMapType` and `isMapModifier`.  
Fortunately, looking in `OpenMPKinds.h`, the enumerator values in 
`OpenMPMapModifierKind` and `OpenMPMapClauseKind` are disjoint so we can tell 
which we have.



Comment at: clang/lib/Parse/ParseOpenMP.cpp:3150-3151
+  unsigned Type = getOpenMPSimpleClauseType(OMPC_map, PP.getSpelling(Tok));
+  if (Type > OMPC_MAP_unknown)
+return OMPC_MAP_unknown;
+  return static_cast(Type);

ABataev wrote:
> Same, why do we need this?
Responded on `isMapModifier`.


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

https://reviews.llvm.org/D83061



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


[clang-tools-extra] 7fcc1bb - [clangd] Fix the build with clang <3.9.

2020-07-17 Thread Michael Spencer via cfe-commits

Author: Michael Spencer
Date: 2020-07-17T16:12:31-06:00
New Revision: 7fcc1bb4b654461c3109b01e1fe7eae191a86f7f

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

LOG: [clangd] Fix the build with clang <3.9.

In clang <3.9 the `unique_ptr` constructor that is supposed to allow
for Derived to Base conversion does not work. Remove this if we drop
support for such configurations.

This is the same fix as in fda901a987ddd, and it updates the comments
to better reflect the actual issue. The same thing reproduces with
libc++ with older clangs.

Added: 


Modified: 
clang-tools-extra/clangd/ConfigProvider.cpp
llvm/utils/TableGen/OptParserEmitter.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/ConfigProvider.cpp 
b/clang-tools-extra/clangd/ConfigProvider.cpp
index eec1ae992194..a56cdd755322 100644
--- a/clang-tools-extra/clangd/ConfigProvider.cpp
+++ b/clang-tools-extra/clangd/ConfigProvider.cpp
@@ -209,7 +209,11 @@ Provider::combine(std::vector Providers) 
{
   };
   auto Result = std::make_unique();
   Result->Providers = std::move(Providers);
-  return Result;
+  // FIXME: This is a workaround for a bug in older versions of clang (< 3.9)
+  //   The constructor that is supposed to allow for Derived to Base
+  //   conversion does not work. Remove this if we drop support for such
+  //   configurations.
+  return std::unique_ptr(Result.release());
 }
 
 Config Provider::getConfig(const Params &P, DiagnosticCallback DC) const {

diff  --git a/llvm/utils/TableGen/OptParserEmitter.cpp 
b/llvm/utils/TableGen/OptParserEmitter.cpp
index 34699b55e274..6e49e248e4b8 100644
--- a/llvm/utils/TableGen/OptParserEmitter.cpp
+++ b/llvm/utils/TableGen/OptParserEmitter.cpp
@@ -110,10 +110,10 @@ class MarshallingFlagInfo final : public 
MarshallingKindInfo {
   static std::unique_ptr create(const Record &R) {
 std::unique_ptr Ret(new MarshallingFlagInfo(R));
 Ret->IsPositive = R.getValueAsBit("IsPositive");
-// FIXME: This is a workaround for a bug in older versions of libstdc++ 
when
-//   compiled with Clang. The constructor that is supposed to allow for
-//   Derived to Base conversion does not work. Remove this if we drop
-//   support for such configurations.
+// FIXME: This is a workaround for a bug in older versions of clang (< 3.9)
+//   The constructor that is supposed to allow for Derived to Base
+//   conversion does not work. Remove this if we drop support for such
+//   configurations.
 return std::unique_ptr(Ret.release());
   }
 
@@ -208,10 +208,10 @@ struct SimpleEnumValueTable {
  "values");
 }
 
-// FIXME: This is a workaround for a bug in older versions of libstdc++ 
when
-//   compiled with Clang. The constructor that is supposed to allow for
-//   Derived to Base conversion does not work. Remove this if we drop
-//   support for such configurations.
+// FIXME: This is a workaround for a bug in older versions of clang (< 3.9)
+//   The constructor that is supposed to allow for Derived to Base
+//   conversion does not work. Remove this if we drop support for such
+//   configurations.
 return std::unique_ptr(Ret.release());
   }
 



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


[PATCH] D83454: [CMake] Make `intrinsics_gen` dependency unconditional.

2020-07-17 Thread Michele Scandale via Phabricator via cfe-commits
michele.scandale added a comment.

In D83454#2145086 , @michele.scandale 
wrote:

> In D83454#2144386 , @JDevlieghere 
> wrote:
>
> > In D83454#2142719 , 
> > @michele.scandale wrote:
> >
> > > I tested locally the standalone build of Clang with D83426 
> > > .
> > >  I just want to make sure that we all agree this is right way moving 
> > > forward.
> >
> >
> > Yep, with the target exported this is the right thing to do.
>
>
> Great.
>
> I don't have commit rights. Could someone land this on my behalf?


Anybody?

Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83454



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


[PATCH] D81031: [OpenMP] Add Additional Function Attribute Information to OMPKinds.def

2020-07-17 Thread Joseph Huber via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG09fe0c5ab9ca: [OpenMP] Add Additional Function Attribute 
Information to OMPKinds.def (authored by jhuber6).

Changed prior to commit:
  https://reviews.llvm.org/D81031?vs=278905&id=278908#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81031

Files:
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  llvm/test/Transforms/OpenMP/add_attributes.ll
  llvm/test/Transforms/OpenMP/parallel_deletion.ll

Index: llvm/test/Transforms/OpenMP/parallel_deletion.ll
===
--- llvm/test/Transforms/OpenMP/parallel_deletion.ll
+++ llvm/test/Transforms/OpenMP/parallel_deletion.ll
@@ -393,7 +393,7 @@
 
 define internal void @.omp.reduction.reduction_func(i8* %arg, i8* %arg1) {
 ; CHECK-LABEL: define {{[^@]+}}@.omp.reduction.reduction_func
-; CHECK-SAME: (i8* nocapture nofree nonnull readonly align 8 dereferenceable(8) [[ARG:%.*]], i8* nocapture nofree nonnull readonly align 8 dereferenceable(8) [[ARG1:%.*]]) #10
+; CHECK-SAME: (i8* nocapture nofree nonnull readonly align 8 dereferenceable(8) [[ARG:%.*]], i8* nocapture nofree nonnull readonly align 8 dereferenceable(8) [[ARG1:%.*]]) #{{[0-9]+}}
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:[[TMP:%.*]] = bitcast i8* [[ARG1]] to i32**
 ; CHECK-NEXT:[[TMP2:%.*]] = load i32*, i32** [[TMP]], align 8
Index: llvm/test/Transforms/OpenMP/add_attributes.ll
===
--- llvm/test/Transforms/OpenMP/add_attributes.ll
+++ llvm/test/Transforms/OpenMP/add_attributes.ll
@@ -890,373 +890,373 @@
 ; CHECK: ; Function Attrs: nounwind
 ; CHECK-NEXT: declare dso_local i32 @omp_get_supported_active_levels() #0
 
-; CHECK-NOT: Function Attrs
-; CHECK: declare void @__kmpc_barrier(%struct.ident_t*, i32)
+; CHECK: ; Function Attrs: nounwind
+; CHECK-NEXT: declare void @__kmpc_barrier(%struct.ident_t*, i32) #0
 
-; CHECK: Function Attrs: inaccessiblemem_or_argmemonly
-; CHECK-NEXT: declare i32 @__kmpc_cancel(%struct.ident_t*, i32, i32)
+; CHECK: ; Function Attrs: nounwind
+; CHECK-NEXT: declare i32 @__kmpc_cancel(%struct.ident_t*, i32, i32) #0
 
-; CHECK-NOT: Function Attrs
-; CHECK: declare i32 @__kmpc_cancel_barrier(%struct.ident_t*, i32)
+; CHECK: ; Function Attrs: nounwind
+; CHECK-NEXT: declare i32 @__kmpc_cancel_barrier(%struct.ident_t*, i32) #0
 
-; CHECK-NOT: Function Attrs
-; CHECK: declare void @__kmpc_flush(%struct.ident_t*)
+; CHECK: ; Function Attrs: nounwind
+; CHECK-NEXT: declare void @__kmpc_flush(%struct.ident_t*) #0
 
-; CHECK: Function Attrs: nounwind
-; CHECK-NEXT: declare i32 @__kmpc_global_thread_num(%struct.ident_t*)
+; CHECK: ; Function Attrs: nounwind
+; CHECK-NEXT: declare i32 @__kmpc_global_thread_num(%struct.ident_t*) #0
 
-; CHECK: Function Attrs: nounwind
-; CHECK-NEXT: declare void @__kmpc_fork_call(%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...)
+; CHECK: ; Function Attrs: nounwind
+; CHECK-NEXT: declare void @__kmpc_fork_call(%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) #0
 
-; CHECK-NOT: Function Attrs
-; CHECK: declare i32 @__kmpc_omp_taskwait(%struct.ident_t*, i32)
+; CHECK: ; Function Attrs: nounwind
+; CHECK-NEXT: declare i32 @__kmpc_omp_taskwait(%struct.ident_t*, i32) #0
 
-; CHECK: Function Attrs: inaccessiblemem_or_argmemonly
-; CHECK-NEXT: declare i32 @__kmpc_omp_taskyield(%struct.ident_t*, i32, i32)
+; CHECK: ; Function Attrs: nounwind
+; CHECK-NEXT: declare i32 @__kmpc_omp_taskyield(%struct.ident_t*, i32, i32) #0
 
-; CHECK: Function Attrs: inaccessiblemem_or_argmemonly
-; CHECK-NEXT: declare void @__kmpc_push_num_threads(%struct.ident_t*, i32, i32)
+; CHECK: ; Function Attrs: nounwind
+; CHECK-NEXT: declare void @__kmpc_push_num_threads(%struct.ident_t*, i32, i32) #0
 
-; CHECK: Function Attrs: inaccessiblemem_or_argmemonly
-; CHECK-NEXT: declare void @__kmpc_push_proc_bind(%struct.ident_t*, i32, i32)
+; CHECK: ; Function Attrs: nounwind
+; CHECK-NEXT: declare void @__kmpc_push_proc_bind(%struct.ident_t*, i32, i32) #0
 
-; CHECK: Function Attrs: inaccessiblemem_or_argmemonly
-; CHECK-NEXT: declare void @__kmpc_serialized_parallel(%struct.ident_t*, i32)
+; CHECK: ; Function Attrs: nounwind
+; CHECK-NEXT: declare void @__kmpc_serialized_parallel(%struct.ident_t*, i32) #0
 
-; CHECK: Function Attrs: inaccessiblemem_or_argmemonly
-; CHECK-NEXT: declare void @__kmpc_end_serialized_parallel(%struct.ident_t*, i32)
+; CHECK: ; Function Attrs: nounwind
+; CHECK-NEXT: declare void @__kmpc_end_serialized_parallel(%struct.ident_t*, i32) #0
 
-; CHECK: Function Attrs: inaccessiblemem_or_argmemonly
-; CHECK-NEXT: declare i32 @__kmpc_master(%struct.ident_t*, i32)
+; CHECK: ; Function Attrs: nounwind
+; CHECK-NEXT: declare i32 @__kmpc_master(%struct.ident_t*, i32) #0
 
-; CHECK: Function Attrs: inaccessiblemem_or_argmemonly
-; CHECK-NEXT: declare void @__kmpc_end_mast

[PATCH] D83652: Merge some of the PCH object support with modular codegen

2020-07-17 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

@hans - could you perhaps give me a quick summary of commands I could use to 
test this feature in Chromium (or anything else you might suggest) on a Linux 
box? I don't have a Windows machine, or any projects that use PCH. (or if you'd 
be willing to test this, that'd be great - see if the PCH object file has the 
same symbols before/after this patch)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83652



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


[PATCH] D81031: [OpenMP] Add Additional Function Attribute Information to OMPKinds.def

2020-07-17 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 278905.
jhuber6 added a comment.

Removed usage of alignment and deference attributes and changed several 
functions to use barrier attributes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81031

Files:
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  llvm/test/Transforms/OpenMP/add_attributes.ll
  llvm/test/Transforms/OpenMP/parallel_deletion.ll

Index: llvm/test/Transforms/OpenMP/parallel_deletion.ll
===
--- llvm/test/Transforms/OpenMP/parallel_deletion.ll
+++ llvm/test/Transforms/OpenMP/parallel_deletion.ll
@@ -393,7 +393,7 @@
 
 define internal void @.omp.reduction.reduction_func(i8* %arg, i8* %arg1) {
 ; CHECK-LABEL: define {{[^@]+}}@.omp.reduction.reduction_func
-; CHECK-SAME: (i8* nocapture nofree nonnull readonly align 8 dereferenceable(8) [[ARG:%.*]], i8* nocapture nofree nonnull readonly align 8 dereferenceable(8) [[ARG1:%.*]]) #10
+; CHECK-SAME: (i8* nocapture nofree nonnull readonly align 8 dereferenceable(8) [[ARG:%.*]], i8* nocapture nofree nonnull readonly align 8 dereferenceable(8) [[ARG1:%.*]]) #{{[0-9]+}}
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:[[TMP:%.*]] = bitcast i8* [[ARG1]] to i32**
 ; CHECK-NEXT:[[TMP2:%.*]] = load i32*, i32** [[TMP]], align 8
Index: llvm/test/Transforms/OpenMP/add_attributes.ll
===
--- llvm/test/Transforms/OpenMP/add_attributes.ll
+++ llvm/test/Transforms/OpenMP/add_attributes.ll
@@ -890,373 +890,373 @@
 ; CHECK: ; Function Attrs: nounwind
 ; CHECK-NEXT: declare dso_local i32 @omp_get_supported_active_levels() #0
 
-; CHECK-NOT: Function Attrs
-; CHECK: declare void @__kmpc_barrier(%struct.ident_t*, i32)
+; CHECK: ; Function Attrs: nounwind
+; CHECK-NEXT: declare void @__kmpc_barrier(%struct.ident_t*, i32) #0
 
-; CHECK: Function Attrs: inaccessiblemem_or_argmemonly
-; CHECK-NEXT: declare i32 @__kmpc_cancel(%struct.ident_t*, i32, i32)
+; CHECK: ; Function Attrs: nounwind
+; CHECK-NEXT: declare i32 @__kmpc_cancel(%struct.ident_t*, i32, i32) #0
 
-; CHECK-NOT: Function Attrs
-; CHECK: declare i32 @__kmpc_cancel_barrier(%struct.ident_t*, i32)
+; CHECK: ; Function Attrs: nounwind
+; CHECK-NEXT: declare i32 @__kmpc_cancel_barrier(%struct.ident_t*, i32) #0
 
-; CHECK-NOT: Function Attrs
-; CHECK: declare void @__kmpc_flush(%struct.ident_t*)
+; CHECK: ; Function Attrs: nounwind
+; CHECK-NEXT: declare void @__kmpc_flush(%struct.ident_t*) #0
 
-; CHECK: Function Attrs: nounwind
-; CHECK-NEXT: declare i32 @__kmpc_global_thread_num(%struct.ident_t*)
+; CHECK: ; Function Attrs: nounwind
+; CHECK-NEXT: declare i32 @__kmpc_global_thread_num(%struct.ident_t*) #0
 
-; CHECK: Function Attrs: nounwind
-; CHECK-NEXT: declare void @__kmpc_fork_call(%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...)
+; CHECK: ; Function Attrs: nounwind
+; CHECK-NEXT: declare void @__kmpc_fork_call(%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) #0
 
-; CHECK-NOT: Function Attrs
-; CHECK: declare i32 @__kmpc_omp_taskwait(%struct.ident_t*, i32)
+; CHECK: ; Function Attrs: nounwind
+; CHECK-NEXT: declare i32 @__kmpc_omp_taskwait(%struct.ident_t*, i32) #0
 
-; CHECK: Function Attrs: inaccessiblemem_or_argmemonly
-; CHECK-NEXT: declare i32 @__kmpc_omp_taskyield(%struct.ident_t*, i32, i32)
+; CHECK: ; Function Attrs: nounwind
+; CHECK-NEXT: declare i32 @__kmpc_omp_taskyield(%struct.ident_t*, i32, i32) #0
 
-; CHECK: Function Attrs: inaccessiblemem_or_argmemonly
-; CHECK-NEXT: declare void @__kmpc_push_num_threads(%struct.ident_t*, i32, i32)
+; CHECK: ; Function Attrs: nounwind
+; CHECK-NEXT: declare void @__kmpc_push_num_threads(%struct.ident_t*, i32, i32) #0
 
-; CHECK: Function Attrs: inaccessiblemem_or_argmemonly
-; CHECK-NEXT: declare void @__kmpc_push_proc_bind(%struct.ident_t*, i32, i32)
+; CHECK: ; Function Attrs: nounwind
+; CHECK-NEXT: declare void @__kmpc_push_proc_bind(%struct.ident_t*, i32, i32) #0
 
-; CHECK: Function Attrs: inaccessiblemem_or_argmemonly
-; CHECK-NEXT: declare void @__kmpc_serialized_parallel(%struct.ident_t*, i32)
+; CHECK: ; Function Attrs: nounwind
+; CHECK-NEXT: declare void @__kmpc_serialized_parallel(%struct.ident_t*, i32) #0
 
-; CHECK: Function Attrs: inaccessiblemem_or_argmemonly
-; CHECK-NEXT: declare void @__kmpc_end_serialized_parallel(%struct.ident_t*, i32)
+; CHECK: ; Function Attrs: nounwind
+; CHECK-NEXT: declare void @__kmpc_end_serialized_parallel(%struct.ident_t*, i32) #0
 
-; CHECK: Function Attrs: inaccessiblemem_or_argmemonly
-; CHECK-NEXT: declare i32 @__kmpc_master(%struct.ident_t*, i32)
+; CHECK: ; Function Attrs: nounwind
+; CHECK-NEXT: declare i32 @__kmpc_master(%struct.ident_t*, i32) #0
 
-; CHECK: Function Attrs: inaccessiblemem_or_argmemonly
-; CHECK-NEXT: declare void @__kmpc_end_master(%struct.ident_t*, i32)
+; CHECK: ; Function Attrs: nounwind
+; CHECK-NEXT: declare void @__kmpc_end_

[clang] c2d69d8 - Remove clang matrix lowering test for now as it is still failing under the NPM.

2020-07-17 Thread Sjoerd Meijer via cfe-commits

Author: Sjoerd Meijer
Date: 2020-07-17T22:42:12+01:00
New Revision: c2d69d8d62f2aac941453177e2ae872f5f82feda

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

LOG: Remove clang matrix lowering test for now as it is still failing under the 
NPM.

Added: 


Modified: 


Removed: 
clang/test/CodeGen/matrix-lowering-opt-levels.c



diff  --git a/clang/test/CodeGen/matrix-lowering-opt-levels.c 
b/clang/test/CodeGen/matrix-lowering-opt-levels.c
deleted file mode 100644
index 9edecbe46bc8..
--- a/clang/test/CodeGen/matrix-lowering-opt-levels.c
+++ /dev/null
@@ -1,23 +0,0 @@
-// RUN: %clang -O1 -fenable-matrix -S -emit-llvm %s -o - | FileCheck  %s
-// RUN: %clang -O2 -fenable-matrix -S -emit-llvm %s -o - | FileCheck  %s
-// RUN: %clang -O3 -fenable-matrix -S -emit-llvm %s -o - | FileCheck  %s
-// RUN: %clang -Ofast -fenable-matrix -S -emit-llvm %s -o - | FileCheck  %s
-// RUN: %clang -Os -fenable-matrix -S -emit-llvm %s -o - | FileCheck  %s
-// RUN: %clang -Oz -fenable-matrix -S -emit-llvm %s -o - | FileCheck  %s
-
-// Smoke test that the matrix intrinsics are lowered at any optimisation level.
-
-// FIXME: this fails with the NPM:
-//
-// %clang -O0 -fenable-matrix -S -emit-llvm %s -o - | FileCheck  %s
-
-typedef float m4x4_t __attribute__((matrix_type(4, 4)));
-
-m4x4_t f(m4x4_t a, m4x4_t b, m4x4_t c) {
-  //
-  // CHECK-LABEL: f(
-  // CHECK-NOT: @llvm.matrix
-  // CHECK:   }
-  //
-  return a + b * c;
-}



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


[PATCH] D83722: [PowerPC] Add options to control paired vector memops support

2020-07-17 Thread Amy Kwan via Phabricator via cfe-commits
amyk added inline comments.



Comment at: llvm/lib/Target/PowerPC/PPC.td:243
+   "32Byte load and store instructions",
+   [FeatureISA3_0]>;
 

Is this supposed to be `FeatureISA3_1`?



Comment at: llvm/lib/Target/PowerPC/PPCScheduleP9.td:44
   // Do not support QPX (Quad Processing eXtension), SPE (Signal Processing
   // Engine), prefixed instructions on Power 9, PC relative mem ops, or
   // instructions introduced in ISA 3.1.

Add the paired vector mem ops to the comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83722



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


[PATCH] D83338: [PowerPC][Power10] Implemented Vector Shift Builtins

2020-07-17 Thread Amy Kwan via Phabricator via cfe-commits
amyk added a comment.

Please also change the function names.




Comment at: clang/lib/Headers/altivec.h:17151
+
+/* vs[l | r | raq] */
+static __inline__ vector unsigned __int128 __ATTRS_o_ai

Actually, sorry, I think this comment should be the following instead:
`/* vec_s[l | r | ra] */` since these functions are actually supposed to be 
`vec_sl`, `vec_sr`, `vec_sra`.



Comment at: clang/lib/Headers/altivec.h:17158
+static __inline__ vector signed __int128 __ATTRS_o_ai
+vec_sl(vector signed __int128 __a, vector unsigned __int128 __b) {
+  return __builtin_altivec_vslq((vector unsigned __int128) __a, __b);

stefanp wrote:
> nit:
> Is this supposed to be `vec_slq`?
Actually `vec_sl` seems to be correct. However, that would mean the other 
functions need to be renamed as the functions are supposed to be: `vec_sl`, 
`vec_sr`, `vec_sra`. Albion, could you please rename these functions and also 
ensure your test uses the correct naming.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83338



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


[PATCH] D83494: [libFuzzer] Link libFuzzer's own interceptors when other compiler runtimes are not linked.

2020-07-17 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse added inline comments.



Comment at: compiler-rt/lib/fuzzer/FuzzerInterceptors.cpp:62
+
+static int internal_strncmp(const char *s1, const char *s2, uintptr_t n) {
+  for (uintptr_t i = 0; i < n; i++) {

Can we use `size_t` instead of `uintptr_t`?



Comment at: compiler-rt/lib/fuzzer/FuzzerInterceptors.cpp:77
+static int internal_memcmp(const void *s1, const void *s2, uintptr_t n) {
+  const char *t1 = (const char *)s1;
+  const char *t2 = (const char *)s2;

Can we use `uint8_t` and `static_cast`?



Comment at: compiler-rt/lib/fuzzer/FuzzerInterceptors.cpp:119
+return internal_memcmp(s1, s2, n);
+  ensureFuzzerInited();
+  int result = REAL(memcmp)(s1, s2, n);

I think `ensureFuzzerInited` is no longer useful here.



Comment at: compiler-rt/test/fuzzer/CustomAllocatorTest.cpp:15
+  return 0;
+}

Do we need this file?  Can we use `EmptyTest.cpp` instead?



Comment at: compiler-rt/test/fuzzer/custom-allocator.test:2
+UNSUPPORTED: freebsd
+RUN: %cpp_compiler -fno-sanitize=all -fno-builtin %S/CustomAllocator.cpp -fPIC 
%ld_flags_rpath_so1 -O0 -shared -o %dynamiclib1
+RUN: %cpp_compiler -fno-sanitize=address %S/CustomAllocatorTest.cpp 
%ld_flags_rpath_exe1 -o %t-NoAsanCustomAllocatorTest

Why do we need each of these flags?



Comment at: compiler-rt/test/fuzzer/memcmp.test:9
+RUN: %cpp_compiler -fno-sanitize=all -fno-builtin %S/CustomAllocator.cpp -fPIC 
%ld_flags_rpath_so1 -O0 -shared -o %dynamiclib1
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-memcmp %S/MemcmpTest.cpp 
%ld_flags_rpath_exe1 -o %t-NoAsanCustomAllocatorMemcmpTest
+RUN: not %run %t-NoAsanCustomAllocatorMemcmpTest-seed=1 -runs=1000 
  2>&1 | FileCheck %s

Why is the custom allocator test here useful?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83494



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


[PATCH] D81442: [PowerPC] Add clang options to control MMA support

2020-07-17 Thread Amy Kwan via Phabricator via cfe-commits
amyk accepted this revision.
amyk added a comment.

I think overall it LGTM.




Comment at: llvm/lib/Target/PowerPC/PPCScheduleP9.td:44
   // Do not support QPX (Quad Processing eXtension), SPE (Signal Processing
   // Engine), prefixed instructions on Power 9, PC relative mem ops, or
   // instructions introduced in ISA 3.1.

nit: I think it would be good to add `MMA` to the comment here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81442



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


[PATCH] D83877: [Analyzer] Handle unique_ptr::swap() in SmartPtrModeling

2020-07-17 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added inline comments.



Comment at: clang/test/Analysis/Inputs/system-header-simulator-cxx.h:964-965
+
+  template 
+  void swap(unique_ptr &x, unique_ptr &y) noexcept {
+x.swap(y);

vrnithinkumar wrote:
> xazax.hun wrote:
> > NoQ wrote:
> > > You seem to be relying on the fact that global `std::swap` is implemented 
> > > in terms of the member `std::swap`. That's an implementation detail of 
> > > the standard library; i'm not sure that this is always the case. Ideally 
> > > we should model the global `std::swap` separately.
> > I am not sure how reliable cppreference is, but I think this overload might 
> > actually be guaranteed by the standard: 
> > https://en.cppreference.com/w/cpp/memory/unique_ptr/swap2
> I also made the assumption based on this 
> (https://en.cppreference.com/w/cpp/memory/unique_ptr/swap2).
> 
Aha, interesting. We still probably can't rely on it being always inlined 
though, so we'll still probably have to model it separately.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83877



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


[PATCH] D83836: [Analyzer] Add checkRegionChanges for SmartPtrModeling

2020-07-17 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

I think this looks great!

P.S. I unforgot why we won't be able to remove the option after all. That's 
because when we partially evalCall and partially inline, inlining breaks. Like, 
once we evalCalled a single method call, we can no longer trust RegionStore to 
have the right data inside of it on the current path, so further inlining 
cannot work correctly. We could forbid inlining and resort to conservative 
evaluation but that'd still be a regression compared to inlining. So i'd rather 
keep the option for as long as possible :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83836



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


[PATCH] D83061: [OpenMP] Implement TR8 `present` map type modifier in Clang (1/2)

2020-07-17 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:7043-7044
 OMP_MAP_CLOSE = 0x400,
+/// Produce a runtime error if the data is not already allocated.
+OMP_MAP_PRESENT = 0x800,
 /// The 16 MSBs of the flags indicate whether the entry is member of some

ABataev wrote:
> jdenny wrote:
> > ABataev wrote:
> > > Better to use thу next value to avoid compatibility issues with XLC. 
> > You mean 0x1000?
> Yes
Could you add a comment that 0x800 is currently reserved for compatibility, 
please?



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:7934-7940
+// If any element has the present modifier, then make sure the runtime
+// doesn't attempt to allocate the struct.
+if (CurTypes.end() !=
+llvm::find_if(CurTypes, [](OpenMPOffloadMappingFlags Type) {
+  return Type & OMP_MAP_PRESENT;
+}))
+  Types.back() |= OMP_MAP_PRESENT;

Why do we need this extra stuff here?



Comment at: clang/lib/Parse/ParseOpenMP.cpp:3067-3068
+  unsigned Type = getOpenMPSimpleClauseType(OMPC_map, PP.getSpelling(Tok));
+  if (Type < OMPC_MAP_MODIFIER_unknown)
+return OMPC_MAP_MODIFIER_unknown;
+  return static_cast(Type);

Why do we need this?



Comment at: clang/lib/Parse/ParseOpenMP.cpp:3133
+  Diag(Tok, diag::err_omp_unknown_map_type_modifier)
+  << (getLangOpts().OpenMP >= 51);
   ConsumeToken();

Better to use `(getLangOpts().OpenMP >= 51 ? 1 : 0)`, the `select` is of 
integer type.



Comment at: clang/lib/Parse/ParseOpenMP.cpp:3150-3151
+  unsigned Type = getOpenMPSimpleClauseType(OMPC_map, PP.getSpelling(Tok));
+  if (Type > OMPC_MAP_unknown)
+return OMPC_MAP_unknown;
+  return static_cast(Type);

Same, why do we need this?


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

https://reviews.llvm.org/D83061



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


[PATCH] D83731: Add Debug Info Size to Symbol Status

2020-07-17 Thread Yifan Shen via Phabricator via cfe-commits
aelitashen updated this revision to Diff 278900.
aelitashen added a comment.

Merge if statements in GetDebugInfoSizeInSection()


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83731

Files:
  clang/tools/clang-format/git-clang-format
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
  lldb/test/API/tools/lldb-vscode/module/TestVSCode_module.py
  lldb/tools/lldb-vscode/JSONUtils.cpp

Index: lldb/tools/lldb-vscode/JSONUtils.cpp
===
--- lldb/tools/lldb-vscode/JSONUtils.cpp
+++ lldb/tools/lldb-vscode/JSONUtils.cpp
@@ -327,6 +327,46 @@
   return llvm::json::Value(std::move(object));
 }
 
+static uint64_t GetDebugInfoSizeInSection(lldb::SBSection section) {
+  uint64_t debug_info_size = 0;
+  llvm::StringRef section_name(section.GetName());
+  if (section_name.startswith(".debug") || section_name.startswith("__debug")
+  || section_name.startswith(".apple") || section_name.startswith("__apple"))
+debug_info_size += section.GetFileByteSize();
+  size_t num_sub_sections = section.GetNumSubSections();
+  for (size_t i = 0; i < num_sub_sections; i++) {
+debug_info_size +=
+GetDebugInfoSizeInSection(section.GetSubSectionAtIndex(i));
+  }
+  return debug_info_size;
+}
+
+static uint64_t GetDebugInfoSize(lldb::SBModule module) {
+  uint64_t debug_info_size = 0;
+  size_t num_sections = module.GetNumSections();
+  for (size_t i = 0; i < num_sections; i++) {
+debug_info_size += GetDebugInfoSizeInSection(module.GetSectionAtIndex(i));
+  }
+  return debug_info_size;
+}
+
+static std::string ConvertDebugInfoSize(uint64_t debug_info) {
+  char debug_info_size[32];
+  if (debug_info < 1024) {
+snprintf(debug_info_size, sizeof(debug_info_size), " (%" PRIu64 "B)",
+ debug_info);
+  } else if (debug_info < 1024 * 1024) {
+double kb = double(debug_info) / 1024.0;
+snprintf(debug_info_size, sizeof(debug_info_size), " (%.1fKB)", kb);
+  } else if (debug_info < 1024 * 1024 * 1024) {
+double mb = double(debug_info) / (1024.0 * 1024.0);
+snprintf(debug_info_size, sizeof(debug_info_size), " (%.1fMB)", mb);
+  } else {
+double gb = double(debug_info) / (1024.0 * 1024.0 * 1024.0);
+snprintf(debug_info_size, sizeof(debug_info_size), " (%.1fGB)", gb);
+  }
+  return std::string(debug_info_size);
+}
 llvm::json::Value CreateModule(lldb::SBModule &module) {
   llvm::json::Object object;
   if (!module.IsValid())
@@ -339,9 +379,16 @@
   std::string module_path(module_path_arr);
   object.try_emplace("path", module_path);
   if (module.GetNumCompileUnits() > 0) {
-object.try_emplace("symbolStatus", "Symbols loaded.");
+std::string symbol_str = "Symbols loaded.";
+uint64_t debug_info = GetDebugInfoSize(module);
+if (debug_info > 0) {
+  std::string debug_info_size = ConvertDebugInfoSize(debug_info);
+  symbol_str = symbol_str + debug_info_size;
+}
+object.try_emplace("symbolStatus", symbol_str);
 char symbol_path_arr[PATH_MAX];
-module.GetSymbolFileSpec().GetPath(symbol_path_arr, sizeof(symbol_path_arr));
+module.GetSymbolFileSpec().GetPath(symbol_path_arr,
+   sizeof(symbol_path_arr));
 std::string symbol_path(symbol_path_arr);
 object.try_emplace("symbolFilePath", symbol_path);
   } else {
@@ -352,8 +399,9 @@
   object.try_emplace("addressRange", loaded_addr);
   std::string version_str;
   uint32_t version_nums[3];
-  uint32_t num_versions = module.GetVersion(version_nums, sizeof(version_nums)/sizeof(uint32_t));
-  for (uint32_t i=0; ihttps://llvm.org/LICENSE.txt for license information.
-# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-#
-#======#
-
-r"""
-clang-format git integration
-
-
-This file provides a clang-format integration for git. Put it somewhere in your
-path and ensure that it is executable. Then, "git clang-format" will invoke
-clang-format on the changes in current files or a specific commit.
-
-For further details, run:
-git clang-format -h
-
-Requires Python 2.7 or Python 3
-"""
-
-from __future__ import absolute_import, division, print_function
-import argparse
-import collections
-import contextlib
-import errno
-import os
-import re
-import subprocess
-import sys
-
-usage = 'git clang-format [OPTIONS] [] [] [--] [...]'
-
-desc = '''
-If zero or one commits are given, run clang-format on all lines that differ
-between the working directory and , which defaults to HEAD.  Changes are
-only applied to the working directory.
-
-If two commits are given (requires --diff), run clang-format on all lines in the
-second  that differ from the first .
-
-The following git-config settings set the default of the corresponding option:
-  clangFormat.binary
-  clangFormat.commit
-  clangFormat.extensi

[PATCH] D83731: Add Debug Info Size to Symbol Status

2020-07-17 Thread Yifan Shen via Phabricator via cfe-commits
aelitashen updated this revision to Diff 278898.
aelitashen added a comment.

Merge Codes and Improve Readability


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83731

Files:
  clang/tools/clang-format/git-clang-format
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
  lldb/test/API/tools/lldb-vscode/module/TestVSCode_module.py
  lldb/tools/lldb-vscode/JSONUtils.cpp

Index: lldb/tools/lldb-vscode/JSONUtils.cpp
===
--- lldb/tools/lldb-vscode/JSONUtils.cpp
+++ lldb/tools/lldb-vscode/JSONUtils.cpp
@@ -327,6 +327,46 @@
   return llvm::json::Value(std::move(object));
 }
 
+static uint64_t GetDebugInfoSizeInSection(lldb::SBSection section) {
+  uint64_t debug_info_size = 0;
+  llvm::StringRef section_name(section.GetName());
+  if (section_name.startswith(".debug") || section_name.startswith("__debug")
+  ||section_name.startswith(".apple") || section_name.startswith("__apple"))
+debug_info_size += section.GetFileByteSize();
+  size_t num_sub_sections = section.GetNumSubSections();
+  for (size_t i = 0; i < num_sub_sections; i++) {
+debug_info_size +=
+GetDebugInfoSizeInSection(section.GetSubSectionAtIndex(i));
+  }
+  return debug_info_size;
+}
+
+static uint64_t GetDebugInfoSize(lldb::SBModule module) {
+  uint64_t debug_info_size = 0;
+  size_t num_sections = module.GetNumSections();
+  for (size_t i = 0; i < num_sections; i++) {
+debug_info_size += GetDebugInfoSizeInSection(module.GetSectionAtIndex(i));
+  }
+  return debug_info_size;
+}
+
+static std::string ConvertDebugInfoSize(uint64_t debug_info) {
+  char debug_info_size[32];
+  if (debug_info < 1024) {
+snprintf(debug_info_size, sizeof(debug_info_size), " (%" PRIu64 "B)",
+ debug_info);
+  } else if (debug_info < 1024 * 1024) {
+double kb = double(debug_info) / 1024.0;
+snprintf(debug_info_size, sizeof(debug_info_size), " (%.1fKB)", kb);
+  } else if (debug_info < 1024 * 1024 * 1024) {
+double mb = double(debug_info) / (1024.0 * 1024.0);
+snprintf(debug_info_size, sizeof(debug_info_size), " (%.1fMB)", mb);
+  } else {
+double gb = double(debug_info) / (1024.0 * 1024.0 * 1024.0);
+snprintf(debug_info_size, sizeof(debug_info_size), " (%.1fGB)", gb);
+  }
+  return std::string(debug_info_size);
+}
 llvm::json::Value CreateModule(lldb::SBModule &module) {
   llvm::json::Object object;
   if (!module.IsValid())
@@ -339,9 +379,16 @@
   std::string module_path(module_path_arr);
   object.try_emplace("path", module_path);
   if (module.GetNumCompileUnits() > 0) {
-object.try_emplace("symbolStatus", "Symbols loaded.");
+std::string symbol_str = "Symbols loaded.";
+uint64_t debug_info = GetDebugInfoSize(module);
+if (debug_info > 0) {
+  std::string debug_info_size = ConvertDebugInfoSize(debug_info);
+  symbol_str = symbol_str + debug_info_size;
+}
+object.try_emplace("symbolStatus", symbol_str);
 char symbol_path_arr[PATH_MAX];
-module.GetSymbolFileSpec().GetPath(symbol_path_arr, sizeof(symbol_path_arr));
+module.GetSymbolFileSpec().GetPath(symbol_path_arr,
+   sizeof(symbol_path_arr));
 std::string symbol_path(symbol_path_arr);
 object.try_emplace("symbolFilePath", symbol_path);
   } else {
@@ -352,8 +399,9 @@
   object.try_emplace("addressRange", loaded_addr);
   std::string version_str;
   uint32_t version_nums[3];
-  uint32_t num_versions = module.GetVersion(version_nums, sizeof(version_nums)/sizeof(uint32_t));
-  for (uint32_t i=0; ihttps://llvm.org/LICENSE.txt for license information.
-# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-#
-#======#
-
-r"""
-clang-format git integration
-
-
-This file provides a clang-format integration for git. Put it somewhere in your
-path and ensure that it is executable. Then, "git clang-format" will invoke
-clang-format on the changes in current files or a specific commit.
-
-For further details, run:
-git clang-format -h
-
-Requires Python 2.7 or Python 3
-"""
-
-from __future__ import absolute_import, division, print_function
-import argparse
-import collections
-import contextlib
-import errno
-import os
-import re
-import subprocess
-import sys
-
-usage = 'git clang-format [OPTIONS] [] [] [--] [...]'
-
-desc = '''
-If zero or one commits are given, run clang-format on all lines that differ
-between the working directory and , which defaults to HEAD.  Changes are
-only applied to the working directory.
-
-If two commits are given (requires --diff), run clang-format on all lines in the
-second  that differ from the first .
-
-The following git-config settings set the default of the corresponding option:
-  clangFormat.binary
-  clangFormat.commit
-  clangFormat.extensions
-  clangForm

[PATCH] D80802: [RISCV] Upgrade RVV MC to v0.9.

2020-07-17 Thread Evandro Menezes via Phabricator via cfe-commits
evandro added a comment.

Just a couple of nits, but otherwise it LGTM.




Comment at: llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp:776
 }
-return "";
+llvm_unreachable("Unknown SEW.");
   }

I'd rather the first case be the `default` case and that it would call 
`llvm_unreachabe()` instead.



Comment at: llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp:796
 }
-return "";
+llvm_unreachable("Unknown LMUL.");
   }

Ditto.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80802



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


[PATCH] D83731: Add Debug Info Size to Symbol Status

2020-07-17 Thread Yifan Shen via Phabricator via cfe-commits
aelitashen updated this revision to Diff 278894.
aelitashen added a comment.

Create help function in tests for code re-use. Take care of both macOS and 
Linux system.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83731

Files:
  clang/tools/clang-format/git-clang-format
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
  lldb/test/API/tools/lldb-vscode/module/TestVSCode_module.py
  lldb/tools/lldb-vscode/JSONUtils.cpp

Index: lldb/tools/lldb-vscode/JSONUtils.cpp
===
--- lldb/tools/lldb-vscode/JSONUtils.cpp
+++ lldb/tools/lldb-vscode/JSONUtils.cpp
@@ -327,6 +327,47 @@
   return llvm::json::Value(std::move(object));
 }
 
+static uint64_t GetDebugInfoSizeInSection(lldb::SBSection section) {
+  uint64_t debug_info_size = 0;
+  llvm::StringRef section_name(section.GetName());
+  if (section_name.startswith(".debug") || section_name.startswith("__debug"))
+debug_info_size += section.GetFileByteSize();
+  if (section_name.startswith(".apple") || section_name.startswith("__apple"))
+debug_info_size += section.GetFileByteSize();
+  size_t num_sub_sections = section.GetNumSubSections();
+  for (size_t i = 0; i < num_sub_sections; i++) {
+debug_info_size +=
+GetDebugInfoSizeInSection(section.GetSubSectionAtIndex(i));
+  }
+  return debug_info_size;
+}
+
+static uint64_t GetDebugInfoSize(lldb::SBModule module) {
+  uint64_t debug_info_size = 0;
+  size_t num_sections = module.GetNumSections();
+  for (size_t i = 0; i < num_sections; i++) {
+debug_info_size += GetDebugInfoSizeInSection(module.GetSectionAtIndex(i));
+  }
+  return debug_info_size;
+}
+
+static std::string ConvertDebugInfoSize(uint64_t debug_info) {
+  char debug_info_size[32];
+  if (debug_info < 1024) {
+snprintf(debug_info_size, sizeof(debug_info_size), " (%" PRIu64 "B)",
+ debug_info);
+  } else if (debug_info < 1024 * 1024) {
+double kb = double(debug_info) / 1024.0;
+snprintf(debug_info_size, sizeof(debug_info_size), " (%.1fKB)", kb);
+  } else if (debug_info < 1024 * 1024 * 1024) {
+double mb = double(debug_info) / (1024.0 * 1024.0);
+snprintf(debug_info_size, sizeof(debug_info_size), " (%.1fMB)", mb);
+  } else {
+double gb = double(debug_info) / (1024.0 * 1024.0 * 1024.0);
+snprintf(debug_info_size, sizeof(debug_info_size), " (%.1fGB)", gb);
+  }
+  return std::string(debug_info_size);
+}
 llvm::json::Value CreateModule(lldb::SBModule &module) {
   llvm::json::Object object;
   if (!module.IsValid())
@@ -339,9 +380,16 @@
   std::string module_path(module_path_arr);
   object.try_emplace("path", module_path);
   if (module.GetNumCompileUnits() > 0) {
-object.try_emplace("symbolStatus", "Symbols loaded.");
+std::string symbol_str = "Symbols loaded.";
+uint64_t debug_info = GetDebugInfoSize(module);
+if (debug_info > 0) {
+  std::string debug_info_size = ConvertDebugInfoSize(debug_info);
+  symbol_str = symbol_str + debug_info_size;
+}
+object.try_emplace("symbolStatus", symbol_str);
 char symbol_path_arr[PATH_MAX];
-module.GetSymbolFileSpec().GetPath(symbol_path_arr, sizeof(symbol_path_arr));
+module.GetSymbolFileSpec().GetPath(symbol_path_arr,
+   sizeof(symbol_path_arr));
 std::string symbol_path(symbol_path_arr);
 object.try_emplace("symbolFilePath", symbol_path);
   } else {
@@ -352,8 +400,9 @@
   object.try_emplace("addressRange", loaded_addr);
   std::string version_str;
   uint32_t version_nums[3];
-  uint32_t num_versions = module.GetVersion(version_nums, sizeof(version_nums)/sizeof(uint32_t));
-  for (uint32_t i=0; ihttps://llvm.org/LICENSE.txt for license information.
-# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-#
-#======#
-
-r"""
-clang-format git integration
-
-
-This file provides a clang-format integration for git. Put it somewhere in your
-path and ensure that it is executable. Then, "git clang-format" will invoke
-clang-format on the changes in current files or a specific commit.
-
-For further details, run:
-git clang-format -h
-
-Requires Python 2.7 or Python 3
-"""
-
-from __future__ import absolute_import, division, print_function
-import argparse
-import collections
-import contextlib
-import errno
-import os
-import re
-import subprocess
-import sys
-
-usage = 'git clang-format [OPTIONS] [] [] [--] [...]'
-
-desc = '''
-If zero or one commits are given, run clang-format on all lines that differ
-between the working directory and , which defaults to HEAD.  Changes are
-only applied to the working directory.
-
-If two commits are given (requires --diff), run clang-format on all lines in the
-second  that differ from the first .
-
-The following git-config settings set the default of the 

[PATCH] D83494: [libFuzzer] Link libFuzzer's own interceptors when other compiler runtimes are not linked.

2020-07-17 Thread Dokyung Song via Phabricator via cfe-commits
dokyungs updated this revision to Diff 278892.
dokyungs added a comment.

Introduce internal_(memcmp|strncmp|strstr) and use them before interceptors are 
fully initialized.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83494

Files:
  clang/include/clang/Driver/SanitizerArgs.h
  clang/lib/Driver/SanitizerArgs.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  compiler-rt/lib/fuzzer/CMakeLists.txt
  compiler-rt/lib/fuzzer/FuzzerInterceptors.cpp
  compiler-rt/test/fuzzer/CustomAllocator.cpp
  compiler-rt/test/fuzzer/CustomAllocatorTest.cpp
  compiler-rt/test/fuzzer/custom-allocator.test
  compiler-rt/test/fuzzer/memcmp.test
  compiler-rt/test/fuzzer/memcmp64.test
  compiler-rt/test/fuzzer/strcmp.test
  compiler-rt/test/fuzzer/strncmp.test
  compiler-rt/test/fuzzer/strstr.test

Index: compiler-rt/test/fuzzer/strstr.test
===
--- compiler-rt/test/fuzzer/strstr.test
+++ compiler-rt/test/fuzzer/strstr.test
@@ -1,5 +1,12 @@
 UNSUPPORTED: freebsd
 RUN: %cpp_compiler %S/StrstrTest.cpp -o %t-StrstrTest
 RUN: not %run %t-StrstrTest   -seed=1 -runs=200   2>&1 | FileCheck %s
-CHECK: BINGO
 
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-strstr %S/StrstrTest.cpp -o %t-NoAsanStrstrTest
+RUN: not %run %t-NoAsanStrstrTest -seed=1 -runs=200   2>&1 | FileCheck %s
+
+RUN: %cpp_compiler -fno-sanitize=all -fno-builtin %S/CustomAllocator.cpp -fPIC %ld_flags_rpath_so1 -O0 -shared -o %dynamiclib1
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-strstr %S/StrstrTest.cpp %ld_flags_rpath_exe1 -o %t-NoAsanCustomAllocatorStrstrTest
+RUN: not %run %t-NoAsanCustomAllocatorStrstrTest-seed=1 -runs=1000   2>&1 | FileCheck %s
+
+CHECK: BINGO
Index: compiler-rt/test/fuzzer/strncmp.test
===
--- compiler-rt/test/fuzzer/strncmp.test
+++ compiler-rt/test/fuzzer/strncmp.test
@@ -1,5 +1,12 @@
 UNSUPPORTED: freebsd
 RUN: %cpp_compiler %S/StrncmpTest.cpp -o %t-StrncmpTest
 RUN: not %run %t-StrncmpTest  -seed=2 -runs=1000   2>&1 | FileCheck %s
-CHECK: BINGO
 
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-strncmp %S/StrncmpTest.cpp -o %t-NoAsanStrncmpTest
+RUN: not %run %t-NoAsanStrncmpTest-seed=2 -runs=1000   2>&1 | FileCheck %s
+
+RUN: %cpp_compiler -fno-sanitize=all -fno-builtin %S/CustomAllocator.cpp -fPIC %ld_flags_rpath_so1 -O0 -shared -o %dynamiclib1
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-strncmp %S/StrncmpTest.cpp %ld_flags_rpath_exe1 -o %t-NoAsanCustomAllocatorStrncmpTest
+RUN: not %run %t-NoAsanCustomAllocatorStrncmpTest-seed=2 -runs=1000   2>&1 | FileCheck %s
+
+CHECK: BINGO
Index: compiler-rt/test/fuzzer/strcmp.test
===
--- compiler-rt/test/fuzzer/strcmp.test
+++ compiler-rt/test/fuzzer/strcmp.test
@@ -1,5 +1,8 @@
 UNSUPPORTED: freebsd
 RUN: %cpp_compiler %S/StrcmpTest.cpp -o %t-StrcmpTest
 RUN: not %run %t-StrcmpTest   -seed=1 -runs=200   2>&1 | FileCheck %s
-CHECK: BINGO
 
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-strcmp %S/StrcmpTest.cpp -o %t-NoAsanStrcmpTest
+RUN: not %run %t-NoAsanStrcmpTest -seed=1 -runs=200   2>&1 | FileCheck %s
+
+CHECK: BINGO
Index: compiler-rt/test/fuzzer/memcmp64.test
===
--- compiler-rt/test/fuzzer/memcmp64.test
+++ compiler-rt/test/fuzzer/memcmp64.test
@@ -1,4 +1,8 @@
 UNSUPPORTED: freebsd
 RUN: %cpp_compiler %S/Memcmp64BytesTest.cpp -o %t-Memcmp64BytesTest
 RUN: not %run %t-Memcmp64BytesTest-seed=1 -runs=100   2>&1 | FileCheck %s
+
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-memcmp %S/Memcmp64BytesTest.cpp -o %t-NoAsanMemcmp64BytesTest
+RUN: not %run %t-NoAsanMemcmp64BytesTest  -seed=1 -runs=100   2>&1 | FileCheck %s
+
 CHECK: BINGO
Index: compiler-rt/test/fuzzer/memcmp.test
===
--- compiler-rt/test/fuzzer/memcmp.test
+++ compiler-rt/test/fuzzer/memcmp.test
@@ -1,4 +1,12 @@
 UNSUPPORTED: freebsd
 RUN: %cpp_compiler %S/MemcmpTest.cpp -o %t-MemcmpTest
 RUN: not %run %t-MemcmpTest   -seed=1 -runs=1000   2>&1 | FileCheck %s
+
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-memcmp %S/MemcmpTest.cpp -o %t-NoAsanMemcmpTest
+RUN: not %run %t-NoAsanMemcmpTest -seed=1 -runs=1000   2>&1 | FileCheck %s
+
+RUN: %cpp_compiler -fno-sanitize=all -fno-builtin %S/CustomAllocator.cpp -fPIC %ld_flags_rpath_so1 -O0 -shared -o %dynamiclib1
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-memcmp %S/MemcmpTest.cpp %ld_flags_rpath_exe1 -o %t-NoAsanCustomAllocatorMemcmpTest
+RUN: not %run %t-NoAsanCustomAllocatorMemcmpTest-seed=1 -runs=1000   2>&1 | FileCheck %s
+
 CHECK: BINGO
Index: compiler-rt/tes

[PATCH] D84067: Fix issue in typo handling which could lead clang to hang

2020-07-17 Thread David Goldman via Phabricator via cfe-commits
dgoldman updated this revision to Diff 278890.
dgoldman added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84067

Files:
  clang/include/clang/Sema/SemaInternal.h
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/Sema/typo-correction-no-hang.cpp
  clang/test/Sema/typo-correction-recursive.cpp

Index: clang/test/Sema/typo-correction-recursive.cpp
===
--- clang/test/Sema/typo-correction-recursive.cpp
+++ clang/test/Sema/typo-correction-recursive.cpp
@@ -118,3 +118,15 @@
   asDeepASItGet().
   functionE();
 }
+
+struct Dog {
+  int age;  //expected-note{{'age' declared here}}
+  int size; //expected-note{{'size' declared here}}
+};
+
+int from_dog_years(int DogYears, int DogSize);
+int get_dog_years() {
+  struct Dog doggo;
+  return from_dog_years(doggo.agee,   //expected-error{{no member named 'agee' in 'Dog'; did you mean 'age'}}
+doggo.sizee); //expected-error{{no member named 'sizee' in 'Dog'; did you mean 'size'}}
+}
Index: clang/test/Sema/typo-correction-no-hang.cpp
===
--- /dev/null
+++ clang/test/Sema/typo-correction-no-hang.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// From `test/Sema/typo-correction.c` but for C++ since the behavior varies
+// between the two languages.
+struct rdar38642201 {
+  int fieldName;
+};
+
+void rdar38642201_callee(int x, int y);
+void rdar38642201_caller() {
+  struct rdar38642201 structVar;
+  rdar38642201_callee(
+  structVar1.fieldName1.member1,  //expected-error{{use of undeclared identifier 'structVar1'}}
+  structVar2.fieldName2.member2); //expected-error{{use of undeclared identifier 'structVar2'}}
+}
+
+// Similar reproducer.
+class A {
+public:
+  int minut() const = delete;
+  int hour() const = delete;
+
+  int longit() const; //expected-note{{'longit' declared here}}
+  int latit() const;
+};
+
+class B {
+public:
+  A depar() const { return A(); }
+};
+
+int Foo(const B &b) {
+  return b.deparT().hours() * 60 + //expected-error{{no member named 'deparT' in 'B'}}
+ b.deparT().minutes(); //expected-error{{no member named 'deparT' in 'B'}}
+}
+
+int Bar(const B &b) {
+  return b.depar().longitude() + //expected-error{{no member named 'longitude' in 'A'; did you mean 'longit'?}}
+ b.depar().latitude();   //expected-error{{no member named 'latitude' in 'A'}}
+}
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -7977,19 +7977,26 @@
 }
   }
 
-  /// If corrections for the first TypoExpr have been exhausted for a
-  /// given combination of the other TypoExprs, retry those corrections against
-  /// the next combination of substitutions for the other TypoExprs by advancing
-  /// to the next potential correction of the second TypoExpr. For the second
-  /// and subsequent TypoExprs, if its stream of corrections has been exhausted,
-  /// the stream is reset and the next TypoExpr's stream is advanced by one (a
-  /// TypoExpr's correction stream is advanced by removing the TypoExpr from the
-  /// TransformCache). Returns true if there is still any untried combinations
-  /// of corrections.
+  /// Try to advance the typo correction state of the first unfinished TypoExpr.
+  /// We allow advancement of the correction stream by removing it from the
+  /// TransformCache which allows `TransformTypoExpr` to advance during the
+  /// next transformation attempt.
+  ///
+  /// Any substitution attempts for the previous TypoExprs (which must have been
+  /// finished) will need to be retried since it's possible that they will now
+  /// be invalid given the latest advancement.
+  ///
+  /// We need to be sure that we're making progress - it's possible that the
+  /// tree is so malformed that the transform never makes it to the
+  /// `TransformTypoExpr`.
+  ///
+  /// Returns true if there are any untried correction combinations.
   bool CheckAndAdvanceTypoExprCorrectionStreams() {
 for (auto TE : TypoExprs) {
   auto &State = SemaRef.getTypoExprState(TE);
   TransformCache.erase(TE);
+  if (!State.Consumer->hasMadeAnyCorrectionProgress())
+return false;
   if (!State.Consumer->finished())
 return true;
   State.Consumer->resetCorrectionStream();
Index: clang/include/clang/Sema/SemaInternal.h
===
--- clang/include/clang/Sema/SemaInternal.h
+++ clang/include/clang/Sema/SemaInternal.h
@@ -168,6 +168,11 @@
 return TC;
   }
 
+  /// In the case of deeply invalid expressions, `getNextCorrection()` will
+  /// never be called since the transform never makes progress. If we don't
+  /// detect this we risk trying to correct typos f

[clang] ec6ada6 - [AIX] report_fatal_error on `-fregister_global_dtors_with_atexit` for static init

2020-07-17 Thread Xiangling Liao via cfe-commits

Author: Xiangling Liao
Date: 2020-07-17T16:14:49-04:00
New Revision: ec6ada62643cf7cded8160e04cce163323112ade

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

LOG: [AIX] report_fatal_error on `-fregister_global_dtors_with_atexit` for 
static init

On AIX, the semantic of global_dtors contains __sterm functions associated with 
C++
cleanup actions and user-declared __attribute__((destructor)) functions. We 
should
never merely register __sterm with atexit(), so currently
-fregister_global_dtors_with_atexit does not work well on AIX: It would cause
finalization actions to not occur when unloading shared libraries.  We need to 
figure
out a way to handle that when we start supporting user-declared
__attribute__((destructor)) functions.

Currently we report_fatal_error on this option temporarily.

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

Added: 
clang/test/CodeGenCXX/aix-sinit-register-global-dtors-with-atexit.cpp

Modified: 
clang/lib/CodeGen/CodeGenModule.cpp
clang/test/Driver/cxa-atexit.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 4ae8ce7e5ccf..4c792520b5f3 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -1209,6 +1209,9 @@ void CodeGenModule::AddGlobalCtor(llvm::Function *Ctor, 
int Priority,
 /// when the module is unloaded.
 void CodeGenModule::AddGlobalDtor(llvm::Function *Dtor, int Priority) {
   if (CodeGenOpts.RegisterGlobalDtorsWithAtExit) {
+if (getCXXABI().useSinitAndSterm())
+  llvm::report_fatal_error(
+  "register global dtors with atexit() is not supported yet");
 DtorsUsingAtExit[Priority].push_back(Dtor);
 return;
   }

diff  --git 
a/clang/test/CodeGenCXX/aix-sinit-register-global-dtors-with-atexit.cpp 
b/clang/test/CodeGenCXX/aix-sinit-register-global-dtors-with-atexit.cpp
new file mode 100644
index ..4cec83d461ad
--- /dev/null
+++ b/clang/test/CodeGenCXX/aix-sinit-register-global-dtors-with-atexit.cpp
@@ -0,0 +1,14 @@
+// RUN: not %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ \
+// RUN: -fregister-global-dtors-with-atexit < %s 2>&1 | \
+// RUN:   FileCheck %s
+
+// RUN: not %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ \
+// RUN: -fregister-global-dtors-with-atexit < %s 2>&1 | \
+// RUN:   FileCheck %s
+
+struct T {
+  T();
+  ~T();
+} t;
+
+// CHECK: error in backend: register global dtors with atexit() is not 
supported yet

diff  --git a/clang/test/Driver/cxa-atexit.cpp 
b/clang/test/Driver/cxa-atexit.cpp
index e81af6cd5963..537a11a35f51 100644
--- a/clang/test/Driver/cxa-atexit.cpp
+++ b/clang/test/Driver/cxa-atexit.cpp
@@ -36,6 +36,7 @@
 // RUN: FileCheck --check-prefix=WITHATEXIT %s
 // RUN: %clang -target x86_64-apple-darwin -c -mkernel -### %s 2>&1 | \
 // RUN: FileCheck --check-prefix=WITHOUTATEXIT %s
+
 // RUN: %clang -target x86_64-pc-linux-gnu -fregister-global-dtors-with-atexit 
-fno-register-global-dtors-with-atexit -c -### %s 2>&1 | \
 // RUN: FileCheck --check-prefix=WITHOUTATEXIT %s
 // RUN: %clang -target x86_64-pc-linux-gnu 
-fno-register-global-dtors-with-atexit -fregister-global-dtors-with-atexit -c 
-### %s 2>&1 | \
@@ -43,5 +44,18 @@
 // RUN: %clang -target x86_64-pc-linux-gnu -c -### %s 2>&1 | \
 // RUN: FileCheck --check-prefix=WITHOUTATEXIT %s
 
+// RUN: %clang -target powerpc-ibm-aix-xcoff 
-fregister-global-dtors-with-atexit -fno-register-global-dtors-with-atexit -c 
-### %s 2>&1 | \
+// RUN: FileCheck --check-prefix=WITHOUTATEXIT %s
+// RUN: %clang -target powerpc-ibm-aix-xcoff 
-fno-register-global-dtors-with-atexit -fregister-global-dtors-with-atexit -c 
-### %s 2>&1 | \
+// RUN: FileCheck --check-prefix=WITHATEXIT %s
+// RUN: %clang -target powerpc-ibm-aix-xcoff -c -### %s 2>&1 | \
+// RUN: FileCheck --check-prefix=WITHOUTATEXIT %s
+// RUN: %clang -target powerpc64-ibm-aix-xcoff 
-fregister-global-dtors-with-atexit -fno-register-global-dtors-with-atexit -c 
-### %s 2>&1 | \
+// RUN: FileCheck --check-prefix=WITHOUTATEXIT %s
+// RUN: %clang -target powerpc64-ibm-aix-xcoff 
-fno-register-global-dtors-with-atexit -fregister-global-dtors-with-atexit -c 
-### %s 2>&1 | \
+// RUN: FileCheck --check-prefix=WITHATEXIT %s
+// RUN: %clang -target powerpc64-ibm-aix-xcoff -c -### %s 2>&1 | \
+// RUN: FileCheck --check-prefix=WITHOUTATEXIT %s
+
 // WITHATEXIT: -fregister-global-dtors-with-atexit
 // WITHOUTATEXIT-NOT: -fregister-global-dtors-with-atexit



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


[PATCH] D83974: [AIX] report_fatal_error on `-fregister_global_dtors_with_atexit` for static init

2020-07-17 Thread Xiangling Liao via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGec6ada62643c: [AIX] report_fatal_error on 
`-fregister_global_dtors_with_atexit` for static… (authored by Xiangling_L).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83974

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGenCXX/aix-sinit-register-global-dtors-with-atexit.cpp
  clang/test/Driver/cxa-atexit.cpp


Index: clang/test/Driver/cxa-atexit.cpp
===
--- clang/test/Driver/cxa-atexit.cpp
+++ clang/test/Driver/cxa-atexit.cpp
@@ -36,6 +36,7 @@
 // RUN: FileCheck --check-prefix=WITHATEXIT %s
 // RUN: %clang -target x86_64-apple-darwin -c -mkernel -### %s 2>&1 | \
 // RUN: FileCheck --check-prefix=WITHOUTATEXIT %s
+
 // RUN: %clang -target x86_64-pc-linux-gnu -fregister-global-dtors-with-atexit 
-fno-register-global-dtors-with-atexit -c -### %s 2>&1 | \
 // RUN: FileCheck --check-prefix=WITHOUTATEXIT %s
 // RUN: %clang -target x86_64-pc-linux-gnu 
-fno-register-global-dtors-with-atexit -fregister-global-dtors-with-atexit -c 
-### %s 2>&1 | \
@@ -43,5 +44,18 @@
 // RUN: %clang -target x86_64-pc-linux-gnu -c -### %s 2>&1 | \
 // RUN: FileCheck --check-prefix=WITHOUTATEXIT %s
 
+// RUN: %clang -target powerpc-ibm-aix-xcoff 
-fregister-global-dtors-with-atexit -fno-register-global-dtors-with-atexit -c 
-### %s 2>&1 | \
+// RUN: FileCheck --check-prefix=WITHOUTATEXIT %s
+// RUN: %clang -target powerpc-ibm-aix-xcoff 
-fno-register-global-dtors-with-atexit -fregister-global-dtors-with-atexit -c 
-### %s 2>&1 | \
+// RUN: FileCheck --check-prefix=WITHATEXIT %s
+// RUN: %clang -target powerpc-ibm-aix-xcoff -c -### %s 2>&1 | \
+// RUN: FileCheck --check-prefix=WITHOUTATEXIT %s
+// RUN: %clang -target powerpc64-ibm-aix-xcoff 
-fregister-global-dtors-with-atexit -fno-register-global-dtors-with-atexit -c 
-### %s 2>&1 | \
+// RUN: FileCheck --check-prefix=WITHOUTATEXIT %s
+// RUN: %clang -target powerpc64-ibm-aix-xcoff 
-fno-register-global-dtors-with-atexit -fregister-global-dtors-with-atexit -c 
-### %s 2>&1 | \
+// RUN: FileCheck --check-prefix=WITHATEXIT %s
+// RUN: %clang -target powerpc64-ibm-aix-xcoff -c -### %s 2>&1 | \
+// RUN: FileCheck --check-prefix=WITHOUTATEXIT %s
+
 // WITHATEXIT: -fregister-global-dtors-with-atexit
 // WITHOUTATEXIT-NOT: -fregister-global-dtors-with-atexit
Index: clang/test/CodeGenCXX/aix-sinit-register-global-dtors-with-atexit.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/aix-sinit-register-global-dtors-with-atexit.cpp
@@ -0,0 +1,14 @@
+// RUN: not %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ \
+// RUN: -fregister-global-dtors-with-atexit < %s 2>&1 | \
+// RUN:   FileCheck %s
+
+// RUN: not %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ \
+// RUN: -fregister-global-dtors-with-atexit < %s 2>&1 | \
+// RUN:   FileCheck %s
+
+struct T {
+  T();
+  ~T();
+} t;
+
+// CHECK: error in backend: register global dtors with atexit() is not 
supported yet
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -1209,6 +1209,9 @@
 /// when the module is unloaded.
 void CodeGenModule::AddGlobalDtor(llvm::Function *Dtor, int Priority) {
   if (CodeGenOpts.RegisterGlobalDtorsWithAtExit) {
+if (getCXXABI().useSinitAndSterm())
+  llvm::report_fatal_error(
+  "register global dtors with atexit() is not supported yet");
 DtorsUsingAtExit[Priority].push_back(Dtor);
 return;
   }


Index: clang/test/Driver/cxa-atexit.cpp
===
--- clang/test/Driver/cxa-atexit.cpp
+++ clang/test/Driver/cxa-atexit.cpp
@@ -36,6 +36,7 @@
 // RUN: FileCheck --check-prefix=WITHATEXIT %s
 // RUN: %clang -target x86_64-apple-darwin -c -mkernel -### %s 2>&1 | \
 // RUN: FileCheck --check-prefix=WITHOUTATEXIT %s
+
 // RUN: %clang -target x86_64-pc-linux-gnu -fregister-global-dtors-with-atexit -fno-register-global-dtors-with-atexit -c -### %s 2>&1 | \
 // RUN: FileCheck --check-prefix=WITHOUTATEXIT %s
 // RUN: %clang -target x86_64-pc-linux-gnu -fno-register-global-dtors-with-atexit -fregister-global-dtors-with-atexit -c -### %s 2>&1 | \
@@ -43,5 +44,18 @@
 // RUN: %clang -target x86_64-pc-linux-gnu -c -### %s 2>&1 | \
 // RUN: FileCheck --check-prefix=WITHOUTATEXIT %s
 
+// RUN: %clang -target powerpc-ibm-aix-xcoff -fregister-global-dtors-with-atexit -fno-register-global-dtors-with-atexit -c -### %s 2>&1 | \
+// RUN: FileCheck --check-prefix=WITHOUTATEXIT %s
+// RUN: %clang -target powerpc-ibm-aix-xcoff -fno-register-global-dtors-with-atexit -fregister-global-dtors-with-atexit -c -### %s 2>&1 | \
+// RUN: FileCheck --check-prefix=WITHATEXIT %s
+// RUN: %cla

[PATCH] D84068: AMDGPU/clang: Search resource directory for device libraries

2020-07-17 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

Could you walk me through how you see this working in practice?

IIUIC, the idea is to have bitcode files located somewhere within clang 
installation.
If that's the case, will we ship those bitcode libraries with clang, or do they 
come from ROCm packages?
If we ship them with clang, who/where/how builds them?
If they come from ROCm packages, how would those packages add stuff into 
*clang* install directory? Resource dir is a rather awkward location if 
contents may be expected to change routinely.
What if I have multiple ROCm versions installed? Which one should provide the 
bitcode in the resource dir?

As long as explicitly specified `--hip-device-lib-path` can still point to the 
right path, it's probably OK, but it all adds some confusion about who controls 
which parts of the HIP compilation and how it all is supposed to work in cases 
that deviate from the default assumptions.
It would help if the requirements would be documented somewhere.


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

https://reviews.llvm.org/D84068



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


[PATCH] D80242: [Clang] implement -fno-eliminate-unused-debug-types

2020-07-17 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:5385
+  if (getCodeGenOpts().hasMaybeUnusedDebugInfo() && CRD->hasDefinition())
+DI->completeUnusedClass(*CRD);
+  else if (auto *ES = D->getASTContext().getExternalSource())

nickdesaulniers wrote:
> dblaikie wrote:
> > nickdesaulniers wrote:
> > > dblaikie wrote:
> > > > I think this might not work as intended if the type trips over the 
> > > > other class deduplication optimizations (try manually testing with a 
> > > > type that has an external VTable?) - and perhaps this codepath should 
> > > > use the EmitAndRetain functionality.
> > > completeUnusedClass eventually calls into CGDebugInfo::completeClass 
> > > which makes use of the TypeCache.  What does it mean for a class to have 
> > > "an external vtable?"  Can you give me an example?
> > Here's some sample code that uses a type in the DWARF but due to the vtable 
> > being external (an external vtable is one that's guaranteed to be emitted 
> > in some other object file - due to the key function optimization in the 
> > Itanium ABI - since all virtual functions must be defined if a type is ODR 
> > used, the compiler can make a shared assumption that the vtable will only 
> > be emitted with a single consistently chosen virtual function (ideally: the 
> > first non-inline one) and emit the vtable only in that object and nowhere 
> > else) the type is emitted as a declaration (when using 
> > "-fno-standalone-debug"):
> > 
> > ```
> > struct t1 {
> >   virtual void f1();
> > };
> > t1 v1;
> > ```
> Cool, thanks for the example.  For your example:
> `clang -g -emit-llvm -S foo.cpp -o -`:
> ```
> ...
> DIGlobalVariable(name: "v1"
> ...
> DICompositeType(tag: DW_TAG_structure_type, name: "t1"
> ...
> ```
> `clang -g -fno-eliminate-unused-debug-types -emit-llvm -S foo.cpp -o -`:
> ```
> ...
> DIGlobalVariable(name: "v1"
> ...
> DICompositeType(tag: DW_TAG_structure_type, name: "t1"
> ...
> DIDerivedType(tag: DW_TAG_member, name: "_vptr$t1"
> DIDerivedType(tag: DW_TAG_pointer_type
> DIDerivedType(tag: DW_TAG_pointer_type, name: "__vtbl_ptr_type"
> DIBasicType(name: "int"
> DISubprogram(name: "f1"
> DISubroutineType
> DIDerivedType(tag: DW_TAG_pointer_type
> ...
> ```
> So even though `f1` was not defined, we still emit debug info for it.
> 
> Comparing the output of `llvm-dwarfdump` on `$CC -g 
> -fno-eliminate-unused-debug-types -c ` for `g++` vs `clang++`; 
> we're definitely producing more debug info (the vtable info).
> 
> 
> 
> That said, the creation of `v1` technically means that `t1` is no longer an 
> "unused type."  If we comment out its creation, then compare `$CC -g 
> -fno-eliminate-unused-debug-types -c ` for `g++` vs `clang++`, 
> `g++` produces no debug info (That seems like a bug in `g++` to me), while 
> `clang++` with this patch produces the debug info for the `CXXRecord`, and 
> additional info for the vtable ptr and signature of `f1`.
> 
> I'm not sure what's expected in this case (we should at least emit the 
> `DW_TAG_structure_type` for `t1`, but I'm not sure about the 
> `DW_TAG_subprogram` for `f1`.  I assume that's because we've enabled 
> more-than-full-debuginfo behavior? WDYT?
I think it'd be nice to handle this the same as GCC (though technically we 
don't offer the same customization that GCC offers - I imagine the GCC behavior 
of -femit-class-debug-always, which Clang doesn't have a configuration option 
for (well, not specifically - again, comes back to that "independent 
configuration" or "overriding behavior" implementation choice) - I'd sort of 
think of it like that flag is always enabled)

But I guess if we think of it as a series of escalations, then, yeah, it makes 
sense in the Clang way of thinking of it, as -fno-eliminate-unused-debug-types 
as overriding the default -fno-emit-class-debug-always... *shrug* don't feel 
/super/ strongly either way I guess. If the current implementation is such that 
-fno-eliminate-unused-debug-types overrides all other type homing techniques 
(vtable based, explicit template specialization decl/def, ctor based, and 
not-required-to-be-complete (define a type but only use pouinters to that type 
and never dereference them)) that's fine by me.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:3825-3828
+  if (EmitDwarf &&
+  Args.hasFlag(options::OPT_fno_eliminate_unused_debug_types,
+   options::OPT_feliminate_unused_debug_types, false))
+DebugInfoKind = codegenoptions::UnusedTypeInfo;

nickdesaulniers wrote:
> dblaikie wrote:
> > How does GCC compose this with -gmlt, for instance? I'd suspect that the 
> > desired behavior might be for -gmlt to override this -f flag? So maybe this 
> > should be predicated on "if (EmitDwarf && DebugInfoKind >= 
> > codegenoptions::LimitedDebugInfo && ... "?
> > 
> > (so if someone wants to use only -gmlt in certain parts of their build that 
> > doesn't 

[PATCH] D84067: Fix issue in typo handling which could lead clang to hang

2020-07-17 Thread David Goldman via Phabricator via cfe-commits
dgoldman updated this revision to Diff 278881.
dgoldman added a comment.

- CheckAndAdvanceTypoExprCorrectionStreams comment fix


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84067

Files:
  clang/include/clang/Sema/SemaInternal.h
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/Sema/typo-correction-no-hang.cpp
  clang/test/Sema/typo-correction-recursive.cpp

Index: clang/test/Sema/typo-correction-recursive.cpp
===
--- clang/test/Sema/typo-correction-recursive.cpp
+++ clang/test/Sema/typo-correction-recursive.cpp
@@ -118,3 +118,15 @@
   asDeepASItGet().
   functionE();
 }
+
+struct Dog {
+  int age;  //expected-note{{'age' declared here}}
+  int size; //expected-note{{'size' declared here}}
+};
+
+int from_dog_years(int DogYears, int DogSize);
+int get_dog_years() {
+  struct Dog doggo;
+  return from_dog_years(doggo.agee,   //expected-error{{no member named 'agee' in 'Dog'; did you mean 'age'}}
+doggo.sizee); //expected-error{{no member named 'sizee' in 'Dog'; did you mean 'size'}}
+}
Index: clang/test/Sema/typo-correction-no-hang.cpp
===
--- /dev/null
+++ clang/test/Sema/typo-correction-no-hang.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// From `test/Sema/typo-correction.c` but for C++ since the behavior varies
+// between the two languages.
+struct rdar38642201 {
+  int fieldName;
+};
+
+void rdar38642201_callee(int x, int y);
+void rdar38642201_caller() {
+  struct rdar38642201 structVar;
+  rdar38642201_callee(
+  structVar1.fieldName1.member1,  //expected-error{{use of undeclared identifier 'structVar1'}}
+  structVar2.fieldName2.member2); //expected-error{{use of undeclared identifier 'structVar2'}}
+}
+
+// Similar reproducer.
+class A {
+public:
+  int minut() const = delete;
+  int hour() const = delete;
+
+  int longit() const; //expected-note{{'longit' declared here}}
+  int latit() const;
+};
+
+class B {
+public:
+  A depar() const { return A(); }
+};
+
+int Foo(const B &b) {
+  return b.deparT().hours() * 60 + //expected-error{{no member named 'deparT' in 'B'}}
+ b.deparT().minutes(); //expected-error{{no member named 'deparT' in 'B'}}
+}
+
+int Bar(const B &b) {
+  return b.depar().longitude() + //expected-error{{no member named 'longitude' in 'A'; did you mean 'longit'?}}
+ b.depar().latitude();   //expected-error{{no member named 'latitude' in 'A'}}
+}
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -7977,19 +7977,26 @@
 }
   }
 
-  /// If corrections for the first TypoExpr have been exhausted for a
-  /// given combination of the other TypoExprs, retry those corrections against
-  /// the next combination of substitutions for the other TypoExprs by advancing
-  /// to the next potential correction of the second TypoExpr. For the second
-  /// and subsequent TypoExprs, if its stream of corrections has been exhausted,
-  /// the stream is reset and the next TypoExpr's stream is advanced by one (a
-  /// TypoExpr's correction stream is advanced by removing the TypoExpr from the
-  /// TransformCache). Returns true if there is still any untried combinations
-  /// of corrections.
+  /// Try to advance the typo correction state of the first unfinished TypoExpr.
+  /// We allow advancement of the correction stream by removing it from the
+  /// TransformCache which allows `TransformTypoExpr` to advance during the
+  /// next transformation attempt.
+  ///
+  /// Any substitution attempts for the previous TypoExprs (which must have been
+  /// finished) will need to be retried since it's possible that they will now
+  /// be invalid given the latest advancement.
+  ///
+  /// We need to be sure that we're making progress - it's possible that the
+  /// tree is so malformed that the transform never makes it to the
+  /// `TransformTypoExpr`.
+  ///
+  /// Returns true if there are any untried correction combinations.
   bool CheckAndAdvanceTypoExprCorrectionStreams() {
 for (auto TE : TypoExprs) {
   auto &State = SemaRef.getTypoExprState(TE);
   TransformCache.erase(TE);
+  if (!State.Consumer->hasMadeAnyCorrectionProgress())
+return false;
   if (!State.Consumer->finished())
 return true;
   State.Consumer->resetCorrectionStream();
Index: clang/include/clang/Sema/SemaInternal.h
===
--- clang/include/clang/Sema/SemaInternal.h
+++ clang/include/clang/Sema/SemaInternal.h
@@ -168,6 +168,11 @@
 return TC;
   }
 
+  /// In the case of deeply invalid expressions, `getNextCorrection()` will
+  /// never be called since the transform never makes progress. If we don't
+  /

[PATCH] D84067: Fix issue in typo handling which could lead clang to hang

2020-07-17 Thread David Goldman via Phabricator via cfe-commits
dgoldman updated this revision to Diff 278876.
dgoldman added a comment.

- Minor comment fix


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84067

Files:
  clang/include/clang/Sema/SemaInternal.h
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/Sema/typo-correction-no-hang.cpp
  clang/test/Sema/typo-correction-recursive.cpp

Index: clang/test/Sema/typo-correction-recursive.cpp
===
--- clang/test/Sema/typo-correction-recursive.cpp
+++ clang/test/Sema/typo-correction-recursive.cpp
@@ -118,3 +118,15 @@
   asDeepASItGet().
   functionE();
 }
+
+struct Dog {
+  int age;  //expected-note{{'age' declared here}}
+  int size; //expected-note{{'size' declared here}}
+};
+
+int from_dog_years(int DogYears, int DogSize);
+int get_dog_years() {
+  struct Dog doggo;
+  return from_dog_years(doggo.agee,   //expected-error{{no member named 'agee' in 'Dog'; did you mean 'age'}}
+doggo.sizee); //expected-error{{no member named 'sizee' in 'Dog'; did you mean 'size'}}
+}
Index: clang/test/Sema/typo-correction-no-hang.cpp
===
--- /dev/null
+++ clang/test/Sema/typo-correction-no-hang.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// From `test/Sema/typo-correction.c` but for C++ since the behavior varies
+// between the two languages.
+struct rdar38642201 {
+  int fieldName;
+};
+
+void rdar38642201_callee(int x, int y);
+void rdar38642201_caller() {
+  struct rdar38642201 structVar;
+  rdar38642201_callee(
+  structVar1.fieldName1.member1,  //expected-error{{use of undeclared identifier 'structVar1'}}
+  structVar2.fieldName2.member2); //expected-error{{use of undeclared identifier 'structVar2'}}
+}
+
+// Similar reproducer.
+class A {
+public:
+  int minut() const = delete;
+  int hour() const = delete;
+
+  int longit() const; //expected-note{{'longit' declared here}}
+  int latit() const;
+};
+
+class B {
+public:
+  A depar() const { return A(); }
+};
+
+int Foo(const B &b) {
+  return b.deparT().hours() * 60 + //expected-error{{no member named 'deparT' in 'B'}}
+ b.deparT().minutes(); //expected-error{{no member named 'deparT' in 'B'}}
+}
+
+int Bar(const B &b) {
+  return b.depar().longitude() + //expected-error{{no member named 'longitude' in 'A'; did you mean 'longit'?}}
+ b.depar().latitude();   //expected-error{{no member named 'latitude' in 'A'}}
+}
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -7977,19 +7977,24 @@
 }
   }
 
-  /// If corrections for the first TypoExpr have been exhausted for a
-  /// given combination of the other TypoExprs, retry those corrections against
-  /// the next combination of substitutions for the other TypoExprs by advancing
-  /// to the next potential correction of the second TypoExpr. For the second
-  /// and subsequent TypoExprs, if its stream of corrections has been exhausted,
-  /// the stream is reset and the next TypoExpr's stream is advanced by one (a
-  /// TypoExpr's correction stream is advanced by removing the TypoExpr from the
-  /// TransformCache). Returns true if there is still any untried combinations
-  /// of corrections.
+  /// Try to advance the typo correction state of the first unfinished TypoExpr.
+  /// We allow advancement of the correction stream by removing it from the
+  /// TransformCache which allows `TransformTypoExpr` to advance during the
+  /// next transformation attempt.
+  ///
+  /// Any substitution attempts for the previous TypoExprs (which must have be
+  /// finished) will need to be retried since it's possible that they will now
+  /// be valid given the latest advancement.
+  ///
+  /// We need to be sure that we're making progress - it's possible that the
+  /// tree is so malformed that the transform never makes it to the
+  /// `TransformTypoExpr`.
   bool CheckAndAdvanceTypoExprCorrectionStreams() {
 for (auto TE : TypoExprs) {
   auto &State = SemaRef.getTypoExprState(TE);
   TransformCache.erase(TE);
+  if (!State.Consumer->hasMadeAnyCorrectionProgress())
+return false;
   if (!State.Consumer->finished())
 return true;
   State.Consumer->resetCorrectionStream();
Index: clang/include/clang/Sema/SemaInternal.h
===
--- clang/include/clang/Sema/SemaInternal.h
+++ clang/include/clang/Sema/SemaInternal.h
@@ -168,6 +168,11 @@
 return TC;
   }
 
+  /// In the case of deeply invalid expressions, `getNextCorrection()` will
+  /// never be called since the transform never makes progress. If we don't
+  /// detect this we risk trying to correct typos forever.
+  bool hasMadeAnyCorrectionProgress() const { return Curren

[PATCH] D84068: AMDGPU/clang: Search resource directory for device libraries

2020-07-17 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm created this revision.
arsenm added reviewers: yaxunl, tra.
Herald added subscribers: kerbowa, t-tye, tpr, dstuttard, nhaehnle, wdng, 
jvesely, kzhuravl.

This should be the preferred way of locating the libraries, and it's a
packaging problem to ensure the libraries are symlinked into the
resource directory.

  

This takes precedence over searching for the rocm installation, but
 check an explicit --hip-device-lib-path first.


https://reviews.llvm.org/D84068

Files:
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/lib/Driver/ToolChains/ROCm.h
  clang/test/Driver/Inputs/resource_dir/lib/amdhsa/amdgcn/hip.bc
  clang/test/Driver/Inputs/resource_dir/lib/amdhsa/amdgcn/ockl.bc
  
clang/test/Driver/Inputs/resource_dir/lib/amdhsa/amdgcn/oclc_correctly_rounded_sqrt_off.bc
  
clang/test/Driver/Inputs/resource_dir/lib/amdhsa/amdgcn/oclc_correctly_rounded_sqrt_on.bc
  clang/test/Driver/Inputs/resource_dir/lib/amdhsa/amdgcn/oclc_daz_opt_off.bc
  clang/test/Driver/Inputs/resource_dir/lib/amdhsa/amdgcn/oclc_daz_opt_on.bc
  
clang/test/Driver/Inputs/resource_dir/lib/amdhsa/amdgcn/oclc_finite_only_off.bc
  clang/test/Driver/Inputs/resource_dir/lib/amdhsa/amdgcn/oclc_finite_only_on.bc
  
clang/test/Driver/Inputs/resource_dir/lib/amdhsa/amdgcn/oclc_isa_version_1010.bc
  
clang/test/Driver/Inputs/resource_dir/lib/amdhsa/amdgcn/oclc_isa_version_1011.bc
  
clang/test/Driver/Inputs/resource_dir/lib/amdhsa/amdgcn/oclc_isa_version_1012.bc
  
clang/test/Driver/Inputs/resource_dir/lib/amdhsa/amdgcn/oclc_isa_version_803.bc
  
clang/test/Driver/Inputs/resource_dir/lib/amdhsa/amdgcn/oclc_isa_version_900.bc
  
clang/test/Driver/Inputs/resource_dir/lib/amdhsa/amdgcn/oclc_unsafe_math_off.bc
  clang/test/Driver/Inputs/resource_dir/lib/amdhsa/amdgcn/oclc_unsafe_math_on.bc
  
clang/test/Driver/Inputs/resource_dir/lib/amdhsa/amdgcn/oclc_wavefrontsize64_off.bc
  
clang/test/Driver/Inputs/resource_dir/lib/amdhsa/amdgcn/oclc_wavefrontsize64_on.bc
  clang/test/Driver/Inputs/resource_dir/lib/amdhsa/amdgcn/ocml.bc
  clang/test/Driver/Inputs/resource_dir/lib/amdhsa/amdgcn/opencl.bc
  clang/test/Driver/hip-device-libs-resource-dir.hip

Index: clang/test/Driver/hip-device-libs-resource-dir.hip
===
--- /dev/null
+++ clang/test/Driver/hip-device-libs-resource-dir.hip
@@ -0,0 +1,120 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: amdgpu-registered-target
+
+// Test if oclc_daz_opt_on or if oclc_daz_opt_off is linked depending on
+// expected denormal mode.
+
+// Test subtarget with flushing on by default.
+// RUN: %clang -### -target x86_64-linux-gnu \
+// RUN:  --cuda-gpu-arch=gfx803 \
+// RUN:  -resource-dir=%S/Inputs/resource_dir   \
+// RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
+// RUN: 2>&1 | FileCheck %s --check-prefixes=ALL,FLUSHD
+
+
+// Test subtarget with flushing off by ddefault.
+// RUN: %clang -### -target x86_64-linux-gnu \
+// RUN:  --cuda-gpu-arch=gfx900 \
+// RUN:  -resource-dir=%S/Inputs/resource_dir \
+// RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
+// RUN: 2>&1 | FileCheck %s --check-prefixes=ALL,NOFLUSHD
+
+
+// Test explicit flag, opposite of target default.
+// RUN: %clang -### -target x86_64-linux-gnu \
+// RUN:   --cuda-gpu-arch=gfx900 \
+// RUN:   -fcuda-flush-denormals-to-zero \
+// RUN:   -resource-dir=%S/Inputs/resource_dir \
+// RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
+// RUN: 2>&1 | FileCheck %s --check-prefixes=ALL,FLUSHD
+
+
+// Test explicit flag, opposite of target default.
+// RUN: %clang -### -target x86_64-linux-gnu \
+// RUN:   --cuda-gpu-arch=gfx803 \
+// RUN:   -fno-cuda-flush-denormals-to-zero \
+// RUN:   -resource-dir=%S/Inputs/resource_dir \
+// RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
+// RUN: 2>&1 | FileCheck %s --check-prefixes=ALL,NOFLUSHD
+
+
+// Test explicit flag, same as target default.
+// RUN: %clang -### -target x86_64-linux-gnu \
+// RUN:   --cuda-gpu-arch=gfx900 \
+// RUN:   -fno-cuda-flush-denormals-to-zero \
+// RUN:   -resource-dir=%S/Inputs/resource_dir \
+// RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
+// RUN: 2>&1 | FileCheck %s --check-prefixes=ALL,NOFLUSHD
+
+
+// Test explicit flag, same as target default.
+// RUN: %clang -### -target x86_64-linux-gnu \
+// RUN:   --cuda-gpu-arch=gfx803 \
+// RUN:   -fcuda-flush-denormals-to-zero \
+// RUN:   -resource-dir=%S/Inputs/resource_dir \
+// RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
+// RUN: 2>&1 | FileCheck %s --check-prefixes=ALL,FLUSHD
+
+
+// Test last flag wins, not flushing
+// RUN: %clang -### -target x86_64-linux-gnu \
+// RUN:   --cuda-gpu-arch=gfx803 \
+// RUN:   -fcuda-flush-denormals-to-zero -fno-cuda-flush-denormals-to-zero \
+// RUN:   -resource-dir=%S/Inputs/resource_dir \
+// RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
+// RUN: 2>&1 | FileCheck %s --check-prefixes=ALL,NOFLUSHD
+
+
+// RUN: %clang -### -target x86_64-linux-gnu \
+// RUN:   --cuda-gpu-arch=gfx900 \
+// RUN:   -fcuda-flush-denormals-to-zero

[PATCH] D84067: Fix issue in typo handling which could lead clang to hang

2020-07-17 Thread David Goldman via Phabricator via cfe-commits
dgoldman created this revision.
dgoldman added a reviewer: rsmith.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

We need to detect when certain TypoExprs are not being transformed
due to invalid trees, otherwise we risk endlessly trying to fix it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84067

Files:
  clang/include/clang/Sema/SemaInternal.h
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/Sema/typo-correction-no-hang.cpp
  clang/test/Sema/typo-correction-recursive.cpp

Index: clang/test/Sema/typo-correction-recursive.cpp
===
--- clang/test/Sema/typo-correction-recursive.cpp
+++ clang/test/Sema/typo-correction-recursive.cpp
@@ -118,3 +118,15 @@
   asDeepASItGet().
   functionE();
 }
+
+struct Dog {
+  int age;  //expected-note{{'age' declared here}}
+  int size; //expected-note{{'size' declared here}}
+};
+
+int from_dog_years(int DogYears, int DogSize);
+int get_dog_years() {
+  struct Dog doggo;
+  return from_dog_years(doggo.agee,   //expected-error{{no member named 'agee' in 'Dog'; did you mean 'age'}}
+doggo.sizee); //expected-error{{no member named 'sizee' in 'Dog'; did you mean 'size'}}
+}
Index: clang/test/Sema/typo-correction-no-hang.cpp
===
--- /dev/null
+++ clang/test/Sema/typo-correction-no-hang.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// From `test/Sema/typo-correction.c` but for C++ since the behavior varies
+// between the two languages.
+struct rdar38642201 {
+  int fieldName;
+};
+
+void rdar38642201_callee(int x, int y);
+void rdar38642201_caller() {
+  struct rdar38642201 structVar;
+  rdar38642201_callee(
+  structVar1.fieldName1.member1,  //expected-error{{use of undeclared identifier 'structVar1'}}
+  structVar2.fieldName2.member2); //expected-error{{use of undeclared identifier 'structVar2'}}
+}
+
+// Similar reproducer.
+class A {
+public:
+  int minut() const = delete;
+  int hour() const = delete;
+
+  int longit() const; //expected-note{{'longit' declared here}}
+  int latit() const;
+};
+
+class B {
+public:
+  A depar() const { return A(); }
+};
+
+int Foo(const B &b) {
+  return b.deparT().hours() * 60 + //expected-error{{no member named 'deparT' in 'B'}}
+ b.deparT().minutes(); //expected-error{{no member named 'deparT' in 'B'}}
+}
+
+int Bar(const B &b) {
+  return b.depar().longitude() + //expected-error{{no member named 'longitude' in 'A'; did you mean 'longit'?}}
+ b.depar().latitude();   //expected-error{{no member named 'latitude' in 'A'}}
+}
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -7977,19 +7977,24 @@
 }
   }
 
-  /// If corrections for the first TypoExpr have been exhausted for a
-  /// given combination of the other TypoExprs, retry those corrections against
-  /// the next combination of substitutions for the other TypoExprs by advancing
-  /// to the next potential correction of the second TypoExpr. For the second
-  /// and subsequent TypoExprs, if its stream of corrections has been exhausted,
-  /// the stream is reset and the next TypoExpr's stream is advanced by one (a
-  /// TypoExpr's correction stream is advanced by removing the TypoExpr from the
-  /// TransformCache). Returns true if there is still any untried combinations
-  /// of corrections.
+  /// Try to advance the typo correction state of the first unfinished TypoExpr.
+  /// We allow advancement of the correction stream by removing it from the
+  /// TransformCache which allows `TransformTypoExpr` to advance during the
+  /// next transformation attempt.
+  ///
+  /// Any substitution attempts for the previous TypoExprs (which must have be
+  /// finished) will need to be retried since it's possible that they will now
+  /// be valid given the latest advancement.
+  ///
+  /// We need to be sure that we're making progress - it's possible that the
+  /// tree is so malformed that the transform never makes it to the
+  /// `TransformTypoExpr`.
   bool CheckAndAdvanceTypoExprCorrectionStreams() {
 for (auto TE : TypoExprs) {
   auto &State = SemaRef.getTypoExprState(TE);
   TransformCache.erase(TE);
+  if (!State.Consumer->hasMadeAnyCorrectionProgress())
+return false;
   if (!State.Consumer->finished())
 return true;
   State.Consumer->resetCorrectionStream();
Index: clang/include/clang/Sema/SemaInternal.h
===
--- clang/include/clang/Sema/SemaInternal.h
+++ clang/include/clang/Sema/SemaInternal.h
@@ -168,6 +168,11 @@
 return TC;
   }
 
+  /// In the case of deeply invalid expressions, `getCurrentCorrection()` will
+  /// never be called since the transform never makes progress. If we don't
+  

[PATCH] D82467: [PowerPC][Power10] Implement Truncate and Store VSX Vector Builtins

2020-07-17 Thread Stefan Pintilie via Phabricator via cfe-commits
stefanp accepted this revision as: stefanp.
stefanp added a comment.

LGTM.

Please wait for Lei to give the approval as well before you commit.




Comment at: llvm/test/CodeGen/PowerPC/builtins-ppc-p10vsx.ll:2
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN:   -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | \

NeHuang wrote:
> Do we also need to run for big endian?
I don't think it would hurt to add a BE run for this as well. the only thing to 
watch out for is the fact that this is not actually a new file. This test file 
already exists on master so I assume that this will be merged in (and not added 
as a new file). 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82467



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


[PATCH] D83099: [clangd] Store index in '.cache/clangd/index' instead of '.clangd/index'

2020-07-17 Thread David Van Cleve via Phabricator via cfe-commits
davidvancleve added a comment.

Seems like it's working as expected now! Thanks again.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83099



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


[PATCH] D83519: [NewPM] Support optnone under new pass manager

2020-07-17 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

In D83519#2158938 , @ychen wrote:

> In D83519#2144616 , @aeubanks wrote:
>
> > In D83519#2144463 , @aeubanks 
> > wrote:
> >
> > > In D83519#2144403 , @ychen wrote:
> > >
> > > > High-level request: how about split this patch into two, the first for 
> > > > the `require` pass part; the second for the PassInstrument callback. 
> > > > Then we could discuss the choices of first patch and D82344 
> > > > .
> > >
> > >
> > > Good idea, will split the patch and take a closer look at your patch.
> >
> >
> > I split the required passes part into https://reviews.llvm.org/D83575.
>
>
> Could you remove the `Required` part of this patch?


Done. The test now fails because your patch for required passes hasn't been 
submitted yet, after that's submitted this one should be good to go.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83519



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


[PATCH] D84058: Pass -rtlib=libgcc in tests conditioned on the default.

2020-07-17 Thread Anatoly Trosinenko via Phabricator via cfe-commits
atrosinenko added a reviewer: atrosinenko.
atrosinenko added a comment.

If I get it right, the only thing this patch weakens about msp430-toolchain.c 
test is an assumption that libgcc is used by default.

On one hand, now there is no `clang_rt.builtins` for MSP430, so testing this 
assumption makes some sense. Still, it was not intentional at the time of 
writing. :)

On the other hand, I'm working on porting builtins to MSP430. Even when 
builtins library is not available and the default rtlib is compiler-rt, this 
should not introduce some "hidden" errors - just an explicitly failing linker.

So this patch looks quite reasonable to me. I would wait a bit in case @krisb 
has some comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84058



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


[PATCH] D83519: [NewPM] Support optnone under new pass manager

2020-07-17 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks updated this revision to Diff 278871.
aeubanks added a comment.

Remove required passes part
Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83519

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  llvm/include/llvm/Passes/StandardInstrumentations.h
  llvm/lib/LTO/LTOBackend.cpp
  llvm/lib/Passes/StandardInstrumentations.cpp
  llvm/test/Feature/optnone-opt.ll
  llvm/tools/opt/NewPMDriver.cpp

Index: llvm/tools/opt/NewPMDriver.cpp
===
--- llvm/tools/opt/NewPMDriver.cpp
+++ llvm/tools/opt/NewPMDriver.cpp
@@ -260,7 +260,7 @@
 }
   }
   PassInstrumentationCallbacks PIC;
-  StandardInstrumentations SI;
+  StandardInstrumentations SI(DebugPM);
   SI.registerCallbacks(PIC);
 
   PipelineTuningOptions PTO;
Index: llvm/test/Feature/optnone-opt.ll
===
--- llvm/test/Feature/optnone-opt.ll
+++ llvm/test/Feature/optnone-opt.ll
@@ -1,9 +1,15 @@
-; RUN: opt -S -debug %s 2>&1 | FileCheck %s --check-prefix=OPT-O0
-; RUN: opt -O1 -S -debug %s 2>&1 | FileCheck %s --check-prefix=OPT-O1
-; RUN: opt -O2 -S -debug %s 2>&1 | FileCheck %s --check-prefix=OPT-O1 --check-prefix=OPT-O2O3
-; RUN: opt -O3 -S -debug %s 2>&1 | FileCheck %s --check-prefix=OPT-O1 --check-prefix=OPT-O2O3
-; RUN: opt -dce -die -gvn-hoist -loweratomic -S -debug %s 2>&1 | FileCheck %s --check-prefix=OPT-MORE
-; RUN: opt -indvars -licm -loop-deletion -loop-extract -loop-idiom -loop-instsimplify -loop-reduce -loop-reroll -loop-rotate -loop-unroll -loop-unswitch -S -debug %s 2>&1 | FileCheck %s --check-prefix=OPT-LOOP
+; RUN: opt -S -debug -enable-new-pm=0 %s 2>&1 | FileCheck %s --check-prefix=O0
+; RUN: opt -O1 -S -debug -enable-new-pm=0 %s 2>&1 | FileCheck %s --check-prefix=O1
+; RUN: opt -O2 -S -debug -enable-new-pm=0 %s 2>&1 | FileCheck %s --check-prefix=O1 --check-prefix=O2O3
+; RUN: opt -O3 -S -debug -enable-new-pm=0 %s 2>&1 | FileCheck %s --check-prefix=O1 --check-prefix=O2O3
+; RUN: opt -dce -die -gvn-hoist -loweratomic -S -debug -enable-new-pm=0 %s 2>&1 | FileCheck %s --check-prefix=MORE
+; RUN: opt -indvars -licm -loop-deletion -loop-extract -loop-idiom -loop-instsimplify -loop-reduce -loop-reroll -loop-rotate -loop-unroll -loop-unswitch -enable-new-pm=0 -S -debug %s 2>&1 | FileCheck %s --check-prefix=LOOP
+; RUN: opt -enable-npm-optnone -S -debug-pass-manager -enable-new-pm %s 2>&1 | FileCheck %s --check-prefix=NPM-O0
+; RUN: opt -enable-npm-optnone -O1 -S -debug-pass-manager -enable-new-pm %s 2>&1 | FileCheck %s --check-prefix=NPM-O1
+; RUN: opt -enable-npm-optnone -O2 -S -debug-pass-manager -enable-new-pm %s 2>&1 | FileCheck %s --check-prefix=NPM-O1 --check-prefix=NPM-O2O3
+; RUN: opt -enable-npm-optnone -O3 -S -debug-pass-manager -enable-new-pm %s 2>&1 | FileCheck %s --check-prefix=NPM-O1 --check-prefix=NPM-O2O3
+; RUN: opt -enable-npm-optnone -dce -gvn-hoist -loweratomic -S -debug-pass-manager -enable-new-pm %s 2>&1 | FileCheck %s --check-prefix=NPM-MORE
+; RUN: opt -enable-npm-optnone -indvars -licm -loop-deletion -loop-idiom -loop-instsimplify -loop-reduce -loop-unroll -simple-loop-unswitch -S -debug-pass-manager -enable-new-pm %s 2>&1 | FileCheck %s --check-prefix=NPM-LOOP
 
 ; REQUIRES: asserts
 
@@ -34,32 +40,53 @@
 attributes #0 = { optnone noinline }
 
 ; Nothing that runs at -O0 gets skipped.
-; OPT-O0-NOT: Skipping pass
+; O0-NOT: Skipping pass
+; NPM-O0-NOT: Skipping pass
 
 ; IR passes run at -O1 and higher.
-; OPT-O1-DAG: Skipping pass 'Aggressive Dead Code Elimination'
-; OPT-O1-DAG: Skipping pass 'Combine redundant instructions'
-; OPT-O1-DAG: Skipping pass 'Early CSE'
-; OPT-O1-DAG: Skipping pass 'Reassociate expressions'
-; OPT-O1-DAG: Skipping pass 'Simplify the CFG'
-; OPT-O1-DAG: Skipping pass 'Sparse Conditional Constant Propagation'
+; O1-DAG: Skipping pass 'Aggressive Dead Code Elimination'
+; O1-DAG: Skipping pass 'Combine redundant instructions'
+; O1-DAG: Skipping pass 'Early CSE'
+; O1-DAG: Skipping pass 'Reassociate expressions'
+; O1-DAG: Skipping pass 'Simplify the CFG'
+; O1-DAG: Skipping pass 'Sparse Conditional Constant Propagation'
+; NPM-O1-DAG: Skipping pass: SimplifyCFGPass
+; NPM-O1-DAG: Skipping pass: SROA
+; NPM-O1-DAG: Skipping pass: EarlyCSEPass
+; NPM-O1-DAG: Skipping pass: LowerExpectIntrinsicPass
+; NPM-O1-DAG: Skipping pass: PromotePass
+; NPM-O1-DAG: Skipping pass: InstCombinePass
 
 ; Additional IR passes run at -O2 and higher.
-; OPT-O2O3-DAG: Skipping pass 'Global Value Numbering'
-; OPT-O2O3-DAG: Skipping pass 'SLP Vectorizer'
+; O2O3-DAG: Skipping pass 'Global Value Numbering'
+; O2O3-DAG: Skipping pass 'SLP Vectorizer'
+; NPM-O2O3-DAG: Skipping pass: GVN
+; NPM-O2O3-DAG: Skipping pass: SLPVectorizerPass
 
 ; Additional IR passes that opt doesn't turn on by default.
-; OPT-MORE-DAG: Skipping pass 'Dead Code Elimination'
-; OPT-MORE-DAG: Skipping pass 'Dead Instruc

[PATCH] D83190: [analyzer] Model iterator random incrementation symmetrically

2020-07-17 Thread Endre Fülöp via Phabricator via cfe-commits
gamesh411 updated this revision to Diff 278870.
gamesh411 added a comment.

rename Offset -> Amount inside handleRandomIncrOrDecl
minor local variable renaming


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83190

Files:
  clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
  clang/test/Analysis/iterator-modeling.cpp

Index: clang/test/Analysis/iterator-modeling.cpp
===
--- clang/test/Analysis/iterator-modeling.cpp
+++ clang/test/Analysis/iterator-modeling.cpp
@@ -149,7 +149,7 @@
   clang_analyzer_express(clang_analyzer_iterator_position(i2)); // expected-warning-re {{$v.end(){{$
 }
 
-void plus(const std::vector &v) {
+void plus_lhs(const std::vector &v) {
   auto i1 = v.begin();
 
   clang_analyzer_denote(clang_analyzer_container_begin(v), "$v.begin()");
@@ -161,7 +161,19 @@
   clang_analyzer_express(clang_analyzer_iterator_position(i2)); // expected-warning-re{{$v.begin() + 2{{$
 }
 
-void plus_negative(const std::vector &v) {
+void plus_rhs(const std::vector &v) {
+  auto i1 = v.begin();
+
+  clang_analyzer_denote(clang_analyzer_container_begin(v), "$v.begin()");
+
+  auto i2 = 2 + i1;
+
+  clang_analyzer_eval(clang_analyzer_iterator_container(i2) == &v); // expected-warning{{TRUE}}
+  clang_analyzer_express(clang_analyzer_iterator_position(i1)); // expected-warning-re{{$v.begin(){{$
+  clang_analyzer_express(clang_analyzer_iterator_position(i2)); // expected-warning-re{{$v.begin() + 2{{$
+}
+
+void plus_lhs_negative(const std::vector &v) {
   auto i1 = v.end();
 
   clang_analyzer_denote(clang_analyzer_container_end(v), "$v.end()");
@@ -173,6 +185,18 @@
   clang_analyzer_express(clang_analyzer_iterator_position(i2)); // expected-warning-re {{$v.end() - 2{{$
 }
 
+void plus_rhs_negative(const std::vector &v) {
+  auto i1 = v.end();
+
+  clang_analyzer_denote(clang_analyzer_container_end(v), "$v.end()");
+
+  auto i2 = (-2) + i1;
+
+  clang_analyzer_eval(clang_analyzer_iterator_container(i2) == &v); // expected-warning{{TRUE}}
+  clang_analyzer_express(clang_analyzer_iterator_position(i1)); // expected-warning-re {{$v.end(){{$
+  clang_analyzer_express(clang_analyzer_iterator_position(i2)); // expected-warning-re {{$v.end() - 2{{$
+}
+
 void minus(const std::vector &v) {
   auto i1 = v.end();
 
@@ -1955,7 +1979,7 @@
   i -= n; // no-crash
 }
 
-void plus_ptr_iterator(const cont_with_ptr_iterator &c) {
+void plus_lhs_ptr_iterator(const cont_with_ptr_iterator &c) {
   auto i1 = c.begin();
 
   clang_analyzer_denote(clang_analyzer_container_begin(c), "$c.begin()");
@@ -1967,6 +1991,18 @@
   clang_analyzer_express(clang_analyzer_iterator_position(i2)); // expected-warning{{$c.begin() + 2}}
 }
 
+void plus_rhs_ptr_iterator(const cont_with_ptr_iterator &c) {
+  auto i1 = c.begin();
+
+  clang_analyzer_denote(clang_analyzer_container_begin(c), "$c.begin()");
+
+  auto i2 = 2 + i1;
+
+  clang_analyzer_eval(clang_analyzer_iterator_container(i2) == &c); // expected-warning{{TRUE}}
+  clang_analyzer_express(clang_analyzer_iterator_position(i1)); // expected-warning{{$c.begin()}}
+  clang_analyzer_express(clang_analyzer_iterator_position(i2)); // expected-warning{{$c.begin() + 2}}
+}
+
 void minus_ptr_iterator(const cont_with_ptr_iterator &c) {
   auto i1 = c.end();
 
Index: clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
+++ clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
@@ -109,7 +109,7 @@
bool Postfix) const;
   void handleRandomIncrOrDecr(CheckerContext &C, const Expr *CE,
   OverloadedOperatorKind Op, const SVal &RetVal,
-  const SVal &LHS, const SVal &RHS) const;
+  const SVal &Iterator, const SVal &Amount) const;
   void handlePtrIncrOrDecr(CheckerContext &C, const Expr *Iterator,
OverloadedOperatorKind OK, SVal Offset) const;
   void handleAdvance(CheckerContext &C, const Expr *CE, SVal RetVal, SVal Iter,
@@ -262,20 +262,30 @@
 
 void IteratorModeling::checkPostStmt(const BinaryOperator *BO,
  CheckerContext &C) const {
-  ProgramStateRef State = C.getState();
-  BinaryOperatorKind OK = BO->getOpcode();
-  SVal RVal = State->getSVal(BO->getRHS(), C.getLocationContext());
+  const ProgramStateRef State = C.getState();
+  const BinaryOperatorKind OK = BO->getOpcode();
+  const Expr *const LHS = BO->getLHS();
+  const Expr *const RHS = BO->getRHS();
+  const SVal LVal = State->getSVal(LHS, C.getLocationContext());
+  const SVal RVal = State->getSVal(RHS, C.getLocationContext());
 
   if (isSimpleComparisonOperator(BO->getOpcode())) {
-SVal LVal = State->getSVal(BO->getLHS(), C.getLocat

[PATCH] D84058: Pass -rtlib=libgcc in tests conditioned on the default.

2020-07-17 Thread Sterling Augustine via Phabricator via cfe-commits
saugustine added a comment.

This is a reasonable workaround, as it seems to be checking the position of 
various arguments, and as things work today, lgcc and the compiler-rt variants 
appear in exactly the same places.

If we wanted to be really strict, we would add some new test that tested that 
the two different libraries appeared in exactly the same places, but I believe 
if this became not true we would see many other failures.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84058



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


[clang] 5d06e8b - Pass -rtlib=libgcc in tests conditioned on the default.

2020-07-17 Thread Stella Laurenzo via cfe-commits

Author: Stella Laurenzo
Date: 2020-07-17T11:28:18-07:00
New Revision: 5d06e8b24f97202764c7522efcfb6e2febdce6b7

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

LOG: Pass -rtlib=libgcc in tests conditioned on the default.

Summary:
* This test was failing in our builds that configure compiler-rt as the 
configure-time rtlib.
* Opted for this test fix instead of a rollback, and hopefully TI can fix 
forward if this weakens the tests beyond expectations.
* Suspected this failure introduced in D81676.

Subscribers: cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/test/Driver/msp430-toolchain.c

Removed: 




diff  --git a/clang/test/Driver/msp430-toolchain.c 
b/clang/test/Driver/msp430-toolchain.c
index f88b32d66a9b..1aee2f75a9d9 100644
--- a/clang/test/Driver/msp430-toolchain.c
+++ b/clang/test/Driver/msp430-toolchain.c
@@ -66,11 +66,11 @@
 
 // Tests for -nostdlib, -nostartfiles, -nodefaultfiles and -f(no-)exceptions
 
-// RUN: %clang %s -### -no-canonical-prefixes -target msp430 \
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -rtlib=libgcc \
 // RUN:   --sysroot="%S/Inputs/basic_msp430_tree" > %t 2>&1
 // RUN: FileCheck -check-prefix=LIBS-DEFAULT-POS %s < %t
 // RUN: FileCheck -check-prefix=LIBS-DEFAULT-NEG %s < %t
-// RUN: %clang %s -### -no-canonical-prefixes -target msp430 \
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -rtlib=libgcc \
 // RUN:   --gcc-toolchain="%S/Inputs/basic_msp430_tree" --sysroot="" 2>&1 \
 // RUN:   | FileCheck -check-prefix=LIBS-DEFAULT-GCC-TOOLCHAIN %s
 // LIBS-DEFAULT-POS: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/../../..{{/|}}..{{/|}}bin{{/|}}msp430-elf-ld"
@@ -112,7 +112,7 @@
 // LIBS-COMPILER-RT-NEG-NOT: crtend.o
 // LIBS-COMPILER-RT-NEG-NOT: /exceptions
 
-// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -fexceptions \
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -rtlib=libgcc 
-fexceptions \
 // RUN:   --sysroot="%S/Inputs/basic_msp430_tree" > %t 2>&1
 // RUN: FileCheck -check-prefix=LIBS-EXC-POS %s < %t
 // RUN: FileCheck -check-prefix=LIBS-EXC-NEG %s < %t
@@ -126,7 +126,7 @@
 // LIBS-EXC-NEG-NOT: "{{.*}}/430"
 // LIBS-EXC-NEG-NOT: "{{.*}}430/crt{{.*}}"
 
-// RUN: %clang %s -### -no-canonical-prefixes -target msp430 \
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -rtlib=libgcc \
 // RUN:   -fstack-protector  --sysroot="%S/Inputs/basic_msp430_tree" 2>&1 \
 // RUN:   | FileCheck -check-prefix=LIBS-SSP %s
 // LIBS-SSP: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/../../..{{/|}}..{{/|}}bin{{/|}}msp430-elf-ld"
@@ -138,7 +138,7 @@
 // LIBS-SSP: "-lgcc" "--start-group" "-lmul_none" "-lc" "-lgcc" "-lcrt" 
"-lnosys" "--end-group"
 // LIBS-SSP: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430{{/|}}crtend_no_eh.o"
 "-lgcc"
 
-// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -nodefaultlibs \
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -rtlib=libgcc 
-nodefaultlibs \
 // RUN:   --sysroot="%S/Inputs/basic_msp430_tree" > %t 2>&1
 // RUN: FileCheck -check-prefix=LIBS-NO-DFT-POS %s < %t
 // RUN: FileCheck -check-prefix=LIBS-NO-DFT-NEG %s < %t
@@ -155,7 +155,7 @@
 // LIBS-NO-DFT-NEG-NOT: "--start-group"
 // LIBS-NO-DFT-NEG-NOT: "--end-group"
 
-// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -nolibc \
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -rtlib=libgcc 
-nolibc \
 // RUN:   -fstack-protector --sysroot="%S/Inputs/basic_msp430_tree" > %t 2>&1
 // RUN: FileCheck -check-prefix=LIBS-NO-LIBC-POS %s < %t
 // RUN: FileCheck -check-prefix=LIBS-NO-LIBC-NEG %s < %t
@@ -173,7 +173,7 @@
 // LIBS-NO-LIBC-NEG-NOT: "--start-group"
 // LIBS-NO-LIBC-NEG-NOT: "--end-group"
 
-// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -nostartfiles \
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -rtlib=libgcc 
-nostartfiles \
 // RUN:   --sysroot="%S/Inputs/basic_msp430_tree" > %t 2>&1
 // RUN: FileCheck -check-prefix=LIBS-NO-START-POS %s < %t
 // RUN: FileCheck -check-prefix=LIBS-NO-START-NEG %s < %t
@@ -222,7 +222,7 @@
 // Test for compiling for simulator
 
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430g2553 
\
-// RUN:   -msim --sysroot=%S/Inputs/basic_msp430_tree > %t 2>&1
+// RUN:   -msim -rtlib=libgcc --sysroot=%S/Inputs/basic_msp430_tree > %t 2>&1
 // RUN: FileCheck -check-prefix=SIMULATOR-POS %s < %t
 // RUN: FileCheck -check-prefix=SIMULATOR-NEG %s < %t
 // SIMULATOR-POS: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/../../..{{/|}}..{{/|}}bin{{/|}}msp430-elf-ld"



___
cfe-comm

[PATCH] D84058: Pass -rtlib=libgcc in tests conditioned on the default.

2020-07-17 Thread Stella Laurenzo via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5d06e8b24f97: Pass -rtlib=libgcc in tests conditioned on the 
default. (authored by stellaraccident).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84058

Files:
  clang/test/Driver/msp430-toolchain.c


Index: clang/test/Driver/msp430-toolchain.c
===
--- clang/test/Driver/msp430-toolchain.c
+++ clang/test/Driver/msp430-toolchain.c
@@ -66,11 +66,11 @@
 
 // Tests for -nostdlib, -nostartfiles, -nodefaultfiles and -f(no-)exceptions
 
-// RUN: %clang %s -### -no-canonical-prefixes -target msp430 \
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -rtlib=libgcc \
 // RUN:   --sysroot="%S/Inputs/basic_msp430_tree" > %t 2>&1
 // RUN: FileCheck -check-prefix=LIBS-DEFAULT-POS %s < %t
 // RUN: FileCheck -check-prefix=LIBS-DEFAULT-NEG %s < %t
-// RUN: %clang %s -### -no-canonical-prefixes -target msp430 \
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -rtlib=libgcc \
 // RUN:   --gcc-toolchain="%S/Inputs/basic_msp430_tree" --sysroot="" 2>&1 \
 // RUN:   | FileCheck -check-prefix=LIBS-DEFAULT-GCC-TOOLCHAIN %s
 // LIBS-DEFAULT-POS: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/../../..{{/|}}..{{/|}}bin{{/|}}msp430-elf-ld"
@@ -112,7 +112,7 @@
 // LIBS-COMPILER-RT-NEG-NOT: crtend.o
 // LIBS-COMPILER-RT-NEG-NOT: /exceptions
 
-// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -fexceptions \
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -rtlib=libgcc 
-fexceptions \
 // RUN:   --sysroot="%S/Inputs/basic_msp430_tree" > %t 2>&1
 // RUN: FileCheck -check-prefix=LIBS-EXC-POS %s < %t
 // RUN: FileCheck -check-prefix=LIBS-EXC-NEG %s < %t
@@ -126,7 +126,7 @@
 // LIBS-EXC-NEG-NOT: "{{.*}}/430"
 // LIBS-EXC-NEG-NOT: "{{.*}}430/crt{{.*}}"
 
-// RUN: %clang %s -### -no-canonical-prefixes -target msp430 \
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -rtlib=libgcc \
 // RUN:   -fstack-protector  --sysroot="%S/Inputs/basic_msp430_tree" 2>&1 \
 // RUN:   | FileCheck -check-prefix=LIBS-SSP %s
 // LIBS-SSP: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/../../..{{/|}}..{{/|}}bin{{/|}}msp430-elf-ld"
@@ -138,7 +138,7 @@
 // LIBS-SSP: "-lgcc" "--start-group" "-lmul_none" "-lc" "-lgcc" "-lcrt" 
"-lnosys" "--end-group"
 // LIBS-SSP: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430{{/|}}crtend_no_eh.o"
 "-lgcc"
 
-// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -nodefaultlibs \
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -rtlib=libgcc 
-nodefaultlibs \
 // RUN:   --sysroot="%S/Inputs/basic_msp430_tree" > %t 2>&1
 // RUN: FileCheck -check-prefix=LIBS-NO-DFT-POS %s < %t
 // RUN: FileCheck -check-prefix=LIBS-NO-DFT-NEG %s < %t
@@ -155,7 +155,7 @@
 // LIBS-NO-DFT-NEG-NOT: "--start-group"
 // LIBS-NO-DFT-NEG-NOT: "--end-group"
 
-// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -nolibc \
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -rtlib=libgcc 
-nolibc \
 // RUN:   -fstack-protector --sysroot="%S/Inputs/basic_msp430_tree" > %t 2>&1
 // RUN: FileCheck -check-prefix=LIBS-NO-LIBC-POS %s < %t
 // RUN: FileCheck -check-prefix=LIBS-NO-LIBC-NEG %s < %t
@@ -173,7 +173,7 @@
 // LIBS-NO-LIBC-NEG-NOT: "--start-group"
 // LIBS-NO-LIBC-NEG-NOT: "--end-group"
 
-// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -nostartfiles \
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -rtlib=libgcc 
-nostartfiles \
 // RUN:   --sysroot="%S/Inputs/basic_msp430_tree" > %t 2>&1
 // RUN: FileCheck -check-prefix=LIBS-NO-START-POS %s < %t
 // RUN: FileCheck -check-prefix=LIBS-NO-START-NEG %s < %t
@@ -222,7 +222,7 @@
 // Test for compiling for simulator
 
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430g2553 
\
-// RUN:   -msim --sysroot=%S/Inputs/basic_msp430_tree > %t 2>&1
+// RUN:   -msim -rtlib=libgcc --sysroot=%S/Inputs/basic_msp430_tree > %t 2>&1
 // RUN: FileCheck -check-prefix=SIMULATOR-POS %s < %t
 // RUN: FileCheck -check-prefix=SIMULATOR-NEG %s < %t
 // SIMULATOR-POS: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/../../..{{/|}}..{{/|}}bin{{/|}}msp430-elf-ld"


Index: clang/test/Driver/msp430-toolchain.c
===
--- clang/test/Driver/msp430-toolchain.c
+++ clang/test/Driver/msp430-toolchain.c
@@ -66,11 +66,11 @@
 
 // Tests for -nostdlib, -nostartfiles, -nodefaultfiles and -f(no-)exceptions
 
-// RUN: %clang %s -### -no-canonical-prefixes -target msp430 \
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -rtlib=libgcc \
 // RUN:   --sysroot="%S/Inputs/basic_msp430_tree" > %t 2>&1
 // RUN: FileCheck -check-prefix=LIBS-DEFAULT-POS %s < %t
 // RUN: FileCheck -check-prefix=LIBS-DEFAULT-NEG %s < %

[PATCH] D84058: Pass -rtlib=libgcc in tests conditioned on the default.

2020-07-17 Thread Stella Laurenzo via Phabricator via cfe-commits
stellaraccident updated this revision to Diff 278865.
stellaraccident added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84058

Files:
  clang/test/Driver/msp430-toolchain.c


Index: clang/test/Driver/msp430-toolchain.c
===
--- clang/test/Driver/msp430-toolchain.c
+++ clang/test/Driver/msp430-toolchain.c
@@ -66,11 +66,11 @@
 
 // Tests for -nostdlib, -nostartfiles, -nodefaultfiles and -f(no-)exceptions
 
-// RUN: %clang %s -### -no-canonical-prefixes -target msp430 \
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -rtlib=libgcc \
 // RUN:   --sysroot="%S/Inputs/basic_msp430_tree" > %t 2>&1
 // RUN: FileCheck -check-prefix=LIBS-DEFAULT-POS %s < %t
 // RUN: FileCheck -check-prefix=LIBS-DEFAULT-NEG %s < %t
-// RUN: %clang %s -### -no-canonical-prefixes -target msp430 \
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -rtlib=libgcc \
 // RUN:   --gcc-toolchain="%S/Inputs/basic_msp430_tree" --sysroot="" 2>&1 \
 // RUN:   | FileCheck -check-prefix=LIBS-DEFAULT-GCC-TOOLCHAIN %s
 // LIBS-DEFAULT-POS: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/../../..{{/|}}..{{/|}}bin{{/|}}msp430-elf-ld"
@@ -112,7 +112,7 @@
 // LIBS-COMPILER-RT-NEG-NOT: crtend.o
 // LIBS-COMPILER-RT-NEG-NOT: /exceptions
 
-// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -fexceptions \
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -rtlib=libgcc 
-fexceptions \
 // RUN:   --sysroot="%S/Inputs/basic_msp430_tree" > %t 2>&1
 // RUN: FileCheck -check-prefix=LIBS-EXC-POS %s < %t
 // RUN: FileCheck -check-prefix=LIBS-EXC-NEG %s < %t
@@ -126,7 +126,7 @@
 // LIBS-EXC-NEG-NOT: "{{.*}}/430"
 // LIBS-EXC-NEG-NOT: "{{.*}}430/crt{{.*}}"
 
-// RUN: %clang %s -### -no-canonical-prefixes -target msp430 \
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -rtlib=libgcc \
 // RUN:   -fstack-protector  --sysroot="%S/Inputs/basic_msp430_tree" 2>&1 \
 // RUN:   | FileCheck -check-prefix=LIBS-SSP %s
 // LIBS-SSP: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/../../..{{/|}}..{{/|}}bin{{/|}}msp430-elf-ld"
@@ -138,7 +138,7 @@
 // LIBS-SSP: "-lgcc" "--start-group" "-lmul_none" "-lc" "-lgcc" "-lcrt" 
"-lnosys" "--end-group"
 // LIBS-SSP: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430{{/|}}crtend_no_eh.o"
 "-lgcc"
 
-// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -nodefaultlibs \
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -rtlib=libgcc 
-nodefaultlibs \
 // RUN:   --sysroot="%S/Inputs/basic_msp430_tree" > %t 2>&1
 // RUN: FileCheck -check-prefix=LIBS-NO-DFT-POS %s < %t
 // RUN: FileCheck -check-prefix=LIBS-NO-DFT-NEG %s < %t
@@ -155,7 +155,7 @@
 // LIBS-NO-DFT-NEG-NOT: "--start-group"
 // LIBS-NO-DFT-NEG-NOT: "--end-group"
 
-// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -nolibc \
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -rtlib=libgcc 
-nolibc \
 // RUN:   -fstack-protector --sysroot="%S/Inputs/basic_msp430_tree" > %t 2>&1
 // RUN: FileCheck -check-prefix=LIBS-NO-LIBC-POS %s < %t
 // RUN: FileCheck -check-prefix=LIBS-NO-LIBC-NEG %s < %t
@@ -173,7 +173,7 @@
 // LIBS-NO-LIBC-NEG-NOT: "--start-group"
 // LIBS-NO-LIBC-NEG-NOT: "--end-group"
 
-// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -nostartfiles \
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -rtlib=libgcc 
-nostartfiles \
 // RUN:   --sysroot="%S/Inputs/basic_msp430_tree" > %t 2>&1
 // RUN: FileCheck -check-prefix=LIBS-NO-START-POS %s < %t
 // RUN: FileCheck -check-prefix=LIBS-NO-START-NEG %s < %t
@@ -222,7 +222,7 @@
 // Test for compiling for simulator
 
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430g2553 
\
-// RUN:   -msim --sysroot=%S/Inputs/basic_msp430_tree > %t 2>&1
+// RUN:   -msim -rtlib=libgcc --sysroot=%S/Inputs/basic_msp430_tree > %t 2>&1
 // RUN: FileCheck -check-prefix=SIMULATOR-POS %s < %t
 // RUN: FileCheck -check-prefix=SIMULATOR-NEG %s < %t
 // SIMULATOR-POS: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/../../..{{/|}}..{{/|}}bin{{/|}}msp430-elf-ld"


Index: clang/test/Driver/msp430-toolchain.c
===
--- clang/test/Driver/msp430-toolchain.c
+++ clang/test/Driver/msp430-toolchain.c
@@ -66,11 +66,11 @@
 
 // Tests for -nostdlib, -nostartfiles, -nodefaultfiles and -f(no-)exceptions
 
-// RUN: %clang %s -### -no-canonical-prefixes -target msp430 \
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -rtlib=libgcc \
 // RUN:   --sysroot="%S/Inputs/basic_msp430_tree" > %t 2>&1
 // RUN: FileCheck -check-prefix=LIBS-DEFAULT-POS %s < %t
 // RUN: FileCheck -check-prefix=LIBS-DEFAULT-NEG %s < %t
-// RUN: %clang %s -### -no-canonical-prefixes -target msp430 \
+// RUN: %clang %s -### -no-canon

[PATCH] D84058: Pass -rtlib=libgcc in tests conditioned on the default.

2020-07-17 Thread Eric Christopher via Phabricator via cfe-commits
echristo added a reviewer: saugustine.
echristo added a comment.

(Adding Sterling as well)
I think this will be an OK workaround for now, go ahead and reply on the main 
thread as I think they'll want to set the default runtime library as part of 
the toolchain. I'm surprised at this behavior as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84058



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


[PATCH] D81676: [MSP430] Align the toolchain definition with the TI's msp430-gcc v9.2.0

2020-07-17 Thread Stella Laurenzo via Phabricator via cfe-commits
stellaraccident added a comment.

The msp430-toolchain.c test was failing in our setup, and I've put together a 
fix in D84058 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81676



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


[PATCH] D84058: Pass -rtlib=libgcc in tests conditioned on the default.

2020-07-17 Thread Stella Laurenzo via Phabricator via cfe-commits
stellaraccident created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

- This test was failing in our builds that configure compiler-rt as the 
configure-time rtlib.
- Opted for this test fix instead of a rollback, and hopefully TI can fix 
forward if this weakens the tests beyond expectations.
- Suspected this failure introduced in D81676 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84058

Files:
  clang/test/Driver/msp430-toolchain.c


Index: clang/test/Driver/msp430-toolchain.c
===
--- clang/test/Driver/msp430-toolchain.c
+++ clang/test/Driver/msp430-toolchain.c
@@ -66,11 +66,11 @@
 
 // Tests for -nostdlib, -nostartfiles, -nodefaultfiles and -f(no-)exceptions
 
-// RUN: %clang %s -### -no-canonical-prefixes -target msp430 \
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -rtlib=libgcc \
 // RUN:   --sysroot="%S/Inputs/basic_msp430_tree" > %t 2>&1
 // RUN: FileCheck -check-prefix=LIBS-DEFAULT-POS %s < %t
 // RUN: FileCheck -check-prefix=LIBS-DEFAULT-NEG %s < %t
-// RUN: %clang %s -### -no-canonical-prefixes -target msp430 \
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -rtlib=libgcc \
 // RUN:   --gcc-toolchain="%S/Inputs/basic_msp430_tree" --sysroot="" 2>&1 \
 // RUN:   | FileCheck -check-prefix=LIBS-DEFAULT-GCC-TOOLCHAIN %s
 // LIBS-DEFAULT-POS: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/../../..{{/|}}..{{/|}}bin{{/|}}msp430-elf-ld"
@@ -112,7 +112,7 @@
 // LIBS-COMPILER-RT-NEG-NOT: crtend.o
 // LIBS-COMPILER-RT-NEG-NOT: /exceptions
 
-// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -fexceptions \
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -rtlib=libgcc 
-fexceptions \
 // RUN:   --sysroot="%S/Inputs/basic_msp430_tree" > %t 2>&1
 // RUN: FileCheck -check-prefix=LIBS-EXC-POS %s < %t
 // RUN: FileCheck -check-prefix=LIBS-EXC-NEG %s < %t
@@ -126,7 +126,7 @@
 // LIBS-EXC-NEG-NOT: "{{.*}}/430"
 // LIBS-EXC-NEG-NOT: "{{.*}}430/crt{{.*}}"
 
-// RUN: %clang %s -### -no-canonical-prefixes -target msp430 \
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -rtlib=libgcc \
 // RUN:   -fstack-protector  --sysroot="%S/Inputs/basic_msp430_tree" 2>&1 \
 // RUN:   | FileCheck -check-prefix=LIBS-SSP %s
 // LIBS-SSP: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/../../..{{/|}}..{{/|}}bin{{/|}}msp430-elf-ld"
@@ -138,7 +138,7 @@
 // LIBS-SSP: "-lgcc" "--start-group" "-lmul_none" "-lc" "-lgcc" "-lcrt" 
"-lnosys" "--end-group"
 // LIBS-SSP: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430{{/|}}crtend_no_eh.o"
 "-lgcc"
 
-// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -nodefaultlibs \
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -rtlib=libgcc 
-nodefaultlibs \
 // RUN:   --sysroot="%S/Inputs/basic_msp430_tree" > %t 2>&1
 // RUN: FileCheck -check-prefix=LIBS-NO-DFT-POS %s < %t
 // RUN: FileCheck -check-prefix=LIBS-NO-DFT-NEG %s < %t
@@ -155,7 +155,7 @@
 // LIBS-NO-DFT-NEG-NOT: "--start-group"
 // LIBS-NO-DFT-NEG-NOT: "--end-group"
 
-// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -nolibc \
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -rtlib=libgcc 
-nolibc \
 // RUN:   -fstack-protector --sysroot="%S/Inputs/basic_msp430_tree" > %t 2>&1
 // RUN: FileCheck -check-prefix=LIBS-NO-LIBC-POS %s < %t
 // RUN: FileCheck -check-prefix=LIBS-NO-LIBC-NEG %s < %t
@@ -173,7 +173,7 @@
 // LIBS-NO-LIBC-NEG-NOT: "--start-group"
 // LIBS-NO-LIBC-NEG-NOT: "--end-group"
 
-// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -nostartfiles \
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -rtlib=libgcc 
-nostartfiles \
 // RUN:   --sysroot="%S/Inputs/basic_msp430_tree" > %t 2>&1
 // RUN: FileCheck -check-prefix=LIBS-NO-START-POS %s < %t
 // RUN: FileCheck -check-prefix=LIBS-NO-START-NEG %s < %t
@@ -222,7 +222,7 @@
 // Test for compiling for simulator
 
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430g2553 
\
-// RUN:   -msim --sysroot=%S/Inputs/basic_msp430_tree > %t 2>&1
+// RUN:   -msim -rtlib=libgcc --sysroot=%S/Inputs/basic_msp430_tree > %t 2>&1
 // RUN: FileCheck -check-prefix=SIMULATOR-POS %s < %t
 // RUN: FileCheck -check-prefix=SIMULATOR-NEG %s < %t
 // SIMULATOR-POS: 
"{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/../../..{{/|}}..{{/|}}bin{{/|}}msp430-elf-ld"


Index: clang/test/Driver/msp430-toolchain.c
===
--- clang/test/Driver/msp430-toolchain.c
+++ clang/test/Driver/msp430-toolchain.c
@@ -66,11 +66,11 @@
 
 // Tests for -nostdlib, -nostartfiles, -nodefaultfiles and -f(no-)exceptions
 
-// RUN: %clang %s -### -no-canonical-prefixes -target msp430 \
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -rtlib=libgcc \
 // RUN:   --sysro

[PATCH] D83190: [analyzer] Model iterator random incrementation symmetrically

2020-07-17 Thread Endre Fülöp via Phabricator via cfe-commits
gamesh411 updated this revision to Diff 278853.
gamesh411 marked an inline comment as done.
gamesh411 added a comment.

apply review suggestions

- rename variables
- remove 1 assert
- rename tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83190

Files:
  clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
  clang/test/Analysis/iterator-modeling.cpp

Index: clang/test/Analysis/iterator-modeling.cpp
===
--- clang/test/Analysis/iterator-modeling.cpp
+++ clang/test/Analysis/iterator-modeling.cpp
@@ -149,7 +149,7 @@
   clang_analyzer_express(clang_analyzer_iterator_position(i2)); // expected-warning-re {{$v.end(){{$
 }
 
-void plus(const std::vector &v) {
+void plus_lhs(const std::vector &v) {
   auto i1 = v.begin();
 
   clang_analyzer_denote(clang_analyzer_container_begin(v), "$v.begin()");
@@ -161,7 +161,19 @@
   clang_analyzer_express(clang_analyzer_iterator_position(i2)); // expected-warning-re{{$v.begin() + 2{{$
 }
 
-void plus_negative(const std::vector &v) {
+void plus_rhs(const std::vector &v) {
+  auto i1 = v.begin();
+
+  clang_analyzer_denote(clang_analyzer_container_begin(v), "$v.begin()");
+
+  auto i2 = 2 + i1;
+
+  clang_analyzer_eval(clang_analyzer_iterator_container(i2) == &v); // expected-warning{{TRUE}}
+  clang_analyzer_express(clang_analyzer_iterator_position(i1)); // expected-warning-re{{$v.begin(){{$
+  clang_analyzer_express(clang_analyzer_iterator_position(i2)); // expected-warning-re{{$v.begin() + 2{{$
+}
+
+void plus_lhs_negative(const std::vector &v) {
   auto i1 = v.end();
 
   clang_analyzer_denote(clang_analyzer_container_end(v), "$v.end()");
@@ -173,6 +185,18 @@
   clang_analyzer_express(clang_analyzer_iterator_position(i2)); // expected-warning-re {{$v.end() - 2{{$
 }
 
+void plus_rhs_negative(const std::vector &v) {
+  auto i1 = v.end();
+
+  clang_analyzer_denote(clang_analyzer_container_end(v), "$v.end()");
+
+  auto i2 = (-2) + i1;
+
+  clang_analyzer_eval(clang_analyzer_iterator_container(i2) == &v); // expected-warning{{TRUE}}
+  clang_analyzer_express(clang_analyzer_iterator_position(i1)); // expected-warning-re {{$v.end(){{$
+  clang_analyzer_express(clang_analyzer_iterator_position(i2)); // expected-warning-re {{$v.end() - 2{{$
+}
+
 void minus(const std::vector &v) {
   auto i1 = v.end();
 
@@ -1955,7 +1979,7 @@
   i -= n; // no-crash
 }
 
-void plus_ptr_iterator(const cont_with_ptr_iterator &c) {
+void plus_lhs_ptr_iterator(const cont_with_ptr_iterator &c) {
   auto i1 = c.begin();
 
   clang_analyzer_denote(clang_analyzer_container_begin(c), "$c.begin()");
@@ -1967,6 +1991,18 @@
   clang_analyzer_express(clang_analyzer_iterator_position(i2)); // expected-warning{{$c.begin() + 2}}
 }
 
+void plus_rhs_ptr_iterator(const cont_with_ptr_iterator &c) {
+  auto i1 = c.begin();
+
+  clang_analyzer_denote(clang_analyzer_container_begin(c), "$c.begin()");
+
+  auto i2 = 2 + i1;
+
+  clang_analyzer_eval(clang_analyzer_iterator_container(i2) == &c); // expected-warning{{TRUE}}
+  clang_analyzer_express(clang_analyzer_iterator_position(i1)); // expected-warning{{$c.begin()}}
+  clang_analyzer_express(clang_analyzer_iterator_position(i2)); // expected-warning{{$c.begin() + 2}}
+}
+
 void minus_ptr_iterator(const cont_with_ptr_iterator &c) {
   auto i1 = c.end();
 
Index: clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
+++ clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
@@ -109,7 +109,7 @@
bool Postfix) const;
   void handleRandomIncrOrDecr(CheckerContext &C, const Expr *CE,
   OverloadedOperatorKind Op, const SVal &RetVal,
-  const SVal &LHS, const SVal &RHS) const;
+  const SVal &Iterator, const SVal &Amount) const;
   void handlePtrIncrOrDecr(CheckerContext &C, const Expr *Iterator,
OverloadedOperatorKind OK, SVal Offset) const;
   void handleAdvance(CheckerContext &C, const Expr *CE, SVal RetVal, SVal Iter,
@@ -262,20 +262,30 @@
 
 void IteratorModeling::checkPostStmt(const BinaryOperator *BO,
  CheckerContext &C) const {
-  ProgramStateRef State = C.getState();
-  BinaryOperatorKind OK = BO->getOpcode();
-  SVal RVal = State->getSVal(BO->getRHS(), C.getLocationContext());
+  const ProgramStateRef State = C.getState();
+  const BinaryOperatorKind OK = BO->getOpcode();
+  const Expr *const LHS = BO->getLHS();
+  const Expr *const RHS = BO->getRHS();
+  const SVal LVal = State->getSVal(LHS, C.getLocationContext());
+  const SVal RVal = State->getSVal(RHS, C.getLocationContext());
 
   if (isSimpleComparisonOperator(BO->getOpcode())) {
-SVal LVal = S

[PATCH] D83190: [analyzer] Model iterator random incrementation symmetrically

2020-07-17 Thread Endre Fülöp via Phabricator via cfe-commits
gamesh411 marked 6 inline comments as done.
gamesh411 added a comment.

Thanks for reviewing this patch this quickly!
I have updated the diff according to your suggestions, but I will not land it 
till I run a llvm+clang analysis with it.
Do you think non-ctu mode is enough to test the stability?




Comment at: clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp:400
+ "Either first or second argument should have structure "
+ "or class type!");
   handleRandomIncrOrDecr(C, OrigExpr, Op, Call.getReturnValue(),

baloghadamsoftware wrote:
> This is generally true in //C++// that overloaded operators must either be 
> class member or must have at least one class argument. Do we have to assert 
> it in this particular checker?
I think you are right, at second glance this assert seems confusing for someone 
reading the code for the first time and does not specifically belong to the 
logic of 'checking an overloaded increment or decrement operation'. Moreover, 
the special instance that is modelled as an iterator is not strictly tied to 
the type system (I mean there could be other things that we could model as 
iterators, not just structs or classes even beside pointer which are handled in 
another method of this modelling class).
All in all, I removed the assert.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83190



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


[PATCH] D83812: [clang][RelativeVTablesABI] Do not emit stubs for architectures that support a PLT relocation

2020-07-17 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/CodeGen/CGVTables.cpp:633
+  auto Arch = targetTriple.getArch();
+  if (Arch == llvm::Triple::aarch64 || Arch == llvm::Triple::x86_64)
+return false;

Could you add a method to TargetCodeGenInfo for this instead of hard-coding a 
list of architectures here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83812



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


[PATCH] D84032: [clang] Make clear Sema::CheckForConstantInitializer is for C-only codepath.

2020-07-17 Thread Haojian Wu via Phabricator via cfe-commits
hokein planned changes to this revision.
hokein marked an inline comment as done.
hokein added inline comments.



Comment at: clang/test/SemaCXX/compound-literal.cpp:92
 
-// This doesn't necessarily need to be an error, but CodeGen can't handle it
-// at the moment.
-int PR17415 = (int){PR17415}; // expected-error {{initializer element is not a 
compile-time constant}}
+int PR17415 = (int){PR17415}; // expected-warning {{variable 'PR17415' is 
uninitialized when used within its own initialization}}
 

hmm, clang will crash at CodeGen again if we turn off the `-Wuninitialized` 
warning.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84032



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


[PATCH] D83088: Introduce CfgTraits abstraction

2020-07-17 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: llvm/include/llvm/CodeGen/MachineCfgTraits.h:44
+// use on a 32-bit architecture.
+assert(wrapped != (uintptr_t)-1 && wrapped != (uintptr_t)-2);
+

I feel like there should be a better way to do this; we should probably have an 
assert where virtual registers are created



Comment at: llvm/include/llvm/CodeGen/MachineCfgTraits.h:101
+  return nullptr;
+return m_regInfo->getUniqueVRegDef(value)->getParent();
+  }

I think regular getVRegDef is preferable for SSA MIR


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83088



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


[PATCH] D83665: [OpenCL] Fixed missing address space for templated copy constructor

2020-07-17 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/lib/Sema/SemaTemplateDeduction.cpp:3811
+  if(S.getLangOpts().OpenCL)
+ArgType = S.deduceOpenCLPointeeAddrSpace(ArgType);
   ArgType = S.Context.getLValueReferenceType(ArgType);

I feel we can just add an address space explicitly since we are creating the 
type here for a known use case. However, does Arg actually have an address 
space? I am just unsure whether we should use generic address space or concrete 
address space.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83665



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


[PATCH] D83519: [NewPM] Support optnone under new pass manager

2020-07-17 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D83519#2144616 , @aeubanks wrote:

> In D83519#2144463 , @aeubanks wrote:
>
> > In D83519#2144403 , @ychen wrote:
> >
> > > High-level request: how about split this patch into two, the first for 
> > > the `require` pass part; the second for the PassInstrument callback. Then 
> > > we could discuss the choices of first patch and D82344 
> > > .
> >
> >
> > Good idea, will split the patch and take a closer look at your patch.
>
>
> I split the required passes part into https://reviews.llvm.org/D83575.


Could you remove the `Required` part of this patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83519



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


[PATCH] D76590: [Analyzer] Model `empty()` member function of containers

2020-07-17 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 278832.
baloghadamsoftware added a comment.

Rebased, updated.


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

https://reviews.llvm.org/D76590

Files:
  clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp
  clang/lib/StaticAnalyzer/Checkers/Iterator.cpp
  clang/lib/StaticAnalyzer/Checkers/Iterator.h
  clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
  clang/test/Analysis/Inputs/system-header-simulator-cxx.h
  clang/test/Analysis/container-modeling.cpp
  clang/test/Analysis/diagnostics/explicit-suppression.cpp

Index: clang/test/Analysis/diagnostics/explicit-suppression.cpp
===
--- clang/test/Analysis/diagnostics/explicit-suppression.cpp
+++ clang/test/Analysis/diagnostics/explicit-suppression.cpp
@@ -19,6 +19,6 @@
 void testCopyNull(C *I, C *E) {
   std::copy(I, E, (C *)0);
 #ifndef SUPPRESSED
-  // expected-warning@../Inputs/system-header-simulator-cxx.h:699 {{Called C++ object pointer is null}}
+  // expected-warning@../Inputs/system-header-simulator-cxx.h:707 {{Called C++ object pointer is null}}
 #endif
 }
Index: clang/test/Analysis/container-modeling.cpp
===
--- clang/test/Analysis/container-modeling.cpp
+++ clang/test/Analysis/container-modeling.cpp
@@ -16,6 +16,12 @@
 void clang_analyzer_eval(bool);
 void clang_analyzer_warnIfReached();
 
+extern void __assert_fail (__const char *__assertion, __const char *__file,
+unsigned int __line, __const char *__function)
+ __attribute__ ((__noreturn__));
+#define assert(expr) \
+  ((expr)  ? (void)(0)  : __assert_fail (#expr, __FILE__, __LINE__, __func__))
+
 void begin(const std::vector &V) {
   V.begin();
 
@@ -56,6 +62,40 @@
// expected-note@-1{{TRUE}}
 }
 
+
+///
+/// C O N T A I N E R   C A P A C I T Y
+///
+
+
+/// empty()
+
+void empty(const std::vector &V) {
+  for (auto n: V) {}
+  clang_analyzer_eval(clang_analyzer_container_begin(V) ==
+  clang_analyzer_container_end(V));
+  // expected-warning@-2{{TRUE}} expected-warning@-2{{FALSE}}
+  // expected-note@-3   {{TRUE}} expected-note@-3   {{FALSE}}
+}
+
+void non_empty1(const std::vector &V) {
+  assert(!V.empty()); // expected-note{{'?' condition is true}}
+  for (auto n: V) {}
+  clang_analyzer_eval(clang_analyzer_container_begin(V) ==
+  clang_analyzer_container_end(V));
+  // expected-warning@-2{{FALSE}}
+  // expected-note@-3   {{FALSE}}
+}
+
+void non_empty2(const std::vector &V) {
+  for (auto n: V) {}
+  assert(!V.empty()); // expected-note{{'?' condition is true}}
+  clang_analyzer_eval(clang_analyzer_container_begin(V) ==
+  clang_analyzer_container_end(V));
+  // expected-warning@-2{{FALSE}}
+  // expected-note@-3   {{FALSE}}
+}
+
 
 ///
 /// C O N T A I N E R   M O D I F I E R S
Index: clang/test/Analysis/Inputs/system-header-simulator-cxx.h
===
--- clang/test/Analysis/Inputs/system-header-simulator-cxx.h
+++ clang/test/Analysis/Inputs/system-header-simulator-cxx.h
@@ -334,6 +334,8 @@
 const T& front() const { return *begin(); }
 T& back() { return *(end() - 1); }
 const T& back() const { return *(end() - 1); }
+
+bool empty() const;
   };
   
   template
@@ -405,6 +407,8 @@
 const T& front() const { return *begin(); }
 T& back() { return *--end(); }
 const T& back() const { return *--end(); }
+
+bool empty() const;
   };
 
   template
@@ -486,6 +490,8 @@
 const T& front() const { return *begin(); }
 T& back() { return *(end() - 1); }
 const T& back() const { return *(end() - 1); }
+
+bool empty() const;
   };
 
   template
@@ -550,6 +556,8 @@
 
 T& front() { return *begin(); }
 const T& front() const { return *begin(); }
+
+bool empty() const;
   };
 
   template 
Index: clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
+++ clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
@@ -465,37 +465,24 @@
 State = State->BindExpr(CE, LCtx, RetVal);
   }
 
-  processComparison(C, State, LPos->getOffset(), RPos->getOffset(), RetVal, Op);
-}
+  if (const auto DefRetVal = RetVal.getAs()) {
+ProgramStateRef StateEqual, StateNonEqual;
+std::tie(StateEqual, StateNonEqual) =
+  assumeComparison(State, LPos->getOffset(), RPos->getOffset(), *DefRetVal,
+   Op);
 
-void IteratorModeling::processComparison(CheckerContext &C,
-  

[PATCH] D84021: [Driver] Add support for -msve-vector-bits=scalable.

2020-07-17 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen added a comment.

Still LGTM :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84021



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


[PATCH] D83717: [clang-tidy] Add check fo SEI CERT item ENV32-C

2020-07-17 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

In D83717#2155103 , @gamesh411 wrote:

> My thoughts exactly! I also thought about anchor-points as a feature in 
> file-check, as that would immensely increase the readability of the test-code 
> in such cases.


I've put in an RFC for that functionality, Think I CC'd you into it, if you 
have any comments about it I'd appreciate them.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83717



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


[PATCH] D84048: DR2303: Prefer 'nearer' base classes during template deduction.

2020-07-17 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 278825.
erichkeane added a comment.

Woops, left in a TODO from when I was planning on how to do this patch.  Should 
be ready now :)


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

https://reviews.llvm.org/D84048

Files:
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/test/CXX/drs/dr23xx.cpp


Index: clang/test/CXX/drs/dr23xx.cpp
===
--- clang/test/CXX/drs/dr23xx.cpp
+++ clang/test/CXX/drs/dr23xx.cpp
@@ -113,3 +113,26 @@
   extern template const int d;
 #endif
 }
+
+#if __cplusplus >= 201103L
+namespace dr2303 {
+template 
+struct A;
+template <>
+struct A<> {};
+template 
+struct A : A {};
+struct B : A {};
+
+template 
+void f(const A &);
+template 
+void f2(const A *);
+
+void g() {
+  f(B{}); // This is no longer ambiguous.
+  B b;
+  f2(&b);
+}
+} //namespace dr2303
+#endif
Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -1792,7 +1792,10 @@
   //   transformed A can be a derived class of the deduced A. Likewise if
   //   P is a pointer to a class of the form simple-template-id, the
   //   transformed A can be a pointer to a derived class pointed to by the
-  //   deduced A.
+  //   deduced A. However, if there is a class C that is a (direct or
+  //   indirect) base class of D and derived (directly or indirectly) from 
a
+  //   class B and that would be a valid deduced A, the deduced A cannot be
+  //   B or pointer to B, respectively.
   //
   //   These alternatives are considered only if type deduction would
   //   otherwise fail. If they yield more than one possible deduced A, the
@@ -1812,6 +1815,7 @@
   while (!ToVisit.empty()) {
 // Retrieve the next class in the inheritance hierarchy.
 const RecordType *NextT = ToVisit.pop_back_val();
+bool SkipBases = false;
 
 // If we have already seen this type, skip it.
 if (!Visited.insert(NextT).second)
@@ -1840,17 +1844,28 @@
 Info.Param = BaseInfo.Param;
 Info.FirstArg = BaseInfo.FirstArg;
 Info.SecondArg = BaseInfo.SecondArg;
+
+// In order to implement CWG2303 (added the following to p4b3):
+//   However, if there is a class C that is a (direct or indirect)
+//   base class of D and derived (directly or indirectly) from a
+//   class B and that would be a valid deduced A, the deduced A
+//   cannot be B or pointer to B, respectively.
+// We shouldn't visit the bases of a successful match ('C'), as 
they
+// could only be 'B' here.
+SkipBases = true;
   }
 
   Deduced = DeducedOrig;
 }
 
 // Visit base classes
-CXXRecordDecl *Next = cast(NextT->getDecl());
-for (const auto &Base : Next->bases()) {
-  assert(Base.getType()->isRecordType() &&
- "Base class that isn't a record?");
-  ToVisit.push_back(Base.getType()->getAs());
+if (!SkipBases) {
+  CXXRecordDecl *Next = cast(NextT->getDecl());
+  for (const auto &Base : Next->bases()) {
+assert(Base.getType()->isRecordType() &&
+   "Base class that isn't a record?");
+ToVisit.push_back(Base.getType()->getAs());
+  }
 }
   }
 


Index: clang/test/CXX/drs/dr23xx.cpp
===
--- clang/test/CXX/drs/dr23xx.cpp
+++ clang/test/CXX/drs/dr23xx.cpp
@@ -113,3 +113,26 @@
   extern template const int d;
 #endif
 }
+
+#if __cplusplus >= 201103L
+namespace dr2303 {
+template 
+struct A;
+template <>
+struct A<> {};
+template 
+struct A : A {};
+struct B : A {};
+
+template 
+void f(const A &);
+template 
+void f2(const A *);
+
+void g() {
+  f(B{}); // This is no longer ambiguous.
+  B b;
+  f2(&b);
+}
+} //namespace dr2303
+#endif
Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -1792,7 +1792,10 @@
   //   transformed A can be a derived class of the deduced A. Likewise if
   //   P is a pointer to a class of the form simple-template-id, the
   //   transformed A can be a pointer to a derived class pointed to by the
-  //   deduced A.
+  //   deduced A. However, if there is a class C that is a (direct or
+  //   indirect) base class of D and derived (directly or indirectly) from a
+  //   class B and that would be a valid deduced A, the deduced A cannot be
+  //   B or pointer to B, respectively.
   //
   //   These alternatives are considered only if type deduction would
   //   otherwise fail

[PATCH] D83788: Removed unused variable in clang

2020-07-17 Thread Aditya Kumar via Phabricator via cfe-commits
hiraditya accepted this revision.
hiraditya added a comment.

LGTM


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

https://reviews.llvm.org/D83788



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


[PATCH] D84048: DR2303: Prefer 'nearer' base classes during template deduction.

2020-07-17 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

I added @rsmith directly, since I suspect he's the most knowledgeable in 
SemaTemplateDeduction.cpp, but if anyone knows of someone else who is a good 
fit for this review, please add them as well!


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

https://reviews.llvm.org/D84048



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


[PATCH] D84048: DR2303: Prefer 'nearer' base classes during template deduction.

2020-07-17 Thread Erich Keane via Phabricator via cfe-commits
erichkeane created this revision.
erichkeane added reviewers: rsmith, rjmccall, aaron.ballman.

DR2303 fixes the case where the derived-base match for template
deduction is ambiguous if a base-of-base ALSO matches. The canonical
example (as shown in the test) is just like the MSVC implementation of
std::tuple.

This fixes a fairly sizable issue, where if a user inherits from
std::tuple on Windows (with the MS STL), they cannot use that type to
call a function that takes std::tuple.


https://reviews.llvm.org/D84048

Files:
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/test/CXX/drs/dr23xx.cpp


Index: clang/test/CXX/drs/dr23xx.cpp
===
--- clang/test/CXX/drs/dr23xx.cpp
+++ clang/test/CXX/drs/dr23xx.cpp
@@ -113,3 +113,26 @@
   extern template const int d;
 #endif
 }
+
+#if __cplusplus >= 201103L
+namespace dr2303 {
+template 
+struct A;
+template <>
+struct A<> {};
+template 
+struct A : A {};
+struct B : A {};
+
+template 
+void f(const A &);
+template 
+void f2(const A *);
+
+void g() {
+  f(B{}); // This is no longer ambiguous.
+  B b;
+  f2(&b);
+}
+} //namespace dr2303
+#endif
Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -1792,7 +1792,10 @@
   //   transformed A can be a derived class of the deduced A. Likewise if
   //   P is a pointer to a class of the form simple-template-id, the
   //   transformed A can be a pointer to a derived class pointed to by the
-  //   deduced A.
+  //   deduced A. However, if there is a class C that is a (direct or
+  //   indirect) base class of D and derived (directly or indirectly) from 
a
+  //   class B and that would be a valid deduced A, the deduced A cannot be
+  //   B or pointer to B, respectively.
   //
   //   These alternatives are considered only if type deduction would
   //   otherwise fail. If they yield more than one possible deduced A, the
@@ -1812,6 +1815,7 @@
   while (!ToVisit.empty()) {
 // Retrieve the next class in the inheritance hierarchy.
 const RecordType *NextT = ToVisit.pop_back_val();
+bool SkipBases = false;
 
 // If we have already seen this type, skip it.
 if (!Visited.insert(NextT).second)
@@ -1840,21 +1844,33 @@
 Info.Param = BaseInfo.Param;
 Info.FirstArg = BaseInfo.FirstArg;
 Info.SecondArg = BaseInfo.SecondArg;
+
+// In order to implement CWG2303 (added the following to p4b3):
+//   However, if there is a class C that is a (direct or indirect)
+//   base class of D and derived (directly or indirectly) from a
+//   class B and that would be a valid deduced A, the deduced A
+//   cannot be B or pointer to B, respectively.
+// We shouldn't visit the bases of a successful match ('C'), as 
they
+// could only be 'B' here.
+SkipBases = true;
   }
 
   Deduced = DeducedOrig;
 }
 
 // Visit base classes
-CXXRecordDecl *Next = cast(NextT->getDecl());
-for (const auto &Base : Next->bases()) {
-  assert(Base.getType()->isRecordType() &&
- "Base class that isn't a record?");
-  ToVisit.push_back(Base.getType()->getAs());
+if (!SkipBases) {
+  CXXRecordDecl *Next = cast(NextT->getDecl());
+  for (const auto &Base : Next->bases()) {
+assert(Base.getType()->isRecordType() &&
+   "Base class that isn't a record?");
+ToVisit.push_back(Base.getType()->getAs());
+  }
 }
   }
 
   if (Successful) {
+// TODO
 std::swap(SuccessfulDeduced, Deduced);
 return Sema::TDK_Success;
   }


Index: clang/test/CXX/drs/dr23xx.cpp
===
--- clang/test/CXX/drs/dr23xx.cpp
+++ clang/test/CXX/drs/dr23xx.cpp
@@ -113,3 +113,26 @@
   extern template const int d;
 #endif
 }
+
+#if __cplusplus >= 201103L
+namespace dr2303 {
+template 
+struct A;
+template <>
+struct A<> {};
+template 
+struct A : A {};
+struct B : A {};
+
+template 
+void f(const A &);
+template 
+void f2(const A *);
+
+void g() {
+  f(B{}); // This is no longer ambiguous.
+  B b;
+  f2(&b);
+}
+} //namespace dr2303
+#endif
Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -1792,7 +1792,10 @@
   //   transformed A can be a derived class of the deduced A. Likewise if
   //   P is a pointer to a class of the form simple-template-id, the
   //   transformed A can be a pointer to a derived class pointed to by the
-  //   deduced A.
+  //   de

[PATCH] D83190: [analyzer] Model iterator random incrementation symmetrically

2020-07-17 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware accepted this revision.
baloghadamsoftware added a comment.
This revision is now accepted and ready to land.

Looks good, aside from the few naming issues I mentioned. Please try it on 
//LLVM/Clang// before committing it to avoid unexpected crashes.




Comment at: clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp:112
   OverloadedOperatorKind Op, const SVal &RetVal,
-  const SVal &LHS, const SVal &RHS) const;
+  const SVal &Iterator, const SVal &Offset) const;
   void handlePtrIncrOrDecr(CheckerContext &C, const Expr *Iterator,

In my subsequent patches I began to use the name `Amount` instead of `Offset` 
to not confuse with `IteratorPosition::Offset`.



Comment at: clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp:281
+const Expr *const &IterExpr = IsIterOnLHS ? LHS : RHS;
+const Expr *const &OtherExpr = IsIterOnLHS ? RHS : LHS;
+

`AmountExpr`.



Comment at: clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp:385
+const QualType FstType = FstExpr->getType();
+const QualType SndType = SndExpr->getType();
+

`Expr1`, `Expr2`, `Type1`, `Type2` or something similar. `Fst` is to be 
confused with //Fast// and `Snd` with //Sound//. Or spell out `First` and 
`Second`.



Comment at: clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp:400
+ "Either first or second argument should have structure "
+ "or class type!");
   handleRandomIncrOrDecr(C, OrigExpr, Op, Call.getReturnValue(),

This is generally true in //C++// that overloaded operators must either be 
class member or must have at least one class argument. Do we have to assert it 
in this particular checker?



Comment at: clang/test/Analysis/iterator-modeling.cpp:152
 
-void plus(const std::vector &v) {
+void lhs_plus(const std::vector &v) {
   auto i1 = v.begin();

`plus_lhs`, `plus_rhs` to begin with the name of the operation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83190



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


[PATCH] D83621: [clang][Tooling] Try to avoid file system access if there is no record for the file in compile_commads.json

2020-07-17 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd19f0666bcd8: [clang][Tooling] Try to avoid file system 
access if there is no record for the… (authored by ArcsinX, committed by 
sammccall).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83621

Files:
  clang/lib/Tooling/FileMatchTrie.cpp
  clang/unittests/Tooling/CompilationDatabaseTest.cpp


Index: clang/unittests/Tooling/CompilationDatabaseTest.cpp
===
--- clang/unittests/Tooling/CompilationDatabaseTest.cpp
+++ clang/unittests/Tooling/CompilationDatabaseTest.cpp
@@ -281,6 +281,15 @@
   EXPECT_EQ("Cannot resolve relative paths", Error);
 }
 
+TEST_F(FileMatchTrieTest, SingleFile) {
+  Trie.insert("/root/RootFile.cc");
+  EXPECT_EQ("", find("/root/rootfile.cc"));
+  // Add subpath to avoid `if (Children.empty())` special case
+  // which we hit at previous `find()`.
+  Trie.insert("/root/otherpath/OtherFile.cc");
+  EXPECT_EQ("", find("/root/rootfile.cc"));
+}
+
 TEST(findCompileArgsInJsonDatabase, FindsNothingIfEmpty) {
   std::string ErrorMessage;
   CompileCommand NotFound = findCompileArgsInJsonDatabase(
Index: clang/lib/Tooling/FileMatchTrie.cpp
===
--- clang/lib/Tooling/FileMatchTrie.cpp
+++ clang/lib/Tooling/FileMatchTrie.cpp
@@ -105,8 +105,13 @@
StringRef FileName,
bool &IsAmbiguous,
unsigned ConsumedLength = 0) const {
+// Note: we support only directory symlinks for performance reasons.
 if (Children.empty()) {
-  if (Comparator.equivalent(StringRef(Path), FileName))
+  // As far as we do not support file symlinks, compare
+  // basenames here to avoid request to file system.
+  if (llvm::sys::path::filename(Path) ==
+  llvm::sys::path::filename(FileName) &&
+  Comparator.equivalent(StringRef(Path), FileName))
 return StringRef(Path);
   return {};
 }
@@ -121,6 +126,13 @@
   if (!Result.empty() || IsAmbiguous)
 return Result;
 }
+
+// If `ConsumedLength` is zero, this is the root and we have no filename
+// match. Give up in this case, we don't try to find symlinks with
+// different names.
+if (ConsumedLength == 0)
+  return {};
+
 std::vector AllChildren;
 getAll(AllChildren, MatchingChild);
 StringRef Result;


Index: clang/unittests/Tooling/CompilationDatabaseTest.cpp
===
--- clang/unittests/Tooling/CompilationDatabaseTest.cpp
+++ clang/unittests/Tooling/CompilationDatabaseTest.cpp
@@ -281,6 +281,15 @@
   EXPECT_EQ("Cannot resolve relative paths", Error);
 }
 
+TEST_F(FileMatchTrieTest, SingleFile) {
+  Trie.insert("/root/RootFile.cc");
+  EXPECT_EQ("", find("/root/rootfile.cc"));
+  // Add subpath to avoid `if (Children.empty())` special case
+  // which we hit at previous `find()`.
+  Trie.insert("/root/otherpath/OtherFile.cc");
+  EXPECT_EQ("", find("/root/rootfile.cc"));
+}
+
 TEST(findCompileArgsInJsonDatabase, FindsNothingIfEmpty) {
   std::string ErrorMessage;
   CompileCommand NotFound = findCompileArgsInJsonDatabase(
Index: clang/lib/Tooling/FileMatchTrie.cpp
===
--- clang/lib/Tooling/FileMatchTrie.cpp
+++ clang/lib/Tooling/FileMatchTrie.cpp
@@ -105,8 +105,13 @@
StringRef FileName,
bool &IsAmbiguous,
unsigned ConsumedLength = 0) const {
+// Note: we support only directory symlinks for performance reasons.
 if (Children.empty()) {
-  if (Comparator.equivalent(StringRef(Path), FileName))
+  // As far as we do not support file symlinks, compare
+  // basenames here to avoid request to file system.
+  if (llvm::sys::path::filename(Path) ==
+  llvm::sys::path::filename(FileName) &&
+  Comparator.equivalent(StringRef(Path), FileName))
 return StringRef(Path);
   return {};
 }
@@ -121,6 +126,13 @@
   if (!Result.empty() || IsAmbiguous)
 return Result;
 }
+
+// If `ConsumedLength` is zero, this is the root and we have no filename
+// match. Give up in this case, we don't try to find symlinks with
+// different names.
+if (ConsumedLength == 0)
+  return {};
+
 std::vector AllChildren;
 getAll(AllChildren, MatchingChild);
 StringRef Result;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] d19f066 - [clang][Tooling] Try to avoid file system access if there is no record for the file in compile_commads.json

2020-07-17 Thread Sam McCall via cfe-commits

Author: Aleksandr Platonov
Date: 2020-07-17T18:49:14+02:00
New Revision: d19f0666bcd8f7d26aaf4019244c3ed91e47b1b7

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

LOG: [clang][Tooling] Try to avoid file system access if there is no record for 
the file in compile_commads.json

Summary:
If there is no record in compile_commands.json, we try to find suitable record 
with `MatchTrie.findEquivalent()` call.
This is very expensive operation with a lot of `llvm::sys::fs::equivalent()` 
calls in some cases.

This patch disables file symlinks for performance reasons.

Example scenario without this patch:
- compile_commands.json generated at clangd build (contains ~3000 files).
- it tooks more than 1 second to get compile command for newly created file in 
the root folder of LLVM project.
- we wait for 1 second every time when clangd requests compile command for this 
file (at file change).

Reviewers: sammccall, kadircet, hokein

Reviewed By: sammccall

Subscribers: chandlerc, djasper, klimek, ilya-biryukov, kadircet, usaxena95, 
cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/lib/Tooling/FileMatchTrie.cpp
clang/unittests/Tooling/CompilationDatabaseTest.cpp

Removed: 




diff  --git a/clang/lib/Tooling/FileMatchTrie.cpp 
b/clang/lib/Tooling/FileMatchTrie.cpp
index 88dea6bb6c9f..3b02405da2f2 100644
--- a/clang/lib/Tooling/FileMatchTrie.cpp
+++ b/clang/lib/Tooling/FileMatchTrie.cpp
@@ -105,8 +105,13 @@ class FileMatchTrieNode {
StringRef FileName,
bool &IsAmbiguous,
unsigned ConsumedLength = 0) const {
+// Note: we support only directory symlinks for performance reasons.
 if (Children.empty()) {
-  if (Comparator.equivalent(StringRef(Path), FileName))
+  // As far as we do not support file symlinks, compare
+  // basenames here to avoid request to file system.
+  if (llvm::sys::path::filename(Path) ==
+  llvm::sys::path::filename(FileName) &&
+  Comparator.equivalent(StringRef(Path), FileName))
 return StringRef(Path);
   return {};
 }
@@ -121,6 +126,13 @@ class FileMatchTrieNode {
   if (!Result.empty() || IsAmbiguous)
 return Result;
 }
+
+// If `ConsumedLength` is zero, this is the root and we have no filename
+// match. Give up in this case, we don't try to find symlinks with
+// 
diff erent names.
+if (ConsumedLength == 0)
+  return {};
+
 std::vector AllChildren;
 getAll(AllChildren, MatchingChild);
 StringRef Result;

diff  --git a/clang/unittests/Tooling/CompilationDatabaseTest.cpp 
b/clang/unittests/Tooling/CompilationDatabaseTest.cpp
index cc948b800f4e..3bfb0ec1f7d5 100644
--- a/clang/unittests/Tooling/CompilationDatabaseTest.cpp
+++ b/clang/unittests/Tooling/CompilationDatabaseTest.cpp
@@ -281,6 +281,15 @@ TEST_F(FileMatchTrieTest, CannotResolveRelativePath) {
   EXPECT_EQ("Cannot resolve relative paths", Error);
 }
 
+TEST_F(FileMatchTrieTest, SingleFile) {
+  Trie.insert("/root/RootFile.cc");
+  EXPECT_EQ("", find("/root/rootfile.cc"));
+  // Add subpath to avoid `if (Children.empty())` special case
+  // which we hit at previous `find()`.
+  Trie.insert("/root/otherpath/OtherFile.cc");
+  EXPECT_EQ("", find("/root/rootfile.cc"));
+}
+
 TEST(findCompileArgsInJsonDatabase, FindsNothingIfEmpty) {
   std::string ErrorMessage;
   CompileCommand NotFound = findCompileArgsInJsonDatabase(



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


[PATCH] D83621: [clang][Tooling] Try to avoid file system access if there is no record for the file in compile_commads.json

2020-07-17 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D83621#2153711 , @ArcsinX wrote:

> As far as I do not have commit access, could you please commit for me?
>  Aleksandr Platonov 


Oops, missed this! Committed as d19f0666bcd8f7d26aaf4019244c3ed91e47b1b7 
 :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83621



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


[PATCH] D82756: Port some floating point options to new option marshalling infrastructure

2020-07-17 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/test/CodeGen/fp-function-attrs.cpp:2
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -ffast-math -ffinite-math-only 
-menable-unsafe-fp-math \
+// RUN:   -menable-no-infs -menable-no-nans -fno-signed-zeros 
-freciprocal-math \
+// RUN:   -fapprox-func -mreassociate -ffp-contract=fast -emit-llvm -o - %s | 
FileCheck %s

dang wrote:
> Anastasia wrote:
> > Not clear why do you need to pass these extra flags now?
> Previously passing -ffast-math to CC1 implied all these other flags. I am 
> trying to make CC1 option parsing as simple as possible, so that we can then 
> make it easy to generate a command line from a CompilerInvocation instance. 
> You can refer to [[ 
> http://lists.llvm.org/pipermail/cfe-dev/2020-May/065421.html | 
> http://lists.llvm.org/pipermail/cfe-dev/2020-May/065421.html ]] for more 
> details on why we want to be able to do this
Just to understand, there used to be implied flags and it made the manual 
command line use of clang more compact and easy... Is the idea now to change 
those compound flags such that individul flags always need to be passed?

Although I thought you are still adding the implicit flags:

  {options::OPT_cl_fast_relaxed_math,
   [&](const Arg *Arg) {
 RenderArg(Arg);

 CmdArgs.push_back(GetArgString(options::OPT_cl_mad_enable));
 CmdArgs.push_back(GetArgString(options::OPT_ffast_math));
 CmdArgs.push_back(GetArgString(options::OPT_ffinite_math_only));
 CmdArgs.push_back(
 GetArgString(options::OPT_menable_unsafe_fp_math));
 CmdArgs.push_back(GetArgString(options::OPT_mreassociate));
 CmdArgs.push_back(GetArgString(options::OPT_menable_no_nans));
 CmdArgs.push_back(
 GetArgString(options::OPT_menable_no_infinities));
 CmdArgs.push_back(GetArgString(options::OPT_fno_signed_zeros));
 CmdArgs.push_back(GetArgString(options::OPT_freciprocal_math));
 CmdArgs.push_back(GetArgString(options::OPT_fapprox_func));
   }}

Do I just misunderstand something?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82756



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


[PATCH] D83991: With MSVC, file needs to be compiled with /BIGOBJ

2020-07-17 Thread Adrian McCarthy via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG14dde438d69c: With MSVC, file needs to be compiled with 
/BIGOBJ (authored by amccarth).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83991

Files:
  clang/lib/ARCMigrate/CMakeLists.txt


Index: clang/lib/ARCMigrate/CMakeLists.txt
===
--- clang/lib/ARCMigrate/CMakeLists.txt
+++ clang/lib/ARCMigrate/CMakeLists.txt
@@ -2,6 +2,12 @@
   Support
   )
 
+# By default MSVC has a 2^16 limit on the number of sections in an object
+# file, and Transforms.cpp needs more than that.
+if (MSVC)
+  set_source_files_properties(Transforms.cpp PROPERTIES COMPILE_FLAGS /bigobj)
+endif()
+
 add_clang_library(clangARCMigrate
   ARCMT.cpp
   ARCMTActions.cpp


Index: clang/lib/ARCMigrate/CMakeLists.txt
===
--- clang/lib/ARCMigrate/CMakeLists.txt
+++ clang/lib/ARCMigrate/CMakeLists.txt
@@ -2,6 +2,12 @@
   Support
   )
 
+# By default MSVC has a 2^16 limit on the number of sections in an object
+# file, and Transforms.cpp needs more than that.
+if (MSVC)
+  set_source_files_properties(Transforms.cpp PROPERTIES COMPILE_FLAGS /bigobj)
+endif()
+
 add_clang_library(clangARCMigrate
   ARCMT.cpp
   ARCMTActions.cpp
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 14dde43 - With MSVC, file needs to be compiled with /BIGOBJ

2020-07-17 Thread Adrian McCarthy via cfe-commits

Author: Adrian McCarthy
Date: 2020-07-17T09:43:06-07:00
New Revision: 14dde438d69c81ab4651157a94d32ee804ff

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

LOG: With MSVC, file needs to be compiled with /BIGOBJ

MSVC, by default, limits the number of sections generated by a single
translation unit to 2^16.  In a debug build, each function or method
can require 4 sections, so it's not uncommon to hit it.

I saw the problem when building tests for LLDB (but, interestingly, not
for LLDB itself).

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

Added: 


Modified: 
clang/lib/ARCMigrate/CMakeLists.txt

Removed: 




diff  --git a/clang/lib/ARCMigrate/CMakeLists.txt 
b/clang/lib/ARCMigrate/CMakeLists.txt
index 6f19bea476da..1d5a185c3b6a 100644
--- a/clang/lib/ARCMigrate/CMakeLists.txt
+++ b/clang/lib/ARCMigrate/CMakeLists.txt
@@ -2,6 +2,12 @@ set(LLVM_LINK_COMPONENTS
   Support
   )
 
+# By default MSVC has a 2^16 limit on the number of sections in an object
+# file, and Transforms.cpp needs more than that.
+if (MSVC)
+  set_source_files_properties(Transforms.cpp PROPERTIES COMPILE_FLAGS /bigobj)
+endif()
+
 add_clang_library(clangARCMigrate
   ARCMT.cpp
   ARCMTActions.cpp



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


[PATCH] D83680: [clang-tidy] Refactor IncludeInserter

2020-07-17 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83680



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


[PATCH] D83149: [gcov] Add __gcov_dump/__gcov_reset and delete __gcov_flush

2020-07-17 Thread calixte via Phabricator via cfe-commits
calixte accepted this revision.
calixte added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83149



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


[PATCH] D83680: [clang-tidy] Refactor IncludeInserter

2020-07-17 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 278807.
njames93 marked 5 inline comments as done.
njames93 added a comment.

Address reviewer comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83680

Files:
  clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp
  clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.h
  clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.h
  
clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.h
  clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
  clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.h
  clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp
  clang-tools-extra/clang-tidy/modernize/PassByValueCheck.h
  clang-tools-extra/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp
  clang-tools-extra/clang-tidy/modernize/ReplaceAutoPtrCheck.h
  clang-tools-extra/clang-tidy/modernize/ReplaceRandomShuffleCheck.cpp
  clang-tools-extra/clang-tidy/modernize/ReplaceRandomShuffleCheck.h
  clang-tools-extra/clang-tidy/performance/MoveConstructorInitCheck.cpp
  clang-tools-extra/clang-tidy/performance/MoveConstructorInitCheck.h
  clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.cpp
  clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.h
  clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
  clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.h
  clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp
  clang-tools-extra/clang-tidy/utils/IncludeInserter.h
  clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
  clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.h
  clang-tools-extra/unittests/clang-tidy/IncludeInserterTest.cpp

Index: clang-tools-extra/unittests/clang-tidy/IncludeInserterTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/IncludeInserterTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/IncludeInserterTest.cpp
@@ -33,9 +33,7 @@
 
   void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
Preprocessor *ModuleExpanderPP) override {
-Inserter = std::make_unique(
-SM, getLangOpts(), utils::IncludeSorter::IS_Google);
-PP->addPPCallbacks(Inserter->CreatePPCallbacks());
+Inserter.registerPreprocessor(PP);
   }
 
   void registerMatchers(ast_matchers::MatchFinder *Finder) override {
@@ -46,15 +44,15 @@
 auto Diag = diag(Result.Nodes.getNodeAs("stmt")->getBeginLoc(),
  "foo, bar");
 for (StringRef Header : HeadersToInclude()) {
-  Diag << Inserter->CreateIncludeInsertion(
-  Result.SourceManager->getMainFileID(), Header, IsAngledInclude());
+  Diag << Inserter.createMainFileIncludeInsertion(Header,
+  IsAngledInclude());
 }
   }
 
   virtual std::vector HeadersToInclude() const = 0;
   virtual bool IsAngledInclude() const = 0;
 
-  std::unique_ptr Inserter;
+  utils::IncludeInserter Inserter{utils::IncludeSorter::IS_Google};
 };
 
 class NonSystemHeaderInserterCheck : public IncludeInserterCheckBase {
Index: clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.h
===
--- clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.h
+++ clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.h
@@ -70,8 +70,7 @@
 
 private:
   Optional Rule;
-  const IncludeSorter::IncludeStyle IncludeStyle;
-  std::unique_ptr Inserter;
+  IncludeInserter Inserter;
 };
 
 } // namespace utils
Index: clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
===
--- clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
+++ clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
@@ -32,8 +32,8 @@
 MakeRule,
 StringRef Name, ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context), Rule(MakeRule(getLangOpts(), Options)),
-  IncludeStyle(Options.getLocalOrGlobal("IncludeStyle",
-IncludeSorter::IS_LLVM)) {
+  Inserter(
+  Options.getLocalOrGlobal("IncludeStyle", IncludeSorter::IS_LLVM)) {
   if (Rule)
 assert(llvm::all_of(Rule->Cases, hasExplanation) &&
"clang-tidy checks must have an explanation by default;"
@@ -44,8 +44,8 @@
  StringRef Name,
  ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context), Rule(std::move(R)),
-  IncludeStyle(Options.getLocalOrGlobal("IncludeStyle",
-  

[PATCH] D84021: [Driver] Add suppoort for -msve-vector-bits=scalable.

2020-07-17 Thread Paul Walker via Phabricator via cfe-commits
paulwalker-arm updated this revision to Diff 278803.
paulwalker-arm added a comment.
Herald added a subscriber: dang.

Sorry for the post acceptance change, but I spotted the help text needed an 
update also.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84021

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Arch/AArch64.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/aarch64-sve-vector-bits.c

Index: clang/test/Driver/aarch64-sve-vector-bits.c
===
--- clang/test/Driver/aarch64-sve-vector-bits.c
+++ clang/test/Driver/aarch64-sve-vector-bits.c
@@ -12,12 +12,15 @@
 // RUN:  -msve-vector-bits=1024 2>&1 | FileCheck --check-prefix=CHECK-1024 %s
 // RUN: %clang -c %s -### -target aarch64-none-linux-gnu -march=armv8-a+sve \
 // RUN:  -msve-vector-bits=2048 2>&1 | FileCheck --check-prefix=CHECK-2048 %s
+// RUN: %clang -c %s -### -target aarch64-none-linux-gnu -march=armv8-a+sve \
+// RUN:  -msve-vector-bits=scalable 2>&1 | FileCheck --check-prefix=CHECK-SCALABLE %s
 
 // CHECK-128: "-msve-vector-bits=128"
 // CHECK-256: "-msve-vector-bits=256"
 // CHECK-512: "-msve-vector-bits=512"
 // CHECK-1024: "-msve-vector-bits=1024"
 // CHECK-2048: "-msve-vector-bits=2048"
+// CHECK-SCALABLE-NOT: "-msve-vector-bits=
 
 // Bail out if -msve-vector-bits is specified without SVE enabled
 // -
@@ -47,11 +50,13 @@
 // -
 // RUN: not %clang -c %s -o /dev/null -target aarch64-none-linux-gnu \
 // RUN:  -march=armv8-a+sve 2>&1 | FileCheck --check-prefix=CHECK-NO-FLAG-ERROR %s
+// RUN: not %clang -c %s -o /dev/null -target aarch64-none-linux-gnu \
+// RUN:  -march=armv8-a+sve -msve-vector-bits=scalable 2>&1 | FileCheck --check-prefix=CHECK-NO-FLAG-ERROR %s
 
 typedef __SVInt32_t svint32_t;
 typedef svint32_t noflag __attribute__((arm_sve_vector_bits(256)));
 
-// CHECK-NO-FLAG-ERROR: error: 'arm_sve_vector_bits' is not supported when '-msve-vector-bits=' is not specified
+// CHECK-NO-FLAG-ERROR: error: 'arm_sve_vector_bits' is only supported when '-msve-vector-bits=' is specified with a value of 128, 256, 512, 1024 or 2048
 
 // Error if attribute vector size != -msve-vector-bits
 // -
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -1720,15 +1720,15 @@
   if (Arg *A = Args.getLastArg(options::OPT_msve_vector_bits_EQ)) {
 StringRef Val = A->getValue();
 const Driver &D = getToolChain().getDriver();
-if (!Val.equals("128") && !Val.equals("256") && !Val.equals("512") &&
-!Val.equals("1024") && !Val.equals("2048")) {
+if (Val.equals("128") || Val.equals("256") || Val.equals("512") ||
+Val.equals("1024") || Val.equals("2048"))
+  CmdArgs.push_back(
+  Args.MakeArgString(llvm::Twine("-msve-vector-bits=") + Val));
+// Silently drop requests for vector-length agnostic code as it's implied.
+else if (!Val.equals("scalable"))
   // Handle the unsupported values passed to msve-vector-bits.
   D.Diag(diag::err_drv_unsupported_option_argument)
   << A->getOption().getName() << Val;
-} else if (A->getOption().matches(options::OPT_msve_vector_bits_EQ)) {
-  CmdArgs.push_back(
-  Args.MakeArgString(llvm::Twine("-msve-vector-bits=") + Val));
-}
   }
 }
 
Index: clang/lib/Driver/ToolChains/Arch/AArch64.cpp
===
--- clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -370,8 +370,8 @@
 V8_6Pos = Features.insert(std::next(V8_6Pos), {"+i8mm", "+bf16"});
 
   bool HasSve = llvm::is_contained(Features, "+sve");
-  // -msve_vector_bits= flag is valid only if SVE is enabled.
-  if (Arg *A = Args.getLastArg(options::OPT_msve_vector_bits_EQ))
+  // -msve-vector-bits= flag is valid only if SVE is enabled.
+  if (Args.hasArg(options::OPT_msve_vector_bits_EQ))
 if (!HasSve)
   D.Diag(diag::err_drv_invalid_sve_vector_bits);
 
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2346,8 +2346,9 @@
 
 def msve_vector_bits_EQ : Joined<["-"], "msve-vector-bits=">,
   Group, Flags<[DriverOption,CC1Option]>,
-  HelpText<"Set the size of fixed-length SVE vectors in bits.">,
-  Values<"128,256,512,1024,2048">;
+  HelpText<"Specify the size in bits of an SVE vector register. Defaults to the"
+   " vect

[PATCH] D72705: [analyzer] Added new checker 'alpha.unix.ErrorReturn'.

2020-07-17 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a comment.

The problem with `fgetc` is here that the returned value indicates not only if 
there was failure or not. In the following (over simplified) example no warning 
is needed even if there is no check for EOF. Because this case, for such kind 
of functions any comparison of the return value should be treated as an error 
check. Similar functions are the `strtol` family.

  c = fgetc(fd);
  if (c == 'a') {
// this is the expected input
  } else {
// any other value is handled as error
  }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72705



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


[PATCH] D83492: [OpenMP] Use common interface to access GPU Grid Values

2020-07-17 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert accepted this revision.
jdoerfert added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83492



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


[PATCH] D83492: [OpenMP] Use common interface to access GPU Grid Values

2020-07-17 Thread Saiyedul Islam via Phabricator via cfe-commits
saiislam updated this revision to Diff 278799.
saiislam added a comment.

Corrected.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83492

Files:
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp


Index: clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
@@ -20,6 +20,7 @@
 #include "clang/AST/StmtVisitor.h"
 #include "clang/Basic/Cuda.h"
 #include "llvm/ADT/SmallPtrSet.h"
+#include "llvm/Frontend/OpenMP/OMPGridValues.h"
 #include "llvm/IR/IntrinsicsNVPTX.h"
 
 using namespace clang;
@@ -195,11 +196,9 @@
 /// code.  For all practical purposes this is fine because the configuration
 /// is the same for all known NVPTX architectures.
 enum MachineConfiguration : unsigned {
-  WarpSize = 32,
-  /// Number of bits required to represent a lane identifier, which is
-  /// computed as log_2(WarpSize).
-  LaneIDBits = 5,
-  LaneIDMask = WarpSize - 1,
+  /// See "llvm/Frontend/OpenMP/OMPGridValues.h" for various related target
+  /// specific Grid Values like GV_Warp_Size, GV_Warp_Size_Log2,
+  /// and GV_Warp_Size_Log2_Mask.
 
   /// Global memory alignment for performance.
   GlobalMemoryAlignment = 128,
@@ -431,6 +430,7 @@
 assert(!GlobalizedRD &&
"Record for globalized variables is built already.");
 ArrayRef EscapedDeclsForParallel, EscapedDeclsForTeams;
+unsigned WarpSize = CGF.getTarget().getGridValue(llvm::omp::GV_Warp_Size);
 if (IsInTTDRegion)
   EscapedDeclsForTeams = EscapedDecls.getArrayRef();
 else
@@ -634,6 +634,8 @@
 /// on the NVPTX device, to generate more efficient code.
 static llvm::Value *getNVPTXWarpID(CodeGenFunction &CGF) {
   CGBuilderTy &Bld = CGF.Builder;
+  unsigned LaneIDBits =
+  CGF.getTarget().getGridValue(llvm::omp::GV_Warp_Size_Log2);
   return Bld.CreateAShr(getNVPTXThreadID(CGF), LaneIDBits, "nvptx_warp_id");
 }
 
@@ -642,6 +644,8 @@
 /// on the NVPTX device, to generate more efficient code.
 static llvm::Value *getNVPTXLaneID(CodeGenFunction &CGF) {
   CGBuilderTy &Bld = CGF.Builder;
+  unsigned LaneIDMask = CGF.getContext().getTargetInfo().getGridValue(
+  llvm::omp::GV_Warp_Size_Log2_Mask);
   return Bld.CreateAnd(getNVPTXThreadID(CGF), Bld.getInt32(LaneIDMask),
"nvptx_lane_id");
 }
@@ -2058,6 +2062,7 @@
   const RecordDecl *GlobalizedRD = nullptr;
   llvm::SmallVector LastPrivatesReductions;
   llvm::SmallDenseMap MappedDeclsFields;
+  unsigned WarpSize = CGM.getTarget().getGridValue(llvm::omp::GV_Warp_Size);
   // Globalize team reductions variable unconditionally in all modes.
   if (getExecutionMode() != CGOpenMPRuntimeGPU::EM_SPMD)
 getTeamsReductionVars(CGM.getContext(), D, LastPrivatesReductions);
@@ -3233,6 +3238,7 @@
   "__openmp_nvptx_data_transfer_temporary_storage";
   llvm::GlobalVariable *TransferMedium =
   M.getGlobalVariable(TransferMediumName);
+  unsigned WarpSize = CGF.getTarget().getGridValue(llvm::omp::GV_Warp_Size);
   if (!TransferMedium) {
 auto *Ty = llvm::ArrayType::get(CGM.Int32Ty, WarpSize);
 unsigned SharedAddressSpace = C.getTargetAddressSpace(LangAS::cuda_shared);


Index: clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
@@ -20,6 +20,7 @@
 #include "clang/AST/StmtVisitor.h"
 #include "clang/Basic/Cuda.h"
 #include "llvm/ADT/SmallPtrSet.h"
+#include "llvm/Frontend/OpenMP/OMPGridValues.h"
 #include "llvm/IR/IntrinsicsNVPTX.h"
 
 using namespace clang;
@@ -195,11 +196,9 @@
 /// code.  For all practical purposes this is fine because the configuration
 /// is the same for all known NVPTX architectures.
 enum MachineConfiguration : unsigned {
-  WarpSize = 32,
-  /// Number of bits required to represent a lane identifier, which is
-  /// computed as log_2(WarpSize).
-  LaneIDBits = 5,
-  LaneIDMask = WarpSize - 1,
+  /// See "llvm/Frontend/OpenMP/OMPGridValues.h" for various related target
+  /// specific Grid Values like GV_Warp_Size, GV_Warp_Size_Log2,
+  /// and GV_Warp_Size_Log2_Mask.
 
   /// Global memory alignment for performance.
   GlobalMemoryAlignment = 128,
@@ -431,6 +430,7 @@
 assert(!GlobalizedRD &&
"Record for globalized variables is built already.");
 ArrayRef EscapedDeclsForParallel, EscapedDeclsForTeams;
+unsigned WarpSize = CGF.getTarget().getGridValue(llvm::omp::GV_Warp_Size);
 if (IsInTTDRegion)
   EscapedDeclsForTeams = EscapedDecls.getArrayRef();
 else
@@ -634,6 +634,8 @@
 /// on the NVPTX device, to generate more efficient code.
 static llvm::Value *getNVPTXWarpID(CodeGenFunction &CGF) {
   CGBuilderTy &Bld = CGF.Builder;
+  unsigned LaneIDBits =
+  CGF.getTarget().getGridValue(llvm::omp::GV_Warp_Size_Log2);
   return Bld.CreateASh

[PATCH] D83901: [clang] Disable a few formatting options for test/

2020-07-17 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added a comment.

In D83901#2155127 , @MyDeveloperDay 
wrote:

> clang-format -n warnings before this change in clang/test/Analysis/*.cpp  
> (clang-format -n *.cpp |& grep warning | wc -l)
>
> before = 6903 vs  after=6595, if it helps I'd say this looks good. A very 
> brief review of changes seem to be mainly whitespace/extra lines and 
> indentation  (44 in headers files vs 43)
>  (Note: There are 11 warnings after the first iteration, clang-format 
> sometimes has to be run twice)
>
> The real proof is how many of the unit tests can be clang-formatted and still 
> pass, but I completely approve of this effort, if the test directories were 
> formatted this would give us a massive test suite of lots of different 
> examples of c++ code to validate any clang-format changes.
>
> If having this in the clang-format file means users can use "Format on Save" 
> options in their editors and not break tests then I think this is a good 
> thing. As this will drive good behavior in all the other files rather than 
> having to turn "Format on Save" off because we cannot maintain running tests.
>
> My 2 cents worth.


Thank you for your comment.

FWIW I think that the current approach with the lint bot needs to be changed 
for the following reasons:

1. `clang-format` lets me forget about formatting and for this I like it very 
much. This only works because running `clang-format` is almost always safe to 
run. ie: it doesn't change the meaning of the code. This breaks down with most 
tests in `test/` because the meaning of many test *is* changed by 
`clang-format`: ie: `clang-format` is very much *not* safe to run on a test.

2. Even after running `clang-format` on a test and fixing it manually, the bot 
will still complain in some cases if the formatting was done with a different 
version of `clang-format`. This has happened to me multiple times and for some 
reason always in a test. The bot should not complain if the formatting is fine 
in one of the previous n versions.

3. Tests are written in a different style optimised for conciseness. For 
example `struct S { S() = default; ~S() = delete; }; // not at all unusual in a 
test`. This could be accounted for in `.clang-format` but...

4. ...`clang-format-diff` does not respect (as far as I know?) the 
`.clang-format` in a sub-folder.

5. The lint bot is very noisy and makes reviews much harder because the 
formatting complaints are inline. Moving them out-of-line would be significant 
improvement.

I must admit I am very much tempted to put a generic `// clang-format off` in 
the tests I write.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83901



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


[PATCH] D83915: [PowerPC] Remove QPX/A2Q BGQ/BGP support

2020-07-17 Thread Jinsong Ji via Phabricator via cfe-commits
jsji added a comment.

In D83915#2156346 , @jsji wrote:

> In D83915#2155650 , 
> @hubert.reinterpretcast wrote:
>
> > Should we indicate planned removal in the Release Notes for version 11 and 
> > actual removal in those for version 12?
>
>
> Good suggestion. https://reviews.llvm.org/D83968 for adding the section in 
> master, will add conent in v11 branch if approved.


Notes added to ReleaseNotes in release/11.x in 
https://reviews.llvm.org/rG297be788a797c0ab98d9677f50e3dc57faab363b


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83915



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


[PATCH] D83822: [clangd] Support config over LSP.

2020-07-17 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

There are lots of choices and overlapping ideas for how the protocol should 
look, little urgency (it isn't going to make clangd 11), and few concrete use 
cases to evaluate the options.

Let's table this for now and let the ideas sink in and more use cases crop up. 
I definitely think we should have this, probably for clangd 12, but it's worth 
getting right.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83822



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


[PATCH] D83974: [AIX] report_fatal_error on `-fregister_global_dtors_with_atexit` for static init

2020-07-17 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast accepted this revision.
hubert.reinterpretcast added a comment.

LGTM; thanks.


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

https://reviews.llvm.org/D83974



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


[PATCH] D83492: [OpenMP] Use common interface to access GPU Grid Values

2020-07-17 Thread Saiyedul Islam via Phabricator via cfe-commits
saiislam updated this revision to Diff 278787.
saiislam added a comment.

Removed getNVPTXWarpSize() changes for a separate patch and rebased.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83492

Files:
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp


Index: clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
@@ -20,6 +20,7 @@
 #include "clang/AST/StmtVisitor.h"
 #include "clang/Basic/Cuda.h"
 #include "llvm/ADT/SmallPtrSet.h"
+#include "llvm/Frontend/OpenMP/OMPGridValues.h"
 #include "llvm/IR/IntrinsicsNVPTX.h"
 
 using namespace clang;
@@ -195,11 +196,9 @@
 /// code.  For all practical purposes this is fine because the configuration
 /// is the same for all known NVPTX architectures.
 enum MachineConfiguration : unsigned {
-  WarpSize = 32,
-  /// Number of bits required to represent a lane identifier, which is
-  /// computed as log_2(WarpSize).
-  LaneIDBits = 5,
-  LaneIDMask = WarpSize - 1,
+  /// See "llvm/Frontend/OpenMP/OMPGridValues.h" for various related target
+  /// specific Grid Values like GV_Warp_Size, GV_Warp_Size_Log2,
+  /// and GV_Warp_Size_Log2_Mask.
 
   /// Global memory alignment for performance.
   GlobalMemoryAlignment = 128,
@@ -431,6 +430,7 @@
 assert(!GlobalizedRD &&
"Record for globalized variables is built already.");
 ArrayRef EscapedDeclsForParallel, EscapedDeclsForTeams;
+unsigned WarpSize = CGF.getTarget().getGridValue(llvm::omp::GV_Warp_Size);
 if (IsInTTDRegion)
   EscapedDeclsForTeams = EscapedDecls.getArrayRef();
 else
@@ -634,6 +634,8 @@
 /// on the NVPTX device, to generate more efficient code.
 static llvm::Value *getNVPTXWarpID(CodeGenFunction &CGF) {
   CGBuilderTy &Bld = CGF.Builder;
+  unsigned LaneIDBits =
+  CGF.getTarget().getGridValue(llvm::omp::GV_Warp_Size_Log2);
   return Bld.CreateAShr(getNVPTXThreadID(CGF), LaneIDBits, "nvptx_warp_id");
 }
 
@@ -642,6 +644,8 @@
 /// on the NVPTX device, to generate more efficient code.
 static llvm::Value *getNVPTXLaneID(CodeGenFunction &CGF) {
   CGBuilderTy &Bld = CGF.Builder;
+  unsigned LaneIDMask = CGF.getContext().getTargetInfo().getGridValue(
+  llvm::omp::GV_Warp_Size_Log2_Mask);
   return Bld.CreateAnd(getNVPTXThreadID(CGF), Bld.getInt32(LaneIDMask),
"nvptx_lane_id");
 }


Index: clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
@@ -20,6 +20,7 @@
 #include "clang/AST/StmtVisitor.h"
 #include "clang/Basic/Cuda.h"
 #include "llvm/ADT/SmallPtrSet.h"
+#include "llvm/Frontend/OpenMP/OMPGridValues.h"
 #include "llvm/IR/IntrinsicsNVPTX.h"
 
 using namespace clang;
@@ -195,11 +196,9 @@
 /// code.  For all practical purposes this is fine because the configuration
 /// is the same for all known NVPTX architectures.
 enum MachineConfiguration : unsigned {
-  WarpSize = 32,
-  /// Number of bits required to represent a lane identifier, which is
-  /// computed as log_2(WarpSize).
-  LaneIDBits = 5,
-  LaneIDMask = WarpSize - 1,
+  /// See "llvm/Frontend/OpenMP/OMPGridValues.h" for various related target
+  /// specific Grid Values like GV_Warp_Size, GV_Warp_Size_Log2,
+  /// and GV_Warp_Size_Log2_Mask.
 
   /// Global memory alignment for performance.
   GlobalMemoryAlignment = 128,
@@ -431,6 +430,7 @@
 assert(!GlobalizedRD &&
"Record for globalized variables is built already.");
 ArrayRef EscapedDeclsForParallel, EscapedDeclsForTeams;
+unsigned WarpSize = CGF.getTarget().getGridValue(llvm::omp::GV_Warp_Size);
 if (IsInTTDRegion)
   EscapedDeclsForTeams = EscapedDecls.getArrayRef();
 else
@@ -634,6 +634,8 @@
 /// on the NVPTX device, to generate more efficient code.
 static llvm::Value *getNVPTXWarpID(CodeGenFunction &CGF) {
   CGBuilderTy &Bld = CGF.Builder;
+  unsigned LaneIDBits =
+  CGF.getTarget().getGridValue(llvm::omp::GV_Warp_Size_Log2);
   return Bld.CreateAShr(getNVPTXThreadID(CGF), LaneIDBits, "nvptx_warp_id");
 }
 
@@ -642,6 +644,8 @@
 /// on the NVPTX device, to generate more efficient code.
 static llvm::Value *getNVPTXLaneID(CodeGenFunction &CGF) {
   CGBuilderTy &Bld = CGF.Builder;
+  unsigned LaneIDMask = CGF.getContext().getTargetInfo().getGridValue(
+  llvm::omp::GV_Warp_Size_Log2_Mask);
   return Bld.CreateAnd(getNVPTXThreadID(CGF), Bld.getInt32(LaneIDMask),
"nvptx_lane_id");
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D83492: [OpenMP] Use common interface to access GPU Grid Values

2020-07-17 Thread Saiyedul Islam via Phabricator via cfe-commits
saiislam marked an inline comment as done.
saiislam added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:654
+  unsigned LaneIDBits =
+  CGF.getTarget().getGridValue(llvm::omp::GV_Warp_Size_Log2);
   return Bld.CreateAShr(getNVPTXThreadID(CGF), LaneIDBits, "nvptx_warp_id");

jdoerfert wrote:
> Why do we keep the enum value with this name then?
Enums in OMPGridValues.h has been named like this because many of the values 
are dependent on a different value in the same enum. For example, hardcoded 
value of number of bits required to represent the max number of threads in a 
warp (LaneIDBits here), is computed as log of WarpSize. Similarly, mask of this 
value (LaneIDMask below) is based on WarpSize. A future change in WarpSize thus 
will require update in all the enums based on (and prefixed as) WarpSize, so 
less chances of a manual error.

See this: 
https://github.com/llvm/llvm-project/blob/8b6821a5843bb321b3738e2519beae7142e62928/llvm/include/llvm/Frontend/OpenMP/OMPGridValues.h#L120


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83492



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


[PATCH] D84021: [Driver] Add suppoort for -msve-vector-bits=scalable.

2020-07-17 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen accepted this revision.
sdesmalen added a comment.
This revision is now accepted and ready to land.

nit: s/suppoort/support/ (in title)
LGTM otherwise!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84021



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


[PATCH] D83922: [OpenMP] Fix map clause for unused var: don't ignore it

2020-07-17 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny marked 3 inline comments as done.
jdenny added a comment.

Thanks for the review.  Will try to push soon.


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

https://reviews.llvm.org/D83922



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


[PATCH] D84032: [clang] Make clear Sema::CheckForConstantInitializer is for C-only codepath.

2020-07-17 Thread Haojian Wu via Phabricator via cfe-commits
hokein marked an inline comment as done.
hokein added inline comments.



Comment at: clang/lib/Sema/SemaDecl.cpp:11072
   // rules there don't matter.)
+  assert(!getLangOpts().CPlusPlus || getLangOpts().OpenCLCPlusPlus);
   const Expr *Culprit;

openCL for C++ is tricky, see 
https://github.com/llvm/llvm-project/blob/master/clang/lib/Sema/SemaDecl.cpp#L12134-L12135.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84032



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


  1   2   >