[PATCH] D86223: [analyzer][z3] Use more elaborate Z3 variable names

2020-08-24 Thread Balázs Benics via Phabricator via cfe-commits
steakhal updated this revision to Diff 287303.
steakhal retitled this revision from "[analyzer][z3] Use more elaborate z3 
variable names in debug build" to "[analyzer][z3] Use more elaborate Z3 
variable names".
steakhal edited the summary of this revision.
steakhal added a comment.

In D86223#2232681 , @mikhail.ramalho 
wrote:

> In D86223#2231991 , @steakhal wrote:
>
>> In D86223#2231959 , 
>> @mikhail.ramalho wrote:
>>
>>> I don't mind having it for release builds as well, why are you applying it 
>>> only for debug builds?
>>
>> It might introduce a slight overhead since Z3 will parse longer the symbol 
>> names.
>
> That overhead should be negligible, in the worst case you are adding just a 
> few extra characters to the variable's name.
>
> I rather have it for release builds as well so we don't introduce different 
> outputs depending on the build options, and we can improve debugging for 
> release builds as well.
>
> Also as a bonus, we don't have to change the test scripts for a single test.

Fixed.

---

Revision updated:

- Use the prettier symbol names unconditionally
- Revert changes to the test infra


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86223

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConv.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymExpr.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
  clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
  clang/test/Analysis/z3/pretty-dump.c

Index: clang/test/Analysis/z3/pretty-dump.c
===
--- /dev/null
+++ clang/test/Analysis/z3/pretty-dump.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -analyze -analyzer-constraints=z3 -setup-static-analyzer \
+// RUN:   -analyzer-checker=core,debug.ExprInspection %s 2>&1 | FileCheck %s
+//
+// REQUIRES: z3
+//
+// Works only with the z3 constraint manager.
+
+void clang_analyzer_printState();
+
+void foo(int x) {
+  if (x == 3) {
+clang_analyzer_printState();
+(void)x;
+// CHECK: "constraints": [
+// CHECK-NEXT: { "symbol": "(reg_$[[#]]) == 3", "range": "(= reg_$[[#]] #x0003)" }
+  }
+}
Index: clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
+++ clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
@@ -34,6 +34,12 @@
 
 void SymExpr::anchor() {}
 
+StringRef SymbolConjured::getKindStr() const { return "conj_$"; }
+StringRef SymbolDerived::getKindStr() const { return "derived_$"; }
+StringRef SymbolExtent::getKindStr() const { return "extent_$"; }
+StringRef SymbolMetadata::getKindStr() const { return "meta_$"; }
+StringRef SymbolRegionValue::getKindStr() const { return "reg_$"; }
+
 LLVM_DUMP_METHOD void SymExpr::dump() const { dumpToStream(llvm::errs()); }
 
 void BinarySymExpr::dumpToStreamImpl(raw_ostream &OS, const SymExpr *Sym) {
@@ -64,7 +70,7 @@
 }
 
 void SymbolConjured::dumpToStream(raw_ostream &os) const {
-  os << "conj_$" << getSymbolID() << '{' << T.getAsString() << ", LC"
+  os << getKindStr() << getSymbolID() << '{' << T.getAsString() << ", LC"
  << LCtx->getID();
   if (S)
 os << ", S" << S->getID(LCtx->getDecl()->getASTContext());
@@ -74,24 +80,24 @@
 }
 
 void SymbolDerived::dumpToStream(raw_ostream &os) const {
-  os << "derived_$" << getSymbolID() << '{'
- << getParentSymbol() << ',' << getRegion() << '}';
+  os << getKindStr() << getSymbolID() << '{' << getParentSymbol() << ','
+ << getRegion() << '}';
 }
 
 void SymbolExtent::dumpToStream(raw_ostream &os) const {
-  os << "extent_$" << getSymbolID() << '{' << getRegion() << '}';
+  os << getKindStr() << getSymbolID() << '{' << getRegion() << '}';
 }
 
 void SymbolMetadata::dumpToStream(raw_ostream &os) const {
-  os << "meta_$" << getSymbolID() << '{'
- << getRegion() << ',' << T.getAsString() << '}';
+  os << getKindStr() << getSymbolID() << '{' << getRegion() << ','
+ << T.getAsString() << '}';
 }
 
 void SymbolData::anchor() {}
 
 void SymbolRegionValue::dumpToStream(raw_ostream &os) const {
-  os << "reg_$" << getSymbolID()
- << '<' << getType().getAsString() << ' ' << R << '>';
+  os << getKindStr() << getSymbolID() << '<' << getType().getAsString() << ' '
+ << R << '>';
 }
 
 bool SymExpr::symbol_iterator::operator==(const symbol_iterator &X) const {
Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
@@ -59,6 +59,8 @@
 Profile(pro

[PATCH] D85105: [doxygen] Fix bad doxygen results for BugReporterVisitors.h

2020-08-24 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko accepted this revision.
vsavchenko added a comment.
This revision is now accepted and ready to land.

Awesome! I will submit the patch!


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

https://reviews.llvm.org/D85105

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


[PATCH] D86293: [analyzer] Add modeling of Eq operator in smart ptr

2020-08-24 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:351
 
+bool SmartPtrModeling::handleEqOp(const CallEvent &Call,
+  CheckerContext &C) const {

xazax.hun wrote:
> I'd prefer to call this AssignOp to avoid confusion with `==`. While your 
> naming is correct, I always found this nomenclature confusing.
IMO it's not a question of preference with this one, `EqOp` is misleading.



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:399
+ArgRegion->printPretty(OS);
+OS << " is null after moved to ";
+ThisRegion->printPretty(OS);

The grammar seems off in this one.  I think it should be smith like "after 
being moved to" or "after it was moved to".



Comment at: clang/test/Analysis/smart-ptr-text-output.cpp:132
+  std::unique_ptr PToMove; // expected-note {{Default constructed smart 
pointer 'PToMove' is null}}
+  P = std::move(PToMove); // expected-note {{Smart pointer 'P' is null after a 
null value moved from 'PToMove'}}
+  P->foo(); // expected-warning {{Dereference of null smart pointer 'P' 
[alpha.cplusplus.SmartPtr]}}

NoQ wrote:
> I suggest: `Null pointer value move-assigned to 'P'`.
+1


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86293

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


[PATCH] D86027: [analyzer] Add bool operator modeling for unque_ptr

2020-08-24 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:404
 
+void SmartPtrModeling::handleBoolOperation(const CallEvent &Call,
+   CheckerContext &C) const {

I suggest `BoolConversion`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86027

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


[PATCH] D81083: [Clang] Allow "vector_size" applied to Booleans

2020-08-24 Thread Simon Moll via Phabricator via cfe-commits
simoll added a comment.

The Hexagon builtins explicitly require bool vectors to have 8-bit wide bool 
elements. That clashes with our new vector type because bool vectors in builtin 
functions and vector_size bool vectors have the same internal representation in 
Clang. However, AFAIK Hexagon is the only target that actually need 8-bit 
bools. I see two possible ways out of this:

1. Introduce a `Bit` type in Clang that is only constructible as a vector 
element type. This way, any existing users of generic bool vectors are 
undisturbed. VE can use `Bit` in its builtin declarations to match the 
vector_size bool type. We may re-purpose the `Bit` type for a proper boolean 
vector type in the future.
2. Add a new target property: `BoolInVectorSize` that is the size of a bool 
element in boolean vectors. Hexagon, as most targets, would define 
`BoolInVectorSize = BoolSize`. VE would define `BoolInVectorSize = 1` for the 
intended behavior.

My preference is for 2. since it means small changes to the current patch and 
less surprises than the other option. Opinions?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81083

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


[PATCH] D85736: [Sema][AArch64] Support arm_sve_vector_bits attribute

2020-08-24 Thread Cullen Rhodes via Phabricator via cfe-commits
c-rhodes added a comment.

ping


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

https://reviews.llvm.org/D85736

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


[PATCH] D86295: [analyzer] Reorder the layout of MemRegion and cache by hand for optimal size

2020-08-24 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

In D86295#2232005 , @steakhal wrote:

> In D86295#2231760 , @NoQ wrote:
>
>> I mean, like, you can measure the entire process with `time` or something 
>> like that. I believe @vsavchenko's docker thingy already knows how to do 
>> that.
>
> I tried to measure this with `time`, without much luck:
> F12735724: time-verbose-results.txt 
>
>> What i'm trying to say is that for almost every region //R// it's a trivial 
>> O(1) operation that yields `RegionOffset` (//R//, +0). It is only 
>> non-trivial for non-base regions like `FieldRegion` or `ElementRegion` or, 
>> well, `CXXBaseObjectRegion`.
>
> What should be my next step?

Can we see any improvements in CPU counters (Linux)?

  # Detailed CPU counter statistics (includes extras) for the specified command:
  perf stat -d command


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86295

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


[PATCH] D86295: [analyzer] Reorder the layout of MemRegion and cache by hand for optimal size

2020-08-24 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

In D86295#2233068 , @martong wrote:

> In D86295#2232005 , @steakhal wrote:
>
>> In D86295#2231760 , @NoQ wrote:
>>
>>> I mean, like, you can measure the entire process with `time` or something 
>>> like that. I believe @vsavchenko's docker thingy already knows how to do 
>>> that.
>>
>> I tried to measure this with `time`, without much luck:
>> F12735724: time-verbose-results.txt 
>>
>>> What i'm trying to say is that for almost every region //R// it's a trivial 
>>> O(1) operation that yields `RegionOffset` (//R//, +0). It is only 
>>> non-trivial for non-base regions like `FieldRegion` or `ElementRegion` or, 
>>> well, `CXXBaseObjectRegion`.
>>
>> What should be my next step?
>
> Can we see any improvements in CPU counters (Linux)?
>
>   # Detailed CPU counter statistics (includes extras) for the specified 
> command:
>   perf stat -d command

I am hoping to see a decrease in L1 
-dcache-load-misses ...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86295

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


[PATCH] D86295: [analyzer] Reorder the layout of MemRegion and cache by hand for optimal size

2020-08-24 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

In D86295#2231760 , @NoQ wrote:

> I believe @vsavchenko's docker thingy already knows how to do that.

Yep, it sure does!  Additionally, there is a `benchmark` subcommand that can 
chart memory consumption for measured projects.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86295

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


[PATCH] D83048: [LiveDebugValues] 3/4 Add Xclang and CodeGen options for using instr-ref variable locations

2020-08-24 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro accepted this revision.
djtodoro added a comment.
This revision is now accepted and ready to land.

nit included, otherwise lgtm, thanks!




Comment at: llvm/lib/CodeGen/LiveDebugValues/LiveDebugValues.cpp:45
+  ~LiveDebugValues()
+  {
+if (TheImpl)

is this clang-formatted?




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

https://reviews.llvm.org/D83048

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


[PATCH] D86437: [SyntaxTree] Split array declarator tests

2020-08-24 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
eduucaldas requested review of this revision.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86437

Files:
  clang/unittests/Tooling/Syntax/BuildTreeTest.cpp

Index: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -3342,45 +3342,63 @@
 )txt"));
 }
 
-TEST_P(SyntaxTreeTest, ArraySubscriptsInDeclarators) {
+TEST_P(SyntaxTreeTest, ArrayDeclarator_Simple) {
   EXPECT_TRUE(treeDumpEqual(
   R"cpp(
 int a[10];
+)cpp",
+  R"txt(
+*: TranslationUnit
+`-SimpleDeclaration
+  |-int
+  |-SimpleDeclarator
+  | |-a
+  | `-ArraySubscript
+  |   |-[
+  |   |-IntegerLiteralExpression
+  |   | `-10
+  |   `-]
+  `-;
+)txt"));
+}
+
+TEST_P(SyntaxTreeTest, ArrayDeclarator_Multidimensional) {
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
 int b[1][2][3];
+)cpp",
+  R"txt(
+*: TranslationUnit
+`-SimpleDeclaration
+  |-int
+  |-SimpleDeclarator
+  | |-b
+  | |-ArraySubscript
+  | | |-[
+  | | |-IntegerLiteralExpression
+  | | | `-1
+  | | `-]
+  | |-ArraySubscript
+  | | |-[
+  | | |-IntegerLiteralExpression
+  | | | `-2
+  | | `-]
+  | `-ArraySubscript
+  |   |-[
+  |   |-IntegerLiteralExpression
+  |   | `-3
+  |   `-]
+  `-;
+)txt"));
+}
+
+TEST_P(SyntaxTreeTest, ArrayDeclarator_UnknownBound) {
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
 int c[] = {1,2,3};
 )cpp",
   R"txt(
 *: TranslationUnit
-|-SimpleDeclaration
-| |-int
-| |-SimpleDeclarator
-| | |-a
-| | `-ArraySubscript
-| |   |-[
-| |   |-IntegerLiteralExpression
-| |   | `-10
-| |   `-]
-| `-;
-|-SimpleDeclaration
-| |-int
-| |-SimpleDeclarator
-| | |-b
-| | |-ArraySubscript
-| | | |-[
-| | | |-IntegerLiteralExpression
-| | | | `-1
-| | | `-]
-| | |-ArraySubscript
-| | | |-[
-| | | |-IntegerLiteralExpression
-| | | | `-2
-| | | `-]
-| | `-ArraySubscript
-| |   |-[
-| |   |-IntegerLiteralExpression
-| |   | `-3
-| |   `-]
-| `-;
 `-SimpleDeclaration
   |-int
   |-SimpleDeclarator
@@ -3405,7 +3423,7 @@
 )txt"));
 }
 
-TEST_P(SyntaxTreeTest, StaticArraySubscriptsInDeclarators) {
+TEST_P(SyntaxTreeTest, ArrayDeclarator_Static) {
   if (!GetParam().isC99OrLater()) {
 return;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] ada2e8e - Reland "Correctly emit dwoIDs after ASTFileSignature refactoring (D81347)"

2020-08-24 Thread Raphael Isemann via cfe-commits

Author: Raphael Isemann
Date: 2020-08-24T11:51:32+02:00
New Revision: ada2e8ea67393aa8c44fe8e9d46be62df6d1c702

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

LOG: Reland "Correctly emit dwoIDs after ASTFileSignature refactoring (D81347)"

This relands D84013 but with a test that relies on less shell features to
hopefully make the test pass on Fuchsia (where the test from the previous patch
version strangely failed with a plain "Exit code 1").

Original summary:

D81347 changes the ASTFileSignature to be an array of 20 uint8_t instead of 5 
uint32_t.
However, it didn't update the code in ObjectFilePCHContainerOperations that 
creates
the dwoID in the module from the ASTFileSignature (`Buffer->Signature` being the
array subclass that is now `std::array` instead of 
`std::array`).

```
  uint64_t Signature = [..] (uint64_t)Buffer->Signature[1] << 32 | 
Buffer->Signature[0]
```

This code works with the old ASTFileSignature  (where two uint32_t are enough to
fill the uint64_t), but after the patch this only took two bytes from the 
ASTFileSignature
and only partly filled the Signature uint64_t.

This caused that the dwoID in the module ref and the dwoID in the actual module 
no
longer match (which in turns causes that LLDB keeps warning about the dwoID's 
not
matching when debugging -gmodules-compiled binaries).

This patch just unifies the logic for turning the ASTFileSignature into an 
uint64_t which
makes the dwoID match again (and should prevent issues like that in the future).

Reviewed By: aprantl, dang

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

Added: 
clang/test/Modules/Inputs/DebugDwoId.h
clang/test/Modules/ModuleDebugInfoDwoId.cpp

Modified: 
clang/include/clang/Basic/Module.h
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
clang/test/Modules/Inputs/module.map

Removed: 




diff  --git a/clang/include/clang/Basic/Module.h 
b/clang/include/clang/Basic/Module.h
index 94dd21537966..ac33c7573f35 100644
--- a/clang/include/clang/Basic/Module.h
+++ b/clang/include/clang/Basic/Module.h
@@ -62,6 +62,15 @@ struct ASTFileSignature : std::array {
 
   explicit operator bool() const { return *this != BaseT({{0}}); }
 
+  /// Returns the value truncated to the size of an uint64_t.
+  uint64_t truncatedValue() const {
+uint64_t Value = 0;
+static_assert(sizeof(*this) >= sizeof(uint64_t), "No need to truncate.");
+for (unsigned I = 0; I < sizeof(uint64_t); ++I)
+  Value |= static_cast((*this)[I]) << (I * 8);
+return Value;
+  }
+
   static ASTFileSignature create(StringRef Bytes) {
 return create(Bytes.bytes_begin(), Bytes.bytes_end());
   }

diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 2faf944d07d1..e3442ecd4bd5 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2545,12 +2545,11 @@ llvm::DIModule 
*CGDebugInfo::getOrCreateModuleRef(ASTSourceDescriptor Mod,
 // We use the lower 64 bits for debug info.
 
 uint64_t Signature = 0;
-if (const auto &ModSig = Mod.getSignature()) {
-  for (unsigned I = 0; I != sizeof(Signature); ++I)
-Signature |= (uint64_t)ModSig[I] << (I * 8);
-} else {
+if (const auto &ModSig = Mod.getSignature())
+  Signature = ModSig.truncatedValue();
+else
   Signature = ~1ULL;
-}
+
 llvm::DIBuilder DIB(CGM.getModule());
 SmallString<0> PCM;
 if (!llvm::sys::path::is_absolute(Mod.getASTFile()))

diff  --git a/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp 
b/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
index 0c7e5f4598f8..04bd6680e31c 100644
--- a/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
+++ b/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
@@ -250,10 +250,10 @@ class PCHContainerGenerator : public ASTConsumer {
 // PCH files don't have a signature field in the control block,
 // but LLVM detects DWO CUs by looking for a non-zero DWO id.
 // We use the lower 64 bits for debug info.
+
 uint64_t Signature =
-Buffer->Signature
-? (uint64_t)Buffer->Signature[1] << 32 | Buffer->Signature[0]
-: ~1ULL;
+Buffer->Signature ? Buffer->Signature.truncatedValue() : ~1ULL;
+
 Builder->getModuleDebugInfo()->setDwoId(Signature);
 
 // Finalize the Builder.

diff  --git a/clang/test/Modules/Inputs/DebugDwoId.h 
b/clang/test/Modules/Inputs/DebugDwoId.h
new file mode 100644
index ..242e4c7f5116
--- /dev/null
+++ b/clang/test/Modules/Inputs/DebugDwoId.h
@@ -0,0 +1,4 @@
+#ifndef DEBUG_DWO_ID_H
+#define DEBUG_DWO_ID_H
+struct Dummy {};
+#endif

diff  --git a/clang/test/Modules/Inputs/module.map 
b/clang/test/Modules/Inputs/module.map
index

[PATCH] D84013: Correctly emit dwoIDs after ASTFileSignature refactoring (D81347)

2020-08-24 Thread Raphael Isemann via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGada2e8ea6739: Reland "Correctly emit dwoIDs after 
ASTFileSignature refactoring (D81347)" (authored by teemperor).

Changed prior to commit:
  https://reviews.llvm.org/D84013?vs=287017&id=287318#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84013

Files:
  clang/include/clang/Basic/Module.h
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
  clang/test/Modules/Inputs/DebugDwoId.h
  clang/test/Modules/Inputs/module.map
  clang/test/Modules/ModuleDebugInfoDwoId.cpp

Index: clang/test/Modules/ModuleDebugInfoDwoId.cpp
===
--- /dev/null
+++ clang/test/Modules/ModuleDebugInfoDwoId.cpp
@@ -0,0 +1,22 @@
+// Tests that dwoIds in modules match the dwoIDs in the main file.
+
+// RUN: rm -rf %t.cache
+// RUN: %clang_cc1 -triple %itanium_abi_triple -x objective-c++ -std=c++11 -debugger-tuning=lldb -debug-info-kind=limited -fmodules -fmodule-format=obj -dwarf-ext-refs -fimplicit-module-maps -fmodules-cache-path=%t.cache %s -I %S/Inputs -emit-llvm -o %t.ll -mllvm -debug-only=pchcontainer 2> %t.mod-out
+// RUN: cat %t.ll > %t.combined_output
+// RUN: cat %t.mod-out >> %t.combined_output
+// RUN: cat %t.combined_output | FileCheck %s
+// RUN: cat %t.ll | FileCheck --check-prefix=CHECK-REALIDS %s
+// RUN: cat %t.mod-out | FileCheck --check-prefix=CHECK-REALIDS %s
+
+@import DebugDwoId;
+
+Dummy d;
+
+// Find the emitted dwoID for DebugInfoId and compare it against the one in the PCM.
+// CHECK: DebugDwoId-{{[A-Z0-9]+}}.pcm
+// CHECK-SAME: dwoId: [[DWOID:[0-9]+]]
+// CHECK: dwoId: [[DWOID]]
+// CHECK-NEXT: !DIFile(filename: "DebugDwoId"
+
+// Make sure the dwo IDs are real IDs and not fallback values (~1ULL).
+// CHECK-REALIDS-NOT: dwoId: 18446744073709551615
Index: clang/test/Modules/Inputs/module.map
===
--- clang/test/Modules/Inputs/module.map
+++ clang/test/Modules/Inputs/module.map
@@ -357,6 +357,10 @@
   }
 }
 
+module DebugDwoId {
+  header "DebugDwoId.h"
+}
+
 module ImportNameInDir {
   header "ImportNameInDir.h"
   export *
Index: clang/test/Modules/Inputs/DebugDwoId.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/DebugDwoId.h
@@ -0,0 +1,4 @@
+#ifndef DEBUG_DWO_ID_H
+#define DEBUG_DWO_ID_H
+struct Dummy {};
+#endif
Index: clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
===
--- clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
+++ clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
@@ -250,10 +250,10 @@
 // PCH files don't have a signature field in the control block,
 // but LLVM detects DWO CUs by looking for a non-zero DWO id.
 // We use the lower 64 bits for debug info.
+
 uint64_t Signature =
-Buffer->Signature
-? (uint64_t)Buffer->Signature[1] << 32 | Buffer->Signature[0]
-: ~1ULL;
+Buffer->Signature ? Buffer->Signature.truncatedValue() : ~1ULL;
+
 Builder->getModuleDebugInfo()->setDwoId(Signature);
 
 // Finalize the Builder.
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2545,12 +2545,11 @@
 // We use the lower 64 bits for debug info.
 
 uint64_t Signature = 0;
-if (const auto &ModSig = Mod.getSignature()) {
-  for (unsigned I = 0; I != sizeof(Signature); ++I)
-Signature |= (uint64_t)ModSig[I] << (I * 8);
-} else {
+if (const auto &ModSig = Mod.getSignature())
+  Signature = ModSig.truncatedValue();
+else
   Signature = ~1ULL;
-}
+
 llvm::DIBuilder DIB(CGM.getModule());
 SmallString<0> PCM;
 if (!llvm::sys::path::is_absolute(Mod.getASTFile()))
Index: clang/include/clang/Basic/Module.h
===
--- clang/include/clang/Basic/Module.h
+++ clang/include/clang/Basic/Module.h
@@ -62,6 +62,15 @@
 
   explicit operator bool() const { return *this != BaseT({{0}}); }
 
+  /// Returns the value truncated to the size of an uint64_t.
+  uint64_t truncatedValue() const {
+uint64_t Value = 0;
+static_assert(sizeof(*this) >= sizeof(uint64_t), "No need to truncate.");
+for (unsigned I = 0; I < sizeof(uint64_t); ++I)
+  Value |= static_cast((*this)[I]) << (I * 8);
+return Value;
+  }
+
   static ASTFileSignature create(StringRef Bytes) {
 return create(Bytes.bytes_begin(), Bytes.bytes_end());
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D86439: [SyntaxTree] Use annotations to reduce noise on member function tests

2020-08-24 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
eduucaldas requested review of this revision.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86439

Files:
  clang/unittests/Tooling/Syntax/BuildTreeTest.cpp

Index: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -2570,61 +2570,47 @@
   if (!GetParam().isCXX11OrLater()) {
 return;
   }
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
 struct S {
-  static void f(){}
+  [[static void f(){}]]
 };
 )cpp",
-  R"txt(
-*: TranslationUnit
-`-SimpleDeclaration
-  |-struct
-  |-S
+  {R"txt(
+SimpleDeclaration
+|-static
+|-void
+|-SimpleDeclarator
+| |-f
+| `-ParametersAndQualifiers
+|   |-(
+|   `-)
+`-CompoundStatement
   |-{
-  |-SimpleDeclaration
-  | |-static
-  | |-void
-  | |-SimpleDeclarator
-  | | |-f
-  | | `-ParametersAndQualifiers
-  | |   |-(
-  | |   `-)
-  | `-CompoundStatement
-  |   |-{
-  |   `-}
-  |-}
-  `-;
-)txt"));
+  `-}
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, ConversionMemberFunction) {
   if (!GetParam().isCXX()) {
 return;
   }
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
 struct X {
-  operator int();
+  [[operator int();]]
 };
 )cpp",
-  R"txt(
-*: TranslationUnit
-`-SimpleDeclaration
-  |-struct
-  |-X
-  |-{
-  |-SimpleDeclaration
-  | |-SimpleDeclarator
-  | | |-operator
-  | | |-int
-  | | `-ParametersAndQualifiers
-  | |   |-(
-  | |   `-)
-  | `-;
-  |-}
-  `-;
-)txt"));
+  {R"txt(
+SimpleDeclaration
+|-SimpleDeclarator
+| |-operator
+| |-int
+| `-ParametersAndQualifiers
+|   |-(
+|   `-)
+`-;
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, LiteralOperatorDeclaration) {
@@ -2687,76 +2673,62 @@
   if (!GetParam().isCXX()) {
 return;
   }
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
 struct X {
-  X& operator=(const X&);
+  [[X& operator=(const X&);]]
 };
 )cpp",
-  R"txt(
-*: TranslationUnit
-`-SimpleDeclaration
-  |-struct
-  |-X
-  |-{
-  |-SimpleDeclaration
-  | |-X
-  | |-SimpleDeclarator
-  | | |-&
-  | | |-operator
-  | | |-=
-  | | `-ParametersAndQualifiers
-  | |   |-(
-  | |   |-SimpleDeclaration
-  | |   | |-const
-  | |   | |-X
-  | |   | `-SimpleDeclarator
-  | |   |   `-&
-  | |   `-)
-  | `-;
-  |-}
-  `-;
-)txt"));
+  {R"txt(
+SimpleDeclaration
+|-X
+|-SimpleDeclarator
+| |-&
+| |-operator
+| |-=
+| `-ParametersAndQualifiers
+|   |-(
+|   |-SimpleDeclaration
+|   | |-const
+|   | |-X
+|   | `-SimpleDeclarator
+|   |   `-&
+|   `-)
+`-;
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, OverloadedOperatorFriendDeclarataion) {
   if (!GetParam().isCXX()) {
 return;
   }
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
 struct X {
-  friend X operator+(X, const X&);
+  [[friend X operator+(X, const X&);]]
 };
 )cpp",
-  R"txt(
-*: TranslationUnit
+  {R"txt(
+UnknownDeclaration
 `-SimpleDeclaration
-  |-struct
+  |-friend
   |-X
-  |-{
-  |-UnknownDeclaration
-  | `-SimpleDeclaration
-  |   |-friend
-  |   |-X
-  |   |-SimpleDeclarator
-  |   | |-operator
-  |   | |-+
-  |   | `-ParametersAndQualifiers
-  |   |   |-(
-  |   |   |-SimpleDeclaration
-  |   |   | `-X
-  |   |   |-,
-  |   |   |-SimpleDeclaration
-  |   |   | |-const
-  |   |   | |-X
-  |   |   | `-SimpleDeclarator
-  |   |   |   `-&
-  |   |   `-)
-  |   `-;
-  |-}
+  |-SimpleDeclarator
+  | |-operator
+  | |-+
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   |-SimpleDeclaration
+  |   | `-X
+  |   |-,
+  |   |-SimpleDeclaration
+  |   | |-const
+  |   | |-X
+  |   | `-SimpleDeclarator
+  |   |   `-&
+  |   `-)
   `-;
-)txt"));
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, ClassTemplateDeclaration) {
@@ -2847,38 +2819,31 @@
   if (!GetParam().isCXX()) {
 return;
   }
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
 struct S {
-  template
-  static U f();
+  [[template
+  static U f();]]
 };
 )cpp",
-  R"txt(
-*: TranslationUnit
+  {R"txt(
+TemplateDeclaration
+|-template
+|-<
+|-UnknownDeclaration
+| |-typename
+| `-U
+|->
 `-SimpleDeclaration
-  |-struct
-  |-S
-  |-{
-  |-TemplateDeclaration
-  | |-template
-  | |-<
-  | |-UnknownDeclaration
-  | | |-typename
-  | | `-U
-  | |->
-  | `-SimpleDeclaration
-  |   |-static
-  |   |-U
-  |   |-SimpleDeclarator
-  |   | |-f
-  |   | `-ParametersAndQualifiers
-  |   |   |-(
-  |   |   `-)
-  |   `-;
-  |-}
+  |-static
+  |-U
+  |-SimpleDeclarator
+  | |-f
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   `-)
   `-;
-)txt"));
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, NestedTemplates) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commi

[PATCH] D86295: [analyzer] Reorder the layout of MemRegion and cache by hand for optimal size

2020-08-24 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

In D86295#2233076 , @vsavchenko wrote:

> In D86295#2231760 , @NoQ wrote:
>
>> I believe @vsavchenko's docker thingy already knows how to do that.
>
> Yep, it sure does!  Additionally, there is a `benchmark` subcommand that can 
> chart memory consumption for measured projects.

Could you point me to some docs to help getting started? I haven't used this 
docker image.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86295

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


[PATCH] D86440: [SyntaxTree] Split FreeStandingClass tests

2020-08-24 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
eduucaldas requested review of this revision.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86440

Files:
  clang/unittests/Tooling/Syntax/BuildTreeTest.cpp

Index: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -2515,55 +2515,65 @@
 )txt"}));
 }
 
-TEST_P(SyntaxTreeTest, FreeStandingClasses) {
-  // Free-standing classes, must live inside a SimpleDeclaration.
-  EXPECT_TRUE(treeDumpEqual(
+TEST_P(SyntaxTreeTest, FreeStandingClass_ForwardDeclaration) {
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
-struct X;
-struct X {};
-
-struct Y *y1;
-struct Y {} *y2;
+[[struct X;]]
+[[struct Y *y1;]]
+)cpp",
+  {R"txt(
+SimpleDeclaration
+|-struct
+|-X
+`-;
+)txt",
+   R"txt(
+SimpleDeclaration
+|-struct
+|-Y
+|-SimpleDeclarator
+| |-*
+| `-y1
+`-;
+)txt"}));
+}
 
-struct {} *a1;
+TEST_P(SyntaxTreeTest, FreeStandingClasses_Definition) {
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
+  R"cpp(
+[[struct X {};]]
+[[struct Y {} *y2;]]
+[[struct {} *a1;]]
 )cpp",
-  R"txt(
-*: TranslationUnit
-|-SimpleDeclaration
-| |-struct
-| |-X
-| `-;
-|-SimpleDeclaration
-| |-struct
-| |-X
-| |-{
-| |-}
-| `-;
-|-SimpleDeclaration
-| |-struct
-| |-Y
-| |-SimpleDeclarator
-| | |-*
-| | `-y1
-| `-;
-|-SimpleDeclaration
-| |-struct
-| |-Y
-| |-{
-| |-}
-| |-SimpleDeclarator
-| | |-*
-| | `-y2
-| `-;
-`-SimpleDeclaration
-  |-struct
-  |-{
-  |-}
-  |-SimpleDeclarator
-  | |-*
-  | `-a1
-  `-;
-)txt"));
+  {R"txt(
+SimpleDeclaration
+|-struct
+|-X
+|-{
+|-}
+`-;
+)txt",
+   R"txt(
+SimpleDeclaration
+|-struct
+|-Y
+|-{
+|-}
+|-SimpleDeclarator
+| |-*
+| `-y2
+`-;
+)txt",
+   R"txt(
+SimpleDeclaration
+|-struct
+|-{
+|-}
+|-SimpleDeclarator
+| |-*
+| `-a1
+`-;
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, StaticMemberFunction) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D86441: [SyntaxTree] Split ExplicitTemplateInstantiation test

2020-08-24 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
eduucaldas requested review of this revision.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86441

Files:
  clang/unittests/Tooling/Syntax/BuildTreeTest.cpp

Index: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -3051,84 +3051,105 @@
 )txt"));
 }
 
-TEST_P(SyntaxTreeTest, ExplicitTemplateInstantations) {
+TEST_P(SyntaxTreeTest, ExplicitTemplateInstantation_Definition) {
   if (!GetParam().isCXX()) {
 return;
   }
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
 template  struct X {};
-template  struct X {};
-template <> struct X {};
+[[template struct X;]]
+)cpp",
+  {R"txt(
+ExplicitTemplateInstantiation
+|-template
+`-SimpleDeclaration
+  |-struct
+  |-X
+  |-<
+  |-double
+  |->
+  `-;
+)txt"}));
+}
 
-template struct X;
-extern template struct X;
+TEST_P(SyntaxTreeTest, ExplicitTemplateInstantation_Declaration) {
+  if (!GetParam().isCXX()) {
+return;
+  }
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
+  R"cpp(
+template  struct X {};
+[[extern template struct X;]]
 )cpp",
-  R"txt(
-*: TranslationUnit
-|-TemplateDeclaration
-| |-template
-| |-<
-| |-UnknownDeclaration
-| | |-class
-| | `-T
-| |->
-| `-SimpleDeclaration
-|   |-struct
-|   |-X
-|   |-{
-|   |-}
-|   `-;
-|-TemplateDeclaration
-| |-template
-| |-<
-| |-UnknownDeclaration
-| | |-class
-| | `-T
-| |->
-| `-SimpleDeclaration
-|   |-struct
-|   |-X
-|   |-<
-|   |-T
-|   |-*
-|   |->
-|   |-{
-|   |-}
-|   `-;
-|-TemplateDeclaration
-| |-template
-| |-<
-| |->
-| `-SimpleDeclaration
-|   |-struct
-|   |-X
-|   |-<
-|   |-int
-|   |->
-|   |-{
-|   |-}
-|   `-;
-|-ExplicitTemplateInstantiation
-| |-template
-| `-SimpleDeclaration
-|   |-struct
-|   |-X
-|   |-<
-|   |-double
-|   |->
-|   `-;
-`-ExplicitTemplateInstantiation
-  |-extern
-  |-template
-  `-SimpleDeclaration
-|-struct
-|-X
-|-<
-|-float
-|->
-`-;
-)txt"));
+  {R"txt(
+ExplicitTemplateInstantiation
+|-extern
+|-template
+`-SimpleDeclaration
+  |-struct
+  |-X
+  |-<
+  |-float
+  |->
+  `-;
+)txt"}));
+}
+
+TEST_P(SyntaxTreeTest, TemplateSpecialization_Partial) {
+  if (!GetParam().isCXX()) {
+return;
+  }
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
+  R"cpp(
+template  struct X {};
+[[template  struct X {};]]
+)cpp",
+  {R"txt(
+TemplateDeclaration
+|-template
+|-<
+|-UnknownDeclaration
+| |-class
+| `-T
+|->
+`-SimpleDeclaration
+  |-struct
+  |-X
+  |-<
+  |-T
+  |-*
+  |->
+  |-{
+  |-}
+  `-;
+)txt"}));
+}
+
+TEST_P(SyntaxTreeTest, TemplateSpecialization_Full) {
+  if (!GetParam().isCXX()) {
+return;
+  }
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
+  R"cpp(
+template  struct X {};
+[[template <> struct X {};]]
+)cpp",
+  {R"txt(
+TemplateDeclaration
+|-template
+|-<
+|->
+`-SimpleDeclaration
+  |-struct
+  |-X
+  |-<
+  |-int
+  |->
+  |-{
+  |-}
+  `-;
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, UsingType) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D86443: [SyntaxTree] Group tests related to `using`

2020-08-24 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
eduucaldas requested review of this revision.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86443

Files:
  clang/unittests/Tooling/Syntax/BuildTreeTest.cpp

Index: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -2494,7 +2494,7 @@
 )txt"}));
 }
 
-TEST_P(SyntaxTreeTest, UsingDeclaration) {
+TEST_P(SyntaxTreeTest, UsingDeclaration_Namespace) {
   if (!GetParam().isCXX()) {
 return;
   }
@@ -2515,6 +2515,59 @@
 )txt"}));
 }
 
+TEST_P(SyntaxTreeTest, UsingDeclaration_ClassMember) {
+  if (!GetParam().isCXX()) {
+return;
+  }
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
+  R"cpp(
+template  struct X {
+  [[using T::foo;]]
+  [[using typename T::bar;]]
+};
+)cpp",
+  {R"txt(
+UsingDeclaration
+|-using
+|-NestedNameSpecifier
+| |-IdentifierNameSpecifier
+| | `-T
+| `-::
+|-foo
+`-;
+)txt",
+   R"txt(
+UsingDeclaration
+|-using
+|-typename
+|-NestedNameSpecifier
+| |-IdentifierNameSpecifier
+| | `-T
+| `-::
+|-bar
+`-;
+)txt"}));
+}
+
+TEST_P(SyntaxTreeTest, UsingTypeAlias) {
+  if (!GetParam().isCXX()) {
+return;
+  }
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+using type = int;
+)cpp",
+  R"txt(
+*: TranslationUnit
+`-TypeAliasDeclaration
+  |-using
+  |-type
+  |-=
+  |-int
+  `-;
+)txt"));
+}
+
 TEST_P(SyntaxTreeTest, FreeStandingClass_ForwardDeclaration) {
   EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
@@ -3005,52 +3058,6 @@
 )txt"));
 }
 
-TEST_P(SyntaxTreeTest, TemplatesUsingUsing) {
-  if (!GetParam().isCXX()) {
-return;
-  }
-  EXPECT_TRUE(treeDumpEqual(
-  R"cpp(
-template  struct X {
-  using T::foo;
-  using typename T::bar;
-};
-)cpp",
-  R"txt(
-*: TranslationUnit
-`-TemplateDeclaration
-  |-template
-  |-<
-  |-UnknownDeclaration
-  | |-class
-  | `-T
-  |->
-  `-SimpleDeclaration
-|-struct
-|-X
-|-{
-|-UsingDeclaration
-| |-using
-| |-NestedNameSpecifier
-| | |-IdentifierNameSpecifier
-| | | `-T
-| | `-::
-| |-foo
-| `-;
-|-UsingDeclaration
-| |-using
-| |-typename
-| |-NestedNameSpecifier
-| | |-IdentifierNameSpecifier
-| | | `-T
-| | `-::
-| |-bar
-| `-;
-|-}
-`-;
-)txt"));
-}
-
 TEST_P(SyntaxTreeTest, ExplicitTemplateInstantation_Definition) {
   if (!GetParam().isCXX()) {
 return;
@@ -3152,25 +3159,6 @@
 )txt"}));
 }
 
-TEST_P(SyntaxTreeTest, UsingType) {
-  if (!GetParam().isCXX()) {
-return;
-  }
-  EXPECT_TRUE(treeDumpEqual(
-  R"cpp(
-using type = int;
-)cpp",
-  R"txt(
-*: TranslationUnit
-`-TypeAliasDeclaration
-  |-using
-  |-type
-  |-=
-  |-int
-  `-;
-)txt"));
-}
-
 TEST_P(SyntaxTreeTest, EmptyDeclaration) {
   EXPECT_TRUE(treeDumpEqual(
   R"cpp(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D86441: [SyntaxTree] Split ExplicitTemplateInstantiation test

2020-08-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/BuildTreeTest.cpp:3054
 
-TEST_P(SyntaxTreeTest, ExplicitTemplateInstantations) {
+TEST_P(SyntaxTreeTest, ExplicitTemplateInstantation_Definition) {
   if (!GetParam().isCXX()) {





Comment at: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp:3076
 
-template struct X;
-extern template struct X;
+TEST_P(SyntaxTreeTest, ExplicitTemplateInstantation_Declaration) {
+  if (!GetParam().isCXX()) {





Comment at: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp:3099
+
+TEST_P(SyntaxTreeTest, TemplateSpecialization_Partial) {
+  if (!GetParam().isCXX()) {





Comment at: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp:3129
+
+TEST_P(SyntaxTreeTest, TemplateSpecialization_Full) {
+  if (!GetParam().isCXX()) {




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86441

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


[PATCH] D84013: Correctly emit dwoIDs after ASTFileSignature refactoring (D81347)

2020-08-24 Thread David Zarzycki via Phabricator via cfe-commits
davezarzycki added a comment.

I have an auto-bisecting cron job that has identified the "reland" as breaking 
the test suite on Fedora 32 (x86). Is there a quick fix or can we revert the 
reland?

  FAIL: Clang :: Modules/ModuleDebugInfoDwoId.cpp (12657 of 68968)
   TEST 'Clang :: Modules/ModuleDebugInfoDwoId.cpp' FAILED 

  Script:
  --
  : 'RUN: at line 3';   rm -rf 
/tmp/_update_lc/r/tools/clang/test/Modules/Output/ModuleDebugInfoDwoId.cpp.tmp.cache
  : 'RUN: at line 4';   /tmp/_update_lc/r/bin/clang -cc1 -internal-isystem 
/tmp/_update_lc/r/lib/clang/12.0.0/include -nostdsysteminc -triple 
x86_64-unknown-linux-gnu -x objective-c++ -std=c++11 -debugger-tuning=lldb 
-debug-info-kind=limited -fmodules -fmodule-format=obj -dwarf-ext-refs 
-fimplicit-module-maps 
-fmodules-cache-path=/tmp/_update_lc/r/tools/clang/test/Modules/Output/ModuleDebugInfoDwoId.cpp.tmp.cache
 /home/dave/ro_s/lp/clang/test/Modules/ModuleDebugInfoDwoId.cpp -I 
/home/dave/ro_s/lp/clang/test/Modules/Inputs -emit-llvm -o 
/tmp/_update_lc/r/tools/clang/test/Modules/Output/ModuleDebugInfoDwoId.cpp.tmp.ll
 -mllvm -debug-only=pchcontainer 2> 
/tmp/_update_lc/r/tools/clang/test/Modules/Output/ModuleDebugInfoDwoId.cpp.tmp.mod-out
  : 'RUN: at line 5';   cat 
/tmp/_update_lc/r/tools/clang/test/Modules/Output/ModuleDebugInfoDwoId.cpp.tmp.ll
 > 
/tmp/_update_lc/r/tools/clang/test/Modules/Output/ModuleDebugInfoDwoId.cpp.tmp.combined_output
  : 'RUN: at line 6';   cat 
/tmp/_update_lc/r/tools/clang/test/Modules/Output/ModuleDebugInfoDwoId.cpp.tmp.mod-out
 >> 
/tmp/_update_lc/r/tools/clang/test/Modules/Output/ModuleDebugInfoDwoId.cpp.tmp.combined_output
  : 'RUN: at line 7';   cat 
/tmp/_update_lc/r/tools/clang/test/Modules/Output/ModuleDebugInfoDwoId.cpp.tmp.combined_output
 | /tmp/_update_lc/r/bin/FileCheck 
/home/dave/ro_s/lp/clang/test/Modules/ModuleDebugInfoDwoId.cpp
  : 'RUN: at line 8';   cat 
/tmp/_update_lc/r/tools/clang/test/Modules/Output/ModuleDebugInfoDwoId.cpp.tmp.ll
 | /tmp/_update_lc/r/bin/FileCheck --check-prefix=CHECK-REALIDS 
/home/dave/ro_s/lp/clang/test/Modules/ModuleDebugInfoDwoId.cpp
  : 'RUN: at line 9';   cat 
/tmp/_update_lc/r/tools/clang/test/Modules/Output/ModuleDebugInfoDwoId.cpp.tmp.mod-out
 | /tmp/_update_lc/r/bin/FileCheck --check-prefix=CHECK-REALIDS 
/home/dave/ro_s/lp/clang/test/Modules/ModuleDebugInfoDwoId.cpp
  --
  Exit Code: 1
  
  
  
  Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..
  
  Failed Tests (1):
Clang :: Modules/ModuleDebugInfoDwoId.cpp


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84013

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


[PATCH] D86295: [analyzer] Reorder the layout of MemRegion and cache by hand for optimal size

2020-08-24 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

In D86295#2233157 , @steakhal wrote:

> In D86295#2233076 , @vsavchenko 
> wrote:
>
>> In D86295#2231760 , @NoQ wrote:
>>
>>> I believe @vsavchenko's docker thingy already knows how to do that.
>>
>> Yep, it sure does!  Additionally, there is a `benchmark` subcommand that can 
>> chart memory consumption for measured projects.
>
> Could you point me to some docs to help getting started? I haven't used this 
> docker image.

I procrastinated the part about docs 😅 I will add those in the nearest future.

Here is a short summary how to do regression testing (check that all warnings 
are the same):

1. `cd clang/utils/analyzer`
2. Build test system's docker image (I assume that `docker` is installed): 
`./SATest.py docker --build-image`
3. Checkout commit that you want to compare against: `git checkout 
origin/master` or `git checkout HEAD^1`
4. Build LLVM in docker for Ubuntu (if you are on Linux you might not it): 
`./SATest.py docker --clang-dir {PATH_WHERE_IT_WILL_BE_INSTALLED} --build-dir 
{PATH_FOR_BUILD_DIR} -- --build-llvm-only`.  I usually put `--build-dir` next 
to my native build directories, ie `${LLVM_DIR}/build/Docker`
5. Gather reference results: `./SATest.py docker --clang-dir 
{PATH_WHERE_LLVM_IS_INSTALLED} --build-dir {PATH_FOR_BUILD_DIR} -- build -j1 -r`
6. Checkout your commit that you want to test: Checkout commit that you want to 
compare against: `git checkout master` or similar
7. Build LLVM with your patch: `./SATest.py docker --clang-dir 
{PATH_WHERE_IT_WILL_BE_INSTALLED} --build-dir {PATH_FOR_BUILD_DIR} -- 
--build-llvm-only`.  If you choose the same `--build-dir` it will get compiled 
incrementally and save you a lot of time.  TIP: you can choose another 
directory for `--clang-dir` so you don't need to rebuild previous version if 
you have to re-run it.
8. Gather new results and compare: `./SATest.py docker --clang-dir 
{PATH_WHERE_LLVM_IS_INSTALLED} --build-dir {PATH_FOR_BUILD_DIR} -- build -j1 
--strictness 2`.  NOTE: `SATest.py docker ... -- build` command accepts a 
comma-separated list of projects for the analysis, so you can choose which 
projects to test.

Benchmarking is very similar in it's nature, run original, run modified, 
compare:

5. `./SATest.py docker --clang-dir {PATH_WHERE_LLVM_IS_INSTALLED} --build-dir 
{PATH_FOR_BUILD_DIR} -- benchmark -o old.csv`
6. ...
7. ...
8. `./SATest.py docker --clang-dir {PATH_WHERE_LLVM_IS_INSTALLED} --build-dir 
{PATH_FOR_BUILD_DIR} -- benchmark -o new.csv`
9. `./SATest.py docker --clang-dir {PATH_WHERE_LLVM_IS_INSTALLED} --build-dir 
{PATH_FOR_BUILD_DIR} -- benchmark compare --old old.csv --new new.csv -o 
comparison.png`

Benchmarks can take a while (they run analysis on the same projects multiple 
times), so it is recommended to use it for smaller projects.  I will merge 
D83942  and after it you can change commands 
this way: `./SATest.py docker ... benchmark --max-size small -o blabla.csv`

If you want to see `--help` for a subcommand, drop `docker` and all the options 
and simply run `./SATest.py build --help` or `./SATest.py benchmark --help`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86295

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


[clang] 2b3074c - Revert "Reland "Correctly emit dwoIDs after ASTFileSignature refactoring (D81347)""

2020-08-24 Thread Raphael Isemann via cfe-commits

Author: Raphael Isemann
Date: 2020-08-24T12:54:25+02:00
New Revision: 2b3074c0d14cadbd9595346fc795d4a49a479a20

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

LOG: Revert "Reland "Correctly emit dwoIDs after ASTFileSignature refactoring 
(D81347)""

This reverts commit ada2e8ea67393aa8c44fe8e9d46be62df6d1c702. Still breaking
on Fuchsia (and also Fedora) with exit code 1, so back to investigating.

Added: 


Modified: 
clang/include/clang/Basic/Module.h
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
clang/test/Modules/Inputs/module.map

Removed: 
clang/test/Modules/Inputs/DebugDwoId.h
clang/test/Modules/ModuleDebugInfoDwoId.cpp



diff  --git a/clang/include/clang/Basic/Module.h 
b/clang/include/clang/Basic/Module.h
index ac33c7573f35..94dd21537966 100644
--- a/clang/include/clang/Basic/Module.h
+++ b/clang/include/clang/Basic/Module.h
@@ -62,15 +62,6 @@ struct ASTFileSignature : std::array {
 
   explicit operator bool() const { return *this != BaseT({{0}}); }
 
-  /// Returns the value truncated to the size of an uint64_t.
-  uint64_t truncatedValue() const {
-uint64_t Value = 0;
-static_assert(sizeof(*this) >= sizeof(uint64_t), "No need to truncate.");
-for (unsigned I = 0; I < sizeof(uint64_t); ++I)
-  Value |= static_cast((*this)[I]) << (I * 8);
-return Value;
-  }
-
   static ASTFileSignature create(StringRef Bytes) {
 return create(Bytes.bytes_begin(), Bytes.bytes_end());
   }

diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index e3442ecd4bd5..2faf944d07d1 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2545,11 +2545,12 @@ llvm::DIModule 
*CGDebugInfo::getOrCreateModuleRef(ASTSourceDescriptor Mod,
 // We use the lower 64 bits for debug info.
 
 uint64_t Signature = 0;
-if (const auto &ModSig = Mod.getSignature())
-  Signature = ModSig.truncatedValue();
-else
+if (const auto &ModSig = Mod.getSignature()) {
+  for (unsigned I = 0; I != sizeof(Signature); ++I)
+Signature |= (uint64_t)ModSig[I] << (I * 8);
+} else {
   Signature = ~1ULL;
-
+}
 llvm::DIBuilder DIB(CGM.getModule());
 SmallString<0> PCM;
 if (!llvm::sys::path::is_absolute(Mod.getASTFile()))

diff  --git a/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp 
b/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
index 04bd6680e31c..0c7e5f4598f8 100644
--- a/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
+++ b/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
@@ -250,10 +250,10 @@ class PCHContainerGenerator : public ASTConsumer {
 // PCH files don't have a signature field in the control block,
 // but LLVM detects DWO CUs by looking for a non-zero DWO id.
 // We use the lower 64 bits for debug info.
-
 uint64_t Signature =
-Buffer->Signature ? Buffer->Signature.truncatedValue() : ~1ULL;
-
+Buffer->Signature
+? (uint64_t)Buffer->Signature[1] << 32 | Buffer->Signature[0]
+: ~1ULL;
 Builder->getModuleDebugInfo()->setDwoId(Signature);
 
 // Finalize the Builder.

diff  --git a/clang/test/Modules/Inputs/DebugDwoId.h 
b/clang/test/Modules/Inputs/DebugDwoId.h
deleted file mode 100644
index 242e4c7f5116..
--- a/clang/test/Modules/Inputs/DebugDwoId.h
+++ /dev/null
@@ -1,4 +0,0 @@
-#ifndef DEBUG_DWO_ID_H
-#define DEBUG_DWO_ID_H
-struct Dummy {};
-#endif

diff  --git a/clang/test/Modules/Inputs/module.map 
b/clang/test/Modules/Inputs/module.map
index e7cb4b27bc08..ed220e667f05 100644
--- a/clang/test/Modules/Inputs/module.map
+++ b/clang/test/Modules/Inputs/module.map
@@ -357,10 +357,6 @@ module DebugObjCImport {
   }
 }
 
-module DebugDwoId {
-  header "DebugDwoId.h"
-}
-
 module ImportNameInDir {
   header "ImportNameInDir.h"
   export *

diff  --git a/clang/test/Modules/ModuleDebugInfoDwoId.cpp 
b/clang/test/Modules/ModuleDebugInfoDwoId.cpp
deleted file mode 100644
index 7a450c2580ea..
--- a/clang/test/Modules/ModuleDebugInfoDwoId.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-// Tests that dwoIds in modules match the dwoIDs in the main file.
-
-// RUN: rm -rf %t.cache
-// RUN: %clang_cc1 -triple %itanium_abi_triple -x objective-c++ -std=c++11 
-debugger-tuning=lldb -debug-info-kind=limited -fmodules -fmodule-format=obj 
-dwarf-ext-refs -fimplicit-module-maps -fmodules-cache-path=%t.cache %s -I 
%S/Inputs -emit-llvm -o %t.ll -mllvm -debug-only=pchcontainer 2> %t.mod-out
-// RUN: cat %t.ll > %t.combined_output
-// RUN: cat %t.mod-out >> %t.combined_output
-// RUN: cat %t.combined_output | FileCheck %s
-// RUN: cat %t.ll | FileCheck --check-prefix=CHECK-REALIDS %s
-// RUN: cat %t.mod-out | FileCheck --check-p

[PATCH] D86295: [analyzer] Reorder the layout of MemRegion and cache by hand for optimal size

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

I really like the patch, but have nothing to add to what other reviewers 
already said. Nice!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86295

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


[PATCH] D84013: Correctly emit dwoIDs after ASTFileSignature refactoring (D81347)

2020-08-24 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor added a comment.

In D84013#2233242 , @davezarzycki 
wrote:

> I have an auto-bisecting cron job that has identified the "reland" as 
> breaking the test suite on Fedora 32 (x86). Is there a quick fix or can we 
> revert the reland?
>
>   FAIL: Clang :: Modules/ModuleDebugInfoDwoId.cpp (12657 of 68968)
>    TEST 'Clang :: Modules/ModuleDebugInfoDwoId.cpp' 
> FAILED 
>   Script:
>   --
>   : 'RUN: at line 3';   rm -rf 
> /tmp/_update_lc/r/tools/clang/test/Modules/Output/ModuleDebugInfoDwoId.cpp.tmp.cache
>   : 'RUN: at line 4';   /tmp/_update_lc/r/bin/clang -cc1 -internal-isystem 
> /tmp/_update_lc/r/lib/clang/12.0.0/include -nostdsysteminc -triple 
> x86_64-unknown-linux-gnu -x objective-c++ -std=c++11 -debugger-tuning=lldb 
> -debug-info-kind=limited -fmodules -fmodule-format=obj -dwarf-ext-refs 
> -fimplicit-module-maps 
> -fmodules-cache-path=/tmp/_update_lc/r/tools/clang/test/Modules/Output/ModuleDebugInfoDwoId.cpp.tmp.cache
>  /home/dave/ro_s/lp/clang/test/Modules/ModuleDebugInfoDwoId.cpp -I 
> /home/dave/ro_s/lp/clang/test/Modules/Inputs -emit-llvm -o 
> /tmp/_update_lc/r/tools/clang/test/Modules/Output/ModuleDebugInfoDwoId.cpp.tmp.ll
>  -mllvm -debug-only=pchcontainer 2> 
> /tmp/_update_lc/r/tools/clang/test/Modules/Output/ModuleDebugInfoDwoId.cpp.tmp.mod-out
>   : 'RUN: at line 5';   cat 
> /tmp/_update_lc/r/tools/clang/test/Modules/Output/ModuleDebugInfoDwoId.cpp.tmp.ll
>  > 
> /tmp/_update_lc/r/tools/clang/test/Modules/Output/ModuleDebugInfoDwoId.cpp.tmp.combined_output
>   : 'RUN: at line 6';   cat 
> /tmp/_update_lc/r/tools/clang/test/Modules/Output/ModuleDebugInfoDwoId.cpp.tmp.mod-out
>  >> 
> /tmp/_update_lc/r/tools/clang/test/Modules/Output/ModuleDebugInfoDwoId.cpp.tmp.combined_output
>   : 'RUN: at line 7';   cat 
> /tmp/_update_lc/r/tools/clang/test/Modules/Output/ModuleDebugInfoDwoId.cpp.tmp.combined_output
>  | /tmp/_update_lc/r/bin/FileCheck 
> /home/dave/ro_s/lp/clang/test/Modules/ModuleDebugInfoDwoId.cpp
>   : 'RUN: at line 8';   cat 
> /tmp/_update_lc/r/tools/clang/test/Modules/Output/ModuleDebugInfoDwoId.cpp.tmp.ll
>  | /tmp/_update_lc/r/bin/FileCheck --check-prefix=CHECK-REALIDS 
> /home/dave/ro_s/lp/clang/test/Modules/ModuleDebugInfoDwoId.cpp
>   : 'RUN: at line 9';   cat 
> /tmp/_update_lc/r/tools/clang/test/Modules/Output/ModuleDebugInfoDwoId.cpp.tmp.mod-out
>  | /tmp/_update_lc/r/bin/FileCheck --check-prefix=CHECK-REALIDS 
> /home/dave/ro_s/lp/clang/test/Modules/ModuleDebugInfoDwoId.cpp
>   --
>   Exit Code: 1
>   
>   
>   
>   Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..
>   
>   Failed Tests (1):
> Clang :: Modules/ModuleDebugInfoDwoId.cpp

I'm still not sure why the test is failing ("Exit Code: 1" isn't incredibly 
enlightening), so I reverted in 2b3074c0d14cadbd9595346fc795d4a49a479a20 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84013

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


[PATCH] D86445: [analyzer][RFC] Simplify MetadataSymbol representation and resolve a CStringChecker FIXME

2020-08-24 Thread Balázs Benics via Phabricator via cfe-commits
steakhal created this revision.
steakhal added reviewers: NoQ, vsavchenko, xazax.hun, martong, Szelethus.
Herald added subscribers: cfe-commits, ASDenysPetrov, Charusso, dkrupp, 
donat.nagy, mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware, 
whisperity.
Herald added a project: clang.
steakhal requested review of this revision.

The `SymbolMetadata` handing was slightly flawed.
Given the following example:

  void strcat_models_dst_length_even_if_src_dies(char *src) {
char dst[8] = "1234";
strcat(dst, src);
clang_analyzer_eval(strlen(dst) >= 4); // expected-warning{{TRUE}}
  }

A metadata symbol was assigned to the cstring length map, representing the new 
length of the `dst`:
'`dst` -> `meta{src} + 4`' where `meta{src}` represents the cstring length of 
the region of `src`.
Unfortunately, this information was immediately removed from the model, since 
the `src` become dead after the evaluation of calling `strcat`.
This results in the removal of all symbolic expressions (eg metadata symbols) 
that refers to the dead `src` memory region.

As of now, `MetadataSymbol`s are used only by the `CStringChecker`, so this fix 
is tightly coupled to fixing the resulting issues of that checker.
There was already a FIXME in the test suite for this - which is now resolved.

---

There was a lengthy discussion on the mailing list 
 how to 
resolve this issue.
In that mailing, @NoQ proposed these steps, which I have implemented in this 
patch:

> 1. Remove statement, location context, block count from SymbolMetadata's 
> identity. Let it solely depend on the region.
> 2. Get rid of the metadata-in-use set. From now on SymbolMetadata, like 
> SymbolRegionValue, is live whenever its region is live.
> 3. When strlen(R) is used for the first time on a region R, produce 
> `$meta` as the answer, but *do not store* it in the string length 
> map. We don't need to change the state because the state didn't  in fact 
> change. On subsequent `strlen(R)` calls we'll simply return the same symbol 
> (**because** the map will remain empty), until the string is changed.
> 4. If the string is mutated, record its length as usual. But if the string is 
> invalidated (or the new length is completely unknown), **do not remove** the 
> length from the state; instead, set it to SymbolConjured. Only remove it from 
> the map when the region dies.
> 5. Keep string length symbols alive as long as they're in the map.




Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86445

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
  clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
  clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
  clang/test/Analysis/bsd-string.c
  clang/test/Analysis/string.c

Index: clang/test/Analysis/string.c
===
--- clang/test/Analysis/string.c
+++ clang/test/Analysis/string.c
@@ -502,6 +502,11 @@
 	strcat(dst, src);
 }
 
+void strcat_models_dst_length_even_if_src_dies(char *src) {
+  char dst[8] = "1234";
+  strcat(dst, src);
+  clang_analyzer_eval(strlen(dst) >= 4); // expected-warning{{TRUE}}
+}
 
 //===--===
 // strncpy()
@@ -1515,23 +1520,12 @@
   free(privkey);
 }
 
-//===--===
-// FIXMEs
-//===--===
-
-// The analyzer_eval call below should evaluate to true. We are being too
-// aggressive in marking the (length of) src symbol dead. The length of dst
-// depends on src. This could be explicitly specified in the checker or the
-// logic for handling MetadataSymbol in SymbolManager needs to change.
 void strcat_symbolic_src_length(char *src) {
-	char dst[8] = "1234";
-	strcat(dst, src);
-  clang_analyzer_eval(strlen(dst) >= 4); // expected-warning{{UNKNOWN}}
+  char dst[8] = "1234";
+  strcat(dst, src);
+  clang_analyzer_eval(strlen(dst) >= 4); // expected-warning{{TRUE}}
 }
 
-
-// The analyzer_eval call below should evaluate to true. Most likely the same
-// issue as the test above.
 void strncpy_exactly_matching_buffer2(char *y) {
 	if (strlen(y) >= 4)
 		return;
@@ -1540,9 +1534,13 @@
 	strncpy(x, y, 4); // no-warning
 
 	// This time, we know that y fits in x anyway.
-  clang_analyzer_eval(strlen(x) <= 3); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(strlen(x) <= 3); // expected-warning{{TRUE}}
 }
 
+//===--===
+// FIXMEs
+//===--===
+
 void memset7_char_array_nonnull() {
   char str[5] = "abcd";
   clang_analyzer_eval(strlen(str) == 4); // expected-warning{{TR

[PATCH] D85324: [SystemZ][z/OS] Add z/OS Target and define macros

2020-08-24 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 287338.
abhina.sreeskantharajan added a comment.

Thanks Hubert, I fixed the comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85324

Files:
  clang/lib/Basic/Targets.cpp
  clang/lib/Basic/Targets/OSTargets.h
  clang/test/Preprocessor/init-zos.c


Index: clang/test/Preprocessor/init-zos.c
===
--- /dev/null
+++ clang/test/Preprocessor/init-zos.c
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=s390x-none-zos 
-fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix 
S390X-ZOS %s
+// RUN: %clang_cc1 -x c++ -std=gnu++14 -E -dM -ffreestanding 
-triple=s390x-none-zos -fno-signed-char < /dev/null | FileCheck 
-match-full-lines -check-prefix S390X-ZOS -check-prefix S390X-ZOS-GNUXX %s
+
+// S390X-ZOS-GNUXX:#define _EXT 1
+// S390X-ZOS:#define _LONG_LONG 1
+// S390X-ZOS-GNUXX:#define _MI_BUILTIN 1
+// S390X-ZOS:#define _OPEN_DEFAULT 1
+// S390X-ZOS:#define _UNIX03_WITHDRAWN 1
+// S390X-ZOS-GNUXX:#define _XOPEN_SOURCE 600
+// S390X-ZOS:#define __370__ 1
+// S390X-ZOS:#define __64BIT__ 1
+// S390X-ZOS:#define __BFP__ 1
+// S390X-ZOS:#define __BOOL__ 1
+// S390X-ZOS-GNUXX:#define __DLL__ 1
+// S390X-ZOS:#define __LONGNAME__ 1
+// S390X-ZOS:#define __MVS__ 1
+// S390X-ZOS:#define __THW_370__ 1
+// S390X-ZOS:#define __THW_BIG_ENDIAN__ 1
+// S390X-ZOS:#define __TOS_390__ 1
+// S390X-ZOS:#define __TOS_MVS__ 1
+// S390X-ZOS:#define __XPLINK__ 1
+// S390X-ZOS-GNUXX:#define __wchar_t 1
Index: clang/lib/Basic/Targets/OSTargets.h
===
--- clang/lib/Basic/Targets/OSTargets.h
+++ clang/lib/Basic/Targets/OSTargets.h
@@ -727,6 +727,55 @@
   bool defaultsToAIXPowerAlignment() const override { return true; }
 };
 
+// z/OS target
+template 
+class LLVM_LIBRARY_VISIBILITY ZOSTargetInfo : public OSTargetInfo {
+protected:
+  void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
+MacroBuilder &Builder) const override {
+// FIXME: _LONG_LONG should not be defined under -std=c89.
+Builder.defineMacro("_LONG_LONG");
+Builder.defineMacro("_OPEN_DEFAULT");
+// _UNIX03_WITHDRAWN is required to build libcxx.
+Builder.defineMacro("_UNIX03_WITHDRAWN");
+Builder.defineMacro("__370__");
+Builder.defineMacro("__BFP__");
+// FIXME: __BOOL__ should not be defined under -std=c89.
+Builder.defineMacro("__BOOL__");
+Builder.defineMacro("__LONGNAME__");
+Builder.defineMacro("__MVS__");
+Builder.defineMacro("__THW_370__");
+Builder.defineMacro("__THW_BIG_ENDIAN__");
+Builder.defineMacro("__TOS_390__");
+Builder.defineMacro("__TOS_MVS__");
+Builder.defineMacro("__XPLINK__");
+
+if (this->PointerWidth == 64)
+  Builder.defineMacro("__64BIT__");
+
+if (Opts.CPlusPlus) {
+  Builder.defineMacro("__DLL__");
+  // _XOPEN_SOURCE=600 is required to build libcxx.
+  Builder.defineMacro("_XOPEN_SOURCE", "600");
+}
+
+if (Opts.GNUMode) {
+  Builder.defineMacro("_MI_BUILTIN");
+  Builder.defineMacro("_EXT");
+}
+
+if (Opts.CPlusPlus && Opts.WChar) {
+  // Macro __wchar_t is defined so that the wchar_t data
+  // type is not declared as a typedef in system headers.
+  Builder.defineMacro("__wchar_t");
+}
+  }
+
+public:
+  ZOSTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
+  : OSTargetInfo(Triple, Opts) {}
+};
+
 void addWindowsDefines(const llvm::Triple &Triple, const LangOptions &Opts,
MacroBuilder &Builder);
 
Index: clang/lib/Basic/Targets.cpp
===
--- clang/lib/Basic/Targets.cpp
+++ clang/lib/Basic/Targets.cpp
@@ -450,6 +450,8 @@
 switch (os) {
 case llvm::Triple::Linux:
   return new LinuxTargetInfo(Triple, Opts);
+case llvm::Triple::ZOS:
+  return new ZOSTargetInfo(Triple, Opts);
 default:
   return new SystemZTargetInfo(Triple, Opts);
 }


Index: clang/test/Preprocessor/init-zos.c
===
--- /dev/null
+++ clang/test/Preprocessor/init-zos.c
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=s390x-none-zos -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix S390X-ZOS %s
+// RUN: %clang_cc1 -x c++ -std=gnu++14 -E -dM -ffreestanding -triple=s390x-none-zos -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix S390X-ZOS -check-prefix S390X-ZOS-GNUXX %s
+
+// S390X-ZOS-GNUXX:#define _EXT 1
+// S390X-ZOS:#define _LONG_LONG 1
+// S390X-ZOS-GNUXX:#define _MI_BUILTIN 1
+// S390X-ZOS:#define _OPEN_DEFAULT 1
+// S390X-ZOS:#define _UNIX03_WITHDRAWN 1
+// S390X-ZOS-GNUXX:#define _XOPEN_SOURCE 600
+// S390X-ZOS:#define __370__ 1
+// S390X-ZOS:#define __64BIT_

[PATCH] D84013: Correctly emit dwoIDs after ASTFileSignature refactoring (D81347)

2020-08-24 Thread David Zarzycki via Phabricator via cfe-commits
davezarzycki added a comment.

Not fighting with how `lit`, `FileCheck`, and shell input/output work would 
help here:

  FAIL: Clang :: Modules/ModuleDebugInfoDwoId.cpp (1 of 1)
   TEST 'Clang :: Modules/ModuleDebugInfoDwoId.cpp' FAILED 

  Script:
  --
  : 'RUN: at line 3';   rm -rf 
/tmp/l/r/tools/clang/test/Modules/Output/ModuleDebugInfoDwoId.cpp.tmp.cache
  : 'RUN: at line 4';   /tmp/l/r/bin/clang -cc1 -internal-isystem 
/tmp/l/r/lib/clang/12.0.0/include -nostdsysteminc -triple 
x86_64-unknown-linux-gnu -x objective-c++ -std=c++11 -debugger-tuning=lldb 
-debug-info-kind=limited -fmodules -fmodule-format=obj -dwarf-ext-refs 
-fimplicit-module-maps 
-fmodules-cache-path=/tmp/l/r/tools/clang/test/Modules/Output/ModuleDebugInfoDwoId.cpp.tmp.cache
 /home/dave/s/l/clang/test/Modules/ModuleDebugInfoDwoId.cpp -I 
/home/dave/s/l/clang/test/Modules/Inputs -emit-llvm -o - -mllvm 
-debug-only=pchcontainer | /tmp/l/r/bin/FileCheck 
--check-prefixes=CHECK,CHECK-REALIDS 
/home/dave/s/l/clang/test/Modules/ModuleDebugInfoDwoId.cpp
  --
  Exit Code: 2
  
  Command Output (stderr):
  --
  clang (LLVM option parsing): Unknown command line argument 
'-debug-only=pchcontainer'.  Try: 'clang (LLVM option parsing) --help'
  clang (LLVM option parsing): Did you mean '--debug-pass=pchcontainer'?
  FileCheck error: '' is empty.
  FileCheck command line:  /tmp/l/r/bin/FileCheck 
--check-prefixes=CHECK,CHECK-REALIDS 
/home/dave/s/l/clang/test/Modules/ModuleDebugInfoDwoId.cpp
  
  --
  
  
  
  Failed Tests (1):
Clang :: Modules/ModuleDebugInfoDwoId.cpp


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84013

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


[PATCH] D86447: [AST] Change return type of getTypeInfoInChars to a proper struct instead of std::pair.

2020-08-24 Thread Bevin Hansson via Phabricator via cfe-commits
ebevhan created this revision.
ebevhan added a reviewer: efriedma.
Herald added subscribers: bjope, martong, jfb.
Herald added a project: clang.
ebevhan requested review of this revision.

Followup to D85191 .

This changes getTypeInfoInChars to return a TypeInfoChars
struct instead of a std::pair of CharUnits. This lets the
interface match getTypeInfo more closely.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86447

Files:
  clang/include/clang/AST/ASTContext.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/lib/CodeGen/CGAtomic.cpp
  clang/lib/CodeGen/CGBlocks.cpp
  clang/lib/CodeGen/CGCUDANV.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGClass.cpp
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/lib/CodeGen/CGObjC.cpp
  clang/lib/CodeGen/CGRecordLayoutBuilder.cpp
  clang/lib/CodeGen/CGValue.h
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp

Index: clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp
@@ -248,8 +248,9 @@
   FieldInfo RetVal;
   RetVal.Field = FD;
   auto &Ctx = FD->getASTContext();
-  std::tie(RetVal.Size, RetVal.Align) =
-  Ctx.getTypeInfoInChars(FD->getType());
+  auto Info = Ctx.getTypeInfoInChars(FD->getType());
+  RetVal.Size = Info.Width;
+  RetVal.Align = Info.Align;
   assert(llvm::isPowerOf2_64(RetVal.Align.getQuantity()));
   if (auto Max = FD->getMaxAlignment())
 RetVal.Align = std::max(Ctx.toCharUnitsFromBits(Max), RetVal.Align);
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -359,7 +359,7 @@
 ///   leaving one or more empty slots behind as padding.
 static Address emitVoidPtrVAArg(CodeGenFunction &CGF, Address VAListAddr,
 QualType ValueTy, bool IsIndirect,
-std::pair ValueInfo,
+TypeInfoChars ValueInfo,
 CharUnits SlotSizeAndAlign,
 bool AllowHigherAlign) {
   // The size and alignment of the value that was passed directly.
@@ -368,8 +368,8 @@
 DirectSize = CGF.getPointerSize();
 DirectAlign = CGF.getPointerAlign();
   } else {
-DirectSize = ValueInfo.first;
-DirectAlign = ValueInfo.second;
+DirectSize = ValueInfo.Width;
+DirectAlign = ValueInfo.Align;
   }
 
   // Cast the address we've calculated to the right type.
@@ -383,7 +383,7 @@
 AllowHigherAlign);
 
   if (IsIndirect) {
-Addr = Address(CGF.Builder.CreateLoad(Addr), ValueInfo.second);
+Addr = Address(CGF.Builder.CreateLoad(Addr), ValueInfo.Align);
   }
 
   return Addr;
@@ -656,7 +656,7 @@
 "Unexpected IndirectRealign seen in arginfo in generic VAArg emitter!");
 
 auto TyInfo = CGF.getContext().getTypeInfoInChars(Ty);
-CharUnits TyAlignForABI = TyInfo.second;
+CharUnits TyAlignForABI = TyInfo.Align;
 
 llvm::Type *BaseTy =
 llvm::PointerType::getUnqual(CGF.ConvertTypeForMem(Ty));
@@ -2062,8 +2062,8 @@
   //
   // Just messing with TypeInfo like this works because we never pass
   // anything indirectly.
-  TypeInfo.second = CharUnits::fromQuantity(
-getTypeStackAlignInBytes(Ty, TypeInfo.second.getQuantity()));
+  TypeInfo.Align = CharUnits::fromQuantity(
+getTypeStackAlignInBytes(Ty, TypeInfo.Align.getQuantity()));
 
   return emitVoidPtrVAArg(CGF, VAListAddr, Ty, /*Indirect*/ false,
   TypeInfo, CharUnits::fromQuantity(4),
@@ -4063,10 +4063,9 @@
 RegAddr = CGF.Builder.CreateElementBitCast(RegAddr, LTy);
 
 // Copy to a temporary if necessary to ensure the appropriate alignment.
-std::pair SizeAlign =
-getContext().getTypeInfoInChars(Ty);
-uint64_t TySize = SizeAlign.first.getQuantity();
-CharUnits TyAlign = SizeAlign.second;
+auto TInfo = getContext().getTypeInfoInChars(Ty);
+uint64_t TySize = TInfo.Width.getQuantity();
+CharUnits TyAlign = TInfo.Align;
 
 // Copy into a temporary if the type is more aligned than the
 // register save area.
@@ -4572,7 +4571,7 @@
 llvm::report_fatal_error("vector type is not supported on AIX yet");
 
   auto TypeInfo = getContext().getTypeInfoInChars(Ty);
-  TypeInfo.second = getParamTypeAlignment(Ty);
+  TypeInfo.Align = getParamTypeAlignment(Ty);
 
   CharUnits SlotSize = CharUnits::fromQuantity(PtrByteSize);
 
@@ -4691,7 +4690,7 @@
   QualType Ty) const {
   if (getTarget().getTriple().isOSDarwin()) {
 auto TI = getContext().getTypeInfoInChars(Ty);
-TI.second = getParamTypeAlign

[PATCH] D84316: [analyzer][NFC] Split CStringChecker to modeling and reporting

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

Do I sense correctly that the only information `CSrtingLengthModeling.cpp` 
requires from the actual `CStringChecker` is a checker tag? Because if so, I 
think we should just separate them even more cleanly -- we could just make a 
`CStringLengthModeling` checker implement the checker callbacks in that cpp 
file and we wouldn't need to move `CStringChecker` to a header. Not that moving 
it there is fundamentally bad, but in this instance it seems like we're 
legalizing bloating checkers instead of separating them. Also, this patch seems 
to have a significant overlap with D84979  -- 
is this intentional?


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

https://reviews.llvm.org/D84316

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


[clang] 09e7fe9 - [AST][RecoveryAST] Preserve the type by default for recovery expression.

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

Author: Haojian Wu
Date: 2020-08-24T14:28:28+02:00
New Revision: 09e7fe9859b4efeeb35697c095c9676e993fc03c

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

LOG: [AST][RecoveryAST] Preserve the type by default for recovery expression.

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/CXX/temp/temp.constr/temp.constr.order/function-templates.cpp
clang/test/SemaCXX/abstract.cpp
clang/test/SemaCXX/decl-expr-ambiguity.cpp
clang/test/SemaCXX/recovery-expr-type.cpp
clang/test/SemaCXX/type-convert-construct.cpp
clang/test/SemaTemplate/dependent-names.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 44b1eb3c614e..111eec4b4a00 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4043,8 +4043,7 @@ def frecovery_ast : Flag<["-"], "frecovery-ast">,
"encountering semantic errors">;
 def fno_recovery_ast : Flag<["-"], "fno-recovery-ast">;
 def frecovery_ast_type : Flag<["-"], "frecovery-ast-type">,
-  HelpText<"Preserve the type for recovery expressions when possible "
-  "(experimental)">;
+  HelpText<"Preserve the type for recovery expressions when possible">;
 def fno_recovery_ast_type : Flag<["-"], "fno-recovery-ast-type">;
 
 let Group = Action_Group in {

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 477959f04c41..175985bd950a 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -2934,8 +2934,8 @@ static void ParseLangArgs(LangOptions &Opts, ArgList 
&Args, InputKind IK,
   // Recovery AST still heavily relies on dependent-type machinery.
   Opts.RecoveryAST =
   Args.hasFlag(OPT_frecovery_ast, OPT_fno_recovery_ast, Opts.CPlusPlus);
-  Opts.RecoveryASTType =
-  Args.hasFlag(OPT_frecovery_ast_type, OPT_fno_recovery_ast_type, false);
+  Opts.RecoveryASTType = Args.hasFlag(
+  OPT_frecovery_ast_type, OPT_fno_recovery_ast_type, Opts.CPlusPlus);
   Opts.HeinousExtensions = Args.hasArg(OPT_fheinous_gnu_extensions);
   Opts.AccessControl = !Args.hasArg(OPT_fno_access_control);
   Opts.ElideConstructors = !Args.hasArg(OPT_fno_elide_constructors);

diff  --git 
a/clang/test/CXX/temp/temp.constr/temp.constr.order/function-templates.cpp 
b/clang/test/CXX/temp/temp.constr/temp.constr.order/function-templates.cpp
index 8ae630871445..b2fe2cd52006 100644
--- a/clang/test/CXX/temp/temp.constr/temp.constr.order/function-templates.cpp
+++ b/clang/test/CXX/temp/temp.constr/temp.constr.order/function-templates.cpp
@@ -67,7 +67,8 @@ void f() { }
 // expected-note@-1 {{candidate function [with T = long long, U = int]}}
 
 static_assert(sizeof(f()));
-// expected-error@-1 {{call to 'f' is ambiguous}}
+// expected-error@-1 {{call to 'f' is ambiguous}} \
+   expected-error@-1 {{invalid application of 'sizeof' to an incomplete type 
'void'}}
 
 template
 concept C3 = true;

diff  --git a/clang/test/SemaCXX/abstract.cpp b/clang/test/SemaCXX/abstract.cpp
index 1fda21caea49..c6ee3c6e4b86 100644
--- a/clang/test/SemaCXX/abstract.cpp
+++ b/clang/test/SemaCXX/abstract.cpp
@@ -279,7 +279,7 @@ namespace pr12658 {
   virtual void f() = 0; // expected-note {{unimplemented pure virtual 
method 'f' in 'C'}}
   };
 
-  void foo( C& c ) {}
+  void foo(const C& c ) {}
 
   void bar( void ) {
 foo(C(99)); // expected-error {{allocating an object of abstract class 
type 'pr12658::C'}}

diff  --git a/clang/test/SemaCXX/decl-expr-ambiguity.cpp 
b/clang/test/SemaCXX/decl-expr-ambiguity.cpp
index b77e226b5d01..a15ec397b4ae 100644
--- a/clang/test/SemaCXX/decl-expr-ambiguity.cpp
+++ b/clang/test/SemaCXX/decl-expr-ambiguity.cpp
@@ -12,7 +12,7 @@ void f() {
   T(a)->m = 7;
   int(a)++; // expected-error {{assignment to cast is illegal}}
   __extension__ int(a)++; // expected-error {{assignment to cast is illegal}}
-  __typeof(int)(a,5)< struct C {
   static const int n = f(T()); // expected-error {{no matching function}}



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


[PATCH] D82657: [AST][RecoveryAST] Preserve the type by default for recovery expression.

2020-08-24 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG09e7fe9859b4: [AST][RecoveryAST] Preserve the type by 
default for recovery expression. (authored by hokein).
Herald added a subscriber: dang.

Changed prior to commit:
  https://reviews.llvm.org/D82657?vs=287030&id=287349#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82657

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CXX/temp/temp.constr/temp.constr.order/function-templates.cpp
  clang/test/SemaCXX/abstract.cpp
  clang/test/SemaCXX/decl-expr-ambiguity.cpp
  clang/test/SemaCXX/recovery-expr-type.cpp
  clang/test/SemaCXX/type-convert-construct.cpp
  clang/test/SemaTemplate/dependent-names.cpp

Index: clang/test/SemaTemplate/dependent-names.cpp
===
--- clang/test/SemaTemplate/dependent-names.cpp
+++ clang/test/SemaTemplate/dependent-names.cpp
@@ -173,7 +173,7 @@
 
 
   namespace O {
-void f(char&); // expected-note {{candidate function not viable}}
+int f(char&); // expected-note {{candidate function not viable}}
 
 template struct C {
   static const int n = f(T()); // expected-error {{no matching function}}
Index: clang/test/SemaCXX/type-convert-construct.cpp
===
--- clang/test/SemaCXX/type-convert-construct.cpp
+++ clang/test/SemaCXX/type-convert-construct.cpp
@@ -6,7 +6,7 @@
   float v1 = float(1);
   int v2 = typeof(int)(1,2); // expected-error {{excess elements in scalar initializer}}
   typedef int arr[];
-  int v3 = arr(); // expected-error {{array types cannot be value-initialized}}
+  arr(); // expected-error {{array types cannot be value-initialized}}
   typedef void fn_ty();
   fn_ty(); // expected-error {{cannot create object of function type 'fn_ty'}}
   fn_ty(0); // expected-error {{functional-style cast from 'int' to 'fn_ty'}}
Index: clang/test/SemaCXX/recovery-expr-type.cpp
===
--- clang/test/SemaCXX/recovery-expr-type.cpp
+++ clang/test/SemaCXX/recovery-expr-type.cpp
@@ -86,3 +86,22 @@
   (T(T())); // expected-error {{call to deleted constructor}}
 }
 }
+
+// verify the secondary diagnostic "no matching function" is emitted.
+namespace test7 {
+struct C {
+  C() = delete; // expected-note {{has been explicitly marked deleted}}
+};
+void f(C &); // expected-note {{candidate function not viable: expects an l-value for 1st argument}}
+void test() {
+  f(C()); // expected-error {{call to deleted constructor}} \
+ expected-error {{no matching function for call}}
+}
+}
+
+// verify the secondary diagnostic "cannot initialize" is emitted.
+namespace test8 {
+typedef int arr[];
+int v = arr(); // expected-error {{array types cannot be value-initialized}} \
+  expected-error {{cannot initialize a variable of type 'int' with an rvalue of type 'test8::arr'}}
+}
Index: clang/test/SemaCXX/decl-expr-ambiguity.cpp
===
--- clang/test/SemaCXX/decl-expr-ambiguity.cpp
+++ clang/test/SemaCXX/decl-expr-ambiguity.cpp
@@ -12,7 +12,7 @@
   T(a)->m = 7;
   int(a)++; // expected-error {{assignment to cast is illegal}}
   __extension__ int(a)++; // expected-error {{assignment to cast is illegal}}
-  __typeof(int)(a,5)<()));
-// expected-error@-1 {{call to 'f' is ambiguous}}
+// expected-error@-1 {{call to 'f' is ambiguous}} \
+   expected-error@-1 {{invalid application of 'sizeof' to an incomplete type 'void'}}
 
 template
 concept C3 = true;
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2934,8 +2934,8 @@
   // Recovery AST still heavily relies on dependent-type machinery.
   Opts.RecoveryAST =
   Args.hasFlag(OPT_frecovery_ast, OPT_fno_recovery_ast, Opts.CPlusPlus);
-  Opts.RecoveryASTType =
-  Args.hasFlag(OPT_frecovery_ast_type, OPT_fno_recovery_ast_type, false);
+  Opts.RecoveryASTType = Args.hasFlag(
+  OPT_frecovery_ast_type, OPT_fno_recovery_ast_type, Opts.CPlusPlus);
   Opts.HeinousExtensions = Args.hasArg(OPT_fheinous_gnu_extensions);
   Opts.AccessControl = !Args.hasArg(OPT_fno_access_control);
   Opts.ElideConstructors = !Args.hasArg(OPT_fno_elide_constructors);
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -4043,8 +4043,7 @@
"encountering semantic errors">;
 def fno_recovery_ast : Flag<["-"], "fno-recovery-ast">;
 def frecovery_ast_type : Flag<["-"], "frecovery-ast-type">,
-  HelpText<"Preserve the type for recovery expressions when p

[PATCH] D85031: [builtins] Unify the softfloat division implementation

2020-08-24 Thread Anatoly Trosinenko via Phabricator via cfe-commits
atrosinenko updated this revision to Diff 287351.
atrosinenko added a comment.

Addressed the review comments mostly by clarifying the explanations.

I expect this code to have no **unresolved** review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85031

Files:
  compiler-rt/lib/builtins/divdf3.c
  compiler-rt/lib/builtins/divsf3.c
  compiler-rt/lib/builtins/divtf3.c
  compiler-rt/lib/builtins/fp_div_impl.inc
  compiler-rt/lib/builtins/fp_lib.h
  compiler-rt/lib/builtins/int_util.h
  compiler-rt/test/builtins/Unit/divdf3_test.c

Index: compiler-rt/test/builtins/Unit/divdf3_test.c
===
--- compiler-rt/test/builtins/Unit/divdf3_test.c
+++ compiler-rt/test/builtins/Unit/divdf3_test.c
@@ -92,5 +92,13 @@
 if (test__divdf3(0x1.0p+0, 0x1.0001p+0, UINT64_C(0x3fefffe0)))
   return 1;
 
+// some misc test cases obtained by fuzzing against h/w implementation
+if (test__divdf3(0x1.fdc239dd64735p-658, -0x1.fff9364c0843fp-948, UINT64_C(0xd20fdc8fc0ceffb1)))
+  return 1;
+if (test__divdf3(-0x1.78abb261d47c8p+794, 0x1.fb01d537cc5aep+266, UINT64_C(0xe0e7c6148ffc23e3)))
+  return 1;
+if (test__divdf3(-0x1.da7dfe6048b8bp-875, 0x1.ffc7ea3ff60a4p-610, UINT64_C(0xaf5dab1fe0269e2a)))
+  return 1;
+
 return 0;
 }
Index: compiler-rt/lib/builtins/int_util.h
===
--- compiler-rt/lib/builtins/int_util.h
+++ compiler-rt/lib/builtins/int_util.h
@@ -28,4 +28,20 @@
 #define COMPILE_TIME_ASSERT2(expr, cnt)\
   typedef char ct_assert_##cnt[(expr) ? 1 : -1] UNUSED
 
+// Force unrolling the code specified to be repeated N times.
+#define REPEAT_0_TIMES(code_to_repeat) /* do nothing */
+#define REPEAT_1_TIMES(code_to_repeat) code_to_repeat
+#define REPEAT_2_TIMES(code_to_repeat) \
+  REPEAT_1_TIMES(code_to_repeat)   \
+  code_to_repeat
+#define REPEAT_3_TIMES(code_to_repeat) \
+  REPEAT_2_TIMES(code_to_repeat)   \
+  code_to_repeat
+#define REPEAT_4_TIMES(code_to_repeat) \
+  REPEAT_3_TIMES(code_to_repeat)   \
+  code_to_repeat
+
+#define REPEAT_N_TIMES_(N, code_to_repeat) REPEAT_##N##_TIMES(code_to_repeat)
+#define REPEAT_N_TIMES(N, code_to_repeat) REPEAT_N_TIMES_(N, code_to_repeat)
+
 #endif // INT_UTIL_H
Index: compiler-rt/lib/builtins/fp_lib.h
===
--- compiler-rt/lib/builtins/fp_lib.h
+++ compiler-rt/lib/builtins/fp_lib.h
@@ -49,9 +49,12 @@
 
 #if defined SINGLE_PRECISION
 
+typedef uint16_t half_rep_t;
 typedef uint32_t rep_t;
+typedef uint64_t twice_rep_t;
 typedef int32_t srep_t;
 typedef float fp_t;
+#define HALF_REP_C UINT16_C
 #define REP_C UINT32_C
 #define significandBits 23
 
@@ -67,9 +70,11 @@
 
 #elif defined DOUBLE_PRECISION
 
+typedef uint32_t half_rep_t;
 typedef uint64_t rep_t;
 typedef int64_t srep_t;
 typedef double fp_t;
+#define HALF_REP_C UINT32_C
 #define REP_C UINT64_C
 #define significandBits 52
 
@@ -111,9 +116,11 @@
 #elif defined QUAD_PRECISION
 #if __LDBL_MANT_DIG__ == 113 && defined(__SIZEOF_INT128__)
 #define CRT_LDBL_128BIT
+typedef uint64_t half_rep_t;
 typedef __uint128_t rep_t;
 typedef __int128_t srep_t;
 typedef long double fp_t;
+#define HALF_REP_C UINT64_C
 #define REP_C (__uint128_t)
 // Note: Since there is no explicit way to tell compiler the constant is a
 // 128-bit integer, we let the constant be casted to 128-bit integer
Index: compiler-rt/lib/builtins/fp_div_impl.inc
===
--- /dev/null
+++ compiler-rt/lib/builtins/fp_div_impl.inc
@@ -0,0 +1,336 @@
+//===-- lib/fp_div_impl.inc - Floating point division -*- 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
+//
+//===--===//
+//
+// This file implements soft-float division with the IEEE-754 default
+// rounding (to nearest, ties to even).
+//
+//===--===//
+
+#include "fp_lib.h"
+
+// The __divXf3__ function implements Newton-Raphson floating point division.
+// It uses 3 iterations for float32, 4 for float64 and 5 for float128,
+// respectively. Due to number of significant bits being roughly doubled
+// every iteration, there are two modes supported: N full-width iterations (as
+// it is done for float32 by default) and (N-1) half-width iteration plus on

[clang] 577f8b1 - [Fixed Point] Add codegen for fixed-point shifts.

2020-08-24 Thread Bevin Hansson via cfe-commits

Author: Bevin Hansson
Date: 2020-08-24T14:37:16+02:00
New Revision: 577f8b157a03055821341146ed0617e3b103fdaf

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

LOG: [Fixed Point] Add codegen for fixed-point shifts.

This patch adds codegen to Clang for fixed-point shift
operations.

Reviewed By: leonardchan

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

Added: 
clang/test/Frontend/fixed_point_shift_const.c

Modified: 
clang/lib/CodeGen/CGExprScalar.cpp
clang/test/Frontend/fixed_point_compound.c
clang/test/Frontend/fixed_point_shift.c

Removed: 




diff  --git a/clang/lib/CodeGen/CGExprScalar.cpp 
b/clang/lib/CodeGen/CGExprScalar.cpp
index b3857b3eeb06..d0ec50f4e011 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -3535,6 +3535,14 @@ Value *ScalarExprEmitter::EmitFixedPointBinOp(const 
BinOpInfo &op) {
   case BO_Div:
 Result = FPBuilder.CreateDiv(LHS, LHSFixedSema, RHS, RHSFixedSema);
 break;
+  case BO_ShlAssign:
+  case BO_Shl:
+Result = FPBuilder.CreateShl(LHS, LHSFixedSema, RHS);
+break;
+  case BO_ShrAssign:
+  case BO_Shr:
+Result = FPBuilder.CreateShr(LHS, LHSFixedSema, RHS);
+break;
   case BO_LT:
 return FPBuilder.CreateLT(LHS, LHSFixedSema, RHS, RHSFixedSema);
   case BO_GT:
@@ -3550,13 +3558,9 @@ Value *ScalarExprEmitter::EmitFixedPointBinOp(const 
BinOpInfo &op) {
 return FPBuilder.CreateEQ(LHS, LHSFixedSema, RHS, RHSFixedSema);
   case BO_NE:
 return FPBuilder.CreateNE(LHS, LHSFixedSema, RHS, RHSFixedSema);
-  case BO_Shl:
-  case BO_Shr:
   case BO_Cmp:
   case BO_LAnd:
   case BO_LOr:
-  case BO_ShlAssign:
-  case BO_ShrAssign:
 llvm_unreachable("Found unimplemented fixed point binary operation");
   case BO_PtrMemD:
   case BO_PtrMemI:
@@ -3573,8 +3577,12 @@ Value *ScalarExprEmitter::EmitFixedPointBinOp(const 
BinOpInfo &op) {
 llvm_unreachable("Found unsupported binary operation for fixed point 
types.");
   }
 
+  bool IsShift = BinaryOperator::isShiftOp(op.Opcode) ||
+ BinaryOperator::isShiftAssignOp(op.Opcode);
   // Convert to the result type.
-  return FPBuilder.CreateFixedToFixed(Result, CommonFixedSema, 
ResultFixedSema);
+  return FPBuilder.CreateFixedToFixed(Result, IsShift ? LHSFixedSema
+  : CommonFixedSema,
+  ResultFixedSema);
 }
 
 Value *ScalarExprEmitter::EmitSub(const BinOpInfo &op) {
@@ -3701,6 +3709,10 @@ Value *ScalarExprEmitter::ConstrainShiftValue(Value 
*LHS, Value *RHS,
 }
 
 Value *ScalarExprEmitter::EmitShl(const BinOpInfo &Ops) {
+  // TODO: This misses out on the sanitizer check below.
+  if (Ops.isFixedPointOp())
+return EmitFixedPointBinOp(Ops);
+
   // LLVM requires the LHS and RHS to be the same type: promote or truncate the
   // RHS to the same size as the LHS.
   Value *RHS = Ops.RHS;
@@ -3768,6 +3780,10 @@ Value *ScalarExprEmitter::EmitShl(const BinOpInfo &Ops) {
 }
 
 Value *ScalarExprEmitter::EmitShr(const BinOpInfo &Ops) {
+  // TODO: This misses out on the sanitizer check below.
+  if (Ops.isFixedPointOp())
+return EmitFixedPointBinOp(Ops);
+
   // LLVM requires the LHS and RHS to be the same type: promote or truncate the
   // RHS to the same size as the LHS.
   Value *RHS = Ops.RHS;

diff  --git a/clang/test/Frontend/fixed_point_compound.c 
b/clang/test/Frontend/fixed_point_compound.c
index 4a44d0ae95a2..897ba2e22636 100644
--- a/clang/test/Frontend/fixed_point_compound.c
+++ b/clang/test/Frontend/fixed_point_compound.c
@@ -567,3 +567,50 @@ void div_csa() {
   c /= sa;
 }
 
+
+// CHECK-LABEL: @shft_ai(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = load i32, i32* @i, align 4
+// CHECK-NEXT:[[TMP1:%.*]] = load i32, i32* @a, align 4
+// CHECK-NEXT:[[TMP2:%.*]] = shl i32 [[TMP1]], [[TMP0]]
+// CHECK-NEXT:store i32 [[TMP2]], i32* @a, align 4
+// CHECK-NEXT:ret void
+//
+void shft_ai() {
+  a <<= i;
+}
+
+// SIGNED-LABEL: @shft_sufi(
+// SIGNED-NEXT:  entry:
+// SIGNED-NEXT:[[TMP0:%.*]] = load i32, i32* @i, align 4
+// SIGNED-NEXT:[[TMP1:%.*]] = load i16, i16* @suf, align 2
+// SIGNED-NEXT:[[TMP2:%.*]] = trunc i32 [[TMP0]] to i16
+// SIGNED-NEXT:[[TMP3:%.*]] = call i16 @llvm.ushl.sat.i16(i16 [[TMP1]], 
i16 [[TMP2]])
+// SIGNED-NEXT:store i16 [[TMP3]], i16* @suf, align 2
+// SIGNED-NEXT:ret void
+//
+// UNSIGNED-LABEL: @shft_sufi(
+// UNSIGNED-NEXT:  entry:
+// UNSIGNED-NEXT:[[TMP0:%.*]] = load i32, i32* @i, align 4
+// UNSIGNED-NEXT:[[TMP1:%.*]] = load i16, i16* @suf, align 2
+// UNSIGNED-NEXT:[[TMP2:%.*]] = trunc i32 [[TMP0]] to i16
+// UNSIGNED-NEXT:[[TMP3:%.*]] = call i16 @llvm.sshl.sat.i16(i16 [[TMP1]], 
i16 [[TMP2]])
+// UNSIGNED-NEXT:st

[PATCH] D86282: [Fixed Point] Use FixedPointBuilder to codegen fixed-point IR.

2020-08-24 Thread Bevin Hansson via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG808ac5464521: [Fixed Point] Use FixedPointBuilder to codegen 
fixed-point IR. (authored by ebevhan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86282

Files:
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/test/Frontend/fixed_point_add.c
  clang/test/Frontend/fixed_point_div.c
  clang/test/Frontend/fixed_point_mul.c
  clang/test/Frontend/fixed_point_sub.c
  clang/test/Frontend/fixed_point_unary.c

Index: clang/test/Frontend/fixed_point_unary.c
===
--- clang/test/Frontend/fixed_point_unary.c
+++ clang/test/Frontend/fixed_point_unary.c
@@ -148,9 +148,9 @@
 // UNSIGNED-LABEL: @inc_sua(
 // UNSIGNED-NEXT:  entry:
 // UNSIGNED-NEXT:[[TMP0:%.*]] = load i32, i32* @sua, align 4
-// UNSIGNED-NEXT:[[RESIZE:%.*]] = trunc i32 [[TMP0]] to i31
-// UNSIGNED-NEXT:[[TMP1:%.*]] = call i31 @llvm.uadd.sat.i31(i31 [[RESIZE]], i31 32768)
-// UNSIGNED-NEXT:[[RESIZE1:%.*]] = zext i31 [[TMP1]] to i32
+// UNSIGNED-NEXT:[[TMP1:%.*]] = call i32 @llvm.sadd.sat.i32(i32 [[TMP0]], i32 32768)
+// UNSIGNED-NEXT:[[RESIZE:%.*]] = trunc i32 [[TMP1]] to i31
+// UNSIGNED-NEXT:[[RESIZE1:%.*]] = zext i31 [[RESIZE]] to i32
 // UNSIGNED-NEXT:store i32 [[RESIZE1]], i32* @sua, align 4
 // UNSIGNED-NEXT:ret void
 //
@@ -168,9 +168,9 @@
 // UNSIGNED-LABEL: @inc_susa(
 // UNSIGNED-NEXT:  entry:
 // UNSIGNED-NEXT:[[TMP0:%.*]] = load i16, i16* @susa, align 2
-// UNSIGNED-NEXT:[[RESIZE:%.*]] = trunc i16 [[TMP0]] to i15
-// UNSIGNED-NEXT:[[TMP1:%.*]] = call i15 @llvm.uadd.sat.i15(i15 [[RESIZE]], i15 128)
-// UNSIGNED-NEXT:[[RESIZE1:%.*]] = zext i15 [[TMP1]] to i16
+// UNSIGNED-NEXT:[[TMP1:%.*]] = call i16 @llvm.sadd.sat.i16(i16 [[TMP0]], i16 128)
+// UNSIGNED-NEXT:[[RESIZE:%.*]] = trunc i16 [[TMP1]] to i15
+// UNSIGNED-NEXT:[[RESIZE1:%.*]] = zext i15 [[RESIZE]] to i16
 // UNSIGNED-NEXT:store i16 [[RESIZE1]], i16* @susa, align 2
 // UNSIGNED-NEXT:ret void
 //
@@ -188,9 +188,9 @@
 // UNSIGNED-LABEL: @inc_suf(
 // UNSIGNED-NEXT:  entry:
 // UNSIGNED-NEXT:[[TMP0:%.*]] = load i16, i16* @suf, align 2
-// UNSIGNED-NEXT:[[RESIZE:%.*]] = trunc i16 [[TMP0]] to i15
-// UNSIGNED-NEXT:[[TMP1:%.*]] = call i15 @llvm.uadd.sat.i15(i15 [[RESIZE]], i15 -1)
-// UNSIGNED-NEXT:[[RESIZE1:%.*]] = zext i15 [[TMP1]] to i16
+// UNSIGNED-NEXT:[[TMP1:%.*]] = call i16 @llvm.sadd.sat.i16(i16 [[TMP0]], i16 32767)
+// UNSIGNED-NEXT:[[RESIZE:%.*]] = trunc i16 [[TMP1]] to i15
+// UNSIGNED-NEXT:[[RESIZE1:%.*]] = zext i15 [[RESIZE]] to i16
 // UNSIGNED-NEXT:store i16 [[RESIZE1]], i16* @suf, align 2
 // UNSIGNED-NEXT:ret void
 //
@@ -329,9 +329,11 @@
 // UNSIGNED-LABEL: @dec_sua(
 // UNSIGNED-NEXT:  entry:
 // UNSIGNED-NEXT:[[TMP0:%.*]] = load i32, i32* @sua, align 4
-// UNSIGNED-NEXT:[[RESIZE:%.*]] = trunc i32 [[TMP0]] to i31
-// UNSIGNED-NEXT:[[TMP1:%.*]] = call i31 @llvm.usub.sat.i31(i31 [[RESIZE]], i31 32768)
-// UNSIGNED-NEXT:[[RESIZE1:%.*]] = zext i31 [[TMP1]] to i32
+// UNSIGNED-NEXT:[[TMP1:%.*]] = call i32 @llvm.ssub.sat.i32(i32 [[TMP0]], i32 32768)
+// UNSIGNED-NEXT:[[TMP2:%.*]] = icmp slt i32 [[TMP1]], 0
+// UNSIGNED-NEXT:[[SATMIN:%.*]] = select i1 [[TMP2]], i32 0, i32 [[TMP1]]
+// UNSIGNED-NEXT:[[RESIZE:%.*]] = trunc i32 [[SATMIN]] to i31
+// UNSIGNED-NEXT:[[RESIZE1:%.*]] = zext i31 [[RESIZE]] to i32
 // UNSIGNED-NEXT:store i32 [[RESIZE1]], i32* @sua, align 4
 // UNSIGNED-NEXT:ret void
 //
@@ -349,9 +351,11 @@
 // UNSIGNED-LABEL: @dec_susa(
 // UNSIGNED-NEXT:  entry:
 // UNSIGNED-NEXT:[[TMP0:%.*]] = load i16, i16* @susa, align 2
-// UNSIGNED-NEXT:[[RESIZE:%.*]] = trunc i16 [[TMP0]] to i15
-// UNSIGNED-NEXT:[[TMP1:%.*]] = call i15 @llvm.usub.sat.i15(i15 [[RESIZE]], i15 128)
-// UNSIGNED-NEXT:[[RESIZE1:%.*]] = zext i15 [[TMP1]] to i16
+// UNSIGNED-NEXT:[[TMP1:%.*]] = call i16 @llvm.ssub.sat.i16(i16 [[TMP0]], i16 128)
+// UNSIGNED-NEXT:[[TMP2:%.*]] = icmp slt i16 [[TMP1]], 0
+// UNSIGNED-NEXT:[[SATMIN:%.*]] = select i1 [[TMP2]], i16 0, i16 [[TMP1]]
+// UNSIGNED-NEXT:[[RESIZE:%.*]] = trunc i16 [[SATMIN]] to i15
+// UNSIGNED-NEXT:[[RESIZE1:%.*]] = zext i15 [[RESIZE]] to i16
 // UNSIGNED-NEXT:store i16 [[RESIZE1]], i16* @susa, align 2
 // UNSIGNED-NEXT:ret void
 //
@@ -369,9 +373,11 @@
 // UNSIGNED-LABEL: @dec_suf(
 // UNSIGNED-NEXT:  entry:
 // UNSIGNED-NEXT:[[TMP0:%.*]] = load i16, i16* @suf, align 2
-// UNSIGNED-NEXT:[[RESIZE:%.*]] = trunc i16 [[TMP0]] to i15
-// UNSIGNED-NEXT:[[TMP1:%.*]] = call i15 @llvm.usub.sat.i15(i15 [[RESIZE]], i15 -1)
-// UNSIGNED-NEXT:[[RESIZE1:%.*]] = zext i15 [[TMP1]] to i16
+// UNSIGNED-NEXT:[[TMP1:%.*]] = call i16 @llvm.ssub.sat.i16(i16 [[TMP0]], i16 3

[clang] 808ac54 - [Fixed Point] Use FixedPointBuilder to codegen fixed-point IR.

2020-08-24 Thread Bevin Hansson via cfe-commits

Author: Bevin Hansson
Date: 2020-08-24T14:37:07+02:00
New Revision: 808ac54645212ddc9aba150cdc97454e36fb9521

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

LOG: [Fixed Point] Use FixedPointBuilder to codegen fixed-point IR.

This changes the methods in CGExprScalar to use
FixedPointBuilder to generate IR for fixed-point
conversions and operations.

Since FixedPointBuilder emits padded operations slightly
differently than the original code, some tests change.

Reviewed By: leonardchan

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

Added: 


Modified: 
clang/lib/CodeGen/CGExprScalar.cpp
clang/test/Frontend/fixed_point_add.c
clang/test/Frontend/fixed_point_div.c
clang/test/Frontend/fixed_point_mul.c
clang/test/Frontend/fixed_point_sub.c
clang/test/Frontend/fixed_point_unary.c

Removed: 




diff  --git a/clang/lib/CodeGen/CGExprScalar.cpp 
b/clang/lib/CodeGen/CGExprScalar.cpp
index aad4d2d2a674..b3857b3eeb06 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -32,6 +32,7 @@
 #include "llvm/IR/CFG.h"
 #include "llvm/IR/Constants.h"
 #include "llvm/IR/DataLayout.h"
+#include "llvm/IR/FixedPointBuilder.h"
 #include "llvm/IR/Function.h"
 #include "llvm/IR/GetElementPtrTypeIterator.h"
 #include "llvm/IR/GlobalVariable.h"
@@ -356,11 +357,6 @@ class ScalarExprEmitter
   /// and an integer.
   Value *EmitFixedPointConversion(Value *Src, QualType SrcTy, QualType DstTy,
   SourceLocation Loc);
-  Value *EmitFixedPointConversion(Value *Src,
-  llvm::FixedPointSemantics &SrcFixedSema,
-  llvm::FixedPointSemantics &DstFixedSema,
-  SourceLocation Loc,
-  bool DstIsInteger = false);
 
   /// Emit a conversion from the specified complex type to the specified
   /// destination type, where the destination type is an LLVM scalar type.
@@ -1447,91 +1443,17 @@ Value 
*ScalarExprEmitter::EmitFixedPointConversion(Value *Src, QualType SrcTy,
SourceLocation Loc) {
   auto SrcFPSema = CGF.getContext().getFixedPointSemantics(SrcTy);
   auto DstFPSema = CGF.getContext().getFixedPointSemantics(DstTy);
-  return EmitFixedPointConversion(Src, SrcFPSema, DstFPSema, Loc,
-  DstTy->isIntegerType());
-}
-
-Value *ScalarExprEmitter::EmitFixedPointConversion(
-Value *Src, llvm::FixedPointSemantics &SrcFPSema,
-llvm::FixedPointSemantics &DstFPSema,
-SourceLocation Loc, bool DstIsInteger) {
-  using llvm::APFixedPoint;
-  using llvm::APInt;
-  using llvm::ConstantInt;
-  using llvm::Value;
-
-  unsigned SrcWidth = SrcFPSema.getWidth();
-  unsigned DstWidth = DstFPSema.getWidth();
-  unsigned SrcScale = SrcFPSema.getScale();
-  unsigned DstScale = DstFPSema.getScale();
-  bool SrcIsSigned = SrcFPSema.isSigned();
-  bool DstIsSigned = DstFPSema.isSigned();
-
-  llvm::Type *DstIntTy = Builder.getIntNTy(DstWidth);
-
-  Value *Result = Src;
-  unsigned ResultWidth = SrcWidth;
-
-  // Downscale.
-  if (DstScale < SrcScale) {
-// When converting to integers, we round towards zero. For negative 
numbers,
-// right shifting rounds towards negative infinity. In this case, we can
-// just round up before shifting.
-if (DstIsInteger && SrcIsSigned) {
-  Value *Zero = llvm::Constant::getNullValue(Result->getType());
-  Value *IsNegative = Builder.CreateICmpSLT(Result, Zero);
-  Value *LowBits = ConstantInt::get(
-  CGF.getLLVMContext(), APInt::getLowBitsSet(ResultWidth, SrcScale));
-  Value *Rounded = Builder.CreateAdd(Result, LowBits);
-  Result = Builder.CreateSelect(IsNegative, Rounded, Result);
-}
-
-Result = SrcIsSigned
- ? Builder.CreateAShr(Result, SrcScale - DstScale, "downscale")
- : Builder.CreateLShr(Result, SrcScale - DstScale, 
"downscale");
-  }
-
-  if (!DstFPSema.isSaturated()) {
-// Resize.
-Result = Builder.CreateIntCast(Result, DstIntTy, SrcIsSigned, "resize");
-
-// Upscale.
-if (DstScale > SrcScale)
-  Result = Builder.CreateShl(Result, DstScale - SrcScale, "upscale");
-  } else {
-// Adjust the number of fractional bits.
-if (DstScale > SrcScale) {
-  // Compare to DstWidth to prevent resizing twice.
-  ResultWidth = std::max(SrcWidth + DstScale - SrcScale, DstWidth);
-  llvm::Type *UpscaledTy = Builder.getIntNTy(ResultWidth);
-  Result = Builder.CreateIntCast(Result, UpscaledTy, SrcIsSigned, 
"resize");
-  Result = Builder.CreateShl(Result, DstScale - SrcScale, "upscale");
-}
-
-// Handle saturation.
-bool LessIntBits = DstFPSema.getIntegralBi

[PATCH] D83294: [Fixed Point] Add codegen for fixed-point shifts.

2020-08-24 Thread Bevin Hansson via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG577f8b157a03: [Fixed Point] Add codegen for fixed-point 
shifts. (authored by ebevhan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83294

Files:
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/test/Frontend/fixed_point_compound.c
  clang/test/Frontend/fixed_point_shift.c
  clang/test/Frontend/fixed_point_shift_const.c

Index: clang/test/Frontend/fixed_point_shift_const.c
===
--- /dev/null
+++ clang/test/Frontend/fixed_point_shift_const.c
@@ -0,0 +1,52 @@
+// RUN: %clang_cc1 -ffixed-point -triple x86_64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,SIGNED
+// RUN: %clang_cc1 -ffixed-point -triple x86_64-unknown-linux-gnu -fpadding-on-unsigned-fixed-point -S -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,UNSIGNED
+
+short _Accum sa_const1 = 1.0hk << 2;
+// CHECK-DAG: @sa_const1 = {{.*}}global i16 512
+short _Accum sa_const2 = 0.5hk << 2;
+// CHECK-DAG: @sa_const2 = {{.*}}global i16 256
+short _Accum sa_const3 = 10.0hk >> 3;
+// CHECK-DAG: @sa_const3 = {{.*}}global i16 160
+short _Accum sa_const4 = 0.0546875hk << 8;
+// CHECK-DAG: @sa_const4 = {{.*}}global i16 1792
+short _Accum sa_const5 = -1.0hk << 2;
+// CHECK-DAG: @sa_const5 = {{.*}}global i16 -512
+short _Accum sa_const6 = -255.0hk >> 8;
+// CHECK-DAG: @sa_const6 = {{.*}}global i16 -128
+
+_Fract f_const1 = -1.0r >> 5;
+// CHECK-DAG: @f_const1 = {{.*}}global i16 -1024
+_Fract f_const2 = 0.0052490234375r >> 3;
+// CHECK-DAG: @f_const2 = {{.*}}global i16 21
+_Fract f_const3 = -0.0001r << 5;
+// CHECK-DAG: @f_const3 = {{.*}}global i16 -96
+_Fract f_const4 = -0.75r >> 15;
+// CHECK-DAG: @f_const4 = {{.*}}global i16 -1
+_Fract f_const5 = 0.078216552734375r << 3;
+// CHECK-DAG: @f_const5 = {{.*}}global i16 20504
+
+unsigned _Fract uf_const1 = 0.375ur >> 13;
+// SIGNED-DAG:   @uf_const1 = {{.*}}global i16 3
+// UNSIGNED-DAG: @uf_const1 = {{.*}}global i16 1
+unsigned _Fract uf_const2 = 0.0546875ur << 3;
+// SIGNED-DAG:   @uf_const2 = {{.*}}global i16 28672
+// UNSIGNED-DAG: @uf_const2 = {{.*}}global i16 14336
+
+_Sat short _Accum ssa_const1 = (_Sat short _Accum)31.875hk << 4;
+// CHECK-DAG: @ssa_const1 = {{.*}}global i16 32767
+_Sat short _Accum ssa_const2 = (_Sat short _Accum) - 1.0hk << 8;
+// CHECK-DAG: @ssa_const2 = {{.*}}global i16 -32768
+_Sat short _Accum ssa_const3 = (_Sat short _Accum)128.0hk << 8;
+// CHECK-DAG: @ssa_const3 = {{.*}}global i16 32767
+_Sat short _Fract ssf_const1 = (_Sat short _Fract) - 0.5hr << 3;
+// CHECK-DAG: @ssf_const1 = {{.*}}global i8 -128
+
+_Sat unsigned _Fract suf_const1 = (_Sat unsigned _Fract)0.5r << 1;
+// SIGNED-DAG:   @suf_const1 = {{.*}}global i16 -1
+// UNSIGNED-DAG: @suf_const1 = {{.*}}global i16 32767
+_Sat unsigned _Fract suf_const2 = (_Sat unsigned _Fract)0.25r << 1;
+// SIGNED-DAG:   @suf_const2 = {{.*}}global i16 -32768
+// UNSIGNED-DAG: @suf_const2 = {{.*}}global i16 16384
+_Sat unsigned _Accum sua_const2 = (_Sat unsigned _Accum)128.0uk << 10;
+// SIGNED-DAG:   @sua_const2 = {{.*}}global i32 -1
+// UNSIGNED-DAG: @sua_const2 = {{.*}}global i32 2147483647
Index: clang/test/Frontend/fixed_point_shift.c
===
--- clang/test/Frontend/fixed_point_shift.c
+++ clang/test/Frontend/fixed_point_shift.c
@@ -1,37 +1,580 @@
-// RUN: %clang_cc1 -ffixed-point -S -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,SIGNED
-// RUN: %clang_cc1 -ffixed-point -fpadding-on-unsigned-fixed-point -S -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,UNSIGNED
-
-short _Accum sa_const1 = 1.0hk << 2;   // CHECK-DAG: @sa_const1 = {{.*}}global i16 512
-short _Accum sa_const2 = 0.5hk << 2;   // CHECK-DAG: @sa_const2 = {{.*}}global i16 256
-short _Accum sa_const3 = 10.0hk >> 3;  // CHECK-DAG: @sa_const3 = {{.*}}global i16 160
-short _Accum sa_const4 = 0.0546875hk << 8; // CHECK-DAG: @sa_const4 = {{.*}}global i16 1792
-short _Accum sa_const5 = -1.0hk << 2;  // CHECK-DAG: @sa_const5 = {{.*}}global i16 -512
-short _Accum sa_const6 = -255.0hk >> 8;// CHECK-DAG: @sa_const6 = {{.*}}global i16 -128
-
-_Fract f_const1 = -1.0r >> 5;  // CHECK-DAG: @f_const1 = {{.*}}global i16 -1024
-_Fract f_const2 = 0.0052490234375r >> 3;   // CHECK-DAG: @f_const2 = {{.*}}global i16 21
-_Fract f_const3 = -0.0001r << 5;   // CHECK-DAG: @f_const3 = {{.*}}global i16 -96
-_Fract f_const4 = -0.75r >> 15;// CHECK-DAG: @f_const4 = {{.*}}global i16 -1
-_Fract f_const5 = 0.078216552734375r << 3; // CHECK-DAG: @f_const5 = {{.*}}global i16 20504
-
-unsigned _Fract uf_const1 = 0.375ur >> 13;
-// SIGNED-DAG:   @uf_const1 = {{.*}}global i16 3
-// UNSIGNED-DAG: @uf_const1 = {{.*}}global i16 1
-unsigned _Fract uf_const2 = 0.0546

[PATCH] D85032: [builtins] Make divXf3 handle denormal results

2020-08-24 Thread Anatoly Trosinenko via Phabricator via cfe-commits
atrosinenko updated this revision to Diff 287354.
atrosinenko added a comment.

Re-upload after parent commits were changed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85032

Files:
  compiler-rt/lib/builtins/fp_div_impl.inc
  compiler-rt/test/builtins/Unit/divdf3_test.c
  compiler-rt/test/builtins/Unit/divsf3_test.c
  compiler-rt/test/builtins/Unit/divtf3_test.c

Index: compiler-rt/test/builtins/Unit/divtf3_test.c
===
--- compiler-rt/test/builtins/Unit/divtf3_test.c
+++ compiler-rt/test/builtins/Unit/divtf3_test.c
@@ -146,6 +146,13 @@
  UINT64_C(0xfffe)))
 return 1;
 
+// smallest normal value divided by 2.0
+if (test__divtf3(0x1.0p-16382L, 2.L, UINT64_C(0x8000), UINT64_C(0x0)))
+  return 1;
+// smallest subnormal result
+if (test__divtf3(0x1.0p-1022L, 0x1p+52L, UINT64_C(0x0), UINT64_C(0x1)))
+  return 1;
+
 // any / any
 if (test__divtf3(0x1.a23b45362464523375893ab4cdefp+5L,
  0x1.eedcbaba3a94546558237654321fp-1L,
Index: compiler-rt/test/builtins/Unit/divsf3_test.c
===
--- compiler-rt/test/builtins/Unit/divsf3_test.c
+++ compiler-rt/test/builtins/Unit/divsf3_test.c
@@ -92,5 +92,20 @@
 if (test__divsf3(0x1.0p+0F, 0x1.0001p+0F, UINT32_C(0x3f7fff00)))
   return 1;
 
+// smallest normal value divided by 2.0
+if (test__divsf3(0x1.0p-126F, 2.0F, UINT32_C(0x0040)))
+  return 1;
+// smallest subnormal result
+if (test__divsf3(0x1.0p-126F, 0x1p+23F, UINT32_C(0x0001)))
+  return 1;
+
+// some misc test cases obtained by fuzzing against h/w implementation
+if (test__divsf3(-0x1.3e75e6p-108F, -0x1.cf372p+38F, UINT32_C(0x0006)))
+  return 1;
+if (test__divsf3(0x1.e77c54p+81F, -0x1.e77c52p-47F, UINT32_C(0xff80)))
+  return 1;
+if (test__divsf3(0x1.fep-126F, 2.F, UINT32_C(0x0080)))
+  return 1;
+
 return 0;
 }
Index: compiler-rt/test/builtins/Unit/divdf3_test.c
===
--- compiler-rt/test/builtins/Unit/divdf3_test.c
+++ compiler-rt/test/builtins/Unit/divdf3_test.c
@@ -92,6 +92,13 @@
 if (test__divdf3(0x1.0p+0, 0x1.0001p+0, UINT64_C(0x3fefffe0)))
   return 1;
 
+// smallest normal value divided by 2.0
+if (test__divdf3(0x1.0p-1022, 2., UINT64_C(0x0008)))
+  return 1;
+// smallest subnormal result
+if (test__divdf3(0x1.0p-1022, 0x1.0p+52, UINT64_C(0x0001)))
+  return 1;
+
 // some misc test cases obtained by fuzzing against h/w implementation
 if (test__divdf3(0x1.fdc239dd64735p-658, -0x1.fff9364c0843fp-948, UINT64_C(0xd20fdc8fc0ceffb1)))
   return 1;
@@ -99,6 +106,12 @@
   return 1;
 if (test__divdf3(-0x1.da7dfe6048b8bp-875, 0x1.ffc7ea3ff60a4p-610, UINT64_C(0xaf5dab1fe0269e2a)))
   return 1;
+if (test__divdf3(0x1.0p-1022, 0x1.9p+5, UINT64_C(0x51eb851eb852)))
+  return 1;
+if (test__divdf3(0x1.0p-1022, 0x1.0028p+41, UINT64_C(0x07ff)))
+  return 1;
+if (test__divdf3(0x1.0p-1022, 0x1.0028p+52, UINT64_C(0x1)))
+  return 1;
 
 return 0;
 }
Index: compiler-rt/lib/builtins/fp_div_impl.inc
===
--- compiler-rt/lib/builtins/fp_div_impl.inc
+++ compiler-rt/lib/builtins/fp_div_impl.inc
@@ -275,6 +275,7 @@
   if (quotient_UQ1 < (implicitBit << 1)) {
 residualLo = (aSignificand << (significandBits + 1)) - quotient_UQ1 * bSignificand;
 writtenExponent -= 1;
+aSignificand <<= 1;
 
 // the error is doubled
   } else {
@@ -304,19 +305,25 @@
   // Now, quotient_UQ1_SB <= the correctly-rounded result
   // and may need taking NextAfter() up to 3 times (see error estimates above)
   // r = a - b * q
+  rep_t absResult;
+  if (writtenExponent > 0) {
+// Clear the implicit bit
+absResult = quotient_UQ1 & significandMask;
+// Insert the exponent
+absResult |= (rep_t)writtenExponent << significandBits;
+residualLo <<= 1;
+  } else {
+// Prevent shift amount from being negative
+if (significandBits + writtenExponent < 0)
+  return fromRep(quotientSign);
 
-  if (writtenExponent < 0) {
-// Result is definitely subnormal, flushing to zero
-return fromRep(quotientSign);
-  }
+absResult = quotient_UQ1 >> (-writtenExponent + 1);
 
-  // Clear the implicit bit
-  rep_t absResult = quotient_UQ1 & significandMask;
-  // Insert the exponent
-  absResult |= (rep_t)writtenExponent << significandBits;
+// multiplied by two to prevent shift amount to be negative
+residualLo = (aSignificand << (significandBits + writtenExponent)) - (absResult * bSignificand << 1);
+  }
 
   // Round
-  residualLo <<= 1;
   residualLo += absResult & 1;

[PATCH] D86295: [analyzer] Reorder the layout of MemRegion and cache by hand for optimal size

2020-08-24 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

In D86295#2233244 , @vsavchenko wrote:

> Here is a short summary how to do regression testing (check that all warnings 
> are the same):

Oh thanks for the detailed guide, I will make the experiment.

However the `./SATest.py docker --build-image` seems broken.

  E: Version '9.0.1-2.3~ubuntu1.18.04.1' for 'python3-pip' was not found
  The command '/bin/sh -c apt-get update && apt-get install -y 
git=1:2.17.1-1ubuntu0.7 gettext=0.19.8.1-6ubuntu0.3 
python3=3.6.7-1~18.04 python3-pip=9.0.1-2.3~ubuntu1.18.04.1 
cmake=3.17.3-0kitware1 ninja-build=1.8.2-1' returned a non-zero code: 100

In the DockerFile it should be `python3-pip=9.0.1-2.3~ubuntu1.18.04.2` instead.
Shouldn't we anchor it to a specific version of //bionic// in the `FROM` clause?

In D86295#2233248 , @Szelethus wrote:

> I really like the patch, but have nothing to add to what other reviewers 
> already said. Nice!

Thanks:)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86295

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


[PATCH] D86295: [analyzer] Reorder the layout of MemRegion and cache by hand for optimal size

2020-08-24 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

In D86295#2233398 , @steakhal wrote:

> In D86295#2233244 , @vsavchenko 
> wrote:
>
>> Here is a short summary how to do regression testing (check that all 
>> warnings are the same):
>
> Oh thanks for the detailed guide, I will make the experiment.
>
> However the `./SATest.py docker --build-image` seems broken.
>
>   E: Version '9.0.1-2.3~ubuntu1.18.04.1' for 'python3-pip' was not found
>   The command '/bin/sh -c apt-get update && apt-get install -y 
> git=1:2.17.1-1ubuntu0.7 gettext=0.19.8.1-6ubuntu0.3 
> python3=3.6.7-1~18.04 python3-pip=9.0.1-2.3~ubuntu1.18.04.1 
> cmake=3.17.3-0kitware1 ninja-build=1.8.2-1' returned a non-zero code: 100
>
> In the DockerFile it should be `python3-pip=9.0.1-2.3~ubuntu1.18.04.2` 
> instead.
> Shouldn't we anchor it to a specific version of //bionic// in the `FROM` 
> clause?

Yep, I guess that is the cause.  I'll take a look.  Did you try it with this 
fast fix?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86295

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


[PATCH] D86299: [compiler-rt][builtins] Factor out some common bit manipulations

2020-08-24 Thread Anatoly Trosinenko via Phabricator via cfe-commits
atrosinenko updated this revision to Diff 287355.
atrosinenko added a comment.

Reupload.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86299

Files:
  compiler-rt/lib/builtins/fixdfdi.c
  compiler-rt/lib/builtins/fixdfsi.c
  compiler-rt/lib/builtins/fixdfti.c
  compiler-rt/lib/builtins/fixsfdi.c
  compiler-rt/lib/builtins/fixsfsi.c
  compiler-rt/lib/builtins/fixsfti.c
  compiler-rt/lib/builtins/fixtfdi.c
  compiler-rt/lib/builtins/fixtfsi.c
  compiler-rt/lib/builtins/fixtfti.c
  compiler-rt/lib/builtins/fp_fixint_impl.inc
  compiler-rt/lib/builtins/int_mulo_impl.inc
  compiler-rt/lib/builtins/int_mulv_impl.inc
  compiler-rt/lib/builtins/int_types.h
  compiler-rt/lib/builtins/negdi2.c
  compiler-rt/lib/builtins/negti2.c
  compiler-rt/lib/builtins/negvdi2.c
  compiler-rt/lib/builtins/negvsi2.c
  compiler-rt/lib/builtins/negvti2.c

Index: compiler-rt/lib/builtins/negvti2.c
===
--- compiler-rt/lib/builtins/negvti2.c
+++ compiler-rt/lib/builtins/negvti2.c
@@ -19,8 +19,7 @@
 // Effects: aborts if -a overflows
 
 COMPILER_RT_ABI ti_int __negvti2(ti_int a) {
-  const ti_int MIN = (ti_int)1 << ((int)(sizeof(ti_int) * CHAR_BIT) - 1);
-  if (a == MIN)
+  if (a == MIN_SIGNED(ti_int))
 compilerrt_abort();
   return -a;
 }
Index: compiler-rt/lib/builtins/negvsi2.c
===
--- compiler-rt/lib/builtins/negvsi2.c
+++ compiler-rt/lib/builtins/negvsi2.c
@@ -17,8 +17,7 @@
 // Effects: aborts if -a overflows
 
 COMPILER_RT_ABI si_int __negvsi2(si_int a) {
-  const si_int MIN = (si_int)1 << ((int)(sizeof(si_int) * CHAR_BIT) - 1);
-  if (a == MIN)
+  if (a == MIN_SIGNED(si_int))
 compilerrt_abort();
   return -a;
 }
Index: compiler-rt/lib/builtins/negvdi2.c
===
--- compiler-rt/lib/builtins/negvdi2.c
+++ compiler-rt/lib/builtins/negvdi2.c
@@ -17,8 +17,7 @@
 // Effects: aborts if -a overflows
 
 COMPILER_RT_ABI di_int __negvdi2(di_int a) {
-  const di_int MIN = (di_int)1 << ((int)(sizeof(di_int) * CHAR_BIT) - 1);
-  if (a == MIN)
+  if (a == MIN_SIGNED(di_int))
 compilerrt_abort();
   return -a;
 }
Index: compiler-rt/lib/builtins/negti2.c
===
--- compiler-rt/lib/builtins/negti2.c
+++ compiler-rt/lib/builtins/negti2.c
@@ -19,7 +19,7 @@
 COMPILER_RT_ABI ti_int __negti2(ti_int a) {
   // Note: this routine is here for API compatibility; any sane compiler
   // should expand it inline.
-  return -a;
+  return -(tu_int)a;
 }
 
 #endif // CRT_HAS_128BIT
Index: compiler-rt/lib/builtins/negdi2.c
===
--- compiler-rt/lib/builtins/negdi2.c
+++ compiler-rt/lib/builtins/negdi2.c
@@ -17,5 +17,5 @@
 COMPILER_RT_ABI di_int __negdi2(di_int a) {
   // Note: this routine is here for API compatibility; any sane compiler
   // should expand it inline.
-  return -a;
+  return -(du_int)a;
 }
Index: compiler-rt/lib/builtins/int_types.h
===
--- compiler-rt/lib/builtins/int_types.h
+++ compiler-rt/lib/builtins/int_types.h
@@ -1,4 +1,4 @@
-//===-- int_lib.h - configuration header for compiler-rt  -===//
+//===-- int_types.h - type definitions for compiler-rt ===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -37,6 +37,30 @@
 typedef int64_t di_int;
 typedef uint64_t du_int;
 
+// Helpers for standard type aliases to get signed from unsigned and vice versa
+#define AS_SIGNED(type) type##_AS_SIGNED
+#define AS_UNSIGNED(type) type##_AS_UNSIGNED
+#define si_int_AS_SIGNED si_int
+#define su_int_AS_SIGNED si_int
+#define di_int_AS_SIGNED di_int
+#define du_int_AS_SIGNED di_int
+#define ti_int_AS_SIGNED ti_int
+#define tu_int_AS_SIGNED ti_int
+#define si_int_AS_UNSIGNED su_int
+#define su_int_AS_UNSIGNED su_int
+#define di_int_AS_UNSIGNED du_int
+#define du_int_AS_UNSIGNED du_int
+#define ti_int_AS_UNSIGNED tu_int
+#define tu_int_AS_UNSIGNED tu_int
+
+// Misc macroses incapsulating common hacks.
+// Supposed to replace the ad-hoc UB-prone implementations.
+#define bitsizeof(type_or_value) ((int)(sizeof(type_or_value) * CHAR_BIT))
+#define SIGN_BIT(type) ((AS_UNSIGNED(type))1 << (bitsizeof(type) - 1))
+#define MIN_SIGNED(type) ((AS_SIGNED(type))SIGN_BIT(type))
+#define MAX_SIGNED(type) ((AS_SIGNED(type))(SIGN_BIT(type) - 1U))
+#define MAX_UNSIGNED(type) (~(AS_UNSIGNED(type))0))
+
 typedef union {
   di_int all;
   struct {
Index: compiler-rt/lib/builtins/int_mulv_impl.inc
===
--- compiler-rt/lib/builtins/int_mulv_impl.inc
+++ compiler-rt/lib/builtins/int_mulv_impl.inc
@@ -17,9 +17,9 @@
 // Ef

[clang] 105151c - Reland "Correctly emit dwoIDs after ASTFileSignature refactoring (D81347)"

2020-08-24 Thread Raphael Isemann via cfe-commits

Author: Raphael Isemann
Date: 2020-08-24T14:52:53+02:00
New Revision: 105151ca5669a0536fb5bb1bc02bd3279cdbbfda

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

LOG: Reland "Correctly emit dwoIDs after ASTFileSignature refactoring (D81347)"

The orignal patch with the missing 'REQUIRES: asserts' as there is a debug-only
flag used in the test.

Original summary:

D81347 changes the ASTFileSignature to be an array of 20 uint8_t instead of 5
uint32_t. However, it didn't update the code in ObjectFilePCHContainerOperations
that creates the dwoID in the module from the ASTFileSignature
(`Buffer->Signature` being the array subclass that is now `std::array` instead of `std::array`).

```
  uint64_t Signature = [..] (uint64_t)Buffer->Signature[1] << 32 | 
Buffer->Signature[0]
```

This code works with the old ASTFileSignature (where two uint32_t are enough to
fill the uint64_t), but after the patch this only took two bytes from the
ASTFileSignature and only partly filled the Signature uint64_t.

This caused that the dwoID in the module ref and the dwoID in the actual module
no longer match (which in turns causes that LLDB keeps warning about the dwoID's
not matching when debugging -gmodules-compiled binaries).

This patch just unifies the logic for turning the ASTFileSignature into an
uint64_t which makes the dwoID match again (and should prevent issues like that
in the future).

Reviewed By: aprantl, dang

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

Added: 
clang/test/Modules/Inputs/DebugDwoId.h
clang/test/Modules/ModuleDebugInfoDwoId.cpp

Modified: 
clang/include/clang/Basic/Module.h
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
clang/test/Modules/Inputs/module.map

Removed: 




diff  --git a/clang/include/clang/Basic/Module.h 
b/clang/include/clang/Basic/Module.h
index 94dd21537966..ac33c7573f35 100644
--- a/clang/include/clang/Basic/Module.h
+++ b/clang/include/clang/Basic/Module.h
@@ -62,6 +62,15 @@ struct ASTFileSignature : std::array {
 
   explicit operator bool() const { return *this != BaseT({{0}}); }
 
+  /// Returns the value truncated to the size of an uint64_t.
+  uint64_t truncatedValue() const {
+uint64_t Value = 0;
+static_assert(sizeof(*this) >= sizeof(uint64_t), "No need to truncate.");
+for (unsigned I = 0; I < sizeof(uint64_t); ++I)
+  Value |= static_cast((*this)[I]) << (I * 8);
+return Value;
+  }
+
   static ASTFileSignature create(StringRef Bytes) {
 return create(Bytes.bytes_begin(), Bytes.bytes_end());
   }

diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 2faf944d07d1..e3442ecd4bd5 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2545,12 +2545,11 @@ llvm::DIModule 
*CGDebugInfo::getOrCreateModuleRef(ASTSourceDescriptor Mod,
 // We use the lower 64 bits for debug info.
 
 uint64_t Signature = 0;
-if (const auto &ModSig = Mod.getSignature()) {
-  for (unsigned I = 0; I != sizeof(Signature); ++I)
-Signature |= (uint64_t)ModSig[I] << (I * 8);
-} else {
+if (const auto &ModSig = Mod.getSignature())
+  Signature = ModSig.truncatedValue();
+else
   Signature = ~1ULL;
-}
+
 llvm::DIBuilder DIB(CGM.getModule());
 SmallString<0> PCM;
 if (!llvm::sys::path::is_absolute(Mod.getASTFile()))

diff  --git a/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp 
b/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
index 0c7e5f4598f8..04bd6680e31c 100644
--- a/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
+++ b/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
@@ -250,10 +250,10 @@ class PCHContainerGenerator : public ASTConsumer {
 // PCH files don't have a signature field in the control block,
 // but LLVM detects DWO CUs by looking for a non-zero DWO id.
 // We use the lower 64 bits for debug info.
+
 uint64_t Signature =
-Buffer->Signature
-? (uint64_t)Buffer->Signature[1] << 32 | Buffer->Signature[0]
-: ~1ULL;
+Buffer->Signature ? Buffer->Signature.truncatedValue() : ~1ULL;
+
 Builder->getModuleDebugInfo()->setDwoId(Signature);
 
 // Finalize the Builder.

diff  --git a/clang/test/Modules/Inputs/DebugDwoId.h 
b/clang/test/Modules/Inputs/DebugDwoId.h
new file mode 100644
index ..242e4c7f5116
--- /dev/null
+++ b/clang/test/Modules/Inputs/DebugDwoId.h
@@ -0,0 +1,4 @@
+#ifndef DEBUG_DWO_ID_H
+#define DEBUG_DWO_ID_H
+struct Dummy {};
+#endif

diff  --git a/clang/test/Modules/Inputs/module.map 
b/clang/test/Modules/Inputs/module.map
index ed220e667f05..e7cb4b27bc08 100644
--- a/clang/test/Modules/Inputs/module.map
+++ b/clang/test/Modules/Inputs/mod

[PATCH] D86414: [compiler-rt][builtins] Fix some other cases of UB

2020-08-24 Thread Anatoly Trosinenko via Phabricator via cfe-commits
atrosinenko updated this revision to Diff 287359.
atrosinenko added a comment.

Re-upload with properly set parent review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86414

Files:
  compiler-rt/lib/builtins/absvdi2.c
  compiler-rt/lib/builtins/absvsi2.c
  compiler-rt/lib/builtins/absvti2.c
  compiler-rt/lib/builtins/floattidf.c
  compiler-rt/lib/builtins/floattixf.c
  compiler-rt/lib/builtins/int_div_impl.inc
  compiler-rt/lib/builtins/int_types.h

Index: compiler-rt/lib/builtins/int_types.h
===
--- compiler-rt/lib/builtins/int_types.h
+++ compiler-rt/lib/builtins/int_types.h
@@ -60,6 +60,7 @@
 #define MIN_SIGNED(type) ((AS_SIGNED(type))SIGN_BIT(type))
 #define MAX_SIGNED(type) ((AS_SIGNED(type))(SIGN_BIT(type) - 1U))
 #define MAX_UNSIGNED(type) (~(AS_UNSIGNED(type))0))
+#define SIGN_OF(signed_int) ((signed_int) >> (bitsizeof(signed_int) - 1))
 
 typedef union {
   di_int all;
Index: compiler-rt/lib/builtins/int_div_impl.inc
===
--- compiler-rt/lib/builtins/int_div_impl.inc
+++ compiler-rt/lib/builtins/int_div_impl.inc
@@ -71,25 +71,31 @@
 
 #ifdef COMPUTE_UDIV
 static __inline fixint_t __divXi3(fixint_t a, fixint_t b) {
-  const int N = (int)(sizeof(fixint_t) * CHAR_BIT) - 1;
-  fixint_t s_a = a >> N;   // s_a = a < 0 ? -1 : 0
-  fixint_t s_b = b >> N;   // s_b = b < 0 ? -1 : 0
-  a = (a ^ s_a) - s_a; // negate if s_a == -1
-  b = (b ^ s_b) - s_b; // negate if s_b == -1
-  s_a ^= s_b;  // sign of quotient
-  return (COMPUTE_UDIV(a, b) ^ s_a) - s_a; // negate if s_a == -1
+  // extract signs (0 or -1) of arguments
+  fixint_t s_a = SIGN_OF(a);
+  fixint_t s_b = SIGN_OF(b);
+  // compute absolute values of arguments
+  a = (fixuint_t)(a ^ s_a) - (fixuint_t)s_a;
+  b = (fixuint_t)(b ^ s_b) - (fixuint_t)s_b;
+  // compute a sign of quotient
+  s_a ^= s_b;
+  // compute an absolute value of quotient and negate it if needed
+  return (fixuint_t)(COMPUTE_UDIV(a, b) ^ s_a) - (fixuint_t)s_a;
 }
 #endif // COMPUTE_UDIV
 
 #ifdef ASSIGN_UMOD
 static __inline fixint_t __modXi3(fixint_t a, fixint_t b) {
-  const int N = (int)(sizeof(fixint_t) * CHAR_BIT) - 1;
-  fixint_t s = b >> N;// s = b < 0 ? -1 : 0
-  b = (b ^ s) - s;// negate if s == -1
-  s = a >> N; // s = a < 0 ? -1 : 0
-  a = (a ^ s) - s;// negate if s == -1
+  // compute an absolute value of b
+  fixint_t s = SIGN_OF(b);
+  b = (fixuint_t)(b ^ s) - (fixuint_t)s;
+  // compute an absolute value of a
+  s = SIGN_OF(a);
+  a = (fixuint_t)(a ^ s) - (fixuint_t)s;
+  // compute an absolute value of the result
   fixuint_t res;
   ASSIGN_UMOD(res, a, b);
-  return (res ^ s) - s;   // negate if s == -1
+  // make the result have the same sign as b
+  return (fixuint_t)(res ^ s) - (fixuint_t)s;
 }
 #endif // ASSIGN_UMOD
Index: compiler-rt/lib/builtins/floattixf.c
===
--- compiler-rt/lib/builtins/floattixf.c
+++ compiler-rt/lib/builtins/floattixf.c
@@ -26,9 +26,9 @@
 COMPILER_RT_ABI long double __floattixf(ti_int a) {
   if (a == 0)
 return 0.0;
-  const unsigned N = sizeof(ti_int) * CHAR_BIT;
-  const ti_int s = a >> (N - 1);
-  a = (a ^ s) - s;
+  const unsigned N = bitsizeof(ti_int);
+  const ti_int s = SIGN_OF(a);
+  a = (tu_int)(a ^ s) - (tu_int)s;
   int sd = N - __clzti2(a); // number of significant digits
   int e = sd - 1;   // exponent
   if (sd > LDBL_MANT_DIG) {
Index: compiler-rt/lib/builtins/floattidf.c
===
--- compiler-rt/lib/builtins/floattidf.c
+++ compiler-rt/lib/builtins/floattidf.c
@@ -25,9 +25,9 @@
 COMPILER_RT_ABI double __floattidf(ti_int a) {
   if (a == 0)
 return 0.0;
-  const unsigned N = sizeof(ti_int) * CHAR_BIT;
-  const ti_int s = a >> (N - 1);
-  a = (a ^ s) - s;
+  const unsigned N = bitsizeof(ti_int);
+  const ti_int s = SIGN_OF(a);
+  a = (tu_int)(a ^ s) - (tu_int)s;
   int sd = N - __clzti2(a); // number of significant digits
   int e = sd - 1;   // exponent
   if (sd > DBL_MANT_DIG) {
Index: compiler-rt/lib/builtins/absvti2.c
===
--- compiler-rt/lib/builtins/absvti2.c
+++ compiler-rt/lib/builtins/absvti2.c
@@ -19,11 +19,10 @@
 // Effects: aborts if abs(x) < 0
 
 COMPILER_RT_ABI ti_int __absvti2(ti_int a) {
-  const int N = (int)(sizeof(ti_int) * CHAR_BIT);
-  if (a == ((ti_int)1 << (N - 1)))
+  if (a == MIN_SIGNED(ti_int))
 compilerrt_abort();
-  const ti_int s = a >> (N - 1);
-  return (a ^ s) - s;
+  const ti_int t = SIGN_OF(a);
+  return (tu_int)(a ^ t) - (tu_int)t;
 }
 
 #endif // CRT_HAS_128BIT
Index: compiler-rt/lib/builtins/absvsi2.c
===

[PATCH] D84013: Correctly emit dwoIDs after ASTFileSignature refactoring (D81347)

2020-08-24 Thread Raphael Isemann via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG105151ca5669: Reland "Correctly emit dwoIDs after 
ASTFileSignature refactoring (D81347)" (authored by teemperor).

Changed prior to commit:
  https://reviews.llvm.org/D84013?vs=287318&id=287358#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84013

Files:
  clang/include/clang/Basic/Module.h
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
  clang/test/Modules/Inputs/DebugDwoId.h
  clang/test/Modules/Inputs/module.map
  clang/test/Modules/ModuleDebugInfoDwoId.cpp

Index: clang/test/Modules/ModuleDebugInfoDwoId.cpp
===
--- /dev/null
+++ clang/test/Modules/ModuleDebugInfoDwoId.cpp
@@ -0,0 +1,22 @@
+// Tests that dwoIds in modules match the dwoIDs in the main file.
+
+// REQUIRES: asserts
+
+// RUN: rm -rf %t.cache
+// RUN: %clang_cc1 -triple %itanium_abi_triple -x objective-c++ -std=c++11 -debugger-tuning=lldb -debug-info-kind=limited -fmodules -fmodule-format=obj -dwarf-ext-refs -fimplicit-module-maps -fmodules-cache-path=%t.cache %s -I %S/Inputs -emit-llvm -o %t.ll -mllvm -debug-only=pchcontainer 2> %t.mod-out
+// RUN: cat %t.ll %t.mod-out | FileCheck %s
+// RUN: cat %t.ll | FileCheck --check-prefix=CHECK-REALIDS %s
+// RUN: cat %t.mod-out | FileCheck --check-prefix=CHECK-REALIDS %s
+
+@import DebugDwoId;
+
+Dummy d;
+
+// Find the emitted dwoID for DebugInfoId and compare it against the one in the PCM.
+// CHECK: DebugDwoId-{{[A-Z0-9]+}}.pcm
+// CHECK-SAME: dwoId: [[DWOID:[0-9]+]]
+// CHECK: dwoId: [[DWOID]]
+// CHECK-NEXT: !DIFile(filename: "DebugDwoId"
+
+// Make sure the dwo IDs are real IDs and not fallback values (~1ULL).
+// CHECK-REALIDS-NOT: dwoId: 18446744073709551615
Index: clang/test/Modules/Inputs/module.map
===
--- clang/test/Modules/Inputs/module.map
+++ clang/test/Modules/Inputs/module.map
@@ -357,6 +357,10 @@
   }
 }
 
+module DebugDwoId {
+  header "DebugDwoId.h"
+}
+
 module ImportNameInDir {
   header "ImportNameInDir.h"
   export *
Index: clang/test/Modules/Inputs/DebugDwoId.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/DebugDwoId.h
@@ -0,0 +1,4 @@
+#ifndef DEBUG_DWO_ID_H
+#define DEBUG_DWO_ID_H
+struct Dummy {};
+#endif
Index: clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
===
--- clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
+++ clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
@@ -250,10 +250,10 @@
 // PCH files don't have a signature field in the control block,
 // but LLVM detects DWO CUs by looking for a non-zero DWO id.
 // We use the lower 64 bits for debug info.
+
 uint64_t Signature =
-Buffer->Signature
-? (uint64_t)Buffer->Signature[1] << 32 | Buffer->Signature[0]
-: ~1ULL;
+Buffer->Signature ? Buffer->Signature.truncatedValue() : ~1ULL;
+
 Builder->getModuleDebugInfo()->setDwoId(Signature);
 
 // Finalize the Builder.
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2545,12 +2545,11 @@
 // We use the lower 64 bits for debug info.
 
 uint64_t Signature = 0;
-if (const auto &ModSig = Mod.getSignature()) {
-  for (unsigned I = 0; I != sizeof(Signature); ++I)
-Signature |= (uint64_t)ModSig[I] << (I * 8);
-} else {
+if (const auto &ModSig = Mod.getSignature())
+  Signature = ModSig.truncatedValue();
+else
   Signature = ~1ULL;
-}
+
 llvm::DIBuilder DIB(CGM.getModule());
 SmallString<0> PCM;
 if (!llvm::sys::path::is_absolute(Mod.getASTFile()))
Index: clang/include/clang/Basic/Module.h
===
--- clang/include/clang/Basic/Module.h
+++ clang/include/clang/Basic/Module.h
@@ -62,6 +62,15 @@
 
   explicit operator bool() const { return *this != BaseT({{0}}); }
 
+  /// Returns the value truncated to the size of an uint64_t.
+  uint64_t truncatedValue() const {
+uint64_t Value = 0;
+static_assert(sizeof(*this) >= sizeof(uint64_t), "No need to truncate.");
+for (unsigned I = 0; I < sizeof(uint64_t); ++I)
+  Value |= static_cast((*this)[I]) << (I * 8);
+return Value;
+  }
+
   static ASTFileSignature create(StringRef Bytes) {
 return create(Bytes.bytes_begin(), Bytes.bytes_end());
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82317: [Clang/Test]: Update tests where `noundef` attribute is necessary

2020-08-24 Thread Gui Andrade via Phabricator via cfe-commits
guiand added a comment.
Herald added a subscriber: wenlei.

@rjmccall We've discussed several different possibilities here. Does any of 
them strike you as a good step forward here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82317

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


[clang] aec12c1 - [analyzer][tests] Add a notion of project sizes

2020-08-24 Thread Valeriy Savchenko via cfe-commits

Author: Valeriy Savchenko
Date: 2020-08-24T16:13:00+03:00
New Revision: aec12c1264ac17877d5cb19750eaa322fe57342d

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

LOG: [analyzer][tests] Add a notion of project sizes

Summary:
Whith the number of projects growing, it is important to be able to
filter them in a more convenient way than by names.  It is especially
important for benchmarks, when it is not viable to analyze big
projects 20 or 50 times in a row.

Because of this reason, this commit adds a notion of sizes and a
filtering interface that puts a limit on a maximum size of the project
to analyze or benchmark.

Sizes assigned to the projects in this commit, do not directly
correspond to the number of lines or files in the project.  The key
factor that is important for the developers of the analyzer is the
time it takes to analyze the project.  And for this very reason,
"size" basically helps to cluster projects based on their analysis
time.

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

Added: 


Modified: 
clang/utils/analyzer/ProjectMap.py
clang/utils/analyzer/SATest.py
clang/utils/analyzer/projects/projects.json

Removed: 




diff  --git a/clang/utils/analyzer/ProjectMap.py 
b/clang/utils/analyzer/ProjectMap.py
index 3daa70140562..1e89ce634e57 100644
--- a/clang/utils/analyzer/ProjectMap.py
+++ b/clang/utils/analyzer/ProjectMap.py
@@ -1,7 +1,7 @@
 import json
 import os
 
-from enum import Enum
+from enum import auto, Enum
 from typing import Any, Dict, List, NamedTuple, Optional, Tuple
 
 
@@ -17,6 +17,64 @@ class DownloadType(str, Enum):
 SCRIPT = "script"
 
 
+class Size(int, Enum):
+"""
+Size of the project.
+
+Sizes do not directly correspond to the number of lines or files in the
+project.  The key factor that is important for the developers of the
+analyzer is the time it takes to analyze the project.  Here is how
+the following sizes map to times:
+
+TINY:  <1min
+SMALL: 1min-10min
+BIG:   10min-1h
+HUGE:  >1h
+
+The borders are a bit of a blur, especially because analysis time varies
+from one machine to another.  However, the relative times will stay pretty
+similar, and these groupings will still be helpful.
+
+UNSPECIFIED is a very special case, which is intentionally last in the list
+of possible sizes.  If the user wants to filter projects by one of the
+possible sizes, we want projects with UNSPECIFIED size to be filtered out
+for any given size.
+"""
+TINY = auto()
+SMALL = auto()
+BIG = auto()
+HUGE = auto()
+UNSPECIFIED = auto()
+
+@staticmethod
+def from_str(raw_size: Optional[str]) -> "Size":
+"""
+Construct a Size object from an optional string.
+
+:param raw_size: optional string representation of the desired Size
+ object.  None will produce UNSPECIFIED size.
+
+This method is case-insensitive, so raw sizes 'tiny', 'TINY', and
+'TiNy' will produce the same result.
+"""
+if raw_size is None:
+return Size.UNSPECIFIED
+
+raw_size_upper = raw_size.upper()
+# The implementation is decoupled from the actual values of the enum,
+# so we can easily add or modify it without bothering about this
+# function.
+for possible_size in Size:
+if possible_size.name == raw_size_upper:
+return possible_size
+
+possible_sizes = [size.name.lower() for size in Size
+  # no need in showing our users this size
+  if size != Size.UNSPECIFIED]
+raise ValueError(f"Incorrect project size '{raw_size}'. "
+ f"Available sizes are {possible_sizes}")
+
+
 class ProjectInfo(NamedTuple):
 """
 Information about a project to analyze.
@@ -27,6 +85,7 @@ class ProjectInfo(NamedTuple):
 origin: str = ""
 commit: str = ""
 enabled: bool = True
+size: Size = Size.UNSPECIFIED
 
 def with_fields(self, **kwargs) -> "ProjectInfo":
 """
@@ -98,6 +157,7 @@ def _parse_project(raw_project: JSON) -> ProjectInfo:
 build_mode: int = raw_project["mode"]
 enabled: bool = raw_project.get("enabled", True)
 source: DownloadType = raw_project.get("source", "zip")
+size = Size.from_str(raw_project.get("size", None))
 
 if source == DownloadType.GIT:
 origin, commit = ProjectMap._get_git_params(raw_project)
@@ -105,7 +165,7 @@ def _parse_project(raw_project: JSON) -> ProjectInfo:
 origin, commit = "", ""
 
 return ProjectInfo(name, build_mode, source, origin, commit,
-   enabled

[PATCH] D83942: [analyzer][tests] Add a notion of project sizes

2020-08-24 Thread Valeriy Savchenko via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGaec12c1264ac: [analyzer][tests] Add a notion of project 
sizes (authored by vsavchenko).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83942

Files:
  clang/utils/analyzer/ProjectMap.py
  clang/utils/analyzer/SATest.py
  clang/utils/analyzer/projects/projects.json

Index: clang/utils/analyzer/projects/projects.json
===
--- clang/utils/analyzer/projects/projects.json
+++ clang/utils/analyzer/projects/projects.json
@@ -4,139 +4,159 @@
 "mode": 1,
 "source": "git",
 "origin": "https://github.com/jarro2783/cxxopts.git";,
-"commit": "794c975"
+"commit": "794c975",
+"size": "tiny"
   },
   {
 "name": "box2d",
 "mode": 1,
 "source": "git",
 "origin": "https://github.com/erincatto/box2d.git";,
-"commit": "1025f9a"
+"commit": "1025f9a",
+"size": "small"
   },
   {
 "name": "tinyexpr",
 "mode": 1,
 "source": "git",
 "origin": "https://github.com/codeplea/tinyexpr.git";,
-"commit": "ffb0d41"
+"commit": "ffb0d41",
+"size": "tiny"
   },
   {
 "name": "symengine",
 "mode": 1,
 "source": "git",
 "origin": "https://github.com/symengine/symengine.git";,
-"commit": "4f669d59"
+"commit": "4f669d59",
+"size": "small"
   },
   {
 "name": "termbox",
 "mode": 1,
 "source": "git",
 "origin": "https://github.com/nsf/termbox.git";,
-"commit": "0df1355"
+"commit": "0df1355",
+"size": "tiny"
   },
   {
 "name": "tinyvm",
 "mode": 1,
 "source": "git",
 "origin": "https://github.com/jakogut/tinyvm.git";,
-"commit": "10c25d8"
+"commit": "10c25d8",
+"size": "tiny"
   },
   {
 "name": "tinyspline",
 "mode": 1,
 "source": "git",
 "origin": "https://github.com/msteinbeck/tinyspline.git";,
-"commit": "f8b1ab7"
+"commit": "f8b1ab7",
+"size": "tiny"
   },
   {
 "name": "oatpp",
 "mode": 1,
 "source": "git",
 "origin": "https://github.com/oatpp/oatpp.git";,
-"commit": "d3e60fb"
+"commit": "d3e60fb",
+"size": "small"
   },
   {
 "name": "libsoundio",
 "mode": 1,
 "source": "git",
 "origin": "https://github.com/andrewrk/libsoundio.git";,
-"commit": "b810bf2"
+"commit": "b810bf2",
+"size": "tiny"
   },
   {
 "name": "zstd",
 "mode": 1,
 "source": "git",
 "origin": "https://github.com/facebook/zstd.git";,
-"commit": "2af4e073"
+"commit": "2af4e073",
+"size": "small"
   },
   {
 "name": "simbody",
 "mode": 1,
 "source": "git",
 "origin": "https://github.com/simbody/simbody.git";,
-"commit": "5cf513d"
+"commit": "5cf513d",
+"size": "big"
   },
   {
 "name": "duckdb",
 "mode": 1,
 "source": "git",
 "origin": "https://github.com/cwida/duckdb.git";,
-"commit": "d098c9f"
+"commit": "d098c9f",
+"size": "big"
   },
   {
 "name": "drogon",
 "mode": 1,
 "source": "git",
 "origin": "https://github.com/an-tao/drogon.git";,
-"commit": "fd2a612"
+"commit": "fd2a612",
+"size": "small"
   },
   {
 "name": "fmt",
 "mode": 1,
 "source": "git",
 "origin": "https://github.com/fmtlib/fmt.git";,
-"commit": "5e7c70e"
+"commit": "5e7c70e",
+"size": "small"
   },
   {
 "name": "re2",
 "mode": 1,
 "source": "git",
 "origin": "https://github.com/google/re2.git";,
-"commit": "2b25567"
+"commit": "2b25567",
+"size": "small"
   },
   {
 "name": "cppcheck",
 "mode": 1,
 "source": "git",
 "origin": "https://github.com/danmar/cppcheck.git";,
-"commit": "5fa3d53"
+"commit": "5fa3d53",
+"size": "small"
   },
   {
 "name": "harfbuzz",
 "mode": 1,
 "source": "git",
 "origin": "https://github.com/harfbuzz/harfbuzz.git";,
-"commit": "f8d345e"
+"commit": "f8d345e",
+"size": "small"
   },
   {
 "name": "capnproto",
 "mode": 1,
 "source": "git",
 "origin": "https://github.com/capnproto/capnproto.git";,
-"commit": "8be1c9f"
+"commit": "8be1c9f",
+"size": "small"
   },
   {
 "name": "tmux",
 "mode": 1,
 "source": "git",
 "origin": "https://github.com/tmux/tmux.git";,
-"commit": "a5f99e1"
+"commit": "a5f99e1",
+"size": "big"
   },
   {
 "name": "faiss",
 "mode": 1,
 "source": "git",
 "origin": "https://github.com/facebookresearch/faiss.git";,
-"commit": "9e5d5b7"
+"commit": "9e5d5b7",
+"size": "small"
   }
 ]
Index: clang/utils/analyzer/SATest.py
===
--- clang/utils/analyzer/SATest.py
+++ clang/utils/analyzer/SATest.py
@@ -37,7 +37,7 @@
 
 SATestBuild.VERBOSE = args.verbose
 
-projec

[PATCH] D86445: [analyzer][RFC] Simplify MetadataSymbol representation and resolve a CStringChecker FIXME

2020-08-24 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h:198
 /// SymbolMetadata - Represents path-dependent metadata about a specific 
region.
 ///  Metadata symbols remain live as long as they are marked as in use before
 ///  dead-symbol sweeping AND their associated regions are still alive.

I think the comments should be updated as well: remove "in use" and refer to 
the aliveness of the memregion.



Comment at: clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp:2417
 
 void CStringChecker::checkDeadSymbols(SymbolReaper &SR,
 CheckerContext &C) const {

Seems like `checkDeadSymbols` could have a generic implementation. Perhaps in 
the following form:
```
class CStringChecker : public Checker<
 check::DeadSymbols
```
But this should be done in a separate patch.

Maybe it would make sense to have a generic default check::LiveSymbols implementation as well. In that implementation we could iterate over 
the GDM entries and could mark the dependent (sub)symbols live.

(Note, this is a reminder from our verbal discussion with @steakhal.)



Comment at: clang/test/Analysis/string.c:1544
+
 void memset7_char_array_nonnull() {
   char str[5] = "abcd";

It would make sense to split this into two. Only one of them should be in the 
`FIXMEs` section with the {{UNKNOWN}}. TRUE expectations could be moved out 
from the FIXMEs section.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86445

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


[PATCH] D86445: [analyzer][RFC] Simplify MetadataSymbol representation and resolve a CStringChecker FIXME

2020-08-24 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added inline comments.



Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h:441
+  const SymbolMetadata *getMetadataSymbol(const MemRegion *R, QualType T,
   const void *SymbolTag = nullptr);
 

Why do we even need the tag?
Why is it defaulted to `nullptr` if it asserts later that the `tag` must not be 
`null`.
I'm confused, somebody help me out :D



Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h:516-522
   /// Unconditionally marks a symbol as live.
   ///
   /// This should never be
   /// used by checkers, only by the state infrastructure such as the store and
   /// environment. Checkers should instead use metadata symbols and markInUse.
+  /// TODO: update this comment!!!
   void markLive(SymbolRef sym);

Is it true for modeling checkers too?



Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h:524-532
   /// Marks a symbol as important to a checker.
   ///
   /// For metadata symbols,
   /// this will keep the symbol alive as long as its associated region is also
   /// live. For other symbols, this has no effect; checkers are not permitted
   /// to influence the life of other symbols. This should be used before any
   /// symbol marking has occurred, i.e. in the MarkLiveSymbols callback.

I think it should be removed, but for now I left it to draw attention in the 
review process.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86445

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


[PATCH] D86445: [analyzer][RFC] Simplify MetadataSymbol representation and resolve a CStringChecker FIXME

2020-08-24 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added inline comments.



Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h:198
 /// SymbolMetadata - Represents path-dependent metadata about a specific 
region.
 ///  Metadata symbols remain live as long as they are marked as in use before
 ///  dead-symbol sweeping AND their associated regions are still alive.

martong wrote:
> I think the comments should be updated as well: remove "in use" and refer to 
> the aliveness of the memregion.
Definitely, thanks.



Comment at: clang/test/Analysis/string.c:1544
+
 void memset7_char_array_nonnull() {
   char str[5] = "abcd";

martong wrote:
> It would make sense to split this into two. Only one of them should be in the 
> `FIXMEs` section with the {{UNKNOWN}}. TRUE expectations could be moved out 
> from the FIXMEs section.
This patch does not interfere with the test case below.

However, it would be nice to say that calling `strlen` on non-null-terminated 
strings is UB.
Thus expecting the `clang_analyzer_eval(strlen(str) >= 5);` to be `TRUE` does 
not make sense much IMO.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86445

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


[PATCH] D84316: [analyzer][NFC] Split CStringChecker to modeling and reporting

2020-08-24 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

In D84316#2233368 , @Szelethus wrote:

> Do I sense correctly that the only information `CSrtingLengthModeling.cpp` 
> requires from the actual `CStringChecker` is a checker tag?

AFAIK yes.

> [...] it seems like we're legalizing bloating checkers instead of separating 
> them.

I agree. I would genuinely have a modeling checker, and a completely different 
checker using the modeled information, let's call it CStringcChecker.
Unfortunately, that approach was not really well received - probably needs 
further discussion.

> Also, this patch seems to have a significant overlap with D84979 
>  -- is this intentional?

It is. In fact, this patch prepares the code for it.
I wanted to separate large code motion changes (like this one) from API 
refactoring changes (like D84979  does).
So in some sense, these two patches are hand in hand. Have a look at them ;)


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

https://reviews.llvm.org/D84316

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


[PATCH] D86459: [SyntaxTree] Split `ParametersAndQualifiers` tests

2020-08-24 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
eduucaldas requested review of this revision.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86459

Files:
  clang/unittests/Tooling/Syntax/BuildTreeTest.cpp

Index: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -3438,19 +3438,30 @@
 )txt"));
 }
 
-TEST_P(SyntaxTreeTest, ParametersAndQualifiersInFreeFunctions) {
-  if (!GetParam().isCXX()) {
-return;
-  }
+TEST_P(SyntaxTreeTest, ParametersAndQualifiers_InFreeFunctions_Empty) {
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+int func();
+)cpp",
+  R"txt(
+*: TranslationUnit
+`-SimpleDeclaration
+  |-int
+  |-SimpleDeclarator
+  | |-func
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   `-)
+  `-;
+)txt"));
+}
+
+TEST_P(SyntaxTreeTest, ParametersAndQualifiers_InFreeFunctions_Named) {
   EXPECT_TRUE(treeDumpEqual(
   R"cpp(
-int func1();
-int func2a(int a);
-int func2b(int);
-int func3a(int *ap);
-int func3b(int *);
-int func4a(int a, float b);
-int func4b(int, float);
+int func1(int a);
+int func2(int *ap);
+int func3(int a, float b);
 )cpp",
   R"txt(
 *: TranslationUnit
@@ -3460,14 +3471,6 @@
 | | |-func1
 | | `-ParametersAndQualifiers
 | |   |-(
-| |   `-)
-| `-;
-|-SimpleDeclaration
-| |-int
-| |-SimpleDeclarator
-| | |-func2a
-| | `-ParametersAndQualifiers
-| |   |-(
 | |   |-SimpleDeclaration
 | |   | |-int
 | |   | `-SimpleDeclarator
@@ -3477,17 +3480,7 @@
 |-SimpleDeclaration
 | |-int
 | |-SimpleDeclarator
-| | |-func2b
-| | `-ParametersAndQualifiers
-| |   |-(
-| |   |-SimpleDeclaration
-| |   | `-int
-| |   `-)
-| `-;
-|-SimpleDeclaration
-| |-int
-| |-SimpleDeclarator
-| | |-func3a
+| | |-func2
 | | `-ParametersAndQualifiers
 | |   |-(
 | |   |-SimpleDeclaration
@@ -3497,39 +3490,61 @@
 | |   |   `-ap
 | |   `-)
 | `-;
+`-SimpleDeclaration
+  |-int
+  |-SimpleDeclarator
+  | |-func3
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   |-SimpleDeclaration
+  |   | |-int
+  |   | `-SimpleDeclarator
+  |   |   `-a
+  |   |-,
+  |   |-SimpleDeclaration
+  |   | |-float
+  |   | `-SimpleDeclarator
+  |   |   `-b
+  |   `-)
+  `-;
+)txt"));
+}
+
+TEST_P(SyntaxTreeTest, ParametersAndQualifiers_InFreeFunctions_Unnamed) {
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+int func1(int);
+int func2(int *);
+int func3(int, float);
+)cpp",
+  R"txt(
+*: TranslationUnit
 |-SimpleDeclaration
 | |-int
 | |-SimpleDeclarator
-| | |-func3b
+| | |-func1
 | | `-ParametersAndQualifiers
 | |   |-(
 | |   |-SimpleDeclaration
-| |   | |-int
-| |   | `-SimpleDeclarator
-| |   |   `-*
+| |   | `-int
 | |   `-)
 | `-;
 |-SimpleDeclaration
 | |-int
 | |-SimpleDeclarator
-| | |-func4a
+| | |-func2
 | | `-ParametersAndQualifiers
 | |   |-(
 | |   |-SimpleDeclaration
 | |   | |-int
 | |   | `-SimpleDeclarator
-| |   |   `-a
-| |   |-,
-| |   |-SimpleDeclaration
-| |   | |-float
-| |   | `-SimpleDeclarator
-| |   |   `-b
+| |   |   `-*
 | |   `-)
 | `-;
 `-SimpleDeclaration
   |-int
   |-SimpleDeclarator
-  | |-func4b
+  | |-func3
   | `-ParametersAndQualifiers
   |   |-(
   |   |-SimpleDeclaration
@@ -3542,47 +3557,60 @@
 )txt"));
 }
 
-TEST_P(SyntaxTreeTest, ParametersAndQualifiersInFreeFunctionsCxx) {
+TEST_P(SyntaxTreeTest,
+   ParametersAndQualifiers_InFreeFunctions_Cxx_CvQualifiers) {
   if (!GetParam().isCXX()) {
 return;
   }
   EXPECT_TRUE(treeDumpEqual(
   R"cpp(
-int func1(const int a, volatile int b, const volatile int c);
-int func2(int& a);
+int func(const int a, volatile int b, const volatile int c);
 )cpp",
   R"txt(
 *: TranslationUnit
-|-SimpleDeclaration
-| |-int
-| |-SimpleDeclarator
-| | |-func1
-| | `-ParametersAndQualifiers
-| |   |-(
-| |   |-SimpleDeclaration
-| |   | |-const
-| |   | |-int
-| |   | `-SimpleDeclarator
-| |   |   `-a
-| |   |-,
-| |   |-SimpleDeclaration
-| |   | |-volatile
-| |   | |-int
-| |   | `-SimpleDeclarator
-| |   |   `-b
-| |   |-,
-| |   |-SimpleDeclaration
-| |   | |-const
-| |   | |-volatile
-| |   | |-int
-| |   | `-SimpleDeclarator
-| |   |   `-c
-| |   `-)
-| `-;
 `-SimpleDeclaration
   |-int
   |-SimpleDeclarator
-  | |-func2
+  | |-func
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   |-SimpleDeclaration
+  |   | |-const
+  |   | |-int
+  |   | `-SimpleDeclarator
+  |   |   `-a
+  |   |-,
+  |   |-SimpleDeclaration
+  |   | |-volatile
+  |   | |-int
+  |   | `-SimpleDeclarator
+  |   |   `-b
+  |   |-,
+  |   |-SimpleDeclaration
+  |   | |-const
+  |   | |-volatile
+  |   | |-int
+  |   | `-SimpleDeclarator
+  |   |   `-c
+  |   `-)
+  `-;
+)txt"));
+}
+
+TEST_P(SyntaxTreeTest, ParametersAndQualifiers_InFreeFunctions_Cxx_Ref) {
+  if (!GetParam().isCXX()) {
+return;
+  }
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+int func(int& a);
+)cpp",
+  R"txt(
+*: TranslationUnit
+`-SimpleDeclaration
+

[PATCH] D86135: [analyzer][MacroExpansion] Fix a crash where multiple parameters resolved to __VA_ARGS__

2020-08-24 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

I can feel your pain.

> The fundamental problem is, we simply can't ask Preprocessor what a macro 
> expands into without hacking really hard.

Can you summarize what is the exact problem (or give a link to a discussion, 
etc)? Is it an architectural problem in Clang itself? Could we somehow refactor 
Clang and the Preprocessor to be usable for us? I mean LLVM and Clang has the 
mindset to build reusable components, the Preprocessor (and the Sema) should be 
one of them too, not just the AST.




Comment at: clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp:910
+
+  void injextRange(const ArgTokensTy &Range) {
+TokenRange = Range;

typo? `injectRange` ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86135

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


[PATCH] D86424: [clang] Do not consider the template arguments of bases to be bases themselves

2020-08-24 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang/lib/Index/IndexTypeSourceInfo.cpp:167
+if (!TraverseTemplateName(TL.getTypePtr()->getTemplateName()))
+  return false;
+

nit: this could be simplified by calling the 
`base::TraverseTemplateSpecializationTypeLoc`



Comment at: clang/unittests/Index/IndexTests.cpp:337
 
+TEST(IndexTest, RelationBaseOf) {
+  std::string Code = R"cpp(

nit: I think we need a test in clang, `clang/test/Index/Core/index-source.cpp`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86424

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


[PATCH] D86441: [SyntaxTree] Split ExplicitTemplateInstantiation test

2020-08-24 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas updated this revision to Diff 287378.
eduucaldas marked 4 inline comments as done.
eduucaldas added a comment.

Template -> ClassTemplate


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86441

Files:
  clang/unittests/Tooling/Syntax/BuildTreeTest.cpp

Index: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -3051,84 +3051,105 @@
 )txt"));
 }
 
-TEST_P(SyntaxTreeTest, ExplicitTemplateInstantations) {
+TEST_P(SyntaxTreeTest, ExplicitClassTemplateInstantation_Definition) {
   if (!GetParam().isCXX()) {
 return;
   }
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
 template  struct X {};
-template  struct X {};
-template <> struct X {};
+[[template struct X;]]
+)cpp",
+  {R"txt(
+ExplicitTemplateInstantiation
+|-template
+`-SimpleDeclaration
+  |-struct
+  |-X
+  |-<
+  |-double
+  |->
+  `-;
+)txt"}));
+}
 
-template struct X;
-extern template struct X;
+TEST_P(SyntaxTreeTest, ExplicitClassTemplateInstantation_Declaration) {
+  if (!GetParam().isCXX()) {
+return;
+  }
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
+  R"cpp(
+template  struct X {};
+[[extern template struct X;]]
 )cpp",
-  R"txt(
-*: TranslationUnit
-|-TemplateDeclaration
-| |-template
-| |-<
-| |-UnknownDeclaration
-| | |-class
-| | `-T
-| |->
-| `-SimpleDeclaration
-|   |-struct
-|   |-X
-|   |-{
-|   |-}
-|   `-;
-|-TemplateDeclaration
-| |-template
-| |-<
-| |-UnknownDeclaration
-| | |-class
-| | `-T
-| |->
-| `-SimpleDeclaration
-|   |-struct
-|   |-X
-|   |-<
-|   |-T
-|   |-*
-|   |->
-|   |-{
-|   |-}
-|   `-;
-|-TemplateDeclaration
-| |-template
-| |-<
-| |->
-| `-SimpleDeclaration
-|   |-struct
-|   |-X
-|   |-<
-|   |-int
-|   |->
-|   |-{
-|   |-}
-|   `-;
-|-ExplicitTemplateInstantiation
-| |-template
-| `-SimpleDeclaration
-|   |-struct
-|   |-X
-|   |-<
-|   |-double
-|   |->
-|   `-;
-`-ExplicitTemplateInstantiation
-  |-extern
-  |-template
-  `-SimpleDeclaration
-|-struct
-|-X
-|-<
-|-float
-|->
-`-;
-)txt"));
+  {R"txt(
+ExplicitTemplateInstantiation
+|-extern
+|-template
+`-SimpleDeclaration
+  |-struct
+  |-X
+  |-<
+  |-float
+  |->
+  `-;
+)txt"}));
+}
+
+TEST_P(SyntaxTreeTest, ClassTemplateSpecialization_Partial) {
+  if (!GetParam().isCXX()) {
+return;
+  }
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
+  R"cpp(
+template  struct X {};
+[[template  struct X {};]]
+)cpp",
+  {R"txt(
+TemplateDeclaration
+|-template
+|-<
+|-UnknownDeclaration
+| |-class
+| `-T
+|->
+`-SimpleDeclaration
+  |-struct
+  |-X
+  |-<
+  |-T
+  |-*
+  |->
+  |-{
+  |-}
+  `-;
+)txt"}));
+}
+
+TEST_P(SyntaxTreeTest, ClassTemplateSpecialization_Full) {
+  if (!GetParam().isCXX()) {
+return;
+  }
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
+  R"cpp(
+template  struct X {};
+[[template <> struct X {};]]
+)cpp",
+  {R"txt(
+TemplateDeclaration
+|-template
+|-<
+|->
+`-SimpleDeclaration
+  |-struct
+  |-X
+  |-<
+  |-int
+  |->
+  |-{
+  |-}
+  `-;
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, UsingType) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D86239: [OPENMP]Fix PR47158, case 3: allow devic_typein nested declare target region.

2020-08-24 Thread Alexey Bataev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbedc841a5098: [OPENMP]Fix PR47158, case 3: allow 
devic_typein nested declare target region. (authored by ABataev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86239

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/AttrImpl.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/test/AST/dump.cpp
  clang/test/OpenMP/declare_target_ast_print.cpp

Index: clang/test/OpenMP/declare_target_ast_print.cpp
===
--- clang/test/OpenMP/declare_target_ast_print.cpp
+++ clang/test/OpenMP/declare_target_ast_print.cpp
@@ -241,6 +241,28 @@
 // CHECK: void cba();
 // CHECK: #pragma omp end declare target
 
+#pragma omp declare target
+int abc1() { return 1; }
+#pragma omp declare target to(abc1) device_type(nohost)
+#pragma omp end declare target
+
+// CHECK-NEXT: #pragma omp declare target
+// CHECK-NEXT: #pragma omp declare target device_type(nohost)
+// CHECK-NEXT: int abc1() {
+// CHECK-NEXT: return 1;
+// CHECK-NEXT: }
+// CHECK-NEXT: #pragma omp end declare target
+
+#pragma omp declare target
+int inner_link;
+#pragma omp declare target link(inner_link)
+#pragma omp end declare target
+
+// CHECK-NEXT: #pragma omp declare target
+// CHECK-NEXT: #pragma omp declare target link
+// CHECK-NEXT: int inner_link;
+// CHECK-NEXT: #pragma omp end declare target
+
 int main (int argc, char **argv) {
   foo();
   foo_c();
@@ -254,4 +276,5 @@
 // CHECK: #pragma omp declare target
 // CHECK-NEXT: int ts = 1;
 // CHECK-NEXT: #pragma omp end declare target
+
 #endif
Index: clang/test/AST/dump.cpp
===
--- clang/test/AST/dump.cpp
+++ clang/test/AST/dump.cpp
@@ -86,4 +86,4 @@
 // CHECK-NEXT:  | `-ReturnStmt {{.+}} 
 // CHECK-NEXT:  |   `-ImplicitCastExpr {{.+}}  'int' 
 // CHECK-NEXT:  | `-DeclRefExpr {{.+}}  'int' lvalue Var {{.+}} 'f' 'int'
-// CHECK-NEXT:  `-OMPDeclareTargetDeclAttr {{.+}} <> Implicit MT_To
+// CHECK-NEXT:  `-OMPDeclareTargetDeclAttr {{.+}}  Implicit MT_To DT_Any 1
Index: clang/lib/Serialization/ASTReaderDecl.cpp
===
--- clang/lib/Serialization/ASTReaderDecl.cpp
+++ clang/lib/Serialization/ASTReaderDecl.cpp
@@ -4666,12 +4666,11 @@
 }
 
 case UPD_DECL_MARKED_OPENMP_DECLARETARGET: {
-  OMPDeclareTargetDeclAttr::MapTypeTy MapType =
-  static_cast(Record.readInt());
-  OMPDeclareTargetDeclAttr::DevTypeTy DevType =
-  static_cast(Record.readInt());
+  auto MapType = Record.readEnum();
+  auto DevType = Record.readEnum();
+  unsigned Level = Record.readInt();
   D->addAttr(OMPDeclareTargetDeclAttr::CreateImplicit(
-  Reader.getContext(), MapType, DevType, readSourceRange(),
+  Reader.getContext(), MapType, DevType, Level, readSourceRange(),
   AttributeCommonInfo::AS_Pragma));
   break;
 }
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -2473,7 +2473,7 @@
 StringRef HostDevTy =
 getOpenMPSimpleClauseTypeName(OMPC_device_type, OMPC_DEVICE_TYPE_host);
 Diag(Loc, diag::err_omp_wrong_device_function_call) << HostDevTy << 0;
-Diag(FD->getAttr()->getLocation(),
+Diag(*OMPDeclareTargetDeclAttr::getLocation(FD),
  diag::note_omp_marked_device_type_here)
 << HostDevTy;
 return;
@@ -2484,7 +2484,7 @@
 StringRef NoHostDevTy = getOpenMPSimpleClauseTypeName(
 OMPC_device_type, OMPC_DEVICE_TYPE_nohost);
 Diag(Loc, diag::err_omp_wrong_device_function_call) << NoHostDevTy << 1;
-Diag(FD->getAttr()->getLocation(),
+Diag(*OMPDeclareTargetDeclAttr::getLocation(FD),
  diag::note_omp_marked_device_type_here)
 << NoHostDevTy;
   }
@@ -18483,14 +18483,14 @@
 Diag(Loc, diag::err_omp_region_not_file_context);
 return false;
   }
-  ++DeclareTargetNestingLevel;
+  DeclareTargetNesting.push_back(Loc);
   return true;
 }
 
 void Sema::ActOnFinishOpenMPDeclareTargetDirective() {
-  assert(DeclareTargetNestingLevel > 0 &&
+  assert(!DeclareTargetNesting.empty() &&
  "Unexpected ActOnFinishOpenMPDeclareTargetDirective");
-  --DeclareTargetNestingLevel;
+  DeclareTargetNesting.pop_back();
 }
 
 NamedDecl *
@@ -18543,19 +18543,25 @@
   (ND->isUsed(/*CheckUsedAttr=*/false) || ND->isReferenced()))
 Diag(Loc, diag::warn_omp_declare_target_after_first_use);
 
+  auto *VD = cast(ND);
   Optional DevTy =
-  OMPDeclareTargetDeclAttr::getDeviceType(cast(ND));
-  if (DevTy.hasValue() && *DevTy != DT) {
+  OMPDeclareTargetDeclAttr::getDeviceType(VD);
+  Optional AttrL

[clang] bedc841 - [OPENMP]Fix PR47158, case 3: allow devic_typein nested declare target region.

2020-08-24 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2020-08-24T09:58:37-04:00
New Revision: bedc841a5098bc0a90bbc66328d7aab4b2c23c4a

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

LOG: [OPENMP]Fix PR47158, case 3: allow devic_typein nested declare target 
region.

OpenMP 5.0 supports nested declare target regions. So, in general,it is
allow to mark a declarationas declare target with different device_type
or link type. Patch adds support for such kind of nesting.

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

Added: 


Modified: 
clang/include/clang/Basic/Attr.td
clang/include/clang/Sema/Sema.h
clang/lib/AST/AttrImpl.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Serialization/ASTReaderDecl.cpp
clang/test/AST/dump.cpp
clang/test/OpenMP/declare_target_ast_print.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 45244c67efe0..9929948adb20 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -3330,13 +3330,15 @@ def OMPDeclareTargetDecl : InheritableAttr {
  [ "MT_To", "MT_Link" ]>,
 EnumArgument<"DevType", "DevTypeTy",
  [ "host", "nohost", "any" ],
- [ "DT_Host", "DT_NoHost", "DT_Any" ]>
+ [ "DT_Host", "DT_NoHost", "DT_Any" ]>,
+UnsignedArgument<"Level">
   ];
   let AdditionalMembers = [{
 void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) 
const;
 static llvm::Optional
 isDeclareTargetDeclaration(const ValueDecl *VD);
 static llvm::Optional getDeviceType(const ValueDecl *VD);
+static llvm::Optional getLocation(const ValueDecl *VD);
   }];
 }
 

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 84e66b85208e..27f424a4cb25 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -9974,7 +9974,7 @@ class Sema final {
 private:
   void *VarDataSharingAttributesStack;
   /// Number of nested '#pragma omp declare target' directives.
-  unsigned DeclareTargetNestingLevel = 0;
+  SmallVector DeclareTargetNesting;
   /// Initialization of data-sharing attributes stack.
   void InitDataSharingAttributesStack();
   void DestroyDataSharingAttributesStack();
@@ -10234,7 +10234,7 @@ class Sema final {
  SourceLocation Loc);
   /// Return true inside OpenMP declare target region.
   bool isInOpenMPDeclareTargetContext() const {
-return DeclareTargetNestingLevel > 0;
+return !DeclareTargetNesting.empty();
   }
   /// Return true inside OpenMP target region.
   bool isInOpenMPTargetExecutionDirective() const;

diff  --git a/clang/lib/AST/AttrImpl.cpp b/clang/lib/AST/AttrImpl.cpp
index 7818fbb1918b..7ca58f2b83a2 100644
--- a/clang/lib/AST/AttrImpl.cpp
+++ b/clang/lib/AST/AttrImpl.cpp
@@ -136,8 +136,16 @@ llvm::Optional
 OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(const ValueDecl *VD) {
   if (!VD->hasAttrs())
 return llvm::None;
-  if (const auto *Attr = VD->getAttr())
-return Attr->getMapType();
+  unsigned Level = 0;
+  const OMPDeclareTargetDeclAttr *FoundAttr = nullptr;
+  for (const auto *Attr : VD->specific_attrs()) {
+if (Level < Attr->getLevel()) {
+  Level = Attr->getLevel();
+  FoundAttr = Attr;
+}
+  }
+  if (FoundAttr)
+return FoundAttr->getMapType();
 
   return llvm::None;
 }
@@ -146,8 +154,34 @@ llvm::Optional
 OMPDeclareTargetDeclAttr::getDeviceType(const ValueDecl *VD) {
   if (!VD->hasAttrs())
 return llvm::None;
-  if (const auto *Attr = VD->getAttr())
-return Attr->getDevType();
+  unsigned Level = 0;
+  const OMPDeclareTargetDeclAttr *FoundAttr = nullptr;
+  for (const auto *Attr : VD->specific_attrs()) {
+if (Level < Attr->getLevel()) {
+  Level = Attr->getLevel();
+  FoundAttr = Attr;
+}
+  }
+  if (FoundAttr)
+return FoundAttr->getDevType();
+
+  return llvm::None;
+}
+
+llvm::Optional
+OMPDeclareTargetDeclAttr::getLocation(const ValueDecl *VD) {
+  if (!VD->hasAttrs())
+return llvm::None;
+  unsigned Level = 0;
+  const OMPDeclareTargetDeclAttr *FoundAttr = nullptr;
+  for (const auto *Attr : VD->specific_attrs()) {
+if (Level < Attr->getLevel()) {
+  Level = Attr->getLevel();
+  FoundAttr = Attr;
+}
+  }
+  if (FoundAttr)
+return FoundAttr->getRange().getBegin();
 
   return llvm::None;
 }

diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 53917ef98acd..cd20b6bfdb98 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -2473,7 +2473,7 @@ void Sema::finalizeOpenMPDelayedAnalysis(const 
FunctionDecl *Caller,
 StringRef HostDevTy =
 getOpenMPSimpleClauseTypeName(OMPC_device_type, OMPC_DEVICE_TYP

[PATCH] D86295: [analyzer] Reorder the layout of MemRegion and cache by hand for optimal size

2020-08-24 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

In D86295#2233401 , @vsavchenko wrote:

> Yep, I guess that is the cause.  I'll take a look.  Did you try it with this 
> fast fix?

I tried, but it lacks further fixes.

Currently, I have this:

  diff --git a/clang/utils/analyzer/Dockerfile b/clang/utils/analyzer/Dockerfile
  index f74ff8aa95c..7727d92f98f 100644
  --- a/clang/utils/analyzer/Dockerfile
  +++ b/clang/utils/analyzer/Dockerfile
  @@ -1,4 +1,4 @@
  -FROM ubuntu:bionic
  +FROM ubuntu:bionic-20200526
   
   RUN apt-get update && apt-get install -y \
   apt-transport-https \
  @@ -12,12 +12,13 @@ RUN wget -O - 
https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/nul
   RUN apt-add-repository -y 'deb https://apt.kitware.com/ubuntu/ bionic main'
   
   # test system dependencies
  +# TODO: should we really depend on the cmake version 3.18.2 here? I don't 
think so.
   RUN apt-get update && apt-get install -y \
   git=1:2.17.1-1ubuntu0.7 \
   gettext=0.19.8.1-6ubuntu0.3 \
   python3=3.6.7-1~18.04 \
  -python3-pip=9.0.1-2.3~ubuntu1.18.04.1 \
  -cmake=3.17.3-0kitware1 \
  +python3-pip=9.0.1-2.3~ubuntu1.18.04.2 \
  +cmake=3.18.2-0kitware1 \
   ninja-build=1.8.2-1
   
   # box2d dependencies
   

I'm not sure if its the company firewall or something else.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86295

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


[PATCH] D86440: [SyntaxTree] Split FreeStandingClass tests

2020-08-24 Thread Eduardo Caldas via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb4093d663f83: [SyntaxTree] Split FreeStandingClass tests 
(authored by eduucaldas).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86440

Files:
  clang/unittests/Tooling/Syntax/BuildTreeTest.cpp

Index: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -2515,55 +2515,65 @@
 )txt"}));
 }
 
-TEST_P(SyntaxTreeTest, FreeStandingClasses) {
-  // Free-standing classes, must live inside a SimpleDeclaration.
-  EXPECT_TRUE(treeDumpEqual(
+TEST_P(SyntaxTreeTest, FreeStandingClass_ForwardDeclaration) {
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
-struct X;
-struct X {};
-
-struct Y *y1;
-struct Y {} *y2;
+[[struct X;]]
+[[struct Y *y1;]]
+)cpp",
+  {R"txt(
+SimpleDeclaration
+|-struct
+|-X
+`-;
+)txt",
+   R"txt(
+SimpleDeclaration
+|-struct
+|-Y
+|-SimpleDeclarator
+| |-*
+| `-y1
+`-;
+)txt"}));
+}
 
-struct {} *a1;
+TEST_P(SyntaxTreeTest, FreeStandingClasses_Definition) {
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
+  R"cpp(
+[[struct X {};]]
+[[struct Y {} *y2;]]
+[[struct {} *a1;]]
 )cpp",
-  R"txt(
-*: TranslationUnit
-|-SimpleDeclaration
-| |-struct
-| |-X
-| `-;
-|-SimpleDeclaration
-| |-struct
-| |-X
-| |-{
-| |-}
-| `-;
-|-SimpleDeclaration
-| |-struct
-| |-Y
-| |-SimpleDeclarator
-| | |-*
-| | `-y1
-| `-;
-|-SimpleDeclaration
-| |-struct
-| |-Y
-| |-{
-| |-}
-| |-SimpleDeclarator
-| | |-*
-| | `-y2
-| `-;
-`-SimpleDeclaration
-  |-struct
-  |-{
-  |-}
-  |-SimpleDeclarator
-  | |-*
-  | `-a1
-  `-;
-)txt"));
+  {R"txt(
+SimpleDeclaration
+|-struct
+|-X
+|-{
+|-}
+`-;
+)txt",
+   R"txt(
+SimpleDeclaration
+|-struct
+|-Y
+|-{
+|-}
+|-SimpleDeclarator
+| |-*
+| `-y2
+`-;
+)txt",
+   R"txt(
+SimpleDeclaration
+|-struct
+|-{
+|-}
+|-SimpleDeclarator
+| |-*
+| `-a1
+`-;
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, StaticMemberFunction) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D86439: [SyntaxTree] Use annotations to reduce noise on member function tests

2020-08-24 Thread Eduardo Caldas via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGed83095254a3: [SyntaxTree] Use annotations to reduce noise 
on member function tests (authored by eduucaldas).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86439

Files:
  clang/unittests/Tooling/Syntax/BuildTreeTest.cpp

Index: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -2570,61 +2570,47 @@
   if (!GetParam().isCXX11OrLater()) {
 return;
   }
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
 struct S {
-  static void f(){}
+  [[static void f(){}]]
 };
 )cpp",
-  R"txt(
-*: TranslationUnit
-`-SimpleDeclaration
-  |-struct
-  |-S
+  {R"txt(
+SimpleDeclaration
+|-static
+|-void
+|-SimpleDeclarator
+| |-f
+| `-ParametersAndQualifiers
+|   |-(
+|   `-)
+`-CompoundStatement
   |-{
-  |-SimpleDeclaration
-  | |-static
-  | |-void
-  | |-SimpleDeclarator
-  | | |-f
-  | | `-ParametersAndQualifiers
-  | |   |-(
-  | |   `-)
-  | `-CompoundStatement
-  |   |-{
-  |   `-}
-  |-}
-  `-;
-)txt"));
+  `-}
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, ConversionMemberFunction) {
   if (!GetParam().isCXX()) {
 return;
   }
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
 struct X {
-  operator int();
+  [[operator int();]]
 };
 )cpp",
-  R"txt(
-*: TranslationUnit
-`-SimpleDeclaration
-  |-struct
-  |-X
-  |-{
-  |-SimpleDeclaration
-  | |-SimpleDeclarator
-  | | |-operator
-  | | |-int
-  | | `-ParametersAndQualifiers
-  | |   |-(
-  | |   `-)
-  | `-;
-  |-}
-  `-;
-)txt"));
+  {R"txt(
+SimpleDeclaration
+|-SimpleDeclarator
+| |-operator
+| |-int
+| `-ParametersAndQualifiers
+|   |-(
+|   `-)
+`-;
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, LiteralOperatorDeclaration) {
@@ -2687,76 +2673,62 @@
   if (!GetParam().isCXX()) {
 return;
   }
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
 struct X {
-  X& operator=(const X&);
+  [[X& operator=(const X&);]]
 };
 )cpp",
-  R"txt(
-*: TranslationUnit
-`-SimpleDeclaration
-  |-struct
-  |-X
-  |-{
-  |-SimpleDeclaration
-  | |-X
-  | |-SimpleDeclarator
-  | | |-&
-  | | |-operator
-  | | |-=
-  | | `-ParametersAndQualifiers
-  | |   |-(
-  | |   |-SimpleDeclaration
-  | |   | |-const
-  | |   | |-X
-  | |   | `-SimpleDeclarator
-  | |   |   `-&
-  | |   `-)
-  | `-;
-  |-}
-  `-;
-)txt"));
+  {R"txt(
+SimpleDeclaration
+|-X
+|-SimpleDeclarator
+| |-&
+| |-operator
+| |-=
+| `-ParametersAndQualifiers
+|   |-(
+|   |-SimpleDeclaration
+|   | |-const
+|   | |-X
+|   | `-SimpleDeclarator
+|   |   `-&
+|   `-)
+`-;
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, OverloadedOperatorFriendDeclarataion) {
   if (!GetParam().isCXX()) {
 return;
   }
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
 struct X {
-  friend X operator+(X, const X&);
+  [[friend X operator+(X, const X&);]]
 };
 )cpp",
-  R"txt(
-*: TranslationUnit
+  {R"txt(
+UnknownDeclaration
 `-SimpleDeclaration
-  |-struct
+  |-friend
   |-X
-  |-{
-  |-UnknownDeclaration
-  | `-SimpleDeclaration
-  |   |-friend
-  |   |-X
-  |   |-SimpleDeclarator
-  |   | |-operator
-  |   | |-+
-  |   | `-ParametersAndQualifiers
-  |   |   |-(
-  |   |   |-SimpleDeclaration
-  |   |   | `-X
-  |   |   |-,
-  |   |   |-SimpleDeclaration
-  |   |   | |-const
-  |   |   | |-X
-  |   |   | `-SimpleDeclarator
-  |   |   |   `-&
-  |   |   `-)
-  |   `-;
-  |-}
+  |-SimpleDeclarator
+  | |-operator
+  | |-+
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   |-SimpleDeclaration
+  |   | `-X
+  |   |-,
+  |   |-SimpleDeclaration
+  |   | |-const
+  |   | |-X
+  |   | `-SimpleDeclarator
+  |   |   `-&
+  |   `-)
   `-;
-)txt"));
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, ClassTemplateDeclaration) {
@@ -2847,38 +2819,31 @@
   if (!GetParam().isCXX()) {
 return;
   }
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
 struct S {
-  template
-  static U f();
+  [[template
+  static U f();]]
 };
 )cpp",
-  R"txt(
-*: TranslationUnit
+  {R"txt(
+TemplateDeclaration
+|-template
+|-<
+|-UnknownDeclaration
+| |-typename
+| `-U
+|->
 `-SimpleDeclaration
-  |-struct
-  |-S
-  |-{
-  |-TemplateDeclaration
-  | |-template
-  | |-<
-  | |-UnknownDeclaration
-  | | |-typename
-  | | `-U
-  | |->
-  | `-SimpleDeclaration
-  |   |-static
-  |   |-U
-  |   |-SimpleDeclarator
-  |   | |-f
-  |   | `-ParametersAndQualifiers
-  |   |   |-(
-  |   |   `-)
-  |   `-;
-  |-}
+  |-static
+  |-U
+  |-SimpleDeclarator
+  | |-f
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   `-)
   `-;
-)txt"));
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, N

[PATCH] D86437: [SyntaxTree] Split array declarator tests

2020-08-24 Thread Eduardo Caldas via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4e8dd506e666: [SyntaxTree] Split array declarator tests 
(authored by eduucaldas).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86437

Files:
  clang/unittests/Tooling/Syntax/BuildTreeTest.cpp

Index: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -3342,45 +3342,63 @@
 )txt"));
 }
 
-TEST_P(SyntaxTreeTest, ArraySubscriptsInDeclarators) {
+TEST_P(SyntaxTreeTest, ArrayDeclarator_Simple) {
   EXPECT_TRUE(treeDumpEqual(
   R"cpp(
 int a[10];
+)cpp",
+  R"txt(
+*: TranslationUnit
+`-SimpleDeclaration
+  |-int
+  |-SimpleDeclarator
+  | |-a
+  | `-ArraySubscript
+  |   |-[
+  |   |-IntegerLiteralExpression
+  |   | `-10
+  |   `-]
+  `-;
+)txt"));
+}
+
+TEST_P(SyntaxTreeTest, ArrayDeclarator_Multidimensional) {
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
 int b[1][2][3];
+)cpp",
+  R"txt(
+*: TranslationUnit
+`-SimpleDeclaration
+  |-int
+  |-SimpleDeclarator
+  | |-b
+  | |-ArraySubscript
+  | | |-[
+  | | |-IntegerLiteralExpression
+  | | | `-1
+  | | `-]
+  | |-ArraySubscript
+  | | |-[
+  | | |-IntegerLiteralExpression
+  | | | `-2
+  | | `-]
+  | `-ArraySubscript
+  |   |-[
+  |   |-IntegerLiteralExpression
+  |   | `-3
+  |   `-]
+  `-;
+)txt"));
+}
+
+TEST_P(SyntaxTreeTest, ArrayDeclarator_UnknownBound) {
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
 int c[] = {1,2,3};
 )cpp",
   R"txt(
 *: TranslationUnit
-|-SimpleDeclaration
-| |-int
-| |-SimpleDeclarator
-| | |-a
-| | `-ArraySubscript
-| |   |-[
-| |   |-IntegerLiteralExpression
-| |   | `-10
-| |   `-]
-| `-;
-|-SimpleDeclaration
-| |-int
-| |-SimpleDeclarator
-| | |-b
-| | |-ArraySubscript
-| | | |-[
-| | | |-IntegerLiteralExpression
-| | | | `-1
-| | | `-]
-| | |-ArraySubscript
-| | | |-[
-| | | |-IntegerLiteralExpression
-| | | | `-2
-| | | `-]
-| | `-ArraySubscript
-| |   |-[
-| |   |-IntegerLiteralExpression
-| |   | `-3
-| |   `-]
-| `-;
 `-SimpleDeclaration
   |-int
   |-SimpleDeclarator
@@ -3405,7 +3423,7 @@
 )txt"));
 }
 
-TEST_P(SyntaxTreeTest, StaticArraySubscriptsInDeclarators) {
+TEST_P(SyntaxTreeTest, ArrayDeclarator_Static) {
   if (!GetParam().isC99OrLater()) {
 return;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 235f9f7 - [SyntaxTree] Split `DynamicExceptionSpecification` test

2020-08-24 Thread Eduardo Caldas via cfe-commits

Author: Eduardo Caldas
Date: 2020-08-24T14:31:46Z
New Revision: 235f9f7fe94488904a60a8a1f5430183b0504945

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

LOG: [SyntaxTree] Split `DynamicExceptionSpecification` test

Added: 


Modified: 
clang/unittests/Tooling/Syntax/BuildTreeTest.cpp

Removed: 




diff  --git a/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp 
b/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
index 005f0a384d58..ce37a952ac1a 100644
--- a/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ b/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -3800,79 +3800,72 @@ TEST_P(SyntaxTreeTest, DynamicExceptionSpecification) {
   if (!GetParam().supportsCXXDynamicExceptionSpecification()) {
 return;
   }
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
 struct MyException1 {};
 struct MyException2 {};
-int a() throw();
-int b() throw(...);
-int c() throw(MyException1);
-int d() throw(MyException1, MyException2);
+[[int a() throw();]]
+[[int b() throw(...);]]
+[[int c() throw(MyException1);]]
+[[int d() throw(MyException1, MyException2);]]
 )cpp",
-  R"txt(
-*: TranslationUnit
-|-SimpleDeclaration
-| |-struct
-| |-MyException1
-| |-{
-| |-}
-| `-;
-|-SimpleDeclaration
-| |-struct
-| |-MyException2
-| |-{
-| |-}
-| `-;
-|-SimpleDeclaration
-| |-int
-| |-SimpleDeclarator
-| | |-a
-| | `-ParametersAndQualifiers
-| |   |-(
-| |   |-)
-| |   |-throw
-| |   |-(
-| |   `-)
-| `-;
-|-SimpleDeclaration
-| |-int
-| |-SimpleDeclarator
-| | |-b
-| | `-ParametersAndQualifiers
-| |   |-(
-| |   |-)
-| |   |-throw
-| |   |-(
-| |   |-...
-| |   `-)
-| `-;
-|-SimpleDeclaration
-| |-int
-| |-SimpleDeclarator
-| | |-c
-| | `-ParametersAndQualifiers
-| |   |-(
-| |   |-)
-| |   |-throw
-| |   |-(
-| |   |-MyException1
-| |   `-)
-| `-;
-`-SimpleDeclaration
-  |-int
-  |-SimpleDeclarator
-  | |-d
-  | `-ParametersAndQualifiers
-  |   |-(
-  |   |-)
-  |   |-throw
-  |   |-(
-  |   |-MyException1
-  |   |-,
-  |   |-MyException2
-  |   `-)
-  `-;
-)txt"));
+  {R"txt(
+SimpleDeclaration
+|-int
+|-SimpleDeclarator
+| |-a
+| `-ParametersAndQualifiers
+|   |-(
+|   |-)
+|   |-throw
+|   |-(
+|   `-)
+`-;
+)txt",
+   R"txt(
+SimpleDeclaration
+|-int
+|-SimpleDeclarator
+| |-b
+| `-ParametersAndQualifiers
+|   |-(
+|   |-)
+|   |-throw
+|   |-(
+|   |-...
+|   `-)
+`-;
+)txt",
+   R"txt(
+SimpleDeclaration
+|-int
+|-SimpleDeclarator
+| |-c
+| `-ParametersAndQualifiers
+|   |-(
+|   |-)
+|   |-throw
+|   |-(
+|   |-MyException1
+|   `-)
+`-;
+)txt",
+   R"txt(
+SimpleDeclaration
+|-int
+|-SimpleDeclarator
+| |-d
+| `-ParametersAndQualifiers
+|   |-(
+|   |-)
+|   |-throw
+|   |-(
+|   |-MyException1
+|   |-,
+|   |-MyException2
+|   `-)
+`-;
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, NoexceptExceptionSpecification) {



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


[PATCH] D86441: [SyntaxTree] Split ExplicitTemplateInstantiation test

2020-08-24 Thread Eduardo Caldas via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa722d6a197c7: [SyntaxTree] Split 
ExplicitTemplateInstantiation test (authored by eduucaldas).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86441

Files:
  clang/unittests/Tooling/Syntax/BuildTreeTest.cpp

Index: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -3051,84 +3051,105 @@
 )txt"));
 }
 
-TEST_P(SyntaxTreeTest, ExplicitTemplateInstantations) {
+TEST_P(SyntaxTreeTest, ExplicitClassTemplateInstantation_Definition) {
   if (!GetParam().isCXX()) {
 return;
   }
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
 template  struct X {};
-template  struct X {};
-template <> struct X {};
+[[template struct X;]]
+)cpp",
+  {R"txt(
+ExplicitTemplateInstantiation
+|-template
+`-SimpleDeclaration
+  |-struct
+  |-X
+  |-<
+  |-double
+  |->
+  `-;
+)txt"}));
+}
 
-template struct X;
-extern template struct X;
+TEST_P(SyntaxTreeTest, ExplicitClassTemplateInstantation_Declaration) {
+  if (!GetParam().isCXX()) {
+return;
+  }
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
+  R"cpp(
+template  struct X {};
+[[extern template struct X;]]
 )cpp",
-  R"txt(
-*: TranslationUnit
-|-TemplateDeclaration
-| |-template
-| |-<
-| |-UnknownDeclaration
-| | |-class
-| | `-T
-| |->
-| `-SimpleDeclaration
-|   |-struct
-|   |-X
-|   |-{
-|   |-}
-|   `-;
-|-TemplateDeclaration
-| |-template
-| |-<
-| |-UnknownDeclaration
-| | |-class
-| | `-T
-| |->
-| `-SimpleDeclaration
-|   |-struct
-|   |-X
-|   |-<
-|   |-T
-|   |-*
-|   |->
-|   |-{
-|   |-}
-|   `-;
-|-TemplateDeclaration
-| |-template
-| |-<
-| |->
-| `-SimpleDeclaration
-|   |-struct
-|   |-X
-|   |-<
-|   |-int
-|   |->
-|   |-{
-|   |-}
-|   `-;
-|-ExplicitTemplateInstantiation
-| |-template
-| `-SimpleDeclaration
-|   |-struct
-|   |-X
-|   |-<
-|   |-double
-|   |->
-|   `-;
-`-ExplicitTemplateInstantiation
-  |-extern
-  |-template
-  `-SimpleDeclaration
-|-struct
-|-X
-|-<
-|-float
-|->
-`-;
-)txt"));
+  {R"txt(
+ExplicitTemplateInstantiation
+|-extern
+|-template
+`-SimpleDeclaration
+  |-struct
+  |-X
+  |-<
+  |-float
+  |->
+  `-;
+)txt"}));
+}
+
+TEST_P(SyntaxTreeTest, ClassTemplateSpecialization_Partial) {
+  if (!GetParam().isCXX()) {
+return;
+  }
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
+  R"cpp(
+template  struct X {};
+[[template  struct X {};]]
+)cpp",
+  {R"txt(
+TemplateDeclaration
+|-template
+|-<
+|-UnknownDeclaration
+| |-class
+| `-T
+|->
+`-SimpleDeclaration
+  |-struct
+  |-X
+  |-<
+  |-T
+  |-*
+  |->
+  |-{
+  |-}
+  `-;
+)txt"}));
+}
+
+TEST_P(SyntaxTreeTest, ClassTemplateSpecialization_Full) {
+  if (!GetParam().isCXX()) {
+return;
+  }
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
+  R"cpp(
+template  struct X {};
+[[template <> struct X {};]]
+)cpp",
+  {R"txt(
+TemplateDeclaration
+|-template
+|-<
+|->
+`-SimpleDeclaration
+  |-struct
+  |-X
+  |-<
+  |-int
+  |->
+  |-{
+  |-}
+  `-;
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, UsingType) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] ed83095 - [SyntaxTree] Use annotations to reduce noise on member function tests

2020-08-24 Thread Eduardo Caldas via cfe-commits

Author: Eduardo Caldas
Date: 2020-08-24T14:31:45Z
New Revision: ed83095254a3e212d14b293a6a0e6c85d1f3331c

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

LOG: [SyntaxTree] Use annotations to reduce noise on member function tests

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

Added: 


Modified: 
clang/unittests/Tooling/Syntax/BuildTreeTest.cpp

Removed: 




diff  --git a/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp 
b/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
index a8e675468257..93f510e0a890 100644
--- a/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ b/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -2570,61 +2570,47 @@ TEST_P(SyntaxTreeTest, StaticMemberFunction) {
   if (!GetParam().isCXX11OrLater()) {
 return;
   }
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
 struct S {
-  static void f(){}
+  [[static void f(){}]]
 };
 )cpp",
-  R"txt(
-*: TranslationUnit
-`-SimpleDeclaration
-  |-struct
-  |-S
+  {R"txt(
+SimpleDeclaration
+|-static
+|-void
+|-SimpleDeclarator
+| |-f
+| `-ParametersAndQualifiers
+|   |-(
+|   `-)
+`-CompoundStatement
   |-{
-  |-SimpleDeclaration
-  | |-static
-  | |-void
-  | |-SimpleDeclarator
-  | | |-f
-  | | `-ParametersAndQualifiers
-  | |   |-(
-  | |   `-)
-  | `-CompoundStatement
-  |   |-{
-  |   `-}
-  |-}
-  `-;
-)txt"));
+  `-}
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, ConversionMemberFunction) {
   if (!GetParam().isCXX()) {
 return;
   }
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
 struct X {
-  operator int();
+  [[operator int();]]
 };
 )cpp",
-  R"txt(
-*: TranslationUnit
-`-SimpleDeclaration
-  |-struct
-  |-X
-  |-{
-  |-SimpleDeclaration
-  | |-SimpleDeclarator
-  | | |-operator
-  | | |-int
-  | | `-ParametersAndQualifiers
-  | |   |-(
-  | |   `-)
-  | `-;
-  |-}
-  `-;
-)txt"));
+  {R"txt(
+SimpleDeclaration
+|-SimpleDeclarator
+| |-operator
+| |-int
+| `-ParametersAndQualifiers
+|   |-(
+|   `-)
+`-;
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, LiteralOperatorDeclaration) {
@@ -2687,76 +2673,62 @@ TEST_P(SyntaxTreeTest, OverloadedOperatorDeclaration) {
   if (!GetParam().isCXX()) {
 return;
   }
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
 struct X {
-  X& operator=(const X&);
+  [[X& operator=(const X&);]]
 };
 )cpp",
-  R"txt(
-*: TranslationUnit
-`-SimpleDeclaration
-  |-struct
-  |-X
-  |-{
-  |-SimpleDeclaration
-  | |-X
-  | |-SimpleDeclarator
-  | | |-&
-  | | |-operator
-  | | |-=
-  | | `-ParametersAndQualifiers
-  | |   |-(
-  | |   |-SimpleDeclaration
-  | |   | |-const
-  | |   | |-X
-  | |   | `-SimpleDeclarator
-  | |   |   `-&
-  | |   `-)
-  | `-;
-  |-}
-  `-;
-)txt"));
+  {R"txt(
+SimpleDeclaration
+|-X
+|-SimpleDeclarator
+| |-&
+| |-operator
+| |-=
+| `-ParametersAndQualifiers
+|   |-(
+|   |-SimpleDeclaration
+|   | |-const
+|   | |-X
+|   | `-SimpleDeclarator
+|   |   `-&
+|   `-)
+`-;
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, OverloadedOperatorFriendDeclarataion) {
   if (!GetParam().isCXX()) {
 return;
   }
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
 struct X {
-  friend X operator+(X, const X&);
+  [[friend X operator+(X, const X&);]]
 };
 )cpp",
-  R"txt(
-*: TranslationUnit
+  {R"txt(
+UnknownDeclaration
 `-SimpleDeclaration
-  |-struct
+  |-friend
   |-X
-  |-{
-  |-UnknownDeclaration
-  | `-SimpleDeclaration
-  |   |-friend
-  |   |-X
-  |   |-SimpleDeclarator
-  |   | |-operator
-  |   | |-+
-  |   | `-ParametersAndQualifiers
-  |   |   |-(
-  |   |   |-SimpleDeclaration
-  |   |   | `-X
-  |   |   |-,
-  |   |   |-SimpleDeclaration
-  |   |   | |-const
-  |   |   | |-X
-  |   |   | `-SimpleDeclarator
-  |   |   |   `-&
-  |   |   `-)
-  |   `-;
-  |-}
+  |-SimpleDeclarator
+  | |-operator
+  | |-+
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   |-SimpleDeclaration
+  |   | `-X
+  |   |-,
+  |   |-SimpleDeclaration
+  |   | |-const
+  |   | |-X
+  |   | `-SimpleDeclarator
+  |   |   `-&
+  |   `-)
   `-;
-)txt"));
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, ClassTemplateDeclaration) {
@@ -2847,38 +2819,31 @@ TEST_P(SyntaxTreeTest, StaticMemberFunctionTemplate) {
   if (!GetParam().isCXX()) {
 return;
   }
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
 struct S {
-  template
-  static U f();
+  [[template
+  static U f();]]
 };
 )cpp",
-  R"txt(
-*: TranslationUnit
+  {R"txt(
+TemplateDeclaration
+|-template
+|-<
+|-UnknownDeclaration
+| |-typename
+| `-U
+|->
 `-SimpleDeclaration
-  |-struct
-  |-S
-  |-{
-  |-TemplateDeclaration
-  | |-template
-  | |-<
-  | |-UnknownDeclaration
-  | | |-typename
-  | | `-U
-  |

[clang] 90f85df - [SyntaxTree] Group tests related to `using`

2020-08-24 Thread Eduardo Caldas via cfe-commits

Author: Eduardo Caldas
Date: 2020-08-24T14:31:46Z
New Revision: 90f85dfc14bc6020486eb2d2c6399f8207ef3625

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

LOG: [SyntaxTree] Group tests related to `using`

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

Added: 


Modified: 
clang/unittests/Tooling/Syntax/BuildTreeTest.cpp

Removed: 




diff  --git a/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp 
b/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
index 4fc648df90b3..acbe90526fcb 100644
--- a/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ b/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -2494,7 +2494,7 @@ UsingNamespaceDirective
 )txt"}));
 }
 
-TEST_P(SyntaxTreeTest, UsingDeclaration) {
+TEST_P(SyntaxTreeTest, UsingDeclaration_Namespace) {
   if (!GetParam().isCXX()) {
 return;
   }
@@ -2515,6 +2515,59 @@ UsingDeclaration
 )txt"}));
 }
 
+TEST_P(SyntaxTreeTest, UsingDeclaration_ClassMember) {
+  if (!GetParam().isCXX()) {
+return;
+  }
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
+  R"cpp(
+template  struct X {
+  [[using T::foo;]]
+  [[using typename T::bar;]]
+};
+)cpp",
+  {R"txt(
+UsingDeclaration
+|-using
+|-NestedNameSpecifier
+| |-IdentifierNameSpecifier
+| | `-T
+| `-::
+|-foo
+`-;
+)txt",
+   R"txt(
+UsingDeclaration
+|-using
+|-typename
+|-NestedNameSpecifier
+| |-IdentifierNameSpecifier
+| | `-T
+| `-::
+|-bar
+`-;
+)txt"}));
+}
+
+TEST_P(SyntaxTreeTest, UsingTypeAlias) {
+  if (!GetParam().isCXX()) {
+return;
+  }
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+using type = int;
+)cpp",
+  R"txt(
+*: TranslationUnit
+`-TypeAliasDeclaration
+  |-using
+  |-type
+  |-=
+  |-int
+  `-;
+)txt"));
+}
+
 TEST_P(SyntaxTreeTest, FreeStandingClass_ForwardDeclaration) {
   EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
@@ -3005,52 +3058,6 @@ template  struct X::Y {};
 )txt"));
 }
 
-TEST_P(SyntaxTreeTest, TemplatesUsingUsing) {
-  if (!GetParam().isCXX()) {
-return;
-  }
-  EXPECT_TRUE(treeDumpEqual(
-  R"cpp(
-template  struct X {
-  using T::foo;
-  using typename T::bar;
-};
-)cpp",
-  R"txt(
-*: TranslationUnit
-`-TemplateDeclaration
-  |-template
-  |-<
-  |-UnknownDeclaration
-  | |-class
-  | `-T
-  |->
-  `-SimpleDeclaration
-|-struct
-|-X
-|-{
-|-UsingDeclaration
-| |-using
-| |-NestedNameSpecifier
-| | |-IdentifierNameSpecifier
-| | | `-T
-| | `-::
-| |-foo
-| `-;
-|-UsingDeclaration
-| |-using
-| |-typename
-| |-NestedNameSpecifier
-| | |-IdentifierNameSpecifier
-| | | `-T
-| | `-::
-| |-bar
-| `-;
-|-}
-`-;
-)txt"));
-}
-
 TEST_P(SyntaxTreeTest, ExplicitClassTemplateInstantation_Definition) {
   if (!GetParam().isCXX()) {
 return;
@@ -3152,25 +3159,6 @@ TemplateDeclaration
 )txt"}));
 }
 
-TEST_P(SyntaxTreeTest, UsingType) {
-  if (!GetParam().isCXX()) {
-return;
-  }
-  EXPECT_TRUE(treeDumpEqual(
-  R"cpp(
-using type = int;
-)cpp",
-  R"txt(
-*: TranslationUnit
-`-TypeAliasDeclaration
-  |-using
-  |-type
-  |-=
-  |-int
-  `-;
-)txt"));
-}
-
 TEST_P(SyntaxTreeTest, EmptyDeclaration) {
   EXPECT_TRUE(treeDumpEqual(
   R"cpp(



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


[clang] 4baa163 - [SyntaxTree] Split `ParametersAndQualifiers` tests

2020-08-24 Thread Eduardo Caldas via cfe-commits

Author: Eduardo Caldas
Date: 2020-08-24T14:31:46Z
New Revision: 4baa163c74237b30c5094c1fafd7ed355575bcfa

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

LOG: [SyntaxTree] Split `ParametersAndQualifiers` tests

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

Added: 


Modified: 
clang/unittests/Tooling/Syntax/BuildTreeTest.cpp

Removed: 




diff  --git a/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp 
b/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
index acbe90526fcb..005f0a384d58 100644
--- a/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ b/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -3438,19 +3438,30 @@ void f(int xs[static 10]);
 )txt"));
 }
 
-TEST_P(SyntaxTreeTest, ParametersAndQualifiersInFreeFunctions) {
-  if (!GetParam().isCXX()) {
-return;
-  }
+TEST_P(SyntaxTreeTest, ParametersAndQualifiers_InFreeFunctions_Empty) {
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+int func();
+)cpp",
+  R"txt(
+*: TranslationUnit
+`-SimpleDeclaration
+  |-int
+  |-SimpleDeclarator
+  | |-func
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   `-)
+  `-;
+)txt"));
+}
+
+TEST_P(SyntaxTreeTest, ParametersAndQualifiers_InFreeFunctions_Named) {
   EXPECT_TRUE(treeDumpEqual(
   R"cpp(
-int func1();
-int func2a(int a);
-int func2b(int);
-int func3a(int *ap);
-int func3b(int *);
-int func4a(int a, float b);
-int func4b(int, float);
+int func1(int a);
+int func2(int *ap);
+int func3(int a, float b);
 )cpp",
   R"txt(
 *: TranslationUnit
@@ -3460,14 +3471,6 @@ int func4b(int, float);
 | | |-func1
 | | `-ParametersAndQualifiers
 | |   |-(
-| |   `-)
-| `-;
-|-SimpleDeclaration
-| |-int
-| |-SimpleDeclarator
-| | |-func2a
-| | `-ParametersAndQualifiers
-| |   |-(
 | |   |-SimpleDeclaration
 | |   | |-int
 | |   | `-SimpleDeclarator
@@ -3477,17 +3480,7 @@ int func4b(int, float);
 |-SimpleDeclaration
 | |-int
 | |-SimpleDeclarator
-| | |-func2b
-| | `-ParametersAndQualifiers
-| |   |-(
-| |   |-SimpleDeclaration
-| |   | `-int
-| |   `-)
-| `-;
-|-SimpleDeclaration
-| |-int
-| |-SimpleDeclarator
-| | |-func3a
+| | |-func2
 | | `-ParametersAndQualifiers
 | |   |-(
 | |   |-SimpleDeclaration
@@ -3497,39 +3490,61 @@ int func4b(int, float);
 | |   |   `-ap
 | |   `-)
 | `-;
+`-SimpleDeclaration
+  |-int
+  |-SimpleDeclarator
+  | |-func3
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   |-SimpleDeclaration
+  |   | |-int
+  |   | `-SimpleDeclarator
+  |   |   `-a
+  |   |-,
+  |   |-SimpleDeclaration
+  |   | |-float
+  |   | `-SimpleDeclarator
+  |   |   `-b
+  |   `-)
+  `-;
+)txt"));
+}
+
+TEST_P(SyntaxTreeTest, ParametersAndQualifiers_InFreeFunctions_Unnamed) {
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+int func1(int);
+int func2(int *);
+int func3(int, float);
+)cpp",
+  R"txt(
+*: TranslationUnit
 |-SimpleDeclaration
 | |-int
 | |-SimpleDeclarator
-| | |-func3b
+| | |-func1
 | | `-ParametersAndQualifiers
 | |   |-(
 | |   |-SimpleDeclaration
-| |   | |-int
-| |   | `-SimpleDeclarator
-| |   |   `-*
+| |   | `-int
 | |   `-)
 | `-;
 |-SimpleDeclaration
 | |-int
 | |-SimpleDeclarator
-| | |-func4a
+| | |-func2
 | | `-ParametersAndQualifiers
 | |   |-(
 | |   |-SimpleDeclaration
 | |   | |-int
 | |   | `-SimpleDeclarator
-| |   |   `-a
-| |   |-,
-| |   |-SimpleDeclaration
-| |   | |-float
-| |   | `-SimpleDeclarator
-| |   |   `-b
+| |   |   `-*
 | |   `-)
 | `-;
 `-SimpleDeclaration
   |-int
   |-SimpleDeclarator
-  | |-func4b
+  | |-func3
   | `-ParametersAndQualifiers
   |   |-(
   |   |-SimpleDeclaration
@@ -3542,47 +3557,60 @@ int func4b(int, float);
 )txt"));
 }
 
-TEST_P(SyntaxTreeTest, ParametersAndQualifiersInFreeFunctionsCxx) {
+TEST_P(SyntaxTreeTest,
+   ParametersAndQualifiers_InFreeFunctions_Cxx_CvQualifiers) {
   if (!GetParam().isCXX()) {
 return;
   }
   EXPECT_TRUE(treeDumpEqual(
   R"cpp(
-int func1(const int a, volatile int b, const volatile int c);
-int func2(int& a);
+int func(const int a, volatile int b, const volatile int c);
 )cpp",
   R"txt(
 *: TranslationUnit
-|-SimpleDeclaration
-| |-int
-| |-SimpleDeclarator
-| | |-func1
-| | `-ParametersAndQualifiers
-| |   |-(
-| |   |-SimpleDeclaration
-| |   | |-const
-| |   | |-int
-| |   | `-SimpleDeclarator
-| |   |   `-a
-| |   |-,
-| |   |-SimpleDeclaration
-| |   | |-volatile
-| |   | |-int
-| |   | `-SimpleDeclarator
-| |   |   `-b
-| |   |-,
-| |   |-SimpleDeclaration
-| |   | |-const
-| |   | |-volatile
-| |   | |-int
-| |   | `-SimpleDeclarator
-| |   |   `-c
-| |   `-)
-| `-;
 `-SimpleDeclaration
   |-int
   |-SimpleDeclarator
-  | |-func2
+  | |-func
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   |-SimpleDeclaration
+  |   | |-const
+  |   | |-int
+  |   | `-SimpleDeclarator
+  |   |   `-a
+  |   |-,
+  |   |-SimpleDeclaration
+  |   | |-volatile
+  |   | |-in

[clang] a722d6a - [SyntaxTree] Split ExplicitTemplateInstantiation test

2020-08-24 Thread Eduardo Caldas via cfe-commits

Author: Eduardo Caldas
Date: 2020-08-24T14:31:45Z
New Revision: a722d6a197c7a4f7a1afb72b4732b8ebe8272628

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

LOG: [SyntaxTree] Split ExplicitTemplateInstantiation test

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

Added: 


Modified: 
clang/unittests/Tooling/Syntax/BuildTreeTest.cpp

Removed: 




diff  --git a/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp 
b/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
index 8dbf99c32db8..4fc648df90b3 100644
--- a/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ b/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -3051,84 +3051,105 @@ template  struct X {
 )txt"));
 }
 
-TEST_P(SyntaxTreeTest, ExplicitTemplateInstantations) {
+TEST_P(SyntaxTreeTest, ExplicitClassTemplateInstantation_Definition) {
   if (!GetParam().isCXX()) {
 return;
   }
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
 template  struct X {};
-template  struct X {};
-template <> struct X {};
+[[template struct X;]]
+)cpp",
+  {R"txt(
+ExplicitTemplateInstantiation
+|-template
+`-SimpleDeclaration
+  |-struct
+  |-X
+  |-<
+  |-double
+  |->
+  `-;
+)txt"}));
+}
 
-template struct X;
-extern template struct X;
+TEST_P(SyntaxTreeTest, ExplicitClassTemplateInstantation_Declaration) {
+  if (!GetParam().isCXX()) {
+return;
+  }
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
+  R"cpp(
+template  struct X {};
+[[extern template struct X;]]
 )cpp",
-  R"txt(
-*: TranslationUnit
-|-TemplateDeclaration
-| |-template
-| |-<
-| |-UnknownDeclaration
-| | |-class
-| | `-T
-| |->
-| `-SimpleDeclaration
-|   |-struct
-|   |-X
-|   |-{
-|   |-}
-|   `-;
-|-TemplateDeclaration
-| |-template
-| |-<
-| |-UnknownDeclaration
-| | |-class
-| | `-T
-| |->
-| `-SimpleDeclaration
-|   |-struct
-|   |-X
-|   |-<
-|   |-T
-|   |-*
-|   |->
-|   |-{
-|   |-}
-|   `-;
-|-TemplateDeclaration
-| |-template
-| |-<
-| |->
-| `-SimpleDeclaration
-|   |-struct
-|   |-X
-|   |-<
-|   |-int
-|   |->
-|   |-{
-|   |-}
-|   `-;
-|-ExplicitTemplateInstantiation
-| |-template
-| `-SimpleDeclaration
-|   |-struct
-|   |-X
-|   |-<
-|   |-double
-|   |->
-|   `-;
-`-ExplicitTemplateInstantiation
-  |-extern
-  |-template
-  `-SimpleDeclaration
-|-struct
-|-X
-|-<
-|-float
-|->
-`-;
-)txt"));
+  {R"txt(
+ExplicitTemplateInstantiation
+|-extern
+|-template
+`-SimpleDeclaration
+  |-struct
+  |-X
+  |-<
+  |-float
+  |->
+  `-;
+)txt"}));
+}
+
+TEST_P(SyntaxTreeTest, ClassTemplateSpecialization_Partial) {
+  if (!GetParam().isCXX()) {
+return;
+  }
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
+  R"cpp(
+template  struct X {};
+[[template  struct X {};]]
+)cpp",
+  {R"txt(
+TemplateDeclaration
+|-template
+|-<
+|-UnknownDeclaration
+| |-class
+| `-T
+|->
+`-SimpleDeclaration
+  |-struct
+  |-X
+  |-<
+  |-T
+  |-*
+  |->
+  |-{
+  |-}
+  `-;
+)txt"}));
+}
+
+TEST_P(SyntaxTreeTest, ClassTemplateSpecialization_Full) {
+  if (!GetParam().isCXX()) {
+return;
+  }
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
+  R"cpp(
+template  struct X {};
+[[template <> struct X {};]]
+)cpp",
+  {R"txt(
+TemplateDeclaration
+|-template
+|-<
+|->
+`-SimpleDeclaration
+  |-struct
+  |-X
+  |-<
+  |-int
+  |->
+  |-{
+  |-}
+  `-;
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, UsingType) {



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


[clang] 4e8dd50 - [SyntaxTree] Split array declarator tests

2020-08-24 Thread Eduardo Caldas via cfe-commits

Author: Eduardo Caldas
Date: 2020-08-24T14:31:45Z
New Revision: 4e8dd506e66642329dcd530524f43b0d2b528521

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

LOG: [SyntaxTree] Split array declarator tests

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

Added: 


Modified: 
clang/unittests/Tooling/Syntax/BuildTreeTest.cpp

Removed: 




diff  --git a/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp 
b/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
index 994dd68028ea..a8e675468257 100644
--- a/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ b/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -3342,45 +3342,63 @@ void test() {
 )txt"));
 }
 
-TEST_P(SyntaxTreeTest, ArraySubscriptsInDeclarators) {
+TEST_P(SyntaxTreeTest, ArrayDeclarator_Simple) {
   EXPECT_TRUE(treeDumpEqual(
   R"cpp(
 int a[10];
+)cpp",
+  R"txt(
+*: TranslationUnit
+`-SimpleDeclaration
+  |-int
+  |-SimpleDeclarator
+  | |-a
+  | `-ArraySubscript
+  |   |-[
+  |   |-IntegerLiteralExpression
+  |   | `-10
+  |   `-]
+  `-;
+)txt"));
+}
+
+TEST_P(SyntaxTreeTest, ArrayDeclarator_Multidimensional) {
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
 int b[1][2][3];
+)cpp",
+  R"txt(
+*: TranslationUnit
+`-SimpleDeclaration
+  |-int
+  |-SimpleDeclarator
+  | |-b
+  | |-ArraySubscript
+  | | |-[
+  | | |-IntegerLiteralExpression
+  | | | `-1
+  | | `-]
+  | |-ArraySubscript
+  | | |-[
+  | | |-IntegerLiteralExpression
+  | | | `-2
+  | | `-]
+  | `-ArraySubscript
+  |   |-[
+  |   |-IntegerLiteralExpression
+  |   | `-3
+  |   `-]
+  `-;
+)txt"));
+}
+
+TEST_P(SyntaxTreeTest, ArrayDeclarator_UnknownBound) {
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
 int c[] = {1,2,3};
 )cpp",
   R"txt(
 *: TranslationUnit
-|-SimpleDeclaration
-| |-int
-| |-SimpleDeclarator
-| | |-a
-| | `-ArraySubscript
-| |   |-[
-| |   |-IntegerLiteralExpression
-| |   | `-10
-| |   `-]
-| `-;
-|-SimpleDeclaration
-| |-int
-| |-SimpleDeclarator
-| | |-b
-| | |-ArraySubscript
-| | | |-[
-| | | |-IntegerLiteralExpression
-| | | | `-1
-| | | `-]
-| | |-ArraySubscript
-| | | |-[
-| | | |-IntegerLiteralExpression
-| | | | `-2
-| | | `-]
-| | `-ArraySubscript
-| |   |-[
-| |   |-IntegerLiteralExpression
-| |   | `-3
-| |   `-]
-| `-;
 `-SimpleDeclaration
   |-int
   |-SimpleDeclarator
@@ -3405,7 +3423,7 @@ int c[] = {1,2,3};
 )txt"));
 }
 
-TEST_P(SyntaxTreeTest, StaticArraySubscriptsInDeclarators) {
+TEST_P(SyntaxTreeTest, ArrayDeclarator_Static) {
   if (!GetParam().isC99OrLater()) {
 return;
   }



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


[clang] b4093d6 - [SyntaxTree] Split FreeStandingClass tests

2020-08-24 Thread Eduardo Caldas via cfe-commits

Author: Eduardo Caldas
Date: 2020-08-24T14:31:45Z
New Revision: b4093d663f8377b3ca3746ff104c83c9c5510c0a

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

LOG: [SyntaxTree] Split FreeStandingClass tests

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

Added: 


Modified: 
clang/unittests/Tooling/Syntax/BuildTreeTest.cpp

Removed: 




diff  --git a/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp 
b/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
index 93f510e0a890..8dbf99c32db8 100644
--- a/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ b/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -2515,55 +2515,65 @@ UsingDeclaration
 )txt"}));
 }
 
-TEST_P(SyntaxTreeTest, FreeStandingClasses) {
-  // Free-standing classes, must live inside a SimpleDeclaration.
-  EXPECT_TRUE(treeDumpEqual(
+TEST_P(SyntaxTreeTest, FreeStandingClass_ForwardDeclaration) {
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
-struct X;
-struct X {};
-
-struct Y *y1;
-struct Y {} *y2;
+[[struct X;]]
+[[struct Y *y1;]]
+)cpp",
+  {R"txt(
+SimpleDeclaration
+|-struct
+|-X
+`-;
+)txt",
+   R"txt(
+SimpleDeclaration
+|-struct
+|-Y
+|-SimpleDeclarator
+| |-*
+| `-y1
+`-;
+)txt"}));
+}
 
-struct {} *a1;
+TEST_P(SyntaxTreeTest, FreeStandingClasses_Definition) {
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
+  R"cpp(
+[[struct X {};]]
+[[struct Y {} *y2;]]
+[[struct {} *a1;]]
 )cpp",
-  R"txt(
-*: TranslationUnit
-|-SimpleDeclaration
-| |-struct
-| |-X
-| `-;
-|-SimpleDeclaration
-| |-struct
-| |-X
-| |-{
-| |-}
-| `-;
-|-SimpleDeclaration
-| |-struct
-| |-Y
-| |-SimpleDeclarator
-| | |-*
-| | `-y1
-| `-;
-|-SimpleDeclaration
-| |-struct
-| |-Y
-| |-{
-| |-}
-| |-SimpleDeclarator
-| | |-*
-| | `-y2
-| `-;
-`-SimpleDeclaration
-  |-struct
-  |-{
-  |-}
-  |-SimpleDeclarator
-  | |-*
-  | `-a1
-  `-;
-)txt"));
+  {R"txt(
+SimpleDeclaration
+|-struct
+|-X
+|-{
+|-}
+`-;
+)txt",
+   R"txt(
+SimpleDeclaration
+|-struct
+|-Y
+|-{
+|-}
+|-SimpleDeclarator
+| |-*
+| `-y2
+`-;
+)txt",
+   R"txt(
+SimpleDeclaration
+|-struct
+|-{
+|-}
+|-SimpleDeclarator
+| |-*
+| `-a1
+`-;
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, StaticMemberFunction) {



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


[PATCH] D86459: [SyntaxTree] Split `ParametersAndQualifiers` tests

2020-08-24 Thread Eduardo Caldas via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4baa163c7423: [SyntaxTree] Split `ParametersAndQualifiers` 
tests (authored by eduucaldas).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86459

Files:
  clang/unittests/Tooling/Syntax/BuildTreeTest.cpp

Index: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -3438,19 +3438,30 @@
 )txt"));
 }
 
-TEST_P(SyntaxTreeTest, ParametersAndQualifiersInFreeFunctions) {
-  if (!GetParam().isCXX()) {
-return;
-  }
+TEST_P(SyntaxTreeTest, ParametersAndQualifiers_InFreeFunctions_Empty) {
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+int func();
+)cpp",
+  R"txt(
+*: TranslationUnit
+`-SimpleDeclaration
+  |-int
+  |-SimpleDeclarator
+  | |-func
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   `-)
+  `-;
+)txt"));
+}
+
+TEST_P(SyntaxTreeTest, ParametersAndQualifiers_InFreeFunctions_Named) {
   EXPECT_TRUE(treeDumpEqual(
   R"cpp(
-int func1();
-int func2a(int a);
-int func2b(int);
-int func3a(int *ap);
-int func3b(int *);
-int func4a(int a, float b);
-int func4b(int, float);
+int func1(int a);
+int func2(int *ap);
+int func3(int a, float b);
 )cpp",
   R"txt(
 *: TranslationUnit
@@ -3460,14 +3471,6 @@
 | | |-func1
 | | `-ParametersAndQualifiers
 | |   |-(
-| |   `-)
-| `-;
-|-SimpleDeclaration
-| |-int
-| |-SimpleDeclarator
-| | |-func2a
-| | `-ParametersAndQualifiers
-| |   |-(
 | |   |-SimpleDeclaration
 | |   | |-int
 | |   | `-SimpleDeclarator
@@ -3477,17 +3480,7 @@
 |-SimpleDeclaration
 | |-int
 | |-SimpleDeclarator
-| | |-func2b
-| | `-ParametersAndQualifiers
-| |   |-(
-| |   |-SimpleDeclaration
-| |   | `-int
-| |   `-)
-| `-;
-|-SimpleDeclaration
-| |-int
-| |-SimpleDeclarator
-| | |-func3a
+| | |-func2
 | | `-ParametersAndQualifiers
 | |   |-(
 | |   |-SimpleDeclaration
@@ -3497,39 +3490,61 @@
 | |   |   `-ap
 | |   `-)
 | `-;
+`-SimpleDeclaration
+  |-int
+  |-SimpleDeclarator
+  | |-func3
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   |-SimpleDeclaration
+  |   | |-int
+  |   | `-SimpleDeclarator
+  |   |   `-a
+  |   |-,
+  |   |-SimpleDeclaration
+  |   | |-float
+  |   | `-SimpleDeclarator
+  |   |   `-b
+  |   `-)
+  `-;
+)txt"));
+}
+
+TEST_P(SyntaxTreeTest, ParametersAndQualifiers_InFreeFunctions_Unnamed) {
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+int func1(int);
+int func2(int *);
+int func3(int, float);
+)cpp",
+  R"txt(
+*: TranslationUnit
 |-SimpleDeclaration
 | |-int
 | |-SimpleDeclarator
-| | |-func3b
+| | |-func1
 | | `-ParametersAndQualifiers
 | |   |-(
 | |   |-SimpleDeclaration
-| |   | |-int
-| |   | `-SimpleDeclarator
-| |   |   `-*
+| |   | `-int
 | |   `-)
 | `-;
 |-SimpleDeclaration
 | |-int
 | |-SimpleDeclarator
-| | |-func4a
+| | |-func2
 | | `-ParametersAndQualifiers
 | |   |-(
 | |   |-SimpleDeclaration
 | |   | |-int
 | |   | `-SimpleDeclarator
-| |   |   `-a
-| |   |-,
-| |   |-SimpleDeclaration
-| |   | |-float
-| |   | `-SimpleDeclarator
-| |   |   `-b
+| |   |   `-*
 | |   `-)
 | `-;
 `-SimpleDeclaration
   |-int
   |-SimpleDeclarator
-  | |-func4b
+  | |-func3
   | `-ParametersAndQualifiers
   |   |-(
   |   |-SimpleDeclaration
@@ -3542,47 +3557,60 @@
 )txt"));
 }
 
-TEST_P(SyntaxTreeTest, ParametersAndQualifiersInFreeFunctionsCxx) {
+TEST_P(SyntaxTreeTest,
+   ParametersAndQualifiers_InFreeFunctions_Cxx_CvQualifiers) {
   if (!GetParam().isCXX()) {
 return;
   }
   EXPECT_TRUE(treeDumpEqual(
   R"cpp(
-int func1(const int a, volatile int b, const volatile int c);
-int func2(int& a);
+int func(const int a, volatile int b, const volatile int c);
 )cpp",
   R"txt(
 *: TranslationUnit
-|-SimpleDeclaration
-| |-int
-| |-SimpleDeclarator
-| | |-func1
-| | `-ParametersAndQualifiers
-| |   |-(
-| |   |-SimpleDeclaration
-| |   | |-const
-| |   | |-int
-| |   | `-SimpleDeclarator
-| |   |   `-a
-| |   |-,
-| |   |-SimpleDeclaration
-| |   | |-volatile
-| |   | |-int
-| |   | `-SimpleDeclarator
-| |   |   `-b
-| |   |-,
-| |   |-SimpleDeclaration
-| |   | |-const
-| |   | |-volatile
-| |   | |-int
-| |   | `-SimpleDeclarator
-| |   |   `-c
-| |   `-)
-| `-;
 `-SimpleDeclaration
   |-int
   |-SimpleDeclarator
-  | |-func2
+  | |-func
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   |-SimpleDeclaration
+  |   | |-const
+  |   | |-int
+  |   | `-SimpleDeclarator
+  |   |   `-a
+  |   |-,
+  |   |-SimpleDeclaration
+  |   | |-volatile
+  |   | |-int
+  |   | `-SimpleDeclarator
+  |   |   `-b
+  |   |-,
+  |   |-SimpleDeclaration
+  |   | |-const
+  |   | |-volatile
+  |   | |-int
+  |   | `-SimpleDeclarator
+  |   |   `-c
+  |   `-)
+  `-;
+)txt"));
+}
+
+TEST_P(SyntaxTreeTest, ParametersAndQualifiers_InFreeFunctions_Cxx_Ref) {
+  if (!GetParam().

[PATCH] D86443: [SyntaxTree] Group tests related to `using`

2020-08-24 Thread Eduardo Caldas via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG90f85dfc14bc: [SyntaxTree] Group tests related to `using` 
(authored by eduucaldas).

Changed prior to commit:
  https://reviews.llvm.org/D86443?vs=287334&id=287389#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86443

Files:
  clang/unittests/Tooling/Syntax/BuildTreeTest.cpp

Index: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -2494,7 +2494,7 @@
 )txt"}));
 }
 
-TEST_P(SyntaxTreeTest, UsingDeclaration) {
+TEST_P(SyntaxTreeTest, UsingDeclaration_Namespace) {
   if (!GetParam().isCXX()) {
 return;
   }
@@ -2515,6 +2515,59 @@
 )txt"}));
 }
 
+TEST_P(SyntaxTreeTest, UsingDeclaration_ClassMember) {
+  if (!GetParam().isCXX()) {
+return;
+  }
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
+  R"cpp(
+template  struct X {
+  [[using T::foo;]]
+  [[using typename T::bar;]]
+};
+)cpp",
+  {R"txt(
+UsingDeclaration
+|-using
+|-NestedNameSpecifier
+| |-IdentifierNameSpecifier
+| | `-T
+| `-::
+|-foo
+`-;
+)txt",
+   R"txt(
+UsingDeclaration
+|-using
+|-typename
+|-NestedNameSpecifier
+| |-IdentifierNameSpecifier
+| | `-T
+| `-::
+|-bar
+`-;
+)txt"}));
+}
+
+TEST_P(SyntaxTreeTest, UsingTypeAlias) {
+  if (!GetParam().isCXX()) {
+return;
+  }
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+using type = int;
+)cpp",
+  R"txt(
+*: TranslationUnit
+`-TypeAliasDeclaration
+  |-using
+  |-type
+  |-=
+  |-int
+  `-;
+)txt"));
+}
+
 TEST_P(SyntaxTreeTest, FreeStandingClass_ForwardDeclaration) {
   EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
@@ -3005,52 +3058,6 @@
 )txt"));
 }
 
-TEST_P(SyntaxTreeTest, TemplatesUsingUsing) {
-  if (!GetParam().isCXX()) {
-return;
-  }
-  EXPECT_TRUE(treeDumpEqual(
-  R"cpp(
-template  struct X {
-  using T::foo;
-  using typename T::bar;
-};
-)cpp",
-  R"txt(
-*: TranslationUnit
-`-TemplateDeclaration
-  |-template
-  |-<
-  |-UnknownDeclaration
-  | |-class
-  | `-T
-  |->
-  `-SimpleDeclaration
-|-struct
-|-X
-|-{
-|-UsingDeclaration
-| |-using
-| |-NestedNameSpecifier
-| | |-IdentifierNameSpecifier
-| | | `-T
-| | `-::
-| |-foo
-| `-;
-|-UsingDeclaration
-| |-using
-| |-typename
-| |-NestedNameSpecifier
-| | |-IdentifierNameSpecifier
-| | | `-T
-| | `-::
-| |-bar
-| `-;
-|-}
-`-;
-)txt"));
-}
-
 TEST_P(SyntaxTreeTest, ExplicitClassTemplateInstantation_Definition) {
   if (!GetParam().isCXX()) {
 return;
@@ -3152,25 +3159,6 @@
 )txt"}));
 }
 
-TEST_P(SyntaxTreeTest, UsingType) {
-  if (!GetParam().isCXX()) {
-return;
-  }
-  EXPECT_TRUE(treeDumpEqual(
-  R"cpp(
-using type = int;
-)cpp",
-  R"txt(
-*: TranslationUnit
-`-TypeAliasDeclaration
-  |-using
-  |-type
-  |-=
-  |-int
-  `-;
-)txt"));
-}
-
 TEST_P(SyntaxTreeTest, EmptyDeclaration) {
   EXPECT_TRUE(treeDumpEqual(
   R"cpp(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D86135: [analyzer][MacroExpansion] Fix a crash where multiple parameters resolved to __VA_ARGS__

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

Is this related to https://bugs.llvm.org/show_bug.cgi?id=44493?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86135

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


[PATCH] D86295: [analyzer] Reorder the layout of MemRegion and cache by hand for optimal size

2020-08-24 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

In D86295#2233666 , @steakhal wrote:

> In D86295#2233401 , @vsavchenko 
> wrote:
>
>> Yep, I guess that is the cause.  I'll take a look.  Did you try it with this 
>> fast fix?
>
> I tried, but it lacks further fixes.
>
> Currently, I have this:
>
>   diff --git a/clang/utils/analyzer/Dockerfile 
> b/clang/utils/analyzer/Dockerfile
>   index f74ff8aa95c..7727d92f98f 100644
>   --- a/clang/utils/analyzer/Dockerfile
>   +++ b/clang/utils/analyzer/Dockerfile
>   @@ -1,4 +1,4 @@
>   -FROM ubuntu:bionic
>   +FROM ubuntu:bionic-20200526
>
>RUN apt-get update && apt-get install -y \
>apt-transport-https \
>   @@ -12,12 +12,13 @@ RUN wget -O - 
> https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/nul
>RUN apt-add-repository -y 'deb https://apt.kitware.com/ubuntu/ bionic main'
>
># test system dependencies
>   +# TODO: should we really depend on the cmake version 3.18.2 here? I don't 
> think so.
>RUN apt-get update && apt-get install -y \
>git=1:2.17.1-1ubuntu0.7 \
>gettext=0.19.8.1-6ubuntu0.3 \
>python3=3.6.7-1~18.04 \
>   -python3-pip=9.0.1-2.3~ubuntu1.18.04.1 \
>   -cmake=3.17.3-0kitware1 \
>   +python3-pip=9.0.1-2.3~ubuntu1.18.04.2 \
>   +cmake=3.18.2-0kitware1 \
>ninja-build=1.8.2-1
>
># box2d dependencies
>
>
> I'm not sure if its the company firewall or something else.

And what is the error right now?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86295

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


[clang] 512e256 - [PowerPC] Add clang options to control MMA support

2020-08-24 Thread Baptiste Saleil via cfe-commits

Author: Baptiste Saleil
Date: 2020-08-24T09:35:55-05:00
New Revision: 512e256c0d8c0fed5b4603ed5ed74b6ad503f368

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

LOG: [PowerPC] Add clang options to control MMA support

This patch adds frontend and backend options to enable and disable
the PowerPC MMA operations added in ISA 3.1. Instructions using these
options will be added in subsequent patches.

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Basic/Targets/PPC.cpp
clang/lib/Basic/Targets/PPC.h
clang/test/Driver/ppc-dependent-options.cpp
clang/test/Preprocessor/init-ppc64.c
llvm/lib/Target/PowerPC/PPC.td
llvm/lib/Target/PowerPC/PPCInstrPrefix.td
llvm/lib/Target/PowerPC/PPCScheduleP9.td
llvm/lib/Target/PowerPC/PPCSubtarget.cpp
llvm/lib/Target/PowerPC/PPCSubtarget.h
llvm/test/CodeGen/PowerPC/future-check-features.ll

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 111eec4b4a00..05aa79d06464 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2506,6 +2506,8 @@ def mlongcall: Flag<["-"], "mlongcall">,
 Group;
 def mno_longcall : Flag<["-"], "mno-longcall">,
 Group;
+def mmma: Flag<["-"], "mmma">, Group;
+def mno_mma: Flag<["-"], "mno-mma">, Group;
 def maix_struct_return : Flag<["-"], "maix-struct-return">,
   Group, Flags<[CC1Option]>,
   HelpText<"Return all structs in memory (PPC32 only)">;

diff  --git a/clang/lib/Basic/Targets/PPC.cpp b/clang/lib/Basic/Targets/PPC.cpp
index c5ad4a5a2d27..13db564d360d 100644
--- a/clang/lib/Basic/Targets/PPC.cpp
+++ b/clang/lib/Basic/Targets/PPC.cpp
@@ -64,6 +64,8 @@ bool 
PPCTargetInfo::handleTargetFeatures(std::vector &Features,
   FloatABI = SoftFloat;
 } else if (Feature == "+paired-vector-memops") {
   PairedVectorMemops = true;
+} else if (Feature == "+mma") {
+  HasMMA = true;
 }
 // TODO: Finish this list and add an assert that we've handled them
 // all.
@@ -184,6 +186,8 @@ void PPCTargetInfo::getTargetDefines(const LangOptions 
&Opts,
 Builder.defineMacro("__FLOAT128__");
   if (HasP9Vector)
 Builder.defineMacro("__POWER9_VECTOR__");
+  if (HasMMA)
+Builder.defineMacro("__MMA__");
   if (HasP10Vector)
 Builder.defineMacro("__POWER10_VECTOR__");
 
@@ -221,6 +225,7 @@ void PPCTargetInfo::getTargetDefines(const LangOptions 
&Opts,
 // - float128
 // - power9-vector
 // - paired-vector-memops
+// - mma
 // - power10-vector
 // then go ahead and error since the customer has expressed an incompatible
 // set of options.
@@ -244,6 +249,7 @@ static bool ppcUserFeaturesCheck(DiagnosticsEngine &Diags,
   Found |= FindVSXSubfeature("+float128", "-mfloat128");
   Found |= FindVSXSubfeature("+power9-vector", "-mpower9-vector");
   Found |= FindVSXSubfeature("+paired-vector-memops", 
"-mpaired-vector-memops");
+  Found |= FindVSXSubfeature("+mma", "-mmma");
   Found |= FindVSXSubfeature("+power10-vector", "-mpower10-vector");
 
   // Return false if any vsx subfeatures was found.
@@ -345,6 +351,7 @@ void PPCTargetInfo::addP10SpecificFeatures(
 llvm::StringMap &Features) const {
   Features["htm"] = false; // HTM was removed for P10.
   Features["paired-vector-memops"] = true;
+  Features["mma"] = true;
   Features["power10-vector"] = true;
   Features["pcrelative-memops"] = true;
   return;
@@ -373,6 +380,7 @@ bool PPCTargetInfo::hasFeature(StringRef Feature) const {
   .Case("power10-vector", HasP10Vector)
   .Case("pcrelative-memops", HasPCRelativeMemops)
   .Case("spe", HasSPE)
+  .Case("mma", HasMMA)
   .Default(false);
 }
 
@@ -389,6 +397,7 @@ void PPCTargetInfo::setFeatureEnabled(llvm::StringMap 
&Features,
  .Case("paired-vector-memops", true)
  .Case("power10-vector", true)
  .Case("float128", true)
+ .Case("mma", true)
  .Default(false);
 if (FeatureHasVSX)
   Features["vsx"] = Features["altivec"] = true;
@@ -406,13 +415,14 @@ void 
PPCTargetInfo::setFeatureEnabled(llvm::StringMap &Features,
 if ((Name == "altivec") || (Name == "vsx"))
   Features["vsx"] = Features["direct-move"] = Features["power8-vector"] =
   Features["float128"] = Features["power9-vector"] =
-  Features["paired-vector-memops"] = Features["power10-vector"] =
-  false;
+  Features["paired-vector-memops"] = Features["mma"] =
+  Features["power10-vector"] = false;
 if (Name == "power8-vector")
   Features["power9-vector"] = Features["paired-vect

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

2020-08-24 Thread Baptiste Saleil via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG512e256c0d8c: [PowerPC] Add clang options to control MMA 
support (authored by bsaleil).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81442

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets/PPC.cpp
  clang/lib/Basic/Targets/PPC.h
  clang/test/Driver/ppc-dependent-options.cpp
  clang/test/Preprocessor/init-ppc64.c
  llvm/lib/Target/PowerPC/PPC.td
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/lib/Target/PowerPC/PPCScheduleP9.td
  llvm/lib/Target/PowerPC/PPCSubtarget.cpp
  llvm/lib/Target/PowerPC/PPCSubtarget.h
  llvm/test/CodeGen/PowerPC/future-check-features.ll

Index: llvm/test/CodeGen/PowerPC/future-check-features.ll
===
--- llvm/test/CodeGen/PowerPC/future-check-features.ll
+++ llvm/test/CodeGen/PowerPC/future-check-features.ll
@@ -1,7 +1,7 @@
-; RUN: llc -mattr=pcrelative-memops,prefix-instrs,paired-vector-memops \
+; RUN: llc -mattr=pcrelative-memops,prefix-instrs,paired-vector-memops,mma \
 ; RUN:   -verify-machineinstrs -mtriple=powerpc64le-unknown-unknown \
 ; RUN:   -ppc-asm-full-reg-names %s -o - 2>&1 | FileCheck %s
-; RUN: llc -mattr=pcrelative-memops,prefix-instrs,paired-vector-memops \
+; RUN: llc -mattr=pcrelative-memops,prefix-instrs,paired-vector-memops,mma \
 ; RUN:   -verify-machineinstrs -mtriple=powerpc64-unknown-unknown \
 ; RUN:   -ppc-asm-full-reg-names %s -o - 2>&1 | FileCheck %s
 
Index: llvm/lib/Target/PowerPC/PPCSubtarget.h
===
--- llvm/lib/Target/PowerPC/PPCSubtarget.h
+++ llvm/lib/Target/PowerPC/PPCSubtarget.h
@@ -107,6 +107,7 @@
   bool HasP10Vector;
   bool HasPrefixInstrs;
   bool HasPCRelativeMemops;
+  bool HasMMA;
   bool HasFCPSGN;
   bool HasFSQRT;
   bool HasFRE, HasFRES, HasFRSQRTE, HasFRSQRTES;
@@ -260,6 +261,7 @@
   bool hasP10Vector() const { return HasP10Vector; }
   bool hasPrefixInstrs() const { return HasPrefixInstrs; }
   bool hasPCRelativeMemops() const { return HasPCRelativeMemops; }
+  bool hasMMA() const { return HasMMA; }
   bool pairedVectorMemops() const { return PairedVectorMemops; }
   bool hasMFOCRF() const { return HasMFOCRF; }
   bool hasISEL() const { return HasISEL; }
Index: llvm/lib/Target/PowerPC/PPCSubtarget.cpp
===
--- llvm/lib/Target/PowerPC/PPCSubtarget.cpp
+++ llvm/lib/Target/PowerPC/PPCSubtarget.cpp
@@ -73,6 +73,7 @@
   HasP8Crypto = false;
   HasP9Vector = false;
   HasP9Altivec = false;
+  HasMMA = false;
   HasP10Vector = false;
   HasPrefixInstrs = false;
   HasPCRelativeMemops = false;
Index: llvm/lib/Target/PowerPC/PPCScheduleP9.td
===
--- llvm/lib/Target/PowerPC/PPCScheduleP9.td
+++ llvm/lib/Target/PowerPC/PPCScheduleP9.td
@@ -41,9 +41,9 @@
   let CompleteModel = 1;
 
   // Do not support SPE (Signal Processing Engine), prefixed instructions on
-  // Power 9, paired vector mem ops, PC relative mem ops, or instructions
+  // Power 9, paired vector mem ops, MMA, PC relative mem ops, or instructions
   // introduced in ISA 3.1.
-  let UnsupportedFeatures = [HasSPE, PrefixInstrs, PairedVectorMemops,
+  let UnsupportedFeatures = [HasSPE, PrefixInstrs, PairedVectorMemops, MMA,
  PCRelativeMemops, IsISA3_1];
 }
 
Index: llvm/lib/Target/PowerPC/PPCInstrPrefix.td
===
--- llvm/lib/Target/PowerPC/PPCInstrPrefix.td
+++ llvm/lib/Target/PowerPC/PPCInstrPrefix.td
@@ -504,6 +504,7 @@
 def PrefixInstrs : Predicate<"Subtarget->hasPrefixInstrs()">;
 def IsISA3_1 : Predicate<"Subtarget->isISA3_1()">;
 def PairedVectorMemops : Predicate<"PPCSubTarget->pairedVectorMemops()">;
+def MMA : Predicate<"PPCSubTarget->hasMMA()">;
 
 let Predicates = [PrefixInstrs] in {
   let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
Index: llvm/lib/Target/PowerPC/PPC.td
===
--- llvm/lib/Target/PowerPC/PPC.td
+++ llvm/lib/Target/PowerPC/PPC.td
@@ -238,6 +238,10 @@
   SubtargetFeature<"paired-vector-memops", "PairedVectorMemops", "true",
"32Byte load and store instructions",
[FeatureISA3_0]>;
+def FeatureMMA : SubtargetFeature<"mma", "HasMMA", "true",
+  "Enable MMA instructions",
+  [FeatureP8Vector, FeatureP9Altivec,
+   FeaturePairedVectorMemops]>;
 
 def FeaturePredictableSelectIsExpensive :
   SubtargetFeature<"predictable-select-expensive",
@@ -343,7 +347,8 @@
   // still exist with the exception of those we know are Power9 specific.
   list P10AdditionalFeatures =
 [DirectivePwr10, FeatureISA3_1, FeaturePrefixInstrs,
- 

[PATCH] D84887: [OPENMP]Fix codegen for is_device_ptr component, captured by reference.

2020-08-24 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 287396.
ABataev added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84887

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


Index: clang/test/OpenMP/target_is_device_ptr_codegen.cpp
===
--- clang/test/OpenMP/target_is_device_ptr_codegen.cpp
+++ clang/test/OpenMP/target_is_device_ptr_codegen.cpp
@@ -285,4 +285,41 @@
   ++arg;
 }
 #endif
+///==///
+// RUN: %clang_cc1 -DCK3 -verify -fopenmp 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple 
powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefix 
CK3 --check-prefix CK3-64
+// RUN: %clang_cc1 -DCK3 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ 
-triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s 
-emit-llvm -o - | FileCheck %s  --check-prefix CK3 --check-prefix CK3-64
+// RUN: %clang_cc1 -DCK3 -verify -fopenmp -fopenmp-targets=i386-pc-linux-gnu 
-x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s  
--check-prefix CK3 --check-prefix CK3-32
+// RUN: %clang_cc1 -DCK3 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ 
-std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple 
i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | 
FileCheck %s  --check-prefix CK3 --check-prefix CK3-32
+
+// RUN: %clang_cc1 -DCK3 -verify -fopenmp-simd 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple 
powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck --check-prefix 
SIMD-ONLY1 %s
+// RUN: %clang_cc1 -DCK3 -fopenmp-simd 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple 
powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x 
c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s 
-emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY1 %s
+// RUN: %clang_cc1 -DCK3 -verify -fopenmp-simd 
-fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown 
-emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY1 %s
+// RUN: %clang_cc1 -DCK3 -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x 
c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x c++ 
-triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm 
-o - | FileCheck --check-prefix SIMD-ONLY1 %s
+// SIMD-ONLY1-NOT: {{__kmpc|__tgt}}
+#ifdef CK3
+
+// CK3-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i[[SZ:64|32]]] [i{{64|32}} 
{{8|4}}]
+// OMP_MAP_TARGET_PARAM = 0x20 | OMP_MAP_TO = 0x1 = 0x21
+// CK3-DAG: [[TYPES:@.+]] = {{.+}}constant [1 x i64] [i64 [[#0x21]]]
+void bar() {
+  __attribute__((aligned(64))) double *ptr;
+  // CK3-DAG: call i32 @__tgt_target_mapper(i64 {{.+}}, i8* {{.+}}, i32 1, 
i8** [[BPGEP:%[0-9]+]], i8** [[PGEP:%[0-9]+]], {{.+}}[[SIZES]]{{.+}}, 
{{.+}}[[TYPES]]{{.+}}, i8** null)
+  // CK3-DAG: [[BPGEP]] = getelementptr inbounds {{.+}}[[BPS:%[^,]+]], i32 0, 
i32 0
+  // CK3-DAG: [[PGEP]] = getelementptr inbounds {{.+}}[[PS:%[^,]+]], i32 0, 
i32 0
+  // CK3-DAG: [[BP1:%.+]] = getelementptr inbounds {{.+}}[[BPS]], i32 0, i32 0
+  // CK3-DAG: [[P1:%.+]] = getelementptr inbounds {{.+}}[[PS]], i32 0, i32 0
+  // CK3-DAG: [[CBP1:%.+]] = bitcast i8** [[BP1]] to double***
+  // CK3-DAG: [[CP1:%.+]] = bitcast i8** [[P1]] to double***
+  // CK3-DAG: store double** [[PTR:%.+]], double*** [[CBP1]]
+  // CK3-DAG: store double** [[PTR]], double*** [[CP1]]
+
+  // CK3: call void [[KERNEL:@.+]](double** [[PTR]])
+#pragma omp target is_device_ptr(ptr)
+  *ptr = 0;
+}
+#endif
 #endif
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -8436,10 +8436,12 @@
 if (DevPointersMap.count(VD)) {
   CombinedInfo.BasePointers.emplace_back(Arg, VD);
   CombinedInfo.Pointers.push_back(Arg);
-  CombinedInfo.Sizes.push_back(
-  
CGF.Builder.CreateIntCast(CGF.getTypeSize(CGF.getContext().VoidPtrTy),
-CGF.Int64Ty, /*isSigned=*/true));
-  CombinedInfo.Types.push_back(OMP_MAP_LITERAL | OMP_MAP_TARGET_PARAM);
+  CombinedInfo.Sizes.push_back(CGF.Builder.CreateIntCast(
+  CGF.getTypeSize(CGF.getContext().VoidPtrTy), CGF.Int64Ty,
+  /*isSigned=*/true));
+  CombinedInfo.Types.push_back(
+  (Cap->capturesVariable() ? OMP_MAP_TO : OMP_M

[PATCH] D86295: [analyzer] Reorder the layout of MemRegion and cache by hand for optimal size

2020-08-24 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

In D86295#2233694 , @vsavchenko wrote:

> And what is the error right now?

F12760388: error.txt 

BTW this sort of ping-pong should be done on a different forum, eg. on the 
Static Analyzer Discord channel of LLVM. Just saying.
You already know what I think about this since we discussed that on the mailing 
list .
Don't take it wrong, I would love it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86295

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


[clang] c9b45ce - [clang][NFC] Fix a GCC warning in ASTImporterTest.cpp

2020-08-24 Thread Raphael Isemann via cfe-commits

Author: Raphael Isemann
Date: 2020-08-24T17:10:55+02:00
New Revision: c9b45ce1fd97531c228e092bedee719b971f82a3

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

LOG: [clang][NFC] Fix a GCC warning in ASTImporterTest.cpp

Apparently only overriding one of the two CompleteType overloads causes
GCC to emit a warning with -Woverloaded-virtual .

Added: 


Modified: 
clang/unittests/AST/ASTImporterTest.cpp

Removed: 




diff  --git a/clang/unittests/AST/ASTImporterTest.cpp 
b/clang/unittests/AST/ASTImporterTest.cpp
index 9cab6cca0dc4..ecddd4d43752 100644
--- a/clang/unittests/AST/ASTImporterTest.cpp
+++ b/clang/unittests/AST/ASTImporterTest.cpp
@@ -5803,6 +5803,7 @@ struct SourceWithCompletedTagList : 
clang::ExternalASTSource {
 Record->completeDefinition();
 CompletedTags.push_back(Tag);
   }
+  void CompleteType(ObjCInterfaceDecl *) override {}
 };
 
 TEST_P(ImportWithExternalSource, CompleteRecordBeforeImporting) {



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


[PATCH] D85635: [clangd] Compute the inactive code range for semantic highlighting.

2020-08-24 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 287405.
hokein marked an inline comment as done.
hokein added a comment.
Herald added a subscriber: mgrang.

address comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85635

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

Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -503,11 +503,11 @@
 
   #define $Macro[[test]]
   #undef $Macro[[test]]
-$InactiveCode[[]]  #ifdef $Macro[[test]]
-$InactiveCode[[]]  #endif
+$InactiveCode[[#ifdef test]]
+$InactiveCode[[#endif]]
 
-$InactiveCode[[]]  #if defined($Macro[[test]])
-$InactiveCode[[]]  #endif
+$InactiveCode[[#if defined(test)]]
+$InactiveCode[[#endif]]
 )cpp",
   R"cpp(
   struct $Class[[S]] {
@@ -614,8 +614,8 @@
   R"cpp(
   // Code in the preamble.
   // Inactive lines get an empty InactiveCode token at the beginning.
-$InactiveCode[[]]  #ifdef $Macro[[test]]
-$InactiveCode[[]]  #endif
+$InactiveCode[[#ifdef test]]
+$InactiveCode[[#endif]]
 
   // A declaration to cause the preamble to end.
   int $Variable[[EndPreamble]];
@@ -623,17 +623,17 @@
   // Code after the preamble.
   // Code inside inactive blocks does not get regular highlightings
   // because it's not part of the AST.
-$InactiveCode[[]]  #ifdef $Macro[[test]]
-$InactiveCode[[]]  int Inactive2;
-$InactiveCode[[]]  #endif
+$InactiveCode[[#ifdef test]]
+$InactiveCode[[int Inactive2;]]
+$InactiveCode[[#endif]]
 
   #ifndef $Macro[[test]]
   int $Variable[[Active1]];
   #endif
 
-$InactiveCode[[]]  #ifdef $Macro[[test]]
-$InactiveCode[[]]  int Inactive3;
-$InactiveCode[[]]  #else
+$InactiveCode[[#ifdef test]]
+$InactiveCode[[int Inactive3;]]
+$InactiveCode[[#else]]
   int $Variable[[Active2]];
   #endif
 )cpp",
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -221,23 +221,51 @@
   // the end of the Tokens).
   TokRef = TokRef.drop_front(Conflicting.size());
 }
-// Add tokens indicating lines skipped by the preprocessor.
-for (const Range &R : AST.getMacros().SkippedRanges) {
+const auto &SM = AST.getSourceManager();
+StringRef MainCode = SM.getBuffer(SM.getMainFileID())->getBuffer();
+
+// Merge token stream with "inactive line" markers.
+std::vector WithInactiveLines;
+auto SortedSkippedRanges = AST.getMacros().SkippedRanges;
+llvm::sort(SortedSkippedRanges);
+auto It = NonConflicting.begin();
+for (const Range &R : SortedSkippedRanges) {
   // Create one token for each line in the skipped range, so it works
   // with line-based diffing.
   assert(R.start.line <= R.end.line);
   for (int Line = R.start.line; Line <= R.end.line; ++Line) {
-// Don't bother computing the offset for the end of the line, just use
-// zero. The client will treat this highlighting kind specially, and
-// highlight the entire line visually (i.e. not just to where the text
-// on the line ends, but to the end of the screen).
-NonConflicting.push_back({HighlightingKind::InactiveCode,
-  {Position{Line, 0}, Position{Line, 0}}});
+// Copy tokens before the inactive line
+for (; It != NonConflicting.end() && It->R.start.line < Line; ++It)
+  WithInactiveLines.push_back(std::move(*It));
+// Add a token for the inactive line itself.
+auto StartOfLine = positionToOffset(MainCode, Position{Line, 0});
+if (StartOfLine) {
+  StringRef LineText =
+  MainCode.drop_front(*StartOfLine).take_until([](char C) {
+return C == '\n';
+  });
+  WithInactiveLines.push_back(
+  {HighlightingKind::InactiveCode,
+   {Position{Line, 0},
+Position{Line, static_cast(lspLength(LineText))}}});
+} else {
+  elog("Failed to convert position to offset: {0}",
+   StartOfLine.takeError());
+}
+
+// Skip any other tokens on the inactive line. e.g.
+// `#ifndef Foo` is considered as part of an inactive region when Foo is
+// defined, and there is a Foo macro token.
+// FIXME: we should reduce the scope of the inactive region to not
+// include the directive itself.
+while (It != NonConflicting.end() && It->R.start.line == Line)
+  ++It;
   }
 }
- 

[PATCH] D86424: [clang] Do not consider the template arguments of bases to be bases themselves

2020-08-24 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added inline comments.



Comment at: clang/lib/Index/IndexTypeSourceInfo.cpp:167
+if (!TraverseTemplateName(TL.getTypePtr()->getTemplateName()))
+  return false;
+

hokein wrote:
> nit: this could be simplified by calling the 
> `base::TraverseTemplateSpecializationTypeLoc`
I don't see how, given that `WalkUpFromTemplateSpecializationTypeLoc()`needs to 
be called with `Relations` containing `RelationIsBaseOf`, while 
`TraverseTemplateArgumentLoc()` needs to be called with `Relations` empty.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86424

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


[PATCH] D85762: [OPENMP]Do not allow threadprivates as base for array-like reduction.

2020-08-24 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 287406.
ABataev added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85762

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/parallel_reduction_messages.cpp


Index: clang/test/OpenMP/parallel_reduction_messages.cpp
===
--- clang/test/OpenMP/parallel_reduction_messages.cpp
+++ clang/test/OpenMP/parallel_reduction_messages.cpp
@@ -92,6 +92,8 @@
 
 S3 h, k;
 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or 
thread local}}
+int *gptr;
+#pragma omp threadprivate(gptr) // expected-note {{defined as threadprivate or 
thread local}}
 
 template// expected-note {{declared here}}
 T tmain(T argc) {
@@ -277,6 +279,8 @@
   m++;
 #pragma omp parallel reduction(task, + : m) // omp45-error 2 {{expected 
expression}} omp45-warning {{missing ':' after reduction identifier - ignoring}}
   m++;
+#pragma omp parallel reduction(+:gptr[:argc]) // expected-error 
{{threadprivate or thread local variable cannot be reduction}}
+  ;
 
   return tmain(argc) + tmain(fl); // expected-note {{in instantiation of 
function template specialization 'tmain' requested here}} expected-note 
{{in instantiation of function template specialization 'tmain' requested 
here}}
 }
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -15116,6 +15116,17 @@
   continue;
 }
   }
+} else {
+  // Threadprivates cannot be shared between threads, so dignose if the 
base
+  // is a threadprivate variable.
+  DSAStackTy::DSAVarData DVar = Stack->getTopDSA(D, /*FromParent=*/false);
+  if (DVar.CKind == OMPC_threadprivate) {
+S.Diag(ELoc, diag::err_omp_wrong_dsa)
+<< getOpenMPClauseName(DVar.CKind)
+<< getOpenMPClauseName(OMPC_reduction);
+reportOriginalDsa(S, Stack, D, DVar);
+continue;
+  }
 }
 
 // Try to find 'declare reduction' corresponding construct before using


Index: clang/test/OpenMP/parallel_reduction_messages.cpp
===
--- clang/test/OpenMP/parallel_reduction_messages.cpp
+++ clang/test/OpenMP/parallel_reduction_messages.cpp
@@ -92,6 +92,8 @@
 
 S3 h, k;
 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
+int *gptr;
+#pragma omp threadprivate(gptr) // expected-note {{defined as threadprivate or thread local}}
 
 template// expected-note {{declared here}}
 T tmain(T argc) {
@@ -277,6 +279,8 @@
   m++;
 #pragma omp parallel reduction(task, + : m) // omp45-error 2 {{expected expression}} omp45-warning {{missing ':' after reduction identifier - ignoring}}
   m++;
+#pragma omp parallel reduction(+:gptr[:argc]) // expected-error {{threadprivate or thread local variable cannot be reduction}}
+  ;
 
   return tmain(argc) + tmain(fl); // expected-note {{in instantiation of function template specialization 'tmain' requested here}} expected-note {{in instantiation of function template specialization 'tmain' requested here}}
 }
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -15116,6 +15116,17 @@
   continue;
 }
   }
+} else {
+  // Threadprivates cannot be shared between threads, so dignose if the base
+  // is a threadprivate variable.
+  DSAStackTy::DSAVarData DVar = Stack->getTopDSA(D, /*FromParent=*/false);
+  if (DVar.CKind == OMPC_threadprivate) {
+S.Diag(ELoc, diag::err_omp_wrong_dsa)
+<< getOpenMPClauseName(DVar.CKind)
+<< getOpenMPClauseName(OMPC_reduction);
+reportOriginalDsa(S, Stack, D, DVar);
+continue;
+  }
 }
 
 // Try to find 'declare reduction' corresponding construct before using
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D86465: [analyzer][solver] Redesign constraint ranges data structure

2020-08-24 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko created this revision.
vsavchenko added reviewers: NoQ, dcoughlin, xazax.hun, Szelethus, 
ASDenysPetrov, steakhal.
Herald added subscribers: cfe-commits, martong, Charusso, dkrupp, donat.nagy, 
mikhail.ramalho, a.sidorin, mgrang, rnkovacs, szepet, baloghadamsoftware.
Herald added a project: clang.
vsavchenko requested review of this revision.

ImmutableSet doesn't seem like the perfect fit for the RangeSet
data structure.  It is good for saving memory in a persistent
setting, but not for the case when the population of the container
is tiny.  This commit replaces RangeSet implementation and
redesigns the most common operations to be more efficient.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86465

Files:
  
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/lib/StaticAnalyzer/Core/RangedConstraintManager.cpp
  clang/unittests/StaticAnalyzer/RangeSetTest.cpp

Index: clang/unittests/StaticAnalyzer/RangeSetTest.cpp
===
--- clang/unittests/StaticAnalyzer/RangeSetTest.cpp
+++ clang/unittests/StaticAnalyzer/RangeSetTest.cpp
@@ -11,120 +11,330 @@
 #include "clang/Basic/SourceManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h"
 #include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/APSInt.h"
+#include "llvm/Support/raw_ostream.h"
+#include "gtest/gtest-typed-test.h"
 #include "gtest/gtest.h"
 
+using namespace clang;
+using namespace ento;
+
 namespace clang {
 namespace ento {
-namespace {
 
-// TestCase contains to lists of ranges.
-// Original one has to be negated.
-// Expected one has to be compared to negated original range.
-template  struct TestCase {
-  RangeSet original;
-  RangeSet expected;
-
-  TestCase(BasicValueFactory &BVF, RangeSet::Factory &F,
-   const std::initializer_list &originalList,
-   const std::initializer_list &expectedList)
-  : original(createRangeSetFromList(BVF, F, originalList)),
-expected(createRangeSetFromList(BVF, F, expectedList)) {}
-
-private:
-  RangeSet createRangeSetFromList(BasicValueFactory &BVF, RangeSet::Factory &F,
-  const std::initializer_list rangeList) {
-llvm::APSInt from(sizeof(T) * 8, std::is_unsigned::value);
-llvm::APSInt to = from;
-RangeSet rangeSet = F.getEmptySet();
-for (auto it = rangeList.begin(); it != rangeList.end(); it += 2) {
-  from = *it;
-  to = *(it + 1);
-  rangeSet = rangeSet.addRange(
-  F, RangeSet(F, BVF.getValue(from), BVF.getValue(to)));
-}
-return rangeSet;
-  }
+template  static std::string toString(const RangeOrSet &Obj) {
+  std::string ObjRepresentation;
+  llvm::raw_string_ostream SS(ObjRepresentation);
+  Obj.print(SS);
+  return SS.str();
+}
+LLVM_ATTRIBUTE_UNUSED static std::string toString(const llvm::APSInt &Point) {
+  return Point.toString(10);
+}
+// We need it here for better fail diagnostics from gtest.
+LLVM_ATTRIBUTE_UNUSED static std::ostream &operator<<(std::ostream &OS,
+  const RangeSet &Set) {
+  return OS << toString(Set);
+}
 
-  void printNegate(const TestCase &TestCase) {
-TestCase.original.print(llvm::dbgs());
-llvm::dbgs() << " => ";
-TestCase.expected.print(llvm::dbgs());
-  }
-};
+} // namespace ento
+} // namespace clang
+
+namespace {
 
-class RangeSetTest : public testing::Test {
-protected:
+template  class RangeSetTest : public testing::Test {
+public:
   // Init block
   std::unique_ptr AST = tooling::buildASTFromCode("struct foo;");
-  ASTContext &context = AST->getASTContext();
-  llvm::BumpPtrAllocator alloc;
-  BasicValueFactory BVF{context, alloc};
-  RangeSet::Factory F;
+  ASTContext &Context = AST->getASTContext();
+  llvm::BumpPtrAllocator Arena;
+  BasicValueFactory BVF{Context, Arena};
+  RangeSet::Factory F{BVF};
   // End init block
 
-  template  void checkNegate() {
-using type = T;
-
-// Use next values of the range {MIN, A, B, MID, C, D, MAX}.
-
-// MID is a value in the middle of the range
-// which unary minus does not affect on,
-// e.g. int8/int32(0), uint8(128), uint32(2147483648).
-
-constexpr type MIN = std::numeric_limits::min();
-constexpr type MAX = std::numeric_limits::max();
-constexpr type MID = std::is_signed::value
- ? 0
- : ~(static_cast(-1) / static_cast(2));
-constexpr type A = MID - static_cast(42 + 42);
-constexpr type B = MID - static_cast(42);
-constexpr type C = -B;
-constexpr type D = -A;
-
-static_assert(MIN < A && A < B && B < MID && MID < C && C < D && D < MAX,
-  "Values shall be in an ascending order");
-
-// Left {[x, y], [x, y]} is what shall be negated.
-// Right {[x, y], [x, y]} is what shall be compared to a negation result.
- 

[PATCH] D84415: [analyzer][StdLibraryFunctionsChecker] Add POSIX pthread handling functions

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

- Remove private ctor of Signature
- Assert a valid signature in Signature::matces


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84415

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

Index: clang/test/Analysis/std-c-library-functions-POSIX.c
===
--- clang/test/Analysis/std-c-library-functions-POSIX.c
+++ clang/test/Analysis/std-c-library-functions-POSIX.c
@@ -95,6 +95,20 @@
 // CHECK: Loaded summary for: ssize_t send(int sockfd, const void *buf, size_t len, int flags)
 // CHECK: Loaded summary for: int socketpair(int domain, int type, int protocol, int sv[2])
 // CHECK: Loaded summary for: int getnameinfo(const struct sockaddr *restrict sa, socklen_t salen, char *restrict node, socklen_t nodelen, char *restrict service, socklen_t servicelen, int flags)
+// CHECK: Loaded summary for: int pthread_cond_signal(pthread_cond_t *cond)
+// CHECK: Loaded summary for: int pthread_cond_broadcast(pthread_cond_t *cond)
+// CHECK: Loaded summary for: int pthread_create(pthread_t *restrict thread, const pthread_attr_t *restrict attr, void *(*start_routine)(void *), void *restrict arg)
+// CHECK: Loaded summary for: int pthread_attr_destroy(pthread_attr_t *attr)
+// CHECK: Loaded summary for: int pthread_attr_init(pthread_attr_t *attr)
+// CHECK: Loaded summary for: int pthread_attr_getstacksize(const pthread_attr_t *restrict attr, size_t *restrict stacksize)
+// CHECK: Loaded summary for: int pthread_attr_getguardsize(const pthread_attr_t *restrict attr, size_t *restrict guardsize)
+// CHECK: Loaded summary for: int pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize)
+// CHECK: Loaded summary for: int pthread_attr_setguardsize(pthread_attr_t *attr, size_t guardsize)
+// CHECK: Loaded summary for: int pthread_mutex_init(pthread_mutex_t *restrict mutex, const pthread_mutexattr_t *restrict attr)
+// CHECK: Loaded summary for: int pthread_mutex_destroy(pthread_mutex_t *mutex)
+// CHECK: Loaded summary for: int pthread_mutex_lock(pthread_mutex_t *mutex)
+// CHECK: Loaded summary for: int pthread_mutex_trylock(pthread_mutex_t *mutex)
+// CHECK: Loaded summary for: int pthread_mutex_unlock(pthread_mutex_t *mutex)
 
 long a64l(const char *str64);
 char *l64a(long value);
@@ -227,6 +241,26 @@
 int socketpair(int domain, int type, int protocol, int sv[2]);
 int getnameinfo(const struct sockaddr *restrict sa, socklen_t salen, char *restrict node, socklen_t nodelen, char *restrict service, socklen_t servicelen, int flags);
 
+typedef union { int x; } pthread_cond_t;
+int pthread_cond_signal(pthread_cond_t *cond);
+int pthread_cond_broadcast(pthread_cond_t *cond);
+typedef union { int x; } pthread_attr_t;
+typedef unsigned long int pthread_t;
+int pthread_create(pthread_t *restrict thread, const pthread_attr_t *restrict attr, void *(*start_routine)(void *), void *restrict arg);
+int pthread_attr_destroy(pthread_attr_t *attr);
+int pthread_attr_init(pthread_attr_t *attr);
+int pthread_attr_getstacksize(const pthread_attr_t *restrict attr, size_t *restrict stacksize);
+int pthread_attr_getguardsize(const pthread_attr_t *restrict attr, size_t *restrict guardsize);
+int pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize);
+int pthread_attr_setguardsize(pthread_attr_t *attr, size_t guardsize);
+typedef union { int x; } pthread_mutex_t;
+typedef union { int x; } pthread_mutexattr_t;
+int pthread_mutex_init(pthread_mutex_t *restrict mutex, const pthread_mutexattr_t *restrict attr);
+int pthread_mutex_destroy(pthread_mutex_t *mutex);
+int pthread_mutex_lock(pthread_mutex_t *mutex);
+int pthread_mutex_trylock(pthread_mutex_t *mutex);
+int pthread_mutex_unlock(pthread_mutex_t *mutex);
+
 // Must have at least one call expression to initialize the summary map.
 int bar(void);
 void foo() {
Index: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -314,7 +314,7 @@
   /// The complete list of constraints that defines a single branch.
   typedef std::vector ConstraintSet;
 
-  using ArgTypes = std::vector;
+  using ArgTypes = std::vector>;
 
   // A placeholder type, we use it whenever we do not care about the concrete
   // type in a Signature.
@@ -324,17 +324,36 @@
   // The signature of a function we want to describe with a summary. This is a
   // concessive signature, meaning there may be irrelevant types in the
   // signature which we do not check against a function with concrete types.
-  struct Signature {
-ArgTypes ArgTys;
+  class Signature {
+  

[PATCH] D84415: [analyzer][StdLibraryFunctionsChecker] Add POSIX pthread handling functions

2020-08-24 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

Thanks @balazske for your comments, you always make an assiduous review!




Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:350
+  } else {
+*this = Signature(Args, *RetTy);
   }

balazske wrote:
> Not very bad but I do not like to call another constructor and assignment 
> here, this can be many redundant operations. It is better to fill the 
> internal arrays here and have a separate assert function that checks for 
> validness (of the internal arrays) instead of the private constructor.
Ok, makes sense, thanks!



Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:378
 
   static QualType getArgType(const FunctionDecl *FD, ArgNo ArgN) {
 assert(FD && "Function must be set");

balazske wrote:
> Check for isInvalid here (with assert)?
We cannot do that, this is not a member function of the Signature, this 
operates on a FuncitonDecl. But it makes sense to add the assert to the 
`mathces` member function.



Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:882
+  const QualType SizePtrTy = getPointerTy(SizeTy);
+  const QualType SizePtrRestrictTy = getRestrictTy(SizePtrTy);
 

balazske wrote:
> Another idea: Have a class that handles all the variants (simple, pointer, 
> const pointer, const restrict pointer, restrict). It can have get functions 
> that compute the type if not done yet, or get every variant at first time 
> even if it is later not used (or has no sense).
> For example create it like `TypeVariants SizeTy{ACtx.getSizeType()};` and 
> then call `SizeTy.getType()`, `SizeTy.asPtr()`, `SizeTy.asPtrRestrict()`, ... 
> .
> ```
I'd rather keep the current form, because I think it makes it easier to compose 
types from different base types (and it is similar to the ASTMatchers in this 
sense).



Comment at: 
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:1026
   Optional FilePtrTy, FilePtrRestrictTy;
   if (FileTy) {
 // FILE *

balazske wrote:
> These `if`s can be removed too (in another patch).
Yep, I am going to create another base patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84415

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


[PATCH] D82663: [CodeGen] Have CodeGen for fixed-point unsigned with padding emit signed operations.

2020-08-24 Thread Bevin Hansson via Phabricator via cfe-commits
ebevhan abandoned this revision.
ebevhan added a comment.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82663

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


[PATCH] D86467: [SyntaxTree] Split `MemberPointer` tests with annotations

2020-08-24 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
eduucaldas requested review of this revision.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86467

Files:
  clang/unittests/Tooling/Syntax/BuildTreeTest.cpp

Index: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -4059,133 +4059,119 @@
   if (!GetParam().isCXX()) {
 return;
   }
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
 struct X {};
-int X::* a;
-const int X::* b;
+[[int X::* a;]]
+[[const int X::* b;]]
 )cpp",
-  R"txt(
-*: TranslationUnit
-|-SimpleDeclaration
-| |-struct
-| |-X
-| |-{
-| |-}
-| `-;
-|-SimpleDeclaration
-| |-int
-| |-SimpleDeclarator
-| | |-MemberPointer
-| | | |-X
-| | | |-::
-| | | `-*
-| | `-a
-| `-;
-`-SimpleDeclaration
-  |-const
-  |-int
-  |-SimpleDeclarator
-  | |-MemberPointer
-  | | |-X
-  | | |-::
-  | | `-*
-  | `-b
-  `-;
-)txt"));
+  {R"txt(
+SimpleDeclaration
+|-int
+|-SimpleDeclarator
+| |-MemberPointer
+| | |-X
+| | |-::
+| | `-*
+| `-a
+`-;
+)txt",
+   R"txt(
+SimpleDeclaration
+|-const
+|-int
+|-SimpleDeclarator
+| |-MemberPointer
+| | |-X
+| | |-::
+| | `-*
+| `-b
+`-;
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, MemberFunctionPointer) {
   if (!GetParam().isCXX()) {
 return;
   }
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
 struct X {
   struct Y {};
 };
-void (X::*xp)();
-void (X::**xpp)(const int*);
+[[void (X::*xp)();]]
+[[void (X::**xpp)(const int*);]]
 // FIXME: Generate the right syntax tree for this type,
 // i.e. create a syntax node for the outer member pointer
-void (X::Y::*xyp)(const int*, char);
+[[void (X::Y::*xyp)(const int*, char);]]
 )cpp",
-  R"txt(
-*: TranslationUnit
-|-SimpleDeclaration
-| |-struct
-| |-X
-| |-{
-| |-SimpleDeclaration
-| | |-struct
-| | |-Y
-| | |-{
-| | |-}
-| | `-;
-| |-}
-| `-;
-|-SimpleDeclaration
-| |-void
-| |-SimpleDeclarator
-| | |-ParenDeclarator
-| | | |-(
-| | | |-MemberPointer
-| | | | |-X
-| | | | |-::
-| | | | `-*
-| | | |-xp
-| | | `-)
-| | `-ParametersAndQualifiers
-| |   |-(
-| |   `-)
-| `-;
-|-SimpleDeclaration
-| |-void
-| |-SimpleDeclarator
-| | |-ParenDeclarator
-| | | |-(
-| | | |-MemberPointer
-| | | | |-X
-| | | | |-::
-| | | | `-*
-| | | |-*
-| | | |-xpp
-| | | `-)
-| | `-ParametersAndQualifiers
-| |   |-(
-| |   |-SimpleDeclaration
-| |   | |-const
-| |   | |-int
-| |   | `-SimpleDeclarator
-| |   |   `-*
-| |   `-)
-| `-;
-`-SimpleDeclaration
-  |-void
-  |-SimpleDeclarator
-  | |-ParenDeclarator
-  | | |-(
-  | | |-X
-  | | |-::
-  | | |-MemberPointer
-  | | | |-Y
-  | | | |-::
-  | | | `-*
-  | | |-xyp
-  | | `-)
-  | `-ParametersAndQualifiers
-  |   |-(
-  |   |-SimpleDeclaration
-  |   | |-const
-  |   | |-int
-  |   | `-SimpleDeclarator
-  |   |   `-*
-  |   |-,
-  |   |-SimpleDeclaration
-  |   | `-char
-  |   `-)
-  `-;
-)txt"));
+  {R"txt(
+SimpleDeclaration
+|-void
+|-SimpleDeclarator
+| |-ParenDeclarator
+| | |-(
+| | |-MemberPointer
+| | | |-X
+| | | |-::
+| | | `-*
+| | |-xp
+| | `-)
+| `-ParametersAndQualifiers
+|   |-(
+|   `-)
+`-;
+)txt",
+   R"txt(
+SimpleDeclaration
+|-void
+|-SimpleDeclarator
+| |-ParenDeclarator
+| | |-(
+| | |-MemberPointer
+| | | |-X
+| | | |-::
+| | | `-*
+| | |-*
+| | |-xpp
+| | `-)
+| `-ParametersAndQualifiers
+|   |-(
+|   |-SimpleDeclaration
+|   | |-const
+|   | |-int
+|   | `-SimpleDeclarator
+|   |   `-*
+|   `-)
+`-;
+)txt",
+   R"txt(
+SimpleDeclaration
+|-void
+|-SimpleDeclarator
+| |-ParenDeclarator
+| | |-(
+| | |-X
+| | |-::
+| | |-MemberPointer
+| | | |-Y
+| | | |-::
+| | | `-*
+| | |-xyp
+| | `-)
+| `-ParametersAndQualifiers
+|   |-(
+|   |-SimpleDeclaration
+|   | |-const
+|   | |-int
+|   | `-SimpleDeclarator
+|   |   `-*
+|   |-,
+|   |-SimpleDeclaration
+|   | `-char
+|   `-)
+`-;
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, ComplexDeclarator) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D84415: [analyzer][StdLibraryFunctionsChecker] Add POSIX pthread handling functions

2020-08-24 Thread Gabor Marton via Phabricator via cfe-commits
martong planned changes to this revision.
martong added a comment.

Planning to rebase this on a dependent patch that uses an API with Optionals.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84415

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


[PATCH] D86308: [CMake][compiler-rt][libunwind] Compile assembly files as ASM not C, unify workarounds

2020-08-24 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor added a comment.

In D86308#2229936 , @tambre wrote:

> In D86308#2229901 , @teemperor wrote:
>
>> Sorry, just got around to check this out. With the new workaround this seems 
>> to work on macOS (the initial patch did produce the same error).
>
> Many thanks!
> I've submitted an upstream CMake MR to hopefully fix this 
> . I'd 
> appreciate if you could test that too. There's an example testcase in CMake 
> issue 20771 .

With that CMake patch your original patch compiles just fine on macOS. Feel 
free to add a FIXME that this workaround can be removed when the CMake version 
you merged this is because the new minimum required. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86308

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


[PATCH] D85960: [AST][FPEnv] Keep FP options in trailing storage of CastExpr

2020-08-24 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added a comment.

In D85960#2218798 , @kpn wrote:

> You mentioned in D85920  a need to merge 
> this review with that review. I don't think that's needed. This code here is 
> farther along. It does everything that D85920 
>  does and has necessary pieces implemented 
> as well.

I think you are right. I looked through D85920 
, in essence it does the same changes as this 
patch. And this patch has better support of serialization and some tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85960

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


[PATCH] D86308: [CMake][compiler-rt][libunwind] Compile assembly files as ASM not C, unify workarounds

2020-08-24 Thread Raul Tambre via Phabricator via cfe-commits
tambre updated this revision to Diff 287421.
tambre added a comment.

Gate Apple workaround behind CMake version 3.19


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86308

Files:
  clang/runtime/CMakeLists.txt
  compiler-rt/cmake/Modules/AddCompilerRT.cmake
  libunwind/src/CMakeLists.txt


Index: libunwind/src/CMakeLists.txt
===
--- libunwind/src/CMakeLists.txt
+++ libunwind/src/CMakeLists.txt
@@ -24,14 +24,10 @@
 UnwindRegistersRestore.S
 UnwindRegistersSave.S
 )
-if (MINGW OR APPLE)
-  # CMake doesn't build assembly sources for windows/gnu targets properly
-  # (up to current CMake, 3.16), so treat them as C files.
-  # Additionally, CMake ignores OSX_ARCHITECTURE for ASM files when targeting
-  # Apple platforms.
-  set_source_files_properties(${LIBUNWIND_ASM_SOURCES}
-  PROPERTIES
-LANGUAGE C)
+
+# See add_asm_sources() in compiler-rt for explanation of this workaround.
+if((APPLE AND CMAKE_VERSION VERSION_LESS 3.19) OR (MINGW AND CMAKE_VERSION 
VERSION_LESS 3.17))
+  set_source_files_properties(${LIBUNWIND_ASM_SOURCES} PROPERTIES LANGUAGE C)
 endif()
 
 set(LIBUNWIND_HEADERS
Index: compiler-rt/cmake/Modules/AddCompilerRT.cmake
===
--- compiler-rt/cmake/Modules/AddCompilerRT.cmake
+++ compiler-rt/cmake/Modules/AddCompilerRT.cmake
@@ -109,11 +109,11 @@
 
 function(add_asm_sources output)
   set(${output} ${ARGN} PARENT_SCOPE)
-  # Xcode will try to compile asm files as C ('clang -x c'), and that will 
fail.
-  if (${CMAKE_GENERATOR} STREQUAL "Xcode")
-enable_language(ASM)
-  else()
-# Pass ASM file directly to the C++ compiler.
+  # CMake doesn't pass the correct architecture for Apple prior to CMake 3.19. 
https://gitlab.kitware.com/cmake/cmake/-/issues/20771
+  # MinGW didn't work correctly with assembly prior to CMake 3.17. 
https://gitlab.kitware.com/cmake/cmake/-/merge_requests/4287 and 
https://reviews.llvm.org/rGb780df052dd2b246a760d00e00f7de9ebdab9d09
+  # Workaround these two issues by compiling as C.
+  # Same workaround used in libunwind. Also update there if changed here.
+  if((APPLE AND CMAKE_VERSION VERSION_LESS 3.19) OR (MINGW AND CMAKE_VERSION 
VERSION_LESS 3.17))
 set_source_files_properties(${ARGN} PROPERTIES LANGUAGE C)
   endif()
 endfunction()
Index: clang/runtime/CMakeLists.txt
===
--- clang/runtime/CMakeLists.txt
+++ clang/runtime/CMakeLists.txt
@@ -75,6 +75,7 @@
 CMAKE_ARGS ${CLANG_COMPILER_RT_CMAKE_ARGS}
-DCMAKE_C_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang
-DCMAKE_CXX_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang++
+   -DCMAKE_ASM_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
-DLLVM_CONFIG_PATH=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-config


Index: libunwind/src/CMakeLists.txt
===
--- libunwind/src/CMakeLists.txt
+++ libunwind/src/CMakeLists.txt
@@ -24,14 +24,10 @@
 UnwindRegistersRestore.S
 UnwindRegistersSave.S
 )
-if (MINGW OR APPLE)
-  # CMake doesn't build assembly sources for windows/gnu targets properly
-  # (up to current CMake, 3.16), so treat them as C files.
-  # Additionally, CMake ignores OSX_ARCHITECTURE for ASM files when targeting
-  # Apple platforms.
-  set_source_files_properties(${LIBUNWIND_ASM_SOURCES}
-  PROPERTIES
-LANGUAGE C)
+
+# See add_asm_sources() in compiler-rt for explanation of this workaround.
+if((APPLE AND CMAKE_VERSION VERSION_LESS 3.19) OR (MINGW AND CMAKE_VERSION VERSION_LESS 3.17))
+  set_source_files_properties(${LIBUNWIND_ASM_SOURCES} PROPERTIES LANGUAGE C)
 endif()
 
 set(LIBUNWIND_HEADERS
Index: compiler-rt/cmake/Modules/AddCompilerRT.cmake
===
--- compiler-rt/cmake/Modules/AddCompilerRT.cmake
+++ compiler-rt/cmake/Modules/AddCompilerRT.cmake
@@ -109,11 +109,11 @@
 
 function(add_asm_sources output)
   set(${output} ${ARGN} PARENT_SCOPE)
-  # Xcode will try to compile asm files as C ('clang -x c'), and that will fail.
-  if (${CMAKE_GENERATOR} STREQUAL "Xcode")
-enable_language(ASM)
-  else()
-# Pass ASM file directly to the C++ compiler.
+  # CMake doesn't pass the correct architecture for Apple prior to CMake 3.19. https://gitlab.kitware.com/cmake/cmake/-/issues/20771
+  # MinGW didn't work correctly with assembly prior to CMake 3.17. https://gitlab.kitware.com/cmake/cmake/-/merge_requests/4287 and https://reviews.llvm.org/rGb780df052dd2b246a760d00e00f7de9ebdab9d09
+  # Workaround these two issues by com

[PATCH] D86308: [CMake][compiler-rt][libunwind] Compile assembly files as ASM not C, unify workarounds

2020-08-24 Thread Raul Tambre via Phabricator via cfe-commits
tambre added a comment.

In D86308#2233934 , @teemperor wrote:

> In D86308#2229936 , @tambre wrote:
>
>> In D86308#2229901 , @teemperor 
>> wrote:
>>
>>> Sorry, just got around to check this out. With the new workaround this 
>>> seems to work on macOS (the initial patch did produce the same error).
>>
>> Many thanks!
>> I've submitted an upstream CMake MR to hopefully fix this 
>> . I'd 
>> appreciate if you could test that too. There's an example testcase in CMake 
>> issue 20771 .
>
> With that CMake patch your original patch compiles just fine on macOS. Feel 
> free to add a FIXME that this workaround can be removed when the CMake 
> version you merged this is because the new minimum required. Thanks!

I've guarded the Apple workaround behind CMake 3.19 version check. I'll ensure 
that the fix on the CMake side makes it into that version.

I'll commit this tomorrow if there are no objections.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86308

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


[PATCH] D86465: [analyzer][solver] Redesign constraint ranges data structure

2020-08-24 Thread Noel Grandin via Phabricator via cfe-commits
grandinj added inline comments.



Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h:88
+  // structure is preferred.
+  using ImplType = llvm::SmallVector;
+

Just curious - if they mostly contain 1 or 2 elements, why is N == 4  here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86465

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


[PATCH] D86469: [SyntaxTree] Split ConstVolatileQualifiers tests

2020-08-24 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
eduucaldas requested review of this revision.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86469

Files:
  clang/unittests/Tooling/Syntax/BuildTreeTest.cpp


Index: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -3962,13 +3962,11 @@
 )txt"));
 }
 
-TEST_P(SyntaxTreeTest, ConstVolatileQualifiers) {
+TEST_P(SyntaxTreeTest, Declaration_ConstVolatileQualifiers_SimpleConst) {
   EXPECT_TRUE(treeDumpEqual(
   R"cpp(
 const int west = -1;
 int const east = 1;
-const int const universal = 0;
-const int const *const *volatile b;
 )cpp",
   R"txt(
 *: TranslationUnit
@@ -3983,25 +3981,45 @@
 | |   `-IntegerLiteralExpression
 | | `-1
 | `-;
-|-SimpleDeclaration
-| |-int
-| |-const
-| |-SimpleDeclarator
-| | |-east
-| | |-=
-| | `-IntegerLiteralExpression
-| |   `-1
-| `-;
-|-SimpleDeclaration
-| |-const
-| |-int
-| |-const
-| |-SimpleDeclarator
-| | |-universal
-| | |-=
-| | `-IntegerLiteralExpression
-| |   `-0
-| `-;
+`-SimpleDeclaration
+  |-int
+  |-const
+  |-SimpleDeclarator
+  | |-east
+  | |-=
+  | `-IntegerLiteralExpression
+  |   `-1
+  `-;
+)txt"));
+}
+
+TEST_P(SyntaxTreeTest, Declaration_ConstVolatileQualifiers_MultipleConst) {
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+const int const universal = 0;
+)cpp",
+  R"txt(
+*: TranslationUnit
+`-SimpleDeclaration
+  |-const
+  |-int
+  |-const
+  |-SimpleDeclarator
+  | |-universal
+  | |-=
+  | `-IntegerLiteralExpression
+  |   `-0
+  `-;
+)txt"));
+}
+
+TEST_P(SyntaxTreeTest, Declaration_ConstVolatileQualifiers_ConstAndVolatile) {
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+const int const *const *volatile b;
+)cpp",
+  R"txt(
+*: TranslationUnit
 `-SimpleDeclaration
   |-const
   |-int


Index: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -3962,13 +3962,11 @@
 )txt"));
 }
 
-TEST_P(SyntaxTreeTest, ConstVolatileQualifiers) {
+TEST_P(SyntaxTreeTest, Declaration_ConstVolatileQualifiers_SimpleConst) {
   EXPECT_TRUE(treeDumpEqual(
   R"cpp(
 const int west = -1;
 int const east = 1;
-const int const universal = 0;
-const int const *const *volatile b;
 )cpp",
   R"txt(
 *: TranslationUnit
@@ -3983,25 +3981,45 @@
 | |   `-IntegerLiteralExpression
 | | `-1
 | `-;
-|-SimpleDeclaration
-| |-int
-| |-const
-| |-SimpleDeclarator
-| | |-east
-| | |-=
-| | `-IntegerLiteralExpression
-| |   `-1
-| `-;
-|-SimpleDeclaration
-| |-const
-| |-int
-| |-const
-| |-SimpleDeclarator
-| | |-universal
-| | |-=
-| | `-IntegerLiteralExpression
-| |   `-0
-| `-;
+`-SimpleDeclaration
+  |-int
+  |-const
+  |-SimpleDeclarator
+  | |-east
+  | |-=
+  | `-IntegerLiteralExpression
+  |   `-1
+  `-;
+)txt"));
+}
+
+TEST_P(SyntaxTreeTest, Declaration_ConstVolatileQualifiers_MultipleConst) {
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+const int const universal = 0;
+)cpp",
+  R"txt(
+*: TranslationUnit
+`-SimpleDeclaration
+  |-const
+  |-int
+  |-const
+  |-SimpleDeclarator
+  | |-universal
+  | |-=
+  | `-IntegerLiteralExpression
+  |   `-0
+  `-;
+)txt"));
+}
+
+TEST_P(SyntaxTreeTest, Declaration_ConstVolatileQualifiers_ConstAndVolatile) {
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+const int const *const *volatile b;
+)cpp",
+  R"txt(
+*: TranslationUnit
 `-SimpleDeclaration
   |-const
   |-int
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D86470: [SyntaxTree] Use annotations on ClassTemplate_MemberClassDefinition test

2020-08-24 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
eduucaldas requested review of this revision.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86470

Files:
  clang/unittests/Tooling/Syntax/BuildTreeTest.cpp


Index: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -3007,55 +3007,37 @@
 )txt"));
 }
 
-TEST_P(SyntaxTreeTest, Templates2) {
+TEST_P(SyntaxTreeTest, ClassTemplate_MemberClassDefinition) {
   if (!GetParam().isCXX()) {
 return;
   }
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
 template  struct X { struct Y; };
-template  struct X::Y {};
+[[template  struct X::Y {};]]
 )cpp",
-  R"txt(
-*: TranslationUnit
-|-TemplateDeclaration
-| |-template
-| |-<
-| |-UnknownDeclaration
-| | |-class
-| | `-T
-| |->
-| `-SimpleDeclaration
-|   |-struct
-|   |-X
-|   |-{
-|   |-SimpleDeclaration
-|   | |-struct
-|   | |-Y
-|   | `-;
-|   |-}
-|   `-;
-`-TemplateDeclaration
-  |-template
-  |-<
-  |-UnknownDeclaration
-  | |-class
-  | `-T
-  |->
-  `-SimpleDeclaration
-|-struct
-|-NestedNameSpecifier
-| |-SimpleTemplateNameSpecifier
-| | |-X
-| | |-<
-| | |-T
-| | `->
-| `-::
-|-Y
-|-{
-|-}
-`-;
-)txt"));
+  {R"txt(
+TemplateDeclaration
+|-template
+|-<
+|-UnknownDeclaration
+| |-class
+| `-T
+|->
+`-SimpleDeclaration
+  |-struct
+  |-NestedNameSpecifier
+  | |-SimpleTemplateNameSpecifier
+  | | |-X
+  | | |-<
+  | | |-T
+  | | `->
+  | `-::
+  |-Y
+  |-{
+  |-}
+  `-;
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, ExplicitClassTemplateInstantation_Definition) {


Index: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -3007,55 +3007,37 @@
 )txt"));
 }
 
-TEST_P(SyntaxTreeTest, Templates2) {
+TEST_P(SyntaxTreeTest, ClassTemplate_MemberClassDefinition) {
   if (!GetParam().isCXX()) {
 return;
   }
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
 template  struct X { struct Y; };
-template  struct X::Y {};
+[[template  struct X::Y {};]]
 )cpp",
-  R"txt(
-*: TranslationUnit
-|-TemplateDeclaration
-| |-template
-| |-<
-| |-UnknownDeclaration
-| | |-class
-| | `-T
-| |->
-| `-SimpleDeclaration
-|   |-struct
-|   |-X
-|   |-{
-|   |-SimpleDeclaration
-|   | |-struct
-|   | |-Y
-|   | `-;
-|   |-}
-|   `-;
-`-TemplateDeclaration
-  |-template
-  |-<
-  |-UnknownDeclaration
-  | |-class
-  | `-T
-  |->
-  `-SimpleDeclaration
-|-struct
-|-NestedNameSpecifier
-| |-SimpleTemplateNameSpecifier
-| | |-X
-| | |-<
-| | |-T
-| | `->
-| `-::
-|-Y
-|-{
-|-}
-`-;
-)txt"));
+  {R"txt(
+TemplateDeclaration
+|-template
+|-<
+|-UnknownDeclaration
+| |-class
+| `-T
+|->
+`-SimpleDeclaration
+  |-struct
+  |-NestedNameSpecifier
+  | |-SimpleTemplateNameSpecifier
+  | | |-X
+  | | |-<
+  | | |-T
+  | | `->
+  | `-::
+  |-Y
+  |-{
+  |-}
+  `-;
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, ExplicitClassTemplateInstantation_Definition) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D85998: Add clang-cl "vctoolsdir" option to specify the location of the msvc toolchain

2020-08-24 Thread Zachary Henkel via Phabricator via cfe-commits
zahen updated this revision to Diff 287425.
zahen edited reviewers, added: aganea; removed: thakis.
zahen added a comment.

Updates as requested


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

https://reviews.llvm.org/D85998

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/MSVC.cpp
  clang/test/Driver/cl-options.c


Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -682,4 +682,7 @@
 // CLANG-NOT: "--dependent-lib=libcmt"
 // CLANG-NOT: "-vectorize-slp"
 
+// RUN: %clang_cl -vctoolsdir "" -### -- %s 2>&1 | FileCheck %s --check-prefix 
VCTOOLSDIR
+// VCTOOLSDIR: "-cc1" "-triple" "x86_64-pc-windows-msvc19.11.0"
+
 void f() { }
Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -66,6 +66,20 @@
 static bool getSystemRegistryString(const char *keyPath, const char *valueName,
 std::string &value, std::string *phValue);
 
+// Check command line arguments to try and find a toolchain.
+static bool
+findVCToolChainViaCommandLine(const ArgList &Args, std::string &Path,
+  MSVCToolChain::ToolsetLayout &VSLayout) {
+  // Don't validate the input; trust the value supplied by the user.
+  // The primary motivation is to prevent unnecessary file and registry access.
+  if (Arg *A = Args.getLastArg(options::OPT__SLASH_vctoolsdir)) {
+Path = A->getValue();
+VSLayout = MSVCToolChain::ToolsetLayout::VS2017OrNewer;
+return true;
+  }
+  return false;
+}
+
 // Check various environment variables to try and find a toolchain.
 static bool findVCToolChainViaEnvironment(std::string &Path,
   MSVCToolChain::ToolsetLayout 
&VSLayout) {
@@ -751,7 +765,8 @@
   // what they want to use.
   // Failing that, just try to find the newest Visual Studio version we can
   // and use its default VC toolchain.
-  findVCToolChainViaEnvironment(VCToolChainPath, VSLayout) ||
+  findVCToolChainViaCommandLine(Args, VCToolChainPath, VSLayout) ||
+  findVCToolChainViaEnvironment(VCToolChainPath, VSLayout) ||
   findVCToolChainViaSetupConfig(VCToolChainPath, VSLayout) ||
   findVCToolChainViaRegistry(VCToolChainPath, VSLayout);
 }
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -4737,6 +4737,8 @@
 def _SLASH_Tp : CLCompileJoinedOrSeparate<"Tp">,
   HelpText<"Treat  as C++ source file">, MetaVarName<"">;
 def _SLASH_TP : CLCompileFlag<"TP">, HelpText<"Treat all source files as C++">;
+def _SLASH_vctoolsdir : CLJoinedOrSeparate<"vctoolsdir">,
+  HelpText<"Path to the VCToolChain">, MetaVarName<"">;
 def _SLASH_volatile_iso : Option<["/", "-"], "volatile:iso", KIND_FLAG>,
   Group<_SLASH_volatile_Group>, Flags<[CLOption, DriverOption]>,
   HelpText<"Volatile loads and stores have standard semantics">;


Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -682,4 +682,7 @@
 // CLANG-NOT: "--dependent-lib=libcmt"
 // CLANG-NOT: "-vectorize-slp"
 
+// RUN: %clang_cl -vctoolsdir "" -### -- %s 2>&1 | FileCheck %s --check-prefix VCTOOLSDIR
+// VCTOOLSDIR: "-cc1" "-triple" "x86_64-pc-windows-msvc19.11.0"
+
 void f() { }
Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -66,6 +66,20 @@
 static bool getSystemRegistryString(const char *keyPath, const char *valueName,
 std::string &value, std::string *phValue);
 
+// Check command line arguments to try and find a toolchain.
+static bool
+findVCToolChainViaCommandLine(const ArgList &Args, std::string &Path,
+  MSVCToolChain::ToolsetLayout &VSLayout) {
+  // Don't validate the input; trust the value supplied by the user.
+  // The primary motivation is to prevent unnecessary file and registry access.
+  if (Arg *A = Args.getLastArg(options::OPT__SLASH_vctoolsdir)) {
+Path = A->getValue();
+VSLayout = MSVCToolChain::ToolsetLayout::VS2017OrNewer;
+return true;
+  }
+  return false;
+}
+
 // Check various environment variables to try and find a toolchain.
 static bool findVCToolChainViaEnvironment(std::string &Path,
   MSVCToolChain::ToolsetLayout &VSLayout) {
@@ -751,7 +765,8 @@
   // what they want to use.
   // Failing that, just try to find the newest Visual Studio version we can
   // and use its default VC toolchain.
-  findVCToolChainViaEnvir

[PATCH] D86465: [analyzer][solver] Redesign constraint ranges data structure

2020-08-24 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added inline comments.



Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h:88
+  // structure is preferred.
+  using ImplType = llvm::SmallVector;
+

grandinj wrote:
> Just curious - if they mostly contain 1 or 2 elements, why is N == 4  here?
Essentially, the main factor is **intuition** 😆 
The main idea here is that allocations are the single most expensive thing 
about ranges, so I want to avoid extra allocations not for 60% of range sets, 
but for 90%.  I still should definitely measure performance difference for 
different values of N and gather some stats about the lengths.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86465

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


[PATCH] D85998: Add clang-cl "vctoolsdir" option to specify the location of the msvc toolchain

2020-08-24 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

Thanks, one more minor thing and it should be good to go.




Comment at: clang/lib/Driver/ToolChains/MSVC.cpp:764
 
   // Check the environment first, since that's probably the user telling us
   // what they want to use.

Please update these comments, and maybe state that the order of execution is 
important (for the reason you mention above)


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

https://reviews.llvm.org/D85998

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


[PATCH] D85330: [SyntaxTree] Extend the syntax tree dump

2020-08-24 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas updated this revision to Diff 287430.
eduucaldas marked an inline comment as done.
eduucaldas added a comment.

Update tests to dump role


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85330

Files:
  clang/include/clang/Tooling/Syntax/Tree.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/Tree.cpp
  clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
  clang/unittests/Tooling/Syntax/TreeTestBase.cpp

Index: clang/unittests/Tooling/Syntax/TreeTestBase.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTestBase.cpp
+++ clang/unittests/Tooling/Syntax/TreeTestBase.cpp
@@ -171,7 +171,7 @@
<< "Source file has syntax errors, they were printed to the test "
   "log";
   }
-  auto Actual = StringRef(Root->dump(*Arena)).trim().str();
+  auto Actual = StringRef(Root->dump(Arena->sourceManager())).trim().str();
   // EXPECT_EQ shows the diff between the two strings if they are different.
   EXPECT_EQ(Tree.trim().str(), Actual);
   if (Actual != Tree.trim().str()) {
@@ -205,7 +205,7 @@
 auto *AnnotatedNode = nodeByRange(AnnotatedRanges[i], Root);
 assert(AnnotatedNode);
 auto AnnotatedNodeDump =
-StringRef(AnnotatedNode->dump(*Arena)).trim().str();
+StringRef(AnnotatedNode->dump(Arena->sourceManager())).trim().str();
 // EXPECT_EQ shows the diff between the two strings if they are different.
 EXPECT_EQ(TreeDumps[i].trim().str(), AnnotatedNodeDump)
 << "Dumps diverged for the code:\n"
Index: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -24,27 +24,27 @@
 void foo() {}
 )cpp",
   R"txt(
-*: TranslationUnit
+TranslationUnit Detached
 |-SimpleDeclaration
-| |-int
-| |-SimpleDeclarator
-| | |-main
+| |-'int'
+| |-SimpleDeclarator SimpleDeclaration_declarator
+| | |-'main'
 | | `-ParametersAndQualifiers
-| |   |-(
-| |   `-)
+| |   |-'(' OpenParen
+| |   `-')' CloseParen
 | `-CompoundStatement
-|   |-{
-|   `-}
+|   |-'{' OpenParen
+|   `-'}' CloseParen
 `-SimpleDeclaration
-  |-void
-  |-SimpleDeclarator
-  | |-foo
+  |-'void'
+  |-SimpleDeclarator SimpleDeclaration_declarator
+  | |-'foo'
   | `-ParametersAndQualifiers
-  |   |-(
-  |   `-)
+  |   |-'(' OpenParen
+  |   `-')' CloseParen
   `-CompoundStatement
-|-{
-`-}
+|-'{' OpenParen
+`-'}' CloseParen
 )txt"));
 }
 
@@ -55,20 +55,20 @@
 int b = 42;
 )cpp",
   R"txt(
-*: TranslationUnit
+TranslationUnit Detached
 |-SimpleDeclaration
-| |-int
-| |-SimpleDeclarator
-| | `-a
-| `-;
+| |-'int'
+| |-SimpleDeclarator SimpleDeclaration_declarator
+| | `-'a'
+| `-';'
 `-SimpleDeclaration
-  |-int
-  |-SimpleDeclarator
-  | |-b
-  | |-=
+  |-'int'
+  |-SimpleDeclarator SimpleDeclaration_declarator
+  | |-'b'
+  | |-'='
   | `-IntegerLiteralExpression
-  |   `-42
-  `-;
+  |   `-'42' LiteralToken
+  `-';'
 )txt"));
 }
 
@@ -78,26 +78,26 @@
 void foo(int a, int b) {}
 )cpp",
   R"txt(
-*: TranslationUnit
+TranslationUnit Detached
 `-SimpleDeclaration
-  |-void
-  |-SimpleDeclarator
-  | |-foo
+  |-'void'
+  |-SimpleDeclarator SimpleDeclaration_declarator
+  | |-'foo'
   | `-ParametersAndQualifiers
-  |   |-(
-  |   |-SimpleDeclaration
-  |   | |-int
-  |   | `-SimpleDeclarator
-  |   |   `-a
-  |   |-,
-  |   |-SimpleDeclaration
-  |   | |-int
-  |   | `-SimpleDeclarator
-  |   |   `-b
-  |   `-)
+  |   |-'(' OpenParen
+  |   |-SimpleDeclaration ParametersAndQualifiers_parameter
+  |   | |-'int'
+  |   | `-SimpleDeclarator SimpleDeclaration_declarator
+  |   |   `-'a'
+  |   |-','
+  |   |-SimpleDeclaration ParametersAndQualifiers_parameter
+  |   | |-'int'
+  |   | `-SimpleDeclarator SimpleDeclaration_declarator
+  |   |   `-'b'
+  |   `-')' CloseParen
   `-CompoundStatement
-|-{
-`-}
+|-'{' OpenParen
+`-'}' CloseParen
 )txt"));
 }
 
@@ -110,36 +110,36 @@
 }
 )cpp",
   {R"txt(
-IfStatement
-|-if
-|-(
+IfStatement CompoundStatement_statement
+|-'if' IntroducerKeyword
+|-'('
 |-IntegerLiteralExpression
-| `-1
-|-)
-`-CompoundStatement
-  |-{
-  `-}
+| `-'1' LiteralToken
+|-')'
+`-CompoundStatement IfStatement_thenStatement
+  |-'{' OpenParen
+  `-'}' CloseParen
   )txt",
R"txt(
-IfStatement
-|-if
-|-(
+IfStatement CompoundStatement_statement
+|-'if' IntroducerKeyword
+|-'('
 |-IntegerLiteralExpression
-| `-1
-|-)
-|-CompoundStatement
-| |-{
-| `-}
-|-else
-`-IfStatement
-  |-if
-  |-(
+| `-'1' LiteralToken
+|-')'
+|-CompoundStatement IfStatement_thenStatement
+| |-'{' OpenParen
+| `-'}' CloseParen
+|-'else' IfStatement_elseKeyword
+`-IfStatement IfStatement_elseStatement
+  |-'if' IntroducerKeyword
+  |-'('
   |-IntegerLiteralExpression
-  | `-0
-  |-)
-  `-CompoundStatement
-|-{
-`-}
+  | `-'0' LiteralTok

[PATCH] D81347: Make ASTFileSignature an array of 20 uint8_t instead of 5 uint32_t

2020-08-24 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D81347#2080217 , @aprantl wrote:

> I was going to ask why make this change, but looking at the patch, it's 
> pretty obvious :-)

Might be worth writing it down for everyone else - isn't exactly obvious to me 
(though not a part of the codebase I'm particularly familiar with).




Comment at: clang/include/clang/Basic/Module.h:57
+struct ASTFileSignature : std::array {
+  using BaseT = std::array;
+

Looks like "Base" is the more common name for this purpose (rather than 
"BaseT") across the LLVM project. BaseT makes me think (when I'm reading the 
rest of the code) that's it's a template parameter.



Comment at: clang/include/clang/Basic/Module.h:61
+
+  ASTFileSignature(BaseT S = {{0}}) : BaseT(std::move(S)) {}
+

Bit of a big structure to pass by value - should it be by const ref instead? 
(existing problem with the old code anyway, so no big deal either way)

(also the std::move is a no-op here because std::array has a move 
that's the same as copy, though I don't mind it out of habit/consistency)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81347

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


[PATCH] D85330: [SyntaxTree] Extend the syntax tree dump

2020-08-24 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas updated this revision to Diff 287431.
eduucaldas marked 4 inline comments as done.
eduucaldas added a comment.

- Nits


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85330

Files:
  clang/include/clang/Tooling/Syntax/Tree.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/Tree.cpp
  clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
  clang/unittests/Tooling/Syntax/TreeTestBase.cpp

Index: clang/unittests/Tooling/Syntax/TreeTestBase.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTestBase.cpp
+++ clang/unittests/Tooling/Syntax/TreeTestBase.cpp
@@ -171,7 +171,7 @@
<< "Source file has syntax errors, they were printed to the test "
   "log";
   }
-  auto Actual = StringRef(Root->dump(*Arena)).trim().str();
+  auto Actual = StringRef(Root->dump(Arena->sourceManager())).trim().str();
   // EXPECT_EQ shows the diff between the two strings if they are different.
   EXPECT_EQ(Tree.trim().str(), Actual);
   if (Actual != Tree.trim().str()) {
@@ -205,7 +205,7 @@
 auto *AnnotatedNode = nodeByRange(AnnotatedRanges[i], Root);
 assert(AnnotatedNode);
 auto AnnotatedNodeDump =
-StringRef(AnnotatedNode->dump(*Arena)).trim().str();
+StringRef(AnnotatedNode->dump(Arena->sourceManager())).trim().str();
 // EXPECT_EQ shows the diff between the two strings if they are different.
 EXPECT_EQ(TreeDumps[i].trim().str(), AnnotatedNodeDump)
 << "Dumps diverged for the code:\n"
Index: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -24,27 +24,27 @@
 void foo() {}
 )cpp",
   R"txt(
-*: TranslationUnit
+TranslationUnit Detached
 |-SimpleDeclaration
-| |-int
-| |-SimpleDeclarator
-| | |-main
+| |-'int'
+| |-SimpleDeclarator SimpleDeclaration_declarator
+| | |-'main'
 | | `-ParametersAndQualifiers
-| |   |-(
-| |   `-)
+| |   |-'(' OpenParen
+| |   `-')' CloseParen
 | `-CompoundStatement
-|   |-{
-|   `-}
+|   |-'{' OpenParen
+|   `-'}' CloseParen
 `-SimpleDeclaration
-  |-void
-  |-SimpleDeclarator
-  | |-foo
+  |-'void'
+  |-SimpleDeclarator SimpleDeclaration_declarator
+  | |-'foo'
   | `-ParametersAndQualifiers
-  |   |-(
-  |   `-)
+  |   |-'(' OpenParen
+  |   `-')' CloseParen
   `-CompoundStatement
-|-{
-`-}
+|-'{' OpenParen
+`-'}' CloseParen
 )txt"));
 }
 
@@ -55,20 +55,20 @@
 int b = 42;
 )cpp",
   R"txt(
-*: TranslationUnit
+TranslationUnit Detached
 |-SimpleDeclaration
-| |-int
-| |-SimpleDeclarator
-| | `-a
-| `-;
+| |-'int'
+| |-SimpleDeclarator SimpleDeclaration_declarator
+| | `-'a'
+| `-';'
 `-SimpleDeclaration
-  |-int
-  |-SimpleDeclarator
-  | |-b
-  | |-=
+  |-'int'
+  |-SimpleDeclarator SimpleDeclaration_declarator
+  | |-'b'
+  | |-'='
   | `-IntegerLiteralExpression
-  |   `-42
-  `-;
+  |   `-'42' LiteralToken
+  `-';'
 )txt"));
 }
 
@@ -78,26 +78,26 @@
 void foo(int a, int b) {}
 )cpp",
   R"txt(
-*: TranslationUnit
+TranslationUnit Detached
 `-SimpleDeclaration
-  |-void
-  |-SimpleDeclarator
-  | |-foo
+  |-'void'
+  |-SimpleDeclarator SimpleDeclaration_declarator
+  | |-'foo'
   | `-ParametersAndQualifiers
-  |   |-(
-  |   |-SimpleDeclaration
-  |   | |-int
-  |   | `-SimpleDeclarator
-  |   |   `-a
-  |   |-,
-  |   |-SimpleDeclaration
-  |   | |-int
-  |   | `-SimpleDeclarator
-  |   |   `-b
-  |   `-)
+  |   |-'(' OpenParen
+  |   |-SimpleDeclaration ParametersAndQualifiers_parameter
+  |   | |-'int'
+  |   | `-SimpleDeclarator SimpleDeclaration_declarator
+  |   |   `-'a'
+  |   |-','
+  |   |-SimpleDeclaration ParametersAndQualifiers_parameter
+  |   | |-'int'
+  |   | `-SimpleDeclarator SimpleDeclaration_declarator
+  |   |   `-'b'
+  |   `-')' CloseParen
   `-CompoundStatement
-|-{
-`-}
+|-'{' OpenParen
+`-'}' CloseParen
 )txt"));
 }
 
@@ -110,36 +110,36 @@
 }
 )cpp",
   {R"txt(
-IfStatement
-|-if
-|-(
+IfStatement CompoundStatement_statement
+|-'if' IntroducerKeyword
+|-'('
 |-IntegerLiteralExpression
-| `-1
-|-)
-`-CompoundStatement
-  |-{
-  `-}
+| `-'1' LiteralToken
+|-')'
+`-CompoundStatement IfStatement_thenStatement
+  |-'{' OpenParen
+  `-'}' CloseParen
   )txt",
R"txt(
-IfStatement
-|-if
-|-(
+IfStatement CompoundStatement_statement
+|-'if' IntroducerKeyword
+|-'('
 |-IntegerLiteralExpression
-| `-1
-|-)
-|-CompoundStatement
-| |-{
-| `-}
-|-else
-`-IfStatement
-  |-if
-  |-(
+| `-'1' LiteralToken
+|-')'
+|-CompoundStatement IfStatement_thenStatement
+| |-'{' OpenParen
+| `-'}' CloseParen
+|-'else' IfStatement_elseKeyword
+`-IfStatement IfStatement_elseStatement
+  |-'if' IntroducerKeyword
+  |-'('
   |-IntegerLiteralExpression
-  | `-0
-  |-)
-  `-CompoundStatement
-|-{
-`-}
+  | `-'0' LiteralToken
+  |-')'
+  `-Co

Re: [clang] c9b45ce - [clang][NFC] Fix a GCC warning in ASTImporterTest.cpp

2020-08-24 Thread David Blaikie via cfe-commits
Usually this would be addressed with a "using Base::Function" - makes it
clear you aren't intending to override any base behavior, just want to
continue to expose the full overload set

On Mon, Aug 24, 2020 at 8:11 AM Raphael Isemann via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

>
> Author: Raphael Isemann
> Date: 2020-08-24T17:10:55+02:00
> New Revision: c9b45ce1fd97531c228e092bedee719b971f82a3
>
> URL:
> https://github.com/llvm/llvm-project/commit/c9b45ce1fd97531c228e092bedee719b971f82a3
> DIFF:
> https://github.com/llvm/llvm-project/commit/c9b45ce1fd97531c228e092bedee719b971f82a3.diff
>
> LOG: [clang][NFC] Fix a GCC warning in ASTImporterTest.cpp
>
> Apparently only overriding one of the two CompleteType overloads causes
> GCC to emit a warning with -Woverloaded-virtual .
>
> Added:
>
>
> Modified:
> clang/unittests/AST/ASTImporterTest.cpp
>
> Removed:
>
>
>
>
> 
> diff  --git a/clang/unittests/AST/ASTImporterTest.cpp
> b/clang/unittests/AST/ASTImporterTest.cpp
> index 9cab6cca0dc4..ecddd4d43752 100644
> --- a/clang/unittests/AST/ASTImporterTest.cpp
> +++ b/clang/unittests/AST/ASTImporterTest.cpp
> @@ -5803,6 +5803,7 @@ struct SourceWithCompletedTagList :
> clang::ExternalASTSource {
>  Record->completeDefinition();
>  CompletedTags.push_back(Tag);
>}
> +  void CompleteType(ObjCInterfaceDecl *) override {}
>  };
>
>  TEST_P(ImportWithExternalSource, CompleteRecordBeforeImporting) {
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >