[PATCH] D71880: [clangd] Implement Decl canonicalization rules for rename

2020-11-12 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

don't dig into details, first round of comments.

I think the scope is a bit ambiguous, my reading is that it 1) removes old 
clang-rename API usage *and* 2) fixes some existing bugs. I would suggest just 
scoping it on 1).




Comment at: clang-tools-extra/clangd/refactor/Rename.cpp:251
+const NamedDecl *canonicalRenameDecl(const FieldDecl *D) {
+  // This is a hacky way to do something like
+  // CXXMethodDecl::getINstantiatedFromMemberFunction for the field because

yeah, this is quite tricky. I'd suggest to defer it to a separate patch. 

The behavior you described in https://github.com/clangd/clangd/issues/582 makes 
sense to me.

Another missing case is about static class members, they are `VarDecl` in the 
AST. 



Comment at: clang-tools-extra/clangd/refactor/Rename.cpp:283
+const auto *Definition = RD->getDefinition();
+Candidate = Definition ? Definition : RD->getMostRecentDecl();
+  }

I'm not sure the motivation of the change,  the same as line 244.



Comment at: clang-tools-extra/clangd/refactor/Rename.cpp:299
+  if (const auto *Field = dyn_cast(Candidate))
+return canonicalRenameDecl(Field);
+  return Candidate;

Looks like we're missing the `VarDecl` case (looks like a regression). I think 
we should probably add tests from 
https://github.com/llvm/llvm-project/commit/1e32df2f91f1aa1f8cd400ce50a621578fa0534e
 to clangd rename test.



Comment at: clang-tools-extra/clangd/refactor/Rename.cpp:300
+return canonicalRenameDecl(Field);
+  return Candidate;
+}

we're comparing Decl pointers to check whether they point to the same symbol, I 
think we should use `Candidate->getCanonicalDecl()` here.

thinking of a case, in the AST, we have two `Decl*`s, one points to the forward 
decl, the other one points to the definition. but they points to the same 
symbol.

```
class Foo; // forward decl, this is the canonical decl.

class Foo {
};
```




Comment at: clang-tools-extra/clangd/refactor/Rename.cpp:307
   trace::Span Tracer("FindOccurrencesWithinFile");
-  // If the cursor is at the underlying CXXRecordDecl of the
-  // ClassTemplateDecl, ND will be the CXXRecordDecl. In this case, we need to
-  // get the primary template manually.
-  // getUSRsForDeclaration will find other related symbols, e.g. virtual and 
its
-  // overriddens, primary template and all explicit specializations.
-  // FIXME: Get rid of the remaining tooling APIs.
-  const auto *RenameDecl =
-  ND.getDescribedTemplate() ? ND.getDescribedTemplate() : &ND;
-  std::vector RenameUSRs =
-  tooling::getUSRsForDeclaration(RenameDecl, AST.getASTContext());
-  llvm::DenseSet TargetIDs;
-  for (auto &USR : RenameUSRs)
-TargetIDs.insert(SymbolID(USR));
+  const auto *RenameDecl = canonicalRenameDecl(&ND);
 

since we call `canonicalRenameDecl` in `locateDeclAt`, I think `ND` is already 
canonical, right?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71880

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


[PATCH] D87981: [X86] AMX programming model prototype.

2020-11-12 Thread LuoYuanke via Phabricator via cfe-commits
LuoYuanke updated this revision to Diff 304736.
LuoYuanke added a comment.

Fix clang-tidy.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87981

Files:
  clang/include/clang/Basic/BuiltinsX86_64.def
  clang/lib/Headers/amxintrin.h
  clang/test/CodeGen/X86/amx_api.c
  llvm/include/llvm/CodeGen/LiveIntervalUnion.h
  llvm/include/llvm/CodeGen/LiveRegMatrix.h
  llvm/include/llvm/CodeGen/Passes.h
  llvm/include/llvm/CodeGen/TileShapeInfo.h
  llvm/include/llvm/CodeGen/VirtRegMap.h
  llvm/include/llvm/IR/Intrinsics.td
  llvm/include/llvm/IR/IntrinsicsX86.td
  llvm/lib/CodeGen/InlineSpiller.cpp
  llvm/lib/CodeGen/LiveIntervalUnion.cpp
  llvm/lib/CodeGen/LiveRegMatrix.cpp
  llvm/lib/CodeGen/VirtRegMap.cpp
  llvm/lib/Target/X86/CMakeLists.txt
  llvm/lib/Target/X86/X86.h
  llvm/lib/Target/X86/X86ExpandPseudo.cpp
  llvm/lib/Target/X86/X86FrameLowering.cpp
  llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/lib/Target/X86/X86InstrAMX.td
  llvm/lib/Target/X86/X86InstrInfo.cpp
  llvm/lib/Target/X86/X86LowerAMXType.cpp
  llvm/lib/Target/X86/X86PreTileConfig.cpp
  llvm/lib/Target/X86/X86RegisterInfo.cpp
  llvm/lib/Target/X86/X86RegisterInfo.h
  llvm/lib/Target/X86/X86RegisterInfo.td
  llvm/lib/Target/X86/X86Subtarget.h
  llvm/lib/Target/X86/X86TargetMachine.cpp
  llvm/lib/Target/X86/X86TileConfig.cpp
  llvm/test/CodeGen/X86/AMX/amx-across-func.ll
  llvm/test/CodeGen/X86/AMX/amx-config.ll
  llvm/test/CodeGen/X86/AMX/amx-spill.ll
  llvm/test/CodeGen/X86/AMX/amx-type.ll
  llvm/test/CodeGen/X86/O0-pipeline.ll
  llvm/test/CodeGen/X86/ipra-reg-usage.ll
  llvm/test/CodeGen/X86/opt-pipeline.ll
  llvm/test/CodeGen/X86/statepoint-fixup-invoke.mir
  llvm/test/CodeGen/X86/statepoint-fixup-shared-ehpad.mir

Index: llvm/test/CodeGen/X86/statepoint-fixup-shared-ehpad.mir
===
--- llvm/test/CodeGen/X86/statepoint-fixup-shared-ehpad.mir
+++ llvm/test/CodeGen/X86/statepoint-fixup-shared-ehpad.mir
@@ -108,7 +108,7 @@
   ; CHECK:   ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp
   ; CHECK:   MOV64mr [[STACK0:%stack.[0-9]+]], 1, $noreg, 0, $noreg, killed $rbx :: (store 8 into [[STACK0]])
   ; CHECK:   MOV64mr [[STACK1:%stack.[0-9]+]], 1, $noreg, 0, $noreg, killed $r14 :: (store 8 into [[STACK1]])
-  ; CHECK:   STATEPOINT 0, 0, 0, @foo, 2, 0, 2, 0, 2, 0, 2, 2, 1, 8, [[STACK0]], 0, 1, 8, [[STACK1]], 0, 2, 0, 2, 2, 0, 0, 1, 1, csr_64, implicit-def $rsp, implicit-def $ssp :: (load store 8 on [[STACK0]]), (load store 8 on [[STACK1]])
+  ; CHECK:   STATEPOINT 0, 0, 0, @foo, 2, 0, 2, 0, 2, 0, 2, 2, 1, 8, [[STACK0]], 0, 1, 8, [[STACK1]], 0, 2, 0, 2, 2, 0, 0, 1, 1, csr_64, implicit-def $rsp, implicit-def $ssp :: (load store 8 on [[STACK1]]), (load store 8 on [[STACK0]])
   ; CHECK-DAG:   $rbx = MOV64rm [[STACK0]], 1, $noreg, 0, $noreg :: (load 8 from [[STACK0]])
   ; CHECK-DAG:   $r14 = MOV64rm [[STACK1]], 1, $noreg, 0, $noreg :: (load 8 from [[STACK1]])
   ; CHECK:   ADJCALLSTACKUP64 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp
@@ -121,7 +121,7 @@
   ; CHECK:   ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp
   ; CHECK-DAG:   MOV64mr [[STACK0]], 1, $noreg, 0, $noreg, killed $rbx :: (store 8 into [[STACK0]])
   ; CHECK-DAG:   MOV64mr [[STACK1]], 1, $noreg, 0, $noreg, killed $r14 :: (store 8 into [[STACK1]])
-  ; CHECK:   STATEPOINT 0, 0, 0, @bar, 2, 0, 2, 0, 2, 0, 2, 2, 1, 8, %stack.0, 0, 1, 8, [[STACK1]], 0, 2, 0, 2, 2, 0, 0, 1, 1, csr_64, implicit-def $rsp, implicit-def $ssp :: (load store 8 on [[STACK0]]), (load store 8 on [[STACK1]])
+  ; CHECK:   STATEPOINT 0, 0, 0, @bar, 2, 0, 2, 0, 2, 0, 2, 2, 1, 8, %stack.0, 0, 1, 8, [[STACK1]], 0, 2, 0, 2, 2, 0, 0, 1, 1, csr_64, implicit-def $rsp, implicit-def $ssp :: (load store 8 on [[STACK1]]), (load store 8 on [[STACK0]])
   ; CHECK-DAG:   $rbx = MOV64rm [[STACK0]], 1, $noreg, 0, $noreg :: (load 8 from [[STACK0]])
   ; CHECK-DAG:   $r14 = MOV64rm [[STACK1]], 1, $noreg, 0, $noreg :: (load 8 from [[STACK1]])
   ; CHECK:   ADJCALLSTACKUP64 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp
Index: llvm/test/CodeGen/X86/statepoint-fixup-invoke.mir
===
--- llvm/test/CodeGen/X86/statepoint-fixup-invoke.mir
+++ llvm/test/CodeGen/X86/statepoint-fixup-invoke.mir
@@ -91,7 +91,7 @@
   ; CHECK-DAG:   MOV64mr %stack.1, 1, $noreg, 0, $noreg, $rdi :: (store 8 into %stack.1)
   ; CHECK:   EH_LABEL 
   ; CHECK:   ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp
-  ; CHECK:   STATEPOINT 0, 0, 1, @some_call, 

[PATCH] D88987: [FPEnv][Clang][Driver] Use MarshallingInfoFlag for -fexperimental-strict-floating-point

2020-11-12 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 accepted this revision.
jansvoboda11 added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D88987

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


[PATCH] D89909: [SYCL] Implement SYCL address space attributes handling

2020-11-12 Thread Sergey Dmitriev via Phabricator via cfe-commits
sdmitriev added inline comments.



Comment at: clang/lib/CodeGen/CGExpr.cpp:4554
+
+  // Language rules define if it is legal to cast from one address space
+  // to another, and which address space we should use as a "common

bader wrote:
> Anastasia wrote:
> > What language rules?
> I suppose it's a generic note and author didn't meant some particular 
> language here. This change was contributed by @sdmitriev. 
> @sdmitriev, could you clarify, please?
This comment was originally added by @asavonic to 
clang/lib/CodeGen/CGExprScalar.cpp (lines 2962-2965 in this patch), and later I 
reused his code along with the comment in this file while fixing a very similar 
issue. So, I guess it would be more correct to ask Andrew to clarify. 
@asavonic, can you please comment on this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89909

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


[PATCH] D91327: [NewPM] Redesign of PreserveCFG Checker

2020-11-12 Thread Yevgeny Rouban via Phabricator via cfe-commits
yrouban created this revision.
yrouban added reviewers: skatkov, kuhar, asbirlea, fedor.sergeev.
Herald added subscribers: cfe-commits, wenlei, steven_wu, hiraditya.
Herald added projects: clang, LLVM.
yrouban requested review of this revision.

Please see the reason for this redesign in the patch D91324 
.
Basically the checker introduces an internal custom CFG analysis that tracks 
current up-to date CFG snapshot. The analysis is invalidated along with any 
other CFG related analysis (the key is //CFGAnalyses//). If the CFG analysis is 
not invalidated at a functional pass exit then the checker asserts that the CFG 
snapshot taken from this analysis is equals to a snapshot of the current CFG.

Along the way:

- the function //CFG::printDiff()// is simplified by removing function name 
calculation. The name is printed by the caller;
- fixed CFG invalidated condition (see //CFG::invalidate()//);
- //StandardInstrumentations::registerCallbacks()// gets additional optional 
parameter of type //FunctionAnalysisManager*//, which is needed by the checker 
to get the custom CFG analysis;
- several PM related tests updated to ignore lines related to running the 
custom CFG analysis.

This patch is safe to land as the CFGChecker is left switched off (the options 
//-verify-cfg-preserved// is false by default). It will be switched on by a 
separate patch to minimize possible reverts.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91327

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  llvm/include/llvm/Passes/StandardInstrumentations.h
  llvm/lib/LTO/LTOBackend.cpp
  llvm/lib/Passes/StandardInstrumentations.cpp
  llvm/test/Other/loop-pm-invalidation.ll
  llvm/test/Other/new-pass-manager.ll
  llvm/test/Other/new-pm-defaults.ll
  llvm/test/Other/new-pm-lto-defaults.ll
  llvm/test/Other/new-pm-thinlto-defaults.ll
  llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
  llvm/test/Transforms/LoopRotate/pr35210.ll
  llvm/test/Transforms/SCCP/ipsccp-preserve-analysis.ll
  llvm/tools/opt/NewPMDriver.cpp
  llvm/unittests/IR/PassManagerTest.cpp

Index: llvm/unittests/IR/PassManagerTest.cpp
===
--- llvm/unittests/IR/PassManagerTest.cpp
+++ llvm/unittests/IR/PassManagerTest.cpp
@@ -826,7 +826,7 @@
   FunctionPassManager FPM(/*DebugLogging*/ true);
   PassInstrumentationCallbacks PIC;
   StandardInstrumentations SI(/*DebugLogging*/ true);
-  SI.registerCallbacks(PIC);
+  SI.registerCallbacks(PIC, &FAM);
   FAM.registerPass([&] { return PassInstrumentationAnalysis(&PIC); });
   FAM.registerPass([&] { return AssumptionAnalysis(); });
   FAM.registerPass([&] { return TargetIRAnalysis(); });
@@ -871,7 +871,7 @@
   FunctionPassManager FPM(/*DebugLogging*/ true);
   PassInstrumentationCallbacks PIC;
   StandardInstrumentations SI(/*DebugLogging*/ true);
-  SI.registerCallbacks(PIC);
+  SI.registerCallbacks(PIC, &FAM);
   FAM.registerPass([&] { return PassInstrumentationAnalysis(&PIC); });
   FAM.registerPass([&] { return AssumptionAnalysis(); });
   FAM.registerPass([&] { return TargetIRAnalysis(); });
@@ -935,7 +935,7 @@
   FunctionPassManager FPM(/*DebugLogging*/ true);
   PassInstrumentationCallbacks PIC;
   StandardInstrumentations SI(/*DebugLogging*/ true);
-  SI.registerCallbacks(PIC);
+  SI.registerCallbacks(PIC, &FAM);
   FAM.registerPass([&] { return PassInstrumentationAnalysis(&PIC); });
   FAM.registerPass([&] { return AssumptionAnalysis(); });
   FAM.registerPass([&] { return TargetIRAnalysis(); });
Index: llvm/tools/opt/NewPMDriver.cpp
===
--- llvm/tools/opt/NewPMDriver.cpp
+++ llvm/tools/opt/NewPMDriver.cpp
@@ -258,8 +258,6 @@
 }
   }
   PassInstrumentationCallbacks PIC;
-  StandardInstrumentations SI(DebugPM, VerifyEachPass);
-  SI.registerCallbacks(PIC);
   DebugifyEachInstrumentation Debugify;
   if (DebugifyEach)
 Debugify.registerCallbacks(PIC);
@@ -360,6 +358,9 @@
   CGSCCAnalysisManager CGAM(DebugPM);
   ModuleAnalysisManager MAM(DebugPM);
 
+  StandardInstrumentations SI(DebugPM, VerifyEachPass);
+  SI.registerCallbacks(PIC, &FAM);
+
   // Register the AA manager first so that our version is the one used.
   FAM.registerPass([&] { return std::move(AA); });
   // Register our TargetLibraryInfoImpl.
Index: llvm/test/Transforms/SCCP/ipsccp-preserve-analysis.ll
===
--- llvm/test/Transforms/SCCP/ipsccp-preserve-analysis.ll
+++ llvm/test/Transforms/SCCP/ipsccp-preserve-analysis.ll
@@ -16,7 +16,7 @@
 ; NEW-PM: Running pass: IPSCCPPass
 ; NEW-PM-DAG: Running analysis: AssumptionAnalysis on f1
 ; NEW-PM-DAG: Running analysis: AssumptionAnalysis on f2
-; NEW-PM-NOT: Running analysis:
+; NEW-PM-NOT: Running analysis: AssumptionAnalysis
 
 ; IR-LABEL: @f1
 ;

[clang-tools-extra] 6484aa1 - [clangd] Simplify relations deserialization loop, NFC.

2020-11-12 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2020-11-12T10:33:39+01:00
New Revision: 6484aa1add41e6483b60ad281b663968c2b68180

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

LOG: [clangd] Simplify relations deserialization loop, NFC.

Added: 


Modified: 
clang-tools-extra/clangd/index/Serialization.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/index/Serialization.cpp 
b/clang-tools-extra/clangd/index/Serialization.cpp
index a817758d7a54..0b82224fa715 100644
--- a/clang-tools-extra/clangd/index/Serialization.cpp
+++ b/clang-tools-extra/clangd/index/Serialization.cpp
@@ -508,10 +508,8 @@ llvm::Expected readRIFF(llvm::StringRef Data) 
{
   if (Chunks.count("rela")) {
 Reader RelationsReader(Chunks.lookup("rela"));
 RelationSlab::Builder Relations;
-while (!RelationsReader.eof()) {
-  auto Relation = readRelation(RelationsReader);
-  Relations.insert(Relation);
-}
+while (!RelationsReader.eof())
+  Relations.insert(readRelation(RelationsReader));
 if (RelationsReader.err())
   return error("malformed or truncated relations");
 Result.Relations = std::move(Relations).build();



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


[PATCH] D91330: [clangd] Ensure we test for compatibility of serialized index format

2020-11-12 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: cfe-commits, wenlei, usaxena95, arphaman.
Herald added a project: clang.
kadircet requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91330

Files:
  clang-tools-extra/clangd/test/index-serialization/Inputs/sample.cpp
  clang-tools-extra/clangd/test/index-serialization/Inputs/sample.h
  clang-tools-extra/clangd/test/index-serialization/Inputs/sample.idx
  clang-tools-extra/clangd/test/index-serialization/version-is-correct.test


Index: clang-tools-extra/clangd/test/index-serialization/version-is-correct.test
===
--- /dev/null
+++ clang-tools-extra/clangd/test/index-serialization/version-is-correct.test
@@ -0,0 +1,11 @@
+# If this test fails it means there has been a backward incompatilbe change to
+# serialization format. Please bump the version number in
+# clang-tools-extra/clangd/index/Serialization.cpp and regenarate the 
sample.idx
+# with
+# clangd-indexer \
+# clang-tools-extra/clangd/test/index-serialization/Inputs/sample.cpp > \
+# clang-tools-extra/clangd/test/index-serialization/Inputs/sample.idx
+# Also if you've introduced new slabs/chunks to serialized index, make sure
+# indexing sample.cpp would yield non-trivial values for those.
+# RUN: dexp %/S/Inputs/sample.idx
+
Index: clang-tools-extra/clangd/test/index-serialization/Inputs/sample.h
===
--- /dev/null
+++ clang-tools-extra/clangd/test/index-serialization/Inputs/sample.h
@@ -0,0 +1,4 @@
+#pragma once
+
+// Introduce a symbol.
+struct Foo {};
Index: clang-tools-extra/clangd/test/index-serialization/Inputs/sample.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/test/index-serialization/Inputs/sample.cpp
@@ -0,0 +1,5 @@
+// Include a file to ensure we have multiple sources.
+#include "sample.h"
+
+// This introduces a symbol, a reference and a relation.
+struct Bar : public Foo {};


Index: clang-tools-extra/clangd/test/index-serialization/version-is-correct.test
===
--- /dev/null
+++ clang-tools-extra/clangd/test/index-serialization/version-is-correct.test
@@ -0,0 +1,11 @@
+# If this test fails it means there has been a backward incompatilbe change to
+# serialization format. Please bump the version number in
+# clang-tools-extra/clangd/index/Serialization.cpp and regenarate the sample.idx
+# with
+# clangd-indexer \
+# clang-tools-extra/clangd/test/index-serialization/Inputs/sample.cpp > \
+# clang-tools-extra/clangd/test/index-serialization/Inputs/sample.idx
+# Also if you've introduced new slabs/chunks to serialized index, make sure
+# indexing sample.cpp would yield non-trivial values for those.
+# RUN: dexp %/S/Inputs/sample.idx
+
Index: clang-tools-extra/clangd/test/index-serialization/Inputs/sample.h
===
--- /dev/null
+++ clang-tools-extra/clangd/test/index-serialization/Inputs/sample.h
@@ -0,0 +1,4 @@
+#pragma once
+
+// Introduce a symbol.
+struct Foo {};
Index: clang-tools-extra/clangd/test/index-serialization/Inputs/sample.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/test/index-serialization/Inputs/sample.cpp
@@ -0,0 +1,5 @@
+// Include a file to ensure we have multiple sources.
+#include "sample.h"
+
+// This introduces a symbol, a reference and a relation.
+struct Bar : public Foo {};
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91330: [clangd] Ensure we test for compatibility of serialized index format

2020-11-12 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

As a side note, I've tested with a clangd-indexer before 
https://github.com/llvm/llvm-project/commit/71064b02701dd65065dd412fb01afe81ff83f746
 and we got the failure (malformed/truncated refs).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91330

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


[PATCH] D87981: [X86] AMX programming model prototype.

2020-11-12 Thread LuoYuanke via Phabricator via cfe-commits
LuoYuanke added inline comments.



Comment at: llvm/test/CodeGen/X86/statepoint-fixup-invoke.mir:94
   ; CHECK:   ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp, implicit-def 
dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp
-  ; CHECK:   STATEPOINT 0, 0, 1, @some_call, $rdi, 2, 0, 2, 0, 2, 5, 2, 0, 2, 
-1, 2, 0, 2, 0, 2, 0, 2, 2, 1, 8, %stack.0, 0, 1, 8, %stack.1, 0, 2, 0, 2, 2, 
0, 0, 1, 1, csr_64, implicit-def $rsp, implicit-def $ssp :: (load store 8 on 
%stack.1), (load store 8 on %stack.0)
+  ; CHECK:   STATEPOINT 0, 0, 1, @some_call, $rdi, 2, 0, 2, 0, 2, 5, 2, 0, 2, 
-1, 2, 0, 2, 0, 2, 0, 2, 2, 1, 8, %stack.0, 0, 1, 8, %stack.1, 0, 2, 0, 2, 2, 
0, 0, 1, 1, csr_64, implicit-def $rsp, implicit-def $ssp :: (load store 8 on 
%stack.0), (load store 8 on %stack.1)
   ; CHECK-DAG:   $r14 = MOV64rm %stack.0, 1, $noreg, 0, $noreg :: (load 8 from 
%stack.0)

LuoYuanke wrote:
> pengfei wrote:
> > Is the different caused by the order change of MachineDominator Tree 
> > Construction?
> It seems the test case doesn't ensure the order. I'll take more time to look 
> into the case.
This is spilled stack slot. The order is sorted by register size. Since the 
register size of r14 and rbx is the same, so the order is undefined. llvm::sort 
call std::sort and std::sort doesn't preserve the order of the equivalent 
elements.  
(https://stackoverflow.com/questions/4107315/stdsort-behavior-with-ints-that-are-equal)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87981

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


[PATCH] D91333: [clang][SveEmitter] Fix enum declarations. [NFCI]

2020-11-12 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli created this revision.
fpetrogalli added reviewers: peterwaller-arm, paulwalker-arm, joechrisellis, 
efriedma.
Herald added subscribers: cfe-commits, kristof.beyls, tschuett.
Herald added a reviewer: rengolin.
Herald added a project: clang.
fpetrogalli requested review of this revision.

Adapt the declarations of `svpattern` and `svprfop` to the most recent
one defined in section "5. Enum declarations" of the SVE ACLE
specifications [1].

The signature of the intrinsics using these enums have been changed
accordingly.

A test has been added to make sure that `svpattern` and `svprfop` are
not typedefs.

[1] https://developer.arm.com/documentation/100987/latest, version
00bet6


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91333

Files:
  clang/test/Sema/aarch64-sve-enums.c
  clang/utils/TableGen/SveEmitter.cpp


Index: clang/utils/TableGen/SveEmitter.cpp
===
--- clang/utils/TableGen/SveEmitter.cpp
+++ clang/utils/TableGen/SveEmitter.cpp
@@ -416,10 +416,10 @@
 
 std::string SVEType::str() const {
   if (isPredicatePattern())
-return "sv_pattern";
+return "enum svpattern";
 
   if (isPrefetchOp())
-return "sv_prfop";
+return "enum svprfop";
 
   std::string S;
   if (Void)
@@ -1163,7 +1163,7 @@
   OS << "typedef __clang_svbfloat16x4_t svbfloat16x4_t;\n";
   OS << "#endif\n";
 
-  OS << "typedef enum\n";
+  OS << "enum svpattern\n";
   OS << "{\n";
   OS << "  SV_POW2 = 0,\n";
   OS << "  SV_VL1 = 1,\n";
@@ -1182,9 +1182,9 @@
   OS << "  SV_MUL4 = 29,\n";
   OS << "  SV_MUL3 = 30,\n";
   OS << "  SV_ALL = 31\n";
-  OS << "} sv_pattern;\n\n";
+  OS << "};\n\n";
 
-  OS << "typedef enum\n";
+  OS << "enum svprfop\n";
   OS << "{\n";
   OS << "  SV_PLDL1KEEP = 0,\n";
   OS << "  SV_PLDL1STRM = 1,\n";
@@ -1198,7 +1198,7 @@
   OS << "  SV_PSTL2STRM = 11,\n";
   OS << "  SV_PSTL3KEEP = 12,\n";
   OS << "  SV_PSTL3STRM = 13\n";
-  OS << "} sv_prfop;\n\n";
+  OS << "};\n\n";
 
   OS << "/* Function attributes */\n";
   OS << "#define __aio static inline __attribute__((__always_inline__, "
Index: clang/test/Sema/aarch64-sve-enums.c
===
--- /dev/null
+++ clang/test/Sema/aarch64-sve-enums.c
@@ -0,0 +1,17 @@
+// REQUIRES: aarch64-registered-target
+// RUN: %clang_cc1 %s -triple aarch64-none-linux-gnu -target-feature +sve 
-fallow-half-arguments-and-returns  -fsyntax-only -verify
+// expected-no-diagnostics
+
+// This test makes sure that the enum declarations in section "5. Enum
+// declarations" of the SVE ACLE [1]  are not
+// presented as typedefs in `arm_sve.h`.
+//
+// [1] https://developer.arm.com/documentation/100987/latest version 00bet6
+
+typedef struct { float f; } svpattern;
+typedef struct { float f; } svprfop;
+#include 
+enum svpattern a1 = SV_ALL;
+svpattern b1 = {1.0f};
+enum svprfop a2 = SV_PLDL1KEEP;
+svprfop b2 = {1.0f};


Index: clang/utils/TableGen/SveEmitter.cpp
===
--- clang/utils/TableGen/SveEmitter.cpp
+++ clang/utils/TableGen/SveEmitter.cpp
@@ -416,10 +416,10 @@
 
 std::string SVEType::str() const {
   if (isPredicatePattern())
-return "sv_pattern";
+return "enum svpattern";
 
   if (isPrefetchOp())
-return "sv_prfop";
+return "enum svprfop";
 
   std::string S;
   if (Void)
@@ -1163,7 +1163,7 @@
   OS << "typedef __clang_svbfloat16x4_t svbfloat16x4_t;\n";
   OS << "#endif\n";
 
-  OS << "typedef enum\n";
+  OS << "enum svpattern\n";
   OS << "{\n";
   OS << "  SV_POW2 = 0,\n";
   OS << "  SV_VL1 = 1,\n";
@@ -1182,9 +1182,9 @@
   OS << "  SV_MUL4 = 29,\n";
   OS << "  SV_MUL3 = 30,\n";
   OS << "  SV_ALL = 31\n";
-  OS << "} sv_pattern;\n\n";
+  OS << "};\n\n";
 
-  OS << "typedef enum\n";
+  OS << "enum svprfop\n";
   OS << "{\n";
   OS << "  SV_PLDL1KEEP = 0,\n";
   OS << "  SV_PLDL1STRM = 1,\n";
@@ -1198,7 +1198,7 @@
   OS << "  SV_PSTL2STRM = 11,\n";
   OS << "  SV_PSTL3KEEP = 12,\n";
   OS << "  SV_PSTL3STRM = 13\n";
-  OS << "} sv_prfop;\n\n";
+  OS << "};\n\n";
 
   OS << "/* Function attributes */\n";
   OS << "#define __aio static inline __attribute__((__always_inline__, "
Index: clang/test/Sema/aarch64-sve-enums.c
===
--- /dev/null
+++ clang/test/Sema/aarch64-sve-enums.c
@@ -0,0 +1,17 @@
+// REQUIRES: aarch64-registered-target
+// RUN: %clang_cc1 %s -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns  -fsyntax-only -verify
+// expected-no-diagnostics
+
+// This test makes sure that the enum declarations in section "5. Enum
+// declarations" of the SVE ACLE [1]  are not
+// presented as typedefs in `arm_sve.h`.
+//
+// [1] https://developer.arm.com/documentation/100987/latest version 00bet6
+
+typedef struct { float f; } svpattern;
+typedef struct { float f; } svprfop;
+#include 
+enum svpattern a1 = SV_ALL;
+svpattern b1 = {1.0f};
+enum 

[PATCH] D71880: [clangd] Implement Decl canonicalization rules for rename

2020-11-12 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 304776.
kbobyrev marked 5 inline comments as done.
kbobyrev added a comment.

- Handle VarDecl
- Handle FunctionTemplateDecl
- Remove FieldDecl handling (leave for the future patches)
- Simplify code
- Prevent regressions by adding more tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71880

Files:
  clang-tools-extra/clangd/refactor/Rename.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp

Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -588,6 +588,103 @@
   ns::[[Old^Alias]] Bar;
 }
   )cpp",
+
+  // Templated method instantiation.
+  R"cpp(
+template
+class Foo {
+public:
+  static T [[f^oo]]() {}
+};
+
+void bar() {
+  Foo::[[f^oo]]();
+}
+  )cpp",
+  R"cpp(
+template
+class Foo {
+public:
+  T [[f^oo]]() {}
+};
+
+void bar() {
+  Foo().[[f^oo]]();
+}
+  )cpp",
+
+  // Templated class specialization.
+  R"cpp(
+template
+class [[Foo^]];
+
+template
+class [[Foo^]] {};
+
+template
+class [[Foo^]];
+  )cpp",
+  R"cpp(
+template
+class [[Foo^]];
+
+template
+class [[Foo^]] {};
+  )cpp",
+
+  // Function template specialization.
+  R"cpp(
+template
+U [[foo^]]();
+
+template
+U [[foo^]]() {};
+  )cpp",
+  R"cpp(
+template
+U [[foo^]]() {};
+
+template
+U [[foo^]]();
+  )cpp",
+  R"cpp(
+template
+U [[foo^]]();
+
+template
+U [[foo^]]();
+  )cpp",
+
+  R"cpp(
+template 
+bool [[F^oo]] = true;
+
+// Explicit template specialization
+template <>
+bool [[F^oo]] = false;
+
+// Partial template specialization
+template 
+bool [[F^oo]] = false;
+
+void foo() {
+  // Ref to the explicit template specialization
+  [[F^oo]];
+  // Ref to the primary template.
+  [[F^oo]];
+}
+  )cpp",
+  R"cpp(
+template 
+void [[f^oo]](T t);
+
+template <>
+void [[f^oo]](int a);
+
+void test() {
+  [[f^oo]](1);
+}
+  )cpp",
   };
   llvm::StringRef NewName = "NewName";
   for (llvm::StringRef T : Tests) {
Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -18,12 +18,12 @@
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/Basic/SourceLocation.h"
-#include "clang/Tooling/Refactoring/Rename/USRFindingAction.h"
 #include "clang/Tooling/Syntax/Tokens.h"
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/Error.h"
+#include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FormatVariadic.h"
 #include 
 
@@ -76,6 +76,8 @@
   return OtherFile;
 }
 
+const NamedDecl *canonicalRenameDecl(const NamedDecl *D);
+
 llvm::DenseSet locateDeclAt(ParsedAST &AST,
SourceLocation TokenStartLoc) {
   unsigned Offset =
@@ -92,8 +94,7 @@
targetDecl(SelectedNode->ASTNode,
   DeclRelation::Alias | DeclRelation::TemplatePattern)) {
 // Get to CXXRecordDecl from constructor or destructor.
-D = tooling::getCanonicalSymbolDeclaration(D);
-Result.insert(D);
+Result.insert(canonicalRenameDecl(D));
   }
   return Result;
 }
@@ -222,23 +223,73 @@
   return error("Cannot rename symbol: {0}", Message(Reason));
 }
 
+const NamedDecl *canonicalRenameDecl(const TemplateDecl *D) {
+  return D->getTemplatedDecl();
+}
+
+const NamedDecl *canonicalRenameDecl(const CXXMethodDecl *D) {
+  const auto *Result = D;
+  if (const auto *InstantiatedMethod = D->getInstantiatedFromMemberFunction())
+Result = cast(InstantiatedMethod);
+  while (Result->isVirtual() && Result->size_overridden_methods())
+Result = *Result->overridden_methods().begin();
+  return Result;
+}
+
+const NamedDecl *canonicalRenameDecl(const FunctionDecl *D) {
+  if (const auto *Template = D->getPrimaryTemplate())
+return canonicalRenameDecl(Template);
+  return D;
+}
+
+const NamedDecl *canonicalRenameDecl(const FunctionTemplateDecl *D) {
+  const auto *TemplatedDecl = D->getTemplatedDecl();
+  if (const auto *Primary = TemplatedDecl->getPrimaryTemplate())
+return Primary;
+  return TemplatedDecl;
+}
+
+const NamedDecl *canonicalRenameDecl(const Var

[clang] b9d3654 - [dllexport] Avoid assert for explicitly defaulted methods in explicit instantiation definitions (PR47683)

2020-11-12 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2020-11-12T13:19:29+01:00
New Revision: b9d36540a85b859ff1189c6c2c3acbc59033ae49

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

LOG: [dllexport] Avoid assert for explicitly defaulted methods in explicit 
instantiation definitions (PR47683)

Clang was asserting due to attempting to codegen such methods twice.

Differential revision: https://reviews.llvm.org/D90849

Added: 


Modified: 
clang/lib/Sema/SemaDeclCXX.cpp
clang/test/CodeGenCXX/dllexport.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index ebda013a7426..c49e9cab6d63 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -5895,13 +5895,22 @@ static void ReferenceDllExportedMembers(Sema &S, 
CXXRecordDecl *Class) {
 
 // The function will be passed to the consumer when its definition is
 // encountered.
-  } else if (!MD->isTrivial() || MD->isExplicitlyDefaulted() ||
+  } else if (MD->isExplicitlyDefaulted()) {
+// Synthesize and instantiate explicitly defaulted methods.
+S.MarkFunctionReferenced(Class->getLocation(), MD);
+
+if (TSK != TSK_ExplicitInstantiationDefinition) {
+  // Except for explicit instantiation defs, we will not see the
+  // definition again later, so pass it to the consumer now.
+  S.Consumer.HandleTopLevelDecl(DeclGroupRef(MD));
+}
+  } else if (!MD->isTrivial() ||
  MD->isCopyAssignmentOperator() ||
  MD->isMoveAssignmentOperator()) {
-// Synthesize and instantiate non-trivial implicit methods, explicitly
-// defaulted methods, and the copy and move assignment operators. The
-// latter are exported even if they are trivial, because the address of
-// an operator can be taken and should compare equal across libraries.
+// Synthesize and instantiate non-trivial implicit methods, and the 
copy
+// and move assignment operators. The latter are exported even if they
+// are trivial, because the address of an operator can be taken and
+// should compare equal across libraries.
 S.MarkFunctionReferenced(Class->getLocation(), MD);
 
 // There is no later point when we will see the definition of this

diff  --git a/clang/test/CodeGenCXX/dllexport.cpp 
b/clang/test/CodeGenCXX/dllexport.cpp
index 3371db3bbdec..f8dc2ab9aa87 100644
--- a/clang/test/CodeGenCXX/dllexport.cpp
+++ b/clang/test/CodeGenCXX/dllexport.cpp
@@ -915,6 +915,36 @@ template<> template<> void 
ExportedClassTemplate2::baz() {}
 // M32-DAG: define dso_local x86_thiscallcc void 
@"??$baz@H@?$ExportedClassTemplate2@H@pr34849@@QAEXXZ"
 }
 
+namespace pr47683 {
+struct X { X() {} };
+
+template  struct S {
+  S() = default;
+  X x;
+};
+template struct __declspec(dllexport) S;
+// M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc 
%"struct.pr47683::S"* @"??0?$S@H@pr47683@@QAE@XZ"
+
+template  struct T {
+  T() = default;
+  X x;
+};
+extern template struct T;
+template struct __declspec(dllexport) T;
+// Don't assert about multiple codegen for explicitly defaulted method in 
explicit instantiation def.
+// M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc 
%"struct.pr47683::T"* @"??0?$T@H@pr47683@@QAE@XZ"
+
+template  struct U {
+  U();
+  X x;
+};
+template  U::U() = default;
+extern template struct U;
+template struct __declspec(dllexport) U;
+// Same as T, but with out-of-line ctor.
+// M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc 
%"struct.pr47683::U"* @"??0?$U@H@pr47683@@QAE@XZ"
+}
+
 
//===--===//
 // Classes with template base classes
 
//===--===//



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


[PATCH] D90849: [dllexport] Avoid multiple codegen assert for explicitly defaulted methods in explicit instantiation definitions (PR47683)

2020-11-12 Thread Hans Wennborg via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb9d36540a85b: [dllexport] Avoid assert for explicitly 
defaulted methods in explicit… (authored by hans).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90849

Files:
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/CodeGenCXX/dllexport.cpp


Index: clang/test/CodeGenCXX/dllexport.cpp
===
--- clang/test/CodeGenCXX/dllexport.cpp
+++ clang/test/CodeGenCXX/dllexport.cpp
@@ -915,6 +915,36 @@
 // M32-DAG: define dso_local x86_thiscallcc void 
@"??$baz@H@?$ExportedClassTemplate2@H@pr34849@@QAEXXZ"
 }
 
+namespace pr47683 {
+struct X { X() {} };
+
+template  struct S {
+  S() = default;
+  X x;
+};
+template struct __declspec(dllexport) S;
+// M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc 
%"struct.pr47683::S"* @"??0?$S@H@pr47683@@QAE@XZ"
+
+template  struct T {
+  T() = default;
+  X x;
+};
+extern template struct T;
+template struct __declspec(dllexport) T;
+// Don't assert about multiple codegen for explicitly defaulted method in 
explicit instantiation def.
+// M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc 
%"struct.pr47683::T"* @"??0?$T@H@pr47683@@QAE@XZ"
+
+template  struct U {
+  U();
+  X x;
+};
+template  U::U() = default;
+extern template struct U;
+template struct __declspec(dllexport) U;
+// Same as T, but with out-of-line ctor.
+// M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc 
%"struct.pr47683::U"* @"??0?$U@H@pr47683@@QAE@XZ"
+}
+
 
//===--===//
 // Classes with template base classes
 
//===--===//
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -5895,13 +5895,22 @@
 
 // The function will be passed to the consumer when its definition is
 // encountered.
-  } else if (!MD->isTrivial() || MD->isExplicitlyDefaulted() ||
+  } else if (MD->isExplicitlyDefaulted()) {
+// Synthesize and instantiate explicitly defaulted methods.
+S.MarkFunctionReferenced(Class->getLocation(), MD);
+
+if (TSK != TSK_ExplicitInstantiationDefinition) {
+  // Except for explicit instantiation defs, we will not see the
+  // definition again later, so pass it to the consumer now.
+  S.Consumer.HandleTopLevelDecl(DeclGroupRef(MD));
+}
+  } else if (!MD->isTrivial() ||
  MD->isCopyAssignmentOperator() ||
  MD->isMoveAssignmentOperator()) {
-// Synthesize and instantiate non-trivial implicit methods, explicitly
-// defaulted methods, and the copy and move assignment operators. The
-// latter are exported even if they are trivial, because the address of
-// an operator can be taken and should compare equal across libraries.
+// Synthesize and instantiate non-trivial implicit methods, and the 
copy
+// and move assignment operators. The latter are exported even if they
+// are trivial, because the address of an operator can be taken and
+// should compare equal across libraries.
 S.MarkFunctionReferenced(Class->getLocation(), MD);
 
 // There is no later point when we will see the definition of this


Index: clang/test/CodeGenCXX/dllexport.cpp
===
--- clang/test/CodeGenCXX/dllexport.cpp
+++ clang/test/CodeGenCXX/dllexport.cpp
@@ -915,6 +915,36 @@
 // M32-DAG: define dso_local x86_thiscallcc void @"??$baz@H@?$ExportedClassTemplate2@H@pr34849@@QAEXXZ"
 }
 
+namespace pr47683 {
+struct X { X() {} };
+
+template  struct S {
+  S() = default;
+  X x;
+};
+template struct __declspec(dllexport) S;
+// M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc %"struct.pr47683::S"* @"??0?$S@H@pr47683@@QAE@XZ"
+
+template  struct T {
+  T() = default;
+  X x;
+};
+extern template struct T;
+template struct __declspec(dllexport) T;
+// Don't assert about multiple codegen for explicitly defaulted method in explicit instantiation def.
+// M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc %"struct.pr47683::T"* @"??0?$T@H@pr47683@@QAE@XZ"
+
+template  struct U {
+  U();
+  X x;
+};
+template  U::U() = default;
+extern template struct U;
+template struct __declspec(dllexport) U;
+// Same as T, but with out-of-line ctor.
+// M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc %"struct.pr47683::U"* @"??0?$U@H@pr47683@@QAE@XZ"
+}
+
 //===--===//
 // Classes with template base classes
 //===--===//
Index: c

[PATCH] D91089: [dllexport] Instantiate default ctor default args for explicit specializations (PR45811)

2020-11-12 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

>> I don't think it makes sense to try to emit the closure until we have the 
>> ctor definition. I'll update the patch to handle this.
>
> Ok. That's a bit different than what MSVC is doing. It generates a closure 
> constructor even if there is only a declaration. But I guess we are not 
> aligning specifically with MSVC!
> Look good.

Right, I noticed that MSVC does this, but I couldn't come up with any reason 
why it would be necessary for us. Emitting the closure with the ctor definition 
should be sufficient.


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

https://reviews.llvm.org/D91089

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


[PATCH] D91029: [clangd] Implement clang-tidy options from config

2020-11-12 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 304780.
njames93 marked 4 inline comments as done.
njames93 added a comment.

Reworked large chunks of this:

- Renamed ClangdTidyProvider->TidyProvider.
- Removed the obselete interface mirroring ClangTidyOptionsProvider, it wasn't 
needed.
- Incorporated the ThreadsafeFS inside the provider.
- Removed some unnecessary changes.
- Removed the internal caching of the ThreadsafeFileTidyProvider.
- Trimmed down inheritance hierarchy.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91029

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/Compiler.h
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/TidyProvider.cpp
  clang-tools-extra/clangd/TidyProvider.h
  clang-tools-extra/clangd/tool/Check.cpp
  clang-tools-extra/clangd/tool/ClangdMain.cpp
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/ClangdTests.cpp
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
  clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
  clang-tools-extra/clangd/unittests/TestTU.cpp
  clang-tools-extra/clangd/unittests/TestTU.h
  clang-tools-extra/clangd/unittests/TestTidyProvider.cpp
  clang-tools-extra/clangd/unittests/TestTidyProvider.h

Index: clang-tools-extra/clangd/unittests/TestTidyProvider.h
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/TestTidyProvider.h
@@ -0,0 +1,33 @@
+//===-- TestTidyProvider.h --*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "../TidyProvider.h"
+#include "llvm/Support/VirtualFileSystem.h"
+
+namespace clang {
+namespace clangd {
+
+class TestClangTidyProvider : public TidyProvider {
+public:
+  /// Convienence method for creating a provider that just uses \p Checks and \p
+  /// WarningsAsErrors
+  TestClangTidyProvider(llvm::StringRef Checks,
+llvm::StringRef WarningsAsErrors = {});
+  TestClangTidyProvider(const tidy::ClangTidyOptions &Options)
+  : Opts(Options) {}
+
+  tidy::ClangTidyOptions getOptions(llvm::StringRef FileName) override {
+return Opts;
+  }
+
+private:
+  tidy::ClangTidyOptions Opts;
+};
+
+} // namespace clangd
+} // namespace clang
Index: clang-tools-extra/clangd/unittests/TestTidyProvider.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/TestTidyProvider.cpp
@@ -0,0 +1,26 @@
+//===-- TestTidyProvider.cpp *- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "TestTidyProvider.h"
+
+namespace clang {
+
+using namespace tidy;
+
+namespace clangd {
+
+TestClangTidyProvider::TestClangTidyProvider(llvm::StringRef Checks,
+ llvm::StringRef WarningsAsErrors) {
+  if (!Checks.empty())
+Opts.Checks.emplace(Checks);
+  if (!WarningsAsErrors.empty())
+Opts.WarningsAsErrors.emplace(WarningsAsErrors);
+}
+
+} // namespace clangd
+} // namespace clang
Index: clang-tools-extra/clangd/unittests/TestTU.h
===
--- clang-tools-extra/clangd/unittests/TestTU.h
+++ clang-tools-extra/clangd/unittests/TestTU.h
@@ -17,6 +17,7 @@
 #ifndef LLVM_CLANG_TOOLS_EXTRA_UNITTESTS_CLANGD_TESTTU_H
 #define LLVM_CLANG_TOOLS_EXTRA_UNITTESTS_CLANGD_TESTTU_H
 
+#include "../TidyProvider.h"
 #include "Compiler.h"
 #include "ParsedAST.h"
 #include "TestFS.h"
@@ -58,8 +59,7 @@
   // Extra arguments for the compiler invocation.
   std::vector ExtraArgs;
 
-  llvm::Optional ClangTidyChecks;
-  llvm::Optional ClangTidyWarningsAsErrors;
+  std::unique_ptr ClangTidyProvider;
   // Index to use when building AST.
   const SymbolIndex *ExternalIndex = nullptr;
 
Index: clang-tools-extra/clangd/unittests/TestTU.cpp
===
--- clang-tools-extra/clangd/unittests/TestTU.cpp
+++ clang-tools-extra/clangd/unittests/TestTU.cpp
@@ -59,8 +59,7 @@
 FS.OverlayRealFileSystemForModules = true;
   Inputs.TFS = &FS;
   Inputs.Opts = ParseOptions();
-  Inputs.Opts.ClangTidyOpts.Checks = ClangTidyChecks;
-  Inputs.Opts.ClangTidyOpts.WarningsAsErrors = ClangTidyWarningsAsErrors;
+  Inputs.ClangTi

[PATCH] D91029: [clangd] Implement clang-tidy options from config

2020-11-12 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

Thanks for the comments, I agree it was a little too much. Likely due in part 
to how I first tried to mirror the interface of ClangTidyOptionsProvider.




Comment at: clang-tools-extra/clangd/ParsedAST.cpp:250
   if (Preamble && Preamble->StatCache)
-VFS = Preamble->StatCache->getConsumingFS(std::move(VFS));
+VFS = Preamble->StatCache->getConsumingFS(VFS.get());
 

sammccall wrote:
> why this change?
So we can use the same VFS a bit further down. However as thats not a thing now 
it can be reverted.



Comment at: clang-tools-extra/clangd/ParsedAST.cpp:310
 CTContext->setCurrentFile(Filename);
+dlog("ClangTidy configuration for file {0}: {1}", Filename,
+ tidy::configurationAsText(CTContext->getOptions()));

sammccall wrote:
> nit: move a few lines above to after the options-initialization if-stmt?
The options for the context are only sourced once the currentFile has been set


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91029

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


[clang] a088766 - [dllexport] Instantiate default ctor default args for explicit specializations (PR45811)

2020-11-12 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2020-11-12T13:29:34+01:00
New Revision: a088766508aa1a5b6e655a239546f1a64e96eb11

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

LOG: [dllexport] Instantiate default ctor default args for explicit 
specializations (PR45811)

For dllexported default constructors with default arguments, we export
default constructor closures which pass in the default args. (See D8331
for a good explanation.)

For templates, that means those default args must be instantiated even
if the function isn't called. That is done by the
InstantiateDefaultCtorDefaultArgs() function, but it wasn't done for
explicit specializations, causing asserts (see bug).

Differential revision: https://reviews.llvm.org/D91089

Added: 


Modified: 
clang/include/clang/Sema/Sema.h
clang/lib/CodeGen/MicrosoftCXXABI.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/test/CodeGenCXX/dllexport-ctor-closure.cpp
clang/test/SemaCXX/dllexport.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 83d2a3122110..fb95b8cbd193 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -9253,6 +9253,8 @@ class Sema final {
   LateInstantiatedAttrVec *LateAttrs = nullptr,
   LocalInstantiationScope *OuterMostScope = nullptr);
 
+  void InstantiateDefaultCtorDefaultArgs(CXXConstructorDecl *Ctor);
+
   bool usesPartialOrExplicitSpecialization(
   SourceLocation Loc, ClassTemplateSpecializationDecl *ClassTemplateSpec);
 

diff  --git a/clang/lib/CodeGen/MicrosoftCXXABI.cpp 
b/clang/lib/CodeGen/MicrosoftCXXABI.cpp
index 31e7e4c66901..8046b7afce57 100644
--- a/clang/lib/CodeGen/MicrosoftCXXABI.cpp
+++ b/clang/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -1244,12 +1244,14 @@ void MicrosoftCXXABI::EmitCXXConstructors(const 
CXXConstructorDecl *D) {
   // the typical calling convention and have a single 'this' pointer for an
   // argument -or- they get a wrapper function which appropriately thunks to 
the
   // real default constructor.  This thunk is the default constructor closure.
-  if (D->hasAttr() && D->isDefaultConstructor())
+  if (D->hasAttr() && D->isDefaultConstructor() &&
+  D->isDefined()) {
 if (!hasDefaultCXXMethodCC(getContext(), D) || D->getNumParams() != 0) {
   llvm::Function *Fn = getAddrOfCXXCtorClosure(D, Ctor_DefaultClosure);
   Fn->setLinkage(llvm::GlobalValue::WeakODRLinkage);
   CGM.setGVProperties(Fn, D);
 }
+  }
 }
 
 void MicrosoftCXXABI::EmitVBPtrStores(CodeGenFunction &CGF,

diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 02dfbd41023c..4f054e9f1ebf 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -13994,6 +13994,16 @@ Decl *Sema::ActOnStartOfFunctionDef(Scope 
*FnBodyScope, Decl *D,
 FD->setInvalidDecl();
   }
 
+  if (auto *Ctor = dyn_cast(FD)) {
+if (Ctor->getTemplateSpecializationKind() == TSK_ExplicitSpecialization &&
+Ctor->isDefaultConstructor() &&
+Context.getTargetInfo().getCXXABI().isMicrosoft()) {
+  // If this is an MS ABI dllexport default constructor, instantiate any
+  // default arguments.
+  InstantiateDefaultCtorDefaultArgs(Ctor);
+}
+  }
+
   // See if this is a redefinition. If 'will have body' (or similar) is already
   // set, then these checks were already performed when it was set.
   if (!FD->willHaveBody() && !FD->isLateTemplateParsed() &&

diff  --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp 
b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 458572cb6fa3..6623e86765d1 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -715,6 +715,26 @@ void Sema::InstantiateAttrs(const 
MultiLevelTemplateArgumentList &TemplateArgs,
   }
 }
 
+/// In the MS ABI, we need to instantiate default arguments of dllexported
+/// default constructors along with the constructor definition. This allows IR
+/// gen to emit a constructor closure which calls the default constructor with
+/// its default arguments.
+void Sema::InstantiateDefaultCtorDefaultArgs(CXXConstructorDecl *Ctor) {
+  assert(Context.getTargetInfo().getCXXABI().isMicrosoft() &&
+ Ctor->isDefaultConstructor());
+  unsigned NumParams = Ctor->getNumParams();
+  if (NumParams == 0)
+return;
+  DLLExportAttr *Attr = Ctor->getAttr();
+  if (!Attr)
+return;
+  for (unsigned I = 0; I != NumParams; ++I) {
+(void)CheckCXXDefaultArgExpr(Attr->getLocation(), Ctor,
+   Ctor->getParamDecl(I));
+DiscardCleanupsInEvaluationContext();
+  }
+}
+
 /// Get the previous declaration of a declaration for the purposes 

[PATCH] D91089: [dllexport] Instantiate default ctor default args for explicit specializations (PR45811)

2020-11-12 Thread Hans Wennborg via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa088766508aa: [dllexport] Instantiate default ctor default 
args for explicit specializations… (authored by hans).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91089

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/CodeGen/MicrosoftCXXABI.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/CodeGenCXX/dllexport-ctor-closure.cpp
  clang/test/SemaCXX/dllexport.cpp

Index: clang/test/SemaCXX/dllexport.cpp
===
--- clang/test/SemaCXX/dllexport.cpp
+++ clang/test/SemaCXX/dllexport.cpp
@@ -792,6 +792,11 @@
 };
 template struct HasDefaults2; // expected-note {{in instantiation of member function 'HasDefaults2::HasDefaults2' requested here}}
 
+template  struct __declspec(dllexport) HasDefaults3 { // expected-note{{in instantiation of default function argument expression for 'HasDefaults3' required here}}
+  HasDefaults3(int x = sizeof(T)) {} // expected-error {{invalid application of 'sizeof'}}
+};
+template <> HasDefaults3::HasDefaults3(int) {};
+
 #endif
 
 //===--===//
Index: clang/test/CodeGenCXX/dllexport-ctor-closure.cpp
===
--- clang/test/CodeGenCXX/dllexport-ctor-closure.cpp
+++ clang/test/CodeGenCXX/dllexport-ctor-closure.cpp
@@ -50,6 +50,14 @@
 // CHECK-LABEL: define weak_odr dso_local dllexport x86_thiscallcc void @"??_F?$TemplateWithClosure@H@@QAEXXZ"({{.*}}) {{#[0-9]+}} comdat
 // CHECK:   call {{.*}} @"??0?$TemplateWithClosure@H@@QAE@H@Z"({{.*}}, i32 4)
 
+template  struct __declspec(dllexport) ExportedTemplateWithClosure {
+  ExportedTemplateWithClosure(int x = sizeof(T)) {}
+};
+template <> ExportedTemplateWithClosure::ExportedTemplateWithClosure(int); // Don't try to emit the closure for a declaration.
+template <> ExportedTemplateWithClosure::ExportedTemplateWithClosure(int) {};
+// CHECK-LABEL: define weak_odr dso_local dllexport x86_thiscallcc void @"??_F?$ExportedTemplateWithClosure@H@@QAEXXZ"({{.*}}) {{#[0-9]+}} comdat
+// CHECK:   call {{.*}} @"??0?$ExportedTemplateWithClosure@H@@QAE@H@Z"({{.*}}, i32 4)
+
 struct __declspec(dllexport) NestedOuter {
   DELETE_IMPLICIT_MEMBERS(NestedOuter);
   NestedOuter(void *p = 0) {}
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -715,6 +715,26 @@
   }
 }
 
+/// In the MS ABI, we need to instantiate default arguments of dllexported
+/// default constructors along with the constructor definition. This allows IR
+/// gen to emit a constructor closure which calls the default constructor with
+/// its default arguments.
+void Sema::InstantiateDefaultCtorDefaultArgs(CXXConstructorDecl *Ctor) {
+  assert(Context.getTargetInfo().getCXXABI().isMicrosoft() &&
+ Ctor->isDefaultConstructor());
+  unsigned NumParams = Ctor->getNumParams();
+  if (NumParams == 0)
+return;
+  DLLExportAttr *Attr = Ctor->getAttr();
+  if (!Attr)
+return;
+  for (unsigned I = 0; I != NumParams; ++I) {
+(void)CheckCXXDefaultArgExpr(Attr->getLocation(), Ctor,
+   Ctor->getParamDecl(I));
+DiscardCleanupsInEvaluationContext();
+  }
+}
+
 /// Get the previous declaration of a declaration for the purposes of template
 /// instantiation. If this finds a previous declaration, then the previous
 /// declaration of the instantiation of D should be an instantiation of the
@@ -4608,27 +4628,6 @@
   return cast_or_null(SubstDecl(FD, FD->getParent(), MArgs));
 }
 
-/// In the MS ABI, we need to instantiate default arguments of dllexported
-/// default constructors along with the constructor definition. This allows IR
-/// gen to emit a constructor closure which calls the default constructor with
-/// its default arguments.
-static void InstantiateDefaultCtorDefaultArgs(Sema &S,
-  CXXConstructorDecl *Ctor) {
-  assert(S.Context.getTargetInfo().getCXXABI().isMicrosoft() &&
- Ctor->isDefaultConstructor());
-  unsigned NumParams = Ctor->getNumParams();
-  if (NumParams == 0)
-return;
-  DLLExportAttr *Attr = Ctor->getAttr();
-  if (!Attr)
-return;
-  for (unsigned I = 0; I != NumParams; ++I) {
-(void)S.CheckCXXDefaultArgExpr(Attr->getLocation(), Ctor,
-   Ctor->getParamDecl(I));
-S.DiscardCleanupsInEvaluationContext();
-  }
-}
-
 /// Instantiate the definition of the given function from its
 /// template.
 ///
@@ -4847,7 +4846,7 @@
 // default arguments.
 if (Context.getTargetInfo().getCXXABI().isMicrosoft() &&
 Ctor->isDefaultConst

[PATCH] D71880: [clangd] Implement Decl canonicalization rules for rename

2020-11-12 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 304783.
kbobyrev added a comment.

Add missing user-defined conversion test and a couple of missing cases with
ctor/dtor out-of-line implementation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71880

Files:
  clang-tools-extra/clangd/refactor/Rename.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp

Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -141,6 +141,12 @@
   ~[[F^oo]]();
   void f([[F^oo]] x);
 };
+
+template
+[[F^oo]]::[[Fo^o]]() {}
+
+template
+[[F^oo]]::~[[Fo^o]]() {}
   )cpp",
 
   // Template class constructor.
@@ -152,6 +158,9 @@
   template
   [[F^oo]](T t);
 };
+
+template
+[[F^oo]]::[[Fo^o]]() {}
   )cpp",
 
   // Class in template argument.
@@ -191,11 +200,15 @@
 struct C : B {
   void [[f^oo]]() override {}
 };
+struct D : B {
+  void [[f^oo]]() override {}
+};
 
 void func() {
   A().[[f^oo]]();
   B().[[f^oo]]();
   C().[[f^oo]]();
+  D().[[f^oo]]();
 }
   )cpp",
 
@@ -588,6 +601,123 @@
   ns::[[Old^Alias]] Bar;
 }
   )cpp",
+
+  // Templated method instantiation.
+  R"cpp(
+template
+class Foo {
+public:
+  static T [[f^oo]]() {}
+};
+
+void bar() {
+  Foo::[[f^oo]]();
+}
+  )cpp",
+  R"cpp(
+template
+class Foo {
+public:
+  T [[f^oo]]() {}
+};
+
+void bar() {
+  Foo().[[f^oo]]();
+}
+  )cpp",
+
+  // Templated class specialization.
+  R"cpp(
+template
+class [[Foo^]];
+
+template
+class [[Foo^]] {};
+
+template
+class [[Foo^]];
+  )cpp",
+  R"cpp(
+template
+class [[Foo^]];
+
+template
+class [[Foo^]] {};
+  )cpp",
+
+  // Function template specialization.
+  R"cpp(
+template
+U [[foo^]]();
+
+template
+U [[foo^]]() {};
+  )cpp",
+  R"cpp(
+template
+U [[foo^]]() {};
+
+template
+U [[foo^]]();
+  )cpp",
+  R"cpp(
+template
+U [[foo^]]();
+
+template
+U [[foo^]]();
+  )cpp",
+
+  R"cpp(
+template 
+bool [[F^oo]] = true;
+
+// Explicit template specialization
+template <>
+bool [[F^oo]] = false;
+
+// Partial template specialization
+template 
+bool [[F^oo]] = false;
+
+void foo() {
+  // Ref to the explicit template specialization
+  [[F^oo]];
+  // Ref to the primary template.
+  [[F^oo]];
+}
+  )cpp",
+  R"cpp(
+template 
+void [[f^oo]](T t);
+
+template <>
+void [[f^oo]](int a);
+
+void test() {
+  [[f^oo]](1);
+}
+  )cpp",
+
+  // User defined conversion.
+  R"cpp(
+class [[F^oo]] {
+public:
+  [[F^oo]]() {}
+};
+
+class Baz {
+public:
+  operator [[F^oo]]() {
+return [[F^oo]]();
+  }
+};
+
+int main() {
+  Baz boo;
+  [[F^oo]] foo = static_cast<[[F^oo]]>(boo);
+}
+  )cpp",
   };
   llvm::StringRef NewName = "NewName";
   for (llvm::StringRef T : Tests) {
Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -18,12 +18,12 @@
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/Basic/SourceLocation.h"
-#include "clang/Tooling/Refactoring/Rename/USRFindingAction.h"
 #include "clang/Tooling/Syntax/Tokens.h"
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/Error.h"
+#include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FormatVariadic.h"
 #include 
 
@@ -76,6 +76,8 @@
   return OtherFile;
 }
 
+const NamedDecl *canonicalRenameDecl(const NamedDecl *D);
+
 llvm::DenseSet locateDeclAt(ParsedAST &AST,
SourceLocation TokenStartLoc) {
   unsigned Offset =
@@ -92,8 +94,7 @@
targetDecl(SelectedNode->ASTNode,
   DeclRelation::Alias | DeclRelation::TemplatePattern)) {
 // Get to CXXRecordDecl from constructor or destructor.
-D = tooling::getCanonicalSymbolDeclaration(D);
-Result.insert(D);
+Result.insert(canonical

[PATCH] D91037: [clang-tidy] Fix crash in bugprone-redundant-branch-condition on ExprWithCleanups

2020-11-12 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-redundant-branch-condition.cpp:1092
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: redundant condition 'isSet' 
[bugprone-redundant-branch-condition]
+  // CHECK-FIXES: {{isSet}}
+}

zinovy.nis wrote:
> aaron.ballman wrote:
> > There's not a whole lot of context for FileCheck to determine if it's been 
> > correctly applied or not (same below) -- for instance, won't this pass even 
> > if no changes are applied because FileCheck is still going to find `isSet` 
> > in the file?
> Thanks. Fixed.
Maybe it's just early in the morning for me, but... I was expecting the 
transformation to be:
```
if (RetT::Test(isSet).Ok() && isSet) {
  if (RetT::Test(isSet).Ok() && isSet) {
  }
}
```
turns into
```
if (RetT::Test(isSet).Ok() && isSet) {
}
```
Why does it remove the `&& isSet` instead? That seems like it's changing the 
logic here from `if (true && false)` to `if (true)`.


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

https://reviews.llvm.org/D91037

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


[PATCH] D71880: [clangd] Implement Decl canonicalization rules for rename

2020-11-12 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 304784.
kbobyrev added a comment.

Add a test with static class member.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71880

Files:
  clang-tools-extra/clangd/refactor/Rename.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp

Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -141,6 +141,12 @@
   ~[[F^oo]]();
   void f([[F^oo]] x);
 };
+
+template
+[[F^oo]]::[[Fo^o]]() {}
+
+template
+[[F^oo]]::~[[Fo^o]]() {}
   )cpp",
 
   // Template class constructor.
@@ -152,6 +158,9 @@
   template
   [[F^oo]](T t);
 };
+
+template
+[[F^oo]]::[[Fo^o]]() {}
   )cpp",
 
   // Class in template argument.
@@ -191,11 +200,15 @@
 struct C : B {
   void [[f^oo]]() override {}
 };
+struct D : B {
+  void [[f^oo]]() override {}
+};
 
 void func() {
   A().[[f^oo]]();
   B().[[f^oo]]();
   C().[[f^oo]]();
+  D().[[f^oo]]();
 }
   )cpp",
 
@@ -307,6 +320,19 @@
 }
   )cpp",
 
+  // Static class member.
+  R"cpp(
+struct Foo {
+  static Foo *[[Static^Member]];
+};
+
+Foo* Foo::[[Static^Member]] = nullptr;
+
+void foo() {
+  Foo* Pointer = Foo::[[Static^Member]];
+}
+  )cpp",
+
   // Reference in lambda parameters.
   R"cpp(
 template 
@@ -588,6 +614,123 @@
   ns::[[Old^Alias]] Bar;
 }
   )cpp",
+
+  // Templated method instantiation.
+  R"cpp(
+template
+class Foo {
+public:
+  static T [[f^oo]]() {}
+};
+
+void bar() {
+  Foo::[[f^oo]]();
+}
+  )cpp",
+  R"cpp(
+template
+class Foo {
+public:
+  T [[f^oo]]() {}
+};
+
+void bar() {
+  Foo().[[f^oo]]();
+}
+  )cpp",
+
+  // Templated class specialization.
+  R"cpp(
+template
+class [[Foo^]];
+
+template
+class [[Foo^]] {};
+
+template
+class [[Foo^]];
+  )cpp",
+  R"cpp(
+template
+class [[Foo^]];
+
+template
+class [[Foo^]] {};
+  )cpp",
+
+  // Function template specialization.
+  R"cpp(
+template
+U [[foo^]]();
+
+template
+U [[foo^]]() {};
+  )cpp",
+  R"cpp(
+template
+U [[foo^]]() {};
+
+template
+U [[foo^]]();
+  )cpp",
+  R"cpp(
+template
+U [[foo^]]();
+
+template
+U [[foo^]]();
+  )cpp",
+
+  R"cpp(
+template 
+bool [[F^oo]] = true;
+
+// Explicit template specialization
+template <>
+bool [[F^oo]] = false;
+
+// Partial template specialization
+template 
+bool [[F^oo]] = false;
+
+void foo() {
+  // Ref to the explicit template specialization
+  [[F^oo]];
+  // Ref to the primary template.
+  [[F^oo]];
+}
+  )cpp",
+  R"cpp(
+template 
+void [[f^oo]](T t);
+
+template <>
+void [[f^oo]](int a);
+
+void test() {
+  [[f^oo]](1);
+}
+  )cpp",
+
+  // User defined conversion.
+  R"cpp(
+class [[F^oo]] {
+public:
+  [[F^oo]]() {}
+};
+
+class Baz {
+public:
+  operator [[F^oo]]() {
+return [[F^oo]]();
+  }
+};
+
+int main() {
+  Baz boo;
+  [[F^oo]] foo = static_cast<[[F^oo]]>(boo);
+}
+  )cpp",
   };
   llvm::StringRef NewName = "NewName";
   for (llvm::StringRef T : Tests) {
Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -18,12 +18,12 @@
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/Basic/SourceLocation.h"
-#include "clang/Tooling/Refactoring/Rename/USRFindingAction.h"
 #include "clang/Tooling/Syntax/Tokens.h"
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/Error.h"
+#include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FormatVariadic.h"
 #include 
 
@@ -76,6 +76,8 @@
   return OtherFile;
 }
 
+const NamedDecl *canonicalRenameDecl(const NamedDecl *D);
+
 llvm::DenseSet locateDeclAt(ParsedAST &AST,
SourceLocation TokenStartLoc) {
  

[PATCH] D71880: [clangd] Implement Decl canonicalization rules for rename

2020-11-12 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 304785.
kbobyrev added a comment.

Remove (now) outdated comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71880

Files:
  clang-tools-extra/clangd/refactor/Rename.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp

Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -141,6 +141,12 @@
   ~[[F^oo]]();
   void f([[F^oo]] x);
 };
+
+template
+[[F^oo]]::[[Fo^o]]() {}
+
+template
+[[F^oo]]::~[[Fo^o]]() {}
   )cpp",
 
   // Template class constructor.
@@ -152,6 +158,9 @@
   template
   [[F^oo]](T t);
 };
+
+template
+[[F^oo]]::[[Fo^o]]() {}
   )cpp",
 
   // Class in template argument.
@@ -191,11 +200,15 @@
 struct C : B {
   void [[f^oo]]() override {}
 };
+struct D : B {
+  void [[f^oo]]() override {}
+};
 
 void func() {
   A().[[f^oo]]();
   B().[[f^oo]]();
   C().[[f^oo]]();
+  D().[[f^oo]]();
 }
   )cpp",
 
@@ -307,6 +320,19 @@
 }
   )cpp",
 
+  // Static class member.
+  R"cpp(
+struct Foo {
+  static Foo *[[Static^Member]];
+};
+
+Foo* Foo::[[Static^Member]] = nullptr;
+
+void foo() {
+  Foo* Pointer = Foo::[[Static^Member]];
+}
+  )cpp",
+
   // Reference in lambda parameters.
   R"cpp(
 template 
@@ -588,6 +614,123 @@
   ns::[[Old^Alias]] Bar;
 }
   )cpp",
+
+  // Templated method instantiation.
+  R"cpp(
+template
+class Foo {
+public:
+  static T [[f^oo]]() {}
+};
+
+void bar() {
+  Foo::[[f^oo]]();
+}
+  )cpp",
+  R"cpp(
+template
+class Foo {
+public:
+  T [[f^oo]]() {}
+};
+
+void bar() {
+  Foo().[[f^oo]]();
+}
+  )cpp",
+
+  // Templated class specialization.
+  R"cpp(
+template
+class [[Foo^]];
+
+template
+class [[Foo^]] {};
+
+template
+class [[Foo^]];
+  )cpp",
+  R"cpp(
+template
+class [[Foo^]];
+
+template
+class [[Foo^]] {};
+  )cpp",
+
+  // Function template specialization.
+  R"cpp(
+template
+U [[foo^]]();
+
+template
+U [[foo^]]() {};
+  )cpp",
+  R"cpp(
+template
+U [[foo^]]() {};
+
+template
+U [[foo^]]();
+  )cpp",
+  R"cpp(
+template
+U [[foo^]]();
+
+template
+U [[foo^]]();
+  )cpp",
+
+  R"cpp(
+template 
+bool [[F^oo]] = true;
+
+// Explicit template specialization
+template <>
+bool [[F^oo]] = false;
+
+// Partial template specialization
+template 
+bool [[F^oo]] = false;
+
+void foo() {
+  // Ref to the explicit template specialization
+  [[F^oo]];
+  // Ref to the primary template.
+  [[F^oo]];
+}
+  )cpp",
+  R"cpp(
+template 
+void [[f^oo]](T t);
+
+template <>
+void [[f^oo]](int a);
+
+void test() {
+  [[f^oo]](1);
+}
+  )cpp",
+
+  // User defined conversion.
+  R"cpp(
+class [[F^oo]] {
+public:
+  [[F^oo]]() {}
+};
+
+class Baz {
+public:
+  operator [[F^oo]]() {
+return [[F^oo]]();
+  }
+};
+
+int main() {
+  Baz boo;
+  [[F^oo]] foo = static_cast<[[F^oo]]>(boo);
+}
+  )cpp",
   };
   llvm::StringRef NewName = "NewName";
   for (llvm::StringRef T : Tests) {
Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -18,12 +18,12 @@
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/Basic/SourceLocation.h"
-#include "clang/Tooling/Refactoring/Rename/USRFindingAction.h"
 #include "clang/Tooling/Syntax/Tokens.h"
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/Error.h"
+#include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FormatVariadic.h"
 #include 
 
@@ -76,6 +76,8 @@
   return OtherFile;
 }
 
+const NamedDecl *canonicalRenameDecl(const NamedDecl *D);
+
 llvm::DenseSet locateDeclAt(ParsedAST &AST,
SourceLocation TokenStartLoc) {
   unsig

[PATCH] D90282: [clang-tidy] Add IgnoreShortNames config to identifier naming checks

2020-11-12 Thread Nathan James via Phabricator via cfe-commits
njames93 added a reviewer: aaron.ballman.
njames93 added a comment.

Should this be a NamingStyle option instead.
`{key: readability-identifier-naming.ParameterShortSizeThreshold, value: 2}`
WDYT?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90282

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


[PATCH] D71880: [clangd] Implement Decl canonicalization rules for rename

2020-11-12 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 304787.
kbobyrev added a comment.

Completely remove new tests from this patch (to be provided in a different
one).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71880

Files:
  clang-tools-extra/clangd/refactor/Rename.cpp

Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -18,12 +18,12 @@
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/Basic/SourceLocation.h"
-#include "clang/Tooling/Refactoring/Rename/USRFindingAction.h"
 #include "clang/Tooling/Syntax/Tokens.h"
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/Error.h"
+#include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FormatVariadic.h"
 #include 
 
@@ -76,6 +76,8 @@
   return OtherFile;
 }
 
+const NamedDecl *canonicalRenameDecl(const NamedDecl *D);
+
 llvm::DenseSet locateDeclAt(ParsedAST &AST,
SourceLocation TokenStartLoc) {
   unsigned Offset =
@@ -91,9 +93,7 @@
   for (const NamedDecl *D :
targetDecl(SelectedNode->ASTNode,
   DeclRelation::Alias | DeclRelation::TemplatePattern)) {
-// Get to CXXRecordDecl from constructor or destructor.
-D = tooling::getCanonicalSymbolDeclaration(D);
-Result.insert(D);
+Result.insert(canonicalRenameDecl(D));
   }
   return Result;
 }
@@ -222,23 +222,73 @@
   return error("Cannot rename symbol: {0}", Message(Reason));
 }
 
+const NamedDecl *canonicalRenameDecl(const TemplateDecl *D) {
+  return D->getTemplatedDecl();
+}
+
+const NamedDecl *canonicalRenameDecl(const CXXMethodDecl *D) {
+  const auto *Result = D;
+  if (const auto *InstantiatedMethod = D->getInstantiatedFromMemberFunction())
+Result = cast(InstantiatedMethod);
+  while (Result->isVirtual() && Result->size_overridden_methods())
+Result = *Result->overridden_methods().begin();
+  return Result;
+}
+
+const NamedDecl *canonicalRenameDecl(const FunctionDecl *D) {
+  if (const auto *Template = D->getPrimaryTemplate())
+return canonicalRenameDecl(Template);
+  return D;
+}
+
+const NamedDecl *canonicalRenameDecl(const FunctionTemplateDecl *D) {
+  const auto *TemplatedDecl = D->getTemplatedDecl();
+  if (const auto *Primary = TemplatedDecl->getPrimaryTemplate())
+return Primary;
+  return TemplatedDecl;
+}
+
+const NamedDecl *canonicalRenameDecl(const VarTemplateSpecializationDecl *D) {
+  return D->getSpecializedTemplate()->getTemplatedDecl();
+}
+
+const NamedDecl *canonicalRenameDecl(const ClassTemplateSpecializationDecl *D) {
+  return D->getSpecializedTemplate()->getTemplatedDecl();
+}
+
+// Canonical declarations help simplify the process of renaming. Examples:
+// - Given a constructor/destructor, canonical declaration is the parent
+//   CXXRecordDecl
+// - Specializations should point to the specialized declaration.
+// - Instantiations should point to instantiated declaration.
+const NamedDecl *canonicalRenameDecl(const NamedDecl *D) {
+  D = dyn_cast(D->getCanonicalDecl());
+  if (const auto *Constructor = dyn_cast(D))
+return canonicalRenameDecl(Constructor->getParent());
+  if (const auto *Destructor = dyn_cast(D))
+return canonicalRenameDecl(Destructor->getParent());
+  if (const auto *FuctionTemplate = dyn_cast(D))
+return canonicalRenameDecl(FuctionTemplate);
+  if (const auto *VarTemplate = dyn_cast(D))
+return canonicalRenameDecl(VarTemplate);
+  if (const auto *Template = dyn_cast(D))
+return canonicalRenameDecl(Template);
+  if (const auto *ClassTemplateSpecialization =
+  dyn_cast(D))
+return canonicalRenameDecl(ClassTemplateSpecialization);
+  if (const auto *Method = dyn_cast(D))
+return canonicalRenameDecl(Method);
+  if (const auto *Function = dyn_cast(D))
+return canonicalRenameDecl(Function);
+  return D;
+}
+
 // Return all rename occurrences in the main file.
 std::vector findOccurrencesWithinFile(ParsedAST &AST,
   const NamedDecl &ND) {
   trace::Span Tracer("FindOccurrencesWithinFile");
-  // If the cursor is at the underlying CXXRecordDecl of the
-  // ClassTemplateDecl, ND will be the CXXRecordDecl. In this case, we need to
-  // get the primary template manually.
-  // getUSRsForDeclaration will find other related symbols, e.g. virtual and its
-  // overriddens, primary template and all explicit specializations.
-  // FIXME: Get rid of the remaining tooling APIs.
-  const auto *RenameDecl =
-  ND.getDescribedTemplate() ? ND.getDescribedTemplate() : &ND;
-  std::vector RenameUSRs =
-  tooling::getUSRsForDeclaration(RenameDecl, AST.getASTContext());
-  llvm::DenseSet TargetIDs;
-  for (auto &USR : RenameUSRs)
-   

[PATCH] D91337: [clangd] Add missing tests to rename feature

2020-11-12 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev created this revision.
kbobyrev added a reviewer: hokein.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman.
Herald added a project: clang.
kbobyrev requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

This adds a couple of missed tests from existing clang-rename ones and
introduces several new ones (e.g. static class member). This patch is required
to ensure feature parity for migration off Clang-Rename API D71880 
.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91337

Files:
  clang-tools-extra/clangd/unittests/RenameTests.cpp

Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -141,6 +141,12 @@
   ~[[F^oo]]();
   void f([[F^oo]] x);
 };
+
+template
+[[F^oo]]::[[Fo^o]]() {}
+
+template
+[[F^oo]]::~[[Fo^o]]() {}
   )cpp",
 
   // Template class constructor.
@@ -152,6 +158,9 @@
   template
   [[F^oo]](T t);
 };
+
+template
+[[F^oo]]::[[Fo^o]]() {}
   )cpp",
 
   // Class in template argument.
@@ -191,11 +200,15 @@
 struct C : B {
   void [[f^oo]]() override {}
 };
+struct D : B {
+  void [[f^oo]]() override {}
+};
 
 void func() {
   A().[[f^oo]]();
   B().[[f^oo]]();
   C().[[f^oo]]();
+  D().[[f^oo]]();
 }
   )cpp",
 
@@ -307,6 +320,19 @@
 }
   )cpp",
 
+  // Static class member.
+  R"cpp(
+struct Foo {
+  static Foo *[[Static^Member]];
+};
+
+Foo* Foo::[[Static^Member]] = nullptr;
+
+void foo() {
+  Foo* Pointer = Foo::[[Static^Member]];
+}
+  )cpp",
+
   // Reference in lambda parameters.
   R"cpp(
 template 
@@ -588,6 +614,123 @@
   ns::[[Old^Alias]] Bar;
 }
   )cpp",
+
+  // Templated method instantiation.
+  R"cpp(
+template
+class Foo {
+public:
+  static T [[f^oo]]() {}
+};
+
+void bar() {
+  Foo::[[f^oo]]();
+}
+  )cpp",
+  R"cpp(
+template
+class Foo {
+public:
+  T [[f^oo]]() {}
+};
+
+void bar() {
+  Foo().[[f^oo]]();
+}
+  )cpp",
+
+  // Templated class specialization.
+  R"cpp(
+template
+class [[Foo^]];
+
+template
+class [[Foo^]] {};
+
+template
+class [[Foo^]];
+  )cpp",
+  R"cpp(
+template
+class [[Foo^]];
+
+template
+class [[Foo^]] {};
+  )cpp",
+
+  // Function template specialization.
+  R"cpp(
+template
+U [[foo^]]();
+
+template
+U [[foo^]]() {};
+  )cpp",
+  R"cpp(
+template
+U [[foo^]]() {};
+
+template
+U [[foo^]]();
+  )cpp",
+  R"cpp(
+template
+U [[foo^]]();
+
+template
+U [[foo^]]();
+  )cpp",
+
+  R"cpp(
+template 
+bool [[F^oo]] = true;
+
+// Explicit template specialization
+template <>
+bool [[F^oo]] = false;
+
+// Partial template specialization
+template 
+bool [[F^oo]] = false;
+
+void foo() {
+  // Ref to the explicit template specialization
+  [[F^oo]];
+  // Ref to the primary template.
+  [[F^oo]];
+}
+  )cpp",
+  R"cpp(
+template 
+void [[f^oo]](T t);
+
+template <>
+void [[f^oo]](int a);
+
+void test() {
+  [[f^oo]](1);
+}
+  )cpp",
+
+  // User defined conversion.
+  R"cpp(
+class [[F^oo]] {
+public:
+  [[F^oo]]() {}
+};
+
+class Baz {
+public:
+  operator [[F^oo]]() {
+return [[F^oo]]();
+  }
+};
+
+int main() {
+  Baz boo;
+  [[F^oo]] foo = static_cast<[[F^oo]]>(boo);
+}
+  )cpp",
   };
   llvm::StringRef NewName = "NewName";
   for (llvm::StringRef T : Tests) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D90750: [clangd] Introduce ProjectAwareIndex

2020-11-12 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 304795.
kadircet added a comment.

- Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90750

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/index/ProjectAware.cpp
  clang-tools-extra/clangd/index/ProjectAware.h
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/ProjectAwareIndexTests.cpp

Index: clang-tools-extra/clangd/unittests/ProjectAwareIndexTests.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/ProjectAwareIndexTests.cpp
@@ -0,0 +1,10 @@
+//===-- ProjectAwareIndexTests.cpp  ---*- C++ -*---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
Index: clang-tools-extra/clangd/unittests/CMakeLists.txt
===
--- clang-tools-extra/clangd/unittests/CMakeLists.txt
+++ clang-tools-extra/clangd/unittests/CMakeLists.txt
@@ -73,6 +73,7 @@
   PathMappingTests.cpp
   PreambleTests.cpp
   PrintASTTests.cpp
+  ProjectAwareIndexTests.cpp
   QualityTests.cpp
   RenameTests.cpp
   RIFFTests.cpp
Index: clang-tools-extra/clangd/index/ProjectAware.h
===
--- /dev/null
+++ clang-tools-extra/clangd/index/ProjectAware.h
@@ -0,0 +1,74 @@
+//===--- ProjectAware.h --*- C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_PROJECT_AWARE_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_PROJECT_AWARE_H
+
+#include "Config.h"
+#include "index/Index.h"
+#include "index/MemIndex.h"
+#include "index/Merge.h"
+#include "index/Serialization.h"
+#include "index/remote/Client.h"
+#include "support/Threading.h"
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringRef.h"
+#include 
+#include 
+#include 
+#include 
+#include 
+namespace clang {
+namespace clangd {
+
+class ProjectAwareIndex : public SymbolIndex {
+public:
+  size_t estimateMemoryUsage() const override;
+
+  /// Only queries the associated index with the current context.
+  void lookup(const LookupRequest &Req,
+  llvm::function_ref Callback) const override;
+
+  /// Query all indexes while prioritizing the associated one (if any).
+  bool refs(const RefsRequest &Req,
+llvm::function_ref Callback) const override;
+
+  /// Queries only the associates index when Req.RestrictForCodeCompletion is
+  /// set, otherwise queries all.
+  bool
+  fuzzyFind(const FuzzyFindRequest &Req,
+llvm::function_ref Callback) const override;
+
+  /// Query all indexes while prioritizing the associated one (if any).
+  void relations(const RelationsRequest &Req,
+ llvm::function_ref
+ Callback) const override;
+
+private:
+  // Returns the index associated with current context, if any.
+  SymbolIndex *getIndex() const;
+  // Adds the Idx into IndexStorage and adjusts the MergedIdx view. Returns a
+  // pointer to the Idx.
+  SymbolIndex *addIndex(std::unique_ptr Idx) const;
+  // Creates a view over all indexes, putting Primary at the top.
+  SymbolIndex *mergedView(SymbolIndex *Primary) const;
+
+  // Storage for all the external indexes.
+  Memoize> IndexForProject;
+  mutable std::mutex Mu;
+  mutable std::vector> IndexStorage;
+  mutable AsyncTaskRunner Tasks;
+  // Used for creating a merged view over all the indexes seen so far to ease
+  // querying them all at once.
+  mutable std::vector> MergedIdxStorage;
+};
+} // namespace clangd
+} // namespace clang
+
+#endif
Index: clang-tools-extra/clangd/index/ProjectAware.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/index/ProjectAware.cpp
@@ -0,0 +1,138 @@
+//===--- ProjectAware.h --*- C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "ProjectAware.h"
+#include "index/Index.h"
+#include "index/Merge.h"
+#include "index/Ref.h"
+#i

[PATCH] D91262: [AArch64][SVE] Allow C-style casts between fixed-size and scalable vectors

2020-11-12 Thread Joe Ellis via Phabricator via cfe-commits
joechrisellis updated this revision to Diff 304796.
joechrisellis marked 2 inline comments as done.
joechrisellis added a comment.

Address @c-rhodes's comments.

- Only allow casting between VLATs and VLSTs.
- Add C test.
- Move C++ test to the correct directory.
- Remove superfluous test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91262

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaCast.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Sema/aarch64-sve-explicit-casts-fixed-size.c
  clang/test/SemaCXX/aarch64-sve-explicit-casts-fixed-size.cpp

Index: clang/test/SemaCXX/aarch64-sve-explicit-casts-fixed-size.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/aarch64-sve-explicit-casts-fixed-size.cpp
@@ -0,0 +1,68 @@
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=128 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=256 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=512 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=1024 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=2048 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
+
+// expected-no-diagnostics
+
+#include 
+
+#define N __ARM_FEATURE_SVE_BITS
+#define FIXED_ATTR __attribute__((arm_sve_vector_bits(N)))
+
+typedef svfloat32_t fixed_float32_t FIXED_ATTR;
+typedef svfloat64_t fixed_float64_t FIXED_ATTR;
+typedef svint32_t fixed_int32_t FIXED_ATTR;
+typedef svint64_t fixed_int64_t FIXED_ATTR;
+
+// SVE VLSTs can be cast to SVE VLATs, regardless of lane size.
+// NOTE: the list below is NOT exhaustive for all SVE types.
+
+#define TESTCASE(from, to) \
+void from##_to_##to() {\
+from a;\
+to b;  \
+   \
+b = (to) a;\
+}
+
+TESTCASE(fixed_float32_t, svfloat32_t)
+TESTCASE(fixed_float32_t, svfloat64_t)
+TESTCASE(fixed_float32_t, svint32_t)
+TESTCASE(fixed_float32_t, svint64_t)
+
+TESTCASE(fixed_float64_t, svfloat32_t)
+TESTCASE(fixed_float64_t, svfloat64_t)
+TESTCASE(fixed_float64_t, svint32_t)
+TESTCASE(fixed_float64_t, svint64_t)
+
+TESTCASE(fixed_int32_t, svfloat32_t)
+TESTCASE(fixed_int32_t, svfloat64_t)
+TESTCASE(fixed_int32_t, svint32_t)
+TESTCASE(fixed_int32_t, svint64_t)
+
+TESTCASE(fixed_int64_t, svfloat32_t)
+TESTCASE(fixed_int64_t, svfloat64_t)
+TESTCASE(fixed_int64_t, svint32_t)
+TESTCASE(fixed_int64_t, svint64_t)
+
+TESTCASE(svfloat32_t, fixed_float32_t)
+TESTCASE(svfloat32_t, fixed_float64_t)
+TESTCASE(svfloat32_t, fixed_int32_t)
+TESTCASE(svfloat32_t, fixed_int64_t)
+
+TESTCASE(svfloat64_t, fixed_float32_t)
+TESTCASE(svfloat64_t, fixed_float64_t)
+TESTCASE(svfloat64_t, fixed_int32_t)
+TESTCASE(svfloat64_t, fixed_int64_t)
+
+TESTCASE(svint32_t, fixed_float32_t)
+TESTCASE(svint32_t, fixed_float64_t)
+TESTCASE(svint32_t, fixed_int32_t)
+TESTCASE(svint32_t, fixed_int64_t)
+
+TESTCASE(svint64_t, fixed_float32_t)
+TESTCASE(svint64_t, fixed_float64_t)
+TESTCASE(svint64_t, fixed_int32_t)
+TESTCASE(svint64_t, fixed_int64_t)
Index: clang/test/Sema/aarch64-sve-explicit-casts-fixed-size.c
===
--- /dev/null
+++ clang/test/Sema/aarch64-sve-explicit-casts-fixed-size.c
@@ -0,0 +1,68 @@
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=128 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=256 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=512 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=1024 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=2048 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
+
+// expected-no

[PATCH] D91262: [AArch64][SVE] Allow C-style casts between fixed-size and scalable vectors

2020-11-12 Thread Joe Ellis via Phabricator via cfe-commits
joechrisellis added inline comments.



Comment at: clang/lib/Sema/SemaCast.cpp:-2227
+// Allow bitcasting if either the source or destination is a scalable
+// vector.
+if (SrcType->isSizelessBuiltinType() || DestType->isSizelessBuiltinType()) 
{
+  Kind = CK_BitCast;
+  return TC_Success;
+}

c-rhodes wrote:
> This is a bit ambiguous, it'll allow bitcasting between things like a fixed 
> predicate and any sizeless type which I don't think makes sense. I think 
> it'll also allow bitcasting between any scalable and GNU vectors regardless 
> of vector length, e.g.:
> 
> ```
> typedef int32_t int32x4_t __attribute__((vector_size(16)));
> 
> void foo() {
> svint32_t s32;
> int32x4_t g32;
> g32 = (int32x4_t)s32;
> s32 = (svint32_t)g32;
> }
> ```
> 
> the above should only work when `-msve-vector-bits=128` but will currently be 
> allowed for any N.
Ah, you're dead right. I think the next diff should fix this, but if there are 
any more inconsistencies/ambiguities I'll fix them too. :) 



Comment at: clang/test/Sema/aarch64-sve-explicit-casts.cpp:1-36
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve 
-msve-vector-bits=512 -flax-vector-conversions=none 
-fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
+
+#include 
+
+// SVE types cannot be C-style casted to one another.
+// "To avoid any ambiguity [between the two operations], the ACLE does not 
allow C-style casting from one
+// vector type to another." ~ACLE Section 3.4 (Vector Types)

c-rhodes wrote:
> `clang/test/SemaCXX/sizeless-1.cpp` already contains a test checking C-style 
> casts between distinct sizeless types aren't supported, I'm not sure if 
> adding this is necessary.
ACK -- removed. :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91262

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


[PATCH] D91311: Add new 'preferred_name' attribute.

2020-11-12 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

I really like this attribute, thank you for working on this!




Comment at: clang/include/clang/Basic/Attr.td:2367
+def PreferredName : InheritableAttr {
+  let Spellings = [Clang<"preferred_name">];
+  let Subjects = SubjectList<[ClassTmpl]>;

This seems like one we should exempt from C code, WDYT? If you agree, you can 
change it to `Clang<"preferred_name", /*AllowInC*/ 0>`



Comment at: clang/include/clang/Basic/Attr.td:2369
+  let Subjects = SubjectList<[ClassTmpl]>;
+  let Args = [TypeArgument<"TypedefType">];
+  let Documentation = [PreferredNameDocs];

Would it make sense for this to be a variadic parameter of type arguments (with 
a constraint that at least one type be named)? This way you can write: 
`[[clang::preferred_name(string, wstring)]]` instead of 
`[[clang::preferred_name(string), clang::preferred_name(wstring)]]`



Comment at: clang/include/clang/Basic/AttrDocs.td:4398
+
+The preferred name must be a typedef declaration that refers to a
+specialization of the class template. In general this requires the template to

May want to be clear that this includes alias declarations as well as typedefs 
(the example helps though). Also, you should mention that the typedef cannot 
include qualifiers.



Comment at: clang/lib/AST/TypePrinter.cpp:1353
+  // Print the preferred name if we have one for this type.
+  for (PreferredNameAttr *PNA :
+   T->getDecl()->specific_attrs()) {

`const auto *`?



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:1394
+
+  if (!T->getAs() || T.hasQualifiers()) {
+S.Diag(AL.getLoc(), diag::err_attribute_preferred_name_arg_invalid)

Given that this is checking properties of the type used in the attribute, I 
wonder if it makes sense to note the original declaration. I left a note on a 
test case below about this.



Comment at: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp:557
+  // template.
+  if (auto *PNA = dyn_cast(A)) {
+QualType T = PNA->getTypedefType();

Can you fix these two lint warnings?



Comment at: clang/test/SemaTemplate/attributes.cpp:79
+  template struct [[clang::preferred_name(const X)]] C; // 
expected-error {{argument 'const preferred_name::X'}}
+  template struct [[clang::preferred_name(Z)]] C; // 
expected-error {{argument 'preferred_name::Z' (aka 'const C')}}
+  template struct C {};

This looks like a pretty reasonable declaration but only fails because of an 
issue with the declaration of `Z` -- should we point out more explicitly that 
the qualifier on the alias declaration is the issue?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91311

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


[clang] 79105e4 - [clang-scan-deps] Fix for input file given as relative path in compilation database "command" entry.

2020-11-12 Thread Sylvain Audi via cfe-commits

Author: Sylvain Audi
Date: 2020-11-12T08:48:17-05:00
New Revision: 79105e464429d2220c81b38bf5339b9c41da1d21

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

LOG: [clang-scan-deps] Fix for input file given as relative path in compilation 
database "command" entry.

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

Added: 
clang/test/ClangScanDeps/Inputs/relative_directory.json
clang/test/ClangScanDeps/relative_directory.cpp

Modified: 
clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp

Removed: 




diff  --git a/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp 
b/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
index 32bbc578d2db..f10b60252715 100644
--- a/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
+++ b/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
@@ -44,28 +44,6 @@ class DependencyConsumerForwarder : public 
DependencyFileGenerator {
   DependencyConsumer &C;
 };
 
-/// A proxy file system that doesn't call `chdir` when changing the working
-/// directory of a clang tool.
-class ProxyFileSystemWithoutChdir : public llvm::vfs::ProxyFileSystem {
-public:
-  ProxyFileSystemWithoutChdir(
-  llvm::IntrusiveRefCntPtr FS)
-  : ProxyFileSystem(std::move(FS)) {}
-
-  llvm::ErrorOr getCurrentWorkingDirectory() const override {
-assert(!CWD.empty() && "empty CWD");
-return CWD;
-  }
-
-  std::error_code setCurrentWorkingDirectory(const Twine &Path) override {
-CWD = Path.str();
-return {};
-  }
-
-private:
-  std::string CWD;
-};
-
 /// A clang tool that runs the preprocessor in a mode that's optimized for
 /// dependency scanning for the given compiler invocation.
 class DependencyScanningAction : public tooling::ToolAction {
@@ -176,7 +154,7 @@ DependencyScanningWorker::DependencyScanningWorker(
 : Format(Service.getFormat()) {
   DiagOpts = new DiagnosticOptions();
   PCHContainerOps = std::make_shared();
-  RealFS = new ProxyFileSystemWithoutChdir(llvm::vfs::getRealFileSystem());
+  RealFS = llvm::vfs::createPhysicalFileSystem().release();
   if (Service.canSkipExcludedPPRanges())
 PPSkipMappings =
 std::make_unique();

diff  --git a/clang/test/ClangScanDeps/Inputs/relative_directory.json 
b/clang/test/ClangScanDeps/Inputs/relative_directory.json
new file mode 100644
index ..ae3d16150bea
--- /dev/null
+++ b/clang/test/ClangScanDeps/Inputs/relative_directory.json
@@ -0,0 +1,12 @@
+[
+{
+  "directory": "DIR",
+  "command": "clang -E Inputs/relative_directory_input1.cpp -IInputs",
+  "file": "DIR/Inputs/relative_directory_input1.cpp"
+},
+{
+  "directory": "DIR/Inputs",
+  "command": "clang -E relative_directory_input2.cpp -I.",
+  "file": "DIR/Inputs/relative_directory_input2.cpp"
+}
+]

diff  --git a/clang/test/ClangScanDeps/relative_directory.cpp 
b/clang/test/ClangScanDeps/relative_directory.cpp
new file mode 100644
index ..bf5cf91a2f7b
--- /dev/null
+++ b/clang/test/ClangScanDeps/relative_directory.cpp
@@ -0,0 +1,25 @@
+// RUN: rm -rf %t.dir
+// RUN: rm -rf %t.cdb
+// RUN: mkdir -p %t.dir
+// RUN: mkdir %t.dir/Inputs
+// RUN: cp %s %t.dir/Inputs/relative_directory_input1.cpp
+// RUN: cp %s %t.dir/Inputs/relative_directory_input2.cpp
+// RUN: touch %t.dir/Inputs/header.h
+// RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/relative_directory.json > %t.cdb
+//
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 1 | FileCheck 
--check-prefixes=CHECK1,CHECK2 %s
+
+// The output order is non-deterministic when using more than one thread,
+// so check the output using two runs.
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 2 | FileCheck 
--check-prefix=CHECK1 %s
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 2 | FileCheck 
--check-prefix=CHECK2 %s
+
+#include 
+
+// CHECK1: relative_directory_input1.o:
+// CHECK1-NEXT: relative_directory_input1.cpp
+// CHECK1-NEXT: header.h
+
+// CHECK2: relative_directory_input2.o:
+// CHECK2-NEXT: relative_directory_input2.cpp
+// CHECK2-NEXT: header.h



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


[PATCH] D91204: [clang-scan-deps] Fix for input file given as relative path in compilation database "command" entry

2020-11-12 Thread Sylvain Audi via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG79105e464429: [clang-scan-deps] Fix for input file given as 
relative path in compilation… (authored by saudi).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91204

Files:
  clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
  clang/test/ClangScanDeps/Inputs/relative_directory.json
  clang/test/ClangScanDeps/relative_directory.cpp


Index: clang/test/ClangScanDeps/relative_directory.cpp
===
--- /dev/null
+++ clang/test/ClangScanDeps/relative_directory.cpp
@@ -0,0 +1,25 @@
+// RUN: rm -rf %t.dir
+// RUN: rm -rf %t.cdb
+// RUN: mkdir -p %t.dir
+// RUN: mkdir %t.dir/Inputs
+// RUN: cp %s %t.dir/Inputs/relative_directory_input1.cpp
+// RUN: cp %s %t.dir/Inputs/relative_directory_input2.cpp
+// RUN: touch %t.dir/Inputs/header.h
+// RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/relative_directory.json > %t.cdb
+//
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 1 | FileCheck 
--check-prefixes=CHECK1,CHECK2 %s
+
+// The output order is non-deterministic when using more than one thread,
+// so check the output using two runs.
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 2 | FileCheck 
--check-prefix=CHECK1 %s
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 2 | FileCheck 
--check-prefix=CHECK2 %s
+
+#include 
+
+// CHECK1: relative_directory_input1.o:
+// CHECK1-NEXT: relative_directory_input1.cpp
+// CHECK1-NEXT: header.h
+
+// CHECK2: relative_directory_input2.o:
+// CHECK2-NEXT: relative_directory_input2.cpp
+// CHECK2-NEXT: header.h
Index: clang/test/ClangScanDeps/Inputs/relative_directory.json
===
--- /dev/null
+++ clang/test/ClangScanDeps/Inputs/relative_directory.json
@@ -0,0 +1,12 @@
+[
+{
+  "directory": "DIR",
+  "command": "clang -E Inputs/relative_directory_input1.cpp -IInputs",
+  "file": "DIR/Inputs/relative_directory_input1.cpp"
+},
+{
+  "directory": "DIR/Inputs",
+  "command": "clang -E relative_directory_input2.cpp -I.",
+  "file": "DIR/Inputs/relative_directory_input2.cpp"
+}
+]
Index: clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
@@ -44,28 +44,6 @@
   DependencyConsumer &C;
 };
 
-/// A proxy file system that doesn't call `chdir` when changing the working
-/// directory of a clang tool.
-class ProxyFileSystemWithoutChdir : public llvm::vfs::ProxyFileSystem {
-public:
-  ProxyFileSystemWithoutChdir(
-  llvm::IntrusiveRefCntPtr FS)
-  : ProxyFileSystem(std::move(FS)) {}
-
-  llvm::ErrorOr getCurrentWorkingDirectory() const override {
-assert(!CWD.empty() && "empty CWD");
-return CWD;
-  }
-
-  std::error_code setCurrentWorkingDirectory(const Twine &Path) override {
-CWD = Path.str();
-return {};
-  }
-
-private:
-  std::string CWD;
-};
-
 /// A clang tool that runs the preprocessor in a mode that's optimized for
 /// dependency scanning for the given compiler invocation.
 class DependencyScanningAction : public tooling::ToolAction {
@@ -176,7 +154,7 @@
 : Format(Service.getFormat()) {
   DiagOpts = new DiagnosticOptions();
   PCHContainerOps = std::make_shared();
-  RealFS = new ProxyFileSystemWithoutChdir(llvm::vfs::getRealFileSystem());
+  RealFS = llvm::vfs::createPhysicalFileSystem().release();
   if (Service.canSkipExcludedPPRanges())
 PPSkipMappings =
 std::make_unique();


Index: clang/test/ClangScanDeps/relative_directory.cpp
===
--- /dev/null
+++ clang/test/ClangScanDeps/relative_directory.cpp
@@ -0,0 +1,25 @@
+// RUN: rm -rf %t.dir
+// RUN: rm -rf %t.cdb
+// RUN: mkdir -p %t.dir
+// RUN: mkdir %t.dir/Inputs
+// RUN: cp %s %t.dir/Inputs/relative_directory_input1.cpp
+// RUN: cp %s %t.dir/Inputs/relative_directory_input2.cpp
+// RUN: touch %t.dir/Inputs/header.h
+// RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/relative_directory.json > %t.cdb
+//
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 1 | FileCheck --check-prefixes=CHECK1,CHECK2 %s
+
+// The output order is non-deterministic when using more than one thread,
+// so check the output using two runs.
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 2 | FileCheck --check-prefix=CHECK1 %s
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 2 | FileCheck --check-prefix=CHECK2 %s
+
+#include 
+
+// CHECK1: relative_directory_input1.o:
+// CHECK1-NEXT: relative_directory_input1.cpp
+// CHECK1-NEXT: header.h
+
+// CHECK2: relative_directory_input2.o:
+// CHECK2-NEXT: relative_directory_input2.cpp
+// CHECK2-NEXT: header.h
Index: clang/test/ClangScanDeps/Input

[PATCH] D91341: [clangd][NFC] Don't store symbolmap on the heap

2020-11-12 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added a reviewer: hokein.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman.
Herald added a project: clang.
njames93 requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

Storing this on the heap doesn't make any sense. Just an extra allocation(and 
for Rename, indirection) thats not needed.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91341

Files:
  clang-tools-extra/clangd/index/CanonicalIncludes.cpp
  clang-tools-extra/clangd/refactor/Rename.cpp


Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -105,12 +105,12 @@
   if (isProtoFile(RenameDecl.getLocation(),
   RenameDecl.getASTContext().getSourceManager()))
 return true;
-  static const auto *StdSymbols = new llvm::DenseSet({
+  static const llvm::DenseSet StdSymbols = {
 #define SYMBOL(Name, NameSpace, Header) {#NameSpace #Name},
 #include "StdSymbolMap.inc"
 #undef SYMBOL
-  });
-  return StdSymbols->count(printQualifiedName(RenameDecl));
+  };
+  return StdSymbols.contains(printQualifiedName(RenameDecl));
 }
 
 enum class ReasonToReject {
Index: clang-tools-extra/clangd/index/CanonicalIncludes.cpp
===
--- clang-tools-extra/clangd/index/CanonicalIncludes.cpp
+++ clang-tools-extra/clangd/index/CanonicalIncludes.cpp
@@ -87,21 +87,21 @@
 
 void CanonicalIncludes::addSystemHeadersMapping(const LangOptions &Language) {
   if (Language.CPlusPlus) {
-static const auto *Symbols = new llvm::StringMap({
+static const llvm::StringMap Symbols{
 #define SYMBOL(Name, NameSpace, Header) {#NameSpace #Name, #Header},
 #include "StdSymbolMap.inc"
 // There are two std::move()s, this is by far the most common.
 SYMBOL(move, std::, )
 #undef SYMBOL
-});
-StdSymbolMapping = Symbols;
+};
+StdSymbolMapping = &Symbols;
   } else if (Language.C11) {
-static const auto *CSymbols = new llvm::StringMap({
+static const llvm::StringMap CSymbols{
 #define SYMBOL(Name, NameSpace, Header) {#Name, #Header},
 #include "CSymbolMap.inc"
 #undef SYMBOL
-});
-StdSymbolMapping = CSymbols;
+};
+StdSymbolMapping = &CSymbols;
   }
 
   // FIXME: remove the std header mapping once we support ambiguous symbols, 
now


Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -105,12 +105,12 @@
   if (isProtoFile(RenameDecl.getLocation(),
   RenameDecl.getASTContext().getSourceManager()))
 return true;
-  static const auto *StdSymbols = new llvm::DenseSet({
+  static const llvm::DenseSet StdSymbols = {
 #define SYMBOL(Name, NameSpace, Header) {#NameSpace #Name},
 #include "StdSymbolMap.inc"
 #undef SYMBOL
-  });
-  return StdSymbols->count(printQualifiedName(RenameDecl));
+  };
+  return StdSymbols.contains(printQualifiedName(RenameDecl));
 }
 
 enum class ReasonToReject {
Index: clang-tools-extra/clangd/index/CanonicalIncludes.cpp
===
--- clang-tools-extra/clangd/index/CanonicalIncludes.cpp
+++ clang-tools-extra/clangd/index/CanonicalIncludes.cpp
@@ -87,21 +87,21 @@
 
 void CanonicalIncludes::addSystemHeadersMapping(const LangOptions &Language) {
   if (Language.CPlusPlus) {
-static const auto *Symbols = new llvm::StringMap({
+static const llvm::StringMap Symbols{
 #define SYMBOL(Name, NameSpace, Header) {#NameSpace #Name, #Header},
 #include "StdSymbolMap.inc"
 // There are two std::move()s, this is by far the most common.
 SYMBOL(move, std::, )
 #undef SYMBOL
-});
-StdSymbolMapping = Symbols;
+};
+StdSymbolMapping = &Symbols;
   } else if (Language.C11) {
-static const auto *CSymbols = new llvm::StringMap({
+static const llvm::StringMap CSymbols{
 #define SYMBOL(Name, NameSpace, Header) {#Name, #Header},
 #include "CSymbolMap.inc"
 #undef SYMBOL
-});
-StdSymbolMapping = CSymbols;
+};
+StdSymbolMapping = &CSymbols;
   }
 
   // FIXME: remove the std header mapping once we support ambiguous symbols, now
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91184: [clang-tidy] Merge options inplace instead of copying

2020-11-12 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/D91184/new/

https://reviews.llvm.org/D91184

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


[PATCH] D89031: [SVE] Add support to vectorize_width loop pragma for scalable vectors

2020-11-12 Thread David Sherwood via Phabricator via cfe-commits
david-arm added a comment.

Hi @SjoerdMeijer I think that given we now support scalable vectors we thought 
it made sense to be able to specify whether the user wants 'fixed' or 
'scalable' vectorisation along with the vector width, although without 
specifying the additional property the default continues to remain 'fixed'. 
However, what you said about having a vectorize_scalable pragma is correct and 
we are intending to also add a pragma like this in a future patch.


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

https://reviews.llvm.org/D89031

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


[PATCH] D91342: WIP: Frontend: Handle PreprocessorOptions::RemappedFiles in createVFSFromCompilerInvocation

2020-11-12 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith created this revision.
dexonsmith added reviewers: JDevlieghere, jansvoboda11, akyrtzi.
Herald added a subscriber: ributzka.
dexonsmith requested review of this revision.

Instead of threading `PreprocessorOptions::RemappedFiles` through to the
`SourceManager`, handle it in `createVFSFromCompilerInvocation`.

I've also removed some of the now-dead code from `SourceManager`. I'll
leave unifying `ContentCache::OrigEntry` and
`ContentCache::ContentsEntry` for follow ups, since otherwise there'll
be a lot of noise here.

WIP: Currently I have hacked clang/test/PCH/remap-file-from-pch.cpp to
get it to pass, but probably the right thing is to write a prep patch
that reimplements the following fishy code in ASTReader from
6eec06d0d4fa2e108546b422619c6cb32f234e6e (maybe sending a list of files
that should trigger this behaviour through `PreprocessorOptions`?), not
necessarily keeping the exact same semantics.

  // Check if there was a request to override the contents of the file
  // that was part of the precompiled header. Overriding such a file
  // can lead to problems when lexing using the source locations from the
  // PCH.
  SourceManager &SM = getSourceManager();
  // FIXME: Reject if the overrides are different.
  if ((!Overridden && !Transient) && SM.isFileOverridden(File)) {
if (Complain)
  Error(diag::err_fe_pch_file_overridden, Filename);
  
// After emitting the diagnostic, bypass the overriding file to recover
// (this creates a separate FileEntry).
File = SM.bypassFileContentsOverride(*File);
if (!File) {
  F.InputFilesLoaded[ID - 1] = InputFile::getNotFound();
  return InputFile();
}
  }


https://reviews.llvm.org/D91342

Files:
  clang/include/clang/Basic/SourceManager.h
  clang/lib/Basic/SourceManager.cpp
  clang/lib/Frontend/ASTUnit.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/PrecompiledPreamble.cpp
  clang/test/PCH/remap-file-from-pch.cpp

Index: clang/test/PCH/remap-file-from-pch.cpp
===
--- clang/test/PCH/remap-file-from-pch.cpp
+++ clang/test/PCH/remap-file-from-pch.cpp
@@ -1,10 +1,18 @@
-//  %clang_cc1 -remap-file "%s;%S/Inputs/remapped-file" -fsyntax-only %s 2>&1 | FileCheck -check-prefix=CHECK-EXIST %s
-
 // RUN: %clang_cc1 -x c++-header %s.h -emit-pch -o %t.pch
-// RUN: not %clang_cc1 %s -include-pch %t.pch -remap-file "%s.h;%s.remap.h" -fsyntax-only 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 %s -include-pch %t.pch -fsyntax-only 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=NO-REMAP
+// RUN: not %clang_cc1 %s -include-pch %t.pch -remap-file "%s.h;%s.remap.h" -fsyntax-only 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=MISMATCH
+//
+// RUN: %clang_cc1 -x c++-header -remap-file "%s.h;%s.remap.h" %s.h -emit-pch -o %t-remapped.pch
+// RUN: %clang_cc1 %s -include-pch %t-remapped.pch -remap-file "%s.h;%s.remap.h" -fsyntax-only 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=REMAP -allow-empty
+// RUN: not %clang_cc1 %s -include-pch %t-remapped.pch -fsyntax-only 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=MISMATCH
 
 const char *str = STR;
 int ge = zool;
 
-// CHECK: file '{{.*[/\\]}}remap-file-from-pch.cpp.h' from the precompiled header has been overridden
-// CHECK: use of undeclared identifier 'zool'
+// MISMATCH: file '{{.*[/\\]}}remap-file-from-pch.cpp.h' has been modified since the precompiled header
+// NO-REMAP: use of undeclared identifier 'zool'
+// REMAP-NOT: use of undeclared identifier
Index: clang/lib/Frontend/PrecompiledPreamble.cpp
===
--- clang/lib/Frontend/PrecompiledPreamble.cpp
+++ clang/lib/Frontend/PrecompiledPreamble.cpp
@@ -534,21 +534,6 @@
   // remapping or unsaved_files.
   std::map OverriddenFiles;
   llvm::StringSet<> OverriddenAbsPaths; // Either by buffers or files.
-  for (const auto &R : PreprocessorOpts.RemappedFiles) {
-llvm::vfs::Status Status;
-if (!moveOnNoError(VFS.status(R.second), Status)) {
-  // If we can't stat the file we're remapping to, assume that something
-  // horrible happened.
-  return false;
-}
-// If a mapped file was previously missing, then it has changed.
-llvm::SmallString<128> MappedPath(R.first);
-if (!VFS.makeAbsolute(MappedPath))
-  OverriddenAbsPaths.insert(MappedPath);
-
-OverriddenFiles[Status.getUniqueID()] = PreambleFileHash::createForFile(
-Status.getSize(), llvm::sys::toTimeT(Status.getLastModificationTime()));
-  }
 
   // OverridenFileBuffers tracks only the files not found in VFS.
   llvm::StringMap OverridenFileBuffers;
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -4057,11 +4057,27 @@
   return Result;
 }
 
+static IntrusiveRefCntPtr
+addRemappedFiles(const Compi

[PATCH] D91067: [AArch64][SVE] Support implicit lax vector conversions for SVE types

2020-11-12 Thread Joe Ellis via Phabricator via cfe-commits
joechrisellis updated this revision to Diff 304811.
joechrisellis marked an inline comment as done.
joechrisellis added a comment.

- Support C lax vector conversions.
- Test C lax vector conversions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91067

Files:
  clang/include/clang/AST/ASTContext.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/Sema/aarch64-sve-lax-vector-conversions.c
  clang/test/SemaCXX/aarch64-sve-lax-vector-conversions.cpp

Index: clang/test/SemaCXX/aarch64-sve-lax-vector-conversions.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/aarch64-sve-lax-vector-conversions.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=512 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify=lax-vector-none %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=512 -flax-vector-conversions=integer -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify=lax-vector-integer %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=512 -flax-vector-conversions=all -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify=lax-vector-all %s
+
+// lax-vector-all-no-diagnostics
+
+#include 
+
+#define N __ARM_FEATURE_SVE_BITS
+#define FIXED_ATTR __attribute__((arm_sve_vector_bits(N)))
+
+typedef svfloat32_t fixed_float32_t FIXED_ATTR;
+typedef svint32_t fixed_int32_t FIXED_ATTR;
+
+void allowed_with_integer_lax_conversions() {
+  fixed_int32_t fi32;
+  svint64_t si64;
+
+  // The implicit cast here should fail if -flax-vector-conversions=none, but pass if
+  // -flax-vector-conversions={integer,all}.
+  fi32 = si64;
+  // lax-vector-none-error@-1 {{assigning to 'fixed_int32_t' (vector of 16 'int' values) from incompatible type}}
+}
+
+void allowed_with_all_lax_conversions() {
+  fixed_float32_t ff32;
+  svfloat64_t sf64;
+
+  // The implicit cast here should fail if -flax-vector-conversions={none,integer}, but pass if
+  // -flax-vector-conversions=all.
+  ff32 = sf64;
+  // lax-vector-none-error@-1 {{assigning to 'fixed_float32_t' (vector of 16 'float' values) from incompatible type}}
+  // lax-vector-integer-error@-2 {{assigning to 'fixed_float32_t' (vector of 16 'float' values) from incompatible type}}
+}
Index: clang/test/Sema/aarch64-sve-lax-vector-conversions.c
===
--- /dev/null
+++ clang/test/Sema/aarch64-sve-lax-vector-conversions.c
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=512 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify=lax-vector-none %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=512 -flax-vector-conversions=integer -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify=lax-vector-integer %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=512 -flax-vector-conversions=all -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify=lax-vector-all %s
+
+// lax-vector-all-no-diagnostics
+
+#include 
+
+#define N __ARM_FEATURE_SVE_BITS
+#define FIXED_ATTR __attribute__((arm_sve_vector_bits(N)))
+
+typedef svfloat32_t fixed_float32_t FIXED_ATTR;
+typedef svint32_t fixed_int32_t FIXED_ATTR;
+
+void allowed_with_integer_lax_conversions() {
+  fixed_int32_t fi32;
+  svint64_t si64;
+
+  // The implicit cast here should fail if -flax-vector-conversions=none, but pass if
+  // -flax-vector-conversions={integer,all}.
+  fi32 = si64;
+  // lax-vector-none-error@-1 {{assigning to 'fixed_int32_t' (vector of 16 'int' values) from incompatible type}}
+}
+
+void allowed_with_all_lax_conversions() {
+  fixed_float32_t ff32;
+  svfloat64_t sf64;
+
+  // The implicit cast here should fail if -flax-vector-conversions={none,integer}, but pass if
+  // -flax-vector-conversions=all.
+  ff32 = sf64;
+  // lax-vector-none-error@-1 {{assigning to 'fixed_float32_t' (vector of 16 'float' values) from incompatible type}}
+  // lax-vector-integer-error@-2 {{assigning to 'fixed_float32_t' (vector of 16 'float' values) from incompatible type}}
+}
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -1644,11 +1644,12 @@
 }
   }
 
-  if ((ToType->isSizelessBuiltinType() || FromType->isSizelessBuiltinType()) &&
-  S.Context.areCompatibleSveTypes(FromType, ToType)) {
-ICK = ICK_SVE_Vector_Conversion;
-return true;
-  }
+  if (ToType->isSizelessBuiltinType() || FromType->isSizelessBuilti

[PATCH] D91300: WIP: Frontend: Use an InMemoryFileSystem for the RemappedFiles parameter in ASTUnit

2020-11-12 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

Note, I just discovered this patch changes behaviour in the ASTReader that was 
only indirectly tested previously via the file-to-file remapping command-line 
options. I've blocked this on https://reviews.llvm.org/D91342 for now, since 
that patch reimplements the file-to-file remapping, and whatever we figure out 
for updating that test should apply here too.


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

https://reviews.llvm.org/D91300

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


[PATCH] D90622: clang: Don't assert on no_unique_address fields in @encode()

2020-11-12 Thread Nico Weber via Phabricator via cfe-commits
thakis added inline comments.



Comment at: clang/test/CodeGenObjCXX/encode.mm:91
 
-  // CHECK: @_ZN11rdar93574002ggE = constant [49 x i8] c"{vector >=[4f]}\00"
+  // FIXME: This difference is due to D76801. It was probably an unintentional 
change. Maybe we want to undo it?
+  // CHECKCXX98: @_ZN11rdar93574002ggE = constant [49 x i8] c"{vector >=[4f]}\00"

Raised this part on cfe-dev here: 
http://lists.llvm.org/pipermail/cfe-dev/2020-November/067188.html


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

https://reviews.llvm.org/D90622

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


[PATCH] D90042: [clang-tidy] performance-unnecessary-copy-initialization: Check for const reference arguments that are replaced template parameter type.

2020-11-12 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D90042#2390203 , @flx wrote:

> Thanks for the suggestion, I had never hear of creduce!

Glad to have introduced you to it -- it's a great tool!

> After a bit of trial an error I seem to have found a more minimal example:
>
>   namespace std { 
>  
>   template  class function; 
>  
>   template  class function {  
>  
>   public: 
>  
> void operator()(b...);
>  
>   };  
>  
>   } // namespace std  
>  
>   struct c {  
>  
> c();  
>  
> c(const c &); 
>  
>   };  
>  
>   std::function f; 
>  
>   void d() {  
>  
> c Orig;   
>  
> c Copy = Orig;
>  
> f(Copy);  
>  
>   }  
>
>
> To be frank I can't spot a meaningful difference to the std::function copy we 
> already have.

Aha, I may have spotted it. The call operators have subtly different signatures 
and the signature we have in our test file is wrong. Note the `&&` in our test 
file compared to what the standard defines: 
http://eel.is/c++draft/func.wrap.func#inv which is what's causing the 
difference here: https://godbolt.org/z/hxfM7P


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90042

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


[PATCH] D89031: [SVE] Add support to vectorize_width loop pragma for scalable vectors

2020-11-12 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added a comment.

In D89031#2391160 , @david-arm wrote:

> Hi @SjoerdMeijer I think that given we now support scalable vectors we 
> thought it made sense to be able to specify whether the user wants 'fixed' or 
> 'scalable' vectorisation along with the vector width, although without 
> specifying the additional property the default continues to remain 'fixed'. 
> However, what you said about having a vectorize_scalable pragma is correct 
> and we are intending to also add a pragma like this in a future patch.

Okay, I haven't looked at the implementation to be honest, but am just trying 
to understand the different use cases of this first.
I just seem to be missing or not understanding why fixed/scalable is an option 
to only vectorize_width, why not to vectorize(enable) or just a separate one 
like vectorize_scalable? By making scalable/fixed and option to 
vectorize_width, you can't toggle this for other pragmas like 
interleave(enable) that enable vectorisation, which would be inconsistent? It 
also seems to be more work to me to do this first for vectorize_width, and then 
fix up other pragmas later. But I might be missing something (obivous) here.


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

https://reviews.llvm.org/D89031

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


[PATCH] D91348: [OpenCL] Warn about side effects for unevaluated vec_step arg

2020-11-12 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh created this revision.
svenvh added a reviewer: Anastasia.
Herald added a subscriber: yaxunl.
Herald added a project: clang.
svenvh requested review of this revision.

The argument to the `vec_step` builtin is not evaluated.  Hoist the
diagnostic for this in `Sema::CheckUnaryExprOrTypeTraitOperand` such
that it comes before `Sema::CheckVecStepTraitOperandType`.

A minor side-effect of this change is that it also produces the
warning for `co_await` and `co_yield` now.

Associated spec clarification: 
https://github.com/KhronosGroup/OpenCL-Docs/pull/481


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91348

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/test/SemaCXX/coroutines.cpp


Index: clang/test/SemaCXX/coroutines.cpp
===
--- clang/test/SemaCXX/coroutines.cpp
+++ clang/test/SemaCXX/coroutines.cpp
@@ -328,6 +328,7 @@
 // expected-warning@-1 {{declaration does not declare 
anything}}
   sizeof(co_await a); // expected-error {{'co_await' cannot be used in an 
unevaluated context}}
   // expected-error@-1 {{invalid application of 'sizeof' 
to an incomplete type 'void'}}
+  // expected-warning@-2 {{expression with side effects 
has no effect in an unevaluated context}}
   typeid(co_await a); // expected-error {{'co_await' cannot be used in an 
unevaluated context}}
   // expected-warning@-1 {{expression with side effects 
has no effect in an unevaluated context}}
   // expected-warning@-2 {{expression result unused}}
@@ -335,6 +336,7 @@
 // expected-warning@-1 {{declaration does not declare 
anything}}
   sizeof(co_yield 2); // expected-error {{'co_yield' cannot be used in an 
unevaluated context}}
   // expected-error@-1 {{invalid application of 'sizeof' 
to an incomplete type 'void'}}
+  // expected-warning@-2 {{expression with side effects 
has no effect in an unevaluated context}}
   typeid(co_yield 3); // expected-error {{'co_yield' cannot be used in an 
unevaluated context}}
   // expected-warning@-1 {{expression with side effects 
has no effect in an unevaluated context}}
   // expected-warning@-2 {{expression result unused}}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -4027,7 +4027,7 @@
 
   bool IsUnevaluatedOperand =
   (ExprKind == UETT_SizeOf || ExprKind == UETT_AlignOf ||
-   ExprKind == UETT_PreferredAlignOf);
+   ExprKind == UETT_PreferredAlignOf || ExprKind == UETT_VecStep);
   if (IsUnevaluatedOperand) {
 ExprResult Result = CheckUnevaluatedOperand(E);
 if (Result.isInvalid())
@@ -4035,6 +4035,12 @@
 E = Result.get();
   }
 
+  // The operand for sizeof and alignof is in an unevaluated expression 
context,
+  // so side effects could result in unintended consequences.
+  if (IsUnevaluatedOperand && !inTemplateInstantiation() &&
+  E->HasSideEffects(Context, false))
+Diag(E->getExprLoc(), diag::warn_side_effects_unevaluated_context);
+
   if (ExprKind == UETT_VecStep)
 return CheckVecStepTraitOperandType(*this, ExprTy, E->getExprLoc(),
 E->getSourceRange());
@@ -4071,12 +4077,6 @@
 return true;
   }
 
-  // The operand for sizeof and alignof is in an unevaluated expression 
context,
-  // so side effects could result in unintended consequences.
-  if (IsUnevaluatedOperand && !inTemplateInstantiation() &&
-  E->HasSideEffects(Context, false))
-Diag(E->getExprLoc(), diag::warn_side_effects_unevaluated_context);
-
   if (CheckObjCTraitOperandConstraints(*this, ExprTy, E->getExprLoc(),
E->getSourceRange(), ExprKind))
 return true;


Index: clang/test/SemaCXX/coroutines.cpp
===
--- clang/test/SemaCXX/coroutines.cpp
+++ clang/test/SemaCXX/coroutines.cpp
@@ -328,6 +328,7 @@
 // expected-warning@-1 {{declaration does not declare anything}}
   sizeof(co_await a); // expected-error {{'co_await' cannot be used in an unevaluated context}}
   // expected-error@-1 {{invalid application of 'sizeof' to an incomplete type 'void'}}
+  // expected-warning@-2 {{expression with side effects has no effect in an unevaluated context}}
   typeid(co_await a); // expected-error {{'co_await' cannot be used in an unevaluated context}}
   // expected-warning@-1 {{expression with side effects has no effect in an unevaluated context}}
   // expected-warning@-2 {{expression result unused}}
@@ -335,6 +336,7 @@
 // expected-warning@-1 {{declaration does not declare anything}}
   sizeof(co_yield 

[PATCH] D91350: [VE] Disable -fsigaddr option for VE

2020-11-12 Thread Kazushi Marukawa via Phabricator via cfe-commits
kaz7 created this revision.
kaz7 added reviewers: simoll, k-ishizaka.
kaz7 added projects: clang, VE.
Herald added a subscriber: cfe-commits.
kaz7 requested review of this revision.

VE needs to support integrated assembler and "nas".  This "nas"
doesn't recognize ".sigaddr" pseudo mnemonics, so need to disable
it.  This patch disable it on VE by default.  Also add a regression
test for that.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91350

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/ve-toolchain.c


Index: clang/test/Driver/ve-toolchain.c
===
--- clang/test/Driver/ve-toolchain.c
+++ clang/test/Driver/ve-toolchain.c
@@ -60,6 +60,23 @@
 // NOTINITARRAY: clang{{.*}} "-cc1"
 // NOTINITARRAY: "-fno-use-init-array"
 
+///-
+/// Checking -faddrsig
+
+// RUN: %clang -### -target ve %s 2>&1 | FileCheck -check-prefix=DEFADDESIG %s
+// DEFADDESIG: clang{{.*}} "-cc1"
+// DEFADDESIG-NOT: "-faddrsig"
+
+// RUN: %clang -### -target ve %s -faddrsig 2>&1 | \
+// RUN: FileCheck -check-prefix=ADDRSIG %s
+// ADDRSIG: clang{{.*}} "-cc1"
+// ADDRSIG: "-faddrsig"
+
+// RUN: %clang -### -target ve %s -fno-addrsig 2>&1 | \
+// RUN: FileCheck -check-prefix=NOADDRSIG %s
+// NOADDRSIG: clang{{.*}} "-cc1"
+// NOADDRSIG-NOT: "-faddrsig"
+
 
///-
 /// Checking exceptions
 
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6365,11 +6365,10 @@
   if (Args.hasFlag(options::OPT_faddrsig, options::OPT_fno_addrsig,
(TC.getTriple().isOSBinFormatELF() ||
 TC.getTriple().isOSBinFormatCOFF()) &&
-  !TC.getTriple().isPS4() &&
-  !TC.getTriple().isOSNetBSD() &&
-  !Distro(D.getVFS(), TC.getTriple()).IsGentoo() &&
-  !TC.getTriple().isAndroid() &&
-   TC.useIntegratedAs()))
+   !TC.getTriple().isPS4() && !TC.getTriple().isVE() &&
+   !TC.getTriple().isOSNetBSD() &&
+   !Distro(D.getVFS(), TC.getTriple()).IsGentoo() &&
+   !TC.getTriple().isAndroid() && TC.useIntegratedAs()))
 CmdArgs.push_back("-faddrsig");
 
   if (Arg *A = Args.getLastArg(options::OPT_fsymbol_partition_EQ)) {


Index: clang/test/Driver/ve-toolchain.c
===
--- clang/test/Driver/ve-toolchain.c
+++ clang/test/Driver/ve-toolchain.c
@@ -60,6 +60,23 @@
 // NOTINITARRAY: clang{{.*}} "-cc1"
 // NOTINITARRAY: "-fno-use-init-array"
 
+///-
+/// Checking -faddrsig
+
+// RUN: %clang -### -target ve %s 2>&1 | FileCheck -check-prefix=DEFADDESIG %s
+// DEFADDESIG: clang{{.*}} "-cc1"
+// DEFADDESIG-NOT: "-faddrsig"
+
+// RUN: %clang -### -target ve %s -faddrsig 2>&1 | \
+// RUN: FileCheck -check-prefix=ADDRSIG %s
+// ADDRSIG: clang{{.*}} "-cc1"
+// ADDRSIG: "-faddrsig"
+
+// RUN: %clang -### -target ve %s -fno-addrsig 2>&1 | \
+// RUN: FileCheck -check-prefix=NOADDRSIG %s
+// NOADDRSIG: clang{{.*}} "-cc1"
+// NOADDRSIG-NOT: "-faddrsig"
+
 ///-
 /// Checking exceptions
 
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6365,11 +6365,10 @@
   if (Args.hasFlag(options::OPT_faddrsig, options::OPT_fno_addrsig,
(TC.getTriple().isOSBinFormatELF() ||
 TC.getTriple().isOSBinFormatCOFF()) &&
-  !TC.getTriple().isPS4() &&
-  !TC.getTriple().isOSNetBSD() &&
-  !Distro(D.getVFS(), TC.getTriple()).IsGentoo() &&
-  !TC.getTriple().isAndroid() &&
-   TC.useIntegratedAs()))
+   !TC.getTriple().isPS4() && !TC.getTriple().isVE() &&
+   !TC.getTriple().isOSNetBSD() &&
+   !Distro(D.getVFS(), TC.getTriple()).IsGentoo() &&
+   !TC.getTriple().isAndroid() && TC.useIntegratedAs()))
 CmdArgs.push_back("-faddrsig");
 
   if (Arg *A = Args.getLastArg(options::OPT_fsymbol_partition_EQ)) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91351: [tooling] Implement determinsitic ordering of CompilationDatabasePlugins

2020-11-12 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added reviewers: klimek, nridge.
Herald added subscribers: cfe-commits, usaxena95, kadircet, mgrang.
Herald added a project: clang.
njames93 requested review of this revision.
Herald added a subscriber: ilya-biryukov.

Right now plugins appear to be registed in an undefined order based on what the 
linker decides to link in first.
This is undesireable as if there are multiple potential databases in a 
directory we can't specify which one should be treated as the defacto.

To address this there is a virtual getPriority method in the 
`CompilationDatabasePlugin`.
Plugins will then be sorted based on that(lowest first) and then search for a 
CompilationDatabase in the specified directory.

JSON database will now load first before Fixed database but there is plenty of 
room to insert plugins that would take priority over JSON, like ninja or make 
files.

Addresses https://github.com/clangd/clangd/issues/578


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91351

Files:
  clang/include/clang/Tooling/CompilationDatabasePluginRegistry.h
  clang/lib/Tooling/CompilationDatabase.cpp
  clang/lib/Tooling/JSONCompilationDatabase.cpp


Index: clang/lib/Tooling/JSONCompilationDatabase.cpp
===
--- clang/lib/Tooling/JSONCompilationDatabase.cpp
+++ clang/lib/Tooling/JSONCompilationDatabase.cpp
@@ -173,6 +173,13 @@
   std::move(Base), llvm::vfs::getRealFileSystem(
 : nullptr;
   }
+
+  unsigned int getPriority() const override {
+// Pretty arbitrary. However we want to leave room for database sources
+// which could have a higher priority, like directly supporting ninja or
+// make files.
+return 50;
+  }
 };
 
 } // namespace
Index: clang/lib/Tooling/CompilationDatabase.cpp
===
--- clang/lib/Tooling/CompilationDatabase.cpp
+++ clang/lib/Tooling/CompilationDatabase.cpp
@@ -64,14 +64,26 @@
 CompilationDatabase::loadFromDirectory(StringRef BuildDirectory,
std::string &ErrorMessage) {
   llvm::raw_string_ostream ErrorStream(ErrorMessage);
+  using NameAndPlugin =
+  std::pair>;
+  llvm::SmallVector Plugins;
+
   for (const CompilationDatabasePluginRegistry::entry &Database :
CompilationDatabasePluginRegistry::entries()) {
+Plugins.emplace_back(Database.getName(), Database.instantiate());
+  }
+  llvm::sort(Plugins, [](const NameAndPlugin &LHS, const NameAndPlugin &RHS) {
+assert(LHS.second->getPriority() != RHS.second->getPriority() &&
+   "Undeterministic priority");
+return LHS.second->getPriority() < RHS.second->getPriority();
+  });
+  for (auto &Plugin : Plugins) {
 std::string DatabaseErrorMessage;
-std::unique_ptr Plugin(Database.instantiate());
 if (std::unique_ptr DB =
-Plugin->loadFromDirectory(BuildDirectory, DatabaseErrorMessage))
+Plugin.second->loadFromDirectory(BuildDirectory,
+ DatabaseErrorMessage))
   return DB;
-ErrorStream << Database.getName() << ": " << DatabaseErrorMessage << "\n";
+ErrorStream << Plugin.first << ": " << DatabaseErrorMessage << "\n";
   }
   return nullptr;
 }
@@ -405,6 +417,12 @@
 llvm::sys::path::append(DatabasePath, "compile_flags.txt");
 return FixedCompilationDatabase::loadFromFile(DatabasePath, ErrorMessage);
   }
+
+  unsigned int getPriority() const override {
+// Give this a high value as it should be the fallback and any other Plugin
+// should be used first.
+return 100;
+  }
 };
 
 } // namespace
Index: clang/include/clang/Tooling/CompilationDatabasePluginRegistry.h
===
--- clang/include/clang/Tooling/CompilationDatabasePluginRegistry.h
+++ clang/include/clang/Tooling/CompilationDatabasePluginRegistry.h
@@ -34,6 +34,10 @@
   /// \see CompilationDatabase::loadFromDirectory().
   virtual std::unique_ptr
   loadFromDirectory(StringRef Directory, std::string &ErrorMessage) = 0;
+
+  /// Used to sort the plugins before attempting to load. Plugins with a lower
+  /// value here will run over a directory first.
+  virtual unsigned getPriority() const = 0;
 };
 
 using CompilationDatabasePluginRegistry =


Index: clang/lib/Tooling/JSONCompilationDatabase.cpp
===
--- clang/lib/Tooling/JSONCompilationDatabase.cpp
+++ clang/lib/Tooling/JSONCompilationDatabase.cpp
@@ -173,6 +173,13 @@
   std::move(Base), llvm::vfs::getRealFileSystem(
 : nullptr;
   }
+
+  unsigned int getPriority() const override {
+// Pretty arbitrary. However we want to leave room for database sources
+// which could have a higher priority, like directly supporting ninja or
+// make files.
+return 50;
+  }
 };
 

[clang] 62ed69b - [clang][docs] Remove wrongly spaced \brief in Doxygen comment (NFC)

2020-11-12 Thread Jean-Michel Gorius via cfe-commits

Author: Jean-Michel Gorius
Date: 2020-11-12T15:44:43+01:00
New Revision: 62ed69b01d38044a6d7b90b18c2271e2d71a9bcd

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

LOG: [clang][docs] Remove wrongly spaced \brief in Doxygen comment (NFC)

Added: 


Modified: 
clang/include/clang/Analysis/CallGraph.h

Removed: 




diff  --git a/clang/include/clang/Analysis/CallGraph.h 
b/clang/include/clang/Analysis/CallGraph.h
index 6f7159330f5d..999ac5da8acb 100644
--- a/clang/include/clang/Analysis/CallGraph.h
+++ b/clang/include/clang/Analysis/CallGraph.h
@@ -91,8 +91,8 @@ class CallGraph : public RecursiveASTVisitor {
   /// Get the number of nodes in the graph.
   unsigned size() const { return FunctionMap.size(); }
 
-  /// \ brief Get the virtual root of the graph, all the functions available
-  /// externally are represented as callees of the node.
+  /// Get the virtual root of the graph, all the functions available externally
+  /// are represented as callees of the node.
   CallGraphNode *getRoot() const { return Root; }
 
   /// Iterators through all the nodes of the graph that have no parent. These



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


[PATCH] D91200: [PowerPC] Prevent the use of MMA with P9 and earlier

2020-11-12 Thread Amy Kwan via Phabricator via cfe-commits
amyk accepted this revision as: amyk.
amyk added a comment.
This revision is now accepted and ready to land.

Overall LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91200

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


[PATCH] D90282: [clang-tidy] Add IgnoreShortNames config to identifier naming checks

2020-11-12 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D90282#2391005 , @njames93 wrote:

> Should this be a NamingStyle option instead.
> `{key: readability-identifier-naming.ParameterShortSizeThreshold, value: 2}`
> WDYT?

I think that makes a lot of sense -- I can imagine wanting to enforce different 
identifier lengths depending on whether we're spelling a type name vs a local 
variable name, etc.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90282

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


[PATCH] D90042: [clang-tidy] performance-unnecessary-copy-initialization: Check for const reference arguments that are replaced template parameter type.

2020-11-12 Thread Felix Berger via Phabricator via cfe-commits
flx updated this revision to Diff 304831.
flx added a comment.

Fixed definition of fake std::function which now makes the bug fixed by this 
change reproducible.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90042

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


Index: 
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
@@ -411,14 +411,37 @@
 
 template 
 class function;
-template 
-class function {
+template 
+class function {
 public:
   function();
-  function(const function &other);
-  R operator()(Args &&...args) const;
+  function(const function &Other);
+  R operator()(ArgTypes... Args) const;
+};
+
+template 
+struct remove_reference;
+
+template 
+struct remove_reference {
+  typedef _Tp type;
+};
+
+template 
+struct remove_reference<_Tp &> {
+  typedef _Tp type;
+};
+
+template 
+struct remove_reference<_Tp &&> {
+  typedef _Tp type;
 };
 
+template 
+constexpr _Tp &&forward(typename remove_reference<_Tp>::type &__t) noexcept {
+  return static_cast<_Tp &&>(__t);
+}
+
 } // namespace __1
 } // namespace std
 
@@ -460,3 +483,19 @@
 }
 
 } // namespace fake
+
+void positiveInvokedOnStdFunction(
+std::function Update,
+const ExpensiveToCopyType Orig) {
+  auto Copy = Orig.reference();
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: the variable 'Copy' is 
copy-constructed from a const reference
+  // CHECK-FIXES: const auto& Copy = Orig.reference();
+  Update(Copy);
+}
+
+void negativeInvokedOnStdFunction(
+std::function Update,
+const ExpensiveToCopyType Orig) {
+  auto Copy = Orig.reference();
+  Update(Copy);
+}
Index: clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
===
--- clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
+++ clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
@@ -59,9 +59,13 @@
   extractNodesByIdTo(Matches, "declRef", DeclRefs);
   auto ConstReferenceOrValue =
   qualType(anyOf(referenceType(pointee(qualType(isConstQualified(,
- unless(anyOf(referenceType(), pointerType();
+ unless(anyOf(referenceType(), pointerType(),
+  substTemplateTypeParmType();
+  auto ConstReferenceOrValueOrReplaced = qualType(anyOf(
+  ConstReferenceOrValue,
+  substTemplateTypeParmType(hasReplacementType(ConstReferenceOrValue;
   auto UsedAsConstRefOrValueArg = forEachArgumentWithParam(
-  DeclRefToVar, parmVarDecl(hasType(ConstReferenceOrValue)));
+  DeclRefToVar, parmVarDecl(hasType(ConstReferenceOrValueOrReplaced)));
   Matches = match(findAll(callExpr(UsedAsConstRefOrValueArg)), Stmt, Context);
   extractNodesByIdTo(Matches, "declRef", DeclRefs);
   Matches =


Index: clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
@@ -411,14 +411,37 @@
 
 template 
 class function;
-template 
-class function {
+template 
+class function {
 public:
   function();
-  function(const function &other);
-  R operator()(Args &&...args) const;
+  function(const function &Other);
+  R operator()(ArgTypes... Args) const;
+};
+
+template 
+struct remove_reference;
+
+template 
+struct remove_reference {
+  typedef _Tp type;
+};
+
+template 
+struct remove_reference<_Tp &> {
+  typedef _Tp type;
+};
+
+template 
+struct remove_reference<_Tp &&> {
+  typedef _Tp type;
 };
 
+template 
+constexpr _Tp &&forward(typename remove_reference<_Tp>::type &__t) noexcept {
+  return static_cast<_Tp &&>(__t);
+}
+
 } // namespace __1
 } // namespace std
 
@@ -460,3 +483,19 @@
 }
 
 } // namespace fake
+
+void positiveInvokedOnStdFunction(
+std::function Update,
+const ExpensiveToCopyType Orig) {
+  auto Copy = Orig.reference();
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: the variable 'Copy' is copy-constructed from a const reference
+  // CHECK-FIXES: const auto& Copy = Orig.reference();
+  Update(Copy);
+}
+
+void negativeInvokedOnStdFunction(
+std::function Update,
+const ExpensiveToCopyType Orig) {
+  auto Copy = Orig.reference();
+  Update(Copy);
+}
Index: clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
===
--- clang-tools-extra/clang-tidy/utils/DeclRefExprU

[PATCH] D90042: [clang-tidy] performance-unnecessary-copy-initialization: Check for const reference arguments that are replaced template parameter type.

2020-11-12 Thread Felix Berger via Phabricator via cfe-commits
flx updated this revision to Diff 304833.
flx added a comment.

Remove unnecessary test code that is not needed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90042

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


Index: 
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
@@ -411,12 +411,12 @@
 
 template 
 class function;
-template 
-class function {
+template 
+class function {
 public:
   function();
-  function(const function &other);
-  R operator()(Args &&...args) const;
+  function(const function &Other);
+  R operator()(ArgTypes... Args) const;
 };
 
 } // namespace __1
@@ -460,3 +460,19 @@
 }
 
 } // namespace fake
+
+void positiveInvokedOnStdFunction(
+std::function Update,
+const ExpensiveToCopyType Orig) {
+  auto Copy = Orig.reference();
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: the variable 'Copy' is 
copy-constructed from a const reference
+  // CHECK-FIXES: const auto& Copy = Orig.reference();
+  Update(Copy);
+}
+
+void negativeInvokedOnStdFunction(
+std::function Update,
+const ExpensiveToCopyType Orig) {
+  auto Copy = Orig.reference();
+  Update(Copy);
+}
Index: clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
===
--- clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
+++ clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
@@ -59,9 +59,13 @@
   extractNodesByIdTo(Matches, "declRef", DeclRefs);
   auto ConstReferenceOrValue =
   qualType(anyOf(referenceType(pointee(qualType(isConstQualified(,
- unless(anyOf(referenceType(), pointerType();
+ unless(anyOf(referenceType(), pointerType(),
+  substTemplateTypeParmType();
+  auto ConstReferenceOrValueOrReplaced = qualType(anyOf(
+  ConstReferenceOrValue,
+  substTemplateTypeParmType(hasReplacementType(ConstReferenceOrValue;
   auto UsedAsConstRefOrValueArg = forEachArgumentWithParam(
-  DeclRefToVar, parmVarDecl(hasType(ConstReferenceOrValue)));
+  DeclRefToVar, parmVarDecl(hasType(ConstReferenceOrValueOrReplaced)));
   Matches = match(findAll(callExpr(UsedAsConstRefOrValueArg)), Stmt, Context);
   extractNodesByIdTo(Matches, "declRef", DeclRefs);
   Matches =


Index: clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
@@ -411,12 +411,12 @@
 
 template 
 class function;
-template 
-class function {
+template 
+class function {
 public:
   function();
-  function(const function &other);
-  R operator()(Args &&...args) const;
+  function(const function &Other);
+  R operator()(ArgTypes... Args) const;
 };
 
 } // namespace __1
@@ -460,3 +460,19 @@
 }
 
 } // namespace fake
+
+void positiveInvokedOnStdFunction(
+std::function Update,
+const ExpensiveToCopyType Orig) {
+  auto Copy = Orig.reference();
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: the variable 'Copy' is copy-constructed from a const reference
+  // CHECK-FIXES: const auto& Copy = Orig.reference();
+  Update(Copy);
+}
+
+void negativeInvokedOnStdFunction(
+std::function Update,
+const ExpensiveToCopyType Orig) {
+  auto Copy = Orig.reference();
+  Update(Copy);
+}
Index: clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
===
--- clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
+++ clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
@@ -59,9 +59,13 @@
   extractNodesByIdTo(Matches, "declRef", DeclRefs);
   auto ConstReferenceOrValue =
   qualType(anyOf(referenceType(pointee(qualType(isConstQualified(,
- unless(anyOf(referenceType(), pointerType();
+ unless(anyOf(referenceType(), pointerType(),
+  substTemplateTypeParmType();
+  auto ConstReferenceOrValueOrReplaced = qualType(anyOf(
+  ConstReferenceOrValue,
+  substTemplateTypeParmType(hasReplacementType(ConstReferenceOrValue;
   auto UsedAsConstRefOrValueArg = forEachArgumentWithParam(
-  DeclRefToVar, parmVarDecl(hasType(ConstReferenceOrValue)));
+  DeclRefToVar, parmVarDecl(hasType(ConstReferenceOrValueOrReplaced)));
   Matches = match(findAll(

[PATCH] D90042: [clang-tidy] performance-unnecessary-copy-initialization: Check for const reference arguments that are replaced template parameter type.

2020-11-12 Thread Felix Berger via Phabricator via cfe-commits
flx added a comment.

In D90042#2391246 , @aaron.ballman 
wrote:

> In D90042#2390203 , @flx wrote:
>
>> Thanks for the suggestion, I had never hear of creduce!
>
> Glad to have introduced you to it -- it's a great tool!
>
>> After a bit of trial an error I seem to have found a more minimal example:
>>
>>   namespace std {
>>   
>>   template  class function;
>>   
>>   template  class function { 
>>   
>>   public:
>>   
>> void operator()(b...);   
>>   
>>   }; 
>>   
>>   } // namespace std 
>>   
>>   struct c { 
>>   
>> c(); 
>>   
>> c(const c &);
>>   
>>   }; 
>>   
>>   std::function f;
>>   
>>   void d() { 
>>   
>> c Orig;  
>>   
>> c Copy = Orig;   
>>   
>> f(Copy); 
>>   
>>   }  
>>
>>
>> To be frank I can't spot a meaningful difference to the std::function copy 
>> we already have.
>
> Aha, I may have spotted it. The call operators have subtly different 
> signatures and the signature we have in our test file is wrong. Note the `&&` 
> in our test file compared to what the standard defines: 
> http://eel.is/c++draft/func.wrap.func#inv which is what's causing the 
> difference here: https://godbolt.org/z/hxfM7P

Ah! That is subtle and surprising, but makes sense. I confirmed that the new 
test cases fail now before the fix is put in place. Thanks for your help!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90042

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


[PATCH] D90042: [clang-tidy] performance-unnecessary-copy-initialization: Check for const reference arguments that are replaced template parameter type.

2020-11-12 Thread Felix Berger via Phabricator via cfe-commits
flx updated this revision to Diff 304834.
flx added a comment.

Updated change description.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90042

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


Index: 
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
@@ -411,12 +411,12 @@
 
 template 
 class function;
-template 
-class function {
+template 
+class function {
 public:
   function();
-  function(const function &other);
-  R operator()(Args &&...args) const;
+  function(const function &Other);
+  R operator()(ArgTypes... Args) const;
 };
 
 } // namespace __1
@@ -460,3 +460,19 @@
 }
 
 } // namespace fake
+
+void positiveInvokedOnStdFunction(
+std::function Update,
+const ExpensiveToCopyType Orig) {
+  auto Copy = Orig.reference();
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: the variable 'Copy' is 
copy-constructed from a const reference
+  // CHECK-FIXES: const auto& Copy = Orig.reference();
+  Update(Copy);
+}
+
+void negativeInvokedOnStdFunction(
+std::function Update,
+const ExpensiveToCopyType Orig) {
+  auto Copy = Orig.reference();
+  Update(Copy);
+}
Index: clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
===
--- clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
+++ clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
@@ -59,9 +59,13 @@
   extractNodesByIdTo(Matches, "declRef", DeclRefs);
   auto ConstReferenceOrValue =
   qualType(anyOf(referenceType(pointee(qualType(isConstQualified(,
- unless(anyOf(referenceType(), pointerType();
+ unless(anyOf(referenceType(), pointerType(),
+  substTemplateTypeParmType();
+  auto ConstReferenceOrValueOrReplaced = qualType(anyOf(
+  ConstReferenceOrValue,
+  substTemplateTypeParmType(hasReplacementType(ConstReferenceOrValue;
   auto UsedAsConstRefOrValueArg = forEachArgumentWithParam(
-  DeclRefToVar, parmVarDecl(hasType(ConstReferenceOrValue)));
+  DeclRefToVar, parmVarDecl(hasType(ConstReferenceOrValueOrReplaced)));
   Matches = match(findAll(callExpr(UsedAsConstRefOrValueArg)), Stmt, Context);
   extractNodesByIdTo(Matches, "declRef", DeclRefs);
   Matches =


Index: clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
@@ -411,12 +411,12 @@
 
 template 
 class function;
-template 
-class function {
+template 
+class function {
 public:
   function();
-  function(const function &other);
-  R operator()(Args &&...args) const;
+  function(const function &Other);
+  R operator()(ArgTypes... Args) const;
 };
 
 } // namespace __1
@@ -460,3 +460,19 @@
 }
 
 } // namespace fake
+
+void positiveInvokedOnStdFunction(
+std::function Update,
+const ExpensiveToCopyType Orig) {
+  auto Copy = Orig.reference();
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: the variable 'Copy' is copy-constructed from a const reference
+  // CHECK-FIXES: const auto& Copy = Orig.reference();
+  Update(Copy);
+}
+
+void negativeInvokedOnStdFunction(
+std::function Update,
+const ExpensiveToCopyType Orig) {
+  auto Copy = Orig.reference();
+  Update(Copy);
+}
Index: clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
===
--- clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
+++ clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
@@ -59,9 +59,13 @@
   extractNodesByIdTo(Matches, "declRef", DeclRefs);
   auto ConstReferenceOrValue =
   qualType(anyOf(referenceType(pointee(qualType(isConstQualified(,
- unless(anyOf(referenceType(), pointerType();
+ unless(anyOf(referenceType(), pointerType(),
+  substTemplateTypeParmType();
+  auto ConstReferenceOrValueOrReplaced = qualType(anyOf(
+  ConstReferenceOrValue,
+  substTemplateTypeParmType(hasReplacementType(ConstReferenceOrValue;
   auto UsedAsConstRefOrValueArg = forEachArgumentWithParam(
-  DeclRefToVar, parmVarDecl(hasType(ConstReferenceOrValue)));
+  DeclRefToVar, parmVarDecl(hasType(ConstReferenceOrValueOrReplaced)));
   Matches = match(findAll(callExpr(UsedAsConstR

[PATCH] D91333: [clang][SveEmitter] Fix enum declarations. [NFCI]

2020-11-12 Thread Joe Ellis via Phabricator via cfe-commits
joechrisellis added a comment.

Thanks for the patch @fpetrogalli! One small comment from me, but not a blocker 
for me, so approved.




Comment at: clang/test/Sema/aarch64-sve-enums.c:14-15
+#include 
+enum svpattern a1 = SV_ALL;
+svpattern b1 = {1.0f};
+enum svprfop a2 = SV_PLDL1KEEP;

[nit] It would be good if you could add a small comment here explaining what 
this is doing. As far as I can tell, you're creating a typedef'd struct with 
the same identifier as the one defined in `arm_sve.h`, then checking that it 
does not overload `enum svpattern` defined in `arm_sve.h`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91333

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


[PATCH] D91361: [AIX][driver] Include crti[_64].o and -bcdtors also for C language link invocations by default

2020-11-12 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L created this revision.
Xiangling_L added reviewers: daltenty, hubert.reinterpretcast, stevewan, 
xingxue.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Xiangling_L requested review of this revision.

In order to support __attribute__((__constructor__)) and 
__attribute__((__destructor__)), which is used by various LLVM non-C++ runtime 
components, AIX will include crti[_64].o and -bcdtors for C language link 
invocations by default.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91361

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/test/Driver/aix-ld.c

Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -16,7 +16,7 @@
 // CHECK-LD32: "-b32"
 // CHECK-LD32: "-bpT:0x1000" "-bpD:0x2000"
 // CHECK-LD32: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
-// CHECK-LD32-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
+// CHECK-LD32: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
 // CHECK-LD32: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-NOT: "-lc++"
 // CHECK-LD32: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
@@ -38,7 +38,7 @@
 // CHECK-LD64: "-b64"
 // CHECK-LD64: "-bpT:0x1" "-bpD:0x11000"
 // CHECK-LD64: "[[SYSROOT]]/usr/lib{{/|}}crt0_64.o"
-// CHECK-LD64-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti_64.o"
+// CHECK-LD64: "[[SYSROOT]]/usr/lib{{/|}}crti_64.o"
 // CHECK-LD64: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD64-NOT: "-lc++"
 // CHECK-LD64: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc64.a"
@@ -61,7 +61,7 @@
 // CHECK-LD32-PTHREAD: "-b32"
 // CHECK-LD32-PTHREAD: "-bpT:0x1000" "-bpD:0x2000"
 // CHECK-LD32-PTHREAD: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
-// CHECK-LD32-PTHREAD-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
+// CHECK-LD32-PTHREAD: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
 // CHECK-LD32-PTHREAD: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-PTHREAD-NOT: "-lc++"
 // CHECK-LD32-PTHREAD: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
@@ -85,7 +85,7 @@
 // CHECK-LD64-PTHREAD: "-b64"
 // CHECK-LD64-PTHREAD: "-bpT:0x1" "-bpD:0x11000"
 // CHECK-LD64-PTHREAD: "[[SYSROOT]]/usr/lib{{/|}}crt0_64.o"
-// CHECK-LD64-PTHREAD-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti_64.o"
+// CHECK-LD64-PTHREAD: "[[SYSROOT]]/usr/lib{{/|}}crti_64.o"
 // CHECK-LD64-PTHREAD: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD64-PTHREAD-NOT: "-lc++"
 // CHECK-LD64-PTHREAD: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc64.a"
@@ -109,7 +109,7 @@
 // CHECK-LD32-PROF: "-b32"
 // CHECK-LD32-PROF: "-bpT:0x1000" "-bpD:0x2000"
 // CHECK-LD32-PROF: "[[SYSROOT]]/usr/lib{{/|}}mcrt0.o"
-// CHECK-LD32-PROF-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
+// CHECK-LD32-PROF: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
 // CHECK-LD32-PROF: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-PROF-NOT: "-lc++"
 // CHECK-LD32-PROF: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
@@ -132,7 +132,7 @@
 // CHECK-LD64-GPROF: "-b64"
 // CHECK-LD64-GPROF: "-bpT:0x1" "-bpD:0x11000"
 // CHECK-LD64-GPROF: "[[SYSROOT]]/usr/lib{{/|}}gcrt0_64.o"
-// CHECK-LD64-GPROF-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti_64.o"
+// CHECK-LD64-GPROF: "[[SYSROOT]]/usr/lib{{/|}}crti_64.o"
 // CHECK-LD64-GPROF: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD64-GPROF-NOT: "-lc++"
 // CHECK-LD64-GPROF: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc64.a"
@@ -155,7 +155,7 @@
 // CHECK-LD32-STATIC: "-b32"
 // CHECK-LD32-STATIC: "-bpT:0x1000" "-bpD:0x2000"
 // CHECK-LD32-STATIC: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
-// CHECK-LD32-STATIC-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
+// CHECK-LD32-STATIC: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
 // CHECK-LD32-STATIC: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-STATIC-NOT: "-lc++"
 // CHECK-LD32-STATIC: "[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
@@ -178,7 +178,7 @@
 // CHECK-LD32-LIBP: "-b32"
 // CHECK-LD32-LIBP: "-bpT:0x1000" "-bpD:0x2000"
 // CHECK-LD32-LIBP: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
-// CHECK-LD32-LIBP-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
+// CHECK-LD32-LIBP: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
 // CHECK-LD32-LIBP: "-L[[SYSROOT]]/powerpc-ibm-aix7.1.0.0"
 // CHECK-LD32-LIBP: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD32-LIBP-NOT: "-lc++"
@@ -228,7 +228,7 @@
 // CHECK-LD64-NO-DEFAULT-LIBS: "-b64"
 // CHECK-LD64-NO-DEFAULT-LIBS: "-bpT:0x1" "-bpD:0x11000"
 // CHECK-LD64-NO-DEFAULT-LIBS: "[[SYSROOT]]/usr/lib{{/|}}crt0_64.o"
-// CHECK-LD64-NO-DEFAULT-LIBS-NOT: "[[SYSROOT]]/usr/lib{{/|}}c

[PATCH] D91200: [PowerPC] Prevent the use of MMA with P9 and earlier

2020-11-12 Thread Baptiste Saleil via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG170e45ae186b: [PowerPC] Prevent the use of MMA with P9 and 
earlier (authored by bsaleil).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91200

Files:
  clang/lib/Basic/Targets/PPC.cpp
  clang/test/Driver/ppc-mma-support-check.c
  clang/test/Preprocessor/init-ppc64.c


Index: clang/test/Preprocessor/init-ppc64.c
===
--- clang/test/Preprocessor/init-ppc64.c
+++ clang/test/Preprocessor/init-ppc64.c
@@ -648,7 +648,7 @@
 // PPCFUTURE:#define _ARCH_PWR_FUTURE 1
 // PPCFUTURE:#define __MMA__ 1
 //
-// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none 
-target-feature +mma -target-cpu power9 -fno-signed-char < /dev/null | 
FileCheck -check-prefix PPC-MMA %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none 
-target-feature +mma -target-cpu power10 -fno-signed-char < /dev/null | 
FileCheck -check-prefix PPC-MMA %s
 // PPC-MMA:#define __MMA__ 1
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none 
-target-feature +float128 -target-cpu power9 -fno-signed-char < /dev/null | 
FileCheck -check-prefix PPC-FLOAT128 %s
Index: clang/test/Driver/ppc-mma-support-check.c
===
--- /dev/null
+++ clang/test/Driver/ppc-mma-support-check.c
@@ -0,0 +1,22 @@
+// RUN: not %clang -target powerpc64le-unknown-linux-gnu -fsyntax-only \
+// RUN:   -mcpu=pwr10 -mmma %s 2>&1 | FileCheck %s --check-prefix=HASMMA
+// RUN: not %clang -target powerpc64le-unknown-linux-gnu -fsyntax-only \
+// RUN:   -mcpu=power10 -mmma %s 2>&1 | FileCheck %s --check-prefix=HASMMA
+
+// RUN: not %clang -target powerpc64le-unknown-linux-gnu -fsyntax-only \
+// RUN:   -mcpu=pwr9 -mmma %s 2>&1 | FileCheck %s --check-prefix=NOMMA
+// RUN: not %clang -target powerpc64le-unknown-linux-gnu -fsyntax-only \
+// RUN:   -mcpu=pwr8 -mmma %s 2>&1 | FileCheck %s --check-prefix=NOMMA
+// RUN: not %clang -target powerpc64le-unknown-linux-gnu -fsyntax-only \
+// RUN:   -mcpu=pwr7 -mmma %s 2>&1 | FileCheck %s --check-prefix=NOMMA
+// RUN: not %clang -target powerpc64le-unknown-linux-gnu -fsyntax-only \
+// RUN:   -mmma %s 2>&1 | FileCheck %s --check-prefix=NOMMA
+
+#ifdef __MMA__
+static_assert(false, "MMA enabled");
+#endif
+
+// HASMMA: MMA enabled
+// HASMMA-NOT: option '-mmma' cannot be specified with
+// NOMMA: option '-mmma' cannot be specified with
+
Index: clang/lib/Basic/Targets/PPC.cpp
===
--- clang/lib/Basic/Targets/PPC.cpp
+++ clang/lib/Basic/Targets/PPC.cpp
@@ -347,6 +347,13 @@
 return false;
   }
 
+  if (!(ArchDefs & ArchDefinePwr10) &&
+  llvm::find(FeaturesVec, "+mma") != FeaturesVec.end()) {
+// We have MMA on PPC but not power 10 and above.
+Diags.Report(diag::err_opt_not_valid_with_opt) << "-mmma" << CPU;
+return false;
+  }
+
   return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
 }
 


Index: clang/test/Preprocessor/init-ppc64.c
===
--- clang/test/Preprocessor/init-ppc64.c
+++ clang/test/Preprocessor/init-ppc64.c
@@ -648,7 +648,7 @@
 // PPCFUTURE:#define _ARCH_PWR_FUTURE 1
 // PPCFUTURE:#define __MMA__ 1
 //
-// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none -target-feature +mma -target-cpu power9 -fno-signed-char < /dev/null | FileCheck -check-prefix PPC-MMA %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none -target-feature +mma -target-cpu power10 -fno-signed-char < /dev/null | FileCheck -check-prefix PPC-MMA %s
 // PPC-MMA:#define __MMA__ 1
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none -target-feature +float128 -target-cpu power9 -fno-signed-char < /dev/null | FileCheck -check-prefix PPC-FLOAT128 %s
Index: clang/test/Driver/ppc-mma-support-check.c
===
--- /dev/null
+++ clang/test/Driver/ppc-mma-support-check.c
@@ -0,0 +1,22 @@
+// RUN: not %clang -target powerpc64le-unknown-linux-gnu -fsyntax-only \
+// RUN:   -mcpu=pwr10 -mmma %s 2>&1 | FileCheck %s --check-prefix=HASMMA
+// RUN: not %clang -target powerpc64le-unknown-linux-gnu -fsyntax-only \
+// RUN:   -mcpu=power10 -mmma %s 2>&1 | FileCheck %s --check-prefix=HASMMA
+
+// RUN: not %clang -target powerpc64le-unknown-linux-gnu -fsyntax-only \
+// RUN:   -mcpu=pwr9 -mmma %s 2>&1 | FileCheck %s --check-prefix=NOMMA
+// RUN: not %clang -target powerpc64le-unknown-linux-gnu -fsyntax-only \
+// RUN:   -mcpu=pwr8 -mmma %s 2>&1 | FileCheck %s --check-prefix=NOMMA
+// RUN: not %clang -target powerpc64le-unknown-linux-gnu -fsyntax-only \
+// RUN:   -mcpu=pwr7 -mmma %s 2>&1 | FileCheck %s --check-prefix=NOMMA
+

[clang] 170e45a - [PowerPC] Prevent the use of MMA with P9 and earlier

2020-11-12 Thread Baptiste Saleil via cfe-commits

Author: Baptiste Saleil
Date: 2020-11-12T10:36:50-06:00
New Revision: 170e45ae186b3eed16898db933c94a85ac623933

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

LOG: [PowerPC] Prevent the use of MMA with P9 and earlier

We want to allow using MMA on P10 CPU only. This patch prevents the use of MMA
with the -mmma option on P9 CPUs and earlier.

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

Added: 
clang/test/Driver/ppc-mma-support-check.c

Modified: 
clang/lib/Basic/Targets/PPC.cpp
clang/test/Preprocessor/init-ppc64.c

Removed: 




diff  --git a/clang/lib/Basic/Targets/PPC.cpp b/clang/lib/Basic/Targets/PPC.cpp
index bafaed7c4caf..7f6f3d7e0c9f 100644
--- a/clang/lib/Basic/Targets/PPC.cpp
+++ b/clang/lib/Basic/Targets/PPC.cpp
@@ -347,6 +347,13 @@ bool PPCTargetInfo::initFeatureMap(
 return false;
   }
 
+  if (!(ArchDefs & ArchDefinePwr10) &&
+  llvm::find(FeaturesVec, "+mma") != FeaturesVec.end()) {
+// We have MMA on PPC but not power 10 and above.
+Diags.Report(diag::err_opt_not_valid_with_opt) << "-mmma" << CPU;
+return false;
+  }
+
   return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
 }
 

diff  --git a/clang/test/Driver/ppc-mma-support-check.c 
b/clang/test/Driver/ppc-mma-support-check.c
new file mode 100644
index ..cd701619bbe4
--- /dev/null
+++ b/clang/test/Driver/ppc-mma-support-check.c
@@ -0,0 +1,22 @@
+// RUN: not %clang -target powerpc64le-unknown-linux-gnu -fsyntax-only \
+// RUN:   -mcpu=pwr10 -mmma %s 2>&1 | FileCheck %s --check-prefix=HASMMA
+// RUN: not %clang -target powerpc64le-unknown-linux-gnu -fsyntax-only \
+// RUN:   -mcpu=power10 -mmma %s 2>&1 | FileCheck %s --check-prefix=HASMMA
+
+// RUN: not %clang -target powerpc64le-unknown-linux-gnu -fsyntax-only \
+// RUN:   -mcpu=pwr9 -mmma %s 2>&1 | FileCheck %s --check-prefix=NOMMA
+// RUN: not %clang -target powerpc64le-unknown-linux-gnu -fsyntax-only \
+// RUN:   -mcpu=pwr8 -mmma %s 2>&1 | FileCheck %s --check-prefix=NOMMA
+// RUN: not %clang -target powerpc64le-unknown-linux-gnu -fsyntax-only \
+// RUN:   -mcpu=pwr7 -mmma %s 2>&1 | FileCheck %s --check-prefix=NOMMA
+// RUN: not %clang -target powerpc64le-unknown-linux-gnu -fsyntax-only \
+// RUN:   -mmma %s 2>&1 | FileCheck %s --check-prefix=NOMMA
+
+#ifdef __MMA__
+static_assert(false, "MMA enabled");
+#endif
+
+// HASMMA: MMA enabled
+// HASMMA-NOT: option '-mmma' cannot be specified with
+// NOMMA: option '-mmma' cannot be specified with
+

diff  --git a/clang/test/Preprocessor/init-ppc64.c 
b/clang/test/Preprocessor/init-ppc64.c
index dd965b86b879..120f1b3dba6a 100644
--- a/clang/test/Preprocessor/init-ppc64.c
+++ b/clang/test/Preprocessor/init-ppc64.c
@@ -648,7 +648,7 @@
 // PPCFUTURE:#define _ARCH_PWR_FUTURE 1
 // PPCFUTURE:#define __MMA__ 1
 //
-// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none 
-target-feature +mma -target-cpu power9 -fno-signed-char < /dev/null | 
FileCheck -check-prefix PPC-MMA %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none 
-target-feature +mma -target-cpu power10 -fno-signed-char < /dev/null | 
FileCheck -check-prefix PPC-MMA %s
 // PPC-MMA:#define __MMA__ 1
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none 
-target-feature +float128 -target-cpu power9 -fno-signed-char < /dev/null | 
FileCheck -check-prefix PPC-FLOAT128 %s



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


[PATCH] D91037: [clang-tidy] Fix crash in bugprone-redundant-branch-condition on ExprWithCleanups

2020-11-12 Thread Zinovy Nis via Phabricator via cfe-commits
zinovy.nis added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-redundant-branch-condition.cpp:1092
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: redundant condition 'isSet' 
[bugprone-redundant-branch-condition]
+  // CHECK-FIXES: {{isSet}}
+}

aaron.ballman wrote:
> zinovy.nis wrote:
> > aaron.ballman wrote:
> > > There's not a whole lot of context for FileCheck to determine if it's 
> > > been correctly applied or not (same below) -- for instance, won't this 
> > > pass even if no changes are applied because FileCheck is still going to 
> > > find `isSet` in the file?
> > Thanks. Fixed.
> Maybe it's just early in the morning for me, but... I was expecting the 
> transformation to be:
> ```
> if (RetT::Test(isSet).Ok() && isSet) {
>   if (RetT::Test(isSet).Ok() && isSet) {
>   }
> }
> ```
> turns into
> ```
> if (RetT::Test(isSet).Ok() && isSet) {
> }
> ```
> Why does it remove the `&& isSet` instead? That seems like it's changing the 
> logic here from `if (true && false)` to `if (true)`.
IMO it's correct.
`isSet` cannot change its value between `if`s while `RetT::Test(isSet).Ok()` 
can.
So we don't need to re-evaluate `isSet` and need to re-evaluate 
`RetT::Test(isSet).Ok()` only.



> That seems like it's changing the logic here from if (true && false) to if 
> (true).


As I understand only the second `if` is transformed.


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

https://reviews.llvm.org/D91037

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


[PATCH] D91037: [clang-tidy] Fix crash in bugprone-redundant-branch-condition on ExprWithCleanups

2020-11-12 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-redundant-branch-condition.cpp:1092
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: redundant condition 'isSet' 
[bugprone-redundant-branch-condition]
+  // CHECK-FIXES: {{isSet}}
+}

zinovy.nis wrote:
> aaron.ballman wrote:
> > zinovy.nis wrote:
> > > aaron.ballman wrote:
> > > > There's not a whole lot of context for FileCheck to determine if it's 
> > > > been correctly applied or not (same below) -- for instance, won't this 
> > > > pass even if no changes are applied because FileCheck is still going to 
> > > > find `isSet` in the file?
> > > Thanks. Fixed.
> > Maybe it's just early in the morning for me, but... I was expecting the 
> > transformation to be:
> > ```
> > if (RetT::Test(isSet).Ok() && isSet) {
> >   if (RetT::Test(isSet).Ok() && isSet) {
> >   }
> > }
> > ```
> > turns into
> > ```
> > if (RetT::Test(isSet).Ok() && isSet) {
> > }
> > ```
> > Why does it remove the `&& isSet` instead? That seems like it's changing 
> > the logic here from `if (true && false)` to `if (true)`.
> IMO it's correct.
> `isSet` cannot change its value between `if`s while `RetT::Test(isSet).Ok()` 
> can.
> So we don't need to re-evaluate `isSet` and need to re-evaluate 
> `RetT::Test(isSet).Ok()` only.
> 
> 
> 
> > That seems like it's changing the logic here from if (true && false) to if 
> > (true).
> 
> 
> As I understand only the second `if` is transformed.
Does this only trigger as a redundant branch condition if the definition of 
`RetT::Test()` is available? Because `Test()` takes a `bool&` so it sure seems 
like `isSet` could be modified between the branches if the definition isn't 
found because it's being passed as a non-const reference to `Test()`.


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

https://reviews.llvm.org/D91037

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


[clang] ac523d2 - [FPEnv][Clang][Driver] Use MarshallingInfoFlag for -fexperimental-strict-floating-point

2020-11-12 Thread Kevin P. Neal via cfe-commits

Author: Kevin P. Neal
Date: 2020-11-12T12:51:35-05:00
New Revision: ac523d2de51c4119ae6233200af07599d61de1fc

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

LOG: [FPEnv][Clang][Driver] Use MarshallingInfoFlag for 
-fexperimental-strict-floating-point

As of D80952 we are disabling strict floating point on all hosts except
those that are explicitly listed as supported. Use of strict floating point
on other hosts requires use of the -fexperimental-strict-floating-point
flag. This is to avoid bugs like "https://bugs.llvm.org/show_bug.cgi?id=45329";
(which has an incorrect link in the previous review).

In the review for D80952 I was asked to mark the -fexperimental option as
a MarshallingInfoFlag. This patch does exactly that.

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 6df4a0222484..245e6765d613 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1308,7 +1308,8 @@ def fexperimental_new_pass_manager : Flag<["-"], 
"fexperimental-new-pass-manager
   HelpText<"Enables an experimental new pass manager in LLVM.">;
 def fexperimental_strict_floating_point : Flag<["-"], 
"fexperimental-strict-floating-point">,
   Group, Flags<[CC1Option]>,
-  HelpText<"Enables experimental strict floating point in LLVM.">;
+  HelpText<"Enables experimental strict floating point in LLVM.">,
+  MarshallingInfoFlag<"LangOpts->ExpStrictFP">;
 def finput_charset_EQ : Joined<["-"], "finput-charset=">, Group;
 def fexec_charset_EQ : Joined<["-"], "fexec-charset=">, Group;
 def finstrument_functions : Flag<["-"], "finstrument-functions">, 
Group, Flags<[CC1Option]>,

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index b2ce88f6cf6b..ffcc3d359e62 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -3335,9 +3335,6 @@ static void ParseLangArgs(LangOptions &Opts, ArgList 
&Args, InputKind IK,
   Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Val;
   }
 
-  if (Args.hasArg(OPT_fexperimental_strict_floating_point))
-Opts.ExpStrictFP = true;
-
   auto FPRM = llvm::RoundingMode::NearestTiesToEven;
   if (Args.hasArg(OPT_frounding_math)) {
 FPRM = llvm::RoundingMode::Dynamic;



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


[PATCH] D88987: [FPEnv][Clang][Driver] Use MarshallingInfoFlag for -fexperimental-strict-floating-point

2020-11-12 Thread Kevin P. Neal via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGac523d2de51c: [FPEnv][Clang][Driver] Use MarshallingInfoFlag 
for -fexperimental-strict… (authored by kpn).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88987

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3335,9 +3335,6 @@
   Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Val;
   }
 
-  if (Args.hasArg(OPT_fexperimental_strict_floating_point))
-Opts.ExpStrictFP = true;
-
   auto FPRM = llvm::RoundingMode::NearestTiesToEven;
   if (Args.hasArg(OPT_frounding_math)) {
 FPRM = llvm::RoundingMode::Dynamic;
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1308,7 +1308,8 @@
   HelpText<"Enables an experimental new pass manager in LLVM.">;
 def fexperimental_strict_floating_point : Flag<["-"], 
"fexperimental-strict-floating-point">,
   Group, Flags<[CC1Option]>,
-  HelpText<"Enables experimental strict floating point in LLVM.">;
+  HelpText<"Enables experimental strict floating point in LLVM.">,
+  MarshallingInfoFlag<"LangOpts->ExpStrictFP">;
 def finput_charset_EQ : Joined<["-"], "finput-charset=">, Group;
 def fexec_charset_EQ : Joined<["-"], "fexec-charset=">, Group;
 def finstrument_functions : Flag<["-"], "finstrument-functions">, 
Group, Flags<[CC1Option]>,


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3335,9 +3335,6 @@
   Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Val;
   }
 
-  if (Args.hasArg(OPT_fexperimental_strict_floating_point))
-Opts.ExpStrictFP = true;
-
   auto FPRM = llvm::RoundingMode::NearestTiesToEven;
   if (Args.hasArg(OPT_frounding_math)) {
 FPRM = llvm::RoundingMode::Dynamic;
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1308,7 +1308,8 @@
   HelpText<"Enables an experimental new pass manager in LLVM.">;
 def fexperimental_strict_floating_point : Flag<["-"], "fexperimental-strict-floating-point">,
   Group, Flags<[CC1Option]>,
-  HelpText<"Enables experimental strict floating point in LLVM.">;
+  HelpText<"Enables experimental strict floating point in LLVM.">,
+  MarshallingInfoFlag<"LangOpts->ExpStrictFP">;
 def finput_charset_EQ : Joined<["-"], "finput-charset=">, Group;
 def fexec_charset_EQ : Joined<["-"], "fexec-charset=">, Group;
 def finstrument_functions : Flag<["-"], "finstrument-functions">, Group, Flags<[CC1Option]>,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91037: [clang-tidy] Fix crash in bugprone-redundant-branch-condition on ExprWithCleanups

2020-11-12 Thread Zinovy Nis via Phabricator via cfe-commits
zinovy.nis marked an inline comment as done.
zinovy.nis added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-redundant-branch-condition.cpp:1092
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: redundant condition 'isSet' 
[bugprone-redundant-branch-condition]
+  // CHECK-FIXES: {{isSet}}
+}

aaron.ballman wrote:
> zinovy.nis wrote:
> > aaron.ballman wrote:
> > > zinovy.nis wrote:
> > > > aaron.ballman wrote:
> > > > > There's not a whole lot of context for FileCheck to determine if it's 
> > > > > been correctly applied or not (same below) -- for instance, won't 
> > > > > this pass even if no changes are applied because FileCheck is still 
> > > > > going to find `isSet` in the file?
> > > > Thanks. Fixed.
> > > Maybe it's just early in the morning for me, but... I was expecting the 
> > > transformation to be:
> > > ```
> > > if (RetT::Test(isSet).Ok() && isSet) {
> > >   if (RetT::Test(isSet).Ok() && isSet) {
> > >   }
> > > }
> > > ```
> > > turns into
> > > ```
> > > if (RetT::Test(isSet).Ok() && isSet) {
> > > }
> > > ```
> > > Why does it remove the `&& isSet` instead? That seems like it's changing 
> > > the logic here from `if (true && false)` to `if (true)`.
> > IMO it's correct.
> > `isSet` cannot change its value between `if`s while 
> > `RetT::Test(isSet).Ok()` can.
> > So we don't need to re-evaluate `isSet` and need to re-evaluate 
> > `RetT::Test(isSet).Ok()` only.
> > 
> > 
> > 
> > > That seems like it's changing the logic here from if (true && false) to 
> > > if (true).
> > 
> > 
> > As I understand only the second `if` is transformed.
> Does this only trigger as a redundant branch condition if the definition of 
> `RetT::Test()` is available? Because `Test()` takes a `bool&` so it sure 
> seems like `isSet` could be modified between the branches if the definition 
> isn't found because it's being passed as a non-const reference to `Test()`.
1) 
> if the definition of RetT::Test() is available?

Removing the body from RetT::Test changes nothing.

2) Turning `RetT Test(bool &_isSet)` -> `RetT Test(bool _isSet)` also changes 
nothing.






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

https://reviews.llvm.org/D91037

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


[clang] b336826 - Non-implicit attribute creation requires a source range; NFC

2020-11-12 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2020-11-12T10:06:30-08:00
New Revision: b336826c1dd92adabef682f9b013b2e36bce066c

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

LOG: Non-implicit attribute creation requires a source range; NFC

There are two factory functions used to create a semantic attribute,
Create() and CreateImplicit(). CreateImplicit() does not need to
specify the source range of the attribute since it's an implicitly-
generated attribute. The same logic does not apply to Create(), so
this removes the default argument from those declarations to avoid
accidentally creating a semantic attribute without source location
information.

Added: 


Modified: 
clang/include/clang/Basic/Attr.td
clang/utils/TableGen/ClangAttrEmitter.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 7ae5803f1c30..62c97cb0440c 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -742,7 +742,7 @@ def Annotate : InheritableParamAttr {
   // '#pragma clang attribute' even though it has no subject list.
   let AdditionalMembers = [{
   static AnnotateAttr *Create(ASTContext &Ctx, llvm::StringRef Annotation, \
-  const AttributeCommonInfo &CommonInfo = {SourceRange{}}) {
+  const AttributeCommonInfo &CommonInfo) {
 return AnnotateAttr::Create(Ctx, Annotation, nullptr, 0, CommonInfo);
   }
   static AnnotateAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef 
Annotation, \

diff  --git a/clang/utils/TableGen/ClangAttrEmitter.cpp 
b/clang/utils/TableGen/ClangAttrEmitter.cpp
index 1ed81eefe981..ec109e134e20 100644
--- a/clang/utils/TableGen/ClangAttrEmitter.cpp
+++ b/clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -2367,7 +2367,7 @@ static void emitAttributes(RecordKeeper &Records, 
raw_ostream &OS,
 ai->writeCtorParameters(OS);
   }
   OS << ", const AttributeCommonInfo &CommonInfo";
-  if (Header)
+  if (Header && Implicit)
 OS << " = {SourceRange{}}";
   OS << ")";
   if (Header) {



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


[PATCH] D91366: Serialization: Hoist the check for in-flight diagnostics in ASTReader::getInputFile, NFC

2020-11-12 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith created this revision.
dexonsmith added a reviewer: jansvoboda11.
Herald added a subscriber: ributzka.
dexonsmith requested review of this revision.

This logic seems easier to follow without the `Error()` helper, and
checking `DiagnosticsEngine::isDiagnosticInFlight` just once up front.


https://reviews.llvm.org/D91366

Files:
  clang/include/clang/Serialization/ASTReader.h
  clang/lib/Serialization/ASTReader.cpp


Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -1246,12 +1246,6 @@
 Diag(DiagID) << Arg1 << Arg2 << Arg3;
 }
 
-void ASTReader::Error(unsigned DiagID, StringRef Arg1, StringRef Arg2,
-  unsigned Select) const {
-  if (!Diags.isDiagnosticInFlight())
-Diag(DiagID) << Arg1 << Arg2 << Select;
-}
-
 void ASTReader::Error(llvm::Error &&Err) const {
   Error(toString(std::move(Err)));
 }
@@ -2395,7 +2389,7 @@
   auto FileChange = HasInputFileChanged();
   // For an overridden file, there is nothing to validate.
   if (!Overridden && FileChange != ModificationType::None) {
-if (Complain) {
+if (Complain && !Diags.isDiagnosticInFlight()) {
   // Build a list of the PCH imports that got us here (in reverse).
   SmallVector ImportStack(1, &F);
   while (!ImportStack.back()->ImportedBy.empty())
@@ -2406,17 +2400,17 @@
   unsigned DiagnosticKind =
   moduleKindForDiagnostic(ImportStack.back()->Kind);
   if (DiagnosticKind == 0)
-Error(diag::err_fe_pch_file_modified, Filename, TopLevelPCHName,
-  (unsigned)FileChange);
+Diag(diag::err_fe_pch_file_modified)
+<< Filename << TopLevelPCHName << FileChange;
   else if (DiagnosticKind == 1)
-Error(diag::err_fe_module_file_modified, Filename, TopLevelPCHName,
-  (unsigned)FileChange);
+Diag(diag::err_fe_module_file_modified)
+<< Filename << TopLevelPCHName << FileChange;
   else
-Error(diag::err_fe_ast_file_modified, Filename, TopLevelPCHName,
-  (unsigned)FileChange);
+Diag(diag::err_fe_ast_file_modified)
+<< Filename << TopLevelPCHName << FileChange;
 
   // Print the import stack.
-  if (ImportStack.size() > 1 && !Diags.isDiagnosticInFlight()) {
+  if (ImportStack.size() > 1) {
 Diag(diag::note_pch_required_by)
   << Filename << ImportStack[0]->FileName;
 for (unsigned I = 1; I < ImportStack.size(); ++I)
@@ -2424,8 +2418,7 @@
 << ImportStack[I-1]->FileName << ImportStack[I]->FileName;
   }
 
-  if (!Diags.isDiagnosticInFlight())
-Diag(diag::note_pch_rebuild_required) << TopLevelPCHName;
+  Diag(diag::note_pch_rebuild_required) << TopLevelPCHName;
 }
 
 IsOutOfDate = true;
Index: clang/include/clang/Serialization/ASTReader.h
===
--- clang/include/clang/Serialization/ASTReader.h
+++ clang/include/clang/Serialization/ASTReader.h
@@ -1450,8 +1450,6 @@
   void Error(StringRef Msg) const;
   void Error(unsigned DiagID, StringRef Arg1 = StringRef(),
  StringRef Arg2 = StringRef(), StringRef Arg3 = StringRef()) const;
-  void Error(unsigned DiagID, StringRef Arg1, StringRef Arg2,
- unsigned Select) const;
   void Error(llvm::Error &&Err) const;
 
 public:


Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -1246,12 +1246,6 @@
 Diag(DiagID) << Arg1 << Arg2 << Arg3;
 }
 
-void ASTReader::Error(unsigned DiagID, StringRef Arg1, StringRef Arg2,
-  unsigned Select) const {
-  if (!Diags.isDiagnosticInFlight())
-Diag(DiagID) << Arg1 << Arg2 << Select;
-}
-
 void ASTReader::Error(llvm::Error &&Err) const {
   Error(toString(std::move(Err)));
 }
@@ -2395,7 +2389,7 @@
   auto FileChange = HasInputFileChanged();
   // For an overridden file, there is nothing to validate.
   if (!Overridden && FileChange != ModificationType::None) {
-if (Complain) {
+if (Complain && !Diags.isDiagnosticInFlight()) {
   // Build a list of the PCH imports that got us here (in reverse).
   SmallVector ImportStack(1, &F);
   while (!ImportStack.back()->ImportedBy.empty())
@@ -2406,17 +2400,17 @@
   unsigned DiagnosticKind =
   moduleKindForDiagnostic(ImportStack.back()->Kind);
   if (DiagnosticKind == 0)
-Error(diag::err_fe_pch_file_modified, Filename, TopLevelPCHName,
-  (unsigned)FileChange);
+Diag(diag::err_fe_pch_file_modified)
+<< Filename << TopLevelPCHName << FileChange;
   else if (DiagnosticKind == 1)
-Error(diag::err_fe_module_file_modified, Filename, TopLevelPCHName,
-  (unsigned)FileChange);
+Diag(di

[PATCH] D91367: Serialization: Merge three diagnostics to simplify ASTReader::getInputFile, NFC

2020-11-12 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith created this revision.
dexonsmith added a reviewer: jansvoboda11.
Herald added a subscriber: ributzka.
dexonsmith requested review of this revision.

Clean up the logic for `err_fe_{pch,module,ast}_file_modified` to use a
`select` like other ASTReader diagnostics. There should be no
functionality change here, just a cleanup.


https://reviews.llvm.org/D91367

Files:
  clang/include/clang/Basic/DiagnosticSerializationKinds.td
  clang/lib/Serialization/ASTReader.cpp


Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -2397,17 +2397,9 @@
 
   // The top-level PCH is stale.
   StringRef TopLevelPCHName(ImportStack.back()->FileName);
-  unsigned DiagnosticKind =
-  moduleKindForDiagnostic(ImportStack.back()->Kind);
-  if (DiagnosticKind == 0)
-Diag(diag::err_fe_pch_file_modified)
-<< Filename << TopLevelPCHName << FileChange;
-  else if (DiagnosticKind == 1)
-Diag(diag::err_fe_module_file_modified)
-<< Filename << TopLevelPCHName << FileChange;
-  else
-Diag(diag::err_fe_ast_file_modified)
-<< Filename << TopLevelPCHName << FileChange;
+  Diag(diag::err_fe_pch_file_modified)
+  << Filename << moduleKindForDiagnostic(ImportStack.back()->Kind)
+  << TopLevelPCHName << FileChange;
 
   // Print the import stack.
   if (ImportStack.size() > 1) {
Index: clang/include/clang/Basic/DiagnosticSerializationKinds.td
===
--- clang/include/clang/Basic/DiagnosticSerializationKinds.td
+++ clang/include/clang/Basic/DiagnosticSerializationKinds.td
@@ -18,16 +18,9 @@
 def err_fe_pch_malformed_block : Error<
 "malformed block record in PCH file: '%0'">, DefaultFatal;
 def err_fe_pch_file_modified : Error<
-"file '%0' has been modified since the precompiled header '%1' was built"
-": %select{size|mtime|content}2 changed">,
-DefaultFatal;
-def err_fe_module_file_modified : Error<
-"file '%0' has been modified since the module file '%1' was built"
-": %select{size|mtime|content}2 changed">,
-DefaultFatal;
-def err_fe_ast_file_modified : Error<
-"file '%0' has been modified since the AST file '%1' was built"
-": %select{size|mtime|content}2 changed">,
+"file '%0' has been modified since the "
+"%select{precompiled header|module file|AST file}1 '%2' was built"
+": %select{size|mtime|content}3 changed">,
 DefaultFatal;
 def err_fe_pch_file_overridden : Error<
 "file '%0' from the precompiled header has been overridden">;


Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -2397,17 +2397,9 @@
 
   // The top-level PCH is stale.
   StringRef TopLevelPCHName(ImportStack.back()->FileName);
-  unsigned DiagnosticKind =
-  moduleKindForDiagnostic(ImportStack.back()->Kind);
-  if (DiagnosticKind == 0)
-Diag(diag::err_fe_pch_file_modified)
-<< Filename << TopLevelPCHName << FileChange;
-  else if (DiagnosticKind == 1)
-Diag(diag::err_fe_module_file_modified)
-<< Filename << TopLevelPCHName << FileChange;
-  else
-Diag(diag::err_fe_ast_file_modified)
-<< Filename << TopLevelPCHName << FileChange;
+  Diag(diag::err_fe_pch_file_modified)
+  << Filename << moduleKindForDiagnostic(ImportStack.back()->Kind)
+  << TopLevelPCHName << FileChange;
 
   // Print the import stack.
   if (ImportStack.size() > 1) {
Index: clang/include/clang/Basic/DiagnosticSerializationKinds.td
===
--- clang/include/clang/Basic/DiagnosticSerializationKinds.td
+++ clang/include/clang/Basic/DiagnosticSerializationKinds.td
@@ -18,16 +18,9 @@
 def err_fe_pch_malformed_block : Error<
 "malformed block record in PCH file: '%0'">, DefaultFatal;
 def err_fe_pch_file_modified : Error<
-"file '%0' has been modified since the precompiled header '%1' was built"
-": %select{size|mtime|content}2 changed">,
-DefaultFatal;
-def err_fe_module_file_modified : Error<
-"file '%0' has been modified since the module file '%1' was built"
-": %select{size|mtime|content}2 changed">,
-DefaultFatal;
-def err_fe_ast_file_modified : Error<
-"file '%0' has been modified since the AST file '%1' was built"
-": %select{size|mtime|content}2 changed">,
+"file '%0' has been modified since the "
+"%select{precompiled header|module file|AST file}1 '%2' was built"
+": %select{size|mtime|content}3 changed">,
 DefaultFatal;
 def err_fe_pch_file_overridden : Error<
 "file '%0' from the precompiled header has been overridden">;
___

[PATCH] D91184: [clang-tidy] Merge options inplace instead of copying

2020-11-12 Thread Nathan James via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG06db8f984f1a: [clang-tidy] Merge options inplace instead of 
copying (authored by njames93).

Changed prior to commit:
  https://reviews.llvm.org/D91184?vs=304237&id=304892#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91184

Files:
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
  clang-tools-extra/clang-tidy/ClangTidyOptions.h
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp

Index: clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
@@ -103,7 +103,7 @@
   UseColor: true
   )");
   ASSERT_TRUE(!!Options2);
-  ClangTidyOptions Options = Options1->mergeWith(*Options2, 0);
+  ClangTidyOptions Options = Options1->merge(*Options2, 0);
   EXPECT_EQ("check1,check2,check3,check4", *Options.Checks);
   EXPECT_EQ("filter2", *Options.HeaderFilterRegex);
   EXPECT_EQ("user2", *Options.User);
Index: clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
@@ -319,7 +319,7 @@
 if (ParsedConfig)
   return std::make_unique(
   GlobalOptions,
-  ClangTidyOptions::getDefaults().mergeWith(DefaultOptions, 0),
+  ClangTidyOptions::getDefaults().merge(DefaultOptions, 0),
   *ParsedConfig, OverrideOptions, std::move(FS));
 llvm::errs() << "Error: invalid configuration specified.\n"
  << ParsedConfig.getError().message() << "\n";
@@ -455,9 +455,8 @@
   if (DumpConfig) {
 EffectiveOptions.CheckOptions =
 getCheckOptions(EffectiveOptions, AllowEnablingAnalyzerAlphaCheckers);
-llvm::outs() << configurationAsText(
-ClangTidyOptions::getDefaults().mergeWith(
-EffectiveOptions, 0))
+llvm::outs() << configurationAsText(ClangTidyOptions::getDefaults().merge(
+EffectiveOptions, 0))
  << "\n";
 return 0;
   }
Index: clang-tools-extra/clang-tidy/ClangTidyOptions.h
===
--- clang-tools-extra/clang-tidy/ClangTidyOptions.h
+++ clang-tools-extra/clang-tidy/ClangTidyOptions.h
@@ -55,11 +55,15 @@
   /// of each registered \c ClangTidyModule.
   static ClangTidyOptions getDefaults();
 
+  /// Overwrites all fields in here by the fields of \p Other that have a value.
+  /// \p Order specifies precedence of \p Other option.
+  ClangTidyOptions &mergeWith(const ClangTidyOptions &Other, unsigned Order);
+
   /// Creates a new \c ClangTidyOptions instance combined from all fields
   /// of this instance overridden by the fields of \p Other that have a value.
   /// \p Order specifies precedence of \p Other option.
-  ClangTidyOptions mergeWith(const ClangTidyOptions &Other,
- unsigned Order) const;
+  LLVM_NODISCARD ClangTidyOptions merge(const ClangTidyOptions &Other,
+unsigned Order) const;
 
   /// Checks filter.
   llvm::Optional Checks;
Index: clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
===
--- clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
+++ clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
@@ -116,7 +116,7 @@
   Options.User = llvm::None;
   for (const ClangTidyModuleRegistry::entry &Module :
ClangTidyModuleRegistry::entries())
-Options = Options.mergeWith(Module.instantiate()->getModuleOptions(), 0);
+Options.mergeWith(Module.instantiate()->getModuleOptions(), 0);
   return Options;
 }
 
@@ -142,27 +142,31 @@
 Dest = Src;
 }
 
-ClangTidyOptions ClangTidyOptions::mergeWith(const ClangTidyOptions &Other,
- unsigned Priority) const {
-  ClangTidyOptions Result = *this;
-
-  mergeCommaSeparatedLists(Result.Checks, Other.Checks);
-  mergeCommaSeparatedLists(Result.WarningsAsErrors, Other.WarningsAsErrors);
-  overrideValue(Result.HeaderFilterRegex, Other.HeaderFilterRegex);
-  overrideValue(Result.SystemHeaders, Other.SystemHeaders);
-  overrideValue(Result.FormatStyle, Other.FormatStyle);
-  overrideValue(Result.User, Other.User);
-  overrideValue(Result.UseColor, Other.UseColor);
-  mergeVectors(Result.ExtraArgs, Other.ExtraArgs);
-  mergeVectors(Result.ExtraArgsBefore, Other.ExtraArgsBefore);
+ClangTidyOptions &ClangTidyOptions::mergeWith(const ClangTidyOptions &Other,
+   

[clang-tools-extra] 06db8f9 - [clang-tidy] Merge options inplace instead of copying

2020-11-12 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2020-11-12T18:19:12Z
New Revision: 06db8f984f1a31e299af7d9ea584061d244caad6

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

LOG: [clang-tidy] Merge options inplace instead of copying

Changed `ClangTidyOptions::mergeWith` to operate on the instance instead of 
returning a copy. The old mergeWith method has been renamed to merge and marked 
as nodiscard, to aid in disambiguating which one is which.

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
clang-tools-extra/clang-tidy/ClangTidyOptions.h
clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp 
b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
index 2b137d0b5113..e7b5b1db08eb 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -205,7 +205,7 @@ const ClangTidyOptions &ClangTidyContext::getOptions() 
const {
 ClangTidyOptions ClangTidyContext::getOptionsForFile(StringRef File) const {
   // Merge options on top of getDefaults() as a safeguard against options with
   // unset values.
-  return ClangTidyOptions::getDefaults().mergeWith(
+  return ClangTidyOptions::getDefaults().merge(
   OptionsProvider->getOptions(File), 0);
 }
 

diff  --git a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp 
b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
index 8c78f289502f..950a64f4c274 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
@@ -116,7 +116,7 @@ ClangTidyOptions ClangTidyOptions::getDefaults() {
   Options.User = llvm::None;
   for (const ClangTidyModuleRegistry::entry &Module :
ClangTidyModuleRegistry::entries())
-Options = Options.mergeWith(Module.instantiate()->getModuleOptions(), 0);
+Options.mergeWith(Module.instantiate()->getModuleOptions(), 0);
   return Options;
 }
 
@@ -142,27 +142,31 @@ static void overrideValue(Optional &Dest, const 
Optional &Src) {
 Dest = Src;
 }
 
-ClangTidyOptions ClangTidyOptions::mergeWith(const ClangTidyOptions &Other,
- unsigned Priority) const {
-  ClangTidyOptions Result = *this;
-
-  mergeCommaSeparatedLists(Result.Checks, Other.Checks);
-  mergeCommaSeparatedLists(Result.WarningsAsErrors, Other.WarningsAsErrors);
-  overrideValue(Result.HeaderFilterRegex, Other.HeaderFilterRegex);
-  overrideValue(Result.SystemHeaders, Other.SystemHeaders);
-  overrideValue(Result.FormatStyle, Other.FormatStyle);
-  overrideValue(Result.User, Other.User);
-  overrideValue(Result.UseColor, Other.UseColor);
-  mergeVectors(Result.ExtraArgs, Other.ExtraArgs);
-  mergeVectors(Result.ExtraArgsBefore, Other.ExtraArgsBefore);
+ClangTidyOptions &ClangTidyOptions::mergeWith(const ClangTidyOptions &Other,
+  unsigned Order) {
+  mergeCommaSeparatedLists(Checks, Other.Checks);
+  mergeCommaSeparatedLists(WarningsAsErrors, Other.WarningsAsErrors);
+  overrideValue(HeaderFilterRegex, Other.HeaderFilterRegex);
+  overrideValue(SystemHeaders, Other.SystemHeaders);
+  overrideValue(FormatStyle, Other.FormatStyle);
+  overrideValue(User, Other.User);
+  overrideValue(UseColor, Other.UseColor);
+  mergeVectors(ExtraArgs, Other.ExtraArgs);
+  mergeVectors(ExtraArgsBefore, Other.ExtraArgsBefore);
 
   for (const auto &KeyValue : Other.CheckOptions) {
-Result.CheckOptions.insert_or_assign(
+CheckOptions.insert_or_assign(
 KeyValue.getKey(),
 ClangTidyValue(KeyValue.getValue().Value,
-   KeyValue.getValue().Priority + Priority));
+   KeyValue.getValue().Priority + Order));
   }
+  return *this;
+}
 
+ClangTidyOptions ClangTidyOptions::merge(const ClangTidyOptions &Other,
+ unsigned Order) const {
+  ClangTidyOptions Result = *this;
+  Result.mergeWith(Other, Order);
   return Result;
 }
 
@@ -178,8 +182,8 @@ ClangTidyOptions
 ClangTidyOptionsProvider::getOptions(llvm::StringRef FileName) {
   ClangTidyOptions Result;
   unsigned Priority = 0;
-  for (const auto &Source : getRawOptions(FileName))
-Result = Result.mergeWith(Source.first, ++Priority);
+  for (auto &Source : getRawOptions(FileName))
+Result.mergeWith(Source.first, ++Priority);
   return Result;
 }
 

diff  --git a/clang-tools-extra/clang-tidy/ClangTidyOptions.h 
b/clang-tools-extra/clang-tidy/ClangTidyOptions.h
ind

[PATCH] D91368: Frontend: Split out addVFSOverlays from createVFSFromCompilerInvocation, NFC

2020-11-12 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith created this revision.
dexonsmith added reviewers: JDevlieghere, jansvoboda11, akyrtzi.
Herald added a subscriber: ributzka.
dexonsmith requested review of this revision.

This is a prep patch to reduce noise in a follow-up, which will add
another layer.


https://reviews.llvm.org/D91368

Files:
  clang/lib/Frontend/CompilerInvocation.cpp


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -4028,10 +4028,9 @@
  llvm::vfs::getRealFileSystem());
 }
 
-IntrusiveRefCntPtr
-clang::createVFSFromCompilerInvocation(
-const CompilerInvocation &CI, DiagnosticsEngine &Diags,
-IntrusiveRefCntPtr BaseFS) {
+static IntrusiveRefCntPtr
+addVFSOverlays(const CompilerInvocation &CI, DiagnosticsEngine &Diags,
+   IntrusiveRefCntPtr BaseFS) {
   if (CI.getHeaderSearchOpts().VFSOverlayFiles.empty())
 return BaseFS;
 
@@ -4057,3 +4056,12 @@
   }
   return Result;
 }
+
+IntrusiveRefCntPtr
+clang::createVFSFromCompilerInvocation(
+const CompilerInvocation &CI, DiagnosticsEngine &Diags,
+IntrusiveRefCntPtr BaseFS) {
+  IntrusiveRefCntPtr FS = std::move(BaseFS);
+  FS = addVFSOverlays(CI, Diags, std::move(FS));
+  return FS;
+}


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -4028,10 +4028,9 @@
  llvm::vfs::getRealFileSystem());
 }
 
-IntrusiveRefCntPtr
-clang::createVFSFromCompilerInvocation(
-const CompilerInvocation &CI, DiagnosticsEngine &Diags,
-IntrusiveRefCntPtr BaseFS) {
+static IntrusiveRefCntPtr
+addVFSOverlays(const CompilerInvocation &CI, DiagnosticsEngine &Diags,
+   IntrusiveRefCntPtr BaseFS) {
   if (CI.getHeaderSearchOpts().VFSOverlayFiles.empty())
 return BaseFS;
 
@@ -4057,3 +4056,12 @@
   }
   return Result;
 }
+
+IntrusiveRefCntPtr
+clang::createVFSFromCompilerInvocation(
+const CompilerInvocation &CI, DiagnosticsEngine &Diags,
+IntrusiveRefCntPtr BaseFS) {
+  IntrusiveRefCntPtr FS = std::move(BaseFS);
+  FS = addVFSOverlays(CI, Diags, std::move(FS));
+  return FS;
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71880: [clangd] Implement Decl canonicalization rules for rename

2020-11-12 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 304893.
kbobyrev added a comment.

Remove unused header (was added for llvm_unreachable).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71880

Files:
  clang-tools-extra/clangd/refactor/Rename.cpp

Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -18,7 +18,6 @@
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/Basic/SourceLocation.h"
-#include "clang/Tooling/Refactoring/Rename/USRFindingAction.h"
 #include "clang/Tooling/Syntax/Tokens.h"
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/STLExtras.h"
@@ -76,6 +75,8 @@
   return OtherFile;
 }
 
+const NamedDecl *canonicalRenameDecl(const NamedDecl *D);
+
 llvm::DenseSet locateDeclAt(ParsedAST &AST,
SourceLocation TokenStartLoc) {
   unsigned Offset =
@@ -91,9 +92,7 @@
   for (const NamedDecl *D :
targetDecl(SelectedNode->ASTNode,
   DeclRelation::Alias | DeclRelation::TemplatePattern)) {
-// Get to CXXRecordDecl from constructor or destructor.
-D = tooling::getCanonicalSymbolDeclaration(D);
-Result.insert(D);
+Result.insert(canonicalRenameDecl(D));
   }
   return Result;
 }
@@ -222,23 +221,73 @@
   return error("Cannot rename symbol: {0}", Message(Reason));
 }
 
+const NamedDecl *canonicalRenameDecl(const TemplateDecl *D) {
+  return D->getTemplatedDecl();
+}
+
+const NamedDecl *canonicalRenameDecl(const CXXMethodDecl *D) {
+  const auto *Result = D;
+  if (const auto *InstantiatedMethod = D->getInstantiatedFromMemberFunction())
+Result = cast(InstantiatedMethod);
+  while (Result->isVirtual() && Result->size_overridden_methods())
+Result = *Result->overridden_methods().begin();
+  return Result;
+}
+
+const NamedDecl *canonicalRenameDecl(const FunctionDecl *D) {
+  if (const auto *Template = D->getPrimaryTemplate())
+return canonicalRenameDecl(Template);
+  return D;
+}
+
+const NamedDecl *canonicalRenameDecl(const FunctionTemplateDecl *D) {
+  const auto *TemplatedDecl = D->getTemplatedDecl();
+  if (const auto *Primary = TemplatedDecl->getPrimaryTemplate())
+return Primary;
+  return TemplatedDecl;
+}
+
+const NamedDecl *canonicalRenameDecl(const VarTemplateSpecializationDecl *D) {
+  return D->getSpecializedTemplate()->getTemplatedDecl();
+}
+
+const NamedDecl *canonicalRenameDecl(const ClassTemplateSpecializationDecl *D) {
+  return D->getSpecializedTemplate()->getTemplatedDecl();
+}
+
+// Canonical declarations help simplify the process of renaming. Examples:
+// - Given a constructor/destructor, canonical declaration is the parent
+//   CXXRecordDecl
+// - Specializations should point to the specialized declaration.
+// - Instantiations should point to instantiated declaration.
+const NamedDecl *canonicalRenameDecl(const NamedDecl *D) {
+  D = dyn_cast(D->getCanonicalDecl());
+  if (const auto *Constructor = dyn_cast(D))
+return canonicalRenameDecl(Constructor->getParent());
+  if (const auto *Destructor = dyn_cast(D))
+return canonicalRenameDecl(Destructor->getParent());
+  if (const auto *FuctionTemplate = dyn_cast(D))
+return canonicalRenameDecl(FuctionTemplate);
+  if (const auto *VarTemplate = dyn_cast(D))
+return canonicalRenameDecl(VarTemplate);
+  if (const auto *Template = dyn_cast(D))
+return canonicalRenameDecl(Template);
+  if (const auto *ClassTemplateSpecialization =
+  dyn_cast(D))
+return canonicalRenameDecl(ClassTemplateSpecialization);
+  if (const auto *Method = dyn_cast(D))
+return canonicalRenameDecl(Method);
+  if (const auto *Function = dyn_cast(D))
+return canonicalRenameDecl(Function);
+  return D;
+}
+
 // Return all rename occurrences in the main file.
 std::vector findOccurrencesWithinFile(ParsedAST &AST,
   const NamedDecl &ND) {
   trace::Span Tracer("FindOccurrencesWithinFile");
-  // If the cursor is at the underlying CXXRecordDecl of the
-  // ClassTemplateDecl, ND will be the CXXRecordDecl. In this case, we need to
-  // get the primary template manually.
-  // getUSRsForDeclaration will find other related symbols, e.g. virtual and its
-  // overriddens, primary template and all explicit specializations.
-  // FIXME: Get rid of the remaining tooling APIs.
-  const auto *RenameDecl =
-  ND.getDescribedTemplate() ? ND.getDescribedTemplate() : &ND;
-  std::vector RenameUSRs =
-  tooling::getUSRsForDeclaration(RenameDecl, AST.getASTContext());
-  llvm::DenseSet TargetIDs;
-  for (auto &USR : RenameUSRs)
-TargetIDs.insert(SymbolID(USR));
+  assert(canonicalRenameDecl(&ND) == &ND &&
+ "ND should be already canonicalized.");
 
   std::vector Results;
   for (Decl *TopLevelDecl : AST.getL

[PATCH] D90892: [AIX][FE] Support constructor/destructor attribute

2020-11-12 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L updated this revision to Diff 304896.
Xiangling_L added a comment.

Fix minor issues in the testcase;


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

https://reviews.llvm.org/D90892

Files:
  clang/lib/CodeGen/CGDeclCXX.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/aix-constructor-attribute.cpp
  clang/test/CodeGen/aix-destructor-attribute.cpp
  clang/test/CodeGen/aix-sinit-register-global-dtors-with-atexit.cpp
  clang/test/CodeGenCXX/aix-constructor-attribute.cpp
  clang/test/CodeGenCXX/aix-destructor-attribute.cpp
  clang/test/CodeGenCXX/aix-sinit-register-global-dtors-with-atexit.cpp

Index: clang/test/CodeGenCXX/aix-sinit-register-global-dtors-with-atexit.cpp
===
--- clang/test/CodeGenCXX/aix-sinit-register-global-dtors-with-atexit.cpp
+++ clang/test/CodeGenCXX/aix-sinit-register-global-dtors-with-atexit.cpp
@@ -1,14 +1,80 @@
-// RUN: not %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ \
-// RUN: -fregister-global-dtors-with-atexit < %s 2>&1 | \
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -x c++ -emit-llvm \
+// RUN: -fno-use-cxa-atexit -fregister-global-dtors-with-atexit < %s | \
 // 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: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -x c++ -emit-llvm \
+// RUN: -fno-use-cxa-atexit -fregister-global-dtors-with-atexit < %s | \
 // RUN:   FileCheck %s
 
-struct T {
-  T();
-  ~T();
+int bar() __attribute__((destructor(100)));
+int bar2() __attribute__((destructor(65535)));
+int bar3(int a) __attribute__((destructor(65535)));
+
+int bar() {
+  return 1;
+}
+
+int bar2() {
+  return 2;
+}
+
+int bar3(int a) {
+  return 3;
+}
+
+struct test {
+  test();
+  ~test();
 } t;
 
-// CHECK: error in backend: register global dtors with atexit() is not supported yet
+// CHECK: @llvm.global_ctors = appending global [3 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__sub_I__, i8* null }, { i32, void ()*, i8* } { i32 100, void ()* @__GLOBAL_init_100, i8* null }, { i32, void ()*, i8* } { i32 65535, void ()* @__GLOBAL_init_65535, i8* null }]
+// CHECK: @llvm.global_dtors = appending global [3 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__D_a, i8* null }, { i32, void ()*, i8* } { i32 100, void ()* @__GLOBAL_cleanup_100, i8* null }, { i32, void ()*, i8* } { i32 65535, void ()* @__GLOBAL_cleanup_65535, i8* null }]
+
+// CHECK: define internal void @__GLOBAL_init_100() [[ATTR:#[0-9]+]] {
+// CHECK: entry:
+// CHECK:   %0 = call i32 @atexit(void ()* bitcast (i32 ()* @_Z3barv to void ()*))
+// CHECK:   ret void
+// CHECK: }
+
+// CHECK: define internal void @__GLOBAL_init_65535() [[ATTR:#[0-9]+]] {
+// CHECK: entry:
+// CHECK:   %0 = call i32 @atexit(void ()* bitcast (i32 ()* @_Z4bar2v to void ()*))
+// CHECK:   %1 = call i32 @atexit(void ()* bitcast (i32 (i32)* @_Z4bar3i to void ()*))
+// CHECK:   ret void
+// CHECK: }
+
+// CHECK: define internal void @__GLOBAL_cleanup_100() [[ATTR:#[0-9]+]] {
+// CHECK: entry:
+// CHECK:   %0 = call i32 @unatexit(void ()* bitcast (i32 ()* @_Z3barv to void ()*))
+// CHECK:   %needs_destruct = icmp eq i32 %0, 0
+// CHECK:   br i1 %needs_destruct, label %destruct.call, label %destruct.end
+
+// CHECK: destruct.call:
+// CHECK:   call void bitcast (i32 ()* @_Z3barv to void ()*)()
+// CHECK:   br label %destruct.end
+
+// CHECK: destruct.end:
+// CHECK:   ret void
+// CHECK: }
+
+// CHECK: define internal void @__GLOBAL_cleanup_65535() [[ATTR:#[0-9]+]] {
+// CHECK: entry:
+// CHECK:   %0 = call i32 @unatexit(void ()* bitcast (i32 (i32)* @_Z4bar3i to void ()*))
+// CHECK:   %needs_destruct = icmp eq i32 %0, 0
+// CHECK:   br i1 %needs_destruct, label %destruct.call, label %unatexit.call
+
+// CHECK: destruct.call:
+// CHECK:   call void bitcast (i32 (i32)* @_Z4bar3i to void ()*)()
+// CHECK:   br label %unatexit.call
+
+// CHECK: unatexit.call:
+// CHECK:   %1 = call i32 @unatexit(void ()* bitcast (i32 ()* @_Z4bar2v to void ()*))
+// CHECK:   %needs_destruct1 = icmp eq i32 %1, 0
+// CHECK:   br i1 %needs_destruct1, label %destruct.call2, label %destruct.end
+
+// CHECK: destruct.call2:
+// CHECK:   call void bitcast (i32 ()* @_Z4bar2v to void ()*)()
+// CHECK:   br label %destruct.end
+
+// CHECK: destruct.end:
+// CHECK:   ret void
+// CHECK: }
Index: clang/test/CodeGenCXX/aix-destructor-attribute.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/aix-destructor-attribute.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -x c++ -emit-llvm \
+// RUN: -fno-use-cxa-atexit < %s | \
+// RUN:   FileCh

[PATCH] D91037: [clang-tidy] Fix crash in bugprone-redundant-branch-condition on ExprWithCleanups

2020-11-12 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!




Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-redundant-branch-condition.cpp:1092
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: redundant condition 'isSet' 
[bugprone-redundant-branch-condition]
+  // CHECK-FIXES: {{isSet}}
+}

zinovy.nis wrote:
> aaron.ballman wrote:
> > zinovy.nis wrote:
> > > aaron.ballman wrote:
> > > > zinovy.nis wrote:
> > > > > aaron.ballman wrote:
> > > > > > There's not a whole lot of context for FileCheck to determine if 
> > > > > > it's been correctly applied or not (same below) -- for instance, 
> > > > > > won't this pass even if no changes are applied because FileCheck is 
> > > > > > still going to find `isSet` in the file?
> > > > > Thanks. Fixed.
> > > > Maybe it's just early in the morning for me, but... I was expecting the 
> > > > transformation to be:
> > > > ```
> > > > if (RetT::Test(isSet).Ok() && isSet) {
> > > >   if (RetT::Test(isSet).Ok() && isSet) {
> > > >   }
> > > > }
> > > > ```
> > > > turns into
> > > > ```
> > > > if (RetT::Test(isSet).Ok() && isSet) {
> > > > }
> > > > ```
> > > > Why does it remove the `&& isSet` instead? That seems like it's 
> > > > changing the logic here from `if (true && false)` to `if (true)`.
> > > IMO it's correct.
> > > `isSet` cannot change its value between `if`s while 
> > > `RetT::Test(isSet).Ok()` can.
> > > So we don't need to re-evaluate `isSet` and need to re-evaluate 
> > > `RetT::Test(isSet).Ok()` only.
> > > 
> > > 
> > > 
> > > > That seems like it's changing the logic here from if (true && false) to 
> > > > if (true).
> > > 
> > > 
> > > As I understand only the second `if` is transformed.
> > Does this only trigger as a redundant branch condition if the definition of 
> > `RetT::Test()` is available? Because `Test()` takes a `bool&` so it sure 
> > seems like `isSet` could be modified between the branches if the definition 
> > isn't found because it's being passed as a non-const reference to `Test()`.
> 1) 
> > if the definition of RetT::Test() is available?
> 
> Removing the body from RetT::Test changes nothing.
> 
> 2) Turning `RetT Test(bool &_isSet)` -> `RetT Test(bool _isSet)` also changes 
> nothing.
> 
> 
> 
> 
Given the following four ways of declaring `Test()`:
```
static RetT Test(bool &_isSet); // #1
static RetT Test(bool _isSet); // #2
static RetT Test(const bool &_isSet); // #3
static RetT Test(bool &_isSet) { return 0; } // #4
```
I would expect #2 and #3 to behave the same way -- the `isSet` argument could 
never be modified by calling `Test()` and so the second `Test(isSet) && isSet` 
is partially redundant and the second `if` statement can drop the ` && isSet`. 
(Without dropping the `Test(isSet)` because the call could still modify some 
global somewhere, etc.)

I would expect #1 to not modify the second `if` statement at all because 
there's no way of knowing whether `Test(isSet) && isSet` is the same between 
the first `if` statement and the second one (because the second call to 
`Test(isSet)` may modify `isSet` in a way the caller can observe).

Ideally, #4 would be a case where we could remove the entire second `if` 
statement because we can identify that not only does `isSet` not get modified 
despite being passed by non-const reference, we can see that the `Test()` 
function doesn't modify any state at all. However, this seems like it would 
require data flow analysis and so I think it makes sense to treat #4 the same 
as #1.

That said, I just realized the check isn't being very careful with reference 
parameters in the first place: https://godbolt.org/z/P1aP3W, so your changes 
aren't introducing a new problem, they just happened to highlight an existing 
issue.


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

https://reviews.llvm.org/D91037

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


[PATCH] D90870: [NFC][NewPM] Reuse PassBuilder callbacks with -O0

2020-11-12 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen accepted this revision.
ychen added a comment.
This revision is now accepted and ready to land.

This is NFC and looks like a nice cleaup. So LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90870

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


[PATCH] D91370: [OPENMP]Fix PR48076: Check map types array before accessing its front.

2020-11-12 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev created this revision.
ABataev added a reviewer: jdoerfert.
Herald added subscribers: guansong, yaxunl.
Herald added a project: clang.
ABataev requested review of this revision.
Herald added a subscriber: sstefan1.

Need to check if there are map types for the components before trying to
access them when trying to modify type mappings for combined partial
mappings.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91370

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/target_data_member_codegen.cpp


Index: clang/test/OpenMP/target_data_member_codegen.cpp
===
--- /dev/null
+++ clang/test/OpenMP/target_data_member_codegen.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple 
i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | 
FileCheck %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple 
i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -triple 
i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch 
%t -verify %s -emit-llvm -o - | FileCheck %s
+
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify 
%s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown 
-fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown 
-fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple i386-unknown-unknown 
-fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s 
-emit-llvm -o - | FileCheck %s
+
+// RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify 
%s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple i386-unknown-unknown 
-fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck 
--check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple 
i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -triple i386-unknown-unknown 
-fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s 
-emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
+
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+// CHECK: [[MAPTYPES:@.+]] = private unnamed_addr constant [1 x i64] 
zeroinitializer
+struct S {
+double *p;
+};
+
+// CHECK-LABEL: @main
+int main() {
+  // CHECK: call i32 @__tgt_target_mapper(i64 -1, i8* @.{{.+}}, i32 1, i8** 
%{{.+}}, i8** %{{.+}}, i64* %{{.+}}, i64* getelementptr inbounds ([1 x i64], [1 
x i64]* [[MAPTYPES]], i32 0, i32 0), i8** null)
+S s;
+#pragma omp target map(s.p)
+{ }
+}
+#endif //HEADER
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -8214,8 +8214,9 @@
   return Type & OMP_MAP_PRESENT;
 }))
   CombinedInfo.Types.back() |= OMP_MAP_PRESENT;
-// Remove TARGET_PARAM flag from the first element
-CurTypes.front() &= ~OMP_MAP_TARGET_PARAM;
+// Remove TARGET_PARAM flag from the first element if any.
+if (!CurTypes.empty())
+  CurTypes.front() &= ~OMP_MAP_TARGET_PARAM;
 
 // All other current entries will be MEMBER_OF the comb

[PATCH] D90622: clang: Don't assert on no_unique_address fields in @encode()

2020-11-12 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D90622

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


[PATCH] D89869: [OpenCL] Define OpenCL feature macros for all versions

2020-11-12 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In D89869#2388499 , @azabaznov wrote:

> Addressed all concerns except replacing //__opencl_c_int64 //definition into 
> header. The reason for this as follows: this macro should be predefined 
> regardless if clang includes default header or not.

FYI clang doesn't provide full support of OpenCL without the header. In fact, 
there is ongoing work on making the header included by default without any 
flag. But I can see that this functionality is related to the frontend and not 
something that is simply added via libraries so I don't have strong objections 
for adding it in the clang source code. However, the macro can be added without 
registering the new extension (see how `__IMAGE_SUPPORT__` is added for 
example). Right now you are adding a pragma and a target setting that targets 
can modify without any effect, so I would like to avoid these.

My preference would be if you prepare a separate patch for this. Smaller 
selfcontained patches are easier and faster to review and also it reduces gaps 
in testing.




Comment at: clang/include/clang/Basic/OpenCLExtensions.def:100
+// OpenCL features
+OPENCLFEAT_INTERNAL(__opencl_c_pipes, 200, ~0U)
+OPENCLFEAT_INTERNAL(__opencl_c_generic_address_space, 200, ~0U)

Btw I guess we don't need the last parameter for the features since it's always 
0?



Comment at: clang/include/clang/Basic/OpenCLExtensions.def:109
+OPENCLFEAT_INTERNAL(__opencl_c_program_scope_global_variables, 200, ~0U)
+OPENCLFEAT_INTERNAL(__opencl_c_fp64, 120, ~0U)
+OPENCLFEAT_INTERNAL(__opencl_c_images, 100, ~0U)

I am thinking maybe we could add an extra parameter where we can specify the 
extension it is aliased to:

```
OPENCLFEAT_INTERNAL(__opencl_c_fp64, 120, ~0U, cl_khr_fp64)
```

Then it makes clearer which features correspond to which extensions and you can 
populate `EquivalentFeaturesExtensions` from this field? Moreover, you can then 
even make a map of references to `OpenCLOptions::Info` so you don't need to 
look them up from the name every time.


The drawback is that we need an extra parameter that is mainly empty... however 
we could recycle the last parameter that is always 0 right now.




Comment at: clang/include/clang/Basic/OpenCLOptions.h:27
 bool Enabled;   // Is this option enabled
+bool IsFeature; // Is this OpenCL feature
 unsigned Avail; // Option starts to be available in this OpenCL version

Ok, let's add spec reference where the feature is described so something like:
OpenCL 3.0 s6.2.1



Comment at: clang/include/clang/Basic/OpenCLOptions.h:37
+  // OpenCL Version
+  unsigned CLVer = 120;
+  bool IsOpenCLCPlusPlus = false;

Ok, I see why you are adding this field but I am not very happy with it. 
However, if you prefer to keep it I suggest to add a comment otherwise it is 
mislediang because ideally in Clang we should be using versions from the 
LangOpts everywhere. Alternatively we could consider a helper function to 
calculate the version although it doesn't eliminate the need to the comment.



Comment at: clang/include/clang/Basic/OpenCLOptions.h:38
+  unsigned CLVer = 120;
+  bool IsOpenCLCPlusPlus = false;
+

I don't see a value in such field. We can simply check 
LangOpts::OpenCLCPlusPlus. 



Comment at: clang/include/clang/Basic/OpenCLOptions.h:42
+
+  // Note that __opencl_c_subgroups and cl_khr_subgroups are not equivalent
+  // because extension requires sub-group independent forward progress

I feel I missed that. Can you explain why it is not the same. Any spec 
reference would be help.



Comment at: clang/include/clang/Basic/OpenCLOptions.h:49
+  // For pre-OpenCL C 3.0 features are supported simultaneously
+  // with corresponding extensions (if there is such extension, otherwise
+  // check specific version of feature)

I find this bit  hard to read `(if there is such extension, otherwise check 
specific version of feature)` how about:


```
Set features for OpenCL C prior to 3.0 based on either:
 - the equivalent extension
 - or language version.
```



Comment at: clang/include/clang/Basic/OpenCLOptions.h:51
+  // check specific version of feature)
+  void supportFeatureForPreOCL30(StringRef Feat, bool On = true) {
+assert(CLVer < 300 && "Can'be called for OpenCL C higher 3.0");

I find the name of this function very confusing but I can't think of any better 
one. Also the flow is becoming harder to understand to be honest. This function 
is not as straight forward as `support` because it might not actually do what 
is expected from it. I wonder if the name with something like `adjust` would be 
more appropriate. At the same time `adjustFeatures` is the only place where we 
need to check for the version. Perha

[PATCH] D89980: [hip] Remove the coercion on aggregate kernel arguments.

2020-11-12 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu:55
 
 struct S {
   int *x;

Should also have a case with a single element struct, which will be treated 
like a scalar


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89980

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


[PATCH] D91372: Some updates/fixes to the creduce script.

2020-11-12 Thread Amy Huang via Phabricator via cfe-commits
akhuang created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
akhuang requested review of this revision.

This was motivated by changes to llvm's `not --crash` disabling symbolization
but I ended up removing `not` from the script entirely because it
returns differently depending on  whether clang "crashes" or exits for some
other reason. The script had to choose between calling `not` and `not --crash`
and sometimes it was wrong.

The script also now disables symbolization when we don't read the stack
trace because symbolizing is kind of slow.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91372

Files:
  clang/utils/creduce-clang-crash.py

Index: clang/utils/creduce-clang-crash.py
===
--- clang/utils/creduce-clang-crash.py
+++ clang/utils/creduce-clang-crash.py
@@ -23,7 +23,6 @@
 verbose = False
 creduce_cmd = None
 clang_cmd = None
-not_cmd = None
 
 def verbose_print(*args, **kwargs):
   if verbose:
@@ -77,7 +76,7 @@
 self.clang = clang_cmd
 self.clang_args = []
 self.expected_output = []
-self.is_crash = True
+self.needs_stack_trace = False
 self.creduce_flags = ["--tidy"]
 
 self.read_clang_args(crash_script, file_to_reduce)
@@ -128,23 +127,20 @@
 crash_output = re.sub(ansi_escape, '', crash_output.decode('utf-8'))
 
 # Look for specific error messages
-regexes = [r"Assertion `(.+)' failed", # Linux assert()
-   r"Assertion failed: (.+),", # FreeBSD/Mac assert()
-   r"fatal error: error in backend: (.+)",
-   r"LLVM ERROR: (.+)",
-   r"UNREACHABLE executed (at .+)?!",
-   r"LLVM IR generation of declaration '(.+)'",
-   r"Generating code for declaration '(.+)'",
-   r"\*\*\* Bad machine code: (.+) \*\*\*"]
+regexes = [r"Assertion .+ failed", # Linux assert()
+   r"Assertion failed: .+,", # FreeBSD/Mac assert()
+   r"fatal error: error in backend: .+",
+   r"LLVM ERROR: .+",
+   r"UNREACHABLE executed at .+?!",
+   r"LLVM IR generation of declaration '.+'",
+   r"Generating code for declaration '.+'",
+   r"\*\*\* Bad machine code: .+ \*\*\*"]
 for msg_re in regexes:
   match = re.search(msg_re, crash_output)
   if match:
-msg = match.group(1)
+msg = match.group(0)
 result = [msg]
 print("Found message:", msg)
-
-if "fatal error:" in msg_re:
-  self.is_crash = False
 break
 
 # If no message was found, use the top five stack trace functions,
@@ -152,12 +148,18 @@
 # Five is a somewhat arbitrary number; the goal is to get a small number
 # of identifying functions with some leeway for common functions
 if not result:
+  self.needs_stack_trace = True
   stacktrace_re = r'[0-9]+\s+0[xX][0-9a-fA-F]+\s*([^(]+)\('
-  filters = ["PrintStackTraceSignalHandler",
- "llvm::sys::RunSignalHandlers",
- "SignalHandler", "__restore_rt", "gsignal", "abort"]
+  filters = ["PrintStackTrace", "RunSignalHandlers", "CleanupOnSignal",
+ "HandleCrash", "SignalHandler", "__restore_rt", "gsignal", "abort"]
+  def skip_function(func_name):
+for name in filters:
+  if name in func_name:
+return True
+return False
+
   matches = re.findall(stacktrace_re, crash_output)
-  result = [x for x in matches if x and x.strip() not in filters][:5]
+  result = [x for x in matches if x and not skip_function(x)][:5]
   for msg in result:
 print("Found stack trace function:", msg)
 
@@ -184,10 +186,17 @@
   def write_interestingness_test(self):
 print("\nCreating the interestingness test...")
 
-crash_flag = "--crash" if self.is_crash else ""
+# Disable symbolization if it's not required to avoid slow symbolization.
+disable_symbolization = ''
+if not self.needs_stack_trace:
+  disable_symbolization = 'export LLVM_DISABLE_SYMBOLIZATION=1'
 
-output = "#!/bin/bash\n%s %s %s >& t.log || exit 1\n" % \
-(pipes.quote(not_cmd), crash_flag, quote_cmd(self.get_crash_cmd()))
+output = """#!/bin/bash
+%s
+if %s >& t.log ; then
+  exit 1
+fi
+""" % (disable_symbolization, quote_cmd(self.get_crash_cmd()))
 
 for msg in self.expected_output:
   output += 'grep -F %s t.log || exit 1\n' % pipes.quote(msg)
@@ -372,7 +381,6 @@
   global verbose
   global creduce_cmd
   global clang_cmd
-  global not_cmd
 
   parser = ArgumentParser(description=__doc__,
   formatter_class=RawTextHelpFormatter)
@@ -382,9 +390,6 @@
   help="Name of the file to be reduced.")
   parser.add_argument('--llvm-bin', dest='llvm_bin', type=str,
   help="Path to the LLVM bin directory.")
-  parser.add_argument('--llvm-not', dest='llvm_not', ty

[PATCH] D91034: [Frontend] Treat CUDA header files as CUDA source files

2020-11-12 Thread Fangrui Song via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe7c7a1982632: [Frontend] Treat .cuh files as CUDA source 
files (authored by tomilov, committed by MaskRay).
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D91034?vs=304905&id=304916#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91034

Files:
  clang/lib/Frontend/FrontendOptions.cpp
  clang/test/Parser/cuda-check-input-kind-assoc.cuh


Index: clang/test/Parser/cuda-check-input-kind-assoc.cuh
===
--- /dev/null
+++ clang/test/Parser/cuda-check-input-kind-assoc.cuh
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -fsyntax-only -Werror %s
+
+// Check input kind association for cuh extension.
+
+__attribute__((host, device)) void hd_fn() {}
Index: clang/lib/Frontend/FrontendOptions.cpp
===
--- clang/lib/Frontend/FrontendOptions.cpp
+++ clang/lib/Frontend/FrontendOptions.cpp
@@ -29,7 +29,7 @@
   .Case("cppm", Language::CXX)
   .Case("iim", InputKind(Language::CXX).getPreprocessed())
   .Case("cl", Language::OpenCL)
-  .Case("cu", Language::CUDA)
+  .Cases("cu", "cuh", Language::CUDA)
   .Case("hip", Language::HIP)
   .Cases("ll", "bc", Language::LLVM_IR)
   .Default(Language::Unknown);


Index: clang/test/Parser/cuda-check-input-kind-assoc.cuh
===
--- /dev/null
+++ clang/test/Parser/cuda-check-input-kind-assoc.cuh
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -fsyntax-only -Werror %s
+
+// Check input kind association for cuh extension.
+
+__attribute__((host, device)) void hd_fn() {}
Index: clang/lib/Frontend/FrontendOptions.cpp
===
--- clang/lib/Frontend/FrontendOptions.cpp
+++ clang/lib/Frontend/FrontendOptions.cpp
@@ -29,7 +29,7 @@
   .Case("cppm", Language::CXX)
   .Case("iim", InputKind(Language::CXX).getPreprocessed())
   .Case("cl", Language::OpenCL)
-  .Case("cu", Language::CUDA)
+  .Cases("cu", "cuh", Language::CUDA)
   .Case("hip", Language::HIP)
   .Cases("ll", "bc", Language::LLVM_IR)
   .Default(Language::Unknown);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] e7c7a19 - [Frontend] Treat .cuh files as CUDA source files

2020-11-12 Thread Fangrui Song via cfe-commits

Author: Anatoliy Tomilov
Date: 2020-11-12T11:42:53-08:00
New Revision: e7c7a1982632270ae655c7ec8e490ca2c44193a0

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

LOG: [Frontend] Treat .cuh files as CUDA source files

to synchronize with tools/clang-format/git-clang-format

tra: Keeping them in sync does have a minor benefit of not raising a question 
why the two maps are different.

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

Added: 
clang/test/Parser/cuda-check-input-kind-assoc.cuh

Modified: 
clang/lib/Frontend/FrontendOptions.cpp

Removed: 




diff  --git a/clang/lib/Frontend/FrontendOptions.cpp 
b/clang/lib/Frontend/FrontendOptions.cpp
index 9f080db733f1..4ea13cf0784f 100644
--- a/clang/lib/Frontend/FrontendOptions.cpp
+++ b/clang/lib/Frontend/FrontendOptions.cpp
@@ -29,7 +29,7 @@ InputKind FrontendOptions::getInputKindForExtension(StringRef 
Extension) {
   .Case("cppm", Language::CXX)
   .Case("iim", InputKind(Language::CXX).getPreprocessed())
   .Case("cl", Language::OpenCL)
-  .Case("cu", Language::CUDA)
+  .Cases("cu", "cuh", Language::CUDA)
   .Case("hip", Language::HIP)
   .Cases("ll", "bc", Language::LLVM_IR)
   .Default(Language::Unknown);

diff  --git a/clang/test/Parser/cuda-check-input-kind-assoc.cuh 
b/clang/test/Parser/cuda-check-input-kind-assoc.cuh
new file mode 100644
index ..3c65453833fa
--- /dev/null
+++ b/clang/test/Parser/cuda-check-input-kind-assoc.cuh
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -fsyntax-only -Werror %s
+
+// Check input kind association for cuh extension.
+
+__attribute__((host, device)) void hd_fn() {}



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


[PATCH] D91370: [OPENMP]Fix PR48076: Check map types array before accessing its front.

2020-11-12 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

This stops it from crashing Clang, but I'm not sure if it's fixing the 
underlying problem. When I compile and run this program it crashes in 
libomptarget. If you get rid of the `float f[50]` in the struct it works as 
expected.

`$ clang++ -fopenmp -fopenmp-targets=nvptx64 test.cpp && ./a.out`

  #include 
  
  struct S2 {
  float f[50];
  double *p; 
  };
  
  int main() {
S2 s;
  #pragma omp target map(s.p)
{ s.p = nullptr; }
  }

Output from running with debugging

  Libomptarget --> Device 0 is ready to use.
  Target CUDA RTL --> Load data from image 0x00400a30
  Target CUDA RTL --> CUDA module successfully loaded!
  Target CUDA RTL --> Entry point 0x maps to 
__omp_offloading_fd02_267be70_main_l10 (0x0174b170)
  Target CUDA RTL --> Sending global device environment data 4 bytes
  Libomptarget --> Entry  0: Base=0x7fffcca22ad8, Begin=0x7fffcca22ba0, 
Size=8, Type=0x20
  Libomptarget --> Entry  1: Base=0x7fffcca22ad8, Begin=0x7fffcca22ad8, 
Size=208, Type=0x10203
  Libomptarget --> Looking up mapping(HstPtrBegin=0x7fffcca22ba0, Size=8)...
  Libomptarget --> MemoryManagerTy::allocate: size 8 with host pointer 
0x7fffcca22ba0.
  Libomptarget --> findBucket: Size 8 is floored to 8.
  Libomptarget --> Cannot find a node in the FreeLists. Allocate on device.
  Libomptarget --> Node address 0x01732d88, target pointer 
0x7f050640, size 8
  Libomptarget --> Creating new map entry: HstBase=0x7fffcca22ad8, 
HstBegin=0x7fffcca22ba0, HstEnd=0x7fffcca22ba8, 
TgtBegin=0x7f050640
  Libomptarget --> There are 8 bytes allocated at target address 
0x7f050640 - is new
  Libomptarget --> Looking up mapping(HstPtrBegin=0x7fffcca22ad8, 
Size=208)...
  Libomptarget --> WARNING: Pointer is not mapped but section extends into 
already mapped data
  Libomptarget --> Mapping exists (implicit) with 
HstPtrBegin=0x7fffcca22ad8, TgtPtrBegin=0x7f05063fff38, Size=208, 
RefCount=1
  Libomptarget --> There are 208 bytes allocated at target address 
0x7f05063fff38 - is not new
  Libomptarget --> DeviceTy::getMapEntry: requested entry found
  Libomptarget --> Moving 208 bytes (hst:0x7fffcca22ad8) -> 
(tgt:0x7f05063fff38)
  Target CUDA RTL --> Error when copying data from host to device. Pointers: 
host = 0x7fffcca22ad8, device = 0x7f05063fff38, size = 208
  Target CUDA RTL --> CUDA error is: invalid argument
  Libomptarget --> Copying data to device failed.
  Libomptarget --> Call to targetDataBegin failed, abort target.
  Libomptarget --> Failed to process data before launching the kernel.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91370

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


[PATCH] D91370: [OPENMP]Fix PR48076: Check map types array before accessing its front.

2020-11-12 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D91370#2392107 , @jhuber6 wrote:

> This stops it from crashing Clang, but I'm not sure if it's fixing the 
> underlying problem. When I compile and run this program it crashes in 
> libomptarget. If you get rid of the `float f[50]` in the struct it works as 
> expected.
>
> `$ clang++ -fopenmp -fopenmp-targets=nvptx64 test.cpp && ./a.out`
>
>   #include 
>   
>   struct S2 {
>   float f[50];
>   double *p; 
>   };
>   
>   int main() {
> S2 s;
>   #pragma omp target map(s.p)
> { s.p = nullptr; }
>   }
>
> Output from running with debugging
>
>   Libomptarget --> Device 0 is ready to use.
>   Target CUDA RTL --> Load data from image 0x00400a30
>   Target CUDA RTL --> CUDA module successfully loaded!
>   Target CUDA RTL --> Entry point 0x maps to 
> __omp_offloading_fd02_267be70_main_l10 (0x0174b170)
>   Target CUDA RTL --> Sending global device environment data 4 bytes
>   Libomptarget --> Entry  0: Base=0x7fffcca22ad8, 
> Begin=0x7fffcca22ba0, Size=8, Type=0x20
>   Libomptarget --> Entry  1: Base=0x7fffcca22ad8, 
> Begin=0x7fffcca22ad8, Size=208, Type=0x10203
>   Libomptarget --> Looking up mapping(HstPtrBegin=0x7fffcca22ba0, 
> Size=8)...
>   Libomptarget --> MemoryManagerTy::allocate: size 8 with host pointer 
> 0x7fffcca22ba0.
>   Libomptarget --> findBucket: Size 8 is floored to 8.
>   Libomptarget --> Cannot find a node in the FreeLists. Allocate on device.
>   Libomptarget --> Node address 0x01732d88, target pointer 
> 0x7f050640, size 8
>   Libomptarget --> Creating new map entry: HstBase=0x7fffcca22ad8, 
> HstBegin=0x7fffcca22ba0, HstEnd=0x7fffcca22ba8, 
> TgtBegin=0x7f050640
>   Libomptarget --> There are 8 bytes allocated at target address 
> 0x7f050640 - is new
>   Libomptarget --> Looking up mapping(HstPtrBegin=0x7fffcca22ad8, 
> Size=208)...
>   Libomptarget --> WARNING: Pointer is not mapped but section extends into 
> already mapped data
>   Libomptarget --> Mapping exists (implicit) with 
> HstPtrBegin=0x7fffcca22ad8, TgtPtrBegin=0x7f05063fff38, Size=208, 
> RefCount=1
>   Libomptarget --> There are 208 bytes allocated at target address 
> 0x7f05063fff38 - is not new
>   Libomptarget --> DeviceTy::getMapEntry: requested entry found
>   Libomptarget --> Moving 208 bytes (hst:0x7fffcca22ad8) -> 
> (tgt:0x7f05063fff38)
>   Target CUDA RTL --> Error when copying data from host to device. Pointers: 
> host = 0x7fffcca22ad8, device = 0x7f05063fff38, size = 208
>   Target CUDA RTL --> CUDA error is: invalid argument
>   Libomptarget --> Copying data to device failed.
>   Libomptarget --> Call to targetDataBegin failed, abort target.
>   Libomptarget --> Failed to process data before launching the kernel.

It is different problem, which should be addressed in the different patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91370

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


[PATCH] D91373: [OpenMP5.0] Support more kinds of lvalues in map clauses

2020-11-12 Thread Jacob Weightman via Phabricator via cfe-commits
jacobdweightman created this revision.
jacobdweightman added a reviewer: ABataev.
jacobdweightman added a project: OpenMP.
Herald added subscribers: cfe-commits, guansong, yaxunl.
Herald added a project: clang.
jacobdweightman requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added a subscriber: sstefan1.

This patch aims to fully support this change from OpenMP 4.5 to 5.0:

> The to and from clauses on the target update construct (see Section 2.12.6 on 
> page 176), the depend clause on task generating constructs (see Section 
> 2.17.11 on page 255), and the map clause (see Section 2.19.7.1 on page 315) 
> were extended to allow any lvalue expression as a list item for C/C++.

Specifically, support is added for:

- calling functions which return references/constexprs
- cast expressions as part of a larger lvalue expression
- expressions with the ternary Elvis operators (A ? B : C and A ?: C)

This patch modifies Sema to accept such expressions. A few small changes in 
CodeGen were required to avoid asserts, but CodeGen appeared to already handle 
such expressions correctly.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91373

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/target_map_messages.cpp
  clang/test/OpenMP/target_parallel_for_map_messages.cpp
  clang/test/OpenMP/target_parallel_for_simd_map_messages.cpp
  clang/test/OpenMP/target_parallel_map_messages.cpp
  clang/test/OpenMP/target_simd_map_messages.cpp
  clang/test/OpenMP/target_teams_distribute_map_messages.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_map_messages.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_simd_map_messages.cpp
  clang/test/OpenMP/target_teams_distribute_simd_map_messages.cpp
  clang/test/OpenMP/target_teams_map_messages.cpp
  clang/test/OpenMP/target_update_from_messages.cpp
  clang/test/OpenMP/target_update_to_messages.cpp

Index: clang/test/OpenMP/target_update_to_messages.cpp
===
--- clang/test/OpenMP/target_update_to_messages.cpp
+++ clang/test/OpenMP/target_update_to_messages.cpp
@@ -1,12 +1,12 @@
-// RUN: %clang_cc1 -verify=expected,le50 -fopenmp -ferror-limit 100 %s -Wno-openmp-mapping -Wuninitialized
-// RUN: %clang_cc1 -verify=expected,le45 -fopenmp -fopenmp-version=40 -ferror-limit 100 %s -Wno-openmp-mapping -Wuninitialized
-// RUN: %clang_cc1 -verify=expected,le45 -fopenmp -fopenmp-version=45 -ferror-limit 100 %s -Wno-openmp-mapping -Wuninitialized
-// RUN: %clang_cc1 -verify=expected,le50 -fopenmp -fopenmp-version=50 -ferror-limit 100 %s -Wno-openmp-mapping -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le50 -fopenmp -ferror-limit 200 %s -Wno-openmp-mapping -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le45 -fopenmp -fopenmp-version=40 -ferror-limit 200 %s -Wno-openmp-mapping -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le45 -fopenmp -fopenmp-version=45 -ferror-limit 200 %s -Wno-openmp-mapping -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le50 -fopenmp -fopenmp-version=50 -ferror-limit 200 %s -Wno-openmp-mapping -Wuninitialized
 
-// RUN: %clang_cc1 -verify=expected,le50 -fopenmp-simd -ferror-limit 100 %s -Wno-openmp-mapping -Wuninitialized
-// RUN: %clang_cc1 -verify=expected,le45 -fopenmp-simd -fopenmp-version=40 -ferror-limit 100 %s -Wno-openmp-mapping -Wuninitialized
-// RUN: %clang_cc1 -verify=expected,le45 -fopenmp-simd -fopenmp-version=45 -ferror-limit 100 %s -Wno-openmp-mapping -Wuninitialized
-// RUN: %clang_cc1 -verify=expected,le50 -fopenmp-simd -fopenmp-version=50 -ferror-limit 100 %s -Wno-openmp-mapping -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le50 -fopenmp-simd -ferror-limit 200 %s -Wno-openmp-mapping -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le45 -fopenmp-simd -fopenmp-version=40 -ferror-limit 200 %s -Wno-openmp-mapping -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le45 -fopenmp-simd -fopenmp-version=45 -ferror-limit 200 %s -Wno-openmp-mapping -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,le50 -fopenmp-simd -fopenmp-version=50 -ferror-limit 200 %s -Wno-openmp-mapping -Wuninitialized
 
 void foo() {
 }
@@ -15,6 +15,14 @@
   return argc;
 }
 
+int &id(int &x) {
+return x;
+}
+
+int *id2(int *x) {
+return x;
+}
+
 struct S1; // expected-note 2 {{declared here}}
 extern S1 a;
 class S2 {
@@ -83,6 +91,12 @@
 double marr[10][5][10];
 #pragma omp target update to(marr [0:1][2:4][1:2]) // le45-error {{array section does not specify contiguous storage}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
 {}
+
+#pragma omp target update to(id) // le45-error {{expected expression containing only member accesses and/or array sections based on named variables}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} le50-error {{expe

[PATCH] D87188: [InstCombine] Canonicalize SPF to abs intrinc

2020-11-12 Thread Nikita Popov via Phabricator via cfe-commits
nikic added a comment.

In D87188#2385619 , @spatel wrote:

> D90554  / f7eac51b9b 
> 
> I think that change makes this patch ready to try again. If we do see 
> regressions, then it should now be easy to adjust target-specific cost 
> modeling of abs() intrinsics to fix those.

We still need to track down the miscompile that @mstorsjo reported before 
reapplying this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87188

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


[PATCH] D91370: [OPENMP]Fix PR48076: Check map types array before accessing its front.

2020-11-12 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 accepted this revision.
jhuber6 added a comment.
This revision is now accepted and ready to land.

LGTM then.

Any clue what the cause of the other problem is?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91370

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


[PATCH] D91370: [OPENMP]Fix PR48076: Check map types array before accessing its front.

2020-11-12 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D91370#2392171 , @jhuber6 wrote:

> LGTM then.
>
> Any clue what the cause of the other problem is?

Will investigate it and prepare a new patch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91370

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


[PATCH] D91376: [OPENMP]Fix PR47790: segfault in frontend while parsing Objective-C with OpenMP.

2020-11-12 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev created this revision.
ABataev added a reviewer: jdoerfert.
Herald added subscribers: guansong, yaxunl.
Herald added a project: clang.
ABataev requested review of this revision.
Herald added a subscriber: sstefan1.

Need to check if the sema is actually finishing a function decl.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91376

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/SemaObjCXX/objcxx_openmp.mm


Index: clang/test/SemaObjCXX/objcxx_openmp.mm
===
--- /dev/null
+++ clang/test/SemaObjCXX/objcxx_openmp.mm
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -fopenmp -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+class Foo {
+  int a;
+};
+
+@interface NSObject
+@end
+
+@interface Bar : NSObject {
+  Foo *foo;
+}
+- (void)setSystemAndWindowCocoa:(class Foo *)foo_1;
+
+@end
+
+@implementation Bar : NSObject
+- (void)setSystemAndWindowCocoa:(Foo *)foo_1 {
+  foo = foo_1;
+}
+@end
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -14598,7 +14598,7 @@
 DiscardCleanupsInEvaluationContext();
   }
 
-  if (LangOpts.OpenMP || LangOpts.CUDA || LangOpts.SYCLIsDevice) {
+  if (FD && (LangOpts.OpenMP || LangOpts.CUDA || LangOpts.SYCLIsDevice)) {
 auto ES = getEmissionStatus(FD);
 if (ES == Sema::FunctionEmissionStatus::Emitted ||
 ES == Sema::FunctionEmissionStatus::Unknown)


Index: clang/test/SemaObjCXX/objcxx_openmp.mm
===
--- /dev/null
+++ clang/test/SemaObjCXX/objcxx_openmp.mm
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -fopenmp -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+class Foo {
+  int a;
+};
+
+@interface NSObject
+@end
+
+@interface Bar : NSObject {
+  Foo *foo;
+}
+- (void)setSystemAndWindowCocoa:(class Foo *)foo_1;
+
+@end
+
+@implementation Bar : NSObject
+- (void)setSystemAndWindowCocoa:(Foo *)foo_1 {
+  foo = foo_1;
+}
+@end
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -14598,7 +14598,7 @@
 DiscardCleanupsInEvaluationContext();
   }
 
-  if (LangOpts.OpenMP || LangOpts.CUDA || LangOpts.SYCLIsDevice) {
+  if (FD && (LangOpts.OpenMP || LangOpts.CUDA || LangOpts.SYCLIsDevice)) {
 auto ES = getEmissionStatus(FD);
 if (ES == Sema::FunctionEmissionStatus::Emitted ||
 ES == Sema::FunctionEmissionStatus::Unknown)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 3c6b457 - [OPENMP]Fix PR48076: Check map types array before accessing its front.

2020-11-12 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2020-11-12T12:00:29-08:00
New Revision: 3c6b457bee0c66294637d50bca1cff7231647249

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

LOG: [OPENMP]Fix PR48076: Check map types array before accessing its front.

Need to check if there are map types for the components before trying to
access them when trying to modify type mappings for combined partial
mappings.

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

Added: 
clang/test/OpenMP/target_data_member_codegen.cpp

Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 3713c672b053..ce8846140d41 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -8214,8 +8214,9 @@ class MappableExprsHandler {
   return Type & OMP_MAP_PRESENT;
 }))
   CombinedInfo.Types.back() |= OMP_MAP_PRESENT;
-// Remove TARGET_PARAM flag from the first element
-CurTypes.front() &= ~OMP_MAP_TARGET_PARAM;
+// Remove TARGET_PARAM flag from the first element if any.
+if (!CurTypes.empty())
+  CurTypes.front() &= ~OMP_MAP_TARGET_PARAM;
 
 // All other current entries will be MEMBER_OF the combined entry
 // (except for PTR_AND_OBJ entries which do not have a placeholder value

diff  --git a/clang/test/OpenMP/target_data_member_codegen.cpp 
b/clang/test/OpenMP/target_data_member_codegen.cpp
new file mode 100644
index ..af21fb286365
--- /dev/null
+++ b/clang/test/OpenMP/target_data_member_codegen.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple 
i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | 
FileCheck %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple 
i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -triple 
i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch 
%t -verify %s -emit-llvm -o - | FileCheck %s
+
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify 
%s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown 
-fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown 
-fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple i386-unknown-unknown 
-fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s 
-emit-llvm -o - | FileCheck %s
+
+// RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify 
%s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple i386-unknown-unknown 
-fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck 
--check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple 
i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -triple i386-unknown-unknown 
-fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s 
-emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
+
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HE

[PATCH] D91370: [OPENMP]Fix PR48076: Check map types array before accessing its front.

2020-11-12 Thread Alexey Bataev via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3c6b457bee0c: [OPENMP]Fix PR48076: Check map types array 
before accessing its front. (authored by ABataev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91370

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/target_data_member_codegen.cpp


Index: clang/test/OpenMP/target_data_member_codegen.cpp
===
--- /dev/null
+++ clang/test/OpenMP/target_data_member_codegen.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple 
i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | 
FileCheck %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple 
i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -triple 
i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch 
%t -verify %s -emit-llvm -o - | FileCheck %s
+
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify 
%s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown 
-fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown 
-fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple i386-unknown-unknown 
-fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s 
-emit-llvm -o - | FileCheck %s
+
+// RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify 
%s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple i386-unknown-unknown 
-fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck 
--check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple 
i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -triple i386-unknown-unknown 
-fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s 
-emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
+
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+// CHECK: [[MAPTYPES:@.+]] = private unnamed_addr constant [1 x i64] 
zeroinitializer
+struct S {
+double *p;
+};
+
+// CHECK-LABEL: @main
+int main() {
+  // CHECK: call i32 @__tgt_target_mapper(i64 -1, i8* @.{{.+}}, i32 1, i8** 
%{{.+}}, i8** %{{.+}}, i64* %{{.+}}, i64* getelementptr inbounds ([1 x i64], [1 
x i64]* [[MAPTYPES]], i32 0, i32 0), i8** null)
+S s;
+#pragma omp target map(s.p)
+{ }
+}
+#endif //HEADER
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -8214,8 +8214,9 @@
   return Type & OMP_MAP_PRESENT;
 }))
   CombinedInfo.Types.back() |= OMP_MAP_PRESENT;
-// Remove TARGET_PARAM flag from the first element
-CurTypes.front() &= ~OMP_MAP_TARGET_PARAM;
+// Remove TARGET_PARAM flag from the first element if any.
+if (!CurTypes.empty())
+  CurTypes.front() &= ~OMP_MAP_TARGET_PARAM;
 
 // All other current entries will be MEMBER_OF the combined entry
 // (except for PTR_AND_OBJ entries wh

[PATCH] D91370: [OPENMP]Fix PR48076: Check map types array before accessing its front.

2020-11-12 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D91370#2392171 , @jhuber6 wrote:

> LGTM then.
>
> Any clue what the cause of the other problem is?

Could you try your test with the patch from https://reviews.llvm.org/D86119?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91370

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


[PATCH] D91376: [OPENMP]Fix PR47790: segfault in frontend while parsing Objective-C with OpenMP.

2020-11-12 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/D91376/new/

https://reviews.llvm.org/D91376

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


[PATCH] D91380: [clang] Fix an assertion crash in delayed access check.

2020-11-12 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: adamcz.
Herald added a project: clang.
hokein requested review of this revision.

TD-getTemplatedDecl() might not be a DeclContext variant, which can
trigger an assertion inside `isa<>`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91380

Files:
  clang/lib/Sema/SemaAccess.cpp
  clang/test/SemaCXX/cxx14-access.cpp


Index: clang/test/SemaCXX/cxx14-access.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/cxx14-access.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++14 -verify %s
+
+namespace NoCrashOnDelayedAccessCheck {
+class Foo {
+  class Private; // expected-note {{declared private here}}
+};
+
+struct Bar {};
+
+template 
+Foo::Private Bar::ABC; // expected-error {{no member named 'ABC' in 
'NoCrashOnDelayedAccessCheck::Bar'}} \
+  expected-error {{'Private' is a private member of}}
+}
Index: clang/lib/Sema/SemaAccess.cpp
===
--- clang/lib/Sema/SemaAccess.cpp
+++ clang/lib/Sema/SemaAccess.cpp
@@ -1476,7 +1476,8 @@
   } else if (FunctionDecl *FN = dyn_cast(D)) {
 DC = FN;
   } else if (TemplateDecl *TD = dyn_cast(D)) {
-DC = cast(TD->getTemplatedDecl());
+if (isa(TD->getTemplatedDecl()))
+  DC = cast(TD->getTemplatedDecl());
   }
 
   EffectiveContext EC(DC);


Index: clang/test/SemaCXX/cxx14-access.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/cxx14-access.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++14 -verify %s
+
+namespace NoCrashOnDelayedAccessCheck {
+class Foo {
+  class Private; // expected-note {{declared private here}}
+};
+
+struct Bar {};
+
+template 
+Foo::Private Bar::ABC; // expected-error {{no member named 'ABC' in 'NoCrashOnDelayedAccessCheck::Bar'}} \
+  expected-error {{'Private' is a private member of}}
+}
Index: clang/lib/Sema/SemaAccess.cpp
===
--- clang/lib/Sema/SemaAccess.cpp
+++ clang/lib/Sema/SemaAccess.cpp
@@ -1476,7 +1476,8 @@
   } else if (FunctionDecl *FN = dyn_cast(D)) {
 DC = FN;
   } else if (TemplateDecl *TD = dyn_cast(D)) {
-DC = cast(TD->getTemplatedDecl());
+if (isa(TD->getTemplatedDecl()))
+  DC = cast(TD->getTemplatedDecl());
   }
 
   EffectiveContext EC(DC);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D90870: [NFC][NewPM] Reuse PassBuilder callbacks with -O0

2020-11-12 Thread Arthur Eubanks via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3a7b57b7cad3: [NFC][NewPM] Reuse PassBuilder callbacks with 
-O0 (authored by aeubanks).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90870

Files:
  clang/lib/CodeGen/BackendUtil.cpp

Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -1062,67 +1062,6 @@
   MPM.addPass(createModuleToFunctionPassAdaptor(CoroCleanupPass()));
 }
 
-static void addSanitizersAtO0(ModulePassManager &MPM,
-  const Triple &TargetTriple,
-  const LangOptions &LangOpts,
-  const CodeGenOptions &CodeGenOpts) {
-  if (CodeGenOpts.SanitizeCoverageType ||
-  CodeGenOpts.SanitizeCoverageIndirectCalls ||
-  CodeGenOpts.SanitizeCoverageTraceCmp) {
-auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts);
-MPM.addPass(ModuleSanitizerCoveragePass(
-SancovOpts, CodeGenOpts.SanitizeCoverageAllowlistFiles,
-CodeGenOpts.SanitizeCoverageBlocklistFiles));
-  }
-
-  auto ASanPass = [&](SanitizerMask Mask, bool CompileKernel) {
-MPM.addPass(RequireAnalysisPass());
-bool Recover = CodeGenOpts.SanitizeRecover.has(Mask);
-MPM.addPass(createModuleToFunctionPassAdaptor(AddressSanitizerPass(
-CompileKernel, Recover, CodeGenOpts.SanitizeAddressUseAfterScope)));
-bool ModuleUseAfterScope = asanUseGlobalsGC(TargetTriple, CodeGenOpts);
-MPM.addPass(
-ModuleAddressSanitizerPass(CompileKernel, Recover, ModuleUseAfterScope,
-   CodeGenOpts.SanitizeAddressUseOdrIndicator));
-  };
-
-  if (LangOpts.Sanitize.has(SanitizerKind::Address)) {
-ASanPass(SanitizerKind::Address, /*CompileKernel=*/false);
-  }
-
-  if (LangOpts.Sanitize.has(SanitizerKind::KernelAddress)) {
-ASanPass(SanitizerKind::KernelAddress, /*CompileKernel=*/true);
-  }
-
-  if (LangOpts.Sanitize.has(SanitizerKind::HWAddress)) {
-bool Recover = CodeGenOpts.SanitizeRecover.has(SanitizerKind::HWAddress);
-MPM.addPass(HWAddressSanitizerPass(
-/*CompileKernel=*/false, Recover));
-  }
-  if (LangOpts.Sanitize.has(SanitizerKind::KernelHWAddress)) {
-MPM.addPass(HWAddressSanitizerPass(
-/*CompileKernel=*/true, /*Recover=*/true));
-  }
-
-  if (LangOpts.Sanitize.has(SanitizerKind::Memory)) {
-bool Recover = CodeGenOpts.SanitizeRecover.has(SanitizerKind::Memory);
-int TrackOrigins = CodeGenOpts.SanitizeMemoryTrackOrigins;
-MPM.addPass(MemorySanitizerPass({TrackOrigins, Recover, false}));
-MPM.addPass(createModuleToFunctionPassAdaptor(
-MemorySanitizerPass({TrackOrigins, Recover, false})));
-  }
-
-  if (LangOpts.Sanitize.has(SanitizerKind::KernelMemory)) {
-MPM.addPass(createModuleToFunctionPassAdaptor(
-MemorySanitizerPass({0, false, /*Kernel=*/true})));
-  }
-
-  if (LangOpts.Sanitize.has(SanitizerKind::Thread)) {
-MPM.addPass(ThreadSanitizerPass());
-MPM.addPass(createModuleToFunctionPassAdaptor(ThreadSanitizerPass()));
-  }
-}
-
 /// A clean version of `EmitAssembly` that uses the new pass manager.
 ///
 /// Not all features are currently supported in this system, but where
@@ -1259,188 +1198,140 @@
 bool IsThinLTO = CodeGenOpts.PrepareForThinLTO;
 bool IsLTO = CodeGenOpts.PrepareForLTO;
 
-if (CodeGenOpts.OptimizationLevel == 0) {
-  // If we reached here with a non-empty index file name, then the index
-  // file was empty and we are not performing ThinLTO backend compilation
-  // (used in testing in a distributed build environment). Drop any the type
-  // test assume sequences inserted for whole program vtables so that
-  // codegen doesn't complain.
-  if (!CodeGenOpts.ThinLTOIndexFile.empty())
-MPM.addPass(LowerTypeTestsPass(/*ExportSummary=*/nullptr,
-   /*ImportSummary=*/nullptr,
-   /*DropTypeTests=*/true));
-  if (Optional Options = getGCOVOptions(CodeGenOpts, LangOpts))
-MPM.addPass(GCOVProfilerPass(*Options));
-  if (Optional Options =
-  getInstrProfOptions(CodeGenOpts, LangOpts))
-MPM.addPass(InstrProfiling(*Options, false));
-
-  // Build a minimal pipeline based on the semantics required by Clang,
-  // which is just that always inlining occurs. Further, disable generating
-  // lifetime intrinsics to avoid enabling further optimizations during
-  // code generation.
-  // However, we need to insert lifetime intrinsics to avoid invalid access
-  // caused by multithreaded coroutines.
-  MPM.addPass(
-  AlwaysInlinerPass(/*InsertLifetimeIntrinsics=*/LangOpts.Coroutines));
-
-  

[clang] 3a7b57b - [NFC][NewPM] Reuse PassBuilder callbacks with -O0

2020-11-12 Thread Arthur Eubanks via cfe-commits

Author: Arthur Eubanks
Date: 2020-11-12T12:42:59-08:00
New Revision: 3a7b57b7cad32a4b59700e029d80a06c35f0a1a3

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

LOG: [NFC][NewPM] Reuse PassBuilder callbacks with -O0

This removes lots of duplicated code which was necessary before
https://reviews.llvm.org/D89158.
Now we can use PassBuilder::runRegisteredEPCallbacks().
This is mostly sanitizers.

There is likely more that can be done to simplify, but let's start with this.

Reviewed By: ychen

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

Added: 


Modified: 
clang/lib/CodeGen/BackendUtil.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 87abce4bbeec..37922882ae46 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -1062,67 +1062,6 @@ static void addCoroutinePassesAtO0(ModulePassManager 
&MPM,
   MPM.addPass(createModuleToFunctionPassAdaptor(CoroCleanupPass()));
 }
 
-static void addSanitizersAtO0(ModulePassManager &MPM,
-  const Triple &TargetTriple,
-  const LangOptions &LangOpts,
-  const CodeGenOptions &CodeGenOpts) {
-  if (CodeGenOpts.SanitizeCoverageType ||
-  CodeGenOpts.SanitizeCoverageIndirectCalls ||
-  CodeGenOpts.SanitizeCoverageTraceCmp) {
-auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts);
-MPM.addPass(ModuleSanitizerCoveragePass(
-SancovOpts, CodeGenOpts.SanitizeCoverageAllowlistFiles,
-CodeGenOpts.SanitizeCoverageBlocklistFiles));
-  }
-
-  auto ASanPass = [&](SanitizerMask Mask, bool CompileKernel) {
-MPM.addPass(RequireAnalysisPass());
-bool Recover = CodeGenOpts.SanitizeRecover.has(Mask);
-MPM.addPass(createModuleToFunctionPassAdaptor(AddressSanitizerPass(
-CompileKernel, Recover, CodeGenOpts.SanitizeAddressUseAfterScope)));
-bool ModuleUseAfterScope = asanUseGlobalsGC(TargetTriple, CodeGenOpts);
-MPM.addPass(
-ModuleAddressSanitizerPass(CompileKernel, Recover, ModuleUseAfterScope,
-   
CodeGenOpts.SanitizeAddressUseOdrIndicator));
-  };
-
-  if (LangOpts.Sanitize.has(SanitizerKind::Address)) {
-ASanPass(SanitizerKind::Address, /*CompileKernel=*/false);
-  }
-
-  if (LangOpts.Sanitize.has(SanitizerKind::KernelAddress)) {
-ASanPass(SanitizerKind::KernelAddress, /*CompileKernel=*/true);
-  }
-
-  if (LangOpts.Sanitize.has(SanitizerKind::HWAddress)) {
-bool Recover = CodeGenOpts.SanitizeRecover.has(SanitizerKind::HWAddress);
-MPM.addPass(HWAddressSanitizerPass(
-/*CompileKernel=*/false, Recover));
-  }
-  if (LangOpts.Sanitize.has(SanitizerKind::KernelHWAddress)) {
-MPM.addPass(HWAddressSanitizerPass(
-/*CompileKernel=*/true, /*Recover=*/true));
-  }
-
-  if (LangOpts.Sanitize.has(SanitizerKind::Memory)) {
-bool Recover = CodeGenOpts.SanitizeRecover.has(SanitizerKind::Memory);
-int TrackOrigins = CodeGenOpts.SanitizeMemoryTrackOrigins;
-MPM.addPass(MemorySanitizerPass({TrackOrigins, Recover, false}));
-MPM.addPass(createModuleToFunctionPassAdaptor(
-MemorySanitizerPass({TrackOrigins, Recover, false})));
-  }
-
-  if (LangOpts.Sanitize.has(SanitizerKind::KernelMemory)) {
-MPM.addPass(createModuleToFunctionPassAdaptor(
-MemorySanitizerPass({0, false, /*Kernel=*/true})));
-  }
-
-  if (LangOpts.Sanitize.has(SanitizerKind::Thread)) {
-MPM.addPass(ThreadSanitizerPass());
-MPM.addPass(createModuleToFunctionPassAdaptor(ThreadSanitizerPass()));
-  }
-}
-
 /// A clean version of `EmitAssembly` that uses the new pass manager.
 ///
 /// Not all features are currently supported in this system, but where
@@ -1259,188 +1198,140 @@ void 
EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
 bool IsThinLTO = CodeGenOpts.PrepareForThinLTO;
 bool IsLTO = CodeGenOpts.PrepareForLTO;
 
-if (CodeGenOpts.OptimizationLevel == 0) {
-  // If we reached here with a non-empty index file name, then the index
-  // file was empty and we are not performing ThinLTO backend compilation
-  // (used in testing in a distributed build environment). Drop any the 
type
-  // test assume sequences inserted for whole program vtables so that
-  // codegen doesn't complain.
-  if (!CodeGenOpts.ThinLTOIndexFile.empty())
-MPM.addPass(LowerTypeTestsPass(/*ExportSummary=*/nullptr,
-   /*ImportSummary=*/nullptr,
-   /*DropTypeTests=*/true));
-  if (Optional Options = getGCOVOptions(CodeGenOpts, 
LangOpts))
-MPM.addPass(GCOVProfilerPass(*Options));
-  if (Optional Options =
-  getInstrProfOptions(CodeG

[PATCH] D91029: [clangd] Implement clang-tidy options from config

2020-11-12 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 304940.
njames93 added a comment.

- Small tweaks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91029

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/Compiler.h
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/TidyProvider.cpp
  clang-tools-extra/clangd/TidyProvider.h
  clang-tools-extra/clangd/tool/Check.cpp
  clang-tools-extra/clangd/tool/ClangdMain.cpp
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/ClangdTests.cpp
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
  clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
  clang-tools-extra/clangd/unittests/TestTU.cpp
  clang-tools-extra/clangd/unittests/TestTU.h
  clang-tools-extra/clangd/unittests/TestTidyProvider.cpp
  clang-tools-extra/clangd/unittests/TestTidyProvider.h

Index: clang-tools-extra/clangd/unittests/TestTidyProvider.h
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/TestTidyProvider.h
@@ -0,0 +1,33 @@
+//===-- TestTidyProvider.h --*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "../TidyProvider.h"
+#include "llvm/Support/VirtualFileSystem.h"
+
+namespace clang {
+namespace clangd {
+
+class TestClangTidyProvider : public TidyProvider {
+public:
+  /// Convienence method for creating a provider that just uses \p Checks and \p
+  /// WarningsAsErrors
+  TestClangTidyProvider(llvm::StringRef Checks,
+llvm::StringRef WarningsAsErrors = {});
+  TestClangTidyProvider(const tidy::ClangTidyOptions &Options)
+  : Opts(Options) {}
+
+  tidy::ClangTidyOptions getOptions(llvm::StringRef FileName) override {
+return Opts;
+  }
+
+private:
+  tidy::ClangTidyOptions Opts;
+};
+
+} // namespace clangd
+} // namespace clang
Index: clang-tools-extra/clangd/unittests/TestTidyProvider.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/TestTidyProvider.cpp
@@ -0,0 +1,26 @@
+//===-- TestTidyProvider.cpp *- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "TestTidyProvider.h"
+
+namespace clang {
+
+using namespace tidy;
+
+namespace clangd {
+
+TestClangTidyProvider::TestClangTidyProvider(llvm::StringRef Checks,
+ llvm::StringRef WarningsAsErrors) {
+  if (!Checks.empty())
+Opts.Checks.emplace(Checks);
+  if (!WarningsAsErrors.empty())
+Opts.WarningsAsErrors.emplace(WarningsAsErrors);
+}
+
+} // namespace clangd
+} // namespace clang
Index: clang-tools-extra/clangd/unittests/TestTU.h
===
--- clang-tools-extra/clangd/unittests/TestTU.h
+++ clang-tools-extra/clangd/unittests/TestTU.h
@@ -17,6 +17,7 @@
 #ifndef LLVM_CLANG_TOOLS_EXTRA_UNITTESTS_CLANGD_TESTTU_H
 #define LLVM_CLANG_TOOLS_EXTRA_UNITTESTS_CLANGD_TESTTU_H
 
+#include "../TidyProvider.h"
 #include "Compiler.h"
 #include "ParsedAST.h"
 #include "TestFS.h"
@@ -58,8 +59,7 @@
   // Extra arguments for the compiler invocation.
   std::vector ExtraArgs;
 
-  llvm::Optional ClangTidyChecks;
-  llvm::Optional ClangTidyWarningsAsErrors;
+  std::unique_ptr ClangTidyProvider;
   // Index to use when building AST.
   const SymbolIndex *ExternalIndex = nullptr;
 
Index: clang-tools-extra/clangd/unittests/TestTU.cpp
===
--- clang-tools-extra/clangd/unittests/TestTU.cpp
+++ clang-tools-extra/clangd/unittests/TestTU.cpp
@@ -59,8 +59,7 @@
 FS.OverlayRealFileSystemForModules = true;
   Inputs.TFS = &FS;
   Inputs.Opts = ParseOptions();
-  Inputs.Opts.ClangTidyOpts.Checks = ClangTidyChecks;
-  Inputs.Opts.ClangTidyOpts.WarningsAsErrors = ClangTidyWarningsAsErrors;
+  Inputs.ClangTidyProvider = ClangTidyProvider.get();
   Inputs.Index = ExternalIndex;
   if (Inputs.Index)
 Inputs.Opts.SuggestMissingIncludes = true;
Index: clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
===
--- clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
+++ clang-tools-extra/clangd/unittests/ParsedASTTests.cpp

[PATCH] D91370: [OPENMP]Fix PR48076: Check map types array before accessing its front.

2020-11-12 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D91370#2392267 , @ABataev wrote:

> In D91370#2392171 , @jhuber6 wrote:
>
>> LGTM then.
>>
>> Any clue what the cause of the other problem is?
>
> Could you try your test with the patch from D86119 
> ?

Still crashes after applying D86119 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91370

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


[PATCH] D91370: [OPENMP]Fix PR48076: Check map types array before accessing its front.

2020-11-12 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D91370#2392310 , @jhuber6 wrote:

> In D91370#2392267 , @ABataev wrote:
>
>> In D91370#2392171 , @jhuber6 wrote:
>>
>>> LGTM then.
>>>
>>> Any clue what the cause of the other problem is?
>>
>> Could you try your test with the patch from D86119 
>> ?
>
> Still crashes after applying D86119 .

Could you provide a debug log?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91370

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


[PATCH] D91333: [clang][SveEmitter] Fix enum declarations. [NFCI]

2020-11-12 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli updated this revision to Diff 304941.
fpetrogalli added a comment.

Improve comment in test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91333

Files:
  clang/test/Sema/aarch64-sve-enums.c
  clang/utils/TableGen/SveEmitter.cpp


Index: clang/utils/TableGen/SveEmitter.cpp
===
--- clang/utils/TableGen/SveEmitter.cpp
+++ clang/utils/TableGen/SveEmitter.cpp
@@ -416,10 +416,10 @@
 
 std::string SVEType::str() const {
   if (isPredicatePattern())
-return "sv_pattern";
+return "enum svpattern";
 
   if (isPrefetchOp())
-return "sv_prfop";
+return "enum svprfop";
 
   std::string S;
   if (Void)
@@ -1163,7 +1163,7 @@
   OS << "typedef __clang_svbfloat16x4_t svbfloat16x4_t;\n";
   OS << "#endif\n";
 
-  OS << "typedef enum\n";
+  OS << "enum svpattern\n";
   OS << "{\n";
   OS << "  SV_POW2 = 0,\n";
   OS << "  SV_VL1 = 1,\n";
@@ -1182,9 +1182,9 @@
   OS << "  SV_MUL4 = 29,\n";
   OS << "  SV_MUL3 = 30,\n";
   OS << "  SV_ALL = 31\n";
-  OS << "} sv_pattern;\n\n";
+  OS << "};\n\n";
 
-  OS << "typedef enum\n";
+  OS << "enum svprfop\n";
   OS << "{\n";
   OS << "  SV_PLDL1KEEP = 0,\n";
   OS << "  SV_PLDL1STRM = 1,\n";
@@ -1198,7 +1198,7 @@
   OS << "  SV_PSTL2STRM = 11,\n";
   OS << "  SV_PSTL3KEEP = 12,\n";
   OS << "  SV_PSTL3STRM = 13\n";
-  OS << "} sv_prfop;\n\n";
+  OS << "};\n\n";
 
   OS << "/* Function attributes */\n";
   OS << "#define __aio static inline __attribute__((__always_inline__, "
Index: clang/test/Sema/aarch64-sve-enums.c
===
--- /dev/null
+++ clang/test/Sema/aarch64-sve-enums.c
@@ -0,0 +1,19 @@
+// REQUIRES: aarch64-registered-target
+// RUN: %clang_cc1 %s -triple aarch64-none-linux-gnu -target-feature +sve 
-fallow-half-arguments-and-returns  -fsyntax-only -verify
+// expected-no-diagnostics
+
+// This test makes sure that the enum declarations in section "5. Enum
+// declarations" of the SVE ACLE [1] are not presented as typedefs in
+// `arm_sve.h`. It does so by creating a typedef'd struct with the
+// same identifier as the one defined in `arm_sve.h`, then checking that
+// it does not overload the enum defined in `arm_sve.h`.
+//
+// [1] https://developer.arm.com/documentation/100987/latest version 00bet6
+
+typedef struct { float f; } svpattern;
+typedef struct { float f; } svprfop;
+#include 
+enum svpattern a1 = SV_ALL;
+svpattern b1 = {1.0f};
+enum svprfop a2 = SV_PLDL1KEEP;
+svprfop b2 = {1.0f};


Index: clang/utils/TableGen/SveEmitter.cpp
===
--- clang/utils/TableGen/SveEmitter.cpp
+++ clang/utils/TableGen/SveEmitter.cpp
@@ -416,10 +416,10 @@
 
 std::string SVEType::str() const {
   if (isPredicatePattern())
-return "sv_pattern";
+return "enum svpattern";
 
   if (isPrefetchOp())
-return "sv_prfop";
+return "enum svprfop";
 
   std::string S;
   if (Void)
@@ -1163,7 +1163,7 @@
   OS << "typedef __clang_svbfloat16x4_t svbfloat16x4_t;\n";
   OS << "#endif\n";
 
-  OS << "typedef enum\n";
+  OS << "enum svpattern\n";
   OS << "{\n";
   OS << "  SV_POW2 = 0,\n";
   OS << "  SV_VL1 = 1,\n";
@@ -1182,9 +1182,9 @@
   OS << "  SV_MUL4 = 29,\n";
   OS << "  SV_MUL3 = 30,\n";
   OS << "  SV_ALL = 31\n";
-  OS << "} sv_pattern;\n\n";
+  OS << "};\n\n";
 
-  OS << "typedef enum\n";
+  OS << "enum svprfop\n";
   OS << "{\n";
   OS << "  SV_PLDL1KEEP = 0,\n";
   OS << "  SV_PLDL1STRM = 1,\n";
@@ -1198,7 +1198,7 @@
   OS << "  SV_PSTL2STRM = 11,\n";
   OS << "  SV_PSTL3KEEP = 12,\n";
   OS << "  SV_PSTL3STRM = 13\n";
-  OS << "} sv_prfop;\n\n";
+  OS << "};\n\n";
 
   OS << "/* Function attributes */\n";
   OS << "#define __aio static inline __attribute__((__always_inline__, "
Index: clang/test/Sema/aarch64-sve-enums.c
===
--- /dev/null
+++ clang/test/Sema/aarch64-sve-enums.c
@@ -0,0 +1,19 @@
+// REQUIRES: aarch64-registered-target
+// RUN: %clang_cc1 %s -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns  -fsyntax-only -verify
+// expected-no-diagnostics
+
+// This test makes sure that the enum declarations in section "5. Enum
+// declarations" of the SVE ACLE [1] are not presented as typedefs in
+// `arm_sve.h`. It does so by creating a typedef'd struct with the
+// same identifier as the one defined in `arm_sve.h`, then checking that
+// it does not overload the enum defined in `arm_sve.h`.
+//
+// [1] https://developer.arm.com/documentation/100987/latest version 00bet6
+
+typedef struct { float f; } svpattern;
+typedef struct { float f; } svprfop;
+#include 
+enum svpattern a1 = SV_ALL;
+svpattern b1 = {1.0f};
+enum svprfop a2 = SV_PLDL1KEEP;
+svprfop b2 = {1.0f};
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://list

[PATCH] D91370: [OPENMP]Fix PR48076: Check map types array before accessing its front.

2020-11-12 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D91370#2392313 , @ABataev wrote:

> In D91370#2392310 , @jhuber6 wrote:
>
>> In D91370#2392267 , @ABataev wrote:
>>
>>> In D91370#2392171 , @jhuber6 wrote:
>>>
 LGTM then.

 Any clue what the cause of the other problem is?
>>>
>>> Could you try your test with the patch from D86119 
>>> ?
>>
>> Still crashes after applying D86119 .
>
> Could you provide a debug log?

From Clang or Libomptarget? Libomptarget is the same as above.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91370

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


[PATCH] D91370: [OPENMP]Fix PR48076: Check map types array before accessing its front.

2020-11-12 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D91370#2392317 , @jhuber6 wrote:

> In D91370#2392313 , @ABataev wrote:
>
>> In D91370#2392310 , @jhuber6 wrote:
>>
>>> In D91370#2392267 , @ABataev wrote:
>>>
 In D91370#2392171 , @jhuber6 
 wrote:

> LGTM then.
>
> Any clue what the cause of the other problem is?

 Could you try your test with the patch from D86119 
 ?
>>>
>>> Still crashes after applying D86119 .
>>
>> Could you provide a debug log?
>
> From Clang or Libomptarget? Libomptarget is the same as above.

From libomptarget. It must be different. Could you copy it here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91370

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


[PATCH] D91337: [clangd] Add missing tests to rename feature

2020-11-12 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tools-extra/clangd/unittests/RenameTests.cpp:203
 };
+struct D : B {
+  void [[f^oo]]() override {}

hmm, I'm not sure this is needed, I think it is identical with `C`.



Comment at: clang-tools-extra/clangd/unittests/RenameTests.cpp:618
+
+  // Templated method instantiation.
+  R"cpp(

nit: we have groups of templates on ~Line  215 already,  I'd suggest to move 
these template-related cases to there.



Comment at: clang-tools-extra/clangd/unittests/RenameTests.cpp:684
+
+  R"cpp(
+template 

nit: add a comment, this is variable template.



Comment at: clang-tools-extra/clangd/unittests/RenameTests.cpp:703
+  )cpp",
+  R"cpp(
+template 

this test case is about function templates, move to Line 683.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91337

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


[PATCH] D91372: Some updates/fixes to the creduce script.

2020-11-12 Thread George Burgess IV via Phabricator via cfe-commits
george.burgess.iv accepted this revision.
george.burgess.iv added a comment.
This revision is now accepted and ready to land.

thanks!




Comment at: clang/utils/creduce-clang-crash.py:156
+  def skip_function(func_name):
+for name in filters:
+  if name in func_name:

nit `return any(name in func_name for name in filters)`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91372

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


[PATCH] D91370: [OPENMP]Fix PR48076: Check map types array before accessing its front.

2020-11-12 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D91370#2392319 , @ABataev wrote:

> From libomptarget. It must be different. Could you copy it here?

Yeah, I think there's some extra information looking at it again.

  Target CUDA RTL --> Start initializing CUDA
  Libomptarget --> Successfully loaded library 'libomptarget.rtl.cuda.so'!
  Libomptarget --> Registering RTL libomptarget.rtl.cuda.so supporting 1 
devices!
  Libomptarget --> Loading library 'libomptarget.rtl.aarch64.so'...
  Libomptarget --> Unable to load library 'libomptarget.rtl.aarch64.so': 
libomptarget.rtl.aarch64.so: cannot open shared object file: No such file or 
directory!
  Libomptarget --> Loading library 'libomptarget.rtl.ve.so'...
  Libomptarget --> Unable to load library 'libomptarget.rtl.ve.so': 
libomptarget.rtl.ve.so: cannot open shared object file: No such file or 
directory!
  Libomptarget --> Loading library 'libomptarget.rtl.amdgpu.so'...
  Libomptarget --> Unable to load library 'libomptarget.rtl.amdgpu.so': 
libomptarget.rtl.amdgpu.so: cannot open shared object file: No such file or 
directory!
  Libomptarget --> RTLs loaded!
  Libomptarget --> Image 0x00400a30 is NOT compatible with RTL 
libomptarget.rtl.x86_64.so!
  Libomptarget --> Image 0x00400a30 is compatible with RTL 
libomptarget.rtl.cuda.so!
  Libomptarget --> RTL 0x008334c0 has index 0!
  Libomptarget --> Registering image 0x00400a30 with RTL 
libomptarget.rtl.cuda.so!
  Libomptarget --> Done registering entries!
  Libomptarget --> Call to omp_get_num_devices returning 1
  Libomptarget --> Default TARGET OFFLOAD policy is now mandatory (devices were 
found)
  Libomptarget --> Entering target region with entry point 0x004009e0 
and device Id -1
  Libomptarget --> Checking whether device 0 is ready.
  Libomptarget --> Is the device 0 (local ID 0) initialized? 0
  Target CUDA RTL --> Init requires flags to 1
  Target CUDA RTL --> Getting device 0
  Target CUDA RTL --> The primary context is inactive, set its flags to 
CU_CTX_SCHED_BLOCKING_SYNC
  Target CUDA RTL --> Max CUDA blocks per grid 2147483647 exceeds the hard team 
limit 65536, capping at the hard limit
  Target CUDA RTL --> Using 1024 CUDA threads per block
  Target CUDA RTL --> Using warp size 32
  Target CUDA RTL --> Device supports up to 65536 CUDA blocks and 1024 threads 
with a warp size of 32
  Target CUDA RTL --> Default number of teams set according to library's 
default 128
  Target CUDA RTL --> Default number of threads set according to library's 
default 128
  Libomptarget --> Device 0 is ready to use.
  Target CUDA RTL --> Load data from image 0x00400a30
  Target CUDA RTL --> CUDA module successfully loaded!
  Target CUDA RTL --> Entry point 0x maps to 
__omp_offloading_fd02_267be70_main_l10 (0x011d0ef0)
  Target CUDA RTL --> Sending global device environment data 4 bytes
  Libomptarget --> Entry  0: Base=0x7ffc7e77c2a8, Begin=0x7ffc7e77c370, 
Size=8, Type=0x20
  Libomptarget --> Entry  1: Base=0x7ffc7e77c2a8, Begin=0x7ffc7e77c2a8, 
Size=208, Type=0x10203
  Libomptarget --> Looking up mapping(HstPtrBegin=0x7ffc7e77c370, Size=8)...
  Libomptarget --> MemoryManagerTy::allocate: size 8 with host pointer 
0x7ffc7e77c370.
  Libomptarget --> findBucket: Size 8 is floored to 8.
  Libomptarget --> Cannot find a node in the FreeLists. Allocate on device.
  Libomptarget --> Node address 0x011b8ba8, target pointer 
0x7fa79240, size 8
  Libomptarget --> Creating new map entry: HstBase=0x7ffc7e77c2a8, 
HstBegin=0x7ffc7e77c370, HstEnd=0x7ffc7e77c378, 
TgtBegin=0x7fa79240
  Libomptarget --> There are 8 bytes allocated at target address 
0x7fa79240 - is new
  Libomptarget --> Looking up mapping(HstPtrBegin=0x7ffc7e77c2a8, 
Size=208)...
  Libomptarget --> WARNING: Pointer is not mapped but section extends into 
already mapped data
  Libomptarget --> Mapping exists (implicit) with 
HstPtrBegin=0x7ffc7e77c2a8, TgtPtrBegin=0x7fa7923fff38, Size=208, 
RefCount=1
  Libomptarget --> There are 208 bytes allocated at target address 
0x7fa7923fff38 - is not new
  Libomptarget --> DeviceTy::getMapEntry: requested entry found
  Libomptarget --> Moving 208 bytes (hst:0x7ffc7e77c2a8) -> 
(tgt:0x7fa7923fff38)
  Target CUDA RTL --> Error when copying data from host to device. Pointers: 
host = 0x7ffc7e77c2a8, device = 0x7fa7923fff38, size = 208
  Target CUDA RTL --> CUDA error is: invalid argument
  Libomptarget --> Copying data to device failed.
  Libomptarget --> Call to targetDataBegin failed, abort target.
  Libomptarget --> Failed to process data before launching the kernel.
  Libomptarget error: run with env LIBOMPTARGET_INFO>1 to dump 
host-targetpointer maps
  Libomptarget fatal error 1: failure of target construct while offloading is 
mandatory
  Aborted (core dumped)


Repository:
  rG LLVM Github Monorepo

CHANGES SI

[PATCH] D91361: [AIX][driver] Include crti[_64].o and -bcdtors also for C language link invocations by default

2020-11-12 Thread David Tenty via Phabricator via cfe-commits
daltenty added inline comments.



Comment at: clang/lib/Driver/ToolChains/AIX.cpp:137
 
-if (D.CCCIsCXX())
+if (D.CCCIsCXX() || D.CCCIsCC())
   CmdArgs.push_back(Args.MakeArgString(

I think that rather that adding CC, we should just pull the if and 
unconditionally link crti.o. This is consistent with what is done on other 
platforms and since the `llvm.global_c/dtors` are generally allowable in the 
IR, we might see them in more than just the two driver scenarios suggested here.



Comment at: clang/lib/Driver/ToolChains/AIX.cpp:146
+  // forward.
+  if (D.CCCIsCXX() || D.CCCIsCC())
 CmdArgs.push_back("-bcdtors:all:0:s");

Ditto the previous comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91361

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


  1   2   >