[PATCH] D82188: [clang-tidy] Reworked enum options handling(again)

2020-06-21 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 272336.
njames93 added a comment.

- Fix compilation failure on rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82188

Files:
  clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
  clang-tools-extra/clang-tidy/ClangTidyCheck.h
  clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
  clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
  clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
  clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp
  clang-tools-extra/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp
  clang-tools-extra/clang-tidy/modernize/ReplaceRandomShuffleCheck.cpp
  clang-tools-extra/clang-tidy/performance/MoveConstructorInitCheck.cpp
  clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.cpp
  clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
  clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
  clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h
  clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp
  clang-tools-extra/clang-tidy/utils/IncludeSorter.h
  clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
  clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp

Index: clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
@@ -6,6 +6,20 @@
 
 namespace clang {
 namespace tidy {
+
+enum class Colours { Red, Orange, Yellow, Green, Blue, Indigo, Violet };
+
+template <> struct OptionEnumMapping {
+  static llvm::ArrayRef> getEnumMapping() {
+static constexpr std::pair Mapping[] = {
+{Colours::Red, "Red"},   {Colours::Orange, "Orange"},
+{Colours::Yellow, "Yellow"}, {Colours::Green, "Green"},
+{Colours::Blue, "Blue"}, {Colours::Indigo, "Indigo"},
+{Colours::Violet, "Violet"}};
+return makeArrayRef(Mapping);
+  }
+};
+
 namespace test {
 
 TEST(ParseLineFilter, EmptyFilter) {
@@ -209,15 +223,6 @@
 }
 
 TEST(ValidConfiguration, ValidEnumOptions) {
-
-  enum class Colours { Red, Orange, Yellow, Green, Blue, Indigo, Violet };
-  static constexpr std::pair Mapping[] = {
-  {"Red", Colours::Red},   {"Orange", Colours::Orange},
-  {"Yellow", Colours::Yellow}, {"Green", Colours::Green},
-  {"Blue", Colours::Blue}, {"Indigo", Colours::Indigo},
-  {"Violet", Colours::Violet}};
-  static const auto Map = makeArrayRef(Mapping);
-
   ClangTidyOptions Options;
   auto  = Options.CheckOptions;
 
@@ -237,29 +242,30 @@
 #define CHECK_ERROR_ENUM(Name, Expected)   \
   CHECK_ERROR(Name, UnparseableEnumOptionError, Expected)
 
-  CHECK_VAL(TestCheck.getLocal("Valid", Map), Colours::Red);
-  CHECK_VAL(TestCheck.getGlobal("GlobalValid", Map), Colours::Violet);
-  CHECK_VAL(TestCheck.getLocal("ValidWrongCase", Map, /*IgnoreCase*/ true),
-Colours::Red);
+  CHECK_VAL(TestCheck.getIntLocal("Valid"), Colours::Red);
+  CHECK_VAL(TestCheck.getIntGlobal("GlobalValid"), Colours::Violet);
   CHECK_VAL(
-  TestCheck.getGlobal("GlobalValidWrongCase", Map, /*IgnoreCase*/ true),
-  Colours::Violet);
-  CHECK_ERROR_ENUM(TestCheck.getLocal("Invalid", Map),
+  TestCheck.getIntLocal("ValidWrongCase", /*IgnoreCase*/ true),
+  Colours::Red);
+  CHECK_VAL(TestCheck.getIntGlobal("GlobalValidWrongCase",
+/*IgnoreCase*/ true),
+Colours::Violet);
+  CHECK_ERROR_ENUM(TestCheck.getIntLocal("Invalid"),
"invalid configuration value "
"'Scarlet' for option 'test.Invalid'");
-  CHECK_ERROR_ENUM(TestCheck.getLocal("ValidWrongCase", Map),
+  CHECK_ERROR_ENUM(TestCheck.getIntLocal("ValidWrongCase"),
"invalid configuration value 'rED' for option "
"'test.ValidWrongCase'; did you mean 'Red'?");
-  CHECK_ERROR_ENUM(TestCheck.getLocal("NearMiss", Map),
+  CHECK_ERROR_ENUM(TestCheck.getIntLocal("NearMiss"),
"invalid configuration value 'Oragne' for option "
"'test.NearMiss'; did you mean 'Orange'?");
-  CHECK_ERROR_ENUM(TestCheck.getGlobal("GlobalInvalid", Map),
+  CHECK_ERROR_ENUM(TestCheck.getIntGlobal("GlobalInvalid"),
"invalid configuration value "
"'Purple' for option 'GlobalInvalid'");
-  CHECK_ERROR_ENUM(TestCheck.getGlobal("GlobalValidWrongCase", Map),
+  CHECK_ERROR_ENUM(TestCheck.getIntGlobal("GlobalValidWrongCase"),
"invalid configuration value 'vIOLET' for option "
   

[PATCH] D79796: Sketch support for generating CC1 command line from CompilerInvocation

2020-06-21 Thread Daniel Grumberg via Phabricator via cfe-commits
dang marked 3 inline comments as done.
dang added inline comments.



Comment at: llvm/utils/TableGen/OptParserEmitter.cpp:430-440
+  std::vector> OptsWithMarshalling;
+  for (unsigned I = 0, E = Opts.size(); I != E; ++I) {
+const Record  = *Opts[I];
 
+// Start a single option entry.
+OS << "OPTION(";
+WriteOptRecordFields(OS, R);

Bigcheese wrote:
> Just to verify, this doesn't change the output for options that don't have 
> marshalling info, right? Just want to make sure this doesn't change anything 
> for other users of libOption.
Yes of course all the previous behavior is in the `WriteOptRecordFields` lambda 
capture. This adds an entirely new macro table and leaves the existing one 
untouched.



Comment at: llvm/utils/TableGen/OptParserEmitter.cpp:468-469
+  OS << "};\n";
+  OS << "static const unsigned SimpleEnumValueTablesSize = "
+"sizeof(SimpleEnumValueTables) / sizeof(SimpleEnumValueTable);\n";
+

Bigcheese wrote:
> What happens if there are none?
There is never going to be none as there currently already is an enum-based 
option that uses this setup, but it would still be nice to have a guard for 
that. Getting on it...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79796



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


[PATCH] D79796: Sketch support for generating CC1 command line from CompilerInvocation

2020-06-21 Thread Daniel Grumberg via Phabricator via cfe-commits
dang marked 2 inline comments as done.
dang added inline comments.



Comment at: llvm/utils/TableGen/OptParserEmitter.cpp:468-469
+  OS << "};\n";
+  OS << "static const unsigned SimpleEnumValueTablesSize = "
+"sizeof(SimpleEnumValueTables) / sizeof(SimpleEnumValueTable);\n";
+

dang wrote:
> Bigcheese wrote:
> > What happens if there are none?
> There is never going to be none as there currently already is an enum-based 
> option that uses this setup, but it would still be nice to have a guard for 
> that. Getting on it...
Actually this does not need any changes, it will correctly report 0 if there 
are no value tables.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79796



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


[PATCH] D82020: PowerPC-specific builtin constrained FP enablement

2020-06-21 Thread Andrew J Wock via Phabricator via cfe-commits
ajwock updated this revision to Diff 272330.
ajwock added a comment.

It seems one of the issues that my tests revealed was already remedied in very 
recent changes, causing my test to fail. I changed the test to reflect that 
while also taking steven's recommendations.


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

https://reviews.llvm.org/D82020

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-ppc-fpconstrained.c

Index: clang/test/CodeGen/builtins-ppc-fpconstrained.c
===
--- /dev/null
+++ clang/test/CodeGen/builtins-ppc-fpconstrained.c
@@ -0,0 +1,159 @@
+// REQUIRES: powerpc-registered-target
+// RUN: %clang_cc1 -triple powerpc64le-gnu-linux -target-feature +vsx \
+// RUN: -emit-llvm %s -o - | FileCheck --check-prefix=CHECK-UNCONSTRAINED %s
+// RUN: %clang_cc1 -triple powerpc64le-gnu-linux -target-feature +vsx \
+// RUN:  -ffp-exception-behavior=strict -emit-llvm %s -o - | FileCheck \
+// RUN: --check-prefix=CHECK-CONSTRAINED -vv %s
+// RUN: %clang_cc1 -triple powerpc64le-gnu-linux -target-feature +vsx \
+// RUN: -fallow-half-arguments-and-returns -S -o - %s | \
+// RUN: FileCheck --check-prefix=CHECK-ASM --check-prefix=NOT-FIXME-CHECK  %s
+// RUN: %clang_cc1 -triple powerpc64le-gnu-linux -target-feature +vsx \
+// RUN: -fallow-half-arguments-and-returns -S -ffp-exception-behavior=strict \
+// RUN: -o - %s | FileCheck --check-prefix=CHECK-ASM \
+// RUN: --check-prefix=FIXME-CHECK  %s
+
+typedef __attribute__((vector_size(4 * sizeof(float float vec_float;
+typedef __attribute__((vector_size(2 * sizeof(double double vec_double;
+
+volatile vec_double vd;
+volatile vec_float vf;
+
+void test_float(void) {
+  vf = __builtin_vsx_xvsqrtsp(vf);
+  // CHECK-LABEL: try-xvsqrtsp
+  // CHECK-UNCONSTRAINED: @llvm.sqrt.v4f32(<4 x float> %{{.*}})
+  // CHECK-CONSTRAINED: @llvm.experimental.constrained.sqrt.v4f32(<4 x float> %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
+  // CHECK-ASM: xvsqrtsp
+
+  vd = __builtin_vsx_xvsqrtdp(vd);
+  // CHECK-LABEL: try-xvsqrtdp
+  // CHECK-UNCONSTRAINED: @llvm.sqrt.v2f64(<2 x double> %{{.*}})
+  // CHECK-CONSTRAINED: @llvm.experimental.constrained.sqrt.v2f64(<2 x double> %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
+  // CHECK-ASM: xvsqrtdp
+
+  vf = __builtin_vsx_xvrspim(vf);
+  // CHECK-LABEL: try-xvrspim
+  // CHECK-UNCONSTRAINED: @llvm.floor.v4f32(<4 x float> %{{.*}})
+  // CHECK-CONSTRAINED: @llvm.experimental.constrained.floor.v4f32(<4 x float> %{{.*}}, metadata !"fpexcept.strict")
+  // CHECK-ASM: xvrspim
+
+  vd = __builtin_vsx_xvrdpim(vd);
+  // CHECK-LABEL: try-xvrdpim
+  // CHECK-UNCONSTRAINED: @llvm.floor.v2f64(<2 x double> %{{.*}})
+  // CHECK-CONSTRAINED: @llvm.experimental.constrained.floor.v2f64(<2 x double> %{{.*}}, metadata !"fpexcept.strict")
+  // CHECK-ASM: xvrdpim
+
+  vf = __builtin_vsx_xvrspi(vf);
+  // CHECK-LABEL: try-xvrspi
+  // CHECK-UNCONSTRAINED: @llvm.round.v4f32(<4 x float> %{{.*}})
+  // CHECK-CONSTRAINED: @llvm.experimental.constrained.round.v4f32(<4 x float> %{{.*}}, metadata !"fpexcept.strict")
+  // CHECK-ASM: xvrspi
+
+  vd = __builtin_vsx_xvrdpi(vd);
+  // CHECK-LABEL: try-xvrdpi
+  // CHECK-UNCONSTRAINED: @llvm.round.v2f64(<2 x double> %{{.*}})
+  // CHECK-CONSTRAINED: @llvm.experimental.constrained.round.v2f64(<2 x double> %{{.*}}, metadata !"fpexcept.strict")
+  // CHECK-ASM: xvrdpi
+
+  vf = __builtin_vsx_xvrspic(vf);
+  // CHECK-LABEL: try-xvrspic
+  // CHECK-UNCONSTRAINED: @llvm.nearbyint.v4f32(<4 x float> %{{.*}})
+  // CHECK-CONSTRAINED: @llvm.experimental.constrained.nearbyint.v4f32(<4 x float> %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
+  // CHECK-ASM: xvrspic
+
+  vd = __builtin_vsx_xvrdpic(vd);
+  // CHECK-LABEL: try-xvrdpic
+  // CHECK-UNCONSTRAINED: @llvm.nearbyint.v2f64(<2 x double> %{{.*}})
+  // CHECK-CONSTRAINED: @llvm.experimental.constrained.nearbyint.v2f64(<2 x double> %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
+  // CHECK-ASM: xvrdpic
+
+  vf = __builtin_vsx_xvrspip(vf);
+  // CHECK-LABEL: try-xvrspip
+  // CHECK-UNCONSTRAINED: @llvm.ceil.v4f32(<4 x float> %{{.*}})
+  // CHECK-CONSTRAINED: @llvm.experimental.constrained.ceil.v4f32(<4 x float> %{{.*}}, metadata !"fpexcept.strict")
+  // CHECK-ASM: xvrspip
+
+  vd = __builtin_vsx_xvrdpip(vd);
+  // CHECK-LABEL: try-xvrdpip
+  // CHECK-UNCONSTRAINED: @llvm.ceil.v2f64(<2 x double> %{{.*}})
+  // CHECK-CONSTRAINED: @llvm.experimental.constrained.ceil.v2f64(<2 x double> %{{.*}}, metadata !"fpexcept.strict")
+  // CHECK-ASM: xvrdpip
+
+  vf = __builtin_vsx_xvrspiz(vf);
+  // CHECK-LABEL: try-xvrspiz
+  // CHECK-UNCONSTRAINED: @llvm.trunc.v4f32(<4 x float> %{{.*}})
+  // CHECK-CONSTRAINED: @llvm.experimental.constrained.trunc.v4f32(<4 x float> %{{.*}}, metadata !"fpexcept.strict")
+  // CHECK-ASM: xvrspiz
+
+  vd = __builtin_vsx_xvrdpiz(vd);
+  // CHECK-LABEL: try-xvrdpiz
+  

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

2020-06-21 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/test/Layout/aix-double-struct-member.cpp:1
+// RUN: %clang_cc1 -emit-llvm-only -triple powerpc-ibm-aix-xcoff \
+// RUN: -fdump-record-layouts -fsyntax-only %s 2>/dev/null | \

There's no testing for `_Complex` types.
```
struct A {
  struct B {
long double _Complex d[3];
  } b;
};

extern char x[__alignof__(struct A)];
extern char x[8];
```



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79719



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


[PATCH] D82020: PowerPC-specific builtin constrained FP enablement

2020-06-21 Thread Qing Shan Zhang via Phabricator via cfe-commits
steven.zhang added a comment.

LGTM overall with some minor comments.




Comment at: clang/lib/CodeGen/CGBuiltin.cpp:14238
  BuiltinID == PPC::BI__builtin_vsx_xvrspi)
-  ID = Intrinsic::round;
+  ID = Builder.getIsFPConstrained() ? 
Intrinsic::experimental_constrained_round : Intrinsic::round;
 else if (BuiltinID == PPC::BI__builtin_vsx_xvrdpic ||

line too long. Please format the code with clang-format. 



Comment at: clang/test/CodeGen/builtins-ppc-fpconstrained.c:4
+// RUN: -disable-O0-optnone -Wall -Wno-unused -Werror -emit-llvm %s -o - | \
+// RUN: FileCheck --check-prefix=CHECK-UNCONSTRAINED -vv %s
+// RUN: %clang_cc1 -triple powerpc64le-gnu-linux -target-feature +vsx \

Do we have to specify option "-disable-O0-optnone -Wall -Wno-unused -Werror" ?


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

https://reviews.llvm.org/D82020



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


[PATCH] D82259: Deprecate error prone temporary directory APIs

2020-06-21 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:3177
   llvm::sys::path::append(Result, "ModuleCache");
 }
 

This default path is not ideal for Linux.  On Linux, if we want to put this 
into the home directory, we should follow XDG and put this into the 
`~/.cache/org.llvm.clang/ModuleCache`, respecting the environment variable 
`XDG_CACHE_DIR`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82259



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


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

2020-06-21 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1887
+  if (BTy->isFloatingPoint()) {
+PreferredAlign = FieldSize;
+  }

I tried `clang -cc1 -triple powerpc-ibm-aix -fsyntax-only` with
:
```
struct A {
  struct B {
double d[3];
  } b;
};

extern char x[__alignof__(struct A)];
extern char x[8];
```

I got an assertion failure:
```
clang: /src/clang/lib/AST/RecordLayoutBuilder.cpp:2078: void 
{anonymous}::ItaniumRecordLayoutBuilder::UpdateAlignment(clang::CharUnits, 
clang::CharUnits, clang::CharUnits): Assertion 
`llvm::isPowerOf2_64(PreferredNewAlignment.getQuantity()) && "Alignment not a 
power of 2"' failed.
```



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79719



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


[PATCH] D82279: Handle invalid types in the nullPointerConstant AST matcher

2020-06-21 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added inline comments.



Comment at: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp:2618
+  )";
+  EXPECT_TRUE(matches(kTest, expr(nullPointerConstant(;
 }

While this test in ASTMatchers might continue to make sense, shouldn't there be 
a test in `clang/unittests/AST` for this API? `isNullPointerConstant` seems to 
be complicated. Does it have a unit test?


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

https://reviews.llvm.org/D82279



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


[PATCH] D82281: [clang-tidy] llvm-twine-local ignores parameters

2020-06-21 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added reviewers: bkramer, alexfh, aaron.ballman.
Herald added subscribers: cfe-commits, xazax.hun.
Herald added a project: clang.

Ignore paramater declarations of type `::llvm::Twine`, These don't suffer the 
same use after free risks as local twines.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82281

Files:
  clang-tools-extra/clang-tidy/llvm/TwineLocalCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/llvm-twine-local.cpp


Index: clang-tools-extra/test/clang-tidy/checkers/llvm-twine-local.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/llvm-twine-local.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/llvm-twine-local.cpp
@@ -13,6 +13,7 @@
 using namespace llvm;
 
 void foo(const Twine );
+void bar(Twine x);
 
 static Twine Moo = Twine("bark") + "bah";
 // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: twine variables are prone to 
use-after-free bugs
Index: clang-tools-extra/clang-tidy/llvm/TwineLocalCheck.cpp
===
--- clang-tools-extra/clang-tidy/llvm/TwineLocalCheck.cpp
+++ clang-tools-extra/clang-tidy/llvm/TwineLocalCheck.cpp
@@ -19,8 +19,10 @@
 
 void TwineLocalCheck::registerMatchers(MatchFinder *Finder) {
   auto TwineType =
-  qualType(hasDeclaration(recordDecl(hasName("::llvm::Twine";
-  Finder->addMatcher(varDecl(hasType(TwineType)).bind("variable"), this);
+  qualType(hasDeclaration(cxxRecordDecl(hasName("::llvm::Twine";
+  Finder->addMatcher(
+  varDecl(unless(parmVarDecl()), hasType(TwineType)).bind("variable"),
+  this);
 }
 
 void TwineLocalCheck::check(const MatchFinder::MatchResult ) {


Index: clang-tools-extra/test/clang-tidy/checkers/llvm-twine-local.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/llvm-twine-local.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/llvm-twine-local.cpp
@@ -13,6 +13,7 @@
 using namespace llvm;
 
 void foo(const Twine );
+void bar(Twine x);
 
 static Twine Moo = Twine("bark") + "bah";
 // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: twine variables are prone to use-after-free bugs
Index: clang-tools-extra/clang-tidy/llvm/TwineLocalCheck.cpp
===
--- clang-tools-extra/clang-tidy/llvm/TwineLocalCheck.cpp
+++ clang-tools-extra/clang-tidy/llvm/TwineLocalCheck.cpp
@@ -19,8 +19,10 @@
 
 void TwineLocalCheck::registerMatchers(MatchFinder *Finder) {
   auto TwineType =
-  qualType(hasDeclaration(recordDecl(hasName("::llvm::Twine";
-  Finder->addMatcher(varDecl(hasType(TwineType)).bind("variable"), this);
+  qualType(hasDeclaration(cxxRecordDecl(hasName("::llvm::Twine";
+  Finder->addMatcher(
+  varDecl(unless(parmVarDecl()), hasType(TwineType)).bind("variable"),
+  this);
 }
 
 void TwineLocalCheck::check(const MatchFinder::MatchResult ) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 1d4c873 - [X86] Assign a feature priority to 'tigerlake' so it won't assert when used with function multiversioning

2020-06-21 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2020-06-21T13:24:58-07:00
New Revision: 1d4c87335d5236ea1f35937e1014980ba961ae34

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

LOG: [X86] Assign a feature priority to 'tigerlake' so it won't assert when 
used with function multiversioning

Also test cooperlake since it was also just added to function
multiversioning when it was enabled for __builtin_cpu_is.

Added: 


Modified: 
clang/test/CodeGen/attr-target-mv.c
llvm/include/llvm/Support/X86TargetParser.def

Removed: 




diff  --git a/clang/test/CodeGen/attr-target-mv.c 
b/clang/test/CodeGen/attr-target-mv.c
index 7d7135d567c2..89b219c25fec 100644
--- a/clang/test/CodeGen/attr-target-mv.c
+++ b/clang/test/CodeGen/attr-target-mv.c
@@ -9,6 +9,8 @@ int __attribute__((target("arch=goldmont-plus"))) foo(void) 
{return 4;}
 int __attribute__((target("arch=tremont"))) foo(void) {return 5;}
 int __attribute__((target("arch=icelake-client"))) foo(void) {return 6;}
 int __attribute__((target("arch=icelake-server"))) foo(void) {return 7;}
+int __attribute__((target("arch=cooperlake"))) foo(void) {return 8;}
+int __attribute__((target("arch=tigerlake"))) foo(void) {return 9;}
 int __attribute__((target("default"))) foo(void) { return 2; }
 
 int bar() {
@@ -85,6 +87,10 @@ __attribute__((target("avx,sse4.2"), used)) inline void 
foo_used2(int i, double
 // LINUX: ret i32 6
 // LINUX: define i32 @foo.arch_icelake-server()
 // LINUX: ret i32 7
+// LINUX: define i32 @foo.arch_cooperlake()
+// LINUX: ret i32 8
+// LINUX: define i32 @foo.arch_tigerlake()
+// LINUX: ret i32 9
 // LINUX: define i32 @foo()
 // LINUX: ret i32 2
 // LINUX: define i32 @bar()

diff  --git a/llvm/include/llvm/Support/X86TargetParser.def 
b/llvm/include/llvm/Support/X86TargetParser.def
index afbfd5d26ffe..3c2614b33bf3 100644
--- a/llvm/include/llvm/Support/X86TargetParser.def
+++ b/llvm/include/llvm/Support/X86TargetParser.def
@@ -331,7 +331,7 @@ PROC_WITH_FEAT(IcelakeServer, "icelake-server", 
PROC_64_BIT, FEATURE_AVX512VBMI2
 
 /// \name Tigerlake
 /// Tigerlake microarchitecture based processors.
-PROC(Tigerlake, "tigerlake", PROC_64_BIT)
+PROC_WITH_FEAT(Tigerlake, "tigerlake", PROC_64_BIT, FEATURE_AVX512VP2INTERSECT)
 
 /// \name Knights Landing
 /// Knights Landing processor.



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


[clang] 42c176c - [X86] Add 'cooperlake' and 'tigerlake' to __builtin_cpu_is.

2020-06-21 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2020-06-21T13:03:18-07:00
New Revision: 42c176c32851833f32863412e74235f085adc801

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

LOG: [X86] Add 'cooperlake' and 'tigerlake' to __builtin_cpu_is.

Cooperlake can be detect by compiler-rt now, but not libgcc yet.
Tigerlake can't be detected by either. Both names are accepted by
gcc. Hopefully the detection code will be in place soon.

Added: 


Modified: 
clang/test/CodeGen/target-builtin-noerror.c
llvm/include/llvm/Support/X86TargetParser.def

Removed: 




diff  --git a/clang/test/CodeGen/target-builtin-noerror.c 
b/clang/test/CodeGen/target-builtin-noerror.c
index 54c5a9b7f218..b2d18fa0b2c0 100644
--- a/clang/test/CodeGen/target-builtin-noerror.c
+++ b/clang/test/CodeGen/target-builtin-noerror.c
@@ -101,6 +101,7 @@ void verifycpustrings() {
   (void)__builtin_cpu_is("btver2");
   (void)__builtin_cpu_is("cannonlake");
   (void)__builtin_cpu_is("cascadelake");
+  (void)__builtin_cpu_is("cooperlake");
   (void)__builtin_cpu_is("core2");
   (void)__builtin_cpu_is("corei7");
   (void)__builtin_cpu_is("goldmont");
@@ -120,6 +121,7 @@ void verifycpustrings() {
   (void)__builtin_cpu_is("skylake");
   (void)__builtin_cpu_is("skylake-avx512");
   (void)__builtin_cpu_is("slm");
+  (void)__builtin_cpu_is("tigerlake");
   (void)__builtin_cpu_is("tremont");
   (void)__builtin_cpu_is("westmere");
   (void)__builtin_cpu_is("znver1");

diff  --git a/llvm/include/llvm/Support/X86TargetParser.def 
b/llvm/include/llvm/Support/X86TargetParser.def
index 38d149851413..afbfd5d26ffe 100644
--- a/llvm/include/llvm/Support/X86TargetParser.def
+++ b/llvm/include/llvm/Support/X86TargetParser.def
@@ -110,6 +110,8 @@ X86_CPU_SUBTYPE_COMPAT("icelake-client", 
INTEL_COREI7_ICELAKE_CLIENT, "icelake-c
 X86_CPU_SUBTYPE_COMPAT("icelake-server", INTEL_COREI7_ICELAKE_SERVER, 
"icelake-server")
 X86_CPU_SUBTYPE_COMPAT("znver2", AMDFAM17H_ZNVER2,"znver2")
 X86_CPU_SUBTYPE_COMPAT("cascadelake",INTEL_COREI7_CASCADELAKE,
"cascadelake")
+X86_CPU_SUBTYPE_COMPAT("tigerlake",  INTEL_COREI7_TIGERLAKE,  
"tigerlake")
+X86_CPU_SUBTYPE_COMPAT("cooperlake", INTEL_COREI7_COOPERLAKE, 
"cooperlake")
 // Entries below this are not in libgcc/compiler-rt.
 X86_CPU_SUBTYPE   ("core2",  INTEL_CORE2_65)
 X86_CPU_SUBTYPE   ("penryn", INTEL_CORE2_45)
@@ -117,8 +119,6 @@ X86_CPU_SUBTYPE   ("k6", AMDPENTIUM_K6)
 X86_CPU_SUBTYPE   ("k6-2",   AMDPENTIUM_K62)
 X86_CPU_SUBTYPE   ("k6-3",   AMDPENTIUM_K63)
 X86_CPU_SUBTYPE   ("geode",  AMDPENTIUM_GEODE)
-X86_CPU_SUBTYPE   ("cooperlake", INTEL_COREI7_COOPERLAKE)
-X86_CPU_SUBTYPE   ("tigerlake",  INTEL_COREI7_TIGERLAKE)
 #undef X86_CPU_SUBTYPE_COMPAT
 #undef X86_CPU_SUBTYPE
 



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


[PATCH] D82188: [clang-tidy] Reworked enum options handling(again)

2020-06-21 Thread Nathan James via Phabricator via cfe-commits
njames93 added inline comments.



Comment at: clang-tools-extra/clang-tidy/ClangTidyCheck.h:31-32
+template  struct OptionEnumMapping {
+  // Must provide:
+  // static ArrayRef> getEnumMapping();
+};

aaron.ballman wrote:
> Any reason not to do:
> ```
> static ArrayRef> getEnumMapping() = delete;
> ```
> so you get a nice error if you instantiate something without the required 
> definition?
I need to read the c++ standard, never even realised you could delete static 
functions like that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82188



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


[PATCH] D82162: [clang-tidy] RenamerClangTidy wont emit fixes in scratch space

2020-06-21 Thread Nathan James via Phabricator via cfe-commits
njames93 marked an inline comment as done.
njames93 added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp:570
+
+// We don't want a warning here as the call to this in Foo is in a scratch
+// buffer so its fix-it wouldn't be applied, resulting in invalid code.

aaron.ballman wrote:
> I may be misunderstanding the comment here. I can understand not wanting to 
> generate fixits into the scratch buffer (that would not do good things), but 
> I think we still want a warning were it not for the macro, right? Just 
> verifying that this is not changing warning behaviors, only fix-it behaviors.
You're absolutely right, however right now this fix just marks it as being 
`InsideMacro`. The reason diagnostics aren't emitted is becuase somewhere in 
this checks life someone decided to not emit warnings for declarations with 
usages inside macros. If that behaviour is to be changed a separate patch would 
be required.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82162



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


[PATCH] D82188: [clang-tidy] Reworked enum options handling(again)

2020-06-21 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 272317.
njames93 marked 2 inline comments as done.
njames93 added a comment.

Use `= delete` for getEnumMapping in template definition.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82188

Files:
  clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
  clang-tools-extra/clang-tidy/ClangTidyCheck.h
  clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
  clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
  clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
  clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp
  clang-tools-extra/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp
  clang-tools-extra/clang-tidy/modernize/ReplaceRandomShuffleCheck.cpp
  clang-tools-extra/clang-tidy/performance/MoveConstructorInitCheck.cpp
  clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.cpp
  clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
  clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
  clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h
  clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp
  clang-tools-extra/clang-tidy/utils/IncludeSorter.h
  clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
  clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp

Index: clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
@@ -6,6 +6,20 @@
 
 namespace clang {
 namespace tidy {
+
+enum class Colours { Red, Orange, Yellow, Green, Blue, Indigo, Violet };
+
+template <> struct OptionEnumMapping {
+  static llvm::ArrayRef> getEnumMapping() {
+static constexpr std::pair Mapping[] = {
+{Colours::Red, "Red"},   {Colours::Orange, "Orange"},
+{Colours::Yellow, "Yellow"}, {Colours::Green, "Green"},
+{Colours::Blue, "Blue"}, {Colours::Indigo, "Indigo"},
+{Colours::Violet, "Violet"}};
+return makeArrayRef(Mapping);
+  }
+};
+
 namespace test {
 
 TEST(ParseLineFilter, EmptyFilter) {
@@ -209,15 +223,6 @@
 }
 
 TEST(ValidConfiguration, ValidEnumOptions) {
-
-  enum class Colours { Red, Orange, Yellow, Green, Blue, Indigo, Violet };
-  static constexpr std::pair Mapping[] = {
-  {"Red", Colours::Red},   {"Orange", Colours::Orange},
-  {"Yellow", Colours::Yellow}, {"Green", Colours::Green},
-  {"Blue", Colours::Blue}, {"Indigo", Colours::Indigo},
-  {"Violet", Colours::Violet}};
-  static const auto Map = makeArrayRef(Mapping);
-
   ClangTidyOptions Options;
   auto  = Options.CheckOptions;
 
@@ -237,29 +242,30 @@
 #define CHECK_ERROR_ENUM(Name, Expected)   \
   CHECK_ERROR(Name, UnparseableEnumOptionError, Expected)
 
-  CHECK_VAL(TestCheck.getLocal("Valid", Map), Colours::Red);
-  CHECK_VAL(TestCheck.getGlobal("GlobalValid", Map), Colours::Violet);
-  CHECK_VAL(TestCheck.getLocal("ValidWrongCase", Map, /*IgnoreCase*/ true),
-Colours::Red);
+  CHECK_VAL(TestCheck.getIntLocal("Valid"), Colours::Red);
+  CHECK_VAL(TestCheck.getIntGlobal("GlobalValid"), Colours::Violet);
   CHECK_VAL(
-  TestCheck.getGlobal("GlobalValidWrongCase", Map, /*IgnoreCase*/ true),
-  Colours::Violet);
-  CHECK_ERROR_ENUM(TestCheck.getLocal("Invalid", Map),
+  TestCheck.getIntLocal("ValidWrongCase", /*IgnoreCase*/ true),
+  Colours::Red);
+  CHECK_VAL(TestCheck.getIntGlobal("GlobalValidWrongCase",
+/*IgnoreCase*/ true),
+Colours::Violet);
+  CHECK_ERROR_ENUM(TestCheck.getIntLocal("Invalid"),
"invalid configuration value "
"'Scarlet' for option 'test.Invalid'");
-  CHECK_ERROR_ENUM(TestCheck.getLocal("ValidWrongCase", Map),
+  CHECK_ERROR_ENUM(TestCheck.getIntLocal("ValidWrongCase"),
"invalid configuration value 'rED' for option "
"'test.ValidWrongCase'; did you mean 'Red'?");
-  CHECK_ERROR_ENUM(TestCheck.getLocal("NearMiss", Map),
+  CHECK_ERROR_ENUM(TestCheck.getIntLocal("NearMiss"),
"invalid configuration value 'Oragne' for option "
"'test.NearMiss'; did you mean 'Orange'?");
-  CHECK_ERROR_ENUM(TestCheck.getGlobal("GlobalInvalid", Map),
+  CHECK_ERROR_ENUM(TestCheck.getIntGlobal("GlobalInvalid"),
"invalid configuration value "
"'Purple' for option 'GlobalInvalid'");
-  CHECK_ERROR_ENUM(TestCheck.getGlobal("GlobalValidWrongCase", Map),
+  CHECK_ERROR_ENUM(TestCheck.getIntGlobal("GlobalValidWrongCase"),
 

[PATCH] D82223: [clang-tidy] Implement storeOptions for checks missing it.

2020-06-21 Thread Nathan James via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdb90d315706b: [clang-tidy] Implement storeOptions for checks 
missing it. (authored by njames93).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82223

Files:
  clang-tools-extra/clang-tidy/bugprone/TooSmallLoopVariableCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.h
  clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.h
  clang-tools-extra/clang-tidy/misc/NonPrivateMemberVariablesInClassesCheck.cpp
  clang-tools-extra/clang-tidy/misc/NonPrivateMemberVariablesInClassesCheck.h
  clang-tools-extra/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp
  clang-tools-extra/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.h
  clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp
  clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.h
  clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
  clang-tools-extra/clang-tidy/modernize/RawStringLiteralCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseAutoCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseBoolLiteralsCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseBoolLiteralsCheck.h
  clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseTransparentFunctorsCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseUsingCheck.h
  clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp
  clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.h
  clang-tools-extra/clang-tidy/readability/RedundantDeclarationCheck.cpp
  clang-tools-extra/clang-tidy/readability/RedundantDeclarationCheck.h
  clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.h
  clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp
  clang-tools-extra/clang-tidy/utils/HeaderGuard.h

Index: clang-tools-extra/clang-tidy/utils/HeaderGuard.h
===
--- clang-tools-extra/clang-tidy/utils/HeaderGuard.h
+++ clang-tools-extra/clang-tidy/utils/HeaderGuard.h
@@ -34,6 +34,7 @@
HeaderFileExtensions,
utils::defaultFileExtensionDelimiters());
   }
+  void storeOptions(ClangTidyOptions::OptionMap ) override;
   void registerPPCallbacks(const SourceManager , Preprocessor *PP,
Preprocessor *ModuleExpanderPP) override;
 
Index: clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp
===
--- clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp
+++ clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp
@@ -266,6 +266,10 @@
 };
 } // namespace
 
+void HeaderGuardCheck::storeOptions(ClangTidyOptions::OptionMap ) {
+  Options.store(Opts, "HeaderFileExtensions", RawStringHeaderFileExtensions);
+}
+
 void HeaderGuardCheck::registerPPCallbacks(const SourceManager ,
Preprocessor *PP,
Preprocessor *ModuleExpanderPP) {
@@ -285,7 +289,6 @@
 std::string HeaderGuardCheck::formatEndIf(StringRef HeaderGuard) {
   return "endif // " + HeaderGuard.str();
 }
-
 } // namespace utils
 } // namespace tidy
 } // namespace clang
Index: clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.h
===
--- clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.h
+++ clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.h
@@ -25,7 +25,7 @@
   StaticAccessedThroughInstanceCheck(StringRef Name, ClangTidyContext *Context)
   : ClangTidyCheck(Name, Context),
 NameSpecifierNestingThreshold(
-Options.get("NameSpecifierNestingThreshold", 3)) {}
+Options.get("NameSpecifierNestingThreshold", 3U)) {}
 
   void storeOptions(ClangTidyOptions::OptionMap ) override;
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
Index: clang-tools-extra/clang-tidy/readability/RedundantDeclarationCheck.h
===
--- clang-tools-extra/clang-tidy/readability/RedundantDeclarationCheck.h
+++ clang-tools-extra/clang-tidy/readability/RedundantDeclarationCheck.h
@@ -22,6 +22,7 @@
 class RedundantDeclarationCheck : public ClangTidyCheck {
 public:
   RedundantDeclarationCheck(StringRef Name, ClangTidyContext *Context);
+  void storeOptions(ClangTidyOptions::OptionMap ) override;
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult ) override;
 
Index: 

[clang-tools-extra] db90d31 - [clang-tidy] Implement storeOptions for checks missing it.

2020-06-21 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2020-06-21T19:01:11+01:00
New Revision: db90d315706b5d5a06cb79607cef1a8d581d0ba8

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

LOG: [clang-tidy] Implement storeOptions for checks missing it.

Just adds the storeOptions for Checks that weren't already storing their 
options.

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/bugprone/TooSmallLoopVariableCheck.cpp
clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.h
clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp
clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.h

clang-tools-extra/clang-tidy/misc/NonPrivateMemberVariablesInClassesCheck.cpp
clang-tools-extra/clang-tidy/misc/NonPrivateMemberVariablesInClassesCheck.h
clang-tools-extra/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp
clang-tools-extra/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.h
clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp
clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.h
clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
clang-tools-extra/clang-tidy/modernize/RawStringLiteralCheck.cpp
clang-tools-extra/clang-tidy/modernize/UseAutoCheck.cpp
clang-tools-extra/clang-tidy/modernize/UseBoolLiteralsCheck.cpp
clang-tools-extra/clang-tidy/modernize/UseBoolLiteralsCheck.h
clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp
clang-tools-extra/clang-tidy/modernize/UseTransparentFunctorsCheck.cpp
clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
clang-tools-extra/clang-tidy/modernize/UseUsingCheck.h
clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp
clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.h
clang-tools-extra/clang-tidy/readability/RedundantDeclarationCheck.cpp
clang-tools-extra/clang-tidy/readability/RedundantDeclarationCheck.h

clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.h
clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp
clang-tools-extra/clang-tidy/utils/HeaderGuard.h

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/bugprone/TooSmallLoopVariableCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/TooSmallLoopVariableCheck.cpp
index be5a4697e94b..06332af92e37 100644
--- a/clang-tools-extra/clang-tidy/bugprone/TooSmallLoopVariableCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/TooSmallLoopVariableCheck.cpp
@@ -30,8 +30,7 @@ static constexpr llvm::StringLiteral LoopIncrementName =
 TooSmallLoopVariableCheck::TooSmallLoopVariableCheck(StringRef Name,
  ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context),
-  MagnitudeBitsUpperLimit(Options.get(
-  "MagnitudeBitsUpperLimit", 16)) {}
+  MagnitudeBitsUpperLimit(Options.get("MagnitudeBitsUpperLimit", 16U)) {}
 
 void TooSmallLoopVariableCheck::storeOptions(
 ClangTidyOptions::OptionMap ) {

diff  --git 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
index a5756ff634bb..608df8a0ab44 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
@@ -29,6 +29,12 @@ InitVariablesCheck::InitVariablesCheck(StringRef Name,
 utils::IncludeSorter::IS_LLVM)),
   MathHeader(Options.get("MathHeader", "math.h")) {}
 
+void InitVariablesCheck::storeOptions(ClangTidyOptions::OptionMap ) {
+  Options.store(Opts, "IncludeStyle", IncludeStyle,
+utils::IncludeSorter::getMapping());
+  Options.store(Opts, "MathHeader", MathHeader);
+}
+
 void InitVariablesCheck::registerMatchers(MatchFinder *Finder) {
   std::string BadDecl = "badDecl";
   Finder->addMatcher(
@@ -102,7 +108,6 @@ void InitVariablesCheck::check(const 
MatchFinder::MatchResult ) {
 }
   }
 }
-
 } // namespace cppcoreguidelines
 } // namespace tidy
 } // namespace clang

diff  --git 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.h 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.h
index 0cacf9e533cf..61521b118a99 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.h
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.h
@@ -24,6 +24,7 @@ namespace cppcoreguidelines {
 class InitVariablesCheck : public ClangTidyCheck {
 public:
   InitVariablesCheck(StringRef Name, ClangTidyContext 

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

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



Comment at: clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp:256
+  SVal SubVal = State->getSVal(UO->getSubExpr(), C.getLocationContext());
+  SVal Result = State->getSVal(UO, C.getLocationContext());
+

baloghadamsoftware wrote:
> baloghadamsoftware wrote:
> > This is the problematic point which is not working. I left the comments 
> > intentionally in the code.
> > 
> > The problem is that in `postStmt` we are //after//  the operation. Thus the 
> > value of the operand (`SubExpr`) is not `i` anymore, but the //former 
> > value// of `i` (a pointer to a symbolic region initially). Instead, the 
> > result is `i` in case of prefix operators, but also the former value in 
> > case of postfix operators. This is correct, of course, because here, after 
> > the call the value of `i` was changed, thus it is not equal to the 
> > parameter. However, we need the region of `i` here and/or the new value 
> > bound to it (e.g. the pointer to an element region which is usually the 
> > result of a `++` or `--` on a pointer to a symbolic region). How to reach 
> > that? Of course, in `preStmt` the operand is `i` as it should be. The same 
> > is true for binary operators `+=` and `-=`. 
> Of course, I know it is all wrong to increment the //former// value. This is 
> also not the goal, probably I cannot reuse `handleIncrement()` and the like 
> here. The question is how to get the region of the variable or even better 
> the //new// region (e.g. the pointer to element region) bound to it? In the 
> prefix case I have the variable, but is there a generic way to get the region 
> bound to it? By generic I mean that I hope that I do not have to branch on 
> all possible lvalue expressions.
Wait! I know the solution! I will try it tomorrow.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82185



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


[PATCH] D82188: [clang-tidy] Reworked enum options handling(again)

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

I like the direction of this, thank you! LGTM with a small suggestion, but you 
should wait a few days in case one of the other reviewers has comments.




Comment at: clang-tools-extra/clang-tidy/ClangTidyCheck.h:31-32
+template  struct OptionEnumMapping {
+  // Must provide:
+  // static ArrayRef> getEnumMapping();
+};

Any reason not to do:
```
static ArrayRef> getEnumMapping() = delete;
```
so you get a nice error if you instantiate something without the required 
definition?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82188



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


[PATCH] D82162: [clang-tidy] RenamerClangTidy wont emit fixes in scratch space

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



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp:570
+
+// We don't want a warning here as the call to this in Foo is in a scratch
+// buffer so its fix-it wouldn't be applied, resulting in invalid code.

I may be misunderstanding the comment here. I can understand not wanting to 
generate fixits into the scratch buffer (that would not do good things), but I 
think we still want a warning were it not for the macro, right? Just verifying 
that this is not changing warning behaviors, only fix-it behaviors.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82162



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


[PATCH] D82223: [clang-tidy] Implement storeOptions for checks missing it.

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

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82223



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


[clang] 448bbc5 - fix clang/PCH/delayed-pch-instantiate test

2020-06-21 Thread Luboš Luňák via cfe-commits

Author: Luboš Luňák
Date: 2020-06-21T19:00:42+02:00
New Revision: 448bbc512f456df6fc817b0d7041897eea2375b7

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

LOG: fix clang/PCH/delayed-pch-instantiate test

-target must match between PCH creation and use.

Added: 


Modified: 
clang/test/PCH/delayed-pch-instantiate.cpp

Removed: 




diff  --git a/clang/test/PCH/delayed-pch-instantiate.cpp 
b/clang/test/PCH/delayed-pch-instantiate.cpp
index cf7a9f2d4a86..d340b3b8b25d 100644
--- a/clang/test/PCH/delayed-pch-instantiate.cpp
+++ b/clang/test/PCH/delayed-pch-instantiate.cpp
@@ -2,10 +2,10 @@
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -DBODY %s -o - | 
FileCheck %s
 
 // Test with pch.
-// RUN: %clang_cc1 -emit-pch -o %t %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-pch -o %t %s
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -include-pch %t -DBODY 
%s -o - | FileCheck %s
 
-// RUN: %clang_cc1 -emit-pch -fpch-instantiate-templates -o %t %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-pch 
-fpch-instantiate-templates -o %t %s
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -include-pch %t -DBODY 
%s -o - | FileCheck %s
 
 // expected-no-diagnostics



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


[PATCH] D82279: Handle invalid types in the nullPointerConstant AST matcher

2020-06-21 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman created this revision.
aaron.ballman added reviewers: rsmith, steveire, klimek, gribozavr.

Currently, using the nullPointerConstant AST matcher can lead to assertions in 
situations where a node to be matched does not have a valid type associated 
with it, such as a ParenListExpr. This patch addresses that by saying such 
nodes cannot be a null pointer constant. This addresses PR46353.


https://reviews.llvm.org/D82279

Files:
  clang/lib/AST/Expr.cpp
  clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp


Index: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -2608,6 +2608,14 @@
   EXPECT_TRUE(matches("char *cp = (char *)0;", expr(nullPointerConstant(;
   EXPECT_TRUE(matches("int *ip = 0;", expr(nullPointerConstant(;
   EXPECT_TRUE(matches("int i = 0;", expr(nullPointerConstant(;
+  const char kTest[] = R"(
+template 
+struct MyTemplate {
+  MyTemplate() : field_(__null) {}
+  T* field_;
+};
+  )";
+  EXPECT_TRUE(matches(kTest, expr(nullPointerConstant(;
 }
 
 TEST(HasExternalFormalLinkage, Basic) {
Index: clang/lib/AST/Expr.cpp
===
--- clang/lib/AST/Expr.cpp
+++ clang/lib/AST/Expr.cpp
@@ -3812,6 +3812,11 @@
   return Source->isNullPointerConstant(Ctx, NPC);
   }
 
+  // If the expression has no type information, it cannot be a null pointer
+  // constant.
+  if (getType().isNull())
+return NPCK_NotNull;
+
   // C++11 nullptr_t is always a null pointer constant.
   if (getType()->isNullPtrType())
 return NPCK_CXX11_nullptr;


Index: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -2608,6 +2608,14 @@
   EXPECT_TRUE(matches("char *cp = (char *)0;", expr(nullPointerConstant(;
   EXPECT_TRUE(matches("int *ip = 0;", expr(nullPointerConstant(;
   EXPECT_TRUE(matches("int i = 0;", expr(nullPointerConstant(;
+  const char kTest[] = R"(
+template 
+struct MyTemplate {
+  MyTemplate() : field_(__null) {}
+  T* field_;
+};
+  )";
+  EXPECT_TRUE(matches(kTest, expr(nullPointerConstant(;
 }
 
 TEST(HasExternalFormalLinkage, Basic) {
Index: clang/lib/AST/Expr.cpp
===
--- clang/lib/AST/Expr.cpp
+++ clang/lib/AST/Expr.cpp
@@ -3812,6 +3812,11 @@
   return Source->isNullPointerConstant(Ctx, NPC);
   }
 
+  // If the expression has no type information, it cannot be a null pointer
+  // constant.
+  if (getType().isNull())
+return NPCK_NotNull;
+
   // C++11 nullptr_t is always a null pointer constant.
   if (getType()->isNullPtrType())
 return NPCK_CXX11_nullptr;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D79755: Implement constexpr BinaryOperator for vector types

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

LGTM!


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

https://reviews.llvm.org/D79755



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


[PATCH] D69585: Add option to instantiate templates already in the PCH

2020-06-21 Thread Luboš Luňák via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa45f713c6730: add option to instantiate templates already in 
the PCH (authored by llunak).

Changed prior to commit:
  https://reviews.llvm.org/D69585?vs=265918=272312#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69585

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/PCH/crash-12631281.cpp
  clang/test/PCH/cxx-alias-decl.cpp
  clang/test/PCH/cxx-dependent-sized-ext-vector.cpp
  clang/test/PCH/cxx-explicit-specifier.cpp
  clang/test/PCH/cxx-exprs.cpp
  clang/test/PCH/cxx-friends.cpp
  clang/test/PCH/cxx-member-init.cpp
  clang/test/PCH/cxx-ms-function-specialization-class-scope.cpp
  clang/test/PCH/cxx-static_assert.cpp
  clang/test/PCH/cxx-templates.cpp
  clang/test/PCH/cxx-variadic-templates-with-default-params.cpp
  clang/test/PCH/cxx-variadic-templates.cpp
  clang/test/PCH/cxx0x-default-delete.cpp
  clang/test/PCH/cxx11-constexpr.cpp
  clang/test/PCH/cxx11-enum-template.cpp
  clang/test/PCH/cxx11-exception-spec.cpp
  clang/test/PCH/cxx11-inheriting-ctors.cpp
  clang/test/PCH/cxx11-user-defined-literals.cpp
  clang/test/PCH/cxx1y-decltype-auto.cpp
  clang/test/PCH/cxx1y-deduced-return-type.cpp
  clang/test/PCH/cxx1y-default-initializer.cpp
  clang/test/PCH/cxx1y-init-captures.cpp
  clang/test/PCH/cxx1y-variable-templates.cpp
  clang/test/PCH/cxx1z-aligned-alloc.cpp
  clang/test/PCH/cxx1z-decomposition.cpp
  clang/test/PCH/cxx1z-using-declaration.cpp
  clang/test/PCH/cxx2a-bitfield-init.cpp
  clang/test/PCH/cxx2a-concept-specialization-expr.cpp
  clang/test/PCH/cxx2a-constraints.cpp
  clang/test/PCH/cxx2a-defaulted-comparison.cpp
  clang/test/PCH/cxx2a-requires-expr.cpp
  clang/test/PCH/cxx2a-template-lambdas.cpp
  clang/test/PCH/delayed-pch-instantiate.cpp
  clang/test/PCH/friend-template.cpp
  clang/test/PCH/implicitly-deleted.cpp
  clang/test/PCH/late-parsed-instantiations.cpp
  clang/test/PCH/local_static.cpp
  clang/test/PCH/macro-undef.cpp
  clang/test/PCH/make-integer-seq.cpp
  clang/test/PCH/ms-if-exists.cpp
  clang/test/PCH/pch-instantiate-templates-forward-decl.cpp
  clang/test/PCH/pch-instantiate-templates.cpp
  clang/test/PCH/pr18806.cpp
  clang/test/PCH/pragma-diag-section.cpp
  clang/test/PCH/rdar10830559.cpp
  clang/test/PCH/specialization-after-instantiation.cpp
  clang/test/PCH/type_pack_element.cpp

Index: clang/test/PCH/type_pack_element.cpp
===
--- clang/test/PCH/type_pack_element.cpp
+++ clang/test/PCH/type_pack_element.cpp
@@ -1,6 +1,9 @@
 // RUN: %clang_cc1 -std=c++14 -x c++-header %s -emit-pch -o %t.pch
 // RUN: %clang_cc1 -std=c++14 -x c++ /dev/null -include-pch %t.pch
 
+// RUN: %clang_cc1 -std=c++14 -x c++-header %s -emit-pch -fpch-instantiate-templates -o %t.pch
+// RUN: %clang_cc1 -std=c++14 -x c++ /dev/null -include-pch %t.pch
+
 template 
 struct X { };
 
Index: clang/test/PCH/specialization-after-instantiation.cpp
===
--- /dev/null
+++ clang/test/PCH/specialization-after-instantiation.cpp
@@ -0,0 +1,32 @@
+// Test this without pch.
+// RUN: %clang_cc1 -fsyntax-only -verify -DBODY %s
+
+// Test with pch.
+// RUN: %clang_cc1 -emit-pch -o %t %s
+// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify -DBODY %s
+
+// RUN: %clang_cc1 -emit-pch -fpch-instantiate-templates -o %t %s
+// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify -DBODY %s
+
+#ifndef HEADER_H
+#define HEADER_H
+
+template 
+struct A {
+  int foo() const;
+};
+
+int bar(A *a) {
+  return a->foo();
+}
+
+#endif // HEADER_H
+
+#ifdef BODY
+
+template <>
+int A::foo() const { // expected-error {{explicit specialization of 'foo' after instantiation}}  // expected-note@20 {{implicit instantiation first required here}}
+  return 10;
+}
+
+#endif // BODY
Index: clang/test/PCH/rdar10830559.cpp
===
--- clang/test/PCH/rdar10830559.cpp
+++ clang/test/PCH/rdar10830559.cpp
@@ -6,6 +6,9 @@
 // RUN: %clang_cc1 -emit-pch -o %t %s
 // RUN: %clang_cc1 -include-pch %t -emit-llvm-only %t.empty.cpp 
 
+// RUN: %clang_cc1 -emit-pch -fpch-instantiate-templates -o %t %s
+// RUN: %clang_cc1 -include-pch %t -emit-llvm-only %t.empty.cpp
+
 // rdar://10830559
 
 //#pragma ms_struct on
Index: clang/test/PCH/pragma-diag-section.cpp
===
--- clang/test/PCH/pragma-diag-section.cpp
+++ clang/test/PCH/pragma-diag-section.cpp
@@ -5,6 +5,9 @@
 // RUN: %clang_cc1 %s -emit-pch -o %t
 // RUN: %clang_cc1 %s -include-pch %t -verify -fsyntax-only -Wuninitialized
 
+// 

[PATCH] D69778: Make -fmodules-codegen and -fmodules-debuginfo work also with precompiled headers

2020-06-21 Thread Luboš Luňák via Phabricator via cfe-commits
llunak added a comment.

So what more needs to be done here to get this change accepted? It's already 
missed 10.0 and 11.1 is getting branched off in about 3 weeks.

- The change was already accepted once and the problem leading to its revert 
has already been fixed.
- It just enables for PCH something that's been enabled for modules for a long 
time (so whatever may be wrong with it will probably be wrong with modules as 
well).
- I've been using the feature for 8 months.
- There's no publicly reported problem with it (I know aganea reported them 
above, but they are private, so nobody can do anything about them).
- The feature is opt-in and disabled by default.


Repository:
  rC Clang

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

https://reviews.llvm.org/D69778



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


[clang] a45f713 - add option to instantiate templates already in the PCH

2020-06-21 Thread Luboš Luňák via cfe-commits

Author: Luboš Luňák
Date: 2020-06-21T17:05:52+02:00
New Revision: a45f713c673001abb4fe0612b909c698073eb356

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

LOG: add option to instantiate templates already in the PCH

Add -fpch-instantiate-templates which makes template instantiations be
performed already in the PCH instead of it being done in every single
file that uses the PCH (but every single file will still do it as well
in order to handle its own instantiations). I can see 20-30% build
time saved with the few tests I've tried.

The change may reorder compiler output and also generated code, but
should be generally safe and produce functionally identical code.
There are some rare cases that do not compile with it,
such as test/PCH/pch-instantiate-templates-forward-decl.cpp. If
template instantiation bailed out instead of reporting the error,
these instantiations could even be postponed, which would make them
work.

Enable this by default for clang-cl. MSVC creates PCHs by compiling
them using an empty .cpp file, which means templates are instantiated
while building the PCH and so the .h needs to be self-contained,
making test/PCH/pch-instantiate-templates-forward-decl.cpp to fail
with MSVC anyway. So the option being enabled for clang-cl matches this.

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

Added: 
clang/test/PCH/delayed-pch-instantiate.cpp
clang/test/PCH/pch-instantiate-templates-forward-decl.cpp
clang/test/PCH/pch-instantiate-templates.cpp
clang/test/PCH/specialization-after-instantiation.cpp

Modified: 
clang/include/clang/Basic/LangOptions.def
clang/include/clang/Driver/Options.td
clang/include/clang/Sema/Sema.h
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Sema/Sema.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/test/PCH/crash-12631281.cpp
clang/test/PCH/cxx-alias-decl.cpp
clang/test/PCH/cxx-dependent-sized-ext-vector.cpp
clang/test/PCH/cxx-explicit-specifier.cpp
clang/test/PCH/cxx-exprs.cpp
clang/test/PCH/cxx-friends.cpp
clang/test/PCH/cxx-member-init.cpp
clang/test/PCH/cxx-ms-function-specialization-class-scope.cpp
clang/test/PCH/cxx-static_assert.cpp
clang/test/PCH/cxx-templates.cpp
clang/test/PCH/cxx-variadic-templates-with-default-params.cpp
clang/test/PCH/cxx-variadic-templates.cpp
clang/test/PCH/cxx0x-default-delete.cpp
clang/test/PCH/cxx11-constexpr.cpp
clang/test/PCH/cxx11-enum-template.cpp
clang/test/PCH/cxx11-exception-spec.cpp
clang/test/PCH/cxx11-inheriting-ctors.cpp
clang/test/PCH/cxx11-user-defined-literals.cpp
clang/test/PCH/cxx1y-decltype-auto.cpp
clang/test/PCH/cxx1y-deduced-return-type.cpp
clang/test/PCH/cxx1y-default-initializer.cpp
clang/test/PCH/cxx1y-init-captures.cpp
clang/test/PCH/cxx1y-variable-templates.cpp
clang/test/PCH/cxx1z-aligned-alloc.cpp
clang/test/PCH/cxx1z-decomposition.cpp
clang/test/PCH/cxx1z-using-declaration.cpp
clang/test/PCH/cxx2a-bitfield-init.cpp
clang/test/PCH/cxx2a-concept-specialization-expr.cpp
clang/test/PCH/cxx2a-constraints.cpp
clang/test/PCH/cxx2a-defaulted-comparison.cpp
clang/test/PCH/cxx2a-requires-expr.cpp
clang/test/PCH/cxx2a-template-lambdas.cpp
clang/test/PCH/friend-template.cpp
clang/test/PCH/implicitly-deleted.cpp
clang/test/PCH/late-parsed-instantiations.cpp
clang/test/PCH/local_static.cpp
clang/test/PCH/macro-undef.cpp
clang/test/PCH/make-integer-seq.cpp
clang/test/PCH/ms-if-exists.cpp
clang/test/PCH/pr18806.cpp
clang/test/PCH/pragma-diag-section.cpp
clang/test/PCH/rdar10830559.cpp
clang/test/PCH/type_pack_element.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index 9236327f688f..bc0c17a14789 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -165,6 +165,7 @@ BENIGN_ENUM_LANGOPT(CompilingModule, CompilingModuleKind, 
2, CMK_None,
 BENIGN_LANGOPT(CompilingPCH, 1, 0, "building a pch")
 BENIGN_LANGOPT(BuildingPCHWithObjectFile, 1, 0, "building a pch which has a 
corresponding object file")
 BENIGN_LANGOPT(CacheGeneratedPCH, 1, 0, "cache generated PCH files in memory")
+BENIGN_LANGOPT(PCHInstantiateTemplates, 1, 0, "instantiate templates while 
building a PCH")
 COMPATIBLE_LANGOPT(ModulesDeclUse, 1, 0, "require declaration of module 
uses")
 BENIGN_LANGOPT(ModulesSearchAll  , 1, 1, "searching even non-imported modules 
to find unresolved references")
 COMPATIBLE_LANGOPT(ModulesStrictDeclUse, 1, 0, "requiring declaration of 
module uses and all headers to be in modules")

diff  --git 

[PATCH] D82278: Fix traversal over CXXConstructExpr in Syntactic mode

2020-06-21 Thread Stephen Kelly via Phabricator via cfe-commits
steveire created this revision.
steveire added reviewers: klimek, ymandel.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Skip over elidable nodes, and ensure that intermediate
CXXFunctionalCastExpr nodes are also skipped if they are semantic.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82278

Files:
  clang-tools-extra/clang-tidy/bugprone/ThrowKeywordMissingCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/UnusedRaiiCheck.cpp
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ParentMapContext.cpp
  clang/unittests/AST/ASTTraverserTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -1891,6 +1891,98 @@
 
   EXPECT_TRUE(matches(Code, traverse(TK_IgnoreUnlessSpelledInSource,
  staticAssertDecl(has(integerLiteral());
+
+  Code = R"cpp(
+
+struct OneParamCtor {
+  explicit OneParamCtor(int);
+};
+struct TwoParamCtor {
+  explicit TwoParamCtor(int, int);
+};
+
+void varDeclCtors() {
+  {
+  auto var1 = OneParamCtor(5);
+  auto var2 = TwoParamCtor(6, 7);
+  }
+  {
+  OneParamCtor var3(5);
+  TwoParamCtor var4(6, 7);
+  }
+  int i = 0;
+  {
+  auto var5 = OneParamCtor(i);
+  auto var6 = TwoParamCtor(i, 7);
+  }
+  {
+  OneParamCtor var7(i);
+  TwoParamCtor var8(i, 7);
+  }
+}
+
+)cpp";
+  EXPECT_TRUE(matches(
+  Code,
+  traverse(TK_AsIs, varDecl(hasName("var1"), hasInitializer(hasDescendant(
+ cxxConstructExpr()));
+  EXPECT_TRUE(matches(
+  Code,
+  traverse(TK_AsIs, varDecl(hasName("var2"), hasInitializer(hasDescendant(
+ cxxConstructExpr()));
+  EXPECT_TRUE(matches(
+  Code, traverse(TK_AsIs, varDecl(hasName("var3"),
+  hasInitializer(cxxConstructExpr());
+  EXPECT_TRUE(matches(
+  Code, traverse(TK_AsIs, varDecl(hasName("var4"),
+  hasInitializer(cxxConstructExpr());
+  EXPECT_TRUE(matches(
+  Code,
+  traverse(TK_AsIs, varDecl(hasName("var5"), hasInitializer(hasDescendant(
+ cxxConstructExpr()));
+  EXPECT_TRUE(matches(
+  Code,
+  traverse(TK_AsIs, varDecl(hasName("var6"), hasInitializer(hasDescendant(
+ cxxConstructExpr()));
+  EXPECT_TRUE(matches(
+  Code, traverse(TK_AsIs, varDecl(hasName("var7"),
+  hasInitializer(cxxConstructExpr());
+  EXPECT_TRUE(matches(
+  Code, traverse(TK_AsIs, varDecl(hasName("var8"),
+  hasInitializer(cxxConstructExpr());
+
+  EXPECT_TRUE(matches(
+  Code,
+  traverse(TK_IgnoreUnlessSpelledInSource,
+   varDecl(hasName("var1"), hasInitializer(cxxConstructExpr());
+  EXPECT_TRUE(matches(
+  Code,
+  traverse(TK_IgnoreUnlessSpelledInSource,
+   varDecl(hasName("var2"), hasInitializer(cxxConstructExpr());
+  EXPECT_TRUE(matches(
+  Code,
+  traverse(TK_IgnoreUnlessSpelledInSource,
+   varDecl(hasName("var3"), hasInitializer(cxxConstructExpr());
+  EXPECT_TRUE(matches(
+  Code,
+  traverse(TK_IgnoreUnlessSpelledInSource,
+   varDecl(hasName("var4"), hasInitializer(cxxConstructExpr());
+  EXPECT_TRUE(matches(
+  Code,
+  traverse(TK_IgnoreUnlessSpelledInSource,
+   varDecl(hasName("var5"), hasInitializer(cxxConstructExpr());
+  EXPECT_TRUE(matches(
+  Code,
+  traverse(TK_IgnoreUnlessSpelledInSource,
+   varDecl(hasName("var6"), hasInitializer(cxxConstructExpr());
+  EXPECT_TRUE(matches(
+  Code,
+  traverse(TK_IgnoreUnlessSpelledInSource,
+   varDecl(hasName("var7"), hasInitializer(cxxConstructExpr());
+  EXPECT_TRUE(matches(
+  Code,
+  traverse(TK_IgnoreUnlessSpelledInSource,
+   varDecl(hasName("var8"), hasInitializer(cxxConstructExpr());
 }
 
 template 
@@ -2096,21 +2188,20 @@
  forFunction(functionDecl(hasName("func2"),
   langCxx20OrLater()));
 
-  EXPECT_TRUE(matches(
-  Code,
-  traverse(
-  TK_IgnoreUnlessSpelledInSource,
-  returnStmt(forFunction(functionDecl(hasName("func3"))),
- hasReturnValue(cxxFunctionalCastExpr(
- hasSourceExpression(integerLiteral(equals(42))),
-  langCxx20OrLater()));
+  EXPECT_TRUE(
+  matches(Code,
+  traverse(TK_IgnoreUnlessSpelledInSource,
+   

[PATCH] D81678: Introduce frozen attribute at call sites for stricter poison analysis

2020-06-21 Thread Juneyoung Lee via Phabricator via cfe-commits
aqjune added a comment.

In D81678#2105077 , @eugenis wrote:

> > Could you explicitly state that if it is aggregate or vector type all 
> > elements and paddings should be frozen too?
>
> If an aggregate is passed as an aggregate at IR level, we should not care 
> about the padding.
>  Unless it's coerced to an integer.


Oh sorry, I missed the comment of @guiand above.
I wanted to suggest making things simpler by having its memory representation 
always have well-defined bits if stored into memory.
But, if it is helpful for MSan's performance because it is well-defined in C, I 
think it is fine to not care about the paddings.
I suggest explicitly mentioning that we're not considering paddings of 
aggregates in the LangRef (at the definition of frozen value too if you want; 
actually I thought it was already described in the definition, but it didn't).

In D81678#2105429 , @jdoerfert wrote:

> I'm unsure if we want the name `frozen` as it is less helpful to anyone now 
> familiar with the frozen instruction.
>  In a different thread we concluded that we need some sort of `nopoison` as 
> an attribute to convey the behavior is UB if the value would be poison.
>  I would very much prefer a self explanatory spelling here, especially since 
> `nopoison` will be derived from sources other than the frozen instruction.


In the nonnull thread I was in favor of `nopoison` as well, but became to think 
that `nopoison` is a bit misleading in this patch because it doesn't talk about 
undef bit.
Personally I preferred `frozen` because whenever there is an ambiguity in its 
semantics, the precise definition can be made by simply updating the notion of 
a frozen value, but if a more intuitive spelling is consideration I'm open to 
any suggestions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81678



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


[PATCH] D81678: Introduce frozen attribute at call sites for stricter poison analysis

2020-06-21 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert requested changes to this revision.
jdoerfert added a comment.
This revision now requires changes to proceed.

First, apologies for being late, I didn't properly monitor the list recently.

---

This diff is impossible to review and later to understand.

I would ask you to split it, at least for review purposes, such that (1) lang 
ref changes, (2) code changes, (3) test changes are separate.
Please also upload it with a full diff (at least for (1) and (2)).

The revision title needs to be updated (maybe add `[LangRef]` or `[Attr]`), and 
the commit message needs more explanation of the reasons and semantics.

---

Lang Ref (https://reviews.llvm.org/differential/changeset/?ref=2023449 <- so 
people can find it)

I think the spelling is not in line with other attributes and needs to be 
changed.

I'm unsure if we want the name `frozen` as it is less helpful to anyone now 
familiar with the frozen instruction.
In a different thread we concluded that we need some sort of `nopoison` as an 
attribute to convey the behavior is UB if the value would be poison.
I would very much prefer a self explanatory spelling here, especially since 
`nopoison` will be derived from sources other than the frozen instruction.

In the lang ref this is listed with and shown as string attribute. It should be 
with the regular ones (as it is implemented as such). It is also not target 
specific.

---

All in all we need to open this up to more people and go over the lang ref 
changes again.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81678



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


[clang] 0dbeffd - [clang][utils] Minor tweak to make-ast-dump-check.sh

2020-06-21 Thread Bruno Ricci via cfe-commits

Author: Bruno Ricci
Date: 2020-06-21T13:59:10+01:00
New Revision: 0dbeffddd1decda612f00e552c35cbcdb59907ab

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

LOG: [clang][utils] Minor tweak to make-ast-dump-check.sh

Remove the space after the "CHECK:" on each line. This space makes the use
of FileCheck --match-full-lines impossible.

Added: 


Modified: 
clang/utils/make-ast-dump-check.sh

Removed: 




diff  --git a/clang/utils/make-ast-dump-check.sh 
b/clang/utils/make-ast-dump-check.sh
index 4e8a1c198608..f0c268c883e9 100755
--- a/clang/utils/make-ast-dump-check.sh
+++ b/clang/utils/make-ast-dump-check.sh
@@ -74,11 +74,11 @@ BEGIN {
 }
 
 matched_last_line == 0 {
-  print "// ${prefix}: " s
+  print "// ${prefix}:" s
 }
 
 matched_last_line == 1 {
-  print "// ${prefix}-NEXT: " s
+  print "// ${prefix}-NEXT:" s
 }
 
 {



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


[clang] ecbf2f5 - [clang][test][NFC] Also test for serialization in AST dump tests, part 2/n.

2020-06-21 Thread Bruno Ricci via cfe-commits

Author: Bruno Ricci
Date: 2020-06-21T13:59:11+01:00
New Revision: ecbf2f5f3d2e2868c6059320c185897f8f23de41

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

LOG: [clang][test][NFC] Also test for serialization in AST dump tests, part 2/n.

The outputs between the direct ast-dump test and the ast-dump test after
deserialization should match modulo a few differences.

For hand-written tests, strip the ""s and
the "imported"s with sed.

For tests generated with "make-ast-dump-check.sh", regenerate the
output.

Part 2/n.

Added: 


Modified: 
clang/test/AST/address_space_attribute.cpp
clang/test/AST/alignas_maybe_odr_cleanup.cpp
clang/test/AST/ast-dump-aarch64-sve-types.c
clang/test/AST/ast-dump-arm-attr.c
clang/test/AST/ast-dump-array.cpp
clang/test/AST/ast-dump-attr.cpp
clang/test/AST/ast-dump-attr.m
clang/test/AST/ast-dump-c-attr.c
clang/test/AST/ast-dump-decl-stmts.cpp
clang/test/AST/ast-dump-decl.c
clang/test/AST/ast-dump-decl.cpp
clang/test/AST/ast-dump-decl.m
clang/test/AST/ast-dump-decl.mm
clang/test/AST/ast-dump-expr.c
clang/test/AST/ast-dump-expr.cpp
clang/test/AST/ast-dump-funcs.cpp
clang/test/AST/ast-dump-msp430-attr.c

Removed: 




diff  --git a/clang/test/AST/address_space_attribute.cpp 
b/clang/test/AST/address_space_attribute.cpp
index 554c9ba0a113..50777ddc7506 100644
--- a/clang/test/AST/address_space_attribute.cpp
+++ b/clang/test/AST/address_space_attribute.cpp
@@ -1,4 +1,11 @@
+// Test without serialization:
 // RUN: %clang_cc1 %s -ast-dump | FileCheck %s
+//
+// Test with serialization:
+// RUN: %clang_cc1 -emit-pch -o %t %s
+// RUN: %clang_cc1 -x c++ -include-pch %t -ast-dump-all /dev/null \
+// RUN: | sed -e "s/ //" -e "s/ imported//" \
+// RUN: | FileCheck %s
 
 // Veryify the ordering of the address_space attribute still comes before the
 // type whereas other attributes are still printed after.

diff  --git a/clang/test/AST/alignas_maybe_odr_cleanup.cpp 
b/clang/test/AST/alignas_maybe_odr_cleanup.cpp
index ebc09084528e..cdff1bfe8b80 100644
--- a/clang/test/AST/alignas_maybe_odr_cleanup.cpp
+++ b/clang/test/AST/alignas_maybe_odr_cleanup.cpp
@@ -1,4 +1,11 @@
+// Test without serialization:
 // RUN: %clang_cc1 -fsyntax-only %s -ast-dump | FileCheck %s
+//
+// Test with serialization:
+// RUN: %clang_cc1 -emit-pch -o %t %s
+// RUN: %clang_cc1 -x c++ -include-pch %t -ast-dump-all /dev/null \
+// RUN: | sed -e "s/ //" -e "s/ imported//" \
+// RUN: | FileCheck %s
 
 struct FOO {
   static const int vec_align_bytes = 32;

diff  --git a/clang/test/AST/ast-dump-aarch64-sve-types.c 
b/clang/test/AST/ast-dump-aarch64-sve-types.c
index a522164124a3..bfb8bc220e8d 100644
--- a/clang/test/AST/ast-dump-aarch64-sve-types.c
+++ b/clang/test/AST/ast-dump-aarch64-sve-types.c
@@ -1,5 +1,13 @@
+// Test without serialization:
 // RUN: %clang_cc1 -triple aarch64-linux-gnu -ast-dump \
 // RUN:   -ast-dump-filter __SV %s | FileCheck %s
+//
+// Test with serialization:
+// RUN: %clang_cc1 -triple aarch64-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -x c -triple aarch64-linux-gnu -include-pch %t \
+// RUN: -ast-dump-all -ast-dump-filter __SV /dev/null \
+// RUN: | sed -e "s/ //" -e "s/ imported//" \
+// RUN: | FileCheck %s
 
 // CHECK: TypedefDecl {{.*}} implicit __SVInt8_t '__SVInt8_t'
 // CHECK-NEXT: -BuiltinType {{.*}} '__SVInt8_t'

diff  --git a/clang/test/AST/ast-dump-arm-attr.c 
b/clang/test/AST/ast-dump-arm-attr.c
index 82a797615009..78f557d4eb0b 100644
--- a/clang/test/AST/ast-dump-arm-attr.c
+++ b/clang/test/AST/ast-dump-arm-attr.c
@@ -1,5 +1,20 @@
-// RUN: %clang_cc1 -triple arm-apple-darwin -ast-dump -ast-dump-filter Test %s 
| FileCheck --strict-whitespace %s
-// RUN: %clang_cc1 -triple armv8m.base-none-eabi -mcmse -ast-dump 
-ast-dump-filter Test %s | FileCheck --strict-whitespace %s 
--check-prefix=CHECK-CMSE
+// Tests without serialization:
+// RUN: %clang_cc1 -triple arm-apple-darwin -ast-dump -ast-dump-filter Test %s 
\
+// RUN: | FileCheck --strict-whitespace %s
+//
+// RUN: %clang_cc1 -triple armv8m.base-none-eabi -mcmse -ast-dump 
-ast-dump-filter Test %s \
+// RUN: | FileCheck --strict-whitespace %s --check-prefix=CHECK-CMSE
+//
+// Tests with serialization:
+// RUN: %clang_cc1 -triple arm-apple-darwin -emit-pch -o %t %s
+// RUN: %clang_cc1 -x c -triple arm-apple-darwin -include-pch %t -ast-dump-all 
-ast-dump-filter Test /dev/null \
+// RUN: | sed -e "s/ //" -e "s/ imported//" \
+// RUN: | FileCheck --strict-whitespace %s
+//
+// RUN: %clang_cc1 -triple armv8m.base-none-eabi -mcmse -emit-pch -o %t %s
+// RUN: %clang_cc1 -x c -triple armv8m.base-none-eabi -mcmse -include-pch %t 
-ast-dump-all -ast-dump-filter Test /dev/null \
+// RUN: | sed -e "s/ //" -e "s/ imported//" \
+// RUN: | FileCheck 

[clang] ef3adbf - [clang][NFC] Fix typos/wording in the comments of ConstantExpr.

2020-06-21 Thread Bruno Ricci via cfe-commits

Author: Bruno Ricci
Date: 2020-06-21T13:59:10+01:00
New Revision: ef3adbfc70bd593e14430c2db31c1426d3834fb4

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

LOG: [clang][NFC] Fix typos/wording in the comments of ConstantExpr.

It is "trailing objects" and "tail-allocated storage".

Added: 


Modified: 
clang/include/clang/AST/Expr.h
clang/include/clang/AST/Stmt.h

Removed: 




diff  --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index d31f582264b5..f8f104b5580b 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -988,11 +988,11 @@ class ConstantExpr final
 : public FullExpr,
   private llvm::TrailingObjects {
   static_assert(std::is_same::value,
-"this class assumes llvm::APInt::WordType is uint64_t for "
-"trail-allocated storage");
+"ConstantExpr assumes that llvm::APInt::WordType is uint64_t "
+"for tail-allocated storage");
 
 public:
-  /// Describes the kind of result that can be trail-allocated.
+  /// Describes the kind of result that can be tail-allocated.
   enum ResultStorageKind { RSK_None, RSK_Int64, RSK_APValue };
 
 private:

diff  --git a/clang/include/clang/AST/Stmt.h b/clang/include/clang/AST/Stmt.h
index 5c5c20b3676b..d76d99b65551 100644
--- a/clang/include/clang/AST/Stmt.h
+++ b/clang/include/clang/AST/Stmt.h
@@ -322,26 +322,26 @@ class alignas(void *) Stmt {
 
 unsigned : NumExprBits;
 
-/// The kind of result that is trail-allocated.
+/// The kind of result that is tail-allocated.
 unsigned ResultKind : 2;
 
-/// Kind of Result as defined by APValue::Kind
+/// The kind of Result as defined by APValue::Kind
 unsigned APValueKind : 4;
 
-/// When ResultKind == RSK_Int64. whether the trail-allocated integer is
-/// signed.
+/// When ResultKind == RSK_Int64, true if the tail-allocated integer is
+/// unsigned.
 unsigned IsUnsigned : 1;
 
-/// When ResultKind == RSK_Int64. the BitWidth of the trail-allocated
-/// integer. 7 bits because it is the minimal number of bit to represent a
-/// value from 0 to 64 (the size of the trail-allocated number).
+/// When ResultKind == RSK_Int64. the BitWidth of the tail-allocated
+/// integer. 7 bits because it is the minimal number of bits to represent a
+/// value from 0 to 64 (the size of the tail-allocated integer).
 unsigned BitWidth : 7;
 
-/// When ResultKind == RSK_APValue. Wether the ASTContext will cleanup the
-/// destructor on the trail-allocated APValue.
+/// When ResultKind == RSK_APValue, true if the ASTContext will cleanup the
+/// tail-allocated APValue.
 unsigned HasCleanup : 1;
 
-/// Whether this ConstantExpr was created for immediate invocation.
+/// True if this ConstantExpr was created for immediate invocation.
 unsigned IsImmediateInvocation : 1;
   };
 



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


[clang] e7ce052 - [clang][Serialization] Fix the serialization of ConstantExpr.

2020-06-21 Thread Bruno Ricci via cfe-commits

Author: Bruno Ricci
Date: 2020-06-21T13:59:10+01:00
New Revision: e7ce0528202306d8b751f132d9d3a6519ce4e688

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

LOG: [clang][Serialization] Fix the serialization of ConstantExpr.

The serialization of ConstantExpr has currently a number of problems:

- Some fields are just not serialized (ConstantExprBits.APValueKind and
  ConstantExprBits.IsImmediateInvocation).

- ASTStmtReader::VisitConstantExpr forgets to add the trailing APValue
  to the list of objects to be destroyed when the APValue needs cleanup.

While we are at it, bring the serialization of ConstantExpr more in-line
with what is done with the other expressions by doing the following NFCs:

- Get rid of ConstantExpr::DefaultInit. It is better to not initialize
  the fields of an empty ConstantExpr since this will allow msan to
  detect if a field was not deserialized.

- Move the initialization of the fields of ConstantExpr to the constructor;
  ConstantExpr::Create allocates the memory and ConstantExpr::ConstantExpr
  is responsible for the initialization.

Review after commit since this is a straightforward mechanical fix
similar to the other serialization fixes.

Added: 
clang/test/AST/ast-dump-constant-expr.cpp

Modified: 
clang/include/clang/AST/Expr.h
clang/include/clang/AST/Stmt.h
clang/lib/AST/Expr.cpp
clang/lib/Serialization/ASTReaderStmt.cpp
clang/lib/Serialization/ASTWriterStmt.cpp

Removed: 




diff  --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index f8f104b5580b..8ee8aa96ae63 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -990,6 +990,9 @@ class ConstantExpr final
   static_assert(std::is_same::value,
 "ConstantExpr assumes that llvm::APInt::WordType is uint64_t "
 "for tail-allocated storage");
+  friend TrailingObjects;
+  friend class ASTStmtReader;
+  friend class ASTStmtWriter;
 
 public:
   /// Describes the kind of result that can be tail-allocated.
@@ -1003,7 +1006,6 @@ class ConstantExpr final
 return ConstantExprBits.ResultKind == ConstantExpr::RSK_Int64;
   }
 
-  void DefaultInit(ResultStorageKind StorageKind);
   uint64_t () {
 assert(ConstantExprBits.ResultKind == ConstantExpr::RSK_Int64 &&
"invalid accessor");
@@ -1021,21 +1023,18 @@ class ConstantExpr final
 return const_cast(this)->APValueResult();
   }
 
-  ConstantExpr(Expr *subexpr, ResultStorageKind StorageKind);
-  ConstantExpr(ResultStorageKind StorageKind, EmptyShell Empty);
+  ConstantExpr(Expr *SubExpr, ResultStorageKind StorageKind,
+   bool IsImmediateInvocation);
+  ConstantExpr(EmptyShell Empty, ResultStorageKind StorageKind);
 
 public:
-  friend TrailingObjects;
-  friend class ASTStmtReader;
-  friend class ASTStmtWriter;
   static ConstantExpr *Create(const ASTContext , Expr *E,
   const APValue );
   static ConstantExpr *Create(const ASTContext , Expr *E,
   ResultStorageKind Storage = RSK_None,
   bool IsImmediateInvocation = false);
   static ConstantExpr *CreateEmpty(const ASTContext ,
-   ResultStorageKind StorageKind,
-   EmptyShell Empty);
+   ResultStorageKind StorageKind);
 
   static ResultStorageKind getStorageKind(const APValue );
   static ResultStorageKind getStorageKind(const Type *T,

diff  --git a/clang/include/clang/AST/Stmt.h b/clang/include/clang/AST/Stmt.h
index d76d99b65551..a226790aa76c 100644
--- a/clang/include/clang/AST/Stmt.h
+++ b/clang/include/clang/AST/Stmt.h
@@ -325,7 +325,7 @@ class alignas(void *) Stmt {
 /// The kind of result that is tail-allocated.
 unsigned ResultKind : 2;
 
-/// The kind of Result as defined by APValue::Kind
+/// The kind of Result as defined by APValue::Kind.
 unsigned APValueKind : 4;
 
 /// When ResultKind == RSK_Int64, true if the tail-allocated integer is

diff  --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index 27a12b880a7b..5cbd66f11601 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -244,6 +244,7 @@ static void 
AssertResultStorageKind(ConstantExpr::ResultStorageKind Kind) {
   assert((Kind == ConstantExpr::RSK_APValue ||
   Kind == ConstantExpr::RSK_Int64 || Kind == ConstantExpr::RSK_None) &&
  "Invalid StorageKind Value");
+  (void)Kind;
 }
 
 ConstantExpr::ResultStorageKind
@@ -268,33 +269,31 @@ ConstantExpr::getStorageKind(const Type *T, const 
ASTContext ) {
   return ConstantExpr::RSK_APValue;
 }
 
-void ConstantExpr::DefaultInit(ResultStorageKind StorageKind) {
+ConstantExpr::ConstantExpr(Expr *SubExpr, 

[clang] e560280 - [clang][NFC] Regenerate test/AST/ast-dump-lambda.cpp with --match-full-lines.

2020-06-21 Thread Bruno Ricci via cfe-commits

Author: Bruno Ricci
Date: 2020-06-21T13:59:11+01:00
New Revision: e560280cd5739503cd9a75e05da769a6742918b5

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

LOG: [clang][NFC] Regenerate test/AST/ast-dump-lambda.cpp with 
--match-full-lines.

Added: 


Modified: 
clang/test/AST/ast-dump-lambda.cpp

Removed: 




diff  --git a/clang/test/AST/ast-dump-lambda.cpp 
b/clang/test/AST/ast-dump-lambda.cpp
index 4b53b17aa284..a3ca4a8fc534 100644
--- a/clang/test/AST/ast-dump-lambda.cpp
+++ b/clang/test/AST/ast-dump-lambda.cpp
@@ -1,12 +1,14 @@
 // Test without serialization:
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -Wno-unused-value 
-std=gnu++17 \
-// RUN: -ast-dump %s | FileCheck 
-strict-whitespace %s
+// RUN: -ast-dump %s -ast-dump-filter 
test \
+// RUN: | FileCheck -strict-whitespace --match-full-lines %s
 
 // Test with serialization:
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -Wno-unused-value 
-std=gnu++17 \
 // RUN:-emit-pch -o %t %s
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -Wno-unused-value 
-std=gnu++17 \
-// RUN:-x c++ -include-pch %t -ast-dump-all | FileCheck 
-strict-whitespace %s
+// RUN:-x c++ -include-pch %t -ast-dump-all -ast-dump-filter test \
+// RUN: | FileCheck -strict-whitespace --match-full-lines %s
 
 
 
@@ -32,262 +34,262 @@ template  void test(Ts... a) {
   []() noexcept {};
   []() -> int { return 0; };
 }
-// CHECK: TranslationUnitDecl {{.*}} <> {{( 
)?}}
-// CHECK: `-FunctionTemplateDecl {{.*}} <{{.*}}ast-dump-lambda.cpp:13:1, 
line:34:1> line:13:32{{( imported)?}} test
-// CHECK-NEXT:   |-TemplateTypeParmDecl {{.*}}  col:23{{( 
imported)?}} referenced typename depth 0 index 0 ... Ts
-// CHECK-NEXT:   `-FunctionDecl {{.*}}  line:13:32{{( 
imported)?}} test 'void (Ts...)'
-// CHECK-NEXT: |-ParmVarDecl {{.*}}  col:43{{( 
imported)?}} referenced a 'Ts...' pack
-// CHECK-NEXT: `-CompoundStmt {{.*}} 
-// CHECK-NEXT:   |-DeclStmt {{.*}} 
-// CHECK-NEXT:   | `-CXXRecordDecl {{.*}}  
line:14:10{{( imported)?}}{{( )?}} struct V 
definition
-// CHECK-NEXT:   |   |-DefinitionData empty aggregate standard_layout 
trivially_copyable pod trivial literal has_constexpr_non_copy_move_ctor 
can_const_default_init
-// CHECK-NEXT:   |   | |-DefaultConstructor exists trivial constexpr 
needs_implicit defaulted_is_constexpr
-// CHECK-NEXT:   |   | |-CopyConstructor simple trivial has_const_param 
needs_implicit implicit_has_const_param
-// CHECK-NEXT:   |   | |-MoveConstructor exists simple trivial 
needs_implicit
-// CHECK-NEXT:   |   | |-CopyAssignment simple trivial has_const_param 
needs_implicit implicit_has_const_param
-// CHECK-NEXT:   |   | |-MoveAssignment exists simple trivial 
needs_implicit
-// CHECK-NEXT:   |   | `-Destructor simple irrelevant trivial 
needs_implicit
-// CHECK-NEXT:   |   |-CXXRecordDecl {{.*}}  col:10{{( 
imported)?}} implicit struct V
-// CHECK-NEXT:   |   `-CXXMethodDecl {{.*}}  
line:15:10{{( imported)?}} f 'void ()'
-// CHECK-NEXT:   | `-CompoundStmt {{.*}} 
-// CHECK-NEXT:   |   |-LambdaExpr {{.*}}  '(lambda 
at {{.*}}ast-dump-lambda.cpp:16:7)'
-// CHECK-NEXT:   |   | |-CXXRecordDecl {{.*}}  col:7{{( 
imported)?}} implicit{{( )?}} class definition
-// CHECK-NEXT:   |   | | |-DefinitionData lambda standard_layout 
trivially_copyable can_const_default_init
-// CHECK-NEXT:   |   | | | |-DefaultConstructor
-// CHECK-NEXT:   |   | | | |-CopyConstructor simple trivial 
has_const_param needs_implicit implicit_has_const_param
-// CHECK-NEXT:   |   | | | |-MoveConstructor exists simple trivial 
needs_implicit
-// CHECK-NEXT:   |   | | | |-CopyAssignment trivial has_const_param 
needs_implicit implicit_has_const_param
-// CHECK-NEXT:   |   | | | |-MoveAssignment
-// CHECK-NEXT:   |   | | | `-Destructor simple irrelevant trivial 
needs_implicit
-// CHECK-NEXT:   |   | | |-CXXMethodDecl {{.*}}  
col:7{{( imported)?}} operator() 'auto () const -> auto' inline
-// CHECK-NEXT:   |   | | | `-CompoundStmt {{.*}} 
-// CHECK-NEXT:   |   | | `-FieldDecl {{.*}}  col:8{{( 
imported)?}} implicit 'V *'
-// CHECK-NEXT:   |   | |-ParenListExpr {{.*}}  'NULL TYPE'
-// CHECK-NEXT:   |   | | `-CXXThisExpr {{.*}}  'V *' this
-// CHECK-NEXT:   |   | `-CompoundStmt {{.*}} 
-// CHECK-NEXT:   |   `-LambdaExpr {{.*}}  '(lambda 
at {{.*}}ast-dump-lambda.cpp:17:7)'
-// CHECK-NEXT:   | |-CXXRecordDecl {{.*}}  col:7{{( 
imported)?}} implicit{{( )?}} class definition
-// CHECK-NEXT:   | | |-DefinitionData lambda standard_layout 

[clang] cddc999 - [clang][test][NFC] Also test for serialization in AST dump tests, part 3/n.

2020-06-21 Thread Bruno Ricci via cfe-commits

Author: Bruno Ricci
Date: 2020-06-21T13:59:11+01:00
New Revision: cddc9993eafd76f08989beea037d085521d48127

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

LOG: [clang][test][NFC] Also test for serialization in AST dump tests, part 3/n.

The outputs between the direct ast-dump test and the ast-dump test after
deserialization should match modulo a few differences.

For hand-written tests, strip the ""s and
the "imported"s with sed.

For tests generated with "make-ast-dump-check.sh", regenerate the output.

Part 3/n.

Added: 


Modified: 
clang/test/AST/atomic-expr.cpp
clang/test/AST/c-casts.c
clang/test/AST/category-attribute.m
clang/test/AST/coroutine-source-location-crash.cpp
clang/test/AST/deduction-guides.cpp
clang/test/AST/fixed_point.c
clang/test/AST/fixed_point_to_string.c
clang/test/AST/float16.cpp
clang/test/AST/implicit-cast-dump.c
clang/test/AST/language_address_space_attribute.cpp
clang/test/AST/multistep-explicit-cast.c
clang/test/AST/multistep-explicit-cast.cpp
clang/test/AST/pr43983.cpp
clang/test/AST/property-atomic-bool.m
clang/test/AST/template-implicit-vars.cpp
clang/test/AST/variadic-promotion.c

Removed: 




diff  --git a/clang/test/AST/atomic-expr.cpp b/clang/test/AST/atomic-expr.cpp
index e7fb6ba833e5..db21d61e98c2 100644
--- a/clang/test/AST/atomic-expr.cpp
+++ b/clang/test/AST/atomic-expr.cpp
@@ -1,4 +1,11 @@
+// Test without serialization:
 // RUN: %clang_cc1 -ast-dump %s | FileCheck %s
+//
+// Test with serialization:
+// RUN: %clang_cc1 -emit-pch -o %t %s
+// RUN: %clang_cc1 -x c++ -include-pch %t -ast-dump-all /dev/null \
+// RUN: | sed -e "s/ //" -e "s/ imported//" \
+// RUN: | FileCheck %s
 
 template
 void pr43370() {
@@ -17,14 +24,14 @@ void useage(){
   foo();
 }
 
-// CHECK:FunctionTemplateDecl 0x{{[0-9a-f]+}} <{{[^,]+}}, line:7:1> line:4:6 
pr43370
+// CHECK:FunctionTemplateDecl 0x{{[0-9a-f]+}} <{{[^,]+}}, line:{{.*}}:1> 
line:{{.*}}:6 pr43370
 // CHECK: AtomicExpr
 // CHECK-NEXT: ImplicitCastExpr
 // CHECK-SAME: 
 // CHECK-NEXT: DeclRefExpr 0x{{[0-9a-f]+}} <{{[^:]+}}:20> 'int [2]' lvalue Var 
0x{{[0-9a-f]+}} 'arr' 'int [2]'
 // CHECK-NEXT: IntegerLiteral 0x{{[0-9a-f]+}} <{{[^:]+}}:28> 'int' 5
 // CHECK-NEXT: IntegerLiteral 0x{{[0-9a-f]+}} <{{[^:]+}}:25> 'int' 0
-// CHECK:FunctionDecl 0x{{[0-9a-f]+}}  line:4:6 used 
pr43370
+// CHECK:FunctionDecl 0x{{[0-9a-f]+}}  
line:{{.*}}:6 used pr43370
 // CHECK: AtomicExpr
 // CHECK-NEXT: ImplicitCastExpr
 // CHECK-SAME: 
@@ -32,7 +39,7 @@ void useage(){
 // CHECK-NEXT: IntegerLiteral 0x{{[0-9a-f]+}} <{{[^:]+}}:28> 'int' 5
 // CHECK-NEXT: IntegerLiteral 0x{{[0-9a-f]+}} <{{[^:]+}}:25> 'int' 0
 
-// CHECK:FunctionTemplateDecl 0x{{[0-9a-f]+}}  line:10:6 
foo
+// CHECK:FunctionTemplateDecl 0x{{[0-9a-f]+}}  
line:{{.*}}:6 foo
 // CHECK: AtomicExpr
 // CHECK-NEXT: ImplicitCastExpr
 // CHECK-SAME: 
@@ -45,7 +52,7 @@ void useage(){
 // CHECK-NEXT: IntegerLiteral 0x{{[0-9a-f]+}} <{{[^:]+}}:47> 'int' 1
 // CHECK-NEXT: ImplicitCastExpr
 // CHECK-NEXT: IntegerLiteral 0x{{[0-9a-f]+}} <{{[^:]+}}:50> 'int' 0
-// CHECK:FunctionDecl 0x{{[0-9a-f]+}}  line:10:6 used foo
+// CHECK:FunctionDecl 0x{{[0-9a-f]+}}  
line:{{.*}}:6 used foo
 // CHECK: AtomicExpr
 // CHECK-NEXT: ImplicitCastExpr
 // CHECK-SAME: 

diff  --git a/clang/test/AST/c-casts.c b/clang/test/AST/c-casts.c
index c3a58ed8274c..5eaa4aaf2345 100644
--- a/clang/test/AST/c-casts.c
+++ b/clang/test/AST/c-casts.c
@@ -1,4 +1,11 @@
+// Test without serialization:
 // RUN: %clang_cc1 -w -ast-dump %s | FileCheck %s
+//
+// Test with serialization:
+// RUN: %clang_cc1 -w -emit-pch -o %t %s
+// RUN: %clang_cc1 -w -x c -include-pch %t -ast-dump-all /dev/null \
+// RUN: | sed -e "s/ //" -e "s/ imported//" \
+// RUN: | FileCheck %s
 
 // The cast construction code both for implicit and c-style casts is very
 // 
diff erent in C vs C++. This file is intended to test the C behavior.

diff  --git a/clang/test/AST/category-attribute.m 
b/clang/test/AST/category-attribute.m
index 7efe3df00ec8..e74f1a1ffbc1 100644
--- a/clang/test/AST/category-attribute.m
+++ b/clang/test/AST/category-attribute.m
@@ -1,5 +1,13 @@
+// Test without serialization:
 // RUN: %clang_cc1 -fsyntax-only -verify %s
 // RUN: %clang_cc1 -fsyntax-only -ast-dump %s | FileCheck %s
+//
+// Test with serialization:
+// RUN: %clang_cc1 -emit-pch -o %t %s
+// RUN: %clang_cc1 -x objective-c -include-pch %t -ast-dump-all /dev/null \
+// RUN: | sed -e "s/ //" -e "s/ imported//" \
+// RUN: | FileCheck %s
+//
 // expected-no-diagnostics
 
 __attribute__ ((external_source_symbol(language= "Swift", defined_in="A")))

diff  --git a/clang/test/AST/coroutine-source-location-crash.cpp 
b/clang/test/AST/coroutine-source-location-crash.cpp
index 

[PATCH] D82188: [clang-tidy] Reworked enum options handling(again)

2020-06-21 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 272306.
njames93 added a comment.

Update doc comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82188

Files:
  clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
  clang-tools-extra/clang-tidy/ClangTidyCheck.h
  clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
  clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
  clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
  clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp
  clang-tools-extra/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp
  clang-tools-extra/clang-tidy/modernize/ReplaceRandomShuffleCheck.cpp
  clang-tools-extra/clang-tidy/performance/MoveConstructorInitCheck.cpp
  clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.cpp
  clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
  clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
  clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h
  clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp
  clang-tools-extra/clang-tidy/utils/IncludeSorter.h
  clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
  clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp

Index: clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
@@ -6,6 +6,20 @@
 
 namespace clang {
 namespace tidy {
+
+enum class Colours { Red, Orange, Yellow, Green, Blue, Indigo, Violet };
+
+template <> struct OptionEnumMapping {
+  static llvm::ArrayRef> getEnumMapping() {
+static constexpr std::pair Mapping[] = {
+{Colours::Red, "Red"},   {Colours::Orange, "Orange"},
+{Colours::Yellow, "Yellow"}, {Colours::Green, "Green"},
+{Colours::Blue, "Blue"}, {Colours::Indigo, "Indigo"},
+{Colours::Violet, "Violet"}};
+return makeArrayRef(Mapping);
+  }
+};
+
 namespace test {
 
 TEST(ParseLineFilter, EmptyFilter) {
@@ -209,15 +223,6 @@
 }
 
 TEST(ValidConfiguration, ValidEnumOptions) {
-
-  enum class Colours { Red, Orange, Yellow, Green, Blue, Indigo, Violet };
-  static constexpr std::pair Mapping[] = {
-  {"Red", Colours::Red},   {"Orange", Colours::Orange},
-  {"Yellow", Colours::Yellow}, {"Green", Colours::Green},
-  {"Blue", Colours::Blue}, {"Indigo", Colours::Indigo},
-  {"Violet", Colours::Violet}};
-  static const auto Map = makeArrayRef(Mapping);
-
   ClangTidyOptions Options;
   auto  = Options.CheckOptions;
 
@@ -237,29 +242,30 @@
 #define CHECK_ERROR_ENUM(Name, Expected)   \
   CHECK_ERROR(Name, UnparseableEnumOptionError, Expected)
 
-  CHECK_VAL(TestCheck.getLocal("Valid", Map), Colours::Red);
-  CHECK_VAL(TestCheck.getGlobal("GlobalValid", Map), Colours::Violet);
-  CHECK_VAL(TestCheck.getLocal("ValidWrongCase", Map, /*IgnoreCase*/ true),
-Colours::Red);
+  CHECK_VAL(TestCheck.getIntLocal("Valid"), Colours::Red);
+  CHECK_VAL(TestCheck.getIntGlobal("GlobalValid"), Colours::Violet);
   CHECK_VAL(
-  TestCheck.getGlobal("GlobalValidWrongCase", Map, /*IgnoreCase*/ true),
-  Colours::Violet);
-  CHECK_ERROR_ENUM(TestCheck.getLocal("Invalid", Map),
+  TestCheck.getIntLocal("ValidWrongCase", /*IgnoreCase*/ true),
+  Colours::Red);
+  CHECK_VAL(TestCheck.getIntGlobal("GlobalValidWrongCase",
+/*IgnoreCase*/ true),
+Colours::Violet);
+  CHECK_ERROR_ENUM(TestCheck.getIntLocal("Invalid"),
"invalid configuration value "
"'Scarlet' for option 'test.Invalid'");
-  CHECK_ERROR_ENUM(TestCheck.getLocal("ValidWrongCase", Map),
+  CHECK_ERROR_ENUM(TestCheck.getIntLocal("ValidWrongCase"),
"invalid configuration value 'rED' for option "
"'test.ValidWrongCase'; did you mean 'Red'?");
-  CHECK_ERROR_ENUM(TestCheck.getLocal("NearMiss", Map),
+  CHECK_ERROR_ENUM(TestCheck.getIntLocal("NearMiss"),
"invalid configuration value 'Oragne' for option "
"'test.NearMiss'; did you mean 'Orange'?");
-  CHECK_ERROR_ENUM(TestCheck.getGlobal("GlobalInvalid", Map),
+  CHECK_ERROR_ENUM(TestCheck.getIntGlobal("GlobalInvalid"),
"invalid configuration value "
"'Purple' for option 'GlobalInvalid'");
-  CHECK_ERROR_ENUM(TestCheck.getGlobal("GlobalValidWrongCase", Map),
+  CHECK_ERROR_ENUM(TestCheck.getIntGlobal("GlobalValidWrongCase"),
"invalid configuration value 'vIOLET' for option "
  

[PATCH] D82256: [analyzer] Enabling ctr in evalCall event

2020-06-21 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus accepted this revision.
Szelethus added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/AnalysisOrderChecker.cpp:130
+llvm::errs() << " (" << ND->getQualifiedNameAsString() << ')';
+  llvm::errs() << " {" << Call.getNumArgs() << '}';
+  llvm::errs() << " [" << Call.getKindAsString() << ']';

This seems a bit cryptic, how about `{argno:`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82256



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


[PATCH] D80961: Ignore template instantiations if not in AsIs mode

2020-06-21 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

Here's another example where it is not appropriate to transform a template 
instantiation:

http://clang-developers.42468.n3.nabble.com/Questions-discussions-about-cast-types-in-clang-td4068626.html

"If we call foo, it can be a const_cast, but if we call foo, it 
has to be a reinterpret_cast. In a situation where the user is writing library 
code, it won't only be relevant to the current translation unit but also for 
future purposes. Therefore, I propose that we leave dependent type c-style 
casts as they are."

Just recording it as part of the motivation of this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80961



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


[PATCH] D82256: [analyzer] Enabling ctr in evalCall event

2020-06-21 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Hmm, given that you're using ARC, you're probably intending to turn the review 
title/summary into a commit message. Let's make it prettier then:

- Commit messages are typically written in imperative mood, eg. "Enabling" -> 
"Enable", "Adding"/"Added" -> "Add".
- Abbreviating "constructor" to "ctr" was really unnecessary :)




Comment at: clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp:586
   ExplodedNodeSet dstCallEvaluated;
+  EvalCallOptions CallOpts;
   getCheckerManager().runCheckersForEvalCall(dstCallEvaluated, dstPreVisit,

vrnithinkumar wrote:
> NoQ wrote:
> > If you want you can make it an optional argument of 
> > `runCheckersForEvalCall()`, like it's done in `defaultEvalCall()`.
> I tried to make it as default argument for `runCheckersForEvalCall()` but 
> `struct EvalCallOptions` is forward declared in `CheckerManager.h`.
Oh well! You probably still don't need a separate local variable, can you try 
`EvalCallOptions()` or even `{}`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82256



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


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

2020-06-21 Thread Wenlei He via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7c8a6936bf6b: [Remarks] Add callsite locations to inline 
remarks (authored by wenlei).

Changed prior to commit:
  https://reviews.llvm.org/D82213?vs=272263=272289#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82213

Files:
  clang/test/Frontend/optimization-remark-with-hotness-new-pm.c
  clang/test/Frontend/optimization-remark-with-hotness.c
  llvm/include/llvm/Analysis/InlineAdvisor.h
  llvm/lib/Analysis/InlineAdvisor.cpp
  llvm/lib/Transforms/IPO/SampleProfile.cpp
  llvm/test/Transforms/Inline/optimization-remarks-passed-yaml.ll
  llvm/test/Transforms/SampleProfile/Inputs/remarks.prof
  llvm/test/Transforms/SampleProfile/remarks.ll

Index: llvm/test/Transforms/SampleProfile/remarks.ll
===
--- llvm/test/Transforms/SampleProfile/remarks.ll
+++ llvm/test/Transforms/SampleProfile/remarks.ll
@@ -21,7 +21,8 @@
 
 ; We are expecting foo() to be inlined in main() (almost all the cycles are
 ; spent inside foo).
-; CHECK: remark: remarks.cc:13:21: inlined callee '_Z3foov' into 'main'
+; CHECK: remark: remarks.cc:13:21: _Z3foov inlined into main to match profiling context with (cost=130, threshold=225) at callsite main:0
+; CHECK: remark: remarks.cc:9:19: rand inlined into main to match profiling context with (cost=always): always inline attribute at callsite _Z3foov:6 @ main:0
 
 ; The back edge for the loop is the hottest edge in the loop subgraph.
 ; CHECK: remark: remarks.cc:6:9: most popular destination for conditional branches at remarks.cc:5:3
@@ -32,18 +33,51 @@
 ; Checking to see if YAML file is generated and contains remarks
 ;YAML:   --- !Passed
 ;YAML-NEXT:  Pass:sample-profile-inline
-;YAML-NEXT:  Name:InlineSuccess
+;YAML-NEXT:  Name:Inlined
 ;YAML-NEXT:  DebugLoc:{ File: remarks.cc, Line: 13, Column: 21 }
 ;YAML-NEXT:  Function:main
 ;YAML-NEXT:  Args:
-;YAML-NEXT:- String:  'inlined callee '''
 ;YAML-NEXT:- Callee:  _Z3foov
 ;YAML-NEXT:  DebugLoc:{ File: remarks.cc, Line: 3, Column: 0 }
-;YAML-NEXT:- String:  ''' into '''
+;YAML-NEXT:- String:  ' inlined into '
 ;YAML-NEXT:- Caller:  main
 ;YAML-NEXT:DebugLoc:{ File: remarks.cc, Line: 13, Column: 0 }
-;YAML-NEXT:- String:  
+;YAML-NEXT:- String:  ' to match profiling context'
+;YAML-NEXT:- String:  ' with '
+;YAML-NEXT:- String:  '(cost='
+;YAML-NEXT:- Cost:'130'
+;YAML-NEXT:- String:  ', threshold='
+;YAML-NEXT:- Threshold:   '225'
+;YAML-NEXT:- String:  ')'
+;YAML-NEXT:- String:  ' at callsite '
+;YAML-NEXT:- String:  main
+;YAML-NEXT:- String:  ':'
+;YAML-NEXT:- Line:'0'
 ;YAML-NEXT:  ...
+;YAML:   --- !Passed
+;YAML-NEXT:  Pass:sample-profile-inline
+;YAML-NEXT:  Name:AlwaysInline
+;YAML-NEXT:  DebugLoc:{ File: remarks.cc, Line: 9, Column: 19 }
+;YAML-NEXT:  Function:main
+;YAML-NEXT:  Args:
+;YAML-NEXT:- Callee:  rand
+;YAML-NEXT:  DebugLoc:{ File: remarks.cc, Line: 90, Column: 0 }
+;YAML-NEXT:- String:  ' inlined into '
+;YAML-NEXT:- Caller:  main
+;YAML-NEXT:  DebugLoc:{ File: remarks.cc, Line: 13, Column: 0 }
+;YAML-NEXT:- String:  ' to match profiling context'
+;YAML-NEXT:- String:  ' with '
+;YAML-NEXT:- String:  '(cost=always)'
+;YAML-NEXT:- String:  ': '
+;YAML-NEXT:- Reason:  always inline attribute
+;YAML-NEXT:- String:  ' at callsite '
+;YAML-NEXT:- String:  _Z3foov
+;YAML-NEXT:- String:  ':'
+;YAML-NEXT:- Line:'6'
+;YAML-NEXT:- String:  ' @ '
+;YAML-NEXT:- String:  main
+;YAML-NEXT:- String:  ':'
+;YAML-NEXT:- Line:'0'
 ;YAML:  --- !Analysis
 ;YAML-NEXT:  Pass:sample-profile
 ;YAML-NEXT:  Name:AppliedSamples
@@ -139,7 +173,9 @@
 declare void @llvm.dbg.declare(metadata, metadata, metadata) #2
 
 ; Function Attrs: nounwind
-declare i32 @rand() #3
+define i32 @rand() #3 !dbg !59 {
+  ret i32 1
+}
 
 ; Function Attrs: nounwind argmemonly
 declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) #1
@@ -158,7 +194,7 @@
 attributes #0 = { nounwind uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" "use-sample-profile" }
 attributes #1 = { nounwind argmemonly }
 attributes #2 = { 

[clang] 7c8a693 - [Remarks] Add callsite locations to inline remarks

2020-06-21 Thread Wenlei He via cfe-commits

Author: Wenlei He
Date: 2020-06-20T23:32:10-07:00
New Revision: 7c8a6936bf6b578518673f442c6c292d62cdd465

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

LOG: [Remarks] Add callsite locations to inline remarks

Summary:
Add call site location info into inline remarks so we can differentiate inline 
sites.
This can be useful for inliner tuning. We can also reconstruct full 
hierarchical inline
tree from parsing such remarks. The messege of inline remark is also tweaked so 
we can
differentiate SampleProfileLoader inline from CGSCC inline.

Reviewers: wmi, davidxl, hoy

Subscribers: hiraditya, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

Added: 


Modified: 
clang/test/Frontend/optimization-remark-with-hotness-new-pm.c
clang/test/Frontend/optimization-remark-with-hotness.c
llvm/include/llvm/Analysis/InlineAdvisor.h
llvm/lib/Analysis/InlineAdvisor.cpp
llvm/lib/Transforms/IPO/SampleProfile.cpp
llvm/test/Transforms/Inline/optimization-remarks-passed-yaml.ll
llvm/test/Transforms/SampleProfile/Inputs/remarks.prof
llvm/test/Transforms/SampleProfile/remarks.ll

Removed: 




diff  --git a/clang/test/Frontend/optimization-remark-with-hotness-new-pm.c 
b/clang/test/Frontend/optimization-remark-with-hotness-new-pm.c
index 24da0925abdc..2a03bcb9390f 100644
--- a/clang/test/Frontend/optimization-remark-with-hotness-new-pm.c
+++ b/clang/test/Frontend/optimization-remark-with-hotness-new-pm.c
@@ -73,7 +73,7 @@ void bar(int x) {
   // THRESHOLD-NOT: hotness
   // NO_PGO: '-fdiagnostics-show-hotness' requires profile-guided optimization 
information
   // NO_PGO: '-fdiagnostics-hotness-threshold=' requires profile-guided 
optimization information
-  // expected-remark@+1 {{foo inlined into bar with (cost=always): always 
inline attribute (hotness:}}
+  // expected-remark@+1 {{foo inlined into bar with (cost=always): always 
inline attribute at callsite bar:8 (hotness:}}
   sum += foo(x, x - 2);
 }
 

diff  --git a/clang/test/Frontend/optimization-remark-with-hotness.c 
b/clang/test/Frontend/optimization-remark-with-hotness.c
index 0f3a4e9d1d6b..96be3524db16 100644
--- a/clang/test/Frontend/optimization-remark-with-hotness.c
+++ b/clang/test/Frontend/optimization-remark-with-hotness.c
@@ -66,7 +66,7 @@ void bar(int x) {
   // THRESHOLD-NOT: hotness
   // NO_PGO: '-fdiagnostics-show-hotness' requires profile-guided optimization 
information
   // NO_PGO: '-fdiagnostics-hotness-threshold=' requires profile-guided 
optimization information
-  // expected-remark@+1 {{foo inlined into bar with (cost=always): always 
inliner (hotness:}}
+  // expected-remark@+1 {{foo inlined into bar with (cost=always): always 
inliner at callsite bar:8 (hotness:}}
   sum += foo(x, x - 2);
 }
 

diff  --git a/llvm/include/llvm/Analysis/InlineAdvisor.h 
b/llvm/include/llvm/Analysis/InlineAdvisor.h
index 7268c11fdd79..66a848e865e1 100644
--- a/llvm/include/llvm/Analysis/InlineAdvisor.h
+++ b/llvm/include/llvm/Analysis/InlineAdvisor.h
@@ -217,7 +217,12 @@ shouldInline(CallBase , 
function_ref GetInlineCost,
 /// Emit ORE message.
 void emitInlinedInto(OptimizationRemarkEmitter , DebugLoc DLoc,
  const BasicBlock *Block, const Function ,
- const Function , const InlineCost );
+ const Function , const InlineCost ,
+ bool ForProfileContext = false,
+ const char *PassName = nullptr);
+
+/// Add location info to ORE message.
+void addLocationToRemarks(OptimizationRemark , DebugLoc DLoc);
 
 /// Set the inline-remark attribute.
 void setInlineRemark(CallBase , StringRef Message);

diff  --git a/llvm/lib/Analysis/InlineAdvisor.cpp 
b/llvm/lib/Analysis/InlineAdvisor.cpp
index d3cd703385f4..2d7b4cabebb1 100644
--- a/llvm/lib/Analysis/InlineAdvisor.cpp
+++ b/llvm/lib/Analysis/InlineAdvisor.cpp
@@ -18,6 +18,7 @@
 #include "llvm/Analysis/ProfileSummaryInfo.h"
 #include "llvm/Analysis/TargetLibraryInfo.h"
 #include "llvm/Analysis/TargetTransformInfo.h"
+#include "llvm/IR/DebugInfoMetadata.h"
 #include "llvm/IR/Instructions.h"
 #include "llvm/Support/raw_ostream.h"
 
@@ -354,14 +355,43 @@ llvm::shouldInline(CallBase ,
   return IC;
 }
 
+void llvm::addLocationToRemarks(OptimizationRemark , DebugLoc DLoc) {
+  if (!DLoc.get())
+return;
+
+  bool First = true;
+  Remark << " at callsite ";
+  for (DILocation *DIL = DLoc.get(); DIL; DIL = DIL->getInlinedAt()) {
+if (!First)
+  Remark << " @ ";
+unsigned int Offset = DIL->getLine();
+Offset -= DIL->getScope()->getSubprogram()->getLine();
+unsigned int Discriminator = DIL->getBaseDiscriminator();
+StringRef Name = DIL->getScope()->getSubprogram()->getLinkageName();
+if