[PATCH] D82314: [RFC][Coroutines] Optimize the lifespan of temporary co_await object

2020-06-24 Thread Xun Li via Phabricator via cfe-commits
lxfind updated this revision to Diff 272916.
lxfind added a comment.

Address test failures


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82314

Files:
  llvm/lib/Transforms/Coroutines/CoroSplit.cpp
  llvm/test/Transforms/Coroutines/coro-split-02.ll

Index: llvm/test/Transforms/Coroutines/coro-split-02.ll
===
--- llvm/test/Transforms/Coroutines/coro-split-02.ll
+++ llvm/test/Transforms/Coroutines/coro-split-02.ll
@@ -40,14 +40,9 @@
 }
 
 ; CHECK-LABEL: @a.resume(
-; CHECK: %testval = alloca i32
 ; CHECK: getelementptr inbounds %a.Frame
 ; CHECK-NEXT:getelementptr inbounds %"struct.lean_future::Awaiter"
-; CHECK-NOT: call token @llvm.coro.save(i8* null)
 ; CHECK-NEXT:%val = load i32, i32* %Result
-; CHECK-NEXT:%cast = bitcast i32* %testval to i8*
-; CHECK-NEXT:call void @llvm.lifetime.start.p0i8(i64 4, i8* %cast)
-; CHECK-NEXT:call void @llvm.lifetime.end.p0i8(i64 4, i8* %cast)
 ; CHECK-NEXT:call void @print(i32 %val)
 ; CHECK-NEXT:ret void
 
Index: llvm/lib/Transforms/Coroutines/CoroSplit.cpp
===
--- llvm/lib/Transforms/Coroutines/CoroSplit.cpp
+++ llvm/lib/Transforms/Coroutines/CoroSplit.cpp
@@ -75,7 +75,7 @@
 
 namespace {
 
-/// A little helper class for building 
+/// A little helper class for building
 class CoroCloner {
 public:
   enum class Kind {
@@ -563,7 +563,7 @@
   // In the original function, the AllocaSpillBlock is a block immediately
   // following the allocation of the frame object which defines GEPs for
   // all the allocas that have been moved into the frame, and it ends by
-  // branching to the original beginning of the coroutine.  Make this 
+  // branching to the original beginning of the coroutine.  Make this
   // the entry block of the cloned function.
   auto *Entry = cast(VMap[Shape.AllocaSpillBlock]);
   auto *OldEntry = &NewF->getEntryBlock();
@@ -1239,6 +1239,106 @@
   S.resize(N);
 }
 
+/// For every local variable that has lifetime intrinsics markers, we sink
+/// their lifetime.start marker to the places where the variable is being
+/// used for the first time. Doing so minimizes the lifetime of each variable,
+/// hence minimizing the amount of data we end up putting on the frame.
+static void sinkLifetimeStartMarkers(Function &F) {
+  DominatorTree Dom(F);
+  for (Instruction &I : instructions(F)) {
+// We look for this particular pattern:
+//   %tmpX = alloca %.., align ...
+//   %0 = bitcast %...* %tmpX to i8*
+//   call void @llvm.lifetime.start.p0i8(i64 ..., i8* nonnull %0) #2
+if (!isa(&I))
+  continue;
+BitCastInst *CastInst = nullptr;
+// There can be multiple lifetime start markers for the same variable.
+SmallPtrSet LifetimeStartInsts;
+// SinkBarriers stores all instructions that use this local variable.
+// When sinking the lifetime start intrinsics, we can never sink past
+// these barriers.
+SmallPtrSet SinkBarriers;
+bool Valid = true;
+auto addSinkBarrier = [&](Instruction *I) {
+  // When adding a new barrier to SinkBarriers, we maintain the case
+  // that no instruction in SinkBarriers dominates another instruction.
+  bool FoundDom = false;
+  SmallPtrSet ToRemove;
+  for (auto *S : SinkBarriers) {
+if (Dom.dominates(S, I)) {
+  FoundDom = true;
+  break;
+} else if (Dom.dominates(I, S)) {
+  ToRemove.insert(S);
+}
+  }
+  if (!FoundDom) {
+SinkBarriers.insert(I);
+for (auto *R : ToRemove) {
+  SinkBarriers.erase(R);
+}
+  }
+};
+for (User *U : I.users()) {
+  if (!isa(U))
+continue;
+  if (CastInst) {
+// If we have multiple cast instructions for the alloca, don't
+// deal with it beause it's too complex.
+Valid = false;
+break;
+  }
+  CastInst = cast(U);
+  for (User *CU : CastInst->users()) {
+// If we see any user of CastInst that's not lifetime start/end
+// intrinsics, give up because it's too complex.
+if (auto *CUI = dyn_cast(CU)) {
+  if (CUI->getIntrinsicID() == Intrinsic::lifetime_start)
+LifetimeStartInsts.insert(CUI);
+  else if (CUI->getIntrinsicID() == Intrinsic::lifetime_end)
+addSinkBarrier(CUI);
+  else
+Valid = false;
+} else {
+  Valid = false;
+}
+  }
+}
+if (!Valid || LifetimeStartInsts.empty())
+  continue;
+
+for (User *U : I.users()) {
+  if (U == CastInst)
+continue;
+  // Every user of the variable is also a sink barrier.
+  addSinkBarrier(cast(U));
+}
+
+// For each sink barrier, we insert a lifetime start marker right
+// before it.
+const auto *LifetimeStartInst = *

[PATCH] D81920: [clangd] Change FSProvider::getFileSystem to take CurrentWorkingDirectory

2020-06-24 Thread Mikael Holmén via Phabricator via cfe-commits
uabelho added a comment.

In D81920#2109901 , @kadircet wrote:

> Can you check if you see the warning with different versions of gcc?


Originally I got them with 7.4.0 and now I tried with 9.3.0 and got them there 
as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81920



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


[PATCH] D82086: [AST][RecoveryExpr] Fix a crash: don't attach error-type base specifiers.

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



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:2430
+  if (BaseType->containsErrors()) {
+// FIXME: should we emit a diagnostic here? We already emit a diagnostic
+// when parsing the error type.

I think this is fine, just "// already emitted this error" or so


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82086



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


[PATCH] D81285: [builtins] Change si_int to int in some helper declarations

2020-06-24 Thread Anatoly Trosinenko via Phabricator via cfe-commits
atrosinenko added a comment.

Thank you!

In D81285#2110102 , @MaskRay wrote:

> > This patch changes types of some integer function arguments or return 
> > values from si_int to the default int type (typedefed to native_int to make 
> > it obvious this is intentional) to make it more compatible with libgcc.
>
> Please drop `native_int` from the description since the code has been 
> adjusted.


Fixed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81285



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


[PATCH] D82436: [clangd] Implement textDocument/foldingRange

2020-06-24 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev created this revision.
kbobyrev added a reviewer: sammccall.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous, 
MaskRay, ilya-biryukov.
Herald added a project: clang.

This patch introduces basic textDocument/foldingRange support. It relies on
textDocument/documentSymbols to collect all symbols and uses takes ranges
to create folds.

The next steps for textDocument/foldingRange support would be:

- Implementing FoldingRangeClientCapabilities and respecting respect client 
preferences
- Specifying folding range kind
- Supporting more folding range types: PP definitions, sequential includes, 
public/private/protected sections of classes and structs

Tested: (Neo)Vim (coc-clangd) and VSCode.

Related issue: https://github.com/clangd/clangd/issues/310


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82436

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdLSPServer.h
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/FindSymbols.cpp
  clang-tools-extra/clangd/FindSymbols.h
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/test/initialize-params.test

Index: clang-tools-extra/clangd/test/initialize-params.test
===
--- clang-tools-extra/clangd/test/initialize-params.test
+++ clang-tools-extra/clangd/test/initialize-params.test
@@ -37,6 +37,7 @@
 # CHECK-NEXT:  "clangd.applyTweak"
 # CHECK-NEXT:]
 # CHECK-NEXT:  },
+# CHECK-NEXT:  "foldingRangeProvider": true,
 # CHECK-NEXT:  "hoverProvider": true,
 # CHECK-NEXT:  "referencesProvider": true,
 # CHECK-NEXT:  "renameProvider": true,
Index: clang-tools-extra/clangd/Protocol.h
===
--- clang-tools-extra/clangd/Protocol.h
+++ clang-tools-extra/clangd/Protocol.h
@@ -1510,6 +1510,22 @@
 };
 llvm::json::Value toJSON(const DocumentLink &DocumentLink);
 
+struct FoldingRangeParams {
+  TextDocumentIdentifier textDocument;
+};
+bool fromJSON(const llvm::json::Value &, FoldingRangeParams &);
+
+/// Stores information about a region of code that can be folded.
+/// FIXME(kirillbobyrev): Implement FoldingRangeClientCapabilities.
+struct FoldingRange {
+  unsigned startLine;
+  llvm::Optional startCharacter;
+  unsigned endLine;
+  llvm::Optional endCharacter;
+  llvm::Optional kind;
+};
+llvm::json::Value toJSON(const FoldingRange &Range);
+
 } // namespace clangd
 } // namespace clang
 
Index: clang-tools-extra/clangd/Protocol.cpp
===
--- clang-tools-extra/clangd/Protocol.cpp
+++ clang-tools-extra/clangd/Protocol.cpp
@@ -1241,5 +1241,24 @@
   };
 }
 
+bool fromJSON(const llvm::json::Value &Params, FoldingRangeParams &R) {
+  llvm::json::ObjectMapper O(Params);
+  return O && O.map("textDocument", R.textDocument);
+}
+
+llvm::json::Value toJSON(const FoldingRange &Range) {
+  llvm::json::Object Result{
+  {"startLine", Range.startLine},
+  {"endLine", Range.endLine},
+  };
+  if (Range.startCharacter)
+Result["startCharacter"] = *Range.startCharacter;
+  if (Range.endCharacter)
+Result["endCharacter"] = *Range.endCharacter;
+  if (Range.kind)
+Result["kind"] = *Range.kind;
+  return Result;
+}
+
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/FindSymbols.h
===
--- clang-tools-extra/clangd/FindSymbols.h
+++ clang-tools-extra/clangd/FindSymbols.h
@@ -47,6 +47,10 @@
 /// same order that they appear.
 llvm::Expected> getDocumentSymbols(ParsedAST &AST);
 
+/// Retrieves folding ranges using Document Symbols in the "main file" section
+/// of given AST.
+llvm::Expected> getFoldingRanges(ParsedAST &AST);
+
 } // namespace clangd
 } // namespace clang
 
Index: clang-tools-extra/clangd/FindSymbols.cpp
===
--- clang-tools-extra/clangd/FindSymbols.cpp
+++ clang-tools-extra/clangd/FindSymbols.cpp
@@ -271,11 +271,35 @@
 std::vector collectDocSymbols(ParsedAST &AST) {
   return DocumentOutline(AST).build();
 }
+
+// Recursively collects FoldingRange from a symbol and its children.
+void collectFoldingRanges(DocumentSymbol Symbol,
+  std::vector &Result) {
+  FoldingRange Range;
+  Range.startLine = Symbol.range.start.line;
+  Range.startCharacter = Symbol.range.start.character;
+  Range.endLine = Symbol.range.end.line;
+  Range.endCharacter = Symbol.range.end.character;
+  Result.push_back(Range);
+  for (const auto &Child : Symbol.children)
+collectFoldingRanges(Child, Result);
+}
 } // namespace
 
 llvm::Expected> getDocumentSymbols(ParsedAST &AST) {
   return collectDocSymbols(AST);
 }
 
+// FIXME(kirillbobyrev): Collect commenets, PP definitions and other c

[PATCH] D82099: [AST][RecoveryAST] Populate error-bit from Type to Expr.

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



Comment at: clang/include/clang/AST/DependenceFlags.h:123
+  translate(D, TypeDependence::Dependent, Dependent) |
+  translate(D, TypeDependence::Error, Error) |
+  translate(D, TypeDependence::VariablyModified, VariablyModified)) {}

oops! seems like we should be able to observe this directly in an AST dump test 
too, which should be failing to mark some nodes as error-dependent.
(Not sure if there's a simpler example than your crashing testcase though)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82099



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


[PATCH] D81869: Modify FPFeatures to use delta not absolute settings to solve PCH compatibility problems

2020-06-24 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Just a bunch of minor suggestions.  LGTM if you get all the tests worked out 
and it actually works the way you want on the tests.




Comment at: clang/include/clang/AST/Expr.h:2280
   }
+  FPOptionsOverride getFPFeatures(const LangOptions &LO) const {
+if (UnaryOperatorBits.HasFPFeatures)

rjmccall wrote:
> I would call this one getFPOptionOverrides or getOverriddenFPOptions.  If 
> you're going to have a getFPFeatures, it really ought to be the other one — 
> although since we're changing pretty much all of the call sites, we might as 
> well rename it to getFPOptions (or getFPOptionsInEffect, that seems fine, 
> too).
I don't think there's any reason for this to take a LangOptions, since the set 
of overrides should be independent of the global settings.



Comment at: clang/include/clang/Basic/LangOptions.h:512
+FPOptions result( (Base.getAsOpaqueInt() & ~OverrideMask)
+ | (OverrideMask & Options.getAsOpaqueInt()));
+return result;

clang-format's suggestion is good here



Comment at: clang/include/clang/Basic/LangOptions.h:542
+  LLVM_DUMP_METHOD void dump();
+};
 

Same here: clang-format's just asking you to right-justify the escapes, and 
it's right, that's the style we usually use with multi-line macros.



Comment at: clang/include/clang/Sema/Sema.h:569
+  }
 
   // RAII object to push / pop sentinel slots for all MS #pragma stacks.

Spurious spaces (as pointed out by clang-format)



Comment at: clang/include/clang/Serialization/ASTWriter.h:509
   void WriteDeclContextVisibleUpdate(const DeclContext *DC);
-  void WriteFPPragmaOptions(const FPOptions &Opts);
+  void WriteFPPragmaOptions(const FPOptionsOverride &Opts);
   void WriteOpenCLExtensions(Sema &SemaRef);

I think it's telling you that you're missing a forward-declaration of this type 
in this file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81869



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


[PATCH] D82385: [Analyzer] Fix errors in iterator modeling

2020-06-24 Thread Endre Fülöp via Phabricator via cfe-commits
gamesh411 added a comment.

Hey! See my inline comments, but after those and a quick clang-format, it looks 
good.




Comment at: clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp:543
 
-  auto NewState =
+  auto TmpState =
 advancePosition(State, LHS, Op, *value);

TmpState feels too generic, maybe AdvancedPosition is more descriptive? Just a 
suggestion.



Comment at: clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp:614
   auto RegionMap = State->get();
+  unsigned Count = 0;
 

I would welcome a one-line comment here, stating that this variable is here for 
formatting reasons (so that the messages are **joined** by a newline, and no 
prefix or postfix newline is present in the output). Or rename to LinesOutput, 
LinesPrinted or something similar.



Comment at: clang/test/Analysis/iterator-modeling.cpp:36
   clang_analyzer_denote(clang_analyzer_container_begin(v), "$v.begin()");
-  clang_analyzer_express(clang_analyzer_iterator_position(i)); 
//expected-warning{{$v.begin()}}
+  clang_analyzer_express(clang_analyzer_iterator_position(i)); // 
expected-warning-re {{$v.begin(){{$
 

It seems important to me that this test is fixed, as we were not testing 
whether the message really **ends** with `$v.begin()`. 👍 


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

https://reviews.llvm.org/D82385



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


[PATCH] D79677: [Clang][OpenMP][OMPBuilder] (1/4) Privatize `parallel` for `OMPBuilder`

2020-06-24 Thread Kiran Chandramohan via Phabricator via cfe-commits
kiranchandramohan added a comment.

Thanks @fghanim for this patch. I will get to this on Friday if you can add me 
as a reviewer.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79677



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


[PATCH] D82385: [Analyzer] Fix errors in iterator modeling

2020-06-24 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 272927.
baloghadamsoftware added a comment.

Code reformatted according to Lint Pre-Merge check suggestions.


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

https://reviews.llvm.org/D82385

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

Index: clang/test/Analysis/iterator-modeling.cpp
===
--- clang/test/Analysis/iterator-modeling.cpp
+++ clang/test/Analysis/iterator-modeling.cpp
@@ -1,12 +1,12 @@
-// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,debug.DebugIteratorModeling,debug.ExprInspection -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=false %s -verify
+// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,debug.DebugIteratorModeling,debug.ExprInspection -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=false %s -verify -analyzer-config display-checker-name=false
 
-// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,debug.DebugIteratorModeling,debug.ExprInspection -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=true -DINLINE=1 %s -verify
+// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,debug.DebugIteratorModeling,debug.ExprInspection -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=true -DINLINE=1 %s -verify -analyzer-config display-checker-name=false
 
-// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,debug.DebugIteratorModeling,debug.ExprInspection -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=true -DINLINE=1 -DSTD_ADVANCE_INLINE_LEVEL=0 %s -verify
+// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,debug.DebugIteratorModeling,debug.ExprInspection -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=true -DINLINE=1 -DSTD_ADVANCE_INLINE_LEVEL=0 %s -verify -analyzer-config display-checker-name=false
 
-// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,debug.DebugIteratorModeling,debug.ExprInspection -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=true -DINLINE=1 -DSTD_ADVANCE_INLINE_LEVEL=1 %s -verify
+// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,debug.DebugIteratorModeling,debug.ExprInspection -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=true -DINLINE=1 -DSTD_ADVANCE_INLINE_LEVEL=1 %s -verify -analyzer-config display-checker-name=false
 
-// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,debug.DebugIteratorModeling,debug.ExprInspection -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=true -DINLINE=1 -DSTD_ADVANCE_INLINE_LEVEL=2 %s -verify
+// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,debug.DebugIteratorModeling,debug.ExprInspection -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=true -DINLINE=1 -DSTD_ADVANCE_INLINE_LEVEL=2 %s -verify -analyzer-config display-checker-name=false
 
 // RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorModeling,debug.ExprInspection -analyzer-config aggressive-binary-operation-simplification=true %s 2>&1 | FileCheck %s
 
@@ -33,7 +33,7 @@
 
   clang_analyzer_eval(clang_analyzer_iterator_container(i) == &v); // expected-warning{{TRUE}}
   clang_analyzer_denote(clang_analyzer_container_begin(v), "$v.begin()");
-  clang_analyzer_express(clang_analyzer_iterator_position(i)); //expected-warning{{$v.begin()}}
+  clang_analyzer_express(clang_analyzer_iterator_position(i)); // expected-warning-re {{$v.begin(){{$
 
   if (i != v.begin()) {
 clang_analyzer_warnIfReached();
@@ -45,7 +45,7 @@
 
   clang_analyzer_eval(clang_analyzer_iterator_container(i) == &v); // expected-warning{{TRUE}}
   clang_analyzer_denote(clang_analyzer_container_end(v), "$v.end()");
-  clang_analyzer_express(clang_analyzer_iterator_position(i)); //expected-warning{{$v.end()}}
+  clang_analyzer_express(clang_analyzer_iterator_position(i)); // expected-warning-re {{$v.end(){{$
 
   if (i != v.end()) {
 clang_analyzer_warnIfReached();
@@ -59,8 +59,8 @@
 
   auto j = ++i;
 
-  clang_analyzer_express(clang_analyzer_iterator_position(i)); //expected-warning{{$v.begin() + 1}}
-  clang_analyzer_express(clang_analyzer_iterator_position(j)); //expected-warning{{$v.begin() + 1}}
+  clang_analyzer_express(clang_analyzer_iterator_position(i)); // expected-warning-re {{$v.begin() + 1{{$
+  clang_analy

[PATCH] D82185: [Analyzer] Handle pointer implemented as iterators in iterator checkers

2020-06-24 Thread Endre Fülöp via Phabricator via cfe-commits
gamesh411 added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp:623
+
+  auto TempState = advancePosition(State, OldVal, OK, Offset);
+  const IteratorPosition *NewPos = getIteratorPosition(TempState, OldVal);

Same as in the other patch. I think variable name `TempState` is too generic, 
should be AdvancedState or something more descriptive.



Comment at: clang/test/Analysis/iterator-modeling.cpp:1875
+  clang_analyzer_denote(clang_analyzer_container_begin(c), "$c.begin()");
+  clang_analyzer_express(clang_analyzer_iterator_position(i)); 
//expected-warning{{$c.begin()}}
+

Just being annoying here, but  I saw you use `// expected` (with a space 
between the slash and expected) consistently elsewhere. Could you please also 
use that here in these tests as well? Being uniform with those helps spot other 
errors and typos IMHO.


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

https://reviews.llvm.org/D82185



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


[PATCH] D82314: [RFC][Coroutines] Optimize the lifespan of temporary co_await object

2020-06-24 Thread JunMa via Phabricator via cfe-commits
junparser added a comment.

@lxfind, Thank you!  And could you please add some testcases?




Comment at: llvm/lib/Transforms/Coroutines/CoroSplit.cpp:1286
+continue;
+  if (CastInst) {
+// If we have multiple cast instructions for the alloca, don't

It is possible to handle multiple cast instructions as long as they are only 
used by lifetime marker intrinsic. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82314



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


[clang] 96d4ccf - [VE] Clang toolchain for VE

2020-06-24 Thread Simon Moll via cfe-commits

Author: Kazushi (Jam) Marukawa
Date: 2020-06-24T10:12:09+02:00
New Revision: 96d4ccf00c8f746aebb549288fac33dcbb15bc4b

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

LOG: [VE] Clang toolchain for VE

Summary:
This patch enables compilation of C code for the VE target with Clang.

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

Added: 
clang/lib/Basic/Targets/VE.cpp
clang/lib/Basic/Targets/VE.h
clang/lib/Driver/ToolChains/Arch/VE.cpp
clang/lib/Driver/ToolChains/Arch/VE.h
clang/lib/Driver/ToolChains/VE.cpp
clang/lib/Driver/ToolChains/VE.h
clang/test/CodeGen/ve-abi.c

Modified: 
clang/include/clang/Basic/TargetBuiltins.h
clang/lib/Basic/CMakeLists.txt
clang/lib/Basic/Targets.cpp
clang/lib/CodeGen/TargetInfo.cpp
clang/lib/Driver/CMakeLists.txt
clang/lib/Driver/Driver.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Driver/ToolChains/Clang.h
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/lib/Driver/ToolChains/Gnu.cpp
clang/lib/Driver/ToolChains/Linux.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/TargetBuiltins.h 
b/clang/include/clang/Basic/TargetBuiltins.h
index eba055c302a7..b472547012f0 100644
--- a/clang/include/clang/Basic/TargetBuiltins.h
+++ b/clang/include/clang/Basic/TargetBuiltins.h
@@ -119,6 +119,11 @@ namespace clang {
   };
   }
 
+  /// VE builtins
+  namespace VE {
+  enum { LastTIBuiltin = clang::Builtin::FirstTSBuiltin - 1, LastTSBuiltin };
+  }
+
   /// Flags to identify the types for overloaded Neon builtins.
   ///
   /// These must be kept in sync with the flags in 
utils/TableGen/NeonEmitter.h.

diff  --git a/clang/lib/Basic/CMakeLists.txt b/clang/lib/Basic/CMakeLists.txt
index cd310ec811b4..1b55d8417377 100644
--- a/clang/lib/Basic/CMakeLists.txt
+++ b/clang/lib/Basic/CMakeLists.txt
@@ -84,6 +84,7 @@ add_clang_library(clangBasic
   Targets/Sparc.cpp
   Targets/SystemZ.cpp
   Targets/TCE.cpp
+  Targets/VE.cpp
   Targets/WebAssembly.cpp
   Targets/X86.cpp
   Targets/XCore.cpp

diff  --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp
index 69133ca31fec..6bbcafa27dfe 100644
--- a/clang/lib/Basic/Targets.cpp
+++ b/clang/lib/Basic/Targets.cpp
@@ -33,6 +33,7 @@
 #include "Targets/Sparc.h"
 #include "Targets/SystemZ.h"
 #include "Targets/TCE.h"
+#include "Targets/VE.h"
 #include "Targets/WebAssembly.h"
 #include "Targets/X86.h"
 #include "Targets/XCore.h"
@@ -613,6 +614,9 @@ TargetInfo *AllocateTarget(const llvm::Triple &Triple,
 return new LinuxTargetInfo(Triple, Opts);
   case llvm::Triple::renderscript64:
 return new LinuxTargetInfo(Triple, Opts);
+
+  case llvm::Triple::ve:
+return new LinuxTargetInfo(Triple, Opts);
   }
 }
 } // namespace targets

diff  --git a/clang/lib/Basic/Targets/VE.cpp b/clang/lib/Basic/Targets/VE.cpp
new file mode 100644
index ..3654e8ad
--- /dev/null
+++ b/clang/lib/Basic/Targets/VE.cpp
@@ -0,0 +1,39 @@
+//===--- VE.cpp - Implement VE target feature support 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file implements VE TargetInfo objects.
+//
+//===--===//
+
+#include "VE.h"
+#include "clang/Basic/Builtins.h"
+#include "clang/Basic/MacroBuilder.h"
+#include "clang/Basic/TargetBuiltins.h"
+
+using namespace clang;
+using namespace clang::targets;
+
+void VETargetInfo::getTargetDefines(const LangOptions &Opts,
+MacroBuilder &Builder) const {
+  Builder.defineMacro("_LP64", "1");
+  Builder.defineMacro("unix", "1");
+  Builder.defineMacro("__unix__", "1");
+  Builder.defineMacro("__linux__", "1");
+  Builder.defineMacro("__ve", "1");
+  Builder.defineMacro("__ve__", "1");
+  Builder.defineMacro("__STDC_HOSTED__", "1");
+  Builder.defineMacro("__STDC__", "1");
+  Builder.defineMacro("__NEC__", "1");
+  // FIXME: define __FAST_MATH__ 1 if -ffast-math is enabled
+  // FIXME: define __OPTIMIZE__ n if -On is enabled
+  // FIXME: define __VECTOR__ n 1 if automatic vectorization is enabled
+}
+
+ArrayRef VETargetInfo::getTargetBuiltins() const {
+  return ArrayRef();
+}

diff  --git a/clang/lib/Basic/Targets/VE.h b/clang/lib/Basic/Targets/VE.h
new file mode 100644
index ..7e50e7daeb90
--- /dev/null
+++ b/clang/lib/Basic/Targets/VE.h
@@ -0,0 +1,170 @@
+//===--- VE.h - Declare VE target feature support ---*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions

[clang] f0084c3 - [AST][RecoveryExpr] Fix a crash: don't attach error-type base specifiers.

2020-06-24 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-06-24T10:13:46+02:00
New Revision: f0084c3bcbc2f2e17ab1a24d19ac6738eb4c4263

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

LOG: [AST][RecoveryExpr] Fix a crash: don't attach error-type base specifiers.

Summary:
otherwise we'll run into code path which expects a good base specifiers,
and lead to crashes.

The crash only occurs in template instantiations (in non-template case,
the bad base specifiers are dropped during parsing.)

crash stacktrace:

```
clang: llvm-project/clang/lib/Sema/SemaInit.cpp:7864: clang::ExprResult 
clang::InitializationSequence::Perform(clang::Sema &, const 
clang::InitializedEntity &, const clang::InitializationKind &, 
clang::MultiExprArg, clang::QualType *): Assertion `Kind.getKind() == 
InitializationKind::IK_Copy || Kind.isExplicitCast() || Kind.getKind() == 
InitializationKind::IK_DirectList' failed.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash 
backtrace, preprocessed source, and associated run script.
Stack dump:
```

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: cfe-commits

Tags: #clang

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

Added: 
clang/test/SemaCXX/invalid-template-base-specifier.cpp

Modified: 
clang/lib/Sema/SemaDeclCXX.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 5e849a190760..a2ada2053534 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -2426,7 +2426,10 @@ Sema::CheckBaseSpecifier(CXXRecordDecl *Class,
  TypeSourceInfo *TInfo,
  SourceLocation EllipsisLoc) {
   QualType BaseType = TInfo->getType();
-
+  if (BaseType->containsErrors()) {
+// Already emitted a diagnostic when parsing the error type.
+return nullptr;
+  }
   // C++ [class.union]p1:
   //   A union shall not have base classes.
   if (Class->isUnion()) {

diff  --git a/clang/test/SemaCXX/invalid-template-base-specifier.cpp 
b/clang/test/SemaCXX/invalid-template-base-specifier.cpp
new file mode 100644
index ..a788cdb859eb
--- /dev/null
+++ b/clang/test/SemaCXX/invalid-template-base-specifier.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -frecovery-ast -verify %s
+
+bool Foo(int *); // expected-note {{candidate function not viable}}
+
+template 
+struct Crash : decltype(Foo(T())) { // expected-error {{no matching function 
for call to 'Foo'}}
+  Crash(){};
+};
+
+void test() { Crash(); } // expected-note {{in instantiation of template 
class}}



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


[clang] bfec030 - [AST][RecoveryExpr] Populate error-bit from Type to Expr.

2020-06-24 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-06-24T10:29:30+02:00
New Revision: bfec030e69afc73b29aa1b66902ae802a448fc19

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

LOG: [AST][RecoveryExpr] Populate error-bit from Type to Expr.

Summary: Looks like this is a fallout when we introduce the error-bit in Type.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/AST/DependenceFlags.h
clang/test/SemaCXX/invalid-template-base-specifier.cpp

Removed: 




diff  --git a/clang/include/clang/AST/DependenceFlags.h 
b/clang/include/clang/AST/DependenceFlags.h
index 0b24bae6df9b..54e12ea47fd5 100644
--- a/clang/include/clang/AST/DependenceFlags.h
+++ b/clang/include/clang/AST/DependenceFlags.h
@@ -118,10 +118,10 @@ class Dependence {
 
   Dependence(TypeDependence D)
   : V(translate(D, TypeDependence::UnexpandedPack, UnexpandedPack) |
- translate(D, TypeDependence::Instantiation, Instantiation) |
- translate(D, TypeDependence::Dependent, Dependent) |
- translate(D, TypeDependence::VariablyModified, VariablyModified)) 
{
-  }
+  translate(D, TypeDependence::Instantiation, Instantiation) |
+  translate(D, TypeDependence::Dependent, Dependent) |
+  translate(D, TypeDependence::Error, Error) |
+  translate(D, TypeDependence::VariablyModified, VariablyModified)) {}
 
   Dependence(ExprDependence D)
   : V(translate(D, ExprDependence::UnexpandedPack, UnexpandedPack) |

diff  --git a/clang/test/SemaCXX/invalid-template-base-specifier.cpp 
b/clang/test/SemaCXX/invalid-template-base-specifier.cpp
index a788cdb859eb..c0f5aabae831 100644
--- a/clang/test/SemaCXX/invalid-template-base-specifier.cpp
+++ b/clang/test/SemaCXX/invalid-template-base-specifier.cpp
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -frecovery-ast -verify %s
 
-bool Foo(int *); // expected-note {{candidate function not viable}}
+bool Foo(int *); // expected-note {{candidate function not viable}} \
+ // expected-note {{candidate function not viable}}
 
 template 
 struct Crash : decltype(Foo(T())) { // expected-error {{no matching function 
for call to 'Foo'}}
@@ -8,3 +9,12 @@ struct Crash : decltype(Foo(T())) { // expected-error {{no 
matching function for
 };
 
 void test() { Crash(); } // expected-note {{in instantiation of template 
class}}
+
+template 
+using Alias = decltype(Foo(T())); // expected-error {{no matching function for 
call to 'Foo'}}
+template 
+struct Crash2 : decltype(Alias()) { // expected-note {{in instantiation of 
template type alias 'Alias' requested here}}
+  Crash2(){};
+};
+
+void test2() { Crash2(); } // expected-note {{in instantiation of 
template class 'Crash2' requested here}}



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


[PATCH] D82099: [AST][RecoveryAST] Populate error-bit from Type to Expr.

2020-06-24 Thread Haojian Wu via Phabricator via cfe-commits
hokein marked 2 inline comments as done.
hokein added inline comments.



Comment at: clang/include/clang/AST/DependenceFlags.h:123
+  translate(D, TypeDependence::Dependent, Dependent) |
+  translate(D, TypeDependence::Error, Error) |
+  translate(D, TypeDependence::VariablyModified, VariablyModified)) {}

sammccall wrote:
> oops! seems like we should be able to observe this directly in an AST dump 
> test too, which should be failing to mark some nodes as error-dependent.
> (Not sure if there's a simpler example than your crashing testcase though)
yes, in theory. The code path need to go through "error expr" -> "error type" 
-> "recovery expr", but it seems not easy to produce a case in non-template 
context, either we bail out too early, or the recovery expression is not built. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82099



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


[PATCH] D75169: [ARM] Supporting lowering of half-precision FP arguments and returns in AArch32's backend

2020-06-24 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi added a comment.

@pratlucas @ostannard @rjmccall

I have noticed this change break on the building of the Swift standard library 
in downstream apple/swift/master-next. I reduced the test case and found that 
the chain of bitcasts/extends in ARMTargetLowering::splitValueIntoRegisterParts 
ends up not being legal and causing an assert in SelectionDag.cpp when 
compiling the following with llc:

  target datalayout = 
"e-m:o-p:32:32-Fi8-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32"
  target triple = "thumbv7s-apple-ios7.0.0"
  
  define fastcc { <8 x half>, <8 x half> } @f() {
ret { <8 x half>, <8 x half> } zeroinitializer
  }

This was originally swiftcc, but I changed it to fastcc so it would compile 
with upstream llvm.org/main while also having a calling convention that would 
satisfy the conditional here: 
https://github.com/llvm/llvm-project/blob/bfec030e69afc73b29aa1b66902ae802a448fc19/llvm/lib/Target/ARM/ARMISelLowering.cpp#L4155

The assert is as follows:

  llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1307: llvm::SDValue 
llvm::SelectionDAG::getConstant(const llvm::ConstantInt &, const llvm::SDLoc &, 
llvm::EVT, bool, bool): Assertion `Elt->getBitWidth() == EltVT.getSizeInBits() 
&& "APInt size does not match type size!"' failed.

The DAG nodes generated before:

  t5: f16 = extract_vector_elt t3, Constant:i32<0>
t3: v8f16,v8f16 = merge_values t2, t2
  t2: v8f16 = BUILD_VECTOR ConstantFP:f16, 
ConstantFP:f16, ConstantFP:f16, 
ConstantFP:f16, ConstantFP:f16, 
ConstantFP:f16, ConstantFP:f16, 
ConstantFP:f16

And After:

  t22: f32 = bitcast t21
t21: i32 = any_extend t20
  t20: i16 = bitcast t5
t5: f16 = extract_vector_elt t3, Constant:i32<0>
  t3: v8f16,v8f16 = merge_values t2, t2
t2: v8f16 = BUILD_VECTOR ConstantFP:f16, 
ConstantFP:f16, ConstantFP:f16, 
ConstantFP:f16, ConstantFP:f16, 
ConstantFP:f16, ConstantFP:f16, 
ConstantFP:f16

I suspect here there could be a the EltVT in the assert was expecting a 16-bit 
size, but is now getting 32.

I hope this is helpful.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75169



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


[PATCH] D82099: [AST][RecoveryAST] Populate error-bit from Type to Expr.

2020-06-24 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
hokein marked an inline comment as done.
Closed by commit rGbfec030e69af: [AST][RecoveryExpr] Populate error-bit from 
Type to Expr. (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82099

Files:
  clang/include/clang/AST/DependenceFlags.h
  clang/test/SemaCXX/invalid-template-base-specifier.cpp


Index: clang/test/SemaCXX/invalid-template-base-specifier.cpp
===
--- clang/test/SemaCXX/invalid-template-base-specifier.cpp
+++ clang/test/SemaCXX/invalid-template-base-specifier.cpp
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -frecovery-ast -verify %s
 
-bool Foo(int *); // expected-note {{candidate function not viable}}
+bool Foo(int *); // expected-note {{candidate function not viable}} \
+ // expected-note {{candidate function not viable}}
 
 template 
 struct Crash : decltype(Foo(T())) { // expected-error {{no matching function 
for call to 'Foo'}}
@@ -8,3 +9,12 @@
 };
 
 void test() { Crash(); } // expected-note {{in instantiation of template 
class}}
+
+template 
+using Alias = decltype(Foo(T())); // expected-error {{no matching function for 
call to 'Foo'}}
+template 
+struct Crash2 : decltype(Alias()) { // expected-note {{in instantiation of 
template type alias 'Alias' requested here}}
+  Crash2(){};
+};
+
+void test2() { Crash2(); } // expected-note {{in instantiation of 
template class 'Crash2' requested here}}
Index: clang/include/clang/AST/DependenceFlags.h
===
--- clang/include/clang/AST/DependenceFlags.h
+++ clang/include/clang/AST/DependenceFlags.h
@@ -118,10 +118,10 @@
 
   Dependence(TypeDependence D)
   : V(translate(D, TypeDependence::UnexpandedPack, UnexpandedPack) |
- translate(D, TypeDependence::Instantiation, Instantiation) |
- translate(D, TypeDependence::Dependent, Dependent) |
- translate(D, TypeDependence::VariablyModified, VariablyModified)) 
{
-  }
+  translate(D, TypeDependence::Instantiation, Instantiation) |
+  translate(D, TypeDependence::Dependent, Dependent) |
+  translate(D, TypeDependence::Error, Error) |
+  translate(D, TypeDependence::VariablyModified, VariablyModified)) {}
 
   Dependence(ExprDependence D)
   : V(translate(D, ExprDependence::UnexpandedPack, UnexpandedPack) |


Index: clang/test/SemaCXX/invalid-template-base-specifier.cpp
===
--- clang/test/SemaCXX/invalid-template-base-specifier.cpp
+++ clang/test/SemaCXX/invalid-template-base-specifier.cpp
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -frecovery-ast -verify %s
 
-bool Foo(int *); // expected-note {{candidate function not viable}}
+bool Foo(int *); // expected-note {{candidate function not viable}} \
+ // expected-note {{candidate function not viable}}
 
 template 
 struct Crash : decltype(Foo(T())) { // expected-error {{no matching function for call to 'Foo'}}
@@ -8,3 +9,12 @@
 };
 
 void test() { Crash(); } // expected-note {{in instantiation of template class}}
+
+template 
+using Alias = decltype(Foo(T())); // expected-error {{no matching function for call to 'Foo'}}
+template 
+struct Crash2 : decltype(Alias()) { // expected-note {{in instantiation of template type alias 'Alias' requested here}}
+  Crash2(){};
+};
+
+void test2() { Crash2(); } // expected-note {{in instantiation of template class 'Crash2' requested here}}
Index: clang/include/clang/AST/DependenceFlags.h
===
--- clang/include/clang/AST/DependenceFlags.h
+++ clang/include/clang/AST/DependenceFlags.h
@@ -118,10 +118,10 @@
 
   Dependence(TypeDependence D)
   : V(translate(D, TypeDependence::UnexpandedPack, UnexpandedPack) |
- translate(D, TypeDependence::Instantiation, Instantiation) |
- translate(D, TypeDependence::Dependent, Dependent) |
- translate(D, TypeDependence::VariablyModified, VariablyModified)) {
-  }
+  translate(D, TypeDependence::Instantiation, Instantiation) |
+  translate(D, TypeDependence::Dependent, Dependent) |
+  translate(D, TypeDependence::Error, Error) |
+  translate(D, TypeDependence::VariablyModified, VariablyModified)) {}
 
   Dependence(ExprDependence D)
   : V(translate(D, ExprDependence::UnexpandedPack, UnexpandedPack) |
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D79411: [VE] Clang toolchain for VE

2020-06-24 Thread Simon Moll via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG96d4ccf00c8f: [VE] Clang toolchain for VE (authored by kaz7, 
committed by simoll).

Changed prior to commit:
  https://reviews.llvm.org/D79411?vs=272632&id=272932#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79411

Files:
  clang/include/clang/Basic/TargetBuiltins.h
  clang/lib/Basic/CMakeLists.txt
  clang/lib/Basic/Targets.cpp
  clang/lib/Basic/Targets/VE.cpp
  clang/lib/Basic/Targets/VE.h
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/Driver/CMakeLists.txt
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Arch/VE.cpp
  clang/lib/Driver/ToolChains/Arch/VE.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/Clang.h
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/lib/Driver/ToolChains/VE.cpp
  clang/lib/Driver/ToolChains/VE.h
  clang/test/CodeGen/ve-abi.c

Index: clang/test/CodeGen/ve-abi.c
===
--- /dev/null
+++ clang/test/CodeGen/ve-abi.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -triple ve-linux-gnu -emit-llvm %s -o - | FileCheck %s
+
+// CHECK-LABEL: define { float, float } @p(float %a.coerce0, float %a.coerce1, float %b.coerce0, float %b.coerce1) #0 {
+float __complex__ p(float __complex__ a, float __complex__ b) {
+}
+
+// CHECK-LABEL: define { double, double } @q(double %a.coerce0, double %a.coerce1, double %b.coerce0, double %b.coerce1) #0 {
+double __complex__ q(double __complex__ a, double __complex__ b) {
+}
+
+void func() {
+  // CHECK-LABEL: %call = call i32 (i32, i32, i32, i32, i32, i32, i32, ...) bitcast (i32 (...)* @hoge to i32 (i32, i32, i32, i32, i32, i32, i32, ...)*)(i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7)
+  hoge(1, 2, 3, 4, 5, 6, 7);
+}
Index: clang/lib/Driver/ToolChains/VE.h
===
--- /dev/null
+++ clang/lib/Driver/ToolChains/VE.h
@@ -0,0 +1,66 @@
+//===--- VE.h - VE ToolChain Implementations *- 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_LIB_DRIVER_TOOLCHAINS_VE_H
+#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_VE_H
+
+#include "Linux.h"
+#include "clang/Driver/ToolChain.h"
+
+namespace clang {
+namespace driver {
+namespace toolchains {
+
+class LLVM_LIBRARY_VISIBILITY VEToolChain : public Linux {
+public:
+  VEToolChain(const Driver &D, const llvm::Triple &Triple,
+  const llvm::opt::ArgList &Args);
+
+protected:
+  Tool *buildAssembler() const override;
+  Tool *buildLinker() const override;
+
+public:
+  bool isPICDefault() const override;
+  bool isPIEDefault() const override;
+  bool isPICDefaultForced() const override;
+  bool SupportsProfiling() const override;
+  bool hasBlocksRuntime() const override;
+  void
+  AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
+llvm::opt::ArgStringList &CC1Args) const override;
+  void
+  addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
+llvm::opt::ArgStringList &CC1Args,
+Action::OffloadKind DeviceOffloadKind) const override;
+  void AddClangCXXStdlibIncludeArgs(
+  const llvm::opt::ArgList &DriverArgs,
+  llvm::opt::ArgStringList &CC1Args) const override;
+  void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
+   llvm::opt::ArgStringList &CmdArgs) const override;
+
+  llvm::ExceptionHandling
+  GetExceptionModel(const llvm::opt::ArgList &Args) const override;
+
+  CXXStdlibType
+  GetCXXStdlibType(const llvm::opt::ArgList &Args) const override {
+return ToolChain::CST_Libcxx;
+  }
+
+  RuntimeLibType GetDefaultRuntimeLibType() const override {
+return ToolChain::RLT_CompilerRT;
+  }
+
+  const char *getDefaultLinker() const override { return "nld"; }
+};
+
+} // end namespace toolchains
+} // end namespace driver
+} // end namespace clang
+
+#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_VE_H
Index: clang/lib/Driver/ToolChains/VE.cpp
===
--- /dev/null
+++ clang/lib/Driver/ToolChains/VE.cpp
@@ -0,0 +1,119 @@
+//===--- VE.cpp - VE ToolChain Implementations --*- 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 "VE.h"
+#include "CommonA

[PATCH] D82086: [AST][RecoveryExpr] Fix a crash: don't attach error-type base specifiers.

2020-06-24 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
hokein marked an inline comment as done.
Closed by commit rGf0084c3bcbc2: [AST][RecoveryExpr] Fix a crash: don't 
attach error-type base specifiers. (authored by hokein).

Changed prior to commit:
  https://reviews.llvm.org/D82086?vs=271680&id=272931#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82086

Files:
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/SemaCXX/invalid-template-base-specifier.cpp


Index: clang/test/SemaCXX/invalid-template-base-specifier.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/invalid-template-base-specifier.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -frecovery-ast -verify %s
+
+bool Foo(int *); // expected-note {{candidate function not viable}}
+
+template 
+struct Crash : decltype(Foo(T())) { // expected-error {{no matching function 
for call to 'Foo'}}
+  Crash(){};
+};
+
+void test() { Crash(); } // expected-note {{in instantiation of template 
class}}
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -2426,7 +2426,10 @@
  TypeSourceInfo *TInfo,
  SourceLocation EllipsisLoc) {
   QualType BaseType = TInfo->getType();
-
+  if (BaseType->containsErrors()) {
+// Already emitted a diagnostic when parsing the error type.
+return nullptr;
+  }
   // C++ [class.union]p1:
   //   A union shall not have base classes.
   if (Class->isUnion()) {


Index: clang/test/SemaCXX/invalid-template-base-specifier.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/invalid-template-base-specifier.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -frecovery-ast -verify %s
+
+bool Foo(int *); // expected-note {{candidate function not viable}}
+
+template 
+struct Crash : decltype(Foo(T())) { // expected-error {{no matching function for call to 'Foo'}}
+  Crash(){};
+};
+
+void test() { Crash(); } // expected-note {{in instantiation of template class}}
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -2426,7 +2426,10 @@
  TypeSourceInfo *TInfo,
  SourceLocation EllipsisLoc) {
   QualType BaseType = TInfo->getType();
-
+  if (BaseType->containsErrors()) {
+// Already emitted a diagnostic when parsing the error type.
+return nullptr;
+  }
   // C++ [class.union]p1:
   //   A union shall not have base classes.
   if (Class->isUnion()) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82381: [analyzer] Introduce small improvements to the solver infra

2020-06-24 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:467-470
+/// Available representations for the arguments are:
+///   * RangeSet
+///   * Optional
+///   * RangeSet *

Why do we have these representations in the first place?

It sounds like you're treating null pointers / empty optionals equivalently to 
full ranges (i.e., intersecting with them has no effect). How hard would it be 
to simply construct an actual full range in all the places in which we 
currently have empty optionals?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82381



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


[PATCH] D75169: [ARM] Supporting lowering of half-precision FP arguments and returns in AArch32's backend

2020-06-24 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi added inline comments.



Comment at: llvm/lib/Target/ARM/ARMISelLowering.cpp:4106
+unsigned NumParts, MVT PartVT, Optional CC) const {
+  bool IsABIRegCopy = CC.hasValue();
+  EVT ValueVT = Val.getValueType();

I'm not well versed in arm CCs, but I suspect you might want this to check if 
the CC is arm_apcscc, arm_aapcscc, or arm_aapcs_vfpcc instead of checking 
merely if it has a CC. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75169



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


[PATCH] D82425: [SemaCXX] Fix false positive of -Wuninitialized-const-reference in empty function body.

2020-06-24 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

Okay, since checking this is cheap I suppose we can do it.




Comment at: clang/lib/Analysis/UninitializedValues.cpp:410
+  if (FunctionDecl *fd = CE->getDirectCallee()) {
+if (FunctionTemplateDecl *ftd = fd->getPrimaryTemplate())
+  return ftd->getTemplatedDecl()->hasTrivialBody();

Is this special check for templates necessary? Doesn't the 
"fd->hasTrivialBody()" check below also handle the template case?



Comment at: clang/test/SemaCXX/warn-uninitialized-const-reference.cpp:13
+template 
+inline void ignore_template(T const &) {}
+void ignore(const int &i) {}

I think "const T &" would be the more common ordering. Also the "inline" isn't 
really necessary.



Comment at: clang/test/SemaCXX/warn-uninitialized-const-reference.cpp:40
+
+  int l;
+  ignore_template(l);

I would add a comment explaining that this is a pattern to avoid "unused 
variable" warnings, and mention the boost function as an example.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82425



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


[clang] 1b090db - [ARM] Improve diagnostics message when Neon is unsupported

2020-06-24 Thread Victor Campos via cfe-commits

Author: Victor Campos
Date: 2020-06-24T10:20:26+01:00
New Revision: 1b090db0df47f3ebf6acab0316180267e6b96f43

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

LOG: [ARM] Improve diagnostics message when Neon is unsupported

Summary:
Whenever Neon is not supported, a generic message is printed:

  error: "NEON support not enabled"

Followed by a series of other error messages that are not useful once
the first one is printed.

This patch gives a more precise message in the case where Neon is
unsupported because an invalid float ABI was specified: the soft float
ABI.

  error: "NEON intrinsics not available with the soft-float ABI. Please
  use -mfloat-abi=softfp or -mfloat-abi=hard"

This message is the same one that GCC gives, so it is also making their
diagnostics more compatible with each other.

Also, by rearranging preprocessor directives, these "unsupported" error
messages are now the only ones printed out, which is also GCC's
behaviour.

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

Added: 


Modified: 
clang/utils/TableGen/NeonEmitter.cpp

Removed: 




diff  --git a/clang/utils/TableGen/NeonEmitter.cpp 
b/clang/utils/TableGen/NeonEmitter.cpp
index 813a0c8afe8d..d5bf59ef04ad 100644
--- a/clang/utils/TableGen/NeonEmitter.cpp
+++ b/clang/utils/TableGen/NeonEmitter.cpp
@@ -2312,9 +2312,14 @@ void NeonEmitter::run(raw_ostream &OS) {
   OS << "#ifndef __ARM_NEON_H\n";
   OS << "#define __ARM_NEON_H\n\n";
 
+  OS << "#ifndef __ARM_FP\n";
+  OS << "#error \"NEON intrinsics not available with the soft-float ABI. "
+"Please use -mfloat-abi=softfp or -mfloat-abi=hard\"\n";
+  OS << "#else\n\n";
+
   OS << "#if !defined(__ARM_NEON)\n";
   OS << "#error \"NEON support not enabled\"\n";
-  OS << "#endif\n\n";
+  OS << "#else\n\n";
 
   OS << "#include \n\n";
 
@@ -2404,6 +2409,8 @@ void NeonEmitter::run(raw_ostream &OS) {
 
   OS << "\n";
   OS << "#undef __ai\n\n";
+  OS << "#endif /* if !defined(__ARM_NEON) */\n";
+  OS << "#endif /* ifndef __ARM_FP */\n";
   OS << "#endif /* __ARM_NEON_H */\n";
 }
 



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


[clang] 3d6cab2 - [AArch64][SVE] Add bfloat16 support to load intrinsics

2020-06-24 Thread Kerry McLaughlin via cfe-commits

Author: Kerry McLaughlin
Date: 2020-06-24T10:32:19+01:00
New Revision: 3d6cab271c7cecf105b77834d837ccd4406700d7

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

LOG: [AArch64][SVE] Add bfloat16 support to load intrinsics

Summary:
Bfloat16 support added for the following intrinsics:
 - LD1
 - LD1RQ
 - LDNT1
 - LDNF1
 - LDFF1

Reviewers: sdesmalen, c-rhodes, efriedma, stuij, fpetrogalli, david-arm

Reviewed By: fpetrogalli

Subscribers: tschuett, kristof.beyls, hiraditya, rkruppe, psnobl, danielkiss, 
cfe-commits, llvm-commits

Tags: #clang, #llvm

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

Added: 
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1-bfloat.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1rq-bfloat.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldff1-bfloat.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldnf1-bfloat.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldnt1-bfloat.c

Modified: 
clang/include/clang/Basic/arm_sve.td
llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h
llvm/test/CodeGen/AArch64/sve-intrinsics-ld1-addressing-mode-reg-imm.ll
llvm/test/CodeGen/AArch64/sve-intrinsics-ld1-addressing-mode-reg-reg.ll
llvm/test/CodeGen/AArch64/sve-intrinsics-ld1.ll
llvm/test/CodeGen/AArch64/sve-intrinsics-loads-ff.ll
llvm/test/CodeGen/AArch64/sve-intrinsics-loads-nf.ll
llvm/test/CodeGen/AArch64/sve-intrinsics-loads.ll
llvm/test/CodeGen/AArch64/sve-masked-ldst-nonext.ll

Removed: 




diff  --git a/clang/include/clang/Basic/arm_sve.td 
b/clang/include/clang/Basic/arm_sve.td
index c55af44bc5ad..091c9e230b51 100644
--- a/clang/include/clang/Basic/arm_sve.td
+++ b/clang/include/clang/Basic/arm_sve.td
@@ -271,6 +271,11 @@ def SVLD1UH : MInst<"svld1uh_{d}", "dPX", "ilUiUl",
  [IsLoad, IsZExtRetu
 def SVLD1SW : MInst<"svld1sw_{d}", "dPU", "lUl", [IsLoad], 
  MemEltTyInt32,   "aarch64_sve_ld1">;
 def SVLD1UW : MInst<"svld1uw_{d}", "dPY", "lUl", [IsLoad, 
IsZExtReturn], MemEltTyInt32,   "aarch64_sve_ld1">;
 
+let ArchGuard = "defined(__ARM_FEATURE_SVE_BF16)" in {
+  def SVLD1_BF  : MInst<"svld1[_{2}]",  "dPc",  "b", [IsLoad], 
MemEltTyDefault, "aarch64_sve_ld1">;
+  def SVLD1_VNUM_BF : MInst<"svld1_vnum[_{2}]", "dPcl", "b", [IsLoad], 
MemEltTyDefault, "aarch64_sve_ld1">;
+}
+
 // Load one vector (scalar base, VL displacement)
 def SVLD1_VNUM   : MInst<"svld1_vnum[_{2}]", "dPcl", "csilUcUsUiUlhfd", 
[IsLoad],   MemEltTyDefault, "aarch64_sve_ld1">;
 def SVLD1SB_VNUM : MInst<"svld1sb_vnum_{d}", "dPSl", "silUsUiUl",   
[IsLoad],   MemEltTyInt8,"aarch64_sve_ld1">;
@@ -376,6 +381,11 @@ def SVLDFF1UH_VNUM : MInst<"svldff1uh_vnum_{d}", "dPXl", 
"ilUiUl",  [IsL
 def SVLDFF1SW_VNUM : MInst<"svldff1sw_vnum_{d}", "dPUl", "lUl", 
[IsLoad],   MemEltTyInt32,   "aarch64_sve_ldff1">;
 def SVLDFF1UW_VNUM : MInst<"svldff1uw_vnum_{d}", "dPYl", "lUl", 
[IsLoad, IsZExtReturn], MemEltTyInt32,   "aarch64_sve_ldff1">;
 
+let ArchGuard = "defined(__ARM_FEATURE_SVE_BF16)" in {
+  def SVLDFF1_BF  : MInst<"svldff1[_{2}]",  "dPc",  "b", [IsLoad], 
MemEltTyDefault, "aarch64_sve_ldff1">;
+  def SVLDFF1_VNUM_BF : MInst<"svldff1_vnum[_{2}]", "dPcl", "b", [IsLoad], 
MemEltTyDefault, "aarch64_sve_ldff1">;
+}
+
 // First-faulting load one vector (vector base)
 def SVLDFF1_GATHER_BASES_U   : MInst<"svldff1_gather[_{2}base]_{d}",   "dPu", 
"ilUiUlfd", [IsGatherLoad],   MemEltTyDefault, 
"aarch64_sve_ldff1_gather_scalar_offset">;
 def SVLDFF1SB_GATHER_BASES_U : MInst<"svldff1sb_gather[_{2}base]_{d}", "dPu", 
"ilUiUl",   [IsGatherLoad],   MemEltTyInt8,
"aarch64_sve_ldff1_gather_scalar_offset">;
@@ -471,15 +481,29 @@ def SVLDNF1UH_VNUM : MInst<"svldnf1uh_vnum_{d}", "dPXl", 
"ilUiUl",  [IsL
 def SVLDNF1SW_VNUM : MInst<"svldnf1sw_vnum_{d}", "dPUl", "lUl", 
[IsLoad],   MemEltTyInt32,   "aarch64_sve_ldnf1">;
 def SVLDNF1UW_VNUM : MInst<"svldnf1uw_vnum_{d}", "dPYl", "lUl", 
[IsLoad, IsZExtReturn], MemEltTyInt32,   "aarch64_sve_ldnf1">;
 
+let ArchGuard = "defined(__ARM_FEATURE_SVE_BF16)" in {
+  def SVLDNF1_BF  : MInst<"svldnf1[_{2}]",  "dPc",  "b", [IsLoad], 
MemEltTyDefault, "aarch64_sve_ldnf1">;
+  def SVLDNF1_VNUM_BF : MInst<"svldnf1_vnum[_{2}]", "dPcl", "b", [IsLoad], 
MemEltTyDefault, "aarch64_sve_ldnf1">;
+}
+
 // Load one vector, unextended load, non-temporal (scalar base)
 def SVLDNT1 : MInst<"svldnt1[_{2}]", "dPc", "csilUcUsUiUlhfd", [IsLoad], 
MemEltTyDefault, "aarch64_sve_ldnt1">;
 
 // Load one vector, unextended load, non-temporal (scalar base, VL 
displ

[PATCH] D82298: [AArch64][SVE] Add bfloat16 support to load intrinsics

2020-06-24 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen accepted this revision.
sdesmalen added a comment.

LGTM




Comment at: clang/include/clang/Basic/arm_sve.td:275
+let ArchGuard = "defined(__ARM_FEATURE_SVE_BF16)" in {
+  def SVLD1_BF  : MInst<"svld1[_{2}]",  "dPc",  "b", [IsLoad], 
MemEltTyDefault, "aarch64_sve_ld1">;
+  def SVLD1_VNUM_BF : MInst<"svld1_vnum[_{2}]", "dPcl", "b", [IsLoad], 
MemEltTyDefault, "aarch64_sve_ld1">;

micro nit: doesn't match column indentation of the code around it.


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

https://reviews.llvm.org/D82298



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


[PATCH] D82288: [analyzer][StdLibraryFunctionsChecker] Add POSIX file handling functions

2020-06-24 Thread Endre Fülöp via Phabricator via cfe-commits
gamesh411 added a comment.

Good job, I really fancy the Summary syntax 👍




Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:740
   // we have a TypedefDecl with the name 'FILE'.
-  for (Decl *D : LookupRes) {
+  for (Decl *D : LookupRes)
 if (auto *TD = dyn_cast(D))

I presume that typically there are only a handful of `Decl`s in LookupRes, so 
it not worth the complexity of using `std::algorithm`s to sort/partition/find.



Comment at: 
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:1591
+
+Optional Off_tMax;
+if (Off_tTy) {

If `Off_tMax` is only used in the if block that follows, consider moving it's 
declaration inside.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82288



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


[PATCH] D75169: [ARM] Supporting lowering of half-precision FP arguments and returns in AArch32's backend

2020-06-24 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi added a comment.

@pratlucas @ostannard @rjmccall

I've posted a diff D82443  to address what I 
think could be a potential fix for the assert I was seeing on the provided 
reduced IR.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75169



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


[PATCH] D82213: [Remarks] Add callsite locations to inline remarks

2020-06-24 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added a comment.

That's interesting. We are also using something similar for the matrix lowering 
remarks [1]: we traverse the inlining chain bottom up and emit a remark at each 
step which contains the expression available at that level. I think those 
approaches could be useful in general to surface remarks at the right level and 
it might be worth moving them somewhere so they can be shared. What do you 
think?

[1] 
https://github.com/llvm/llvm-project/blob/master/llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp#L1783


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82213



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


[PATCH] D81847: [ARM] Improve diagnostics message when Neon is unsupported

2020-06-24 Thread Victor Campos via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1b090db0df47: [ARM] Improve diagnostics message when Neon is 
unsupported (authored by vhscampos).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81847

Files:
  clang/utils/TableGen/NeonEmitter.cpp


Index: clang/utils/TableGen/NeonEmitter.cpp
===
--- clang/utils/TableGen/NeonEmitter.cpp
+++ clang/utils/TableGen/NeonEmitter.cpp
@@ -2312,9 +2312,14 @@
   OS << "#ifndef __ARM_NEON_H\n";
   OS << "#define __ARM_NEON_H\n\n";
 
+  OS << "#ifndef __ARM_FP\n";
+  OS << "#error \"NEON intrinsics not available with the soft-float ABI. "
+"Please use -mfloat-abi=softfp or -mfloat-abi=hard\"\n";
+  OS << "#else\n\n";
+
   OS << "#if !defined(__ARM_NEON)\n";
   OS << "#error \"NEON support not enabled\"\n";
-  OS << "#endif\n\n";
+  OS << "#else\n\n";
 
   OS << "#include \n\n";
 
@@ -2404,6 +2409,8 @@
 
   OS << "\n";
   OS << "#undef __ai\n\n";
+  OS << "#endif /* if !defined(__ARM_NEON) */\n";
+  OS << "#endif /* ifndef __ARM_FP */\n";
   OS << "#endif /* __ARM_NEON_H */\n";
 }
 


Index: clang/utils/TableGen/NeonEmitter.cpp
===
--- clang/utils/TableGen/NeonEmitter.cpp
+++ clang/utils/TableGen/NeonEmitter.cpp
@@ -2312,9 +2312,14 @@
   OS << "#ifndef __ARM_NEON_H\n";
   OS << "#define __ARM_NEON_H\n\n";
 
+  OS << "#ifndef __ARM_FP\n";
+  OS << "#error \"NEON intrinsics not available with the soft-float ABI. "
+"Please use -mfloat-abi=softfp or -mfloat-abi=hard\"\n";
+  OS << "#else\n\n";
+
   OS << "#if !defined(__ARM_NEON)\n";
   OS << "#error \"NEON support not enabled\"\n";
-  OS << "#endif\n\n";
+  OS << "#else\n\n";
 
   OS << "#include \n\n";
 
@@ -2404,6 +2409,8 @@
 
   OS << "\n";
   OS << "#undef __ai\n\n";
+  OS << "#endif /* if !defined(__ARM_NEON) */\n";
+  OS << "#endif /* ifndef __ARM_FP */\n";
   OS << "#endif /* __ARM_NEON_H */\n";
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82298: [AArch64][SVE] Add bfloat16 support to load intrinsics

2020-06-24 Thread Kerry McLaughlin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3d6cab271c7c: [AArch64][SVE] Add bfloat16 support to load 
intrinsics (authored by kmclaughlin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82298

Files:
  clang/include/clang/Basic/arm_sve.td
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1rq-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldff1-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldnf1-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldnt1-bfloat.c
  llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
  llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h
  llvm/test/CodeGen/AArch64/sve-intrinsics-ld1-addressing-mode-reg-imm.ll
  llvm/test/CodeGen/AArch64/sve-intrinsics-ld1-addressing-mode-reg-reg.ll
  llvm/test/CodeGen/AArch64/sve-intrinsics-ld1.ll
  llvm/test/CodeGen/AArch64/sve-intrinsics-loads-ff.ll
  llvm/test/CodeGen/AArch64/sve-intrinsics-loads-nf.ll
  llvm/test/CodeGen/AArch64/sve-intrinsics-loads.ll
  llvm/test/CodeGen/AArch64/sve-masked-ldst-nonext.ll

Index: llvm/test/CodeGen/AArch64/sve-masked-ldst-nonext.ll
===
--- llvm/test/CodeGen/AArch64/sve-masked-ldst-nonext.ll
+++ llvm/test/CodeGen/AArch64/sve-masked-ldst-nonext.ll
@@ -87,6 +87,14 @@
   ret  %load
 }
 
+define  @masked_load_nxv8bf16( *%a,  %mask) nounwind {
+; CHECK-LABEL: masked_load_nxv8bf16:
+; CHECK-NEXT: ld1h { z0.h }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.masked.load.nxv8bf16( *%a, i32 2,  %mask,  undef)
+  ret  %load
+}
+
 ;
 ; Masked Stores
 ;
@@ -182,6 +190,7 @@
 declare  @llvm.masked.load.nxv4f32(*, i32, , )
 declare  @llvm.masked.load.nxv4f16(*, i32, , )
 declare  @llvm.masked.load.nxv8f16(*, i32, , )
+declare  @llvm.masked.load.nxv8bf16(*, i32, , )
 
 declare void @llvm.masked.store.nxv2i64(, *, i32, )
 declare void @llvm.masked.store.nxv4i32(, *, i32, )
Index: llvm/test/CodeGen/AArch64/sve-intrinsics-loads.ll
===
--- llvm/test/CodeGen/AArch64/sve-intrinsics-loads.ll
+++ llvm/test/CodeGen/AArch64/sve-intrinsics-loads.ll
@@ -97,6 +97,23 @@
   ret  %res
 }
 
+define  @ld1rqh_bf16( %pred, bfloat* %addr) {
+; CHECK-LABEL: ld1rqh_bf16:
+; CHECK: ld1rqh { z0.h }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %res = call  @llvm.aarch64.sve.ld1rq.nxv8bf16( %pred, bfloat* %addr)
+  ret  %res
+}
+
+define  @ld1rqh_bf16_imm( %pred, bfloat* %addr) {
+; CHECK-LABEL: ld1rqh_bf16_imm:
+; CHECK: ld1rqh { z0.h }, p0/z, [x0, #-16]
+; CHECK-NEXT: ret
+  %ptr = getelementptr inbounds bfloat, bfloat* %addr, i16 -8
+  %res = call  @llvm.aarch64.sve.ld1rq.nxv8bf16( %pred, bfloat* %ptr)
+  ret  %res
+}
+
 ;
 ; LD1RQW
 ;
@@ -208,6 +225,15 @@
   ret  %res
 }
 
+define  @ldnt1h_bf16( %pred, bfloat* %addr) {
+; CHECK-LABEL: ldnt1h_bf16:
+; CHECK: ldnt1h { z0.h }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %res = call  @llvm.aarch64.sve.ldnt1.nxv8bf16( %pred,
+ bfloat* %addr)
+  ret  %res
+}
+
 ;
 ; LDNT1W
 ;
@@ -498,6 +524,7 @@
 declare  @llvm.aarch64.sve.ld1rq.nxv4i32(, i32*)
 declare  @llvm.aarch64.sve.ld1rq.nxv2i64(, i64*)
 declare  @llvm.aarch64.sve.ld1rq.nxv8f16(, half*)
+declare  @llvm.aarch64.sve.ld1rq.nxv8bf16(, bfloat*)
 declare  @llvm.aarch64.sve.ld1rq.nxv4f32(, float*)
 declare  @llvm.aarch64.sve.ld1rq.nxv2f64(, double*)
 
@@ -506,6 +533,7 @@
 declare  @llvm.aarch64.sve.ldnt1.nxv4i32(, i32*)
 declare  @llvm.aarch64.sve.ldnt1.nxv2i64(, i64*)
 declare  @llvm.aarch64.sve.ldnt1.nxv8f16(, half*)
+declare  @llvm.aarch64.sve.ldnt1.nxv8bf16(, bfloat*)
 declare  @llvm.aarch64.sve.ldnt1.nxv4f32(, float*)
 declare  @llvm.aarch64.sve.ldnt1.nxv2f64(, double*)
 
Index: llvm/test/CodeGen/AArch64/sve-intrinsics-loads-nf.ll
===
--- llvm/test/CodeGen/AArch64/sve-intrinsics-loads-nf.ll
+++ llvm/test/CodeGen/AArch64/sve-intrinsics-loads-nf.ll
@@ -140,6 +140,14 @@
   ret  %load
 }
 
+define  @ldnf1h_bf16( %pg, bfloat* %a) {
+; CHECK-LABEL: ldnf1h_bf16:
+; CHECK: ldnf1h { z0.h }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv8bf16( %pg, bfloat* %a)
+  ret  %load
+}
+
 define  @ldnf1h_f16_inbound( %pg, half* %a) {
 ; CHECK-LABEL: ldnf1h_f16_inbound:
 ; CHECK: ldnf1h { z0.h }, p0/z, [x0, #1, mul vl]
@@ -151,6 +159,17 @@
   ret  %load
 }
 
+define  @ldnf1h_bf16_inbound( %pg, bfloat* %a) {
+; CHECK-LABEL: ldnf1h_bf16_inbound:
+; CHECK: ldnf1h { z0.h }, p0/z, [x0, #1, mul vl]
+; CHECK-NEXT: ret
+  %base_scalable = bitcast bfloat* %a to *
+  %base = getelementptr , * %base_scalable, i64 1
+  %base_scalar = bitcast * %base to bfloat*
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv8bf16( %pg, bfloat* %base_scalar)
+  ret  %load
+}
+
 define  @ldnf1b_

[PATCH] D82199: [clang-format] restore indent in conditionals when AlignOperands is DontAlign

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

This may not be the right long-term solution, but the current behavior is 
pretty broken and this is cheap.




Comment at: clang/unittests/Format/FormatTest.cpp:6287
+  Style.BreakBeforeTernaryOperators = false;
+  verifyFormat("int x = aaa ? aa :\n"
+   "? cc :\n"

aligning the question marks here is a bit weird (given DontAlign) but that's 
another patch.

If we disable the question-column behavior with dontalign, this patch will be 
completely dead, right?
May want to add a FIXME to remove in that case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82199



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


[PATCH] D81456: [clangd] Get rid of WantDiagnostics::Yes

2020-06-24 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

ping :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81456



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


[PATCH] D82318: Add `FloatingLiteral` to SyntaxTree

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



Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:1239-1242
+1e-2;
+2.;
+.2;
+2.f;

Indent -2.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82318



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


[PATCH] D82310: Add `BoolLiteralExpression` to SyntaxTree

2020-06-24 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 accepted this revision.
gribozavr2 marked an inline comment as done.
gribozavr2 added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:1240
+  true;
+  false;
+}

eduucaldas wrote:
> gribozavr2 wrote:
> > C99 has bool literals, but the program should include stdbool.h.
> > 
> > I feel like it is better to make the predicate something like 
> > "hasBoolType()" and change the test to include stdbool.h.
> [[ https://clang.llvm.org/doxygen/stdbool_8h_source.html | stdbool ]] 
> consists on macro definitions, mapping booleans to integers. `true` is 
> preprocessed into 1 and `false` to 0 .
> I don't  think there is a reasonable way of getting the proper SyntaxTree 
> from that macro expansion
> 
> Additional problem, we don't have the test infrastructure for includes, AFAIK 
> ^^
> 
> Finally, regarding the predicates, I prefer if they relate to languages, 
> otherwise we might create many predicates that test for exactly the same 
> thing, e.g. we would have `hasBoolType()` and `hasNullPtr()` that ultimately 
> do the same thing, test if Language is not C 
> true is preprocessed into 1 and false to 0 .

I see -- yes, that would make a completely different syntax tree.

> Finally, regarding the predicates, I prefer if they relate to languages, 
> otherwise we might create many predicates that test for exactly the same thing

Generally, testing for features instead of product versions is considered 
better, as that leads to more future-proof code (for example, we learned this 
lesson again in the area of web extensions and standards). In future, Clang can 
start supporting a language feature in other language modes as an extension 
(for example, supporting `_Atomic` in C++ is already a thing), or the language 
standard itself can decide to incorporate the feature (for example, C 2035 
could adopt the `nullptr` keyword). It is highly unlikely for complex features 
like templates, but may reasonably happen for simpler features.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82310



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


[PATCH] D82385: [Analyzer] Fix errors in iterator modeling

2020-06-24 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 272950.
baloghadamsoftware edited the summary of this revision.
baloghadamsoftware added a comment.

Updated according to the comments.


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

https://reviews.llvm.org/D82385

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

Index: clang/test/Analysis/iterator-modeling.cpp
===
--- clang/test/Analysis/iterator-modeling.cpp
+++ clang/test/Analysis/iterator-modeling.cpp
@@ -1,12 +1,12 @@
-// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,debug.DebugIteratorModeling,debug.ExprInspection -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=false %s -verify
+// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,debug.DebugIteratorModeling,debug.ExprInspection -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=false %s -verify -analyzer-config display-checker-name=false
 
-// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,debug.DebugIteratorModeling,debug.ExprInspection -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=true -DINLINE=1 %s -verify
+// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,debug.DebugIteratorModeling,debug.ExprInspection -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=true -DINLINE=1 %s -verify -analyzer-config display-checker-name=false
 
-// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,debug.DebugIteratorModeling,debug.ExprInspection -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=true -DINLINE=1 -DSTD_ADVANCE_INLINE_LEVEL=0 %s -verify
+// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,debug.DebugIteratorModeling,debug.ExprInspection -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=true -DINLINE=1 -DSTD_ADVANCE_INLINE_LEVEL=0 %s -verify -analyzer-config display-checker-name=false
 
-// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,debug.DebugIteratorModeling,debug.ExprInspection -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=true -DINLINE=1 -DSTD_ADVANCE_INLINE_LEVEL=1 %s -verify
+// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,debug.DebugIteratorModeling,debug.ExprInspection -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=true -DINLINE=1 -DSTD_ADVANCE_INLINE_LEVEL=1 %s -verify -analyzer-config display-checker-name=false
 
-// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,debug.DebugIteratorModeling,debug.ExprInspection -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=true -DINLINE=1 -DSTD_ADVANCE_INLINE_LEVEL=2 %s -verify
+// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,debug.DebugIteratorModeling,debug.ExprInspection -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=true -DINLINE=1 -DSTD_ADVANCE_INLINE_LEVEL=2 %s -verify -analyzer-config display-checker-name=false
 
 // RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorModeling,debug.ExprInspection -analyzer-config aggressive-binary-operation-simplification=true %s 2>&1 | FileCheck %s
 
@@ -33,7 +33,7 @@
 
   clang_analyzer_eval(clang_analyzer_iterator_container(i) == &v); // expected-warning{{TRUE}}
   clang_analyzer_denote(clang_analyzer_container_begin(v), "$v.begin()");
-  clang_analyzer_express(clang_analyzer_iterator_position(i)); //expected-warning{{$v.begin()}}
+  clang_analyzer_express(clang_analyzer_iterator_position(i)); // expected-warning-re {{$v.begin(){{$
 
   if (i != v.begin()) {
 clang_analyzer_warnIfReached();
@@ -45,7 +45,7 @@
 
   clang_analyzer_eval(clang_analyzer_iterator_container(i) == &v); // expected-warning{{TRUE}}
   clang_analyzer_denote(clang_analyzer_container_end(v), "$v.end()");
-  clang_analyzer_express(clang_analyzer_iterator_position(i)); //expected-warning{{$v.end()}}
+  clang_analyzer_express(clang_analyzer_iterator_position(i)); // expected-warning-re {{$v.end(){{$
 
   if (i != v.end()) {
 clang_analyzer_warnIfReached();
@@ -59,8 +59,8 @@
 
   auto j = ++i;
 
-  clang_analyzer_express(clang_analyzer_iterator_position(i)); //expected-warning{{$v.begin() + 1}}
-  clang_analyzer_express(clang_analyzer_iterator_position(j)); //expected-warning{{$v.begin() + 1}}
+  clang_analyzer_express(clang_analyzer_iterator_position(i)); // expected-warning-re {{$v.begin(

[PATCH] D80301: [yaml][clang-tidy] Fix multiline YAML serialization

2020-06-24 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin updated this revision to Diff 272952.
DmitryPolukhin added a comment.

Use double quotation for multiline strings. It solves problems with internal 
newlines because now they are escaped. Also double quotation solves the problem 
with leading whitespace after newline. In case of single quotation YAML parsers 
should remove leading whitespace according to specification. In case of double 
quotation these leading are internal space and they are preserved. There is no 
way to instruct YAML parsers to preserve leading whitespaces after newline so 
double quotation is the only viable option that solves all problems at once.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80301

Files:
  clang/include/clang/Tooling/ReplacementsYaml.h
  clang/unittests/Tooling/ReplacementsYamlTest.cpp
  llvm/include/llvm/Support/YAMLTraits.h
  llvm/lib/Support/YAMLTraits.cpp
  llvm/unittests/Support/YAMLIOTest.cpp

Index: llvm/unittests/Support/YAMLIOTest.cpp
===
--- llvm/unittests/Support/YAMLIOTest.cpp
+++ llvm/unittests/Support/YAMLIOTest.cpp
@@ -285,10 +285,8 @@
 YOut << Original;
   }
   auto Expected = "---\n"
-  "str1:'a multiline string\n"
-  "foobarbaz'\n"
-  "str2:'another one\r"
-  "foobarbaz'\n"
+  "str1:\"a multiline string\\nfoobarbaz\"\n"
+  "str2:\"another one\\rfoobarbaz\"\n"
   "str3:a one-line string\n"
   "...\n";
   ASSERT_EQ(Serialized, Expected);
Index: llvm/lib/Support/YAMLTraits.cpp
===
--- llvm/lib/Support/YAMLTraits.cpp
+++ llvm/lib/Support/YAMLTraits.cpp
@@ -878,12 +878,12 @@
 }
 
 void ScalarTraits::output(const std::string &Val, void *,
- raw_ostream &Out) {
+   raw_ostream &Out) {
   Out << Val;
 }
 
 StringRef ScalarTraits::input(StringRef Scalar, void *,
- std::string &Val) {
+   std::string &Val) {
   Val = Scalar.str();
   return StringRef();
 }
Index: llvm/include/llvm/Support/YAMLTraits.h
===
--- llvm/include/llvm/Support/YAMLTraits.h
+++ llvm/include/llvm/Support/YAMLTraits.h
@@ -649,24 +649,25 @@
 inline QuotingType needsQuotes(StringRef S) {
   if (S.empty())
 return QuotingType::Single;
+
+  QuotingType MaxQuotingNeeded = QuotingType::None;
   if (isSpace(static_cast(S.front())) ||
   isSpace(static_cast(S.back(
-return QuotingType::Single;
+MaxQuotingNeeded = QuotingType::Single;
   if (isNull(S))
-return QuotingType::Single;
+MaxQuotingNeeded = QuotingType::Single;
   if (isBool(S))
-return QuotingType::Single;
+MaxQuotingNeeded = QuotingType::Single;
   if (isNumeric(S))
-return QuotingType::Single;
+MaxQuotingNeeded = QuotingType::Single;
 
   // 7.3.3 Plain Style
   // Plain scalars must not begin with most indicators, as this would cause
   // ambiguity with other YAML constructs.
   static constexpr char Indicators[] = R"(-?:\,[]{}#&*!|>'"%@`)";
   if (S.find_first_of(Indicators) == 0)
-return QuotingType::Single;
+MaxQuotingNeeded = QuotingType::Single;
 
-  QuotingType MaxQuotingNeeded = QuotingType::None;
   for (unsigned char C : S) {
 // Alphanum is safe.
 if (isAlnum(C))
@@ -684,11 +685,11 @@
 case 0x9:
   continue;
 // LF(0xA) and CR(0xD) may delimit values and so require at least single
-// quotes.
+// quotes. LLVM YAML parser cannot handle single quoted multiline so use
+// double quoting to produce valid YAML.
 case 0xA:
 case 0xD:
-  MaxQuotingNeeded = QuotingType::Single;
-  continue;
+  return QuotingType::Double;
 // DEL (0x7F) are excluded from the allowed character range.
 case 0x7F:
   return QuotingType::Double;
Index: clang/unittests/Tooling/ReplacementsYamlTest.cpp
===
--- clang/unittests/Tooling/ReplacementsYamlTest.cpp
+++ clang/unittests/Tooling/ReplacementsYamlTest.cpp
@@ -65,7 +65,7 @@
"  - FilePath:'/path/to/file1.h'\n"
"Offset:  0\n"
"Length:  0\n"
-   "ReplacementText: '#include \n\n'\n"
+   "ReplacementText: \"#include \\n\"\n"
"...\n",
YamlContentStream.str().c_str());
 }
Index: clang/include/clang/Tooling/ReplacementsYaml.h
===
--- clang/include/clang/Tooling/ReplacementsYaml.h
+++ clang/include/clang/Tooling/ReplacementsYaml.h
@@ -35,13 +35,7 @@
 

[PATCH] D82182: [AArch64][SVE] Add bfloat16 support to perm and select intrinsics

2020-06-24 Thread Cullen Rhodes via Phabricator via cfe-commits
c-rhodes added inline comments.



Comment at: clang/include/clang/Basic/arm_sve.td:1115
 
+let ArchGuard = "defined(__ARM_FEATURE_SVE_BF16)" in {
+def SVREV_BF16: SInst<"svrev[_{d}]","dd",   "b", MergeNone, 
"aarch64_sve_rev">;

fpetrogalli wrote:
> c-rhodes wrote:
> > c-rhodes wrote:
> > > fpetrogalli wrote:
> > > > nit: could create a multiclass here like @sdesmalen have done in 
> > > > https://reviews.llvm.org/D82187, seems quite a nice way to keep the 
> > > > definition of the intrinsics together (look for `multiclass 
> > > > StructLoad`, for example)
> > > it might be a bit tedious having separate multiclasses, what do you think 
> > > about:
> > > ```multiclass SInstBF16 > > string i = "",
> > >  list ft = [], list ch = []> {
> > >   def : SInst;
> > >   let ArchGuard = "defined(__ARM_FEATURE_SVE_BF16)" in {
> > > def : SInst;
> > >   }
> > > }
> > > 
> > > defm SVREV: SInstBF16<"svrev[_{d}]","dd",   "csilUcUsUiUlhfd", 
> > > MergeNone, "aarch64_sve_rev">;
> > > defm SVSEL: SInstBF16<"svsel[_{d}]","dPdd", "csilUcUsUiUlhfd", 
> > > MergeNone, "aarch64_sve_sel">;
> > > defm SVSPLICE : SInstBF16<"svsplice[_{d}]", "dPdd", "csilUcUsUiUlhfd", 
> > > MergeNone, "aarch64_sve_splice">;
> > > defm SVTRN1   : SInstBF16<"svtrn1[_{d}]",   "ddd",  "csilUcUsUiUlhfd", 
> > > MergeNone, "aarch64_sve_trn1">;
> > > defm SVTRN2   : SInstBF16<"svtrn2[_{d}]",   "ddd",  "csilUcUsUiUlhfd", 
> > > MergeNone, "aarch64_sve_trn2">;
> > > defm SVUZP1   : SInstBF16<"svuzp1[_{d}]",   "ddd",  "csilUcUsUiUlhfd", 
> > > MergeNone, "aarch64_sve_uzp1">;
> > > defm SVUZP2   : SInstBF16<"svuzp2[_{d}]",   "ddd",  "csilUcUsUiUlhfd", 
> > > MergeNone, "aarch64_sve_uzp2">;
> > > defm SVZIP1   : SInstBF16<"svzip1[_{d}]",   "ddd",  "csilUcUsUiUlhfd", 
> > > MergeNone, "aarch64_sve_zip1">;
> > > defm SVZIP2   : SInstBF16<"svzip2[_{d}]",   "ddd",  "csilUcUsUiUlhfd", 
> > > MergeNone, "aarch64_sve_zip2">;```
> > > 
> > > ?
> > I've played around with this and it works great for instructions guarded on 
> > a single feature flag but falls apart for the .Q forms that also require 
> > `__ARM_FEATURE_SVE_MATMUL_FP64`. I suspect there's a nice way of handling 
> > it in tablegen by passing the features as a list of strings and joining 
> > them but I spent long enough trying to get that to work so I'm going to 
> > keep it simple for now.
> > it might be a bit tedious having separate multiclasses, what do you think 
> > about:
> 
> Sorry I think I misunderstood you when we last discussed this. I didn't mean 
> to write a multiclass that would work for ALL intrinsics that uses regular 
> types and bfloats I just meant to merge together those who were using the 
> same archguard and that you are adding in this patch.
> 
> I think you could keep both macros in a single ArchGuard string:
> 
> ```
> multiclass SInstPerm {
>   def : SInst;
>   let ArchGuard = "defined(__ARM_FEATURE_SVE_BF16)" in {
> def : SInst;
>   }
> }
> 
> defm SVREV: SInstPerm<"svrev[_{d}]","dd",MergeNone, 
> "aarch64_sve_rev">;
> ...
> 
> multiclass SInstPermMatmul {
>   def : SInst;
>   let ArchGuard = "defined(__ARM_FEATURE_SVE_BF16) && 
> defined(__ARM_FEATURE_SVE_MATMUL_FP64)" in {
> def : SInst;
>   }
> }
> 
> def SVTRN1Q : SInstPermMatmul ...
> ...
> ```
Sure, I understood you meant separate multiclasses for each intrinsic / group 
similar to what Sander implemented for structured loads / stores but I thought 
it would be quite abit of extra code to implement that, hence why I proposed a 
single multiclass that could handle this. I've experimented with the 
`SInstBF16` multiclass I mentioned above and have it working with an extra arg 
for arch features. I'll create a follow up patch and if people are happy with 
it we'll move forward with that, otherwise I'm happy to implement your 
suggestion.


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

https://reviews.llvm.org/D82182



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


[PATCH] D82445: [analyzer][solver] Track symbol equivalence

2020-06-24 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko created this revision.
vsavchenko added reviewers: NoQ, dcoughlin, ASDenysPetrov, xazax.hun, Szelethus.
Herald added subscribers: cfe-commits, martong, Charusso, dkrupp, donat.nagy, 
mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware.
Herald added a project: clang.
vsavchenko added a parent revision: D82381: [analyzer] Introduce small 
improvements to the solver infra.

For the most cases, we try to reason about symbol either based on the
information we know about that symbol in particular or about its
composite parts.  This is faster and eliminates costly brute force
searches through existing constraints.

However, we do want to support some cases that are widespread enough
and involve reasoning about different existing constraints at once.
These include:

- resoning about 'a - b' based on what we know about 'b - a'
- reasoning about 'a <= b' based on what we know about 'a > b' or 'a < b'

This commit expands on that part by tracking symbols known to be equal
while still avoiding brute force searches.  It changes the way we track
constraints for individual symbols.  If we know for a fact that 'a == b'
then there is no need in tracking constraints for both 'a' and 'b' especially
if these constraints are different.  This additional relationship makes
dead/live logic for constraints harder as we want to maintain as much
information on the equivalence class as possible, but we still won't
carry the information that we don't need anymore.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82445

Files:
  clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
  
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/lib/StaticAnalyzer/Core/RangedConstraintManager.cpp
  clang/test/Analysis/equality_tracking.c

Index: clang/test/Analysis/equality_tracking.c
===
--- /dev/null
+++ clang/test/Analysis/equality_tracking.c
@@ -0,0 +1,132 @@
+// RUN: %clang_analyze_cc1 -verify %s \
+// RUN:   -analyzer-checker=core,debug.ExprInspection \
+// RUN:   -analyzer-config eagerly-assume=false
+
+#define NULL (void *)0
+
+#define UCHAR_MAX (unsigned char)(~0U)
+#define CHAR_MAX (char)(UCHAR_MAX & (UCHAR_MAX >> 1))
+#define CHAR_MIN (char)(UCHAR_MAX & ~(UCHAR_MAX >> 1))
+
+void clang_analyzer_eval(int);
+
+int getInt();
+
+void zeroImpliesEquality(int a, int b) {
+  clang_analyzer_eval((a - b) == 0); // expected-warning{{UNKNOWN}}
+  if ((a - b) == 0) {
+clang_analyzer_eval(b != a);// expected-warning{{FALSE}}
+clang_analyzer_eval(b == a);// expected-warning{{TRUE}}
+clang_analyzer_eval(!(a != b)); // expected-warning{{TRUE}}
+clang_analyzer_eval(!(b == a)); // expected-warning{{FALSE}}
+return;
+  }
+  clang_analyzer_eval((a - b) == 0); // expected-warning{{FALSE}}
+  // FIXME: we should track disequality information as well
+  clang_analyzer_eval(b == a); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(b != a); // expected-warning{{UNKNOWN}}
+}
+
+void zeroImpliesReversedEqual(int a, int b) {
+  clang_analyzer_eval((b - a) == 0); // expected-warning{{UNKNOWN}}
+  if ((b - a) == 0) {
+clang_analyzer_eval(b != a); // expected-warning{{FALSE}}
+clang_analyzer_eval(b == a); // expected-warning{{TRUE}}
+return;
+  }
+  clang_analyzer_eval((b - a) == 0); // expected-warning{{FALSE}}
+  // FIXME: we should track disequality information as well
+  clang_analyzer_eval(b == a); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(b != a); // expected-warning{{UNKNOWN}}
+}
+
+void canonicalEqual(int a, int b) {
+  clang_analyzer_eval(a == b); // expected-warning{{UNKNOWN}}
+  if (a == b) {
+clang_analyzer_eval(b == a); // expected-warning{{TRUE}}
+return;
+  }
+  clang_analyzer_eval(a == b); // expected-warning{{FALSE}}
+  clang_analyzer_eval(b == a); // expected-warning{{FALSE}}
+}
+
+void test(int a, int b, int c, int d) {
+  if (a == b && c == d) {
+if (a == 0 && b == d) {
+  clang_analyzer_eval(c == 0); // expected-warning{{TRUE}}
+}
+c = 10;
+if (b == d) {
+  clang_analyzer_eval(c == 10); // expected-warning{{TRUE}}
+  clang_analyzer_eval(d == 10); // expected-warning{{UNKNOWN}}
+// expected-warning@-1{{FALSE}}
+  clang_analyzer_eval(b == a);  // expected-warning{{TRUE}}
+  clang_analyzer_eval(a == d);  // expected-warning{{TRUE}}
+
+  b = getInt();
+  clang_analyzer_eval(a == d); // expected-warning{{TRUE}}
+  clang_analyzer_eval(a == b); // expected-warning{{UNKNOWN}}
+}
+  }
+
+  if (a != b && b == c) {
+if (c == 42) {
+  clang_analyzer_eval(b == 42); // expected-warning{{TRUE}}
+  // FIXME: we should track disequality information as well
+  clang_analyzer_eval(a != 42); // expected-warning{{UNKNOWN}}
+   

[clang] fd2c4b8 - [AArch64][SVE] Add bfloat16 support to svlen intrinsic

2020-06-24 Thread Cullen Rhodes via cfe-commits

Author: Cullen Rhodes
Date: 2020-06-24T10:05:51Z
New Revision: fd2c4b8999322031b6cd555007ca69fd83270958

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

LOG: [AArch64][SVE] Add bfloat16 support to svlen intrinsic

Reviewed By: fpetrogalli

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

Added: 
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_len-bfloat.c

Modified: 
clang/include/clang/Basic/arm_sve.td
clang/lib/CodeGen/CGBuiltin.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/arm_sve.td 
b/clang/include/clang/Basic/arm_sve.td
index b6bedac08bc6..eccbb6f3f771 100644
--- a/clang/include/clang/Basic/arm_sve.td
+++ b/clang/include/clang/Basic/arm_sve.td
@@ -1281,6 +1281,10 @@ def SVCNTD : SInst<"svcntd", "n", "", MergeNone, 
"aarch64_sve_cntd", [IsAppendSV
 def SVCNTP : SInst<"svcntp_{d}",  "nPP", "PcPsPiPl",MergeNone, 
"aarch64_sve_cntp">;
 def SVLEN  : SInst<"svlen[_{d}]", "nd",  "csilUcUsUiUlhfd", MergeNone>;
 
+let ArchGuard = "defined(__ARM_FEATURE_SVE_BF16)" in {
+def SVLEN_BF16 : SInst<"svlen[_{d}]", "nd", "b", MergeNone>;
+}
+
 

 // Saturating scalar arithmetic
 

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 69c53527f9ec..9526e46c9c6a 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -8434,6 +8434,7 @@ Value 
*CodeGenFunction::EmitAArch64SVEBuiltinExpr(unsigned BuiltinID,
   case SVE::BI__builtin_sve_svpfalse_b:
 return ConstantInt::getFalse(Ty);
 
+  case SVE::BI__builtin_sve_svlen_bf16:
   case SVE::BI__builtin_sve_svlen_f16:
   case SVE::BI__builtin_sve_svlen_f32:
   case SVE::BI__builtin_sve_svlen_f64:

diff  --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_len-bfloat.c 
b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_len-bfloat.c
new file mode 100644
index ..d636e7a824e6
--- /dev/null
+++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_len-bfloat.c
@@ -0,0 +1,27 @@
+// REQUIRES: aarch64-registered-target
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC 
-D__ARM_FEATURE_SVE_BF16 -triple aarch64-none-linux-gnu -target-feature +sve 
-target-feature +bf16 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall 
-emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC 
-D__ARM_FEATURE_SVE_BF16 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu 
-target-feature +sve -target-feature +bf16 -fallow-half-arguments-and-returns 
-S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC 
-D__ARM_FEATURE_SVE_BF16 -triple aarch64-none-linux-gnu -target-feature +sve 
-target-feature +bf16 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall 
-o - %s >/dev/null 2>%t
+// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC 
-triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 
-fallow-half-arguments-and-returns -fsyntax-only -verify 
-verify-ignore-unexpected=error -verify-ignore-unexpected=note %s
+
+// If this check fails please read test/CodeGen/aarch64-sve-intrinsics/README 
for instructions on how to resolve it.
+// ASM-NOT: warning
+#include 
+
+#ifdef SVE_OVERLOADED_FORMS
+// A simple used,unused... macro, long enough to represent any SVE builtin.
+#define SVE_ACLE_FUNC(A1,A2_UNUSED,A3,A4_UNUSED) A1##A3
+#else
+#define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4
+#endif
+
+uint64_t test_svlen_bf16(svbfloat16_t op)
+{
+  // CHECK-LABEL: test_svlen_bf16
+  // CHECK: %[[VSCALE:.*]] = call i64 @llvm.vscale.i64()
+  // CHECK: %[[SHL:.*]] = shl i64 %[[VSCALE]], 3
+  // CHECK: ret i64 %[[SHL]]
+  // expected-warning@+1 {{implicit declaration of function 'svlen_bf16'}}
+  return SVE_ACLE_FUNC(svlen,_bf16,,)(op);
+}



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


[clang] 05e10ee - [AArch64][SVE2] Add bfloat16 support to whilerw/whilewr intrinsics

2020-06-24 Thread Cullen Rhodes via cfe-commits

Author: Cullen Rhodes
Date: 2020-06-24T10:06:31Z
New Revision: 05e10ee0aee02dd3ff30f59a0b5e1faa2d5a21a0

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

LOG: [AArch64][SVE2] Add bfloat16 support to whilerw/whilewr intrinsics

Reviewed By: fpetrogalli

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

Added: 
clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_whilerw-bfloat.c
clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_whilewr-bfloat.c

Modified: 
clang/include/clang/Basic/arm_sve.td
clang/lib/CodeGen/CGBuiltin.cpp
llvm/test/CodeGen/AArch64/sve2-intrinsics-contiguous-conflict-detection.ll

Removed: 




diff  --git a/clang/include/clang/Basic/arm_sve.td 
b/clang/include/clang/Basic/arm_sve.td
index eccbb6f3f771..3fb86fcdc1ff 100644
--- a/clang/include/clang/Basic/arm_sve.td
+++ b/clang/include/clang/Basic/arm_sve.td
@@ -1962,6 +1962,11 @@ def SVWHILEWR_S : SInst<"svwhilewr[_{1}]", "Pcc", 
"iUif", MergeNone, "aarch64_sv
 def SVWHILEWR_D : SInst<"svwhilewr[_{1}]", "Pcc", "lUld", MergeNone, 
"aarch64_sve_whilewr_d", [IsOverloadWhileRW]>;
 }
 
+let ArchGuard = "defined(__ARM_FEATURE_SVE2) && 
defined(__ARM_FEATURE_SVE_BF16)" in {
+def SVWHILERW_H_BF16 : SInst<"svwhilerw[_{1}]", "Pcc", "b", MergeNone, 
"aarch64_sve_whilerw_h", [IsOverloadWhileRW]>;
+def SVWHILEWR_H_BF16 : SInst<"svwhilewr[_{1}]", "Pcc", "b", MergeNone, 
"aarch64_sve_whilewr_h", [IsOverloadWhileRW]>;
+}
+
 

 // SVE2 - Extended table lookup/permute
 let ArchGuard = "defined(__ARM_FEATURE_SVE2)" in {

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 9526e46c9c6a..89ab1a3c2cb0 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -7726,6 +7726,8 @@ CodeGenFunction::getSVEPredType(SVETypeFlags TypeFlags) {
   case SVETypeFlags::EltTyInt64:
 return llvm::ScalableVectorType::get(Builder.getInt1Ty(), 2);
 
+  case SVETypeFlags::EltTyBFloat16:
+return llvm::ScalableVectorType::get(Builder.getInt1Ty(), 8);
   case SVETypeFlags::EltTyFloat16:
 return llvm::ScalableVectorType::get(Builder.getInt1Ty(), 8);
   case SVETypeFlags::EltTyFloat32:

diff  --git 
a/clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_whilerw-bfloat.c 
b/clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_whilerw-bfloat.c
new file mode 100644
index ..60c9cffd44eb
--- /dev/null
+++ b/clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_whilerw-bfloat.c
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_SVE2 
-D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -D__ARM_FEATURE_SVE_BF16 -triple 
aarch64-none-linux-gnu -target-feature +sve2 -target-feature +bf16 
-fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | 
FileCheck %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_SVE2 
-D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -D__ARM_FEATURE_SVE_BF16 
-DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve2 
-target-feature +bf16 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall 
-emit-llvm -o - %s | FileCheck %s
+
+// Test expected warnings for implicit declaration when +sve2 is missing
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC 
-D__ARM_FEATURE_SVE_BF16 -triple aarch64-none-linux-gnu -target-feature +sve 
-target-feature +bf16 -fallow-half-arguments-and-returns -fsyntax-only -verify 
-verify-ignore-unexpected=error %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC 
-D__ARM_FEATURE_SVE_BF16 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu 
-target-feature +sve -target-feature +bf16 -fallow-half-arguments-and-returns 
-fsyntax-only -verify=overload -verify-ignore-unexpected=error %s
+
+// Test expected warnings for implicit declaration when +bf16 is missing
+// NOTE: +bf16 doesn't currently imply __ARM_FEATURE_SVE_BF16, once the
+// implementation is complete it will, at which point -target-feature +bf16
+// should be removed.
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_SVE2 
-D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -triple aarch64-none-linux-gnu 
-target-feature +sve2 -target-feature +bf16 -fallow-half-arguments-and-returns 
-fsyntax-only -verify -verify-ignore-unexpected=error %s
+
+// Test expected ambiguous call error for overloaded form when +bf16 is missing
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_SVE2 
-D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -DSVE_OVERLOADED_FORMS -triple 
aarch64-none-linux-gnu -target-feature +sve2 -target-feature +bf16 
-fallow-half-arguments-and-returns -fsyntax-only -verify=overload-bf16 
-verify-ignore-unexpected=note %s
+
+#include 
+
+#ifdef SVE_OVERLOADED_FORMS
+// A simpl

[clang] 26502ad - [AArch64][SVE] Add bfloat16 support to perm and select intrinsics

2020-06-24 Thread Cullen Rhodes via cfe-commits

Author: Cullen Rhodes
Date: 2020-06-24T10:04:51Z
New Revision: 26502ad609222321f6384e3317fc03165c844be1

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

LOG: [AArch64][SVE] Add bfloat16 support to perm and select intrinsics

Summary:
Added for following intrinsics:

  * zip1, zip2, zip1q, zip2q
  * trn1, trn2, trn1q, trn2q
  * uzp1, uzp2, uzp1q, uzp2q
  * splice
  * rev
  * sel

Reviewed By: david-arm

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

Added: 
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_rev-bfloat.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_sel-bfloat.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_splice-bfloat.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_trn1-bfloat.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_trn1-fp64-bfloat.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_trn2-bfloat.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_trn2-fp64-bfloat.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_uzp1-bfloat.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_uzp1-fp64-bfloat.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_uzp2-bfloat.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_uzp2-fp64-bfloat.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_zip1-bfloat.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_zip1-fp64-bfloat.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_zip2-bfloat.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_zip2-fp64-bfloat.c

Modified: 
clang/include/clang/Basic/arm_sve.td
llvm/lib/Target/AArch64/SVEInstrFormats.td
llvm/test/CodeGen/AArch64/sve-intrinsics-perm-select.ll
llvm/test/CodeGen/AArch64/sve-intrinsics-sel.ll

Removed: 




diff  --git a/clang/include/clang/Basic/arm_sve.td 
b/clang/include/clang/Basic/arm_sve.td
index 091c9e230b51..b6bedac08bc6 100644
--- a/clang/include/clang/Basic/arm_sve.td
+++ b/clang/include/clang/Basic/arm_sve.td
@@ -1188,6 +1188,18 @@ def SVUZP2   : SInst<"svuzp2[_{d}]",  "ddd",  
"csilUcUsUiUlhfd", MergeNo
 def SVZIP1   : SInst<"svzip1[_{d}]",  "ddd",  "csilUcUsUiUlhfd", 
MergeNone, "aarch64_sve_zip1">;
 def SVZIP2   : SInst<"svzip2[_{d}]",  "ddd",  "csilUcUsUiUlhfd", 
MergeNone, "aarch64_sve_zip2">;
 
+let ArchGuard = "defined(__ARM_FEATURE_SVE_BF16)" in {
+def SVREV_BF16: SInst<"svrev[_{d}]","dd",   "b", MergeNone, 
"aarch64_sve_rev">;
+def SVSEL_BF16: SInst<"svsel[_{d}]","dPdd", "b", MergeNone, 
"aarch64_sve_sel">;
+def SVSPLICE_BF16 : SInst<"svsplice[_{d}]", "dPdd", "b", MergeNone, 
"aarch64_sve_splice">;
+def SVTRN1_BF16   : SInst<"svtrn1[_{d}]",   "ddd",  "b", MergeNone, 
"aarch64_sve_trn1">;
+def SVTRN2_BF16   : SInst<"svtrn2[_{d}]",   "ddd",  "b", MergeNone, 
"aarch64_sve_trn2">;
+def SVUZP1_BF16   : SInst<"svuzp1[_{d}]",   "ddd",  "b", MergeNone, 
"aarch64_sve_uzp1">;
+def SVUZP2_BF16   : SInst<"svuzp2[_{d}]",   "ddd",  "b", MergeNone, 
"aarch64_sve_uzp2">;
+def SVZIP1_BF16   : SInst<"svzip1[_{d}]",   "ddd",  "b", MergeNone, 
"aarch64_sve_zip1">;
+def SVZIP2_BF16   : SInst<"svzip2[_{d}]",   "ddd",  "b", MergeNone, 
"aarch64_sve_zip2">;
+}
+
 def SVREV_B   : SInst<"svrev_{d}",  "PP",   "PcPsPiPl", MergeNone, 
"aarch64_sve_rev">;
 def SVSEL_B   : SInst<"svsel[_b]",  "", "Pc",   MergeNone, 
"aarch64_sve_sel">;
 def SVTRN1_B  : SInst<"svtrn1_{d}", "PPP",  "PcPsPiPl", MergeNone, 
"aarch64_sve_trn1">;
@@ -1359,6 +1371,15 @@ def SVZIP1Q  : SInst<"svzip1q[_{d}]", "ddd",  
"csilUcUsUiUlhfd", MergeNo
 def SVZIP2Q  : SInst<"svzip2q[_{d}]", "ddd",  "csilUcUsUiUlhfd", 
MergeNone, "aarch64_sve_zip2q">;
 }
 
+let ArchGuard = "defined(__ARM_FEATURE_SVE_MATMUL_FP64) && 
defined(__ARM_FEATURE_SVE_BF16)" in {
+def SVTRN1Q_BF16  : SInst<"svtrn1q[_{d}]", "ddd",  "b", MergeNone, 
"aarch64_sve_trn1q">;
+def SVTRN2Q_BF16  : SInst<"svtrn2q[_{d}]", "ddd",  "b", MergeNone, 
"aarch64_sve_trn2q">;
+def SVUZP1Q_BF16  : SInst<"svuzp1q[_{d}]", "ddd",  "b", MergeNone, 
"aarch64_sve_uzp1q">;
+def SVUZP2Q_BF16  : SInst<"svuzp2q[_{d}]", "ddd",  "b", MergeNone, 
"aarch64_sve_uzp2q">;
+def SVZIP1Q_BF16  : SInst<"svzip1q[_{d}]", "ddd",  "b", MergeNone, 
"aarch64_sve_zip1q">;
+def SVZIP2Q_BF16  : SInst<"svzip2q[_{d}]", "ddd",  "b", MergeNone, 
"aarch64_sve_zip2q">;
+}
+
 

 // Vector creation
 def SVUNDEF_1 : SInst<"svundef_{d}",  "d", "csilUcUsUiUlhfd", MergeNone, "", 
[IsUndef]>;

diff  --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_rev-bfloat.c 
b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_rev-bfloat.c
new file mode 100644
index ..b21474d2d82a
---

[PATCH] D82446: [clang] Fix duplicate warning

2020-06-24 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui created this revision.
kamleshbhalui added reviewers: rsmith, aaron.ballman.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fixes duplicate warning emitted by clang when 
char16_t/char32_t is used in the catch block.

Fixes this
https://bugs.llvm.org/show_bug.cgi?id=46425


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82446

Files:
  clang/lib/Parse/ParseExprCXX.cpp
  clang/test/Parser/cxx98-char.cpp


Index: clang/test/Parser/cxx98-char.cpp
===
--- /dev/null
+++ clang/test/Parser/cxx98-char.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -std=c++11 -Wc++98-compat -verify=cxx11 -fcxx-exceptions %s
+void foo() 
+{ 
+try  { }
+catch (char16_t b) {} // cxx11-warning {{'char16_t' type specifier is 
incompatible with C++98}}
+catch (char32_t c) {} // cxx11-warning {{'char32_t' type specifier is 
incompatible with C++98}}
+} 
Index: clang/lib/Parse/ParseExprCXX.cpp
===
--- clang/lib/Parse/ParseExprCXX.cpp
+++ clang/lib/Parse/ParseExprCXX.cpp
@@ -2270,7 +2270,6 @@
 ///
 bool Parser::ParseCXXTypeSpecifierSeq(DeclSpec &DS) {
   ParseSpecifierQualifierList(DS, AS_none, 
DeclSpecContext::DSC_type_specifier);
-  DS.Finish(Actions, Actions.getASTContext().getPrintingPolicy());
   return false;
 }
 


Index: clang/test/Parser/cxx98-char.cpp
===
--- /dev/null
+++ clang/test/Parser/cxx98-char.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -std=c++11 -Wc++98-compat -verify=cxx11 -fcxx-exceptions %s
+void foo() 
+{ 
+try  { }
+catch (char16_t b) {} // cxx11-warning {{'char16_t' type specifier is incompatible with C++98}}
+catch (char32_t c) {} // cxx11-warning {{'char32_t' type specifier is incompatible with C++98}}
+} 
Index: clang/lib/Parse/ParseExprCXX.cpp
===
--- clang/lib/Parse/ParseExprCXX.cpp
+++ clang/lib/Parse/ParseExprCXX.cpp
@@ -2270,7 +2270,6 @@
 ///
 bool Parser::ParseCXXTypeSpecifierSeq(DeclSpec &DS) {
   ParseSpecifierQualifierList(DS, AS_none, DeclSpecContext::DSC_type_specifier);
-  DS.Finish(Actions, Actions.getASTContext().getPrintingPolicy());
   return false;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82360: Add StringLiteral to SyntaxTree

2020-06-24 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 accepted this revision.
gribozavr2 added a comment.
This revision is now accepted and ready to land.

LGTM with improved testing.




Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:1237
+  "a\n";
+  L"a";
+}

Could you add some non-ASCII characters to tests?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82360



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


[PATCH] D82312: Add `CharLiteral` to SyntaxTree

2020-06-24 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 accepted this revision.
gribozavr2 added a comment.
This revision is now accepted and ready to land.

LGTM after new tests are added.




Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:1240
+  'a';
+  L'a';
+}

Could you add tests for escape sequences (`'\n'`, `'\x20'` etc.), and non-ASCII 
characters, here, and below in Unicode literals?



Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:1266
+
+TEST_P(SyntaxTreeTest, CharacterLiteralCxx11) {
+  if (!GetParam().isCXX11OrLater()) {

eduucaldas wrote:
> Rename to `CharacterLiteralUtf`?
Either name is good, I think.



Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:1300
+
+TEST_P(SyntaxTreeTest, CharacterLiteralCxx17) {
+  if (!GetParam().isCXX17OrLater()) {

eduucaldas wrote:
> Rename to `CharacterLiteralUtf8`?
Either name is good, I think.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82312



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


[PATCH] D82199: [clang-format] restore indent in conditionals when AlignOperands is DontAlign

2020-06-24 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir updated this revision to Diff 272957.
krasimir marked an inline comment as done.
krasimir added a comment.

- add a FIXME


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82199

Files:
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -6284,6 +6284,10 @@
 
   Style.AlignOperands = FormatStyle::OAS_DontAlign;
   Style.BreakBeforeTernaryOperators = false;
+  // FIXME: Aligning the question marks is weird given DontAlign.
+  // Consider disabling this alignment in this case. Also check whether this
+  // will render the adjustment from https://reviews.llvm.org/D82199
+  // unnecessary.
   verifyFormat("int x = aaa ? aa :\n"
"? cc :\n"
"  d;\n",


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -6284,6 +6284,10 @@
 
   Style.AlignOperands = FormatStyle::OAS_DontAlign;
   Style.BreakBeforeTernaryOperators = false;
+  // FIXME: Aligning the question marks is weird given DontAlign.
+  // Consider disabling this alignment in this case. Also check whether this
+  // will render the adjustment from https://reviews.llvm.org/D82199
+  // unnecessary.
   verifyFormat("int x = aaa ? aa :\n"
"? cc :\n"
"  d;\n",
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82445: [analyzer][solver] Track symbol equivalence

2020-06-24 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko updated this revision to Diff 272954.
vsavchenko added a comment.

Fix incorrect comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82445

Files:
  clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
  
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/lib/StaticAnalyzer/Core/RangedConstraintManager.cpp
  clang/test/Analysis/equality_tracking.c

Index: clang/test/Analysis/equality_tracking.c
===
--- /dev/null
+++ clang/test/Analysis/equality_tracking.c
@@ -0,0 +1,132 @@
+// RUN: %clang_analyze_cc1 -verify %s \
+// RUN:   -analyzer-checker=core,debug.ExprInspection \
+// RUN:   -analyzer-config eagerly-assume=false
+
+#define NULL (void *)0
+
+#define UCHAR_MAX (unsigned char)(~0U)
+#define CHAR_MAX (char)(UCHAR_MAX & (UCHAR_MAX >> 1))
+#define CHAR_MIN (char)(UCHAR_MAX & ~(UCHAR_MAX >> 1))
+
+void clang_analyzer_eval(int);
+
+int getInt();
+
+void zeroImpliesEquality(int a, int b) {
+  clang_analyzer_eval((a - b) == 0); // expected-warning{{UNKNOWN}}
+  if ((a - b) == 0) {
+clang_analyzer_eval(b != a);// expected-warning{{FALSE}}
+clang_analyzer_eval(b == a);// expected-warning{{TRUE}}
+clang_analyzer_eval(!(a != b)); // expected-warning{{TRUE}}
+clang_analyzer_eval(!(b == a)); // expected-warning{{FALSE}}
+return;
+  }
+  clang_analyzer_eval((a - b) == 0); // expected-warning{{FALSE}}
+  // FIXME: we should track disequality information as well
+  clang_analyzer_eval(b == a); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(b != a); // expected-warning{{UNKNOWN}}
+}
+
+void zeroImpliesReversedEqual(int a, int b) {
+  clang_analyzer_eval((b - a) == 0); // expected-warning{{UNKNOWN}}
+  if ((b - a) == 0) {
+clang_analyzer_eval(b != a); // expected-warning{{FALSE}}
+clang_analyzer_eval(b == a); // expected-warning{{TRUE}}
+return;
+  }
+  clang_analyzer_eval((b - a) == 0); // expected-warning{{FALSE}}
+  // FIXME: we should track disequality information as well
+  clang_analyzer_eval(b == a); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(b != a); // expected-warning{{UNKNOWN}}
+}
+
+void canonicalEqual(int a, int b) {
+  clang_analyzer_eval(a == b); // expected-warning{{UNKNOWN}}
+  if (a == b) {
+clang_analyzer_eval(b == a); // expected-warning{{TRUE}}
+return;
+  }
+  clang_analyzer_eval(a == b); // expected-warning{{FALSE}}
+  clang_analyzer_eval(b == a); // expected-warning{{FALSE}}
+}
+
+void test(int a, int b, int c, int d) {
+  if (a == b && c == d) {
+if (a == 0 && b == d) {
+  clang_analyzer_eval(c == 0); // expected-warning{{TRUE}}
+}
+c = 10;
+if (b == d) {
+  clang_analyzer_eval(c == 10); // expected-warning{{TRUE}}
+  clang_analyzer_eval(d == 10); // expected-warning{{UNKNOWN}}
+// expected-warning@-1{{FALSE}}
+  clang_analyzer_eval(b == a);  // expected-warning{{TRUE}}
+  clang_analyzer_eval(a == d);  // expected-warning{{TRUE}}
+
+  b = getInt();
+  clang_analyzer_eval(a == d); // expected-warning{{TRUE}}
+  clang_analyzer_eval(a == b); // expected-warning{{UNKNOWN}}
+}
+  }
+
+  if (a != b && b == c) {
+if (c == 42) {
+  clang_analyzer_eval(b == 42); // expected-warning{{TRUE}}
+  // FIXME: we should track disequality information as well
+  clang_analyzer_eval(a != 42); // expected-warning{{UNKNOWN}}
+}
+  }
+}
+
+void testIntersection(int a, int b, int c) {
+  if (a < 42 && b > 15 && c >= 25 && c <= 30) {
+if (a != b)
+  return;
+
+clang_analyzer_eval(a > 15);  // expected-warning{{TRUE}}
+clang_analyzer_eval(b < 42);  // expected-warning{{TRUE}}
+clang_analyzer_eval(a <= 30); // expected-warning{{UNKNOWN}}
+
+if (c == b) {
+  // For all equal symbols, we should track the minimal common range.
+  //
+  // Also, it should be noted that c is dead at this point, but the
+  // constraint initially associated with c is still around.
+  clang_analyzer_eval(a >= 25 && a <= 30); // expected-warning{{TRUE}}
+  clang_analyzer_eval(b >= 25 && b <= 30); // expected-warning{{TRUE}}
+}
+  }
+}
+
+void testPromotion(int a, char b) {
+  if (b > 10) {
+if (a == b) {
+  clang_analyzer_eval(a > 10);// expected-warning{{TRUE}}
+  clang_analyzer_eval(a <= CHAR_MAX); // expected-warning{{TRUE}}
+}
+  }
+}
+
+void testPromotionOnlyTypes(int a, char b) {
+  if (a == b) {
+// FIXME: even when b doesn't have any constraints we still
+//should understand that b has a smaller type and assign
+//constraints correspondingly
+clang_analyzer_eval(a <= CHAR_MAX); // expected-warning{{UNKNOWN}}
+  }
+}
+
+void testPoint

[PATCH] D82448: [AArch64][SVE] Add bfloat16 support to store intrinsics

2020-06-24 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin created this revision.
kmclaughlin added reviewers: sdesmalen, c-rhodes, fpetrogalli, efriedma, stuij, 
david-arm.
Herald added subscribers: llvm-commits, cfe-commits, danielkiss, psnobl, 
rkruppe, hiraditya, kristof.beyls, tschuett.
Herald added projects: clang, LLVM.

Bfloat16 support added for the following intrinsics:

- ST1
- STNT1


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82448

Files:
  clang/include/clang/Basic/arm_sve.td
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_st1-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_stnt1-bfloat.c
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
  llvm/test/CodeGen/AArch64/sve-intrinsics-st1-addressing-mode-reg-imm.ll
  llvm/test/CodeGen/AArch64/sve-intrinsics-st1-addressing-mode-reg-reg.ll
  llvm/test/CodeGen/AArch64/sve-intrinsics-st1.ll
  llvm/test/CodeGen/AArch64/sve-intrinsics-stores.ll
  llvm/test/CodeGen/AArch64/sve-masked-ldst-nonext.ll
  llvm/test/CodeGen/AArch64/sve-pred-contiguous-ldst-addressing-mode-reg-imm.ll
  
llvm/test/CodeGen/AArch64/sve-pred-non-temporal-ldst-addressing-mode-reg-imm.ll
  
llvm/test/CodeGen/AArch64/sve-pred-non-temporal-ldst-addressing-mode-reg-reg.ll

Index: llvm/test/CodeGen/AArch64/sve-pred-non-temporal-ldst-addressing-mode-reg-reg.ll
===
--- llvm/test/CodeGen/AArch64/sve-pred-non-temporal-ldst-addressing-mode-reg-reg.ll
+++ llvm/test/CodeGen/AArch64/sve-pred-non-temporal-ldst-addressing-mode-reg-reg.ll
@@ -94,6 +94,20 @@
   ret void
 }
 
+define void @test_masked_ldst_sv8bf16(bfloat* %base,  %mask, i64 %offset) nounwind {
+; CHECK-LABEL: test_masked_ldst_sv8bf16:
+; CHECK-NEXT: ldnt1h { z[[DATA:[0-9]+]].h }, p0/z, [x0, x1, lsl #1]
+; CHECK-NEXT: stnt1h { z[[DATA]].h }, p0, [x0, x1, lsl #1]
+; CHECK-NEXT: ret
+  %gep = getelementptr bfloat, bfloat* %base, i64 %offset
+  %data = call  @llvm.aarch64.sve.ldnt1.nxv8bf16( %mask,
+  bfloat* %gep)
+  call void @llvm.aarch64.sve.stnt1.nxv8bf16( %data,
+  %mask,
+ bfloat* %gep)
+  ret void
+}
+
 ; 16-lane non-temporal load/stores.
 
 define void @test_masked_ldst_sv16i8(i8* %base,  %mask, i64 %offset) nounwind {
@@ -121,6 +135,7 @@
 ; 8-element non-temporal loads.
 declare  @llvm.aarch64.sve.ldnt1.nxv8i16(, i16*)
 declare  @llvm.aarch64.sve.ldnt1.nxv8f16(, half*)
+declare  @llvm.aarch64.sve.ldnt1.nxv8bf16(, bfloat*)
 
 ; 16-element non-temporal loads.
 declare  @llvm.aarch64.sve.ldnt1.nxv16i8(, i8*)
@@ -128,14 +143,15 @@
 ; 2-element non-temporal stores.
 declare void @llvm.aarch64.sve.stnt1.nxv2i64(, , i64*)
 declare void @llvm.aarch64.sve.stnt1.nxv2f64(, , double*)
-  
-; 4-element non-temporal stores.
+
+; 4-element non-temporal stores.
 declare void @llvm.aarch64.sve.stnt1.nxv4i32(, , i32*)
 declare void @llvm.aarch64.sve.stnt1.nxv4f32(, , float*)
-  
-; 8-element non-temporal stores.
+
+; 8-element non-temporal stores.
 declare void @llvm.aarch64.sve.stnt1.nxv8i16(, , i16*)
 declare void @llvm.aarch64.sve.stnt1.nxv8f16(, , half*)
+declare void @llvm.aarch64.sve.stnt1.nxv8bf16(, , bfloat*)
 
 ; 16-element non-temporal stores.
 declare void @llvm.aarch64.sve.stnt1.nxv16i8(, , i8*)
Index: llvm/test/CodeGen/AArch64/sve-pred-non-temporal-ldst-addressing-mode-reg-imm.ll
===
--- llvm/test/CodeGen/AArch64/sve-pred-non-temporal-ldst-addressing-mode-reg-imm.ll
+++ llvm/test/CodeGen/AArch64/sve-pred-non-temporal-ldst-addressing-mode-reg-imm.ll
@@ -139,6 +139,23 @@
   ret void
 }
 
+define void @test_masked_ldst_sv8bf16( * %base,  %mask) nounwind {
+; CHECK-LABEL: test_masked_ldst_sv8bf16:
+; CHECK-NEXT: ldnt1h { z[[DATA:[0-9]+]].h }, p0/z, [x0, #-1, mul vl]
+; CHECK-NEXT: stnt1h { z[[DATA]].h }, p0, [x0, #2, mul vl]
+; CHECK-NEXT: ret
+  %base_load = getelementptr , * %base, i64 -1
+  %base_load_bc = bitcast * %base_load to bfloat*
+  %data = call  @llvm.aarch64.sve.ldnt1.nxv8bf16( %mask,
+  bfloat* %base_load_bc)
+  %base_store = getelementptr ,  * %base, i64 2
+  %base_store_bc = bitcast * %base_store to bfloat*
+  call void @llvm.aarch64.sve.stnt1.nxv8bf16( %data,
+  %mask,
+ bfloat* %base_store_bc)
+  ret void
+}
+
 ; 16-lane non-temporal load/stores.
 
 define void @test_masked_ldst_sv16i8( * %base,  %mask) nounwind {
@@ -169,6 +186,7 @@
 ; 8-element non-temporal loads.
 declare  @llvm.aarch64.sve.ldnt1.nxv8i16(, i16*)
 declare  @llvm.a

[PATCH] D82399: [AArch64][SVE2] Add bfloat16 support to whilerw/whilewr intrinsics

2020-06-24 Thread Cullen Rhodes via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG05e10ee0aee0: [AArch64][SVE2] Add bfloat16 support to 
whilerw/whilewr intrinsics (authored by c-rhodes).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82399

Files:
  clang/include/clang/Basic/arm_sve.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_whilerw-bfloat.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_whilewr-bfloat.c
  llvm/test/CodeGen/AArch64/sve2-intrinsics-contiguous-conflict-detection.ll

Index: llvm/test/CodeGen/AArch64/sve2-intrinsics-contiguous-conflict-detection.ll
===
--- llvm/test/CodeGen/AArch64/sve2-intrinsics-contiguous-conflict-detection.ll
+++ llvm/test/CodeGen/AArch64/sve2-intrinsics-contiguous-conflict-detection.ll
@@ -36,6 +36,14 @@
   ret  %out
 }
 
+define  @whilerw_bfloat(bfloat* %a, bfloat* %b) {
+; CHECK-LABEL: whilerw_bfloat:
+; CHECK: whilerw  p0.h, x0, x1
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.whilerw.h.nx8i1.bf16.bf16(bfloat* %a, bfloat* %b)
+  ret  %out
+}
+
 define  @whilerw_half(half* %a, half* %b) {
 ; CHECK-LABEL: whilerw_half:
 ; CHECK: whilerw  p0.h, x0, x1
@@ -96,6 +104,14 @@
   ret  %out
 }
 
+define  @whilewr_bfloat(bfloat* %a, bfloat* %b) {
+; CHECK-LABEL: whilewr_bfloat:
+; CHECK: whilewr  p0.h, x0, x1
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.whilewr.h.nx8i1.bf16.bf16(bfloat* %a, bfloat* %b)
+  ret  %out
+}
+
 define  @whilewr_half(half* %a, half* %b) {
 ; CHECK-LABEL: whilewr_half:
 ; CHECK: whilewr  p0.h, x0, x1
@@ -125,6 +141,7 @@
 declare  @llvm.aarch64.sve.whilerw.s.nx4i1(i32* %a, i32* %b)
 declare  @llvm.aarch64.sve.whilerw.d.nx2i1(i64* %a, i64* %b)
 
+declare  @llvm.aarch64.sve.whilerw.h.nx8i1.bf16.bf16(bfloat* %a, bfloat* %b)
 declare  @llvm.aarch64.sve.whilerw.h.nx8i1.f16.f16(half* %a, half* %b)
 declare  @llvm.aarch64.sve.whilerw.s.nx4i1.f32.f32(float* %a, float* %b)
 declare  @llvm.aarch64.sve.whilerw.d.nx2i1.f64.f64(double* %a, double* %b)
@@ -134,6 +151,7 @@
 declare  @llvm.aarch64.sve.whilewr.s.nx4i1(i32* %a, i32* %b)
 declare  @llvm.aarch64.sve.whilewr.d.nx2i1(i64* %a, i64* %b)
 
+declare  @llvm.aarch64.sve.whilewr.h.nx8i1.bf16.bf16(bfloat* %a, bfloat* %b)
 declare  @llvm.aarch64.sve.whilewr.h.nx8i1.f16.f16(half* %a, half* %b)
 declare  @llvm.aarch64.sve.whilewr.s.nx4i1.f32.f32(float* %a, float* %b)
 declare  @llvm.aarch64.sve.whilewr.d.nx2i1.f64.f64(double* %a, double* %b)
Index: clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_whilewr-bfloat.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_whilewr-bfloat.c
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_SVE2 -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -D__ARM_FEATURE_SVE_BF16 -triple aarch64-none-linux-gnu -target-feature +sve2 -target-feature +bf16 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_SVE2 -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -D__ARM_FEATURE_SVE_BF16 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve2 -target-feature +bf16 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+
+// Test expected warnings for implicit declaration when +sve2 is missing
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -D__ARM_FEATURE_SVE_BF16 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fallow-half-arguments-and-returns -fsyntax-only -verify -verify-ignore-unexpected=error %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -D__ARM_FEATURE_SVE_BF16 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fallow-half-arguments-and-returns -fsyntax-only -verify=overload -verify-ignore-unexpected=error %s
+
+// Test expected warnings for implicit declaration when +bf16 is missing
+// NOTE: +bf16 doesn't currently imply __ARM_FEATURE_SVE_BF16, once the
+// implementation is complete it will, at which point -target-feature +bf16
+// should be removed.
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_SVE2 -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -triple aarch64-none-linux-gnu -target-feature +sve2 -target-feature +bf16 -fallow-half-arguments-and-returns -fsyntax-only -verify -verify-ignore-unexpected=error %s
+
+// Test expected ambiguous call error for overloaded form when +bf16 is missing
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_SVE2 -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve2 -target-feature +bf16 -fallow-half-arguments-and-returns -fsyntax-only -verify=overload-bf16 -verify-ignore-unexpected=not

[PATCH] D82182: [AArch64][SVE] Add bfloat16 support to perm and select intrinsics

2020-06-24 Thread Cullen Rhodes via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG26502ad60922: [AArch64][SVE] Add bfloat16 support to perm 
and select intrinsics (authored by c-rhodes).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82182

Files:
  clang/include/clang/Basic/arm_sve.td
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_rev-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_sel-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_splice-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_trn1-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_trn1-fp64-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_trn2-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_trn2-fp64-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_uzp1-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_uzp1-fp64-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_uzp2-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_uzp2-fp64-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_zip1-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_zip1-fp64-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_zip2-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_zip2-fp64-bfloat.c
  llvm/lib/Target/AArch64/SVEInstrFormats.td
  llvm/test/CodeGen/AArch64/sve-intrinsics-perm-select.ll
  llvm/test/CodeGen/AArch64/sve-intrinsics-sel.ll

Index: llvm/test/CodeGen/AArch64/sve-intrinsics-sel.ll
===
--- llvm/test/CodeGen/AArch64/sve-intrinsics-sel.ll
+++ llvm/test/CodeGen/AArch64/sve-intrinsics-sel.ll
@@ -57,6 +57,16 @@
   ret  %out
 }
 
+define  @sel_bf16( %pg,  %a,  %b) {
+; CHECK-LABEL: sel_bf16:
+; CHECK: sel z0.h, p0, z0.h, z1.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.sel.nxv8bf16( %pg,
+%a,
+%b)
+  ret  %out
+}
+
 define  @sel_f16( %pg,  %a,  %b) {
 ; CHECK-LABEL: sel_f16:
 ; CHECK: sel z0.h, p0, z0.h, z1.h
@@ -92,6 +102,7 @@
 declare  @llvm.aarch64.sve.sel.nxv8i16(, , )
 declare  @llvm.aarch64.sve.sel.nxv4i32(, , )
 declare  @llvm.aarch64.sve.sel.nxv2i64(, , )
+declare  @llvm.aarch64.sve.sel.nxv8bf16(, , )
 declare  @llvm.aarch64.sve.sel.nxv8f16(, , )
 declare  @llvm.aarch64.sve.sel.nxv4f32(, , )
 declare  @llvm.aarch64.sve.sel.nxv2f64(, , )
Index: llvm/test/CodeGen/AArch64/sve-intrinsics-perm-select.ll
===
--- llvm/test/CodeGen/AArch64/sve-intrinsics-perm-select.ll
+++ llvm/test/CodeGen/AArch64/sve-intrinsics-perm-select.ll
@@ -806,6 +806,14 @@
   ret  %res
 }
 
+define  @rev_bf16( %a) {
+; CHECK-LABEL: rev_bf16
+; CHECK: rev z0.h, z0.h
+; CHECK-NEXT: ret
+  %res = call  @llvm.aarch64.sve.rev.nxv8bf16( %a)
+  ret  %res
+}
+
 define  @rev_f16( %a) {
 ; CHECK-LABEL: rev_f16
 ; CHECK: rev z0.h, z0.h
@@ -874,6 +882,16 @@
   ret  %out
 }
 
+define  @splice_bf16( %pg,  %a,  %b) {
+; CHECK-LABEL: splice_bf16:
+; CHECK: splice z0.h, p0, z0.h, z1.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.splice.nxv8bf16( %pg,
+   %a,
+   %b)
+  ret  %out
+}
+
 define  @splice_f16( %pg,  %a,  %b) {
 ; CHECK-LABEL: splice_f16:
 ; CHECK: splice z0.h, p0, z0.h, z1.h
@@ -1168,6 +1186,15 @@
   ret  %out
 }
 
+define  @trn1_bf16( %a,  %b) {
+; CHECK-LABEL: trn1_bf16:
+; CHECK: trn1 z0.h, z0.h, z1.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.trn1.nxv8bf16( %a,
+ %b)
+  ret  %out
+}
+
 define  @trn1_f16( %a,  %b) {
 ; CHECK-LABEL: trn1_f16:
 ; CHECK: trn1 z0.h, z0.h, z1.h
@@ -1280,6 +1307,15 @@
   ret  %out
 }
 
+define  @trn2_bf16( %a,  %b) {
+; CHECK-LABEL: trn2_bf16:
+; CHECK: trn2 z0.h, z0.h, z1.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.trn2.nxv8bf16( %a,
+ %b)
+  ret  %out
+}
+
 define  @trn2_f16( %a,  %b) {
 ; CHECK-LABEL: trn2_f16:
 ; CHECK: trn2 z0.h, z0.h, z1.h
@@ -1392,6 +1428,15 @@
   ret  %out
 }
 
+define  @uzp1_bf16( %a,  %b) {
+; CHECK-LABEL: uzp1_bf16:
+; CHECK: uzp1 z0.h, z0.h, z1.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.uzp1.nxv8bf16( %a,
+ %b)
+  ret  %out
+}
+
 define  @uzp1_f16( %a,  %b) {
 ; CHECK-LABEL: uzp1_f16:
 ; CHECK: uzp1 z0.h, z0.h, z1.h
@@ -1504,6 +1549,15 @@
   ret  %out
 }
 
+define  @uzp2_bf16( %a,  %b) {
+; CHECK-LABEL: uzp2_bf16:
+; CHECK: uzp2 z0.h, z0.h, z1.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.uzp2.nxv8bf16( %a,
+  

[PATCH] D82186: [AArch64][SVE] Add bfloat16 support to svlen intrinsic

2020-06-24 Thread Cullen Rhodes via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfd2c4b899932: [AArch64][SVE] Add bfloat16 support to svlen 
intrinsic (authored by c-rhodes).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82186

Files:
  clang/include/clang/Basic/arm_sve.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_len-bfloat.c


Index: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_len-bfloat.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_len-bfloat.c
@@ -0,0 +1,27 @@
+// REQUIRES: aarch64-registered-target
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC 
-D__ARM_FEATURE_SVE_BF16 -triple aarch64-none-linux-gnu -target-feature +sve 
-target-feature +bf16 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall 
-emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC 
-D__ARM_FEATURE_SVE_BF16 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu 
-target-feature +sve -target-feature +bf16 -fallow-half-arguments-and-returns 
-S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC 
-D__ARM_FEATURE_SVE_BF16 -triple aarch64-none-linux-gnu -target-feature +sve 
-target-feature +bf16 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall 
-o - %s >/dev/null 2>%t
+// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC 
-triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 
-fallow-half-arguments-and-returns -fsyntax-only -verify 
-verify-ignore-unexpected=error -verify-ignore-unexpected=note %s
+
+// If this check fails please read test/CodeGen/aarch64-sve-intrinsics/README 
for instructions on how to resolve it.
+// ASM-NOT: warning
+#include 
+
+#ifdef SVE_OVERLOADED_FORMS
+// A simple used,unused... macro, long enough to represent any SVE builtin.
+#define SVE_ACLE_FUNC(A1,A2_UNUSED,A3,A4_UNUSED) A1##A3
+#else
+#define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4
+#endif
+
+uint64_t test_svlen_bf16(svbfloat16_t op)
+{
+  // CHECK-LABEL: test_svlen_bf16
+  // CHECK: %[[VSCALE:.*]] = call i64 @llvm.vscale.i64()
+  // CHECK: %[[SHL:.*]] = shl i64 %[[VSCALE]], 3
+  // CHECK: ret i64 %[[SHL]]
+  // expected-warning@+1 {{implicit declaration of function 'svlen_bf16'}}
+  return SVE_ACLE_FUNC(svlen,_bf16,,)(op);
+}
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -8434,6 +8434,7 @@
   case SVE::BI__builtin_sve_svpfalse_b:
 return ConstantInt::getFalse(Ty);
 
+  case SVE::BI__builtin_sve_svlen_bf16:
   case SVE::BI__builtin_sve_svlen_f16:
   case SVE::BI__builtin_sve_svlen_f32:
   case SVE::BI__builtin_sve_svlen_f64:
Index: clang/include/clang/Basic/arm_sve.td
===
--- clang/include/clang/Basic/arm_sve.td
+++ clang/include/clang/Basic/arm_sve.td
@@ -1281,6 +1281,10 @@
 def SVCNTP : SInst<"svcntp_{d}",  "nPP", "PcPsPiPl",MergeNone, 
"aarch64_sve_cntp">;
 def SVLEN  : SInst<"svlen[_{d}]", "nd",  "csilUcUsUiUlhfd", MergeNone>;
 
+let ArchGuard = "defined(__ARM_FEATURE_SVE_BF16)" in {
+def SVLEN_BF16 : SInst<"svlen[_{d}]", "nd", "b", MergeNone>;
+}
+
 

 // Saturating scalar arithmetic
 


Index: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_len-bfloat.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_len-bfloat.c
@@ -0,0 +1,27 @@
+// REQUIRES: aarch64-registered-target
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -D__ARM_FEATURE_SVE_BF16 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -D__ARM_FEATURE_SVE_BF16 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -D__ARM_FEATURE_SVE_BF16 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -o - %s >/dev/null 2>%t
+// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -triple aarch64-none-linux-gnu -target-feature +s

[clang] 7213142 - [libclang] Extend clang_Cursor_Evaluate().

2020-06-24 Thread Florian Hahn via cfe-commits

Author: Christian Kandeler
Date: 2020-06-24T11:58:39+01:00
New Revision: 72131423cc952ccbd6d8e021ff7c04fa22297fe3

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

LOG: [libclang] Extend clang_Cursor_Evaluate().

Let this function (try to) evaluate expressions, in addition to
declarations and compound statements.

Patch by Christian Kandeler 

Reviewers: nik, akyrtzi, arphaman, jkorous

Reviewed By: jkorous

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

Added: 


Modified: 
clang/include/clang-c/Index.h
clang/test/Index/evaluate-cursor.cpp
clang/tools/libclang/CIndex.cpp

Removed: 




diff  --git a/clang/include/clang-c/Index.h b/clang/include/clang-c/Index.h
index 19471af4a675..cfb8e58bfb7e 100644
--- a/clang/include/clang-c/Index.h
+++ b/clang/include/clang-c/Index.h
@@ -5934,6 +5934,7 @@ typedef void *CXEvalResult;
  * If cursor is a statement declaration tries to evaluate the
  * statement and if its variable, tries to evaluate its initializer,
  * into its corresponding type.
+ * If it's an expression, tries to evaluate the expression.
  */
 CINDEX_LINKAGE CXEvalResult clang_Cursor_Evaluate(CXCursor C);
 

diff  --git a/clang/test/Index/evaluate-cursor.cpp 
b/clang/test/Index/evaluate-cursor.cpp
index af396318aab7..2bb687a1eb88 100644
--- a/clang/test/Index/evaluate-cursor.cpp
+++ b/clang/test/Index/evaluate-cursor.cpp
@@ -26,6 +26,9 @@ template  class e {
   static const auto g = alignof(f);
 };
 
+constexpr static int calc_val() { return 1 + 2; }
+const auto the_value = calc_val() + sizeof(char);
+
 // RUN: c-index-test -evaluate-cursor-at=%s:4:7 \
 // RUN:-evaluate-cursor-at=%s:8:7 \
 // RUN:-evaluate-cursor-at=%s:8:11 -std=c++11 %s | FileCheck %s
@@ -53,3 +56,12 @@ template  class e {
 // RUN:-evaluate-cursor-at=%s:26:21 \
 // RUN:-std=c++11 %s | FileCheck -check-prefix=CHECK-DOES-NOT-CRASH %s
 // CHECK-DOES-NOT-CRASH: Not Evaluatable
+
+// RUN: c-index-test -evaluate-cursor-at=%s:30:1 \
+// RUN:-evaluate-cursor-at=%s:30:32 \
+// RUN:-evaluate-cursor-at=%s:30:35 \
+// RUN:-evaluate-cursor-at=%s:30:37 -std=c++11 %s | FileCheck %s 
-check-prefix=CHECK-EXPR
+// CHECK-EXPR: unsigned, Value: 4
+// CHECK-EXPR: Value: 3
+// CHECK-EXPR: unsigned, Value: 4
+// CHECK-EXPR: unsigned, Value: 1

diff  --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp
index 4a65624268d8..8d33deb468e2 100644
--- a/clang/tools/libclang/CIndex.cpp
+++ b/clang/tools/libclang/CIndex.cpp
@@ -4056,10 +4056,14 @@ static const Expr *evaluateCompoundStmtExpr(const 
CompoundStmt *CS) {
 }
 
 CXEvalResult clang_Cursor_Evaluate(CXCursor C) {
-  if (const Expr *E =
-  clang_getCursorKind(C) == CXCursor_CompoundStmt
-  ? evaluateCompoundStmtExpr(cast(getCursorStmt(C)))
-  : evaluateDeclExpr(getCursorDecl(C)))
+  const Expr *E = nullptr;
+  if (clang_getCursorKind(C) == CXCursor_CompoundStmt)
+E = evaluateCompoundStmtExpr(cast(getCursorStmt(C)));
+  else if (clang_isDeclaration(C.kind))
+E = evaluateDeclExpr(getCursorDecl(C));
+  else if (clang_isExpression(C.kind))
+E = getCursorExpr(C);
+  if (E)
 return const_cast(
 reinterpret_cast(evaluateExpr(const_cast(E), 
C)));
   return nullptr;



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


[clang] 0fad648 - [clang-format] restore indent in conditionals when AlignOperands is DontAlign

2020-06-24 Thread Krasimir Georgiev via cfe-commits

Author: Krasimir Georgiev
Date: 2020-06-24T13:11:18+02:00
New Revision: 0fad648b65b99b68040fa26c5da9c0bec5b0aa1d

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

LOG: [clang-format] restore indent in conditionals when AlignOperands is 
DontAlign

Summary:
After D50078, we're experiencing unexpected un-indent using a style combining 
`AlignOperands: DontAlign` with `BreakBeforeTernaryOperators: false`, such as 
Google's JavaScript style:
```
% bin/clang-format -style=google ~/test.js
aaa =  ? cc() :
dd ? ee :
 f;
```
The issue lies with the interaction of `AlignOperands: DontAlign` and the 
edited code section in ContinuationIndenter.cpp, which de-dents the intent by 
`Style.ContinuationIndentWidth`. From [[ 
https://github.com/llvm/llvm-project/blob/ac3e5c4d93fbe7fb2db3c745c721aff41cc1b851/clang/include/clang/Format/Format.h#L170
 | the documentation ]] of AlignOperands: DontAlign:
> The wrapped lines are indented `ContinuationIndentWidth` spaces from the 
> start of the line.
So the de-dent effectively erases the necessary `ContinuationIndentWidth` in 
that case.

This patch restores the `AlignOperands: DontAlign` behavior, producing:
```
% bin/clang-format -style=google ~/test.js
aaa =  ? cc() :
dd ? ee :
 f;
```

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/lib/Format/ContinuationIndenter.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/lib/Format/ContinuationIndenter.cpp 
b/clang/lib/Format/ContinuationIndenter.cpp
index 2ac43b6cfa4b..b1497651a8fe 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -1041,8 +1041,10 @@ unsigned ContinuationIndenter::getNewLineColumn(const 
LineState &State) {
   //* not remove the 'lead' ContinuationIndentWidth
   //* always un-indent by the operator when
   //BreakBeforeTernaryOperators=true
-  unsigned Indent =
-  State.Stack.back().Indent - Style.ContinuationIndentWidth;
+  unsigned Indent = State.Stack.back().Indent;
+  if (Style.AlignOperands != FormatStyle::OAS_DontAlign) {
+Indent -= Style.ContinuationIndentWidth;
+  }
   if (Style.BreakBeforeTernaryOperators &&
   State.Stack.back().UnindentOperator)
 Indent -= 2;

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index dce71b0f0692..beaa68a24617 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -6281,6 +6281,17 @@ TEST_F(FormatTest, BreaksConditionalExpressions) {
"   : bbb ? \n"
" : ;",
Style);
+
+  Style.AlignOperands = FormatStyle::OAS_DontAlign;
+  Style.BreakBeforeTernaryOperators = false;
+  // FIXME: Aligning the question marks is weird given DontAlign.
+  // Consider disabling this alignment in this case. Also check whether this
+  // will render the adjustment from https://reviews.llvm.org/D82199
+  // unnecessary.
+  verifyFormat("int x = aaa ? aa :\n"
+   "? cc :\n"
+   "  d;\n",
+   Style);
 }
 
 TEST_F(FormatTest, BreaksConditionalExpressionsAfterOperator) {



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


[PATCH] D65761: Add Windows Control Flow Guard checks (/guard:cf).

2020-06-24 Thread Andrew Paverd via Phabricator via cfe-commits
ajpaverd added a comment.
Herald added a reviewer: jdoerfert.

In D65761#2102525 , @mehdi_amini wrote:

> It seems like this pass was added in lib/Transforms but does not have any 
> unit-tests (lit tests) provided. It isn't even linked into `opt`. As it is an 
> LLVM IR pass it should be tested as such I believe. Can you provide tests for 
> this?


Thanks for the feedback. D82447  now links 
this into `opt` and adds lit tests in `test/Transforms/CFGuard/`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65761



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


[PATCH] D82199: [clang-format] restore indent in conditionals when AlignOperands is DontAlign

2020-06-24 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir updated this revision to Diff 272964.
krasimir added a comment.

- refresh Phabricator diff


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82199

Files:
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -6284,6 +6284,10 @@
 
   Style.AlignOperands = FormatStyle::OAS_DontAlign;
   Style.BreakBeforeTernaryOperators = false;
+  // FIXME: Aligning the question marks is weird given DontAlign.
+  // Consider disabling this alignment in this case. Also check whether this
+  // will render the adjustment from https://reviews.llvm.org/D82199
+  // unnecessary.
   verifyFormat("int x = aaa ? aa :\n"
"? cc :\n"
"  d;\n",


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -6284,6 +6284,10 @@
 
   Style.AlignOperands = FormatStyle::OAS_DontAlign;
   Style.BreakBeforeTernaryOperators = false;
+  // FIXME: Aligning the question marks is weird given DontAlign.
+  // Consider disabling this alignment in this case. Also check whether this
+  // will render the adjustment from https://reviews.llvm.org/D82199
+  // unnecessary.
   verifyFormat("int x = aaa ? aa :\n"
"? cc :\n"
"  d;\n",
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82102: [AST][RecoveryExpr] Populate the error-bit from template arguments to TemplateSepcializationType.

2020-06-24 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 272963.
hokein added a comment.

per offline discussion: add error-bit to TemplateArgument which provide a more
general fix for missing error-bit in the code path: "error type/expr" -> 
"teample argument"
-> "template specialization typ".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82102

Files:
  clang/include/clang/AST/DependenceFlags.h
  clang/lib/AST/Type.cpp
  clang/test/SemaCXX/invalid-template-base-specifier.cpp


Index: clang/test/SemaCXX/invalid-template-base-specifier.cpp
===
--- clang/test/SemaCXX/invalid-template-base-specifier.cpp
+++ clang/test/SemaCXX/invalid-template-base-specifier.cpp
@@ -1,7 +1,6 @@
 // RUN: %clang_cc1 -frecovery-ast -verify %s
 
-bool Foo(int *); // expected-note {{candidate function not viable}} \
- // expected-note {{candidate function not viable}}
+bool Foo(int *); // expected-note 3{{candidate function not viable}}
 
 template 
 struct Crash : decltype(Foo(T())) { // expected-error {{no matching function 
for call to 'Foo'}}
@@ -18,3 +17,12 @@
 };
 
 void test2() { Crash2(); } // expected-note {{in instantiation of 
template class 'Crash2' requested here}}
+
+template 
+class Base {};
+template 
+struct Crash3 : Base { // expected-error {{no matching 
function for call to 'Foo'}}
+  Crash3(){};
+};
+
+void test3() { Crash3(); } // expected-note {{in instantiation of 
template class}}
Index: clang/lib/AST/Type.cpp
===
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -3591,7 +3591,7 @@
 
   auto *TemplateArgs = reinterpret_cast(this + 1);
   for (const TemplateArgument &Arg : Args) {
-// Update instantiation-dependent and variably-modified bits.
+// Update instantiation-dependent, variably-modified, and error bits.
 // If the canonical type exists and is non-dependent, the template
 // specialization type can be non-dependent even if one of the type
 // arguments is. Given:
Index: clang/include/clang/AST/DependenceFlags.h
===
--- clang/include/clang/AST/DependenceFlags.h
+++ clang/include/clang/AST/DependenceFlags.h
@@ -64,6 +64,23 @@
 };
 using TypeDependence = TypeDependenceScope::TypeDependence;
 
+struct TemplateArgumentDependenceScope {
+  enum TemplateArgumentDependence : uint8_t {
+UnexpandedPack = 1,
+Instantiation = 2,
+Dependent = 4,
+
+Error = 8,
+
+DependentInstantiation = Dependent | Instantiation,
+None = 0,
+All = 15,
+LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/Error)
+  };
+};
+using TemplateArgumentDependence =
+TemplateArgumentDependenceScope ::TemplateArgumentDependence;
+
 #define LLVM_COMMON_DEPENDENCE(NAME)   
\
   struct NAME##Scope { 
\
 enum NAME : uint8_t {  
\
@@ -82,7 +99,6 @@
 
 LLVM_COMMON_DEPENDENCE(NestedNameSpecifierDependence)
 LLVM_COMMON_DEPENDENCE(TemplateNameDependence)
-LLVM_COMMON_DEPENDENCE(TemplateArgumentDependence)
 #undef LLVM_COMMON_DEPENDENCE
 
 // A combined space of all dependence concepts for all node types.
@@ -137,8 +153,9 @@
 
   Dependence(TemplateArgumentDependence D)
   : V(translate(D, TADependence::UnexpandedPack, UnexpandedPack) |
- translate(D, TADependence::Instantiation, Instantiation) |
- translate(D, TADependence::Dependent, Dependent)) {}
+  translate(D, TADependence::Instantiation, Instantiation) |
+  translate(D, TADependence::Dependent, Dependent) |
+  translate(D, TADependence::Error, Error)) {}
 
   Dependence(TemplateNameDependence D)
   : V(translate(D, TNDependence::UnexpandedPack, UnexpandedPack) |
@@ -170,7 +187,8 @@
   TemplateArgumentDependence templateArgument() const {
 return translate(V, UnexpandedPack, TADependence::UnexpandedPack) |
translate(V, Instantiation, TADependence::Instantiation) |
-   translate(V, Dependent, TADependence::Dependent);
+   translate(V, Dependent, TADependence::Dependent) |
+   translate(V, Error, TADependence::Error);
   }
 
   TemplateNameDependence templateName() const {


Index: clang/test/SemaCXX/invalid-template-base-specifier.cpp
===
--- clang/test/SemaCXX/invalid-template-base-specifier.cpp
+++ clang/test/SemaCXX/invalid-template-base-specifier.cpp
@@ -1,7 +1,6 @@
 // RUN: %clang_cc1 -frecovery-ast -verify %s
 
-bool Foo(int *); // expected-note {{candidate function not viable}} \
- // expected-note {{candidate function not viable}}
+bool Foo(int *); // expected-note 3{{candidate function not viable}}
 
 template 
 struct Crash : decltype(Foo(T

[PATCH] D82381: [analyzer] Introduce small improvements to the solver infra

2020-06-24 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:373
+  ++Upper;
+  --Lower;
+

Sorry if my question is dumb, but I do not really have a mental model at this 
point about where do we actually handle types and overflows. Will this method 
work when we delete the last or the first element of the full range of a type?

I think having unit tests would be a great way to make this clear. I always 
felt that the solver is actually something that should be really easy to test 
separately and those tests would also help a lot to understand how the solver 
is actually working. 



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:467-470
+/// Available representations for the arguments are:
+///   * RangeSet
+///   * Optional
+///   * RangeSet *

NoQ wrote:
> Why do we have these representations in the first place?
> 
> It sounds like you're treating null pointers / empty optionals equivalently 
> to full ranges (i.e., intersecting with them has no effect). How hard would 
> it be to simply construct an actual full range in all the places in which we 
> currently have empty optionals?
+1

I also find this confusing. Should I interpret a None as a full or empty range? 
Does this depend on the context or a general rule? Is there any reason we need 
to handle nullable pointers or could we actually make call sites more uniform 
to get rid of some of the complexity here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82381



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


[PATCH] D82182: [AArch64][SVE] Add bfloat16 support to perm and select intrinsics

2020-06-24 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen added inline comments.



Comment at: llvm/test/CodeGen/AArch64/sve-intrinsics-perm-select.ll:809
 
+define  @rev_bf16( %a) {
+; CHECK-LABEL: rev_bf16

Does this test not need the `+bf16` attribute to work? (which implies the 
patterns are missing the right predicate)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82182



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


[PATCH] D82199: [clang-format] restore indent in conditionals when AlignOperands is DontAlign

2020-06-24 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir updated this revision to Diff 272966.
krasimir added a comment.

- try to update Phabricator diff


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82199

Files:
  clang/lib/Format/ContinuationIndenter.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -6281,6 +6281,17 @@
"   : bbb ? \n"
" : ;",
Style);
+
+  Style.AlignOperands = FormatStyle::OAS_DontAlign;
+  Style.BreakBeforeTernaryOperators = false;
+  // FIXME: Aligning the question marks is weird given DontAlign.
+  // Consider disabling this alignment in this case. Also check whether this
+  // will render the adjustment from https://reviews.llvm.org/D82199
+  // unnecessary.
+  verifyFormat("int x = aaa ? aa :\n"
+   "? cc :\n"
+   "  d;\n",
+   Style);
 }
 
 TEST_F(FormatTest, BreaksConditionalExpressionsAfterOperator) {
Index: clang/lib/Format/ContinuationIndenter.cpp
===
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -1041,8 +1041,10 @@
   //* not remove the 'lead' ContinuationIndentWidth
   //* always un-indent by the operator when
   //BreakBeforeTernaryOperators=true
-  unsigned Indent =
-  State.Stack.back().Indent - Style.ContinuationIndentWidth;
+  unsigned Indent = State.Stack.back().Indent;
+  if (Style.AlignOperands != FormatStyle::OAS_DontAlign) {
+Indent -= Style.ContinuationIndentWidth;
+  }
   if (Style.BreakBeforeTernaryOperators &&
   State.Stack.back().UnindentOperator)
 Indent -= 2;


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -6281,6 +6281,17 @@
"   : bbb ? \n"
" : ;",
Style);
+
+  Style.AlignOperands = FormatStyle::OAS_DontAlign;
+  Style.BreakBeforeTernaryOperators = false;
+  // FIXME: Aligning the question marks is weird given DontAlign.
+  // Consider disabling this alignment in this case. Also check whether this
+  // will render the adjustment from https://reviews.llvm.org/D82199
+  // unnecessary.
+  verifyFormat("int x = aaa ? aa :\n"
+   "? cc :\n"
+   "  d;\n",
+   Style);
 }
 
 TEST_F(FormatTest, BreaksConditionalExpressionsAfterOperator) {
Index: clang/lib/Format/ContinuationIndenter.cpp
===
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -1041,8 +1041,10 @@
   //* not remove the 'lead' ContinuationIndentWidth
   //* always un-indent by the operator when
   //BreakBeforeTernaryOperators=true
-  unsigned Indent =
-  State.Stack.back().Indent - Style.ContinuationIndentWidth;
+  unsigned Indent = State.Stack.back().Indent;
+  if (Style.AlignOperands != FormatStyle::OAS_DontAlign) {
+Indent -= Style.ContinuationIndentWidth;
+  }
   if (Style.BreakBeforeTernaryOperators &&
   State.Stack.back().UnindentOperator)
 Indent -= 2;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82182: [AArch64][SVE] Add bfloat16 support to perm and select intrinsics

2020-06-24 Thread Cullen Rhodes via Phabricator via cfe-commits
c-rhodes marked an inline comment as done.
c-rhodes added inline comments.



Comment at: clang/include/clang/Basic/arm_sve.td:1115
 
+let ArchGuard = "defined(__ARM_FEATURE_SVE_BF16)" in {
+def SVREV_BF16: SInst<"svrev[_{d}]","dd",   "b", MergeNone, 
"aarch64_sve_rev">;

c-rhodes wrote:
> fpetrogalli wrote:
> > c-rhodes wrote:
> > > c-rhodes wrote:
> > > > fpetrogalli wrote:
> > > > > nit: could create a multiclass here like @sdesmalen have done in 
> > > > > https://reviews.llvm.org/D82187, seems quite a nice way to keep the 
> > > > > definition of the intrinsics together (look for `multiclass 
> > > > > StructLoad`, for example)
> > > > it might be a bit tedious having separate multiclasses, what do you 
> > > > think about:
> > > > ```multiclass SInstBF16 > > > string i = "",
> > > >  list ft = [], list ch = []> {
> > > >   def : SInst;
> > > >   let ArchGuard = "defined(__ARM_FEATURE_SVE_BF16)" in {
> > > > def : SInst;
> > > >   }
> > > > }
> > > > 
> > > > defm SVREV: SInstBF16<"svrev[_{d}]","dd",   "csilUcUsUiUlhfd", 
> > > > MergeNone, "aarch64_sve_rev">;
> > > > defm SVSEL: SInstBF16<"svsel[_{d}]","dPdd", "csilUcUsUiUlhfd", 
> > > > MergeNone, "aarch64_sve_sel">;
> > > > defm SVSPLICE : SInstBF16<"svsplice[_{d}]", "dPdd", "csilUcUsUiUlhfd", 
> > > > MergeNone, "aarch64_sve_splice">;
> > > > defm SVTRN1   : SInstBF16<"svtrn1[_{d}]",   "ddd",  "csilUcUsUiUlhfd", 
> > > > MergeNone, "aarch64_sve_trn1">;
> > > > defm SVTRN2   : SInstBF16<"svtrn2[_{d}]",   "ddd",  "csilUcUsUiUlhfd", 
> > > > MergeNone, "aarch64_sve_trn2">;
> > > > defm SVUZP1   : SInstBF16<"svuzp1[_{d}]",   "ddd",  "csilUcUsUiUlhfd", 
> > > > MergeNone, "aarch64_sve_uzp1">;
> > > > defm SVUZP2   : SInstBF16<"svuzp2[_{d}]",   "ddd",  "csilUcUsUiUlhfd", 
> > > > MergeNone, "aarch64_sve_uzp2">;
> > > > defm SVZIP1   : SInstBF16<"svzip1[_{d}]",   "ddd",  "csilUcUsUiUlhfd", 
> > > > MergeNone, "aarch64_sve_zip1">;
> > > > defm SVZIP2   : SInstBF16<"svzip2[_{d}]",   "ddd",  "csilUcUsUiUlhfd", 
> > > > MergeNone, "aarch64_sve_zip2">;```
> > > > 
> > > > ?
> > > I've played around with this and it works great for instructions guarded 
> > > on a single feature flag but falls apart for the .Q forms that also 
> > > require `__ARM_FEATURE_SVE_MATMUL_FP64`. I suspect there's a nice way of 
> > > handling it in tablegen by passing the features as a list of strings and 
> > > joining them but I spent long enough trying to get that to work so I'm 
> > > going to keep it simple for now.
> > > it might be a bit tedious having separate multiclasses, what do you think 
> > > about:
> > 
> > Sorry I think I misunderstood you when we last discussed this. I didn't 
> > mean to write a multiclass that would work for ALL intrinsics that uses 
> > regular types and bfloats I just meant to merge together those who were 
> > using the same archguard and that you are adding in this patch.
> > 
> > I think you could keep both macros in a single ArchGuard string:
> > 
> > ```
> > multiclass SInstPerm {
> >   def : SInst;
> >   let ArchGuard = "defined(__ARM_FEATURE_SVE_BF16)" in {
> > def : SInst;
> >   }
> > }
> > 
> > defm SVREV: SInstPerm<"svrev[_{d}]","dd",MergeNone, 
> > "aarch64_sve_rev">;
> > ...
> > 
> > multiclass SInstPermMatmul {
> >   def : SInst;
> >   let ArchGuard = "defined(__ARM_FEATURE_SVE_BF16) && 
> > defined(__ARM_FEATURE_SVE_MATMUL_FP64)" in {
> > def : SInst;
> >   }
> > }
> > 
> > def SVTRN1Q : SInstPermMatmul ...
> > ...
> > ```
> Sure, I understood you meant separate multiclasses for each intrinsic / group 
> similar to what Sander implemented for structured loads / stores but I 
> thought it would be quite abit of extra code to implement that, hence why I 
> proposed a single multiclass that could handle this. I've experimented with 
> the `SInstBF16` multiclass I mentioned above and have it working with an 
> extra arg for arch features. I'll create a follow up patch and if people are 
> happy with it we'll move forward with that, otherwise I'm happy to implement 
> your suggestion.
> I'll create a follow up patch

https://reviews.llvm.org/D82450


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82182



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


[PATCH] D82298: [AArch64][SVE] Add bfloat16 support to load intrinsics

2020-06-24 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen added inline comments.



Comment at: 
llvm/test/CodeGen/AArch64/sve-intrinsics-ld1-addressing-mode-reg-imm.ll:217
+  %base_scalar = bitcast * %base to bfloat*
+  %load = call  @llvm.aarch64.sve.ld1.nxv8bf16( %pg, bfloat* %base_scalar)
+  ret  %load

Sorry I only just spotted this in D82182 , but to match these intrinsics, the 
llc command needs to be passed +bf16 (and the patterns in the .td file need to 
be predicated accordingly)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82298



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


[PATCH] D82450: [AArch64][SVE] Add multiclass for bfloat16 intrinsic definitions

2020-06-24 Thread Cullen Rhodes via Phabricator via cfe-commits
c-rhodes created this revision.
c-rhodes added reviewers: sdesmalen, fpetrogalli, kmclaughlin, efriedma.
Herald added subscribers: danielkiss, psnobl, rkruppe, kristof.beyls, tschuett.
Herald added a project: clang.

Patch implements a multiclass 'SInstBF16', a wrapper around SInst that
also defines a bfloat16 variant. This is used to merge the definitions
of intrinsics with bfloat16 support. The multiclass also handles
multiple arch guards.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82450

Files:
  clang/include/clang/Basic/arm_sve.td

Index: clang/include/clang/Basic/arm_sve.td
===
--- clang/include/clang/Basic/arm_sve.td
+++ clang/include/clang/Basic/arm_sve.td
@@ -253,6 +253,26 @@
 : Inst {
 }
 
+// SInstBF16: Wrapper around SInst that also defines a bfloat16 instruction
+// guarded by __ARM_FEATURE_SVE_BF16. Type signature matches SInst but has an
+// extra arg 'arch_features', a list of strings used to construct the
+// ArchGuard. This is useful for defining intrinsics that are guarded on one or
+// more arch features.
+multiclass SInstBF16 ft = [], list ch = [],
+ list arch_features = []> {
+  let ArchGuard = !foldl("", arch_features, lhs, rhs,
+ lhs # !if(!ne(lhs, ""), " && ", "") # rhs) in {
+def : SInst;
+  }
+  let ArchGuard = !foldl("", !listconcat(arch_features,
+ ["__ARM_FEATURE_SVE_BF16"]),
+ lhs, rhs,
+ lhs # !if(!ne(lhs, ""), " && ", "") # rhs) in {
+def : SInst;
+  }
+}
+
 // MInst: Instructions which access memory
 class MInst f,
 MemEltType met = MemEltTyDefault, string i = "">
@@ -498,11 +518,7 @@
 }
 
 // Load one quadword and replicate (scalar base)
-def SVLD1RQ : SInst<"svld1rq[_{2}]", "dPc", "csilUcUsUiUlhfd", MergeNone, "aarch64_sve_ld1rq">;
-
-let ArchGuard = "defined(__ARM_FEATURE_SVE_BF16)" in {
-  def SVLD1RQ_BF : SInst<"svld1rq[_{2}]", "dPc",  "b", MergeNone, "aarch64_sve_ld1rq">;
-}
+defm SVLD1RQ : SInstBF16<"svld1rq[_{2}]", "dPc", "csilUcUsUiUlhfd", MergeNone, "aarch64_sve_ld1rq">;
 
 multiclass StructLoad {
   def : SInst;
@@ -522,12 +538,7 @@
 defm SVLD4_VNUM : StructLoad<"svld4_vnum[_{2}]", "4Pcl", "aarch64_sve_ld4">;
 
 // Load one octoword and replicate (scalar base)
-let ArchGuard = "defined(__ARM_FEATURE_SVE_MATMUL_FP64)" in {
-  def SVLD1RO : SInst<"svld1ro[_{2}]", "dPc", "csilUcUsUiUlhfd", MergeNone, "aarch64_sve_ld1ro">;
-}
-let ArchGuard = "defined(__ARM_FEATURE_SVE_MATMUL_FP64) && defined(__ARM_FEATURE_SVE_BF16)" in {
-  def SVLD1RO_BF16 : SInst<"svld1ro[_{2}]", "dPc", "b", MergeNone, "aarch64_sve_ld1ro">;
-}
+defm SVLD1RO : SInstBF16<"svld1ro[_{2}]", "dPc", "csilUcUsUiUlhfd", MergeNone, "aarch64_sve_ld1ro", [], [], ["__ARM_FEATURE_SVE_MATMUL_FP64"]>;
 
 let ArchGuard = "defined(__ARM_FEATURE_SVE_BF16)" in {
   def SVBFDOT: SInst<"svbfdot[_{0}]","MMdd",  "b", MergeNone, "aarch64_sve_bfdot",[IsOverloadNone]>;
@@ -1170,36 +1181,24 @@
 // instruction's immediate.
 def SVDUP_LANE   : SInst<"svdup_lane[_{d}]",  "ddL",  "csilUcUsUiUlhfd", MergeNone, "aarch64_sve_tbl">;
 def SVDUPQ_LANE  : SInst<"svdupq_lane[_{d}]", "ddn",  "csilUcUsUiUlhfd", MergeNone, "aarch64_sve_dupq_lane">;
-def SVEXT: SInst<"svext[_{d}]",   "dddi", "csilUcUsUiUlhfd", MergeNone, "aarch64_sve_ext", [], [ImmCheck<2, ImmCheckExtract, 1>]>;
 def SVLASTA  : SInst<"svlasta[_{d}]", "sPd",  "csilUcUsUiUlhfd", MergeNone, "aarch64_sve_lasta">;
 def SVLASTB  : SInst<"svlastb[_{d}]", "sPd",  "csilUcUsUiUlhfd", MergeNone, "aarch64_sve_lastb">;
-def SVREV: SInst<"svrev[_{d}]",   "dd",   "csilUcUsUiUlhfd", MergeNone, "aarch64_sve_rev">;
-def SVSEL: SInst<"svsel[_{d}]",   "dPdd", "csilUcUsUiUlhfd", MergeNone, "aarch64_sve_sel">;
-def SVSPLICE : SInst<"svsplice[_{d}]","dPdd", "csilUcUsUiUlhfd", MergeNone, "aarch64_sve_splice">;
 def SVTBL: SInst<"svtbl[_{d}]",   "ddu",  "csilUcUsUiUlhfd", MergeNone, "aarch64_sve_tbl">;
-def SVTRN1   : SInst<"svtrn1[_{d}]",  "ddd",  "csilUcUsUiUlhfd", MergeNone, "aarch64_sve_trn1">;
-def SVTRN2   : SInst<"svtrn2[_{d}]",  "ddd",  "csilUcUsUiUlhfd", MergeNone, "aarch64_sve_trn2">;
 def SVUNPKHI_S   : SInst<"svunpkhi[_{d}]","dh",   "sil", MergeNone, "aarch64_sve_sunpkhi">;
 def SVUNPKHI_U   : SInst<"svunpkhi[_{d}]","dh",   "UsUiUl",  MergeNone, "aarch64_sve_uunpkhi">;
 def SVUNPKLO_S   : SInst<"svunpklo[_{d}]","dh",   "sil", MergeNone, "aarch64_sve_sunpklo">;
 def SVUNPKLO_U   : SInst<"svunpklo[_{d}]","dh",   "UsUiUl",  MergeNone, "aarch64_sve_uunpklo">;
-def SVUZP1   : SInst<"svuzp1[_{d}]",  "ddd",  "csilUcUsUiUlhfd", MergeNone, "aarch64_sve_uzp1">;
-def SVUZP2   : SInst<"svuzp2[_{d}]",  "ddd",  "csilUcUsUiUlhfd", MergeNone, "aarch64_sve_uzp2">;
-def SVZIP1   

[PATCH] D82445: [analyzer][solver] Track symbol equivalence

2020-06-24 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

I only checked the test cases and the comments so far and it looks very useful 
and promising. I really hope that the performance will be ok :) I'll look at 
the actual code changes later.




Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:425
+///
+///   * "Merge (or Union) operation" merges two classes into one.  It is the
+/// main operation to produce non-trivial classes.

I found the mention of union confusing here. Especially since merging means 
intersection in terms of the ranges. I think I know what you meant but some 
additional clarification is welcome.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82445



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


[PATCH] D71739: [AssumeBundles] Use operand bundles to encode alignment assumptions

2020-06-24 Thread Tyker via Phabricator via cfe-commits
Tyker updated this revision to Diff 272968.
Tyker marked 2 inline comments as done.
Tyker added a comment.

addressed comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71739

Files:
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/test/CodeGen/align_value.cpp
  clang/test/CodeGen/alloc-align-attr.c
  clang/test/CodeGen/assume-aligned-and-alloc-align-attributes.c
  clang/test/CodeGen/builtin-align-array.c
  clang/test/CodeGen/builtin-align.c
  clang/test/CodeGen/builtin-assume-aligned.c
  
clang/test/CodeGen/catch-alignment-assumption-attribute-align_value-on-lvalue.cpp
  
clang/test/CodeGen/catch-alignment-assumption-attribute-align_value-on-paramvar.cpp
  
clang/test/CodeGen/catch-alignment-assumption-attribute-alloc_align-on-function-variable.cpp
  
clang/test/CodeGen/catch-alignment-assumption-attribute-alloc_align-on-function.cpp
  
clang/test/CodeGen/catch-alignment-assumption-attribute-assume_aligned-on-function-two-params.cpp
  
clang/test/CodeGen/catch-alignment-assumption-attribute-assume_aligned-on-function.cpp
  
clang/test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-three-params-variable.cpp
  
clang/test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-three-params.cpp
  
clang/test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-two-params.cpp
  clang/test/CodeGen/catch-alignment-assumption-openmp.cpp
  clang/test/CodeGen/non-power-of-2-alignment-assumptions.c
  clang/test/OpenMP/simd_codegen.cpp
  clang/test/OpenMP/simd_metadata.c
  clang/test/OpenMP/target_teams_distribute_parallel_for_simd_codegen.cpp
  llvm/include/llvm/IR/IRBuilder.h
  llvm/lib/Analysis/AssumeBundleQueries.cpp
  llvm/lib/IR/IRBuilder.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
  llvm/lib/Transforms/Scalar/AlignmentFromAssumptions.cpp
  llvm/test/Transforms/AlignmentFromAssumptions/simple.ll
  llvm/test/Transforms/AlignmentFromAssumptions/simple32.ll
  llvm/test/Transforms/Inline/align.ll
  llvm/test/Transforms/InstCombine/assume.ll
  llvm/test/Transforms/PhaseOrdering/inlining-alignment-assumptions.ll
  llvm/test/Verifier/assume-bundles.ll
  llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp

Index: llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp
===
--- llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp
+++ llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp
@@ -546,3 +546,41 @@
   ASSERT_EQ(AR[0].Index, 1u);
   ASSERT_EQ(AR[0].Assume, &*First);
 }
+
+TEST(AssumeQueryAPI, Alignment) {
+  LLVMContext C;
+  SMDiagnostic Err;
+  std::unique_ptr Mod = parseAssemblyString(
+  "declare void @llvm.assume(i1)\n"
+  "define void @test(i32* %P, i32* %P1, i32* %P2, i32 %I3, i1 %B) {\n"
+  "call void @llvm.assume(i1 true) [\"align\"(i32* %P, i32 8, i32 %I3)]\n"
+  "call void @llvm.assume(i1 true) [\"align\"(i32* %P1, i32 %I3, i32 "
+  "%I3)]\n"
+  "call void @llvm.assume(i1 true) [\"align\"(i32* %P2, i32 16, i32 8)]\n"
+  "ret void\n}\n",
+  Err, C);
+  if (!Mod)
+Err.print("AssumeQueryAPI", errs());
+
+  Function *F = Mod->getFunction("test");
+  BasicBlock::iterator Start = F->begin()->begin();
+  IntrinsicInst *II;
+  RetainedKnowledge RK;
+  II = cast(&*Start);
+  RK = getKnowledgeFromBundle(*II, II->bundle_op_info_begin()[0]);
+  ASSERT_EQ(RK.AttrKind, Attribute::Alignment);
+  ASSERT_EQ(RK.WasOn, F->getArg(0));
+  ASSERT_EQ(RK.ArgValue, 1u);
+  Start++;
+  II = cast(&*Start);
+  RK = getKnowledgeFromBundle(*II, II->bundle_op_info_begin()[0]);
+  ASSERT_EQ(RK.AttrKind, Attribute::Alignment);
+  ASSERT_EQ(RK.WasOn, F->getArg(1));
+  ASSERT_EQ(RK.ArgValue, 1u);
+  Start++;
+  II = cast(&*Start);
+  RK = getKnowledgeFromBundle(*II, II->bundle_op_info_begin()[0]);
+  ASSERT_EQ(RK.AttrKind, Attribute::Alignment);
+  ASSERT_EQ(RK.WasOn, F->getArg(2));
+  ASSERT_EQ(RK.ArgValue, 8u);
+}
Index: llvm/test/Verifier/assume-bundles.ll
===
--- llvm/test/Verifier/assume-bundles.ll
+++ llvm/test/Verifier/assume-bundles.ll
@@ -1,3 +1,4 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
 ; RUN: not opt -verify < %s 2>&1 | FileCheck %s
 
 declare void @llvm.assume(i1)
@@ -6,14 +7,21 @@
 ; CHECK: tags must be valid attribute names
   call void @llvm.assume(i1 true) ["adazdazd"()]
 ; CHECK: the second argument should be a constant integral value
-  call void @llvm.assume(i1 true) ["align"(i32* %P, i32 %P1)]
+  call void @llvm.assume(i1 true) ["dereferenceable"(i32* %P, i32 %P1)]
 ; CHECK: to many arguments
-  call void @llvm.assume(i1 true) ["align"(i32* %P, i32 8, i32 8)]
+  call void @llvm.assume(i1 true) ["dereferenceable"(i32* %P, i32 8, i32 8)]
 ; CHECK: this attribute should have 2 arguments
-  call void @llvm.assume(i1 true) ["align"(i32* %P)]
+  call void @llvm.assume(i1 true) ["dere

[PATCH] D80279: [libclang] Extend clang_Cursor_Evaluate().

2020-06-24 Thread Florian Hahn via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG72131423cc95: [libclang] Extend clang_Cursor_Evaluate(). 
(authored by ckandeler, committed by fhahn).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80279

Files:
  clang/include/clang-c/Index.h
  clang/test/Index/evaluate-cursor.cpp
  clang/tools/libclang/CIndex.cpp


Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -4056,10 +4056,14 @@
 }
 
 CXEvalResult clang_Cursor_Evaluate(CXCursor C) {
-  if (const Expr *E =
-  clang_getCursorKind(C) == CXCursor_CompoundStmt
-  ? evaluateCompoundStmtExpr(cast(getCursorStmt(C)))
-  : evaluateDeclExpr(getCursorDecl(C)))
+  const Expr *E = nullptr;
+  if (clang_getCursorKind(C) == CXCursor_CompoundStmt)
+E = evaluateCompoundStmtExpr(cast(getCursorStmt(C)));
+  else if (clang_isDeclaration(C.kind))
+E = evaluateDeclExpr(getCursorDecl(C));
+  else if (clang_isExpression(C.kind))
+E = getCursorExpr(C);
+  if (E)
 return const_cast(
 reinterpret_cast(evaluateExpr(const_cast(E), 
C)));
   return nullptr;
Index: clang/test/Index/evaluate-cursor.cpp
===
--- clang/test/Index/evaluate-cursor.cpp
+++ clang/test/Index/evaluate-cursor.cpp
@@ -26,6 +26,9 @@
   static const auto g = alignof(f);
 };
 
+constexpr static int calc_val() { return 1 + 2; }
+const auto the_value = calc_val() + sizeof(char);
+
 // RUN: c-index-test -evaluate-cursor-at=%s:4:7 \
 // RUN:-evaluate-cursor-at=%s:8:7 \
 // RUN:-evaluate-cursor-at=%s:8:11 -std=c++11 %s | FileCheck %s
@@ -53,3 +56,12 @@
 // RUN:-evaluate-cursor-at=%s:26:21 \
 // RUN:-std=c++11 %s | FileCheck -check-prefix=CHECK-DOES-NOT-CRASH %s
 // CHECK-DOES-NOT-CRASH: Not Evaluatable
+
+// RUN: c-index-test -evaluate-cursor-at=%s:30:1 \
+// RUN:-evaluate-cursor-at=%s:30:32 \
+// RUN:-evaluate-cursor-at=%s:30:35 \
+// RUN:-evaluate-cursor-at=%s:30:37 -std=c++11 %s | FileCheck %s 
-check-prefix=CHECK-EXPR
+// CHECK-EXPR: unsigned, Value: 4
+// CHECK-EXPR: Value: 3
+// CHECK-EXPR: unsigned, Value: 4
+// CHECK-EXPR: unsigned, Value: 1
Index: clang/include/clang-c/Index.h
===
--- clang/include/clang-c/Index.h
+++ clang/include/clang-c/Index.h
@@ -5934,6 +5934,7 @@
  * If cursor is a statement declaration tries to evaluate the
  * statement and if its variable, tries to evaluate its initializer,
  * into its corresponding type.
+ * If it's an expression, tries to evaluate the expression.
  */
 CINDEX_LINKAGE CXEvalResult clang_Cursor_Evaluate(CXCursor C);
 


Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -4056,10 +4056,14 @@
 }
 
 CXEvalResult clang_Cursor_Evaluate(CXCursor C) {
-  if (const Expr *E =
-  clang_getCursorKind(C) == CXCursor_CompoundStmt
-  ? evaluateCompoundStmtExpr(cast(getCursorStmt(C)))
-  : evaluateDeclExpr(getCursorDecl(C)))
+  const Expr *E = nullptr;
+  if (clang_getCursorKind(C) == CXCursor_CompoundStmt)
+E = evaluateCompoundStmtExpr(cast(getCursorStmt(C)));
+  else if (clang_isDeclaration(C.kind))
+E = evaluateDeclExpr(getCursorDecl(C));
+  else if (clang_isExpression(C.kind))
+E = getCursorExpr(C);
+  if (E)
 return const_cast(
 reinterpret_cast(evaluateExpr(const_cast(E), C)));
   return nullptr;
Index: clang/test/Index/evaluate-cursor.cpp
===
--- clang/test/Index/evaluate-cursor.cpp
+++ clang/test/Index/evaluate-cursor.cpp
@@ -26,6 +26,9 @@
   static const auto g = alignof(f);
 };
 
+constexpr static int calc_val() { return 1 + 2; }
+const auto the_value = calc_val() + sizeof(char);
+
 // RUN: c-index-test -evaluate-cursor-at=%s:4:7 \
 // RUN:-evaluate-cursor-at=%s:8:7 \
 // RUN:-evaluate-cursor-at=%s:8:11 -std=c++11 %s | FileCheck %s
@@ -53,3 +56,12 @@
 // RUN:-evaluate-cursor-at=%s:26:21 \
 // RUN:-std=c++11 %s | FileCheck -check-prefix=CHECK-DOES-NOT-CRASH %s
 // CHECK-DOES-NOT-CRASH: Not Evaluatable
+
+// RUN: c-index-test -evaluate-cursor-at=%s:30:1 \
+// RUN:-evaluate-cursor-at=%s:30:32 \
+// RUN:-evaluate-cursor-at=%s:30:35 \
+// RUN:-evaluate-cursor-at=%s:30:37 -std=c++11 %s | FileCheck %s -check-prefix=CHECK-EXPR
+// CHECK-EXPR: unsigned, Value: 4
+// CHECK-EXPR: Value: 3
+// CHECK-EXPR: unsigned, Value: 4
+// CHECK-EXPR: unsigned, Value: 1
Index: clang/include/clang-c/Index.h
===
--- clang/include/clang-c/Index.h
+++ clang/include/clang-c/Index.h
@@ -5934,6 +59

[PATCH] D82199: [clang-format] restore indent in conditionals when AlignOperands is DontAlign

2020-06-24 Thread Krasimir Georgiev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0fad648b65b9: [clang-format] restore indent in conditionals 
when AlignOperands is DontAlign (authored by krasimir).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82199

Files:
  clang/lib/Format/ContinuationIndenter.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -6281,6 +6281,17 @@
"   : bbb ? \n"
" : ;",
Style);
+
+  Style.AlignOperands = FormatStyle::OAS_DontAlign;
+  Style.BreakBeforeTernaryOperators = false;
+  // FIXME: Aligning the question marks is weird given DontAlign.
+  // Consider disabling this alignment in this case. Also check whether this
+  // will render the adjustment from https://reviews.llvm.org/D82199
+  // unnecessary.
+  verifyFormat("int x = aaa ? aa :\n"
+   "? cc :\n"
+   "  d;\n",
+   Style);
 }
 
 TEST_F(FormatTest, BreaksConditionalExpressionsAfterOperator) {
Index: clang/lib/Format/ContinuationIndenter.cpp
===
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -1041,8 +1041,10 @@
   //* not remove the 'lead' ContinuationIndentWidth
   //* always un-indent by the operator when
   //BreakBeforeTernaryOperators=true
-  unsigned Indent =
-  State.Stack.back().Indent - Style.ContinuationIndentWidth;
+  unsigned Indent = State.Stack.back().Indent;
+  if (Style.AlignOperands != FormatStyle::OAS_DontAlign) {
+Indent -= Style.ContinuationIndentWidth;
+  }
   if (Style.BreakBeforeTernaryOperators &&
   State.Stack.back().UnindentOperator)
 Indent -= 2;


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -6281,6 +6281,17 @@
"   : bbb ? \n"
" : ;",
Style);
+
+  Style.AlignOperands = FormatStyle::OAS_DontAlign;
+  Style.BreakBeforeTernaryOperators = false;
+  // FIXME: Aligning the question marks is weird given DontAlign.
+  // Consider disabling this alignment in this case. Also check whether this
+  // will render the adjustment from https://reviews.llvm.org/D82199
+  // unnecessary.
+  verifyFormat("int x = aaa ? aa :\n"
+   "? cc :\n"
+   "  d;\n",
+   Style);
 }
 
 TEST_F(FormatTest, BreaksConditionalExpressionsAfterOperator) {
Index: clang/lib/Format/ContinuationIndenter.cpp
===
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -1041,8 +1041,10 @@
   //* not remove the 'lead' ContinuationIndentWidth
   //* always un-indent by the operator when
   //BreakBeforeTernaryOperators=true
-  unsigned Indent =
-  State.Stack.back().Indent - Style.ContinuationIndentWidth;
+  unsigned Indent = State.Stack.back().Indent;
+  if (Style.AlignOperands != FormatStyle::OAS_DontAlign) {
+Indent -= Style.ContinuationIndentWidth;
+  }
   if (Style.BreakBeforeTernaryOperators &&
   State.Stack.back().UnindentOperator)
 Indent -= 2;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 2ace693 - Don't install clang-import-test

2020-06-24 Thread Alex Richardson via cfe-commits

Author: Alex Richardson
Date: 2020-06-24T12:24:43+01:00
New Revision: 2ace69339ffe3d3432b1fb930f51b490bb8856c8

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

LOG: Don't install clang-import-test

I have been trying to reduce the installed size of our CHERI toolchain and
noticed that this tool was being installed even with 
-DLLVM_INSTALL_TOOLCHAIN_ONLY=ON.
This appears to be a test binary that should not be installed.

Reviewed By: v.g.vassilev
Differential Revision: https://reviews.llvm.org/D82169

Added: 


Modified: 
clang/tools/clang-import-test/CMakeLists.txt

Removed: 




diff  --git a/clang/tools/clang-import-test/CMakeLists.txt 
b/clang/tools/clang-import-test/CMakeLists.txt
index 39a5c41c1512..4ccc2d752aac 100644
--- a/clang/tools/clang-import-test/CMakeLists.txt
+++ b/clang/tools/clang-import-test/CMakeLists.txt
@@ -7,7 +7,7 @@ if(NOT CLANG_BUILT_STANDALONE)
   set(tablegen_deps intrinsics_gen)
 endif()
 
-add_clang_tool(clang-import-test
+add_clang_executable(clang-import-test
   clang-import-test.cpp
   DEPENDS
   ${tablegen_deps}



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


[PATCH] D82381: [analyzer] Introduce small improvements to the solver infra

2020-06-24 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko marked an inline comment as done.
vsavchenko added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:467-470
+/// Available representations for the arguments are:
+///   * RangeSet
+///   * Optional
+///   * RangeSet *

xazax.hun wrote:
> NoQ wrote:
> > Why do we have these representations in the first place?
> > 
> > It sounds like you're treating null pointers / empty optionals equivalently 
> > to full ranges (i.e., intersecting with them has no effect). How hard would 
> > it be to simply construct an actual full range in all the places in which 
> > we currently have empty optionals?
> +1
> 
> I also find this confusing. Should I interpret a None as a full or empty 
> range? Does this depend on the context or a general rule? Is there any reason 
> we need to handle nullable pointers or could we actually make call sites more 
> uniform to get rid of some of the complexity here?
> It sounds like you're treating null pointers / empty optionals equivalently 
> to full ranges (i.e., intersecting with them has no effect)
It is not actually true.  Empty optionals is the information that "this range 
information is not available for this symbol".  It is true that intersecting 
with them has no effect, but they are semantically different in other aspects.  

Currently solver RELIES on the information that whether the range is available 
or not (see my previous comment), and we simply couldn't get rid of this 
behavior as part of NFC.

> How hard would it be to simply construct an actual full range in all the 
> places in which we currently have empty optionals?
It is not hard architecturally, but it WILL make the change functional and 
possibly impact the performance.

> Should I interpret a None as a full or empty range?
Neither of those.  That is the problem right now, that we rely on different 
sources of information for the ranges and behave differently depending on 
whether one piece of information is available or not.

> Does this depend on the context or a general rule?
Semantics are always the same - this info is not available.

> Is there any reason we need to handle nullable pointers?
`State->get(abc)` returns a nullable pointer meaning optional object, it 
is hard to avoid it especially because we currently behave very differently 
when this information is not available.

> ...could we actually make call sites more uniform to get rid of some of the 
> complexity here?
Yes we can, but later on. See the explanations above and in my other comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82381



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


[PATCH] D71339: [VE,#2] Clang toolchain for SX-Aurora

2020-06-24 Thread Simon Moll via Phabricator via cfe-commits
simoll abandoned this revision.
simoll added a comment.

Basic Clang support for VE is now upstream: rG96d4ccf0 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71339



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


[PATCH] D82386: [clangd] Config: Fragments and parsing from YAML

2020-06-24 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/ConfigYAML.cpp:29
+  llvm::SourceMgr &SM;
+  llvm::SmallString<256> Buf;
+

a comment for this buf, especially the reason why it's a member rather than a 
function-local when needed. (I suppose to get rid of const/dest penalties?)



Comment at: clang-tools-extra/clangd/ConfigYAML.cpp:40
+Dict.handle("If", [&](Node &N) {
+  F.Condition.emplace();
+  return parse(*F.Condition, N);

It is a little bit subtle that "at most once" execution of this handler is 
assured by DictParser. Can we put some comments explaining it to either 
DictParser itself or to `handle` member ?



Comment at: clang-tools-extra/clangd/ConfigYAML.cpp:74
+llvm::StringRef Description;
+std::vector>> Keys;
+std::function Unknown;

maybe a comment for these two, suggesting the latter is used for unknown keys.

and also mention it is handlers responsibility emit any diagnostics in case of 
failures?



Comment at: clang-tools-extra/clangd/ConfigYAML.cpp:84
+void handle(llvm::StringLiteral Key, std::function Parse) {
+  Keys.emplace_back(Key, std::move(Parse));
+}

maybe assert on duplicate keys in debug builds?



Comment at: clang-tools-extra/clangd/ConfigYAML.cpp:100
+if (!K)
+  return false;
+auto Key = Outer->scalarValue(*K, "Dictionary key");

i suppose yamlparser has already emitted a diagnostic by then ? can you add a 
comment about it if that's the case.

and if not, shouldn't we emit something about a broken stream?

same goes for `KV.getValue()` below.



Comment at: clang-tools-extra/clangd/ConfigYAML.cpp:105
+if (!Seen.insert(**Key).second) {
+  Outer->warning("Duplicate key " + **Key, *K);
+  continue;

maybe `Ignoring duplicate key` instead of just `Duplicate key` ?



Comment at: clang-tools-extra/clangd/ConfigYAML.cpp:136
+else if (auto *BS = llvm::dyn_cast(&N))
+  return Located(S->getValue(Buf).str(), N.getSourceRange());
+warning(Desc + " should be scalar", N);

s/S->getValue(Buf)/BS->getValue()/  (or change `auto *BS` to `auto *S`)

and a test



Comment at: clang-tools-extra/clangd/ConfigYAML.cpp:150
+  for (auto &Child : *S) {
+if (auto Value = scalarValue(Child, "List item"))
+  Result.push_back(std::move(*Value));

shouldn't we error/warn out if not ?



Comment at: clang-tools-extra/clangd/ConfigYAML.cpp:161
+  // Report a "hard" error, reflecting a config file that can never be valid.
+  bool error(const llvm::Twine &Msg, const Node &N) {
+SM.PrintMessage(N.getSourceRange().Start, llvm::SourceMgr::DK_Error, Msg,

do we really want to return a boolean here (and not at the warning ?)

I can see that it's nice to `return error("xxx")` but it looks surprising as we 
are not returning the error but just false.
I would make this void, up to you though.



Comment at: clang-tools-extra/clangd/ConfigYAML.cpp:202
+  // SM has two entries: "main" non-owning buffer, and ignored owning buffer.
+  SM->AddNewSourceBuffer(std::move(Buf), llvm::SMLoc());
+  return Result;

*sigh*

what a mess, Scanner in YamlParser already adds this buffer. It is unclear why 
though, as it adds a non-owning buffer and that buffer is never accessed.  
(well apart from SMLoc to Buffer conversions when emitting diags)
It rather makes use of pointers to the underlying data, obtained before adding 
that buffer. So it is the caller keeping the data alive anyways.

should we consider having an entry point that takes an SMLoc and a SourceMgr 
for `yaml::Stream` instead of this? That way we can add the owning entry to 
sourcemanager and start the stream at beginning of that buffer.

i am afraid this might bite us in the future, as SM is exposed publicly and one 
might try to iterate over buffers, which might come as a shock. we can postpone 
until that happens though, so feel free to leave it as it is.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82386



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


[PATCH] D82445: [analyzer][solver] Track symbol equivalence

2020-06-24 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko marked an inline comment as done.
vsavchenko added a comment.

>   I really hope that the performance will be ok :)

I had a test run for one of the earlier implementations of this and it looks 
like it adds 1-2% to the execution time.  And of course I will attach more info 
on that later.

Additionally, I have a couple of disappeared FPs concerning reference counting, 
that I still need to figure out.




Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:425
+///
+///   * "Merge (or Union) operation" merges two classes into one.  It is the
+/// main operation to produce non-trivial classes.

xazax.hun wrote:
> I found the mention of union confusing here. Especially since merging means 
> intersection in terms of the ranges. I think I know what you meant but some 
> additional clarification is welcome.
Gotcha, I guess I'll add parallels with the Union-Find data structure in the 
implementation and make it more transparent.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82445



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


[PATCH] D82185: [Analyzer] Handle pointer implemented as iterators in iterator checkers

2020-06-24 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 272973.
baloghadamsoftware added a comment.

Updated according to the comments.


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

https://reviews.llvm.org/D82185

Files:
  clang/lib/StaticAnalyzer/Checkers/InvalidatedIteratorChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/Iterator.cpp
  clang/lib/StaticAnalyzer/Checkers/Iterator.h
  clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
  clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/MismatchedIteratorChecker.cpp
  clang/test/Analysis/invalidated-iterator.cpp
  clang/test/Analysis/iterator-modeling.cpp
  clang/test/Analysis/iterator-range.cpp
  clang/test/Analysis/mismatched-iterator.cpp

Index: clang/test/Analysis/mismatched-iterator.cpp
===
--- clang/test/Analysis/mismatched-iterator.cpp
+++ clang/test/Analysis/mismatched-iterator.cpp
@@ -118,3 +118,15 @@
 
   if (V1.cbegin() == V2.cbegin()) {} //no-warning
 }
+
+template
+struct cont_with_ptr_iterator {
+  T *begin() const;
+  T *end() const;
+};
+
+void comparison_ptr_iterator(cont_with_ptr_iterator &C1,
+ cont_with_ptr_iterator &C2) {
+  if (C1.begin() != C2.end()) {} // expected-warning{{Iterators of different containers used where the same container is expected}}
+}
+
Index: clang/test/Analysis/iterator-range.cpp
===
--- clang/test/Analysis/iterator-range.cpp
+++ clang/test/Analysis/iterator-range.cpp
@@ -854,3 +854,84 @@
   *i; // expected-warning{{Past-the-end iterator dereferenced}}
   // expected-note@-1{{Past-the-end iterator dereferenced}}
 }
+
+template
+struct cont_with_ptr_iterator {
+  T* begin() const;
+  T* end() const;
+};
+
+void deref_end_ptr_iterator(const cont_with_ptr_iterator &c) {
+  auto i = c.end();
+  (void) *i; // expected-warning{{Past-the-end iterator dereferenced}}
+ // expected-note@-1{{Past-the-end iterator dereferenced}}
+}
+
+void array_deref_end_ptr_iterator(const cont_with_ptr_iterator &c) {
+  auto i = c.end();
+  (void) i[0]; // expected-warning{{Past-the-end iterator dereferenced}}
+   // expected-note@-1{{Past-the-end iterator dereferenced}}
+}
+
+void arrow_deref_end_ptr_iterator(const cont_with_ptr_iterator &c) {
+  auto i = c.end();
+  (void) i->n; // expected-warning{{Past-the-end iterator dereferenced}}
+   // expected-note@-1{{Past-the-end iterator dereferenced}}
+}
+
+void arrow_star_deref_end_ptr_iterator(const cont_with_ptr_iterator &c,
+   int S::*p) {
+  auto i = c.end();
+  (void)(i->*p); // expected-warning{{Past-the-end iterator dereferenced}}
+ // expected-note@-1{{Past-the-end iterator dereferenced}}
+}
+
+void prefix_incr_end_ptr_iterator(const cont_with_ptr_iterator &c) {
+  auto i = c.end();
+  ++i; // expected-warning{{Iterator incremented behind the past-the-end iterator}}
+   // expected-note@-1{{Iterator incremented behind the past-the-end iterator}}
+}
+
+void postfix_incr_end_ptr_iterator(const cont_with_ptr_iterator &c) {
+  auto i = c.end();
+  i++; // expected-warning{{Iterator incremented behind the past-the-end iterator}}
+   // expected-note@-1{{Iterator incremented behind the past-the-end iterator}}
+}
+
+void prefix_decr_begin_ptr_iterator(const cont_with_ptr_iterator &c) {
+  auto i = c.begin();
+  --i; // expected-warning{{Iterator decremented ahead of its valid range}}
+   // expected-note@-1{{Iterator decremented ahead of its valid range}}
+}
+
+void postfix_decr_begin_ptr_iterator(const cont_with_ptr_iterator &c) {
+  auto i = c.begin();
+  i--; // expected-warning{{Iterator decremented ahead of its valid range}}
+   // expected-note@-1{{Iterator decremented ahead of its valid range}}
+}
+
+void prefix_add_2_end_ptr_iterator(const cont_with_ptr_iterator &c) {
+  auto i = c.end();
+  (void)(i + 2); // expected-warning{{Iterator incremented behind the past-the-end iterator}}
+ // expected-note@-1{{Iterator incremented behind the past-the-end iterator}}
+}
+
+void postfix_add_assign_2_end_ptr_iterator(const cont_with_ptr_iterator &c) {
+  auto i = c.end();
+  i += 2; // expected-warning{{Iterator incremented behind the past-the-end iterator}}
+  // expected-note@-1{{Iterator incremented behind the past-the-end iterator}}
+}
+
+void prefix_minus_2_begin_ptr_iterator(const cont_with_ptr_iterator &c) {
+  auto i = c.begin();
+  (void)(i - 2); // expected-warning{{Iterator decremented ahead of its valid range}}
+ // expected-note@-1{{Iterator decremented ahead of its valid range}}
+}
+
+void postfix_minus_assign_2_begin_ptr_iterator(
+const cont_with_ptr_iterator &c) {
+  auto i = c.begin();
+  i -= 2; // expected-warning{{Iterator decremented ahead of its valid range}}
+  // expected-note@-1{{Iterator decrem

[PATCH] D82288: [analyzer][StdLibraryFunctionsChecker] Add POSIX file handling functions

2020-06-24 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

I see a lot of `NoEvalCall`, but I wonder whether modifying `errno` warrants 
this. Shouldn't we have a alongside `NoEvalCall` and `EvalCallAsPure` an 
`EvalCallAsPureButInvalidateErrno` invalidation kind?

Also, I'm kind of worried by this checker taking on the responsibility of 
modeling functions by `EvalCall`, except for a few functions that it also 
models, but not with `EvalCall`, it feels clunky. I remember this one time when 
I wanted to model `alloca()` 
, which has a 
`__builtin_alloca` variant as well, and I spent a good couple hours figuring 
out that why the descpription `{CDF_MaybeBuiltin, "alloca", 1}` was causing 
crashes. Turns out that `BuiltinFunctionsChecker` `EvalCall`ed the builtin 
version, but not the other.

In general, I don't think we have a well established stance on whether we use 
`EvalCall`, or `PreCall`+`PostCall`, and what roles do batch modeling checkers 
like `StdLibraryFunctionsChecker`, `GenericTaintChecker` and 
`BuiltinFunctionsChecker` should play alongside mode sophisticated modeling 
checkers like `CStringModeling`, `DynamicMemoryModeling` and `StreamChecker`. I 
bet some of us have ideas how this is supposed to be done, but I feel like 
there is no unified, agreed upon road we're moving towards. This problem came 
up in D69662  as well. D75612 
 introduces `EvalCall`s to `StreamChecker`, 
and I was puzzled why this hasn't been a thing in all similar chekers like 
`MallocChecker`, which I commented on in D81315#2079457 
.

It would also be great if we could enforce that no two checkers evaluate the 
same function.

None of what I said is a problem introduced by this specific patch, but it 
definitely amplifies it with the modeling of functions such as `strncasecmp` 
(should be the responsibility of `CStringModeling`), `strdup` (`MallocChecker`) 
and `popen` (`StreamChecker`). I'd like to see something set in stone, such as 
what you're eluding to in D75612#inline-690087 
, that the role of this checker 
is to model **numerical** (null-ness, ranges, etc) pre- and post conditions for 
standard functions, nothing less, nothing more, and it is technically an error 
to reimplement this in other checkers. If that is the goal, I guess we have to 
implement tests for individual functions added in this patch to make sure that 
these conditions aren't already checked elsewhere.

I didn't read this patch line-by-line, but I trust that its okay if Endre did 
so.




Comment at: clang/include/clang/StaticAnalyzer/Checkers/Checkers.td:352-357
 CmdLineOption,

D78118#inline-723679 Please mark this `Hidden`.



Comment at: clang/include/clang/StaticAnalyzer/Checkers/Checkers.td:358-363
+CmdLineOption

I'm fine with not hiding this, but as a user, why would I never not enable it? 
If the reasoning is that this isn't ready quite yet, change `Released` to 
`InAlpha`. Otherwise, either mark this `Hidden` or give a user friendly 
explanation as to what is there to gain/lose by tinkering with this option.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82288



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


[PATCH] D82381: [analyzer] Introduce small improvements to the solver infra

2020-06-24 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko marked an inline comment as done.
vsavchenko added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:373
+  ++Upper;
+  --Lower;
+

xazax.hun wrote:
> Sorry if my question is dumb, but I do not really have a mental model at this 
> point about where do we actually handle types and overflows. Will this method 
> work when we delete the last or the first element of the full range of a type?
> 
> I think having unit tests would be a great way to make this clear. I always 
> felt that the solver is actually something that should be really easy to test 
> separately and those tests would also help a lot to understand how the solver 
> is actually working. 
> Sorry if my question is dumb...
No problem at all, I also had this question when I looked at that.

> where do we actually handle types and overflows
`APInt` class basically does it all for us in terms of overflows, number of 
bits, and signedness.

> I think having unit tests would be a great way to make this clear
I am onboard! I will add a framework for testing the solver in later patches.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82381



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


[PATCH] D82169: Don't install clang-import-test

2020-06-24 Thread Alexander Richardson via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2ace69339ffe: Don't install clang-import-test (authored 
by arichardson).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82169

Files:
  clang/tools/clang-import-test/CMakeLists.txt


Index: clang/tools/clang-import-test/CMakeLists.txt
===
--- clang/tools/clang-import-test/CMakeLists.txt
+++ clang/tools/clang-import-test/CMakeLists.txt
@@ -7,7 +7,7 @@
   set(tablegen_deps intrinsics_gen)
 endif()
 
-add_clang_tool(clang-import-test
+add_clang_executable(clang-import-test
   clang-import-test.cpp
   DEPENDS
   ${tablegen_deps}


Index: clang/tools/clang-import-test/CMakeLists.txt
===
--- clang/tools/clang-import-test/CMakeLists.txt
+++ clang/tools/clang-import-test/CMakeLists.txt
@@ -7,7 +7,7 @@
   set(tablegen_deps intrinsics_gen)
 endif()
 
-add_clang_tool(clang-import-test
+add_clang_executable(clang-import-test
   clang-import-test.cpp
   DEPENDS
   ${tablegen_deps}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82446: [clang] Fix duplicate warning

2020-06-24 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/Parse/ParseExprCXX.cpp:2273
   ParseSpecifierQualifierList(DS, AS_none, 
DeclSpecContext::DSC_type_specifier);
-  DS.Finish(Actions, Actions.getASTContext().getPrintingPolicy());
   return false;

This change is incorrect -- `Finish` is what ensures the `DeclSpec` is in a 
consistent state (even in the presence of errors), so removing it would be bad.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82446



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


[PATCH] D81769: [clang-tidy] Repair various issues with modernize-avoid-bind

2020-06-24 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D81769#2109936 , @jaafar wrote:

> One more simplification from Aaron. Thanks!


No problem! Do you need someone to commit on your behalf, btw? If so, let me 
know what name and email address you would like me to attribute.


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

https://reviews.llvm.org/D81769



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


[PATCH] D82182: [AArch64][SVE] Add bfloat16 support to perm and select intrinsics

2020-06-24 Thread Cullen Rhodes via Phabricator via cfe-commits
c-rhodes added inline comments.



Comment at: llvm/test/CodeGen/AArch64/sve-intrinsics-perm-select.ll:809
 
+define  @rev_bf16( %a) {
+; CHECK-LABEL: rev_bf16

sdesmalen wrote:
> Does this test not need the `+bf16` attribute to work? (which implies the 
> patterns are missing the right predicate)
It should do, sorry I missed that. I've tried:
```diff --git a/llvm/lib/Target/AArch64/SVEInstrFormats.td 
b/llvm/lib/Target/AArch64/SVEInstrFormats.td
index 46cca2a..5ab2502 100644
--- a/llvm/lib/Target/AArch64/SVEInstrFormats.td
+++ b/llvm/lib/Target/AArch64/SVEInstrFormats.td
@@ -1124,10 +1124,13 @@ multiclass sve_int_perm_reverse_z {
   def : SVE_1_Op_Pat(NAME # _S)>;
   def : SVE_1_Op_Pat(NAME # _D)>;

-  def : SVE_1_Op_Pat(NAME # _H)>;
   def : SVE_1_Op_Pat(NAME # _H)>;
   def : SVE_1_Op_Pat(NAME # _S)>;
   def : SVE_1_Op_Pat(NAME # _D)>;
+
+  let Predicates = [HasBF16] in {
+def : SVE_1_Op_Pat(NAME # _H)>;
+  }
 }```

but this still works without `+bf16`. I noticed in your patch D82187 you check 
`Subtarget->hasBF16()` for `MVT::nxv8bf16` at select phase of ISEL, I guess 
it's different here with patterns. I also noticed we add the register class for 
`MVT::nxv8bf16` in AArch64ISelLowering without checking `Subtarget->hasBF16()` 
which I suspect is a bug. This test requires `+bf16` with that fixed but I 
wonder why the predicate isn't being recognised.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82182



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


[PATCH] D82425: [SemaCXX] Fix false positive of -Wuninitialized-const-reference in empty function body.

2020-06-24 Thread Nikita Kniazev via Phabricator via cfe-commits
nick added a comment.

Thanks @zequanwu, much appreciated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82425



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


[PATCH] D82386: [clangd] Config: Fragments and parsing from YAML

2020-06-24 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

Thanks! Looks great, I've finally managed to finish all my iterations :D

Apart from the comments(IIRC which are mostly minor), it felt like there were a 
few lines that aren't clang-format'd. Please make sure to run clang-format on 
the files at some point.




Comment at: clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp:58
+  Out.Pos.character = D.getColumnNo(); // Zero-based - bug in SourceMgr?
+  if (!D.getRanges().empty()) {
+const auto &R = D.getRanges().front();

is there an explanation to what these ranges are ?

All I could find is somewhere in the implementation making sure these are 
relative to the `D.getLineNo` and nothing else :/



Comment at: clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp:73
+
+friend void PrintTo(const Diag &D, std::ostream *OS) { *OS << D.Message; }
+  };

why no print others ?

`Kind: D.Message @ Pos - Range`



Comment at: clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp:133
+  ASSERT_THAT(Diags.Diagnostics,
+  ElementsAre(DiagMessage("Unknown Condition key 
UnknownCondition"),
+  DiagMessage("Unexpected token. Expected Key, Flow "

i think having a full matcher(i.e with kind, pos and ranges) might be more 
expressive here, up to you though


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82386



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


[PATCH] D82373: [CodeComplete] Tweak code completion for `typename`

2020-06-24 Thread liu hui via Phabricator via cfe-commits
lh123 updated this revision to Diff 272994.
lh123 edited the summary of this revision.
lh123 added a comment.

address comment.
Also tweak  code completion behavior  for `using`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82373

Files:
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/test/CodeCompletion/ordinary-name-cxx11.cpp
  clang/test/CodeCompletion/ordinary-name.cpp

Index: clang/test/CodeCompletion/ordinary-name.cpp
===
--- clang/test/CodeCompletion/ordinary-name.cpp
+++ clang/test/CodeCompletion/ordinary-name.cpp
@@ -54,7 +54,7 @@
   // CHECK-CC1: COMPLETION: TYPEDEF : TYPEDEF
   // CHECK-CC1-NEXT: COMPLETION: Pattern : typedef <#type#> <#name#>;
   // CHECK-CC1-NEXT: COMPLETION: Pattern : [#std::type_info#]typeid(<#expression-or-type#>)
-  // CHECK-CC1-NEXT: COMPLETION: Pattern : typename <#qualifier#>::<#name#>
+  // CHECK-CC1-NEXT: COMPLETION: Pattern : typename <#name#>
   // CHECK-CC1-NEXT: COMPLETION: Pattern : typeof <#expression#>
   // CHECK-CC1-NEXT: COMPLETION: Pattern : typeof(<#type#>)
   // CHECK-CC1-NEXT: COMPLETION: union
@@ -97,12 +97,12 @@
   // CHECK-CC2-NEXT: COMPLETION: Pattern : template<<#parameters#>>
   // CHECK-CC2-NEXT: COMPLETION: TYPEDEF : TYPEDEF
   // CHECK-CC2-NEXT: COMPLETION: Pattern : typedef <#type#> <#name#>;
-  // CHECK-CC2-NEXT: COMPLETION: Pattern : typename <#qualifier#>::<#name#>
+  // CHECK-CC2-NEXT: COMPLETION: Pattern : typename <#name#>
   // CHECK-CC2-NEXT: COMPLETION: Pattern : typeof <#expression#>
   // CHECK-CC2-NEXT: COMPLETION: Pattern : typeof(<#type#>)
   // CHECK-CC2-NEXT: COMPLETION: union
   // CHECK-CC2-NEXT: COMPLETION: unsigned
-  // CHECK-CC2-NEXT: COMPLETION: Pattern : using <#qualifier#>::<#name#>;
+  // CHECK-CC2-NEXT: COMPLETION: Pattern : using <#name#>;
   // CHECK-CC2-NEXT: COMPLETION: Pattern : using namespace <#identifier#>;
   // CHECK-CC2-NEXT: COMPLETION: void
   // CHECK-CC2-NEXT: COMPLETION: volatile
@@ -134,12 +134,12 @@
   // CHECK-CC3-NEXT: COMPLETION: struct
   // CHECK-CC3-NEXT: COMPLETION: Pattern : template<<#parameters#>>
   // CHECK-CC3-NEXT: COMPLETION: Pattern : typedef <#type#> <#name#>;
-  // CHECK-CC3-NEXT: COMPLETION: Pattern : typename <#qualifier#>::<#name#>
+  // CHECK-CC3-NEXT: COMPLETION: Pattern : typename <#name#>
   // CHECK-CC3-NEXT: COMPLETION: Pattern : typeof <#expression#>
   // CHECK-CC3-NEXT: COMPLETION: Pattern : typeof(<#type#>)
   // CHECK-CC3-NEXT: COMPLETION: union
   // CHECK-CC3-NEXT: COMPLETION: unsigned
-  // CHECK-CC3-NEXT: COMPLETION: Pattern : using <#qualifier#>::<#name#>;
+  // CHECK-CC3-NEXT: COMPLETION: Pattern : using <#name#>;
   // CHECK-CC3-NEXT: COMPLETION: virtual
   // CHECK-CC3-NEXT: COMPLETION: void
   // CHECK-CC3-NEXT: COMPLETION: volatile
@@ -176,7 +176,7 @@
   // CHECK-CC4-NEXT: COMPLETION: Pattern : [#bool#]true
   // CHECK-CC4-NEXT: COMPLETION: TYPEDEF : TYPEDEF
   // CHECK-CC4-NEXT: COMPLETION: Pattern : [#std::type_info#]typeid(<#expression-or-type#>)
-  // CHECK-CC4-NEXT: COMPLETION: Pattern : typename <#qualifier#>::<#name#>
+  // CHECK-CC4-NEXT: COMPLETION: Pattern : typename <#name#>
   // CHECK-CC4-NEXT: COMPLETION: Pattern : typeof <#expression#>
   // CHECK-CC4-NEXT: COMPLETION: Pattern : typeof(<#type#>)
   // CHECK-CC4-NEXT: COMPLETION: union
@@ -227,7 +227,7 @@
   // CHECK-NO-RTTI: COMPLETION: TYPEDEF : TYPEDEF
   // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : typedef <#type#> <#name#>;
   // CHECK-NO-RTTI-NOT: typeid
-  // CHECK-NO-RTTI: COMPLETION: Pattern : typename <#qualifier#>::<#name#>
+  // CHECK-NO-RTTI: COMPLETION: Pattern : typename <#name#>
   // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : typeof <#expression#>
   // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : typeof(<#type#>)
   // CHECK-NO-RTTI-NEXT: COMPLETION: union
Index: clang/test/CodeCompletion/ordinary-name-cxx11.cpp
===
--- clang/test/CodeCompletion/ordinary-name-cxx11.cpp
+++ clang/test/CodeCompletion/ordinary-name-cxx11.cpp
@@ -57,7 +57,7 @@
   // CHECK-CC1: COMPLETION: TYPEDEF : TYPEDEF
   // CHECK-CC1-NEXT: COMPLETION: Pattern : typedef <#type#> <#name#>;
   // CHECK-CC1-NEXT: COMPLETION: Pattern : [#std::type_info#]typeid(<#expression-or-type#>)
-  // CHECK-CC1-NEXT: COMPLETION: Pattern : typename <#qualifier#>::<#name#>
+  // CHECK-CC1-NEXT: COMPLETION: Pattern : typename <#name#>
   // CHECK-CC1-NEXT: COMPLETION: Pattern : typeof <#expression#>
   // CHECK-CC1-NEXT: COMPLETION: Pattern : typeof(<#type#>)
   // CHECK-CC1-NEXT: COMPLETION: union
@@ -107,12 +107,12 @@
   // CHECK-CC2-NEXT: COMPLETION: thread_local
   // CHECK-CC2-NEXT: COMPLETION: TYPEDEF : TYPEDEF
   // CHECK-CC2-NEXT: COMPLETION: Pattern : typedef <#type#> <#name#>;
-  // CHECK-CC2-NEXT: COMPLETION: Pattern : typename <#qualifier#>::<#name#>
+  // CHECK-CC2-NEXT: COMPLETION: Pattern : typename <#name#>

[PATCH] D82450: [AArch64][SVE] Add multiclass for bfloat16 intrinsic definitions

2020-06-24 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen added inline comments.



Comment at: clang/include/clang/Basic/arm_sve.td:264
+ list arch_features = []> {
+  let ArchGuard = !foldl("", arch_features, lhs, rhs,
+ lhs # !if(!ne(lhs, ""), " && ", "") # rhs) in {

I'd rather see that we define ArchGuard as a list of strings, and then do a 
simple `!listconcat` for each of the features. Then we can do the expansion to 
the eventual `#if defined (pred1 && pred2 && ... predN)` in `SveEmitter.cpp`. 
There you can get the ArchGuard as a `std::vector`.

I also think the current implementation isn't correct, because it misses the 
encapsulating `defined(...)` ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82450



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


[PATCH] D76342: [OpenMP] Implement '#pragma omp tile'

2020-06-24 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/include/clang/AST/StmtOpenMP.h:4781-4784
+/// This represents the '#pragma omp tile' loop transformation directive.
+class OMPTileDirective final
+: public OMPLoopDirective,
+  private llvm::TrailingObjects {

Meinersbur wrote:
> ABataev wrote:
> > Meinersbur wrote:
> > > ABataev wrote:
> > > > Not sure that this is a good idea to treat this directive as the 
> > > > executable directive. To me, it looks like kind of `AttributedStmt`. 
> > > > Maybe better to introduce some kind of a new base node for this and 
> > > > similar constructs, which does not own the loop but is its kind of 
> > > > attribute-like entity?
> > > > Also, can we have something like:
> > > > ```
> > > > #pragma omp simd
> > > > #pragma omp tile ...
> > > > for(...) ;
> > > > ```
> > > > Thoughts?
> > > While not executed at runtime, syntactically it is parsed like a 
> > > executable (loop-associated) directive. IMHO it does 'own' the loop, but 
> > > produces another one for to be owned(/associated) by a different 
> > > directive, as in your tile/simd example, which should already work. 
> > > Allowing this was the motivation to do the transformation on the 
> > > AST-level for now.
> > I'm not saying that we should separate parsing of this directive from 
> > others, it is just better to treat this directive as a little bit different 
> > node. Currently, it introduces too many changes in the base classes. Better 
> > to create a new base class, that does not relies on `CapturedStmt` as the 
> > base, and derive `OMPExecutableDirective` and this directive and other 
> > similar (+ maybe, `OMPSimdDirective`) from this new base class.
> Unless you tell me otherwise, `OMPLoopDirective` represents a loop-associated 
> directive. `#pragma omp tile` is a loop-associated directive. 
> `OMPLoopDirective` contains all the functionality to parse associated loops, 
> and unfortunately if derived from `OMPExecutableDirective`.
> 
> You seem to ask me to create a new class 
> "OMPDirectiveAssociatedWithLoopButNotExecutable" that duplicates the parsing 
> part of "OMPLoopDirective"? This will either be a lot of duplicated code or 
> result in even more changes to the base classes due to the refactoring.
> 
> By the OpenMP specification, simd and tile are executable directives, so 
> structurally I think the class hierarchy as-is makes sense. From the glossary 
> of the upcoming OpenMP 5.1:
> > An OpenMP directive that appears in an executable context and results in 
> > implementation code and/or prescribes the manner in which associated user 
> > code must execute.
> 
> Avoiding a CapturedStmt when not needed would a modification of 
> `clang::getOpenMPCaptureRegions` which currently adds a capture of type 
> `OMPD_unknown` for such directives. This is unrelated to loop-associated 
> directives.
> 
No, this is not what I'm asking for. I asked you to think about adding a new 
level of abstraction somewhere between the `OMPLoop...` and 
`OMPExecutableDirective` classes to minimize the functional changes and make 
the classes more robust. Anyway, give me a week or so to try to find possible 
better abstractions and if there are no better ones, we'll proceed with your 
original solution. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76342



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


[PATCH] D80301: [yaml][clang-tidy] Fix multiline YAML serialization

2020-06-24 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin updated this revision to Diff 272996.
DmitryPolukhin added a comment.

Fix test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80301

Files:
  clang/include/clang/Tooling/ReplacementsYaml.h
  clang/unittests/Tooling/ReplacementsYamlTest.cpp
  llvm/include/llvm/Support/YAMLTraits.h
  llvm/lib/Support/YAMLTraits.cpp
  llvm/test/Transforms/LowerMatrixIntrinsics/remarks-shared-subtrees.ll
  llvm/unittests/Support/YAMLIOTest.cpp

Index: llvm/unittests/Support/YAMLIOTest.cpp
===
--- llvm/unittests/Support/YAMLIOTest.cpp
+++ llvm/unittests/Support/YAMLIOTest.cpp
@@ -285,10 +285,8 @@
 YOut << Original;
   }
   auto Expected = "---\n"
-  "str1:'a multiline string\n"
-  "foobarbaz'\n"
-  "str2:'another one\r"
-  "foobarbaz'\n"
+  "str1:\"a multiline string\\nfoobarbaz\"\n"
+  "str2:\"another one\\rfoobarbaz\"\n"
   "str3:a one-line string\n"
   "...\n";
   ASSERT_EQ(Serialized, Expected);
Index: llvm/test/Transforms/LowerMatrixIntrinsics/remarks-shared-subtrees.ll
===
--- llvm/test/Transforms/LowerMatrixIntrinsics/remarks-shared-subtrees.ll
+++ llvm/test/Transforms/LowerMatrixIntrinsics/remarks-shared-subtrees.ll
@@ -18,8 +18,7 @@
 ; YAML-NEXT:- String:  ' loads, '
 ; YAML-NEXT:- NumComputeOps:   '0'
 ; YAML-NEXT:- String:  ' compute ops'
-; YAML-NEXT:- String:  ',
-; YAML-NEXT:  additionally '
+; YAML-NEXT:- String:  ",\nadditionally "
 ; YAML-NEXT:- NumStores:   '0'
 ; YAML-NEXT:- String:  ' stores, '
 ; YAML-NEXT:- NumLoads:'4'
@@ -47,8 +46,7 @@
 ; YAML-NEXT:- String:  ' loads, '
 ; YAML-NEXT:- NumComputeOps:   '120'
 ; YAML-NEXT:- String:  ' compute ops'
-; YAML-NEXT:- String:  ',
-; YAML-NEXT:  additionally '
+; YAML-NEXT:- String:  ",\nadditionally "
 ; YAML-NEXT:- NumStores:   '0'
 ; YAML-NEXT:- String:  ' stores, '
 ; YAML-NEXT:- NumLoads:'4'
Index: llvm/lib/Support/YAMLTraits.cpp
===
--- llvm/lib/Support/YAMLTraits.cpp
+++ llvm/lib/Support/YAMLTraits.cpp
@@ -878,12 +878,12 @@
 }
 
 void ScalarTraits::output(const std::string &Val, void *,
- raw_ostream &Out) {
+   raw_ostream &Out) {
   Out << Val;
 }
 
 StringRef ScalarTraits::input(StringRef Scalar, void *,
- std::string &Val) {
+   std::string &Val) {
   Val = Scalar.str();
   return StringRef();
 }
Index: llvm/include/llvm/Support/YAMLTraits.h
===
--- llvm/include/llvm/Support/YAMLTraits.h
+++ llvm/include/llvm/Support/YAMLTraits.h
@@ -649,24 +649,25 @@
 inline QuotingType needsQuotes(StringRef S) {
   if (S.empty())
 return QuotingType::Single;
+
+  QuotingType MaxQuotingNeeded = QuotingType::None;
   if (isSpace(static_cast(S.front())) ||
   isSpace(static_cast(S.back(
-return QuotingType::Single;
+MaxQuotingNeeded = QuotingType::Single;
   if (isNull(S))
-return QuotingType::Single;
+MaxQuotingNeeded = QuotingType::Single;
   if (isBool(S))
-return QuotingType::Single;
+MaxQuotingNeeded = QuotingType::Single;
   if (isNumeric(S))
-return QuotingType::Single;
+MaxQuotingNeeded = QuotingType::Single;
 
   // 7.3.3 Plain Style
   // Plain scalars must not begin with most indicators, as this would cause
   // ambiguity with other YAML constructs.
   static constexpr char Indicators[] = R"(-?:\,[]{}#&*!|>'"%@`)";
   if (S.find_first_of(Indicators) == 0)
-return QuotingType::Single;
+MaxQuotingNeeded = QuotingType::Single;
 
-  QuotingType MaxQuotingNeeded = QuotingType::None;
   for (unsigned char C : S) {
 // Alphanum is safe.
 if (isAlnum(C))
@@ -684,11 +685,11 @@
 case 0x9:
   continue;
 // LF(0xA) and CR(0xD) may delimit values and so require at least single
-// quotes.
+// quotes. LLVM YAML parser cannot handle single quoted multiline so use
+// double quoting to produce valid YAML.
 case 0xA:
 case 0xD:
-  MaxQuotingNeeded = QuotingType::Single;
-  continue;
+  return QuotingType::Double;
 // DEL (0x7F) are excluded from the allowed character range.
 case 0x7F:
   return QuotingType::Double;
Index: clang/unittests/Tooling/ReplacementsYamlTest.cpp
===
--- clang/unittests/Tooling/ReplacementsYamlTest.cpp
+++ clang/unittest

[PATCH] D82373: [CodeComplete] Tweak code completion for `typename`

2020-06-24 Thread liu hui via Phabricator via cfe-commits
lh123 added a comment.

If this patch looks good, please land it for me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82373



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


[PATCH] D82385: [Analyzer] Fix errors in iterator modeling

2020-06-24 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp:530-532
   const auto *Pos = getIteratorPosition(State, LHS);
   if (!Pos)
 return;

I fear this might be a stupid question, but what's up with `5 + it`? Why does 
the LHS have to be the iterator? Am I missing something here?



Comment at: clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp:541
 
   auto &TgtVal = (Op == OO_PlusEqual || Op == OO_MinusEqual) ? LHS : RetVal;
 

What does `Tgt` mean?


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

https://reviews.llvm.org/D82385



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


[PATCH] D82081: [z/OS] Add binary format goff and operating system zos to the triple

2020-06-24 Thread Kai Nacke via Phabricator via cfe-commits
Kai updated this revision to Diff 273004.
Kai added a comment.

- Added a `break;` in several places
- Follow local formatting style in `triple.cpp`


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

https://reviews.llvm.org/D82081

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CGObjCMac.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  llvm/include/llvm/ADT/Triple.h
  llvm/include/llvm/Support/TargetRegistry.h
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/MC/MCObjectFileInfo.cpp
  llvm/lib/Support/Triple.cpp
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  llvm/unittests/ADT/TripleTest.cpp

Index: llvm/unittests/ADT/TripleTest.cpp
===
--- llvm/unittests/ADT/TripleTest.cpp
+++ llvm/unittests/ADT/TripleTest.cpp
@@ -171,6 +171,18 @@
   EXPECT_EQ(Triple::FreeBSD, T.getOS());
   EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
 
+  T = Triple("s390x-ibm-zos");
+  EXPECT_EQ(Triple::systemz, T.getArch());
+  EXPECT_EQ(Triple::IBM, T.getVendor());
+  EXPECT_EQ(Triple::ZOS, T.getOS());
+  EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
+
+  T = Triple("systemz-ibm-zos");
+  EXPECT_EQ(Triple::systemz, T.getArch());
+  EXPECT_EQ(Triple::IBM, T.getVendor());
+  EXPECT_EQ(Triple::ZOS, T.getOS());
+  EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
+
   T = Triple("arm-none-none-eabi");
   EXPECT_EQ(Triple::arm, T.getArch());
   EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
@@ -1349,6 +1361,15 @@
   EXPECT_EQ(Triple::ELF, Triple("i686-pc-windows-msvc-elf").getObjectFormat());
   EXPECT_EQ(Triple::ELF, Triple("i686-pc-cygwin-elf").getObjectFormat());
 
+  EXPECT_EQ(Triple::ELF, Triple("systemz-ibm-linux").getObjectFormat());
+  EXPECT_EQ(Triple::ELF, Triple("systemz-ibm-unknown").getObjectFormat());
+
+  EXPECT_EQ(Triple::GOFF, Triple("s390x-ibm-zos").getObjectFormat());
+  EXPECT_EQ(Triple::GOFF, Triple("systemz-ibm-zos").getObjectFormat());
+  EXPECT_EQ(Triple::GOFF, Triple("s390x-ibm-zos-goff").getObjectFormat());
+  EXPECT_EQ(Triple::GOFF, Triple("s390x-unknown-zos-goff").getObjectFormat());
+  EXPECT_EQ(Triple::GOFF, Triple("s390x---goff").getObjectFormat());
+
   EXPECT_EQ(Triple::Wasm, Triple("wasm32-unknown-unknown").getObjectFormat());
   EXPECT_EQ(Triple::Wasm, Triple("wasm64-unknown-unknown").getObjectFormat());
   EXPECT_EQ(Triple::Wasm, Triple("wasm32-wasi").getObjectFormat());
@@ -1395,6 +1416,9 @@
 
   T.setObjectFormat(Triple::XCOFF);
   EXPECT_EQ(Triple::XCOFF, T.getObjectFormat());
+
+  T.setObjectFormat(Triple::GOFF);
+  EXPECT_EQ(Triple::GOFF, T.getObjectFormat());
 }
 
 TEST(TripleTest, NormalizeWindows) {
Index: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -1952,9 +1952,10 @@
   case Triple::ELF:   return "asan_globals";
   case Triple::MachO: return "__DATA,__asan_globals,regular";
   case Triple::Wasm:
+  case Triple::GOFF:
   case Triple::XCOFF:
 report_fatal_error(
-"ModuleAddressSanitizer not implemented for object file format.");
+"ModuleAddressSanitizer not implemented for object file format");
   case Triple::UnknownObjectFormat:
 break;
   }
Index: llvm/lib/Support/Triple.cpp
===
--- llvm/lib/Support/Triple.cpp
+++ llvm/lib/Support/Triple.cpp
@@ -218,6 +218,7 @@
   case WASI: return "wasi";
   case WatchOS: return "watchos";
   case Win32: return "windows";
+  case ZOS: return "zos";
   }
 
   llvm_unreachable("Invalid OSType");
@@ -504,6 +505,7 @@
 .StartsWith("solaris", Triple::Solaris)
 .StartsWith("win32", Triple::Win32)
 .StartsWith("windows", Triple::Win32)
+.StartsWith("zos", Triple::ZOS)
 .StartsWith("haiku", Triple::Haiku)
 .StartsWith("minix", Triple::Minix)
 .StartsWith("rtems", Triple::RTEMS)
@@ -558,6 +560,7 @@
 .EndsWith("xcoff", Triple::XCOFF)
 .EndsWith("coff", Triple::COFF)
 .EndsWith("elf", Triple::ELF)
+.EndsWith("goff", Triple::GOFF)
 .EndsWith("macho", Triple::MachO)
 .EndsWith("wasm", Triple::Wasm)
 .Default(Triple::UnknownObjectFormat);
@@ -649,6 +652,7 @@
   case Triple::UnknownObjectFormat: return "";
   case Triple::COFF:  return "coff";
   case Triple::ELF:   return "elf";
+  case Triple::GOFF:  return "goff";
   case Triple::MachO: return "macho";
   case Triple::Wasm:  return "wasm";
   case Triple::XCOFF: return "xcoff";
@@ -706,7 +710,6 @@
   case Triple::sparcv9:
   case Triple::spir64:
   case Triple::spir:
-  case Triple::systemz:
   case Triple::tce:
   case Triple::tcele:
   case Triple::thumbeb:
@@ -720,6 +723,11 @@
   return Triple::XCOFF;
 return Triple::ELF;
 
+  case Triple::systemz:
+if (T.isOSzOS())
+  return Triple::GOFF;
+return Triple::EL

[PATCH] D77062: [analyzer] Improved zero assumption in CStringChecke::assumeZero

2020-06-24 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 272997.
ASDenysPetrov added a comment.

@NoQ thanks for the approval. But I'm afraid we should return the check for 
`!V.getAs()` back in `CStringChecker::assumeZero`.

Look, I paid attention to the fix for https://llvm.org/PR24951 and related 
commit rG480a0c00ca51d909a925120737b71289cbb79eda 
. I saw 
that @dcoughlin added a check for `V.getAs()` to fix 
and the old code used it implicitly. My patch returns this issue back. That's 
why we need to add the check for `LazyCompoundVal` as well.

Another big question is why `LazyCompoundVal` can be possible here at all. As I 
see according to the graph below the answer is somewhere deep in the core. Thus 
I'd propose to apply this patch in scope of fix https://llvm.org/PR37503.
F11723847: tmp63ucwe5i.html 

I updated the patch. I've also added a //FIXME// caveat.


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

https://reviews.llvm.org/D77062

Files:
  clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  clang/test/Analysis/string.c

Index: clang/test/Analysis/string.c
===
--- clang/test/Analysis/string.c
+++ clang/test/Analysis/string.c
@@ -363,6 +363,14 @@
 strcpy(x, y); // no-warning
 }
 
+void *func_strcpy_no_assertion();
+char ***ptr_strcpy_no_assertion;
+void strcpy_no_assertion() {
+  *(unsigned char **)ptr_strcpy_no_assertion = (unsigned char *)(func_strcpy_no_assertion());
+  char c;
+  strcpy(**ptr_strcpy_no_assertion, &c); // no-assertion
+}
+
 //===--===
 // stpcpy()
 //===--===
Index: clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -196,9 +196,8 @@
   void evalBzero(CheckerContext &C, const CallExpr *CE) const;
 
   // Utility methods
-  std::pair
-  static assumeZero(CheckerContext &C,
-ProgramStateRef state, SVal V, QualType Ty);
+  std::pair static assumeZero(
+  ProgramStateRef state, SVal V);
 
   static ProgramStateRef setCStringLength(ProgramStateRef state,
   const MemRegion *MR,
@@ -279,16 +278,18 @@
 // Individual checks and utility methods.
 //===--===//
 
-std::pair
-CStringChecker::assumeZero(CheckerContext &C, ProgramStateRef state, SVal V,
-   QualType Ty) {
+std::pair
+CStringChecker::assumeZero(ProgramStateRef state, SVal V) {
+  auto states = std::make_pair(state, state);
+
   Optional val = V.getAs();
-  if (!val)
-return std::pair(state, state);
+  // FIXME: We should understand how LazyCompoundVal can be possible here,
+  // fix the root cause and get rid of this check.
+  if (val && !V.getAs())
+// Returned pair shall be {null, non-null} so reorder states.
+std::tie(states.second, states.first) = state->assume(*val);
 
-  SValBuilder &svalBuilder = C.getSValBuilder();
-  DefinedOrUnknownSVal zero = svalBuilder.makeZeroVal(Ty);
-  return state->assume(svalBuilder.evalEQ(state, *val, zero));
+  return states;
 }
 
 ProgramStateRef CStringChecker::checkNonNull(CheckerContext &C,
@@ -299,8 +300,7 @@
 return nullptr;
 
   ProgramStateRef stateNull, stateNonNull;
-  std::tie(stateNull, stateNonNull) =
-  assumeZero(C, State, l, Arg.Expression->getType());
+  std::tie(stateNull, stateNonNull) = assumeZero(State, l);
 
   if (stateNull && !stateNonNull) {
 if (Filter.CheckCStringNullArg) {
@@ -1071,8 +1071,7 @@
 CharVal = svalBuilder.evalCast(CharVal, Ctx.UnsignedCharTy, Ctx.IntTy);
 
 ProgramStateRef StateNullChar, StateNonNullChar;
-std::tie(StateNullChar, StateNonNullChar) =
-assumeZero(C, State, CharVal, Ctx.UnsignedCharTy);
+std::tie(StateNullChar, StateNonNullChar) = assumeZero(State, CharVal);
 
 if (StateWholeReg && !StateNotWholeReg && StateNullChar &&
 !StateNonNullChar) {
@@ -1133,11 +1132,9 @@
   // See if the size argument is zero.
   const LocationContext *LCtx = C.getLocationContext();
   SVal sizeVal = state->getSVal(Size.Expression, LCtx);
-  QualType sizeTy = Size.Expression->getType();
 
   ProgramStateRef stateZeroSize, stateNonZeroSize;
-  std::tie(stateZeroSize, stateNonZeroSize) =
-  assumeZero(C, state, sizeVal, sizeTy);
+  std::tie(stateZeroSize, stateNonZeroSize) = assumeZero(state, sizeVal);
 
   // Get the value of the Dest.
   SVal destVal = state->getSVal(Dest.Expression, LCtx);
@@ -1287,11 +1284,9 @@
 
   // See if the size argument is zero.
   SVal sizeVal = State->getSVal(Size.Expression, LCtx);
-  QualType sizeTy = Size.Expres

[PATCH] D82414: [X86] Replace PROC macros with an enum and a lookup table of processor information.

2020-06-24 Thread Erich Keane via Phabricator via cfe-commits
erichkeane accepted this revision.
erichkeane added a comment.
This revision is now accepted and ready to land.

1 nit, plus the clang-tidy suggestions.




Comment at: clang/lib/Basic/Targets/X86.cpp:1559
+   "CPU Type without a key feature used in 'target' attribute");
+return (getFeaturePriority((ProcessorFeatures)KeyFeature) << 1) + 1;
   }

static-cast?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82414



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


[PATCH] D71199: [clang-tidy] New check cppcoreguidelines-prefer-member-initializer

2020-06-24 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware marked 2 inline comments as done.
baloghadamsoftware added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer-assignment.cpp:29
+public:
+  Simple2() : n (0) {
+x = 0.0;

aaron.ballman wrote:
> baloghadamsoftware wrote:
> > aaron.ballman wrote:
> > > By my reading of the core guideline 
> > > (https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#c48-prefer-in-class-initializers-to-member-initializers-in-constructors-for-constant-initializers),
> > >  it looks like `n` should also be diagnosed because all of the 
> > > constructors in the class initialize the member to the same constant 
> > > value. Is there a reason to deviate from the rule (or have I missed 
> > > something)?
> > > 
> > > Also, I'd like to see a test case like:
> > > ```
> > > class C {
> > >   int n;
> > > public:
> > >   C() { n = 0; }
> > >   explicit C(int) { n = 12; }
> > > };
> > > ```
> > This check only cares for initializations inside the body (rule `C.49`, but 
> > if the proper fix is to convert them to default member initializer 
> > according to rule `C.48` then we follow that rule in the fix). For 
> > initializations implemented as constructor member initializers but 
> > according to `C.48` they should have been implemented as default member 
> > initializers we already have check `modernize-use-default-member-init`.
> Thank you for the explanation. I have the feeling that these two rules are 
> going to have some really weird interactions together. For instance, the 
> example you added at my request shows behavior I can't easily explain as a 
> user:
> ```
> class Complex19 {
>   int n;
>   // CHECK-FIXES: int n{0};
> public:
>   Complex19() {
> n = 0;
> // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'n' should be initialized in 
> an in-class default member initializer 
> [cppcoreguidelines-prefer-member-initializer]
> // CHECK-FIXES: {{^\ *$}}
>   }
> 
>   explicit Complex19(int) {
> // CHECK-FIXES: Complex19(int) : n(12) {
> n = 12;
> // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'n' should be initialized in 
> a member initializer of the constructor 
> [cppcoreguidelines-prefer-member-initializer]
> // CHECK-FIXES: {{^\ *$}}
>   }
> 
>   ~Complex19() = default;
> };
> ```
> Despite both constructors having the assignment expression `n = ;` 
> one gets one diagnostic + fixit and the other gets a different diagnostic + 
> fixit.
> 
> Also, from reading C.49, I don't see anything about using in-class 
> initialization. I see C.49 as being about avoiding the situation where the 
> ctor runs a constructor for a data member only to then immediately in the 
> ctor body make an assignment to that member. You don't need to initialize 
> then reinitialize when you can use a member init list to construct the object 
> properly initially.
Thank you for your comment. While I can agree with you, I think that this check 
should be fully consistent with `modernize-use-default-member-init`. Thus I 
tried it on the following example:
```
class C {
  int n;
public:
  C() : n(1) {}
  C(int nn) : n(nn) {}

  int get_n() { return n; }
};
```
I got the following message from Clang-Tidy:
```
warning: use default member initializer for 'n' 
[modernize-use-default-member-init]
  int n;
  ^
   {1}
```
This is no surprise, however. If you take a look on the example in [[ 
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#c48-prefer-in-class-initializers-to-member-initializers-in-constructors-for-constant-initializers
 | C.48: Prefer in-class initializers to member initializers in constructors 
for constant initializers ]] you can see that our code is almost the same as 
the example considered bad there. So rule C.49 does not speak anything about 
in-class initialization, but C.48 does, our check enforcing C.49 must not 
suggest a fixit the the check enforcing C.48 fixes again. We should not force 
the user to run Clang-Tidy in multiple passes. Maybe we can mention the numbers 
of the rules in the error messages to make them clearer.


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

https://reviews.llvm.org/D71199



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


[PATCH] D82385: [Analyzer] Fix errors in iterator modeling

2020-06-24 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware marked 2 inline comments as done.
baloghadamsoftware added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp:530-532
   const auto *Pos = getIteratorPosition(State, LHS);
   if (!Pos)
 return;

Szelethus wrote:
> I fear this might be a stupid question, but what's up with `5 + it`? Why does 
> the LHS have to be the iterator? Am I missing something here?
There is nothing wrong with it, but it is not (yet) supported, because I simply 
forgot. However I think it is much less common than `it + 5`. This patch is 
just a fixit patch, so I try not to add new features here, just fix existing 
ones.



Comment at: clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp:541
 
   auto &TgtVal = (Op == OO_PlusEqual || Op == OO_MinusEqual) ? LHS : RetVal;
 

Szelethus wrote:
> What does `Tgt` mean?
`Tgt` is the abbreviation of "target". The target of `+` and `-` is their 
results, but of `+=` and `-=` is their left operands. However, I did not change 
this line in this patch.


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

https://reviews.llvm.org/D82385



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


[PATCH] D82446: [clang] Fix duplicate warning

2020-06-24 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui marked an inline comment as done.
kamleshbhalui added inline comments.



Comment at: clang/lib/Parse/ParseExprCXX.cpp:2273
   ParseSpecifierQualifierList(DS, AS_none, 
DeclSpecContext::DSC_type_specifier);
-  DS.Finish(Actions, Actions.getASTContext().getPrintingPolicy());
   return false;

aaron.ballman wrote:
> This change is incorrect -- `Finish` is what ensures the `DeclSpec` is in a 
> consistent state (even in the presence of errors), so removing it would be 
> bad.
you are right but ParseSpecifierQualifierList ->(calls) 
ParseDeclarationSpecifiers
and it makes a call to 
Finish(https://github.com/llvm/llvm-project/blob/master/clang/lib/Parse/ParseDecl.cpp#L2962).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82446



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


[PATCH] D79719: [AIX] Implement AIX special alignment rule about double/long double

2020-06-24 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L marked 2 inline comments as done.
Xiangling_L added inline comments.



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1881
+  if (isAIXLayout(Context) && FieldOffset == CharUnits::Zero() &&
+  (IsUnion || NonOverlappingEmptyFieldFound)) {
+FirstNonOverlappingEmptyFieldHandled = true;

jasonliu wrote:
> Xiangling_L wrote:
> > jasonliu wrote:
> > > Maybe it's a naive thought, but is it possible to replace 
> > > `NonOverlappingEmptyFieldFound` with `IsOverlappingEmptyField && 
> > > FieldOffsets.size() == 0`?
> > I don't think these two work the same. `NonOverlappingEmptyFieldFound` 
> > represents the 1st non-empty and non-overlapping field in the record. 
> > `IsOverlappingEmptyField && FieldOffsets.size() == 0` represents something 
> > opposite.
> You are right. I meant could we replace it with `!(IsOverlappingEmptyField && 
> FieldOffsets.size() == 0)`?
I don't think so. The replacement does not work for the case:


```
struct A {
  int : 0;
  double d;
};
```

where __alignof(A) should be 4;


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

https://reviews.llvm.org/D79719



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


[PATCH] D82461: [VE] Add clang tests for VE

2020-06-24 Thread Kazushi Marukawa via Phabricator via cfe-commits
kaz7 created this revision.
kaz7 added reviewers: simoll, k-ishizaka.
kaz7 added projects: LLVM, VE.
Herald added subscribers: cfe-commits, ormris, jfb, krytarowski.
Herald added a project: clang.

Add a preprocessor test to check VE predefinitions.  Add a driver test
to check VE toolchain behavior.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82461

Files:
  clang/test/Driver/ve-toolchain.c
  clang/test/Preprocessor/init-ve.c

Index: clang/test/Preprocessor/init-ve.c
===
--- /dev/null
+++ clang/test/Preprocessor/init-ve.c
@@ -0,0 +1,274 @@
+/// Check predefinitions for NEC Aurora VE
+/// REQUIRES: ve-registered-target
+
+// RUN: %clang_cc1 -E -dM -triple=ve < /dev/null | \
+// RUN: FileCheck -match-full-lines -check-prefix VE %s
+// RUN: %clang_cc1 -x c++ -E -dM -triple=ve < /dev/null | \
+// RUN: FileCheck -match-full-lines -check-prefix VE -check-prefix VE-CXX %s
+//
+// VE:#define _LP64 1
+// VE:#define __BIGGEST_ALIGNMENT__ 8
+// VE:#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
+// VE:#define __CHAR16_TYPE__ unsigned short
+// VE:#define __CHAR32_TYPE__ unsigned int
+// VE:#define __CHAR_BIT__ 8
+// VE:#define __DBL_DECIMAL_DIG__ 17
+// VE:#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
+// VE:#define __DBL_DIG__ 15
+// VE:#define __DBL_EPSILON__ 2.2204460492503131e-16
+// VE:#define __DBL_HAS_DENORM__ 1
+// VE:#define __DBL_HAS_INFINITY__ 1
+// VE:#define __DBL_HAS_QUIET_NAN__ 1
+// VE:#define __DBL_MANT_DIG__ 53
+// VE:#define __DBL_MAX_10_EXP__ 308
+// VE:#define __DBL_MAX_EXP__ 1024
+// VE:#define __DBL_MAX__ 1.7976931348623157e+308
+// VE:#define __DBL_MIN_10_EXP__ (-307)
+// VE:#define __DBL_MIN_EXP__ (-1021)
+// VE:#define __DBL_MIN__ 2.2250738585072014e-308
+// VE:#define __DECIMAL_DIG__ __LDBL_DECIMAL_DIG__
+// VE-NOT:#define __FAST_MATH__ 1
+// VE:#define __FLT_DECIMAL_DIG__ 9
+// VE:#define __FLT_DENORM_MIN__ 1.40129846e-45F
+// VE:#define __FLT_DIG__ 6
+// VE:#define __FLT_EPSILON__ 1.19209290e-7F
+// VE:#define __FLT_EVAL_METHOD__ 0
+// VE:#define __FLT_HAS_DENORM__ 1
+// VE:#define __FLT_HAS_INFINITY__ 1
+// VE:#define __FLT_HAS_QUIET_NAN__ 1
+// VE:#define __FLT_MANT_DIG__ 24
+// VE:#define __FLT_MAX_10_EXP__ 38
+// VE:#define __FLT_MAX_EXP__ 128
+// VE:#define __FLT_MAX__ 3.40282347e+38F
+// VE:#define __FLT_MIN_10_EXP__ (-37)
+// VE:#define __FLT_MIN_EXP__ (-125)
+// VE:#define __FLT_MIN__ 1.17549435e-38F
+// VE:#define __FLT_RADIX__ 2
+// VE:#define __INT16_C_SUFFIX__
+// VE:#define __INT16_FMTd__ "hd"
+// VE:#define __INT16_FMTi__ "hi"
+// VE:#define __INT16_MAX__ 32767
+// VE:#define __INT16_TYPE__ short
+// VE:#define __INT32_C_SUFFIX__
+// VE:#define __INT32_FMTd__ "d"
+// VE:#define __INT32_FMTi__ "i"
+// VE:#define __INT32_MAX__ 2147483647
+// VE:#define __INT32_TYPE__ int
+// VE:#define __INT64_C_SUFFIX__ L
+// VE:#define __INT64_FMTd__ "ld"
+// VE:#define __INT64_FMTi__ "li"
+// VE:#define __INT64_MAX__ 9223372036854775807L
+// VE:#define __INT64_TYPE__ long int
+// VE:#define __INT8_C_SUFFIX__
+// VE:#define __INT8_FMTd__ "hhd"
+// VE:#define __INT8_FMTi__ "hhi"
+// VE:#define __INT8_MAX__ 127
+// VE:#define __INT8_TYPE__ signed char
+// VE:#define __INTMAX_C_SUFFIX__ L
+// VE:#define __INTMAX_FMTd__ "ld"
+// VE:#define __INTMAX_FMTi__ "li"
+// VE:#define __INTMAX_MAX__ 9223372036854775807L
+// VE:#define __INTMAX_TYPE__ long int
+// VE:#define __INTMAX_WIDTH__ 64
+// VE:#define __INTPTR_FMTd__ "ld"
+// VE:#define __INTPTR_FMTi__ "li"
+// VE:#define __INTPTR_MAX__ 9223372036854775807L
+// VE:#define __INTPTR_TYPE__ long int
+// VE:#define __INTPTR_WIDTH__ 64
+// VE:#define __INT_FAST16_FMTd__ "hd"
+// VE:#define __INT_FAST16_FMTi__ "hi"
+// VE:#define __INT_FAST16_MAX__ 32767
+// VE:#define __INT_FAST16_TYPE__ short
+// VE:#define __INT_FAST32_FMTd__ "d"
+// VE:#define __INT_FAST32_FMTi__ "i"
+// VE:#define __INT_FAST32_MAX__ 2147483647
+// VE:#define __INT_FAST32_TYPE__ int
+// VE:#define __INT_FAST64_FMTd__ "ld"
+// VE:#define __INT_FAST64_FMTi__ "li"
+// VE:#define __INT_FAST64_MAX__ 9223372036854775807L
+// VE:#define __INT_FAST64_TYPE__ long int
+// VE:#define __INT_FAST8_FMTd__ "hhd"
+// VE:#define __INT_FAST8_FMTi__ "hhi"
+// VE:#define __INT_FAST8_MAX__ 127
+// VE:#define __INT_FAST8_TYPE__ signed char
+// VE:#define __INT_LEAST16_FMTd__ "hd"
+// VE:#define __INT_LEAST16_FMTi__ "hi"
+// VE:#define __INT_LEAST16_MAX__ 32767
+// VE:#define __INT_LEAST16_TYPE__ short
+// VE:#define __INT_LEAST32_FMTd__ "d"
+// VE:#define __INT_LEAST32_FMTi__ "i"
+// VE:#define __INT_LEAST32_MAX__ 2147483647
+// VE:#define __INT_LEAST32_TYPE__ int
+// VE:#define __INT_LEAST64_FMTd__ "ld"
+// VE:#define __INT_LEAST64_FMTi__ "li"
+// VE:#define __INT_LEAST64_MAX__ 9223372036854775807L
+// VE:#define __INT_LEAST64_TYPE__ long int
+// VE:#define __INT_LEAST8_FMTd__ "hhd"
+// VE:#define __INT_LEAST8_FMTi__ "hhi"
+// VE:#define __INT_LEAST8_MAX__ 127
+// VE:#define __INT_LEAST8_TYPE__ signed char

[PATCH] D82385: [Analyzer] Fix errors in iterator modeling

2020-06-24 Thread Endre Fülöp via Phabricator via cfe-commits
gamesh411 accepted this revision.
gamesh411 added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp:530-532
   const auto *Pos = getIteratorPosition(State, LHS);
   if (!Pos)
 return;

baloghadamsoftware wrote:
> Szelethus wrote:
> > I fear this might be a stupid question, but what's up with `5 + it`? Why 
> > does the LHS have to be the iterator? Am I missing something here?
> There is nothing wrong with it, but it is not (yet) supported, because I 
> simply forgot. However I think it is much less common than `it + 5`. This 
> patch is just a fixit patch, so I try not to add new features here, just fix 
> existing ones.
Good catch, we should definitely support that! I can even volunteer if you are 
ok with that.


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

https://reviews.llvm.org/D82385



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


[clang] 5f94c9a - [AST][RecoveryExpr] Add error-bit TemplateArgument

2020-06-24 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-06-24T16:21:35+02:00
New Revision: 5f94c9a421ec7cc7ece2bd875e010639ee0783ec

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

LOG: [AST][RecoveryExpr] Add error-bit TemplateArgument

Summary: We are missing the error-bit somehow if the error-bit is propagated
through the code path: "error type/expr" -> "template argument" ->
"template specialization type", which will lead to crashes.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/AST/DependenceFlags.h
clang/lib/AST/Type.cpp
clang/test/SemaCXX/invalid-template-base-specifier.cpp

Removed: 




diff  --git a/clang/include/clang/AST/DependenceFlags.h 
b/clang/include/clang/AST/DependenceFlags.h
index 54e12ea47fd5..7e044865b254 100644
--- a/clang/include/clang/AST/DependenceFlags.h
+++ b/clang/include/clang/AST/DependenceFlags.h
@@ -64,6 +64,23 @@ struct TypeDependenceScope {
 };
 using TypeDependence = TypeDependenceScope::TypeDependence;
 
+struct TemplateArgumentDependenceScope {
+  enum TemplateArgumentDependence : uint8_t {
+UnexpandedPack = 1,
+Instantiation = 2,
+Dependent = 4,
+
+Error = 8,
+
+DependentInstantiation = Dependent | Instantiation,
+None = 0,
+All = 15,
+LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/Error)
+  };
+};
+using TemplateArgumentDependence =
+TemplateArgumentDependenceScope ::TemplateArgumentDependence;
+
 #define LLVM_COMMON_DEPENDENCE(NAME)   
\
   struct NAME##Scope { 
\
 enum NAME : uint8_t {  
\
@@ -82,7 +99,6 @@ using TypeDependence = TypeDependenceScope::TypeDependence;
 
 LLVM_COMMON_DEPENDENCE(NestedNameSpecifierDependence)
 LLVM_COMMON_DEPENDENCE(TemplateNameDependence)
-LLVM_COMMON_DEPENDENCE(TemplateArgumentDependence)
 #undef LLVM_COMMON_DEPENDENCE
 
 // A combined space of all dependence concepts for all node types.
@@ -137,8 +153,9 @@ class Dependence {
 
   Dependence(TemplateArgumentDependence D)
   : V(translate(D, TADependence::UnexpandedPack, UnexpandedPack) |
- translate(D, TADependence::Instantiation, Instantiation) |
- translate(D, TADependence::Dependent, Dependent)) {}
+  translate(D, TADependence::Instantiation, Instantiation) |
+  translate(D, TADependence::Dependent, Dependent) |
+  translate(D, TADependence::Error, Error)) {}
 
   Dependence(TemplateNameDependence D)
   : V(translate(D, TNDependence::UnexpandedPack, UnexpandedPack) |
@@ -170,7 +187,8 @@ class Dependence {
   TemplateArgumentDependence templateArgument() const {
 return translate(V, UnexpandedPack, TADependence::UnexpandedPack) |
translate(V, Instantiation, TADependence::Instantiation) |
-   translate(V, Dependent, TADependence::Dependent);
+   translate(V, Dependent, TADependence::Dependent) |
+   translate(V, Error, TADependence::Error);
   }
 
   TemplateNameDependence templateName() const {

diff  --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index ba0d86befe1b..05962f34bbf1 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -3591,7 +3591,7 @@ TemplateSpecializationType::TemplateSpecializationType(
 
   auto *TemplateArgs = reinterpret_cast(this + 1);
   for (const TemplateArgument &Arg : Args) {
-// Update instantiation-dependent and variably-modified bits.
+// Update instantiation-dependent, variably-modified, and error bits.
 // If the canonical type exists and is non-dependent, the template
 // specialization type can be non-dependent even if one of the type
 // arguments is. Given:

diff  --git a/clang/test/SemaCXX/invalid-template-base-specifier.cpp 
b/clang/test/SemaCXX/invalid-template-base-specifier.cpp
index c0f5aabae831..7a1a7f801c45 100644
--- a/clang/test/SemaCXX/invalid-template-base-specifier.cpp
+++ b/clang/test/SemaCXX/invalid-template-base-specifier.cpp
@@ -1,7 +1,6 @@
 // RUN: %clang_cc1 -frecovery-ast -verify %s
 
-bool Foo(int *); // expected-note {{candidate function not viable}} \
- // expected-note {{candidate function not viable}}
+bool Foo(int *); // expected-note 3{{candidate function not viable}}
 
 template 
 struct Crash : decltype(Foo(T())) { // expected-error {{no matching function 
for call to 'Foo'}}
@@ -18,3 +17,12 @@ struct Crash2 : decltype(Alias()) { // expected-note {{in 
instantiation of te
 };
 
 void test2() { Crash2(); } // expected-note {{in instantiation of 
template class 'Crash2' requested here}}
+
+template 
+class Base {};
+template 
+struct Cras

[PATCH] D81938: [InferAddressSpaces] Handle the pair of `ptrtoint`/`inttoptr`.

2020-06-24 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu:62-64
+// OPT-NOT: alloca
+// OPT-NOT: ptrtoint
+// OPT-NOT: inttoptr

Positive checks are preferable (here and through the rest of the file)



Comment at: llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp:223
 
+static bool isNoopPtrIntCastPair(const Operator *I2P, const DataLayout *DL,
+ const TargetTransformInfo *TTI) {

Can you add a comment elaborating on why this is necessary? This is special 
casing this to paper over the missing no-op pointer bitcast



Comment at: llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp:237-239
+ TTI->isNoopAddrSpaceCast(
+ P2I->getOperand(0)->getType()->getPointerAddressSpace(),
+ I2P->getType()->getPointerAddressSpace());

Can you also elaborate on why the isNoopAddrSpaceCast check is needed? I'm not 
100% sure it is in all contexts, so want to be sure to document that



Comment at: llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp:245
 // getelementptr operators.
-static bool isAddressExpression(const Value &V) {
+static bool isAddressExpression(const Value &V, const DataLayout *DL,
+const TargetTransformInfo *TTI) {

data layout should be const reference



Comment at: llvm/test/Transforms/InferAddressSpaces/noop-ptrint-pair.ll:21
+; CHECK-NEXT: ret void
+define void @non_noop_ptrint_pair(i32 addrspace(3)* %x.coerce) {
+  %1 = ptrtoint i32 addrspace(3)* %x.coerce to i64

Can you also add one where the cast would be a no-op, but the integer size is 
different? e.g. 0 to 1 and 1 to 0 where the intermediate size is 32-bits or 128 
bits



Comment at: llvm/test/Transforms/InferAddressSpaces/noop-ptrint-pair.ll:45
+  ret void
+}

Can you add some cases where the pointer value isn't used for memory? Like pure 
pointer arithmetic


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81938



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


[PATCH] D82446: [clang] Fix duplicate warning

2020-06-24 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added a comment.

I apologise for a quick drive-by comment, but this is something I find very 
annoying when looking at the history of a piece of code:

Could you spent a few minutes to make a more descriptive title and description?

  Fixes duplicate warning emitted by clang when
  char16_t/char32_t is used in the catch block.

Does not actually explains what is wrong (the duplicate warning is just a 
symptom), nor does it explains what is done to fix it, nor does it explains 
*why* this is the right fix.
Unless the patch is really trivial I think that it pays to put a little more 
context in the description.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82446



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


[PATCH] D82288: [analyzer][StdLibraryFunctionsChecker] Add POSIX file handling functions

2020-06-24 Thread Gabor Marton via Phabricator via cfe-commits
martong marked 8 inline comments as done.
martong added inline comments.



Comment at: clang/include/clang/StaticAnalyzer/Checkers/Checkers.td:352-357
 CmdLineOption,

Szelethus wrote:
> D78118#inline-723679 Please mark this `Hidden`.
Ok, it missed my attention about that back then.



Comment at: clang/include/clang/StaticAnalyzer/Checkers/Checkers.td:358-363
+CmdLineOption

Szelethus wrote:
> I'm fine with not hiding this, but as a user, why would I never not enable 
> it? If the reasoning is that this isn't ready quite yet, change `Released` to 
> `InAlpha`. Otherwise, either mark this `Hidden` or give a user friendly 
> explanation as to what is there to gain/lose by tinkering with this option.
Yes, thanks, I wanted to make it similar to alpha checkers, now I know it is 
`InAlpha` that I need.



Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:740
   // we have a TypedefDecl with the name 'FILE'.
-  for (Decl *D : LookupRes) {
+  for (Decl *D : LookupRes)
 if (auto *TD = dyn_cast(D))

gamesh411 wrote:
> I presume that typically there are only a handful of `Decl`s in LookupRes, so 
> it not worth the complexity of using `std::algorithm`s to sort/partition/find.
There may be many `Decl`s in the lookup result, but I don't know based on which 
property would it make sense to sort them. They are essentially stored in the 
order of creation, so as the parser reads an upcoming Decl.



Comment at: 
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:1591
+
+Optional Off_tMax;
+if (Off_tTy) {

gamesh411 wrote:
> If `Off_tMax` is only used in the if block that follows, consider moving it's 
> declaration inside.
Yeah, good catch, thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82288



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


[PATCH] D82288: [analyzer][StdLibraryFunctionsChecker] Add POSIX file handling functions

2020-06-24 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 273018.
martong marked 4 inline comments as done.
martong added a comment.

- Add 'Hide' and 'InAlpha', move Off_tMax inside the brace


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82288

Files:
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  clang/test/Analysis/analyzer-config.c
  clang/test/Analysis/std-c-library-functions-POSIX.c

Index: clang/test/Analysis/std-c-library-functions-POSIX.c
===
--- /dev/null
+++ clang/test/Analysis/std-c-library-functions-POSIX.c
@@ -0,0 +1,178 @@
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions \
+// RUN:   -analyzer-config apiModeling.StdCLibraryFunctions:ModelPOSIX=true \
+// RUN:   -analyzer-config apiModeling.StdCLibraryFunctions:DisplayLoadedSummaries=true \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -analyzer-config eagerly-assume=false \
+// RUN:   -triple i686-unknown-linux 2>&1 | FileCheck %s
+
+// CHECK: Loaded summary for: long a64l(const char *str64)
+// CHECK: Loaded summary for: char *l64a(long value)
+// CHECK: Loaded summary for: int access(const char *pathname, int amode)
+// CHECK: Loaded summary for: int faccessat(int dirfd, const char *pathname, int mode, int flags)
+// CHECK: Loaded summary for: int dup(int fildes)
+// CHECK: Loaded summary for: int dup2(int fildes1, int filedes2)
+// CHECK: Loaded summary for: int fdatasync(int fildes)
+// CHECK: Loaded summary for: int fnmatch(const char *pattern, const char *string, int flags)
+// CHECK: Loaded summary for: int fsync(int fildes)
+// CHECK: Loaded summary for: int truncate(const char *path, off_t length)
+// CHECK: Loaded summary for: int symlink(const char *oldpath, const char *newpath)
+// CHECK: Loaded summary for: int symlinkat(const char *oldpath, int newdirfd, const char *newpath)
+// CHECK: Loaded summary for: int lockf(int fd, int cmd, off_t len)
+// CHECK: Loaded summary for: int creat(const char *pathname, mode_t mode)
+// CHECK: Loaded summary for: unsigned int sleep(unsigned int seconds)
+// CHECK: Loaded summary for: int dirfd(DIR *dirp)
+// CHECK: Loaded summary for: unsigned int alarm(unsigned int seconds)
+// CHECK: Loaded summary for: int closedir(DIR *dir)
+// CHECK: Loaded summary for: char *strdup(const char *s)
+// CHECK: Loaded summary for: char *strndup(const char *s, size_t n)
+// CHECK: Loaded summary for: int mkstemp(char *template)
+// CHECK: Loaded summary for: char *mkdtemp(char *template)
+// CHECK: Loaded summary for: char *getcwd(char *buf, size_t size)
+// CHECK: Loaded summary for: int mkdir(const char *pathname, mode_t mode)
+// CHECK: Loaded summary for: int mkdirat(int dirfd, const char *pathname, mode_t mode)
+// CHECK: Loaded summary for: int mknod(const char *pathname, mode_t mode, dev_t dev)
+// CHECK: Loaded summary for: int mknodat(int dirfd, const char *pathname, mode_t mode, dev_t dev)
+// CHECK: Loaded summary for: int chmod(const char *path, mode_t mode)
+// CHECK: Loaded summary for: int fchmodat(int dirfd, const char *pathname, mode_t mode, int flags)
+// CHECK: Loaded summary for: int fchmod(int fildes, mode_t mode)
+// CHECK: Loaded summary for: int fchownat(int dirfd, const char *pathname, uid_t owner, gid_t group, int flags)
+// CHECK: Loaded summary for: int chown(const char *path, uid_t owner, gid_t group)
+// CHECK: Loaded summary for: int lchown(const char *path, uid_t owner, gid_t group)
+// CHECK: Loaded summary for: int fchown(int fildes, uid_t owner, gid_t group)
+// CHECK: Loaded summary for: int rmdir(const char *pathname)
+// CHECK: Loaded summary for: int chdir(const char *path)
+// CHECK: Loaded summary for: int link(const char *oldpath, const char *newpath)
+// CHECK: Loaded summary for: int linkat(int fd1, const char *path1, int fd2, const char *path2, int flag)
+// CHECK: Loaded summary for: int unlink(const char *pathname)
+// CHECK: Loaded summary for: int unlinkat(int fd, const char *path, int flag)
+// CHECK: Loaded summary for: int fstat(int fd, struct stat *statbuf)
+// CHECK: Loaded summary for: int stat(const char *restrict path, struct stat *restrict buf)
+// CHECK: Loaded summary for: int lstat(const char *restrict path, struct stat *restrict buf)
+// CHECK: Loaded summary for: int fstatat(int fd, const char *restrict path, struct stat *restrict buf, int flag)
+// CHECK: Loaded summary for: DIR *opendir(const char *name)
+// CHECK: Loaded summary for: DIR *fdopendir(int fd)
+// CHECK: Loaded summary for: int isatty(int fildes)
+// CHECK: Loaded summary for: FILE *popen(const char *command, const char *type)
+// CHECK: Loaded summary for: int pclose(FILE *stream)
+// CHECK: Loaded summary for: int close(int fildes)
+// CHECK: Loaded summary for: long fpathcon

  1   2   3   >