[PATCH] D58609: [clang-tidy] bugprone-string-integer-assignment: Reduce false positives.

2019-02-25 Thread Clement Courbet via Phabricator via cfe-commits
courbet updated this revision to Diff 188316.
courbet added a comment.

- more tests


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D58609

Files:
  clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
  test/clang-tidy/bugprone-string-integer-assignment.cpp


Index: test/clang-tidy/bugprone-string-integer-assignment.cpp
===
--- test/clang-tidy/bugprone-string-integer-assignment.cpp
+++ test/clang-tidy/bugprone-string-integer-assignment.cpp
@@ -59,4 +59,11 @@
   s += toupper(x);
   s += tolower(x);
   s += std::tolower(x);
+
+  // Likely character expressions.
+  s += x & 0xff;
+  s += 0xff & x;
+
+  s += 'a' + (x % 26);
+  s += (x % 10) + 'b';
 }
Index: clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
===
--- clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
+++ clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
@@ -40,11 +40,44 @@
   this);
 }
 
+static bool isLikelyCharExpression(const Expr *Argument,
+   const ASTContext ) {
+  const auto *BinOp = dyn_cast(Argument);
+  if (!BinOp) {
+return false;
+  }
+  const auto *LHS = BinOp->getLHS()->IgnoreParenImpCasts();
+  const auto *RHS = BinOp->getRHS()->IgnoreParenImpCasts();
+  //  & , mask is a compile time constant.
+  Expr::EvalResult RHSVal;
+  if (BinOp->getOpcode() == BO_And &&
+  (RHS->EvaluateAsInt(RHSVal, Ctx, Expr::SE_AllowSideEffects) ||
+   LHS->EvaluateAsInt(RHSVal, Ctx, Expr::SE_AllowSideEffects))) {
+return true;
+  }
+  //  + ( % ), where  is a char literal.
+  const auto IsCharPlusModExpr = [](const Expr *L, const Expr *R) {
+const auto *ROp = dyn_cast(R);
+return ROp && ROp->getOpcode() == BO_Rem && isa(L);
+  };
+  if (BinOp->getOpcode() == BO_Add) {
+if (IsCharPlusModExpr(LHS, RHS) || IsCharPlusModExpr(RHS, LHS)) {
+  return true;
+}
+  }
+  return false;
+}
+
 void StringIntegerAssignmentCheck::check(
 const MatchFinder::MatchResult ) {
   const auto *Argument = Result.Nodes.getNodeAs("expr");
   SourceLocation Loc = Argument->getBeginLoc();
 
+  // Try to detect a few common expressions to reduce false positives.
+  if (isLikelyCharExpression(Argument, *Result.Context)) {
+return;
+  }
+
   auto Diag =
   diag(Loc, "an integer is interpreted as a character code when assigning "
 "it to a string; if this is intended, cast the integer to the "


Index: test/clang-tidy/bugprone-string-integer-assignment.cpp
===
--- test/clang-tidy/bugprone-string-integer-assignment.cpp
+++ test/clang-tidy/bugprone-string-integer-assignment.cpp
@@ -59,4 +59,11 @@
   s += toupper(x);
   s += tolower(x);
   s += std::tolower(x);
+
+  // Likely character expressions.
+  s += x & 0xff;
+  s += 0xff & x;
+
+  s += 'a' + (x % 26);
+  s += (x % 10) + 'b';
 }
Index: clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
===
--- clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
+++ clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
@@ -40,11 +40,44 @@
   this);
 }
 
+static bool isLikelyCharExpression(const Expr *Argument,
+   const ASTContext ) {
+  const auto *BinOp = dyn_cast(Argument);
+  if (!BinOp) {
+return false;
+  }
+  const auto *LHS = BinOp->getLHS()->IgnoreParenImpCasts();
+  const auto *RHS = BinOp->getRHS()->IgnoreParenImpCasts();
+  //  & , mask is a compile time constant.
+  Expr::EvalResult RHSVal;
+  if (BinOp->getOpcode() == BO_And &&
+  (RHS->EvaluateAsInt(RHSVal, Ctx, Expr::SE_AllowSideEffects) ||
+   LHS->EvaluateAsInt(RHSVal, Ctx, Expr::SE_AllowSideEffects))) {
+return true;
+  }
+  //  + ( % ), where  is a char literal.
+  const auto IsCharPlusModExpr = [](const Expr *L, const Expr *R) {
+const auto *ROp = dyn_cast(R);
+return ROp && ROp->getOpcode() == BO_Rem && isa(L);
+  };
+  if (BinOp->getOpcode() == BO_Add) {
+if (IsCharPlusModExpr(LHS, RHS) || IsCharPlusModExpr(RHS, LHS)) {
+  return true;
+}
+  }
+  return false;
+}
+
 void StringIntegerAssignmentCheck::check(
 const MatchFinder::MatchResult ) {
   const auto *Argument = Result.Nodes.getNodeAs("expr");
   SourceLocation Loc = Argument->getBeginLoc();
 
+  // Try to detect a few common expressions to reduce false positives.
+  if (isLikelyCharExpression(Argument, *Result.Context)) {
+return;
+  }
+
   auto Diag =
   diag(Loc, "an integer is interpreted as a character code when assigning "
 "it to a string; if this is intended, cast the integer to the "
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58569: [libclang] Avoid crashing when getting layout info of an undeduced type.

2019-02-25 Thread Emilio Cobos Álvarez via Phabricator via cfe-commits
emilio marked 2 inline comments as done.
emilio added a comment.

Huh, somehow forgot to press "Submit" this morning :)




Comment at: clang/tools/c-index-test/c-index-test.c:1695
+CXType RT = clang_getResultType(T);
+if (RT.kind != CXType_Invalid)
+  PrintSingleTypeSize(RT, " [resulttype=%s] [resulttypekind=%s]",

Anastasia wrote:
> emilio wrote:
> > Anastasia wrote:
> > > Should it not return undeduced error in the other case?
> > I'm not sure what you mean, can you clarify?
> > 
> > The undeduced error is only returned when you try to access the `Auto` type 
> > which is the return value, not the function type, which has a known layout.
> > 
> > So in the error case, `T` here is the `auto Tie(void*) const;` type, and 
> > `RT` is the undeduced `auto` type, which is what crashed.
> > 
> > We had no way to exercise this in `c-index-test`, so I changed it to 
> > exercise this codepath too. I can add a `CHECK` for the error code if you 
> > want.
> Yep, error check would be good since it's covers better changes in your patch.
Alrighty, done!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58569



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


[PATCH] D58321: [WIP] Support for relative vtables

2019-02-25 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/include/clang/Driver/Options.td:1250
+  Group, Flags<[CC1Option]>,
+  HelpText<"Use the unstable C++ class ABI for classes with hidden LTO 
visibility">;
 def flto_jobs_EQ : Joined<["-"], "flto-jobs=">,

Please make this a `-cc1` option or otherwise mark it clearly experimental.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58321



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


[PATCH] D56411: [CUDA][HIP][Sema] Fix template kernel with function as template parameter

2019-02-25 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In D56411#1406212 , @yaxunl wrote:

> I would like to fix the validation issue only and leave the overload 
> resolution issue for future.


As I understand it, the "validation issue" is just that you'd like a diagnostic 
to be emitted when resolving the template argument in order to force SFINAE to 
pick a different template.  I think that's actually just the 
overload-resolution issue.


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

https://reviews.llvm.org/D56411



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


[PATCH] D58634: [PR40778] Generate address space conversion when binding reference to a temporary value in different address space

2019-02-25 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/CodeGen/CGCall.cpp:4067
+  IRFuncTy->getParamType(FirstIRArg)->isPointerTy())
+V = Builder.CreatePointerBitCastOrAddrSpaceCast(
+V, IRFuncTy->getParamType(FirstIRArg));

Anastasia wrote:
> We have started using `performAddrSpaceCast` for those but, however, I was 
> very confused about how to get address space of the Clang types correctly 
> here.
> 
> I was using this function in a couple of places before but I must admit I am 
> still a bit confused about the purpose of it. Mainly I was wondering if we 
> could drop `LangAS` parameters from it? It would simplify its use a lot in 
> multiple places. As far as I can see they are not used in the function at the 
> moment. I am not sure if they are reserved for some development in the future 
> though?
> 
> Altogether I quite like using `IRBuilder` directly because in combination 
> with target address space map it allows to do what's needed here and keep 
> consistent with the rest. Perhaps, I am missing some background info. I have 
> tried to dig out a bit but no much success.
We want to allow language address spaces to be arbitrarily mapped to IR address 
spaces during lowering, which might include e.g. changing the null value.  
That's why we pass language address spaces down.

You should be getting the language address space from the appropriate type.  I 
wouldn't expect that to include address-space conversions at this point, 
though; is there maybe a missing implicit conversions somewhere?


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

https://reviews.llvm.org/D58634



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


[PATCH] D58663: [ASTImporter] Add support for importing ChooseExpr AST nodes.

2019-02-25 Thread Tom Roeder via Phabricator via cfe-commits
tmroeder updated this revision to Diff 188307.
tmroeder added a comment.

Dropped the C++ part of the ImportChooseExpr test entirely.

This is the part that was breaking the tests on Windows, and after further 
experimentation, it turns out that clang on Windows never expands the template 
under the conditions of the test. Dropping this test doesn't reduce coverage of 
the logic regression discussed in the original review. This is explained in the 
revised summary.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58663

Files:
  clang/docs/LibASTMatchersReference.html
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/ASTMatchers/ASTMatchersInternal.cpp
  clang/lib/ASTMatchers/Dynamic/Registry.cpp
  clang/test/ASTMerge/choose-expr/Inputs/choose.c
  clang/test/ASTMerge/choose-expr/test.c
  clang/unittests/AST/ASTImporterTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -754,6 +754,11 @@
   EXPECT_TRUE(matches("int* i = nullptr;", cxxNullPtrLiteralExpr()));
 }
 
+TEST(Matcher, ChooseExpr) {
+  EXPECT_TRUE(matchesC("void f() { (void)__builtin_choose_expr(1, 2, 3); }",
+   chooseExpr()));
+}
+
 TEST(Matcher, GNUNullExpr) {
   EXPECT_TRUE(matches("int* i = __null;", gnuNullExpr()));
 }
Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -563,6 +563,17 @@
   stringLiteral(hasType(asString("const char [7]"));
 }
 
+TEST_P(ImportExpr, ImportChooseExpr) {
+  MatchVerifier Verifier;
+
+  // This case tests C code that is not condition-dependent and has a true
+  // condition.
+  testImport(
+"void declToImport() { (void)__builtin_choose_expr(1, 2, 3); }",
+Lang_C, "", Lang_C, Verifier,
+functionDecl(hasDescendant(chooseExpr(;
+}
+
 TEST_P(ImportExpr, ImportGNUNullExpr) {
   MatchVerifier Verifier;
   testImport(
@@ -1312,6 +1323,27 @@
   ASSERT_EQ(ToTemplated1, ToTemplated);
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase, ImportChooseExpr) {
+  // This tests the import of isConditionTrue directly to make sure the importer
+  // gets it right.
+  Decl *From, *To;
+  std::tie(From, To) = getImportedDecl(
+"void declToImport() { (void)__builtin_choose_expr(1, 0, 1); }",
+Lang_C, "", Lang_C);
+
+  auto ToResults = match(chooseExpr().bind("choose"), To->getASTContext());
+  auto FromResults = match(chooseExpr().bind("choose"), From->getASTContext());
+
+  const ChooseExpr *FromChooseExpr =
+  selectFirst("choose", FromResults);
+  ASSERT_TRUE(FromChooseExpr);
+
+  const ChooseExpr *ToChooseExpr = selectFirst("choose", ToResults);
+  ASSERT_TRUE(ToChooseExpr);
+
+  EXPECT_EQ(FromChooseExpr->isConditionTrue(), ToChooseExpr->isConditionTrue());
+}
+
 TEST_P(ASTImporterOptionSpecificTestBase,
ImportFunctionWithBackReferringParameter) {
   Decl *From, *To;
Index: clang/test/ASTMerge/choose-expr/test.c
===
--- /dev/null
+++ clang/test/ASTMerge/choose-expr/test.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -std=c11 -emit-pch -o %t.ast %S/Inputs/choose.c
+// RUN: %clang_cc1 -std=c11 -ast-merge %t.ast -fsyntax-only -verify %s
+// expected-no-diagnostics
+
Index: clang/test/ASTMerge/choose-expr/Inputs/choose.c
===
--- /dev/null
+++ clang/test/ASTMerge/choose-expr/Inputs/choose.c
@@ -0,0 +1,2 @@
+_Static_assert(__builtin_choose_expr(1, 1, 0), "Incorrect semantics of __builtin_choose_expr");
+_Static_assert(__builtin_choose_expr(0, 0, 1), "Incorrect semantics of __builtin_choose_expr");
Index: clang/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -147,6 +147,7 @@
   REGISTER_MATCHER(caseStmt);
   REGISTER_MATCHER(castExpr);
   REGISTER_MATCHER(characterLiteral);
+  REGISTER_MATCHER(chooseExpr);
   REGISTER_MATCHER(classTemplateDecl);
   REGISTER_MATCHER(classTemplateSpecializationDecl);
   REGISTER_MATCHER(complexType);
Index: clang/lib/ASTMatchers/ASTMatchersInternal.cpp
===
--- clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -727,6 +727,7 @@
 compoundLiteralExpr;
 const internal::VariadicDynCastAllOfMatcher
 cxxNullPtrLiteralExpr;
+const internal::VariadicDynCastAllOfMatcher chooseExpr;
 const internal::VariadicDynCastAllOfMatcher gnuNullExpr;
 

[PATCH] D58514: Avoid needlessly copying blocks that initialize or are assigned to local auto variables to the heap

2019-02-25 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Okay, one last minor request, then LGTM.




Comment at: lib/CodeGen/CGObjC.cpp:2953
+  return asImpl().visitExpr(e);
+}
+

Oh, I'd forgotten this wasn't a normal expression visitor.  Well, okay, this 
isn't too bad.



Comment at: lib/Sema/SemaExpr.cpp:12461
+  if (auto *BE = dyn_cast(RHS.get()->IgnoreParens()))
+if (auto *DRE = dyn_cast(LHS.get()))
+  if (auto *VD = dyn_cast(DRE->getDecl()))

You should `IgnoreParens` on the LHS as well.  In general, you should always 
`IgnoreParens`.


Repository:
  rC Clang

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

https://reviews.llvm.org/D58514



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


[PATCH] D58663: [ASTImporter] Add support for importing ChooseExpr AST nodes.

2019-02-25 Thread Tom Roeder via Phabricator via cfe-commits
tmroeder created this revision.
tmroeder added reviewers: shafik, a_sidorin, martong, aaron.ballman, rnk.
tmroeder added a project: clang.
Herald added a reviewer: a.sidorin.

This allows ASTs to be merged when they contain ChooseExpr (the GNU
__builtin_choose_expr construction). This is needed, for example, for
cross-CTU analysis of C code that makes use of __builtin_choose_expr.

The node is already supported in the AST, but it didn't have a matcher
in ASTMatchers. So, this change adds the matcher and adds support to
ASTImporter.

This was originally reviewed and approved in
https://reviews.llvm.org/D58292 and submitted as r354832. It was
reverted in r354839 due to failures on the Windows CI builds.

This version fixes the test failures on Windows, caused by differences
in the behavior of -fms-compatibility between Linux and MSVC builds. In
MSVC builds, -fms-compatibility delays template evaluation for the C++
test case in clang/unittests/AST/ASTImporter.cpp, and that causes the
matcher to fail to match chooseExpr().

The only difference between this patch and r354839 is that the unit test
now checks for "-fms-compatibility" and treats it like
"-fdelayed-template-parsing": it doesn't try to match chooseExpr().


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D58663

Files:
  clang/docs/LibASTMatchersReference.html
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/ASTMatchers/ASTMatchersInternal.cpp
  clang/lib/ASTMatchers/Dynamic/Registry.cpp
  clang/test/ASTMerge/choose-expr/Inputs/choose.c
  clang/test/ASTMerge/choose-expr/test.c
  clang/unittests/AST/ASTImporterTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -754,6 +754,11 @@
   EXPECT_TRUE(matches("int* i = nullptr;", cxxNullPtrLiteralExpr()));
 }
 
+TEST(Matcher, ChooseExpr) {
+  EXPECT_TRUE(matchesC("void f() { (void)__builtin_choose_expr(1, 2, 3); }",
+   chooseExpr()));
+}
+
 TEST(Matcher, GNUNullExpr) {
   EXPECT_TRUE(matches("int* i = __null;", gnuNullExpr()));
 }
Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -563,6 +563,36 @@
   stringLiteral(hasType(asString("const char [7]"));
 }
 
+TEST_P(ImportExpr, ImportChooseExpr) {
+  MatchVerifier Verifier;
+
+  // This case tests C code that is not condition-dependent and has a true
+  // condition.
+  testImport(
+"void declToImport() { (void)__builtin_choose_expr(1, 2, 3); }",
+Lang_C, "", Lang_C, Verifier,
+functionDecl(hasDescendant(chooseExpr(;
+
+  ArgVector Args = getExtraArgs();
+  BindableMatcher Matcher =
+  functionTemplateDecl(hasDescendant(chooseExpr()));
+
+  // Don't try to match the template contents if template parsing. The
+  // -fms-compatibility flag delays template parsing on Windows.
+  if (llvm::find(Args, "-fdelayed-template-parsing") != Args.end() ||
+  llvm::find(Args, "-fms-compatibility") != Args.end()) {
+Matcher = functionTemplateDecl();
+  }
+
+  // Make sure that uses of (void)__builtin_choose_expr with dependent types in
+  // the condition are handled properly. This test triggers an assertion if the
+  // ASTImporter incorrectly tries to access isConditionTrue() when
+  // isConditionDependent() is true.
+  testImport("template void declToImport() { "
+ "(void)__builtin_choose_expr(N, 1, 0); }",
+ Lang_CXX, "", Lang_CXX, Verifier, Matcher);
+}
+
 TEST_P(ImportExpr, ImportGNUNullExpr) {
   MatchVerifier Verifier;
   testImport(
@@ -1312,6 +1342,27 @@
   ASSERT_EQ(ToTemplated1, ToTemplated);
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase, ImportChooseExpr) {
+  // This tests the import of isConditionTrue directly to make sure the importer
+  // gets it right.
+  Decl *From, *To;
+  std::tie(From, To) = getImportedDecl(
+"void declToImport() { (void)__builtin_choose_expr(1, 0, 1); }",
+Lang_C, "", Lang_C);
+
+  auto ToResults = match(chooseExpr().bind("choose"), To->getASTContext());
+  auto FromResults = match(chooseExpr().bind("choose"), From->getASTContext());
+
+  const ChooseExpr *FromChooseExpr =
+  selectFirst("choose", FromResults);
+  ASSERT_TRUE(FromChooseExpr);
+
+  const ChooseExpr *ToChooseExpr = selectFirst("choose", ToResults);
+  ASSERT_TRUE(ToChooseExpr);
+
+  EXPECT_EQ(FromChooseExpr->isConditionTrue(), ToChooseExpr->isConditionTrue());
+}
+
 TEST_P(ASTImporterOptionSpecificTestBase,
ImportFunctionWithBackReferringParameter) {
   Decl *From, *To;
Index: clang/test/ASTMerge/choose-expr/test.c
===
--- /dev/null
+++ 

[PATCH] D52956: Support `-fno-visibility-inlines-hidden`

2019-02-25 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

I tried committing this for you, but it doesn't apply to master. Could you 
rebase?


Repository:
  rC Clang

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

https://reviews.llvm.org/D52956



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


r354832 - [ASTImporter] Add support for importing ChooseExpr AST nodes.

2019-02-25 Thread Tom Roeder via cfe-commits
Author: tmroeder
Date: Mon Feb 25 15:24:58 2019
New Revision: 354832

URL: http://llvm.org/viewvc/llvm-project?rev=354832=rev
Log:
[ASTImporter] Add support for importing ChooseExpr AST nodes.

Summary:
This allows ASTs to be merged when they contain ChooseExpr (the GNU
__builtin_choose_expr construction). This is needed, for example, for
cross-CTU analysis of C code that makes use of __builtin_choose_expr.

The node is already supported in the AST, but it didn't have a matcher
in ASTMatchers. So, this change adds the matcher and adds support to
ASTImporter.

Reviewers: shafik, a_sidorin, martong, aaron.ballman

Subscribers: aaron.ballman, rnkovacs, jdoerfert, cfe-commits

Tags: #clang

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

Added:
cfe/trunk/test/ASTMerge/choose-expr/
cfe/trunk/test/ASTMerge/choose-expr/Inputs/
cfe/trunk/test/ASTMerge/choose-expr/Inputs/choose.c
cfe/trunk/test/ASTMerge/choose-expr/test.c
Modified:
cfe/trunk/docs/LibASTMatchersReference.html
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp
cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
cfe/trunk/unittests/AST/ASTImporterTest.cpp
cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp

Modified: cfe/trunk/docs/LibASTMatchersReference.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=354832=354831=354832=diff
==
--- cfe/trunk/docs/LibASTMatchersReference.html (original)
+++ cfe/trunk/docs/LibASTMatchersReference.html Mon Feb 25 15:24:58 2019
@@ -788,6 +788,11 @@ Example matches 'a', L'a'
 
 
 
+Matcherhttps://clang.llvm.org/doxygen/classclang_1_1Stmt.html;>StmtchooseExprMatcherhttps://clang.llvm.org/doxygen/classclang_1_1ChooseExpr.html;>ChooseExpr...
+Matches GNU 
__builtin_choose_expr.
+
+
+
 Matcherhttps://clang.llvm.org/doxygen/classclang_1_1Stmt.html;>StmtcompoundLiteralExprMatcherhttps://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html;>CompoundLiteralExpr...
 Matches 
compound (i.e. non-scalar) literals
 

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=354832=354831=354832=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Mon Feb 25 15:24:58 2019
@@ -2158,6 +2158,10 @@ extern const internal::VariadicDynCastAl
 extern const internal::VariadicDynCastAllOfMatcher
 cxxNullPtrLiteralExpr;
 
+/// Matches GNU __builtin_choose_expr.
+extern const internal::VariadicDynCastAllOfMatcher
+chooseExpr;
+
 /// Matches GNU __null expression.
 extern const internal::VariadicDynCastAllOfMatcher
 gnuNullExpr;

Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=354832=354831=354832=diff
==
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Mon Feb 25 15:24:58 2019
@@ -552,6 +552,7 @@ namespace clang {
 // Importing expressions
 ExpectedStmt VisitExpr(Expr *E);
 ExpectedStmt VisitVAArgExpr(VAArgExpr *E);
+ExpectedStmt VisitChooseExpr(ChooseExpr *E);
 ExpectedStmt VisitGNUNullExpr(GNUNullExpr *E);
 ExpectedStmt VisitPredefinedExpr(PredefinedExpr *E);
 ExpectedStmt VisitDeclRefExpr(DeclRefExpr *E);
@@ -6135,6 +6136,33 @@ ExpectedStmt ASTNodeImporter::VisitVAArg
   E->isMicrosoftABI());
 }
 
+ExpectedStmt ASTNodeImporter::VisitChooseExpr(ChooseExpr *E) {
+  auto Imp = importSeq(E->getCond(), E->getLHS(), E->getRHS(),
+   E->getBuiltinLoc(), E->getRParenLoc(), E->getType());
+  if (!Imp)
+return Imp.takeError();
+
+  Expr *ToCond;
+  Expr *ToLHS;
+  Expr *ToRHS;
+  SourceLocation ToBuiltinLoc, ToRParenLoc;
+  QualType ToType;
+  std::tie(ToCond, ToLHS, ToRHS, ToBuiltinLoc, ToRParenLoc, ToType) = *Imp;
+
+  ExprValueKind VK = E->getValueKind();
+  ExprObjectKind OK = E->getObjectKind();
+
+  bool TypeDependent = ToCond->isTypeDependent();
+  bool ValueDependent = ToCond->isValueDependent();
+
+  // The value of CondIsTrue only matters if the value is not
+  // condition-dependent.
+  bool CondIsTrue = !E->isConditionDependent() && E->isConditionTrue();
+
+  return new (Importer.getToContext())
+  ChooseExpr(ToBuiltinLoc, ToCond, ToLHS, ToRHS, ToType, VK, OK,
+ ToRParenLoc, CondIsTrue, TypeDependent, ValueDependent);
+}
 
 ExpectedStmt ASTNodeImporter::VisitGNUNullExpr(GNUNullExpr *E) {
   ExpectedType TypeOrErr = import(E->getType());

Modified: cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp
URL: 

r354843 - [CGDebugInfo] Set NonTrivial DIFlag to a c++ record if it's not trivial

2019-02-25 Thread Aaron Smith via cfe-commits
Author: asmith
Date: Mon Feb 25 19:49:05 2019
New Revision: 354843

URL: http://llvm.org/viewvc/llvm-project?rev=354843=rev
Log:
[CGDebugInfo] Set NonTrivial DIFlag to a c++ record if it's not trivial

This goes with https://reviews.llvm.org/D44406


Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=354843=354842=354843=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Feb 25 19:49:05 2019
@@ -3031,6 +3031,8 @@ llvm::DICompositeType *CGDebugInfo::Crea
 // Record if a C++ record is trivial type.
 if (CXXRD->isTrivial())
   Flags |= llvm::DINode::FlagTrivial;
+else
+  Flags |= llvm::DINode::FlagNonTrivial;
   }
 
   llvm::DICompositeType *RealDecl = DBuilder.createReplaceableCompositeType(


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


[PATCH] D37994: Implement LWG2946: More ambiguity in `string` vs. `string_view`

2019-02-25 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists abandoned this revision.
mclow.lists added a comment.
Herald added a subscriber: jdoerfert.

This appears to have been applied in a slightly different form. Certainly the 
functionality is there. Closing.


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

https://reviews.llvm.org/D37994



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


[PATCH] D58530: Add PragmaHandler for MSVC pragma execution_character_set

2019-02-25 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

Looks good and thorough, but it needs tests.


Repository:
  rC Clang

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

https://reviews.llvm.org/D58530



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


[PATCH] D41950: Fix for Bug 8446. Template instantiation without a 'typename' keyword.

2019-02-25 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

In D41950#1409332 , @zahiraam wrote:

> I don't think I have commit right can you please commit it. Thanks.


Sure, done!


Repository:
  rC Clang

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

https://reviews.llvm.org/D41950



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


[PATCH] D41950: Fix for Bug 8446. Template instantiation without a 'typename' keyword.

2019-02-25 Thread Reid Kleckner via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC354838: [MS] Fix for Bug 8446, template instantiation 
without a typename keyword (authored by rnk, committed by ).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rC Clang

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

https://reviews.llvm.org/D41950

Files:
  lib/Parse/ParseTentative.cpp
  test/SemaTemplate/missing-typename.cpp

Index: test/SemaTemplate/missing-typename.cpp
===
--- test/SemaTemplate/missing-typename.cpp
+++ test/SemaTemplate/missing-typename.cpp
@@ -0,0 +1,102 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -Wno-unused
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -Wno-unused -fms-compatibility -DMSVC
+
+namespace PR8446_1 {
+struct A {
+  typedef int BASE_VALUE;
+};
+
+void g(int ) {}
+
+template 
+void f(int ) {
+#if MSVC
+// expected-warning@+4 {{missing 'typename' prior to dependent type name 'BASE_CLASS::BASE_VALUE'}}
+#else
+  // expected-error@+2 {{expected expression}}
+#endif
+  return g((BASE_CLASS::BASE_VALUE &)rValue);
+}
+
+int main() {
+  int x;
+  f(x);
+  return 0;
+}
+} // namespace PR8446_1
+
+
+namespace PR8446_2 {
+struct site_symmetry_ops {};
+
+template 
+struct class_ {
+  template 
+  void def(A1 const ) {}
+};
+
+template 
+struct init {
+  init() {}
+};
+
+struct special_position_site_parameter {
+  typedef char scatterer_type;
+};
+
+template 
+struct valued_asu_parameter_heir_wrapper {
+  static class_ wrap(char const *name) {
+return class_();
+  }
+};
+
+template 
+struct special_position_wrapper {
+  static void wrap(char const *name) {
+valued_asu_parameter_heir_wrapper::wrap(name)
+#if MSVC
+// expected-warning@+4 {{missing 'typename' prior to dependent type name 'wt::scatterer_type'}}
+#else
+// expected-error@+2 {{expected expression}}
+#endif
+.def(init());
+  }
+};
+
+void wrap_special_position() {
+  special_position_wrapper::wrap("special_position_site_parameter");
+}
+} // namespace PR8446_2
+
+namespace PR8446_3 {
+int g(int);
+template 
+int f1(int x) {
+  return g((T::InnerName & x) & x);
+}
+
+template 
+int f2(int x) {
+  return g((T::InnerName & 3) & x);
+}
+
+template 
+int f3(int x) {
+  return g((T::InnerName & (3)));
+}
+
+template 
+int f4(int x) {
+  return g((T::InnerName * 3) & x);
+}
+struct A {
+  static const int InnerName = 42;
+};
+int main() {
+  f1(0);
+  f2(0);
+  f3(0);
+  return f4(0);
+}
+} // namespace PR8446_3
Index: lib/Parse/ParseTentative.cpp
===
--- lib/Parse/ParseTentative.cpp
+++ lib/Parse/ParseTentative.cpp
@@ -1498,6 +1498,17 @@
 // expression.
 *HasMissingTypename = true;
 return TPResult::Ambiguous;
+  } else {
+// In MS mode, if HasMissingTypename is not provided, and the tokens
+// are or the form *) or &) *> or &> &&>, this can't be an expression.
+// The typename must be missing.
+if (getLangOpts().MSVCCompat) {
+  if (((Tok.is(tok::amp) || Tok.is(tok::star)) &&
+   (NextToken().is(tok::r_paren) ||
+NextToken().is(tok::greater))) ||
+  (Tok.is(tok::ampamp) && NextToken().is(tok::greater)))
+return TPResult::True;
+}
   }
 } else {
   // Try to resolve the name. If it doesn't exist, assume it was
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58292: Add support for importing ChooseExpr AST nodes.

2019-02-25 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

I had to revert this in rL354839  because 
one of the tests didn't pass on Windows:
http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/4641


Repository:
  rL LLVM

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

https://reviews.llvm.org/D58292



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


r354839 - Revert r354832 "[ASTImporter] Add support for importing ChooseExpr AST nodes."

2019-02-25 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Mon Feb 25 18:22:22 2019
New Revision: 354839

URL: http://llvm.org/viewvc/llvm-project?rev=354839=rev
Log:
Revert r354832 "[ASTImporter] Add support for importing ChooseExpr AST nodes."

Test does not pass on Windows

Removed:
cfe/trunk/test/ASTMerge/
Modified:
cfe/trunk/docs/LibASTMatchersReference.html
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp
cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
cfe/trunk/unittests/AST/ASTImporterTest.cpp
cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp

Modified: cfe/trunk/docs/LibASTMatchersReference.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=354839=354838=354839=diff
==
--- cfe/trunk/docs/LibASTMatchersReference.html (original)
+++ cfe/trunk/docs/LibASTMatchersReference.html Mon Feb 25 18:22:22 2019
@@ -788,11 +788,6 @@ Example matches 'a', L'a'
 
 
 
-Matcherhttps://clang.llvm.org/doxygen/classclang_1_1Stmt.html;>StmtchooseExprMatcherhttps://clang.llvm.org/doxygen/classclang_1_1ChooseExpr.html;>ChooseExpr...
-Matches GNU 
__builtin_choose_expr.
-
-
-
 Matcherhttps://clang.llvm.org/doxygen/classclang_1_1Stmt.html;>StmtcompoundLiteralExprMatcherhttps://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html;>CompoundLiteralExpr...
 Matches 
compound (i.e. non-scalar) literals
 

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=354839=354838=354839=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Mon Feb 25 18:22:22 2019
@@ -2158,10 +2158,6 @@ extern const internal::VariadicDynCastAl
 extern const internal::VariadicDynCastAllOfMatcher
 cxxNullPtrLiteralExpr;
 
-/// Matches GNU __builtin_choose_expr.
-extern const internal::VariadicDynCastAllOfMatcher
-chooseExpr;
-
 /// Matches GNU __null expression.
 extern const internal::VariadicDynCastAllOfMatcher
 gnuNullExpr;

Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=354839=354838=354839=diff
==
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Mon Feb 25 18:22:22 2019
@@ -552,7 +552,6 @@ namespace clang {
 // Importing expressions
 ExpectedStmt VisitExpr(Expr *E);
 ExpectedStmt VisitVAArgExpr(VAArgExpr *E);
-ExpectedStmt VisitChooseExpr(ChooseExpr *E);
 ExpectedStmt VisitGNUNullExpr(GNUNullExpr *E);
 ExpectedStmt VisitPredefinedExpr(PredefinedExpr *E);
 ExpectedStmt VisitDeclRefExpr(DeclRefExpr *E);
@@ -6136,33 +6135,6 @@ ExpectedStmt ASTNodeImporter::VisitVAArg
   E->isMicrosoftABI());
 }
 
-ExpectedStmt ASTNodeImporter::VisitChooseExpr(ChooseExpr *E) {
-  auto Imp = importSeq(E->getCond(), E->getLHS(), E->getRHS(),
-   E->getBuiltinLoc(), E->getRParenLoc(), E->getType());
-  if (!Imp)
-return Imp.takeError();
-
-  Expr *ToCond;
-  Expr *ToLHS;
-  Expr *ToRHS;
-  SourceLocation ToBuiltinLoc, ToRParenLoc;
-  QualType ToType;
-  std::tie(ToCond, ToLHS, ToRHS, ToBuiltinLoc, ToRParenLoc, ToType) = *Imp;
-
-  ExprValueKind VK = E->getValueKind();
-  ExprObjectKind OK = E->getObjectKind();
-
-  bool TypeDependent = ToCond->isTypeDependent();
-  bool ValueDependent = ToCond->isValueDependent();
-
-  // The value of CondIsTrue only matters if the value is not
-  // condition-dependent.
-  bool CondIsTrue = !E->isConditionDependent() && E->isConditionTrue();
-
-  return new (Importer.getToContext())
-  ChooseExpr(ToBuiltinLoc, ToCond, ToLHS, ToRHS, ToType, VK, OK,
- ToRParenLoc, CondIsTrue, TypeDependent, ValueDependent);
-}
 
 ExpectedStmt ASTNodeImporter::VisitGNUNullExpr(GNUNullExpr *E) {
   ExpectedType TypeOrErr = import(E->getType());

Modified: cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp?rev=354839=354838=354839=diff
==
--- cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp (original)
+++ cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp Mon Feb 25 18:22:22 2019
@@ -727,7 +727,6 @@ const internal::VariadicDynCastAllOfMatc
 compoundLiteralExpr;
 const internal::VariadicDynCastAllOfMatcher
 cxxNullPtrLiteralExpr;
-const internal::VariadicDynCastAllOfMatcher chooseExpr;
 const internal::VariadicDynCastAllOfMatcher gnuNullExpr;
 const internal::VariadicDynCastAllOfMatcher atomicExpr;
 const internal::VariadicDynCastAllOfMatcher stmtExpr;

Modified: 

r354838 - [MS] Fix for Bug 8446, template instantiation without a 'typename' keyword

2019-02-25 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Mon Feb 25 18:22:17 2019
New Revision: 354838

URL: http://llvm.org/viewvc/llvm-project?rev=354838=rev
Log:
[MS] Fix for Bug 8446, template instantiation without a 'typename' keyword

Patch by Zahira Ammarguellat!

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

Added:
cfe/trunk/test/SemaTemplate/missing-typename.cpp
Modified:
cfe/trunk/lib/Parse/ParseTentative.cpp

Modified: cfe/trunk/lib/Parse/ParseTentative.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseTentative.cpp?rev=354838=354837=354838=diff
==
--- cfe/trunk/lib/Parse/ParseTentative.cpp (original)
+++ cfe/trunk/lib/Parse/ParseTentative.cpp Mon Feb 25 18:22:17 2019
@@ -1498,6 +1498,17 @@ Parser::isCXXDeclarationSpecifier(Parser
 // expression.
 *HasMissingTypename = true;
 return TPResult::Ambiguous;
+  } else {
+// In MS mode, if HasMissingTypename is not provided, and the 
tokens
+// are or the form *) or &) *> or &> &&>, this can't be an 
expression.
+// The typename must be missing.
+if (getLangOpts().MSVCCompat) {
+  if (((Tok.is(tok::amp) || Tok.is(tok::star)) &&
+   (NextToken().is(tok::r_paren) ||
+NextToken().is(tok::greater))) ||
+  (Tok.is(tok::ampamp) && NextToken().is(tok::greater)))
+return TPResult::True;
+}
   }
 } else {
   // Try to resolve the name. If it doesn't exist, assume it was

Added: cfe/trunk/test/SemaTemplate/missing-typename.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/missing-typename.cpp?rev=354838=auto
==
--- cfe/trunk/test/SemaTemplate/missing-typename.cpp (added)
+++ cfe/trunk/test/SemaTemplate/missing-typename.cpp Mon Feb 25 18:22:17 2019
@@ -0,0 +1,102 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -Wno-unused
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -Wno-unused 
-fms-compatibility -DMSVC
+
+namespace PR8446_1 {
+struct A {
+  typedef int BASE_VALUE;
+};
+
+void g(int ) {}
+
+template 
+void f(int ) {
+#if MSVC
+// expected-warning@+4 {{missing 'typename' prior to dependent type name 
'BASE_CLASS::BASE_VALUE'}}
+#else
+  // expected-error@+2 {{expected expression}}
+#endif
+  return g((BASE_CLASS::BASE_VALUE &)rValue);
+}
+
+int main() {
+  int x;
+  f(x);
+  return 0;
+}
+} // namespace PR8446_1
+
+
+namespace PR8446_2 {
+struct site_symmetry_ops {};
+
+template 
+struct class_ {
+  template 
+  void def(A1 const ) {}
+};
+
+template 
+struct init {
+  init() {}
+};
+
+struct special_position_site_parameter {
+  typedef char scatterer_type;
+};
+
+template 
+struct valued_asu_parameter_heir_wrapper {
+  static class_ wrap(char const *name) {
+return class_();
+  }
+};
+
+template 
+struct special_position_wrapper {
+  static void wrap(char const *name) {
+valued_asu_parameter_heir_wrapper::wrap(name)
+#if MSVC
+// expected-warning@+4 {{missing 'typename' prior to dependent type name 
'wt::scatterer_type'}}
+#else
+// expected-error@+2 {{expected expression}}
+#endif
+.def(init());
+  }
+};
+
+void wrap_special_position() {
+  
special_position_wrapper::wrap("special_position_site_parameter");
+}
+} // namespace PR8446_2
+
+namespace PR8446_3 {
+int g(int);
+template 
+int f1(int x) {
+  return g((T::InnerName & x) & x);
+}
+
+template 
+int f2(int x) {
+  return g((T::InnerName & 3) & x);
+}
+
+template 
+int f3(int x) {
+  return g((T::InnerName & (3)));
+}
+
+template 
+int f4(int x) {
+  return g((T::InnerName * 3) & x);
+}
+struct A {
+  static const int InnerName = 42;
+};
+int main() {
+  f1(0);
+  f2(0);
+  f3(0);
+  return f4(0);
+}
+} // namespace PR8446_3


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


[PATCH] D58137: [clang-tidy] Add the abseil-time-subtraction check

2019-02-25 Thread Hyrum Wright via Phabricator via cfe-commits
hwright added inline comments.



Comment at: clang-tidy/abseil/TimeSubtractionCheck.cpp:97
+void TimeSubtractionCheck::check(const MatchFinder::MatchResult ) {
+  const auto *BinOp = Result.Nodes.getNodeAs("binop");
+  std::string inverse_name =

JonasToth wrote:
> hwright wrote:
> > JonasToth wrote:
> > > Could you please split this function up into smaller ones. There are 
> > > three or four distinct cases that are easier to comprehend in isolation.
> > The actual bodies of these if-statements are only one or two separate 
> > statements themselves.  Moving those to separate functions seems like it 
> > would just obfuscate things a bit.
> IMHO they are complicated statements and hide what is being done. Wrapping 
> them in a function with a name that states what is done seems appropriate.
I would agree that they are complicated statements, which is why there are 
multi-line comments explaining what is being doing.  Moving a two-line compound 
statement into a separate function which is only called once seems more 
confusing than simplifying.  More information can be expressed in a prose 
comment than a single concise function name, no?



Comment at: test/clang-tidy/abseil-time-subtraction.cpp:12
+
+  d = absl::Hours(absl::ToUnixHours(t) - x);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time 
domain [abseil-time-subtraction]

JonasToth wrote:
> hwright wrote:
> > JonasToth wrote:
> > > please add tests where `x` itself is a calculation with different 
> > > precedence of its operators (multiplication, addition) to ensure these 
> > > cases are transformed properly as well.
> > This doesn't actually matter in this case: `x` will be wrapped in a 
> > function call.
> > 
> > It does matter in the case where we //unwrap// the first argument (below) 
> > and I've already got a test which uses multiplication in this case.  I've 
> > also added one for division.
> Yes, it should not matter if `x` is an expr itself or just a variable. Thats 
> why it should be tested its actually true.
Added, though this seems more a test of the matcher infrastructure than the 
tool itself.


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

https://reviews.llvm.org/D58137



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


[PATCH] D58137: [clang-tidy] Add the abseil-time-subtraction check

2019-02-25 Thread Hyrum Wright via Phabricator via cfe-commits
hwright updated this revision to Diff 188289.
hwright marked 5 inline comments as done.

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

https://reviews.llvm.org/D58137

Files:
  clang-tidy/abseil/AbseilTidyModule.cpp
  clang-tidy/abseil/CMakeLists.txt
  clang-tidy/abseil/DurationRewriter.cpp
  clang-tidy/abseil/DurationRewriter.h
  clang-tidy/abseil/TimeSubtractionCheck.cpp
  clang-tidy/abseil/TimeSubtractionCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/abseil-time-subtraction.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/Inputs/absl/time/time.h
  test/clang-tidy/abseil-time-subtraction.cpp

Index: test/clang-tidy/abseil-time-subtraction.cpp
===
--- /dev/null
+++ test/clang-tidy/abseil-time-subtraction.cpp
@@ -0,0 +1,117 @@
+// RUN: %check_clang_tidy %s abseil-time-subtraction %t -- -- -I%S/Inputs
+
+#include "absl/time/time.h"
+
+void g(absl::Duration d);
+
+void f() {
+  absl::Time t;
+  int x, y;
+  absl::Duration d;
+
+  d = absl::Hours(absl::ToUnixHours(t) - x);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: d = (t - absl::FromUnixHours(x));
+  d = absl::Minutes(absl::ToUnixMinutes(t) - x);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: d = (t - absl::FromUnixMinutes(x));
+  d = absl::Seconds(absl::ToUnixSeconds(t) - x);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: d = (t - absl::FromUnixSeconds(x));
+  d = absl::Milliseconds(absl::ToUnixMillis(t) - x);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: d = (t - absl::FromUnixMillis(x));
+  d = absl::Microseconds(absl::ToUnixMicros(t) - x);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: d = (t - absl::FromUnixMicros(x));
+  d = absl::Nanoseconds(absl::ToUnixNanos(t) - x);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: d = (t - absl::FromUnixNanos(x));
+
+  y = x - absl::ToUnixHours(t);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: y = absl::ToInt64Hours(absl::FromUnixHours(x) - t);
+  y = x - absl::ToUnixMinutes(t);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: y = absl::ToInt64Minutes(absl::FromUnixMinutes(x) - t);
+  y = x - absl::ToUnixSeconds(t);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: y = absl::ToInt64Seconds(absl::FromUnixSeconds(x) - t);
+  y = x - absl::ToUnixMillis(t);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: y = absl::ToInt64Milliseconds(absl::FromUnixMillis(x) - t);
+  y = x - absl::ToUnixMicros(t);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: y = absl::ToInt64Microseconds(absl::FromUnixMicros(x) - t);
+  y = x - absl::ToUnixNanos(t);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: y = absl::ToInt64Nanoseconds(absl::FromUnixNanos(x) - t);
+
+  // Check parenthesis placement
+  d = 5 * absl::Seconds(absl::ToUnixSeconds(t) - x);
+  // CHECK-MESSAGES: [[@LINE-1]]:11: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: d = 5 * (t - absl::FromUnixSeconds(x));
+  d = absl::Seconds(absl::ToUnixSeconds(t) - x) / 5;
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: d = (t - absl::FromUnixSeconds(x)) / 5;
+
+  // No extra parens around arguments
+  g(absl::Seconds(absl::ToUnixSeconds(t) - x));
+  // CHECK-MESSAGES: [[@LINE-1]]:5: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: g(t - absl::FromUnixSeconds(x));
+  g(absl::Seconds(x - absl::ToUnixSeconds(t)));
+  // CHECK-MESSAGES: [[@LINE-1]]:5: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: g(absl::FromUnixSeconds(x) - t);
+
+  // More complex subexpressions
+  d = absl::Hours(absl::ToUnixHours(t) - 5 * x);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: d = (t - absl::FromUnixHours(5 * x));
+
+  // These should not trigger; they are likely bugs
+  d = absl::Milliseconds(absl::ToUnixSeconds(t) - x);
+  d = 

[PATCH] D58659: [Sema] Fix assertion when `auto` parameter in lambda has an attribute.

2019-02-25 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

Have doubts that checking only the outermost type for being `AttributedType` 
after `Sema::ReplaceAutoType` is sufficient but haven't found a counterexample 
yet. Decided to post the proposed fix to see if others have any ideas.


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

https://reviews.llvm.org/D58659



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


[PATCH] D58659: [Sema] Fix assertion when `auto` parameter in lambda has an attribute.

2019-02-25 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai created this revision.
vsapsai added reviewers: rsmith, arphaman.
Herald added subscribers: jdoerfert, dexonsmith, jkorous.

Fixes the assertion

> no Attr* for AttributedType*
>  UNREACHABLE executed at llvm-project/clang/lib/Sema/SemaType.cpp:298!

In `TypeProcessingState::getAttributedType` we put into `AttrsForTypes`
types with `auto` but later in
`TypeProcessingState::takeAttrForAttributedType` we use transformed
types and that's why cannot find `Attr` corresponding to
`AttributedType`.

Fix by keeping `AttrsForTypes` up to date after replacing `AutoType`.

rdar://problem/47689465


https://reviews.llvm.org/D58659

Files:
  clang/lib/Sema/SemaType.cpp
  clang/test/SemaCXX/auto-cxx0x.cpp


Index: clang/test/SemaCXX/auto-cxx0x.cpp
===
--- clang/test/SemaCXX/auto-cxx0x.cpp
+++ clang/test/SemaCXX/auto-cxx0x.cpp
@@ -15,3 +15,11 @@
   // expected-error@-2 {{'auto' not allowed in lambda parameter}}
 #endif
 }
+
+void rdar47689465() {
+  int x = 0;
+  [](auto __attribute__((noderef)) *){}();
+#if __cplusplus == 201103L
+  // expected-error@-2 {{'auto' not allowed in lambda parameter}}
+#endif
+}
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -255,6 +255,23 @@
   return T;
 }
 
+/// Completely replace the \c auto in \p TypeWithAuto by
+/// \p Replacement. Also replace \p TypeWithAuto in \c TypeAttrPair if
+/// necessary.
+QualType ReplaceAutoType(QualType TypeWithAuto, QualType Replacement) {
+  QualType T = sema.ReplaceAutoType(TypeWithAuto, Replacement);
+  if (auto *AttrTy = TypeWithAuto->getAs()) {
+// Attributed type still should be an attributed type after 
replacement.
+auto *NewAttrTy = cast(T.getTypePtr());
+for (TypeAttrPair  : AttrsForTypes) {
+  if (A.first == AttrTy)
+A.first = NewAttrTy;
+}
+AttrsForTypesSorted = false;
+  }
+  return T;
+}
+
 /// Extract and remove the Attr* for a given attributed type.
 const Attr *takeAttrForAttributedType(const AttributedType *AT) {
   if (!AttrsForTypesSorted) {
@@ -2935,7 +2952,7 @@
 // template type parameter.
 // FIXME: Retain some type sugar to indicate that this was written
 // as 'auto'.
-T = SemaRef.ReplaceAutoType(
+T = state.ReplaceAutoType(
 T, QualType(CorrespondingTemplateParam->getTypeForDecl(), 0));
   }
   break;


Index: clang/test/SemaCXX/auto-cxx0x.cpp
===
--- clang/test/SemaCXX/auto-cxx0x.cpp
+++ clang/test/SemaCXX/auto-cxx0x.cpp
@@ -15,3 +15,11 @@
   // expected-error@-2 {{'auto' not allowed in lambda parameter}}
 #endif
 }
+
+void rdar47689465() {
+  int x = 0;
+  [](auto __attribute__((noderef)) *){}();
+#if __cplusplus == 201103L
+  // expected-error@-2 {{'auto' not allowed in lambda parameter}}
+#endif
+}
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -255,6 +255,23 @@
   return T;
 }
 
+/// Completely replace the \c auto in \p TypeWithAuto by
+/// \p Replacement. Also replace \p TypeWithAuto in \c TypeAttrPair if
+/// necessary.
+QualType ReplaceAutoType(QualType TypeWithAuto, QualType Replacement) {
+  QualType T = sema.ReplaceAutoType(TypeWithAuto, Replacement);
+  if (auto *AttrTy = TypeWithAuto->getAs()) {
+// Attributed type still should be an attributed type after replacement.
+auto *NewAttrTy = cast(T.getTypePtr());
+for (TypeAttrPair  : AttrsForTypes) {
+  if (A.first == AttrTy)
+A.first = NewAttrTy;
+}
+AttrsForTypesSorted = false;
+  }
+  return T;
+}
+
 /// Extract and remove the Attr* for a given attributed type.
 const Attr *takeAttrForAttributedType(const AttributedType *AT) {
   if (!AttrsForTypesSorted) {
@@ -2935,7 +2952,7 @@
 // template type parameter.
 // FIXME: Retain some type sugar to indicate that this was written
 // as 'auto'.
-T = SemaRef.ReplaceAutoType(
+T = state.ReplaceAutoType(
 T, QualType(CorrespondingTemplateParam->getTypeForDecl(), 0));
   }
   break;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58658: [OpenCL] Fix assertion due to blocks

2019-02-25 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added a reviewer: Anastasia.
Herald added subscribers: kristof.beyls, javed.absar.

A recent change caused assertion in CodeGenFunction::EmitBlockCallExpr when a 
block is called.

There is code

  if (!isa(E->getCalleeDecl()))
Func = CGM.getOpenCLRuntime().getInvokeFunction(E->getCallee());

getCalleeDecl calls Expr::getReferencedDeclOfCallee, which does not handle
BlockExpr and returns nullptr, which causes isa to assert.

This patch fixes that.


https://reviews.llvm.org/D58658

Files:
  lib/AST/Expr.cpp
  test/CodeGenOpenCL/blocks.cl


Index: test/CodeGenOpenCL/blocks.cl
===
--- test/CodeGenOpenCL/blocks.cl
+++ test/CodeGenOpenCL/blocks.cl
@@ -90,6 +90,12 @@
   return blockArgFunc(^{return 42;});
 }
 
+// COMMON-LABEL: define {{.*}}@call_block
+// call {{.*}}@__call_block_block_invoke
+int call_block() {
+  return ^int(int num) { return num; } (11);
+}
+
 // CHECK-DEBUG: !DIDerivedType(tag: DW_TAG_member, name: "__size"
 // CHECK-DEBUG: !DIDerivedType(tag: DW_TAG_member, name: "__align"
 
Index: lib/AST/Expr.cpp
===
--- lib/AST/Expr.cpp
+++ lib/AST/Expr.cpp
@@ -1358,6 +1358,8 @@
 return DRE->getDecl();
   if (MemberExpr *ME = dyn_cast(CEE))
 return ME->getMemberDecl();
+  if (auto *BE = dyn_cast(CEE))
+return BE->getBlockDecl();
 
   return nullptr;
 }


Index: test/CodeGenOpenCL/blocks.cl
===
--- test/CodeGenOpenCL/blocks.cl
+++ test/CodeGenOpenCL/blocks.cl
@@ -90,6 +90,12 @@
   return blockArgFunc(^{return 42;});
 }
 
+// COMMON-LABEL: define {{.*}}@call_block
+// call {{.*}}@__call_block_block_invoke
+int call_block() {
+  return ^int(int num) { return num; } (11);
+}
+
 // CHECK-DEBUG: !DIDerivedType(tag: DW_TAG_member, name: "__size"
 // CHECK-DEBUG: !DIDerivedType(tag: DW_TAG_member, name: "__align"
 
Index: lib/AST/Expr.cpp
===
--- lib/AST/Expr.cpp
+++ lib/AST/Expr.cpp
@@ -1358,6 +1358,8 @@
 return DRE->getDecl();
   if (MemberExpr *ME = dyn_cast(CEE))
 return ME->getMemberDecl();
+  if (auto *BE = dyn_cast(CEE))
+return BE->getBlockDecl();
 
   return nullptr;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58292: Add support for importing ChooseExpr AST nodes.

2019-02-25 Thread Tom Roeder via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354832: [ASTImporter] Add support for importing ChooseExpr 
AST nodes. (authored by tmroeder, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D58292?vs=188262=188266#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D58292

Files:
  cfe/trunk/docs/LibASTMatchersReference.html
  cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
  cfe/trunk/lib/AST/ASTImporter.cpp
  cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp
  cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
  cfe/trunk/test/ASTMerge/choose-expr/Inputs/choose.c
  cfe/trunk/test/ASTMerge/choose-expr/test.c
  cfe/trunk/unittests/AST/ASTImporterTest.cpp
  cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp

Index: cfe/trunk/docs/LibASTMatchersReference.html
===
--- cfe/trunk/docs/LibASTMatchersReference.html
+++ cfe/trunk/docs/LibASTMatchersReference.html
@@ -788,6 +788,11 @@
 
 
 
+Matcherhttps://clang.llvm.org/doxygen/classclang_1_1Stmt.html;>StmtchooseExprMatcherhttps://clang.llvm.org/doxygen/classclang_1_1ChooseExpr.html;>ChooseExpr...
+Matches GNU __builtin_choose_expr.
+
+
+
 Matcherhttps://clang.llvm.org/doxygen/classclang_1_1Stmt.html;>StmtcompoundLiteralExprMatcherhttps://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html;>CompoundLiteralExpr...
 Matches compound (i.e. non-scalar) literals
 
Index: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
===
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
@@ -2158,6 +2158,10 @@
 extern const internal::VariadicDynCastAllOfMatcher
 cxxNullPtrLiteralExpr;
 
+/// Matches GNU __builtin_choose_expr.
+extern const internal::VariadicDynCastAllOfMatcher
+chooseExpr;
+
 /// Matches GNU __null expression.
 extern const internal::VariadicDynCastAllOfMatcher
 gnuNullExpr;
Index: cfe/trunk/test/ASTMerge/choose-expr/Inputs/choose.c
===
--- cfe/trunk/test/ASTMerge/choose-expr/Inputs/choose.c
+++ cfe/trunk/test/ASTMerge/choose-expr/Inputs/choose.c
@@ -0,0 +1,2 @@
+_Static_assert(__builtin_choose_expr(1, 1, 0), "Incorrect semantics of __builtin_choose_expr");
+_Static_assert(__builtin_choose_expr(0, 0, 1), "Incorrect semantics of __builtin_choose_expr");
Index: cfe/trunk/test/ASTMerge/choose-expr/test.c
===
--- cfe/trunk/test/ASTMerge/choose-expr/test.c
+++ cfe/trunk/test/ASTMerge/choose-expr/test.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -std=c11 -emit-pch -o %t.ast %S/Inputs/choose.c
+// RUN: %clang_cc1 -std=c11 -ast-merge %t.ast -fsyntax-only -verify %s
+// expected-no-diagnostics
+
Index: cfe/trunk/lib/AST/ASTImporter.cpp
===
--- cfe/trunk/lib/AST/ASTImporter.cpp
+++ cfe/trunk/lib/AST/ASTImporter.cpp
@@ -552,6 +552,7 @@
 // Importing expressions
 ExpectedStmt VisitExpr(Expr *E);
 ExpectedStmt VisitVAArgExpr(VAArgExpr *E);
+ExpectedStmt VisitChooseExpr(ChooseExpr *E);
 ExpectedStmt VisitGNUNullExpr(GNUNullExpr *E);
 ExpectedStmt VisitPredefinedExpr(PredefinedExpr *E);
 ExpectedStmt VisitDeclRefExpr(DeclRefExpr *E);
@@ -6135,6 +6136,33 @@
   E->isMicrosoftABI());
 }
 
+ExpectedStmt ASTNodeImporter::VisitChooseExpr(ChooseExpr *E) {
+  auto Imp = importSeq(E->getCond(), E->getLHS(), E->getRHS(),
+   E->getBuiltinLoc(), E->getRParenLoc(), E->getType());
+  if (!Imp)
+return Imp.takeError();
+
+  Expr *ToCond;
+  Expr *ToLHS;
+  Expr *ToRHS;
+  SourceLocation ToBuiltinLoc, ToRParenLoc;
+  QualType ToType;
+  std::tie(ToCond, ToLHS, ToRHS, ToBuiltinLoc, ToRParenLoc, ToType) = *Imp;
+
+  ExprValueKind VK = E->getValueKind();
+  ExprObjectKind OK = E->getObjectKind();
+
+  bool TypeDependent = ToCond->isTypeDependent();
+  bool ValueDependent = ToCond->isValueDependent();
+
+  // The value of CondIsTrue only matters if the value is not
+  // condition-dependent.
+  bool CondIsTrue = !E->isConditionDependent() && E->isConditionTrue();
+
+  return new (Importer.getToContext())
+  ChooseExpr(ToBuiltinLoc, ToCond, ToLHS, ToRHS, ToType, VK, OK,
+ ToRParenLoc, CondIsTrue, TypeDependent, ValueDependent);
+}
 
 ExpectedStmt ASTNodeImporter::VisitGNUNullExpr(GNUNullExpr *E) {
   ExpectedType TypeOrErr = import(E->getType());
Index: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -147,6 +147,7 @@
   REGISTER_MATCHER(caseStmt);
   

[PATCH] D58649: Fix inline assembler constraint validation

2019-02-25 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg created this revision.
joerg added a reviewer: compnerd.
Herald added a subscriber: eraman.

The current constraint logic is both too lax and too strict. It fails for input 
outside the [INT_MIN..INT_MAX] range, but it also implicitly accepts 0 as value 
when it should not. Adjust logic to handle both correctly.


https://reviews.llvm.org/D58649

Files:
  include/clang/Basic/TargetInfo.h
  test/Sema/inline-asm-validate-x86.c


Index: test/Sema/inline-asm-validate-x86.c
===
--- test/Sema/inline-asm-validate-x86.c
+++ test/Sema/inline-asm-validate-x86.c
@@ -55,6 +55,7 @@
 void L(int i, int j) {
   static const int Invalid1 = 1;
   static const int Invalid2 = 42;
+  static const int Invalid3 = 0;
   static const int Valid1 = 0xff;
   static const int Valid2 = 0x;
   static const int Valid3 = 0x;
@@ -69,6 +70,9 @@
   : "0"(i), "L"(Invalid2)); // expected-error{{value '42' out of range 
for constraint 'L'}}
   __asm__("xorl %0,%2"
   : "=r"(i)
+  : "0"(i), "L"(Invalid3)); // expected-error{{value '0' out of range 
for constraint 'L'}}
+  __asm__("xorl %0,%2"
+  : "=r"(i)
   : "0"(i), "L"(Valid1)); // expected-no-error
   __asm__("xorl %0,%2"
   : "=r"(i)
Index: include/clang/Basic/TargetInfo.h
===
--- include/clang/Basic/TargetInfo.h
+++ include/clang/Basic/TargetInfo.h
@@ -816,6 +816,7 @@
 struct {
   int Min;
   int Max;
+  bool isConstrained;
 } ImmRange;
 llvm::SmallSet ImmSet;
 
@@ -826,6 +827,7 @@
 : Flags(0), TiedOperand(-1), ConstraintStr(ConstraintStr.str()),
   Name(Name.str()) {
   ImmRange.Min = ImmRange.Max = 0;
+  ImmRange.isConstrained = false;
 }
 
 const std::string () const { return ConstraintStr; }
@@ -854,8 +856,9 @@
   return (Flags & CI_ImmediateConstant) != 0;
 }
 bool isValidAsmImmediate(const llvm::APInt ) const {
-  return (Value.sge(ImmRange.Min) && Value.sle(ImmRange.Max)) ||
- ImmSet.count(Value.getZExtValue()) != 0;
+  if (!ImmSet.empty())
+return ImmSet.count(Value.getZExtValue()) != 0;
+  return !ImmRange.isConstrained || (Value.sge(ImmRange.Min) && 
Value.sle(ImmRange.Max));
 }
 
 void setIsReadWrite() { Flags |= CI_ReadWrite; }
@@ -867,6 +870,7 @@
   Flags |= CI_ImmediateConstant;
   ImmRange.Min = Min;
   ImmRange.Max = Max;
+  ImmRange.isConstrained = true;
 }
 void setRequiresImmediate(llvm::ArrayRef Exacts) {
   Flags |= CI_ImmediateConstant;
@@ -879,8 +883,6 @@
 }
 void setRequiresImmediate() {
   Flags |= CI_ImmediateConstant;
-  ImmRange.Min = INT_MIN;
-  ImmRange.Max = INT_MAX;
 }
 
 /// Indicate that this is an input operand that is tied to


Index: test/Sema/inline-asm-validate-x86.c
===
--- test/Sema/inline-asm-validate-x86.c
+++ test/Sema/inline-asm-validate-x86.c
@@ -55,6 +55,7 @@
 void L(int i, int j) {
   static const int Invalid1 = 1;
   static const int Invalid2 = 42;
+  static const int Invalid3 = 0;
   static const int Valid1 = 0xff;
   static const int Valid2 = 0x;
   static const int Valid3 = 0x;
@@ -69,6 +70,9 @@
   : "0"(i), "L"(Invalid2)); // expected-error{{value '42' out of range for constraint 'L'}}
   __asm__("xorl %0,%2"
   : "=r"(i)
+  : "0"(i), "L"(Invalid3)); // expected-error{{value '0' out of range for constraint 'L'}}
+  __asm__("xorl %0,%2"
+  : "=r"(i)
   : "0"(i), "L"(Valid1)); // expected-no-error
   __asm__("xorl %0,%2"
   : "=r"(i)
Index: include/clang/Basic/TargetInfo.h
===
--- include/clang/Basic/TargetInfo.h
+++ include/clang/Basic/TargetInfo.h
@@ -816,6 +816,7 @@
 struct {
   int Min;
   int Max;
+  bool isConstrained;
 } ImmRange;
 llvm::SmallSet ImmSet;
 
@@ -826,6 +827,7 @@
 : Flags(0), TiedOperand(-1), ConstraintStr(ConstraintStr.str()),
   Name(Name.str()) {
   ImmRange.Min = ImmRange.Max = 0;
+  ImmRange.isConstrained = false;
 }
 
 const std::string () const { return ConstraintStr; }
@@ -854,8 +856,9 @@
   return (Flags & CI_ImmediateConstant) != 0;
 }
 bool isValidAsmImmediate(const llvm::APInt ) const {
-  return (Value.sge(ImmRange.Min) && Value.sle(ImmRange.Max)) ||
- ImmSet.count(Value.getZExtValue()) != 0;
+  if (!ImmSet.empty())
+return ImmSet.count(Value.getZExtValue()) != 0;
+  return !ImmRange.isConstrained || (Value.sge(ImmRange.Min) && Value.sle(ImmRange.Max));
 }
 
 void setIsReadWrite() { Flags |= CI_ReadWrite; }
@@ -867,6 +870,7 @@
   Flags |= CI_ImmediateConstant;
   ImmRange.Min = Min;
   ImmRange.Max = Max;
+  ImmRange.isConstrained = true;
 }

[PATCH] D58292: Add support for importing ChooseExpr AST nodes.

2019-02-25 Thread Tom Roeder via Phabricator via cfe-commits
tmroeder updated this revision to Diff 188262.
tmroeder added a comment.

Updating after switching to the git monorepo model.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58292

Files:
  clang/docs/LibASTMatchersReference.html
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/ASTMatchers/ASTMatchersInternal.cpp
  clang/lib/ASTMatchers/Dynamic/Registry.cpp
  clang/test/ASTMerge/choose-expr/Inputs/choose.c
  clang/test/ASTMerge/choose-expr/test.c
  clang/unittests/AST/ASTImporterTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -754,6 +754,11 @@
   EXPECT_TRUE(matches("int* i = nullptr;", cxxNullPtrLiteralExpr()));
 }
 
+TEST(Matcher, ChooseExpr) {
+  EXPECT_TRUE(matchesC("void f() { (void)__builtin_choose_expr(1, 2, 3); }",
+   chooseExpr()));
+}
+
 TEST(Matcher, GNUNullExpr) {
   EXPECT_TRUE(matches("int* i = __null;", gnuNullExpr()));
 }
Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -563,6 +563,34 @@
   stringLiteral(hasType(asString("const char [7]"));
 }
 
+TEST_P(ImportExpr, ImportChooseExpr) {
+  MatchVerifier Verifier;
+
+  // This case tests C code that is not condition-dependent and has a true
+  // condition.
+  testImport(
+"void declToImport() { (void)__builtin_choose_expr(1, 2, 3); }",
+Lang_C, "", Lang_C, Verifier,
+functionDecl(hasDescendant(chooseExpr(;
+
+  ArgVector Args = getExtraArgs();
+  BindableMatcher Matcher =
+  functionTemplateDecl(hasDescendant(chooseExpr()));
+
+  // Don't try to match the template contents if template parsing is delayed.
+  if (llvm::find(Args, "-fdelayed-template-parsing") != Args.end()) {
+Matcher = functionTemplateDecl();
+  }
+
+  // Make sure that uses of (void)__builtin_choose_expr with dependent types in
+  // the condition are handled properly. This test triggers an assertion if the
+  // ASTImporter incorrectly tries to access isConditionTrue() when
+  // isConditionDependent() is true.
+  testImport("template void declToImport() { "
+ "(void)__builtin_choose_expr(N, 1, 0); }",
+ Lang_CXX, "", Lang_CXX, Verifier, Matcher);
+}
+
 TEST_P(ImportExpr, ImportGNUNullExpr) {
   MatchVerifier Verifier;
   testImport(
@@ -1312,6 +1340,27 @@
   ASSERT_EQ(ToTemplated1, ToTemplated);
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase, ImportChooseExpr) {
+  // This tests the import of isConditionTrue directly to make sure the importer
+  // gets it right.
+  Decl *From, *To;
+  std::tie(From, To) = getImportedDecl(
+"void declToImport() { (void)__builtin_choose_expr(1, 0, 1); }",
+Lang_C, "", Lang_C);
+
+  auto ToResults = match(chooseExpr().bind("choose"), To->getASTContext());
+  auto FromResults = match(chooseExpr().bind("choose"), From->getASTContext());
+
+  const ChooseExpr *FromChooseExpr =
+  selectFirst("choose", FromResults);
+  ASSERT_TRUE(FromChooseExpr);
+
+  const ChooseExpr *ToChooseExpr = selectFirst("choose", ToResults);
+  ASSERT_TRUE(ToChooseExpr);
+
+  EXPECT_EQ(FromChooseExpr->isConditionTrue(), ToChooseExpr->isConditionTrue());
+}
+
 TEST_P(ASTImporterOptionSpecificTestBase,
ImportFunctionWithBackReferringParameter) {
   Decl *From, *To;
Index: clang/test/ASTMerge/choose-expr/test.c
===
--- /dev/null
+++ clang/test/ASTMerge/choose-expr/test.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -std=c11 -emit-pch -o %t.ast %S/Inputs/choose.c
+// RUN: %clang_cc1 -std=c11 -ast-merge %t.ast -fsyntax-only -verify %s
+// expected-no-diagnostics
+
Index: clang/test/ASTMerge/choose-expr/Inputs/choose.c
===
--- /dev/null
+++ clang/test/ASTMerge/choose-expr/Inputs/choose.c
@@ -0,0 +1,2 @@
+_Static_assert(__builtin_choose_expr(1, 1, 0), "Incorrect semantics of __builtin_choose_expr");
+_Static_assert(__builtin_choose_expr(0, 0, 1), "Incorrect semantics of __builtin_choose_expr");
Index: clang/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -147,6 +147,7 @@
   REGISTER_MATCHER(caseStmt);
   REGISTER_MATCHER(castExpr);
   REGISTER_MATCHER(characterLiteral);
+  REGISTER_MATCHER(chooseExpr);
   REGISTER_MATCHER(classTemplateDecl);
   REGISTER_MATCHER(classTemplateSpecializationDecl);
   REGISTER_MATCHER(complexType);
Index: 

r354831 - [NFC] Reorder some mis-ordered tests

2019-02-25 Thread JF Bastien via cfe-commits
Author: jfb
Date: Mon Feb 25 15:09:34 2019
New Revision: 354831

URL: http://llvm.org/viewvc/llvm-project?rev=354831=rev
Log:
[NFC] Reorder some mis-ordered tests

I somehow had misaligned some of the tests when I originally wrote this. 
Re-order them properly.

Modified:
cfe/trunk/test/CodeGenCXX/auto-var-init.cpp

Modified: cfe/trunk/test/CodeGenCXX/auto-var-init.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/auto-var-init.cpp?rev=354831=354830=354831=diff
==
--- cfe/trunk/test/CodeGenCXX/auto-var-init.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/auto-var-init.cpp Mon Feb 25 15:09:34 2019
@@ -111,22 +111,22 @@ struct derived : public base {};
 struct virtualderived : public virtual base, public virtual derived {};
 // PATTERN: @__const.test_matching_uninit.uninit = private unnamed_addr 
constant %union.matching { i32 -1431655766 }, align 4
 // PATTERN: @__const.test_matching_custom.custom = private unnamed_addr 
constant { float } { float 6.145500e+04 }, align 4
+// ZERO: @__const.test_matching_custom.custom = private unnamed_addr constant 
{ float } { float 6.145500e+04 }, align 4
 union matching { int i; float f; };
 // PATTERN: @__const.test_matchingreverse_uninit.uninit = private unnamed_addr 
constant %union.matchingreverse { float 0xE000 }, align 4
 // PATTERN: @__const.test_matchingreverse_custom.custom = private unnamed_addr 
constant { i32 } { i32 61455 }, align 4
-// ZERO: @__const.test_matching_custom.custom = private unnamed_addr constant 
{ float } { float 6.145500e+04 }, align 4
+// ZERO: @__const.test_matchingreverse_custom.custom = private unnamed_addr 
constant { i32 } { i32 61455 }, align 4
 union matchingreverse { float f; int i; };
 // PATTERN: @__const.test_unmatched_uninit.uninit = private unnamed_addr 
constant %union.unmatched { i32 -1431655766 }, align 4
 // PATTERN: @__const.test_unmatched_custom.custom = private unnamed_addr 
constant %union.unmatched { i32 1001242351 }, align 4
-// ZERO: @__const.test_matchingreverse_custom.custom = private unnamed_addr 
constant { i32 } { i32 61455 }, align 4
+// ZERO: @__const.test_unmatched_custom.custom = private unnamed_addr constant 
%union.unmatched { i32 1001242351 }, align 4
 union unmatched { char c; int i; };
 // PATTERN: @__const.test_unmatchedreverse_uninit.uninit = private 
unnamed_addr constant %union.unmatchedreverse { i32 -1431655766 }, align 4
 // PATTERN: @__const.test_unmatchedreverse_custom.custom = private 
unnamed_addr constant { i8, [3 x i8] } { i8 42, [3 x i8] zeroinitializer }, 
align 4
-// ZERO: @__const.test_unmatched_custom.custom = private unnamed_addr constant 
%union.unmatched { i32 1001242351 }, align 4
+// ZERO: @__const.test_unmatchedreverse_custom.custom = private unnamed_addr 
constant { i8, [3 x i8] } { i8 42, [3 x i8] zeroinitializer }, align 4
 union unmatchedreverse { int i; char c; };
 // PATTERN: @__const.test_unmatchedfp_uninit.uninit = private unnamed_addr 
constant %union.unmatchedfp { double 0x }, align 8
 // PATTERN: @__const.test_unmatchedfp_custom.custom = private unnamed_addr 
constant %union.unmatchedfp { double 0x400921FB54442D18 }, align 8
-// ZERO: @__const.test_unmatchedreverse_custom.custom = private unnamed_addr 
constant { i8, [3 x i8] } { i8 42, [3 x i8] zeroinitializer }, align 4
 // ZERO: @__const.test_unmatchedfp_custom.custom = private unnamed_addr 
constant %union.unmatchedfp { double 0x400921FB54442D18 }, align 8
 union unmatchedfp { float f; double d; };
 enum emptyenum {};


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


[PATCH] D57898: CodeGen: Fix PR40605: split constant structures generated by -ftrivial-auto-var-init when emitting initializators

2019-02-25 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.

I think (with test updates) this will be good to go once D58188 
 lands.




Comment at: tools/clang/lib/CodeGen/CGDecl.cpp:1158
+  llvm::StructType *STy = dyn_cast(Ty);
+  if (STy && (STy == Loc.getElementType()) &&
+  shouldSplitStructStore(CGM, ConstantSize)) {

Can you leave a FIXME here to handle `STY != Loc.getElementType()`, as well as 
another FIXME to handle non-struct aggregate types such as arrays? I'm happy to 
do them as a follow-up.


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

https://reviews.llvm.org/D57898



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


Re: r354795 - Make static counters in ASTContext non-static.

2019-02-25 Thread Alexander Kornienko via cfe-commits
Done. r354827 should be better.

On Mon, Feb 25, 2019 at 11:18 PM Alexander Kornienko 
wrote:

> Thank you for taking care of this! That's a bug indeed. Will recommit with
> a fix.
>
> On Mon, Feb 25, 2019 at 9:25 PM Vlad Tsyrklevich 
> wrote:
>
>> I've reverted this commit in r354812, it was causing MSan failures like
>> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/29886/steps/check-clang%20msan/logs/stdio
>>  Though
>> these error reports don't clearly implicate this change, from your change
>> it seems like the failure is occurring because you changed static
>> (zero-initialized) variables to member (uninitialized) variables that were
>> then never initialized before being used. The build recovered after the
>> revert landed in
>> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/29894
>>
>> On Mon, Feb 25, 2019 at 8:07 AM Alexander Kornienko via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: alexfh
>>> Date: Mon Feb 25 08:08:46 2019
>>> New Revision: 354795
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=354795=rev
>>> Log:
>>> Make static counters in ASTContext non-static.
>>>
>>> Summary:
>>> Fixes a data race and makes it possible to run clang-based tools in
>>> multithreaded environment with TSan.
>>>
>>> Reviewers: ilya-biryukov, riccibruno
>>>
>>> Reviewed By: riccibruno
>>>
>>> Subscribers: riccibruno, jfb, cfe-commits
>>>
>>> Tags: #clang
>>>
>>> Differential Revision: https://reviews.llvm.org/D58612
>>>
>>> Modified:
>>> cfe/trunk/include/clang/AST/ASTContext.h
>>> cfe/trunk/lib/AST/ASTContext.cpp
>>> cfe/trunk/lib/Sema/SemaDeclCXX.cpp
>>>
>>> Modified: cfe/trunk/include/clang/AST/ASTContext.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=354795=354794=354795=diff
>>>
>>> ==
>>> --- cfe/trunk/include/clang/AST/ASTContext.h (original)
>>> +++ cfe/trunk/include/clang/AST/ASTContext.h Mon Feb 25 08:08:46 2019
>>> @@ -2809,46 +2809,46 @@ public:
>>>
>>>  
>>> //======//
>>>
>>>/// The number of implicitly-declared default constructors.
>>> -  static unsigned NumImplicitDefaultConstructors;
>>> +  unsigned NumImplicitDefaultConstructors;
>>>
>>>/// The number of implicitly-declared default constructors for
>>>/// which declarations were built.
>>> -  static unsigned NumImplicitDefaultConstructorsDeclared;
>>> +  unsigned NumImplicitDefaultConstructorsDeclared;
>>>
>>>/// The number of implicitly-declared copy constructors.
>>> -  static unsigned NumImplicitCopyConstructors;
>>> +  unsigned NumImplicitCopyConstructors;
>>>
>>>/// The number of implicitly-declared copy constructors for
>>>/// which declarations were built.
>>> -  static unsigned NumImplicitCopyConstructorsDeclared;
>>> +  unsigned NumImplicitCopyConstructorsDeclared;
>>>
>>>/// The number of implicitly-declared move constructors.
>>> -  static unsigned NumImplicitMoveConstructors;
>>> +  unsigned NumImplicitMoveConstructors;
>>>
>>>/// The number of implicitly-declared move constructors for
>>>/// which declarations were built.
>>> -  static unsigned NumImplicitMoveConstructorsDeclared;
>>> +  unsigned NumImplicitMoveConstructorsDeclared;
>>>
>>>/// The number of implicitly-declared copy assignment operators.
>>> -  static unsigned NumImplicitCopyAssignmentOperators;
>>> +  unsigned NumImplicitCopyAssignmentOperators;
>>>
>>>/// The number of implicitly-declared copy assignment operators for
>>>/// which declarations were built.
>>> -  static unsigned NumImplicitCopyAssignmentOperatorsDeclared;
>>> +  unsigned NumImplicitCopyAssignmentOperatorsDeclared;
>>>
>>>/// The number of implicitly-declared move assignment operators.
>>> -  static unsigned NumImplicitMoveAssignmentOperators;
>>> +  unsigned NumImplicitMoveAssignmentOperators;
>>>
>>>/// The number of implicitly-declared move assignment operators for
>>>/// which declarations were built.
>>> -  static unsigned NumImplicitMoveAssignmentOperatorsDeclared;
>>> +  unsigned NumImplicitMoveAssignmentOperatorsDeclared;
>>>
>>>/// The number of implicitly-declared destructors.
>>> -  static unsigned NumImplicitDestructors;
>>> +  unsigned NumImplicitDestructors;
>>>
>>>/// The number of implicitly-declared destructors for which
>>>/// declarations were built.
>>> -  static unsigned NumImplicitDestructorsDeclared;
>>> +  unsigned NumImplicitDestructorsDeclared;
>>>
>>>  public:
>>>/// Initialize built-in types.
>>>
>>> Modified: cfe/trunk/lib/AST/ASTContext.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=354795=354794=354795=diff
>>>
>>> ==
>>> --- cfe/trunk/lib/AST/ASTContext.cpp (original)
>>> +++ 

r354827 - Reapply "Make static counters in ASTContext non-static." with fixes.

2019-02-25 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Mon Feb 25 14:22:09 2019
New Revision: 354827

URL: http://llvm.org/viewvc/llvm-project?rev=354827=rev
Log:
Reapply "Make static counters in ASTContext non-static." with fixes.

This reverts commit e50038e4dc53caee1acc811362ac0b15e00ef5eb.

Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=354827=354826=354827=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Mon Feb 25 14:22:09 2019
@@ -2809,46 +2809,46 @@ public:
   
//======//
 
   /// The number of implicitly-declared default constructors.
-  static unsigned NumImplicitDefaultConstructors;
+  unsigned NumImplicitDefaultConstructors = 0;
 
   /// The number of implicitly-declared default constructors for
   /// which declarations were built.
-  static unsigned NumImplicitDefaultConstructorsDeclared;
+  unsigned NumImplicitDefaultConstructorsDeclared = 0;
 
   /// The number of implicitly-declared copy constructors.
-  static unsigned NumImplicitCopyConstructors;
+  unsigned NumImplicitCopyConstructors = 0;
 
   /// The number of implicitly-declared copy constructors for
   /// which declarations were built.
-  static unsigned NumImplicitCopyConstructorsDeclared;
+  unsigned NumImplicitCopyConstructorsDeclared = 0;
 
   /// The number of implicitly-declared move constructors.
-  static unsigned NumImplicitMoveConstructors;
+  unsigned NumImplicitMoveConstructors = 0;
 
   /// The number of implicitly-declared move constructors for
   /// which declarations were built.
-  static unsigned NumImplicitMoveConstructorsDeclared;
+  unsigned NumImplicitMoveConstructorsDeclared = 0;
 
   /// The number of implicitly-declared copy assignment operators.
-  static unsigned NumImplicitCopyAssignmentOperators;
+  unsigned NumImplicitCopyAssignmentOperators = 0;
 
   /// The number of implicitly-declared copy assignment operators for
   /// which declarations were built.
-  static unsigned NumImplicitCopyAssignmentOperatorsDeclared;
+  unsigned NumImplicitCopyAssignmentOperatorsDeclared = 0;
 
   /// The number of implicitly-declared move assignment operators.
-  static unsigned NumImplicitMoveAssignmentOperators;
+  unsigned NumImplicitMoveAssignmentOperators = 0;
 
   /// The number of implicitly-declared move assignment operators for
   /// which declarations were built.
-  static unsigned NumImplicitMoveAssignmentOperatorsDeclared;
+  unsigned NumImplicitMoveAssignmentOperatorsDeclared = 0;
 
   /// The number of implicitly-declared destructors.
-  static unsigned NumImplicitDestructors;
+  unsigned NumImplicitDestructors = 0;
 
   /// The number of implicitly-declared destructors for which
   /// declarations were built.
-  static unsigned NumImplicitDestructorsDeclared;
+  unsigned NumImplicitDestructorsDeclared = 0;
 
 public:
   /// Initialize built-in types.

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=354827=354826=354827=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Mon Feb 25 14:22:09 2019
@@ -94,19 +94,6 @@
 
 using namespace clang;
 
-unsigned ASTContext::NumImplicitDefaultConstructors;
-unsigned ASTContext::NumImplicitDefaultConstructorsDeclared;
-unsigned ASTContext::NumImplicitCopyConstructors;
-unsigned ASTContext::NumImplicitCopyConstructorsDeclared;
-unsigned ASTContext::NumImplicitMoveConstructors;
-unsigned ASTContext::NumImplicitMoveConstructorsDeclared;
-unsigned ASTContext::NumImplicitCopyAssignmentOperators;
-unsigned ASTContext::NumImplicitCopyAssignmentOperatorsDeclared;
-unsigned ASTContext::NumImplicitMoveAssignmentOperators;
-unsigned ASTContext::NumImplicitMoveAssignmentOperatorsDeclared;
-unsigned ASTContext::NumImplicitDestructors;
-unsigned ASTContext::NumImplicitDestructorsDeclared;
-
 enum FloatingRank {
   Float16Rank, HalfRank, FloatRank, DoubleRank, LongDoubleRank, Float128Rank
 };

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=354827=354826=354827=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Mon Feb 25 14:22:09 2019
@@ -7971,14 +7971,14 @@ void Sema::ActOnFinishCXXMemberSpecifica
 /// definition of the class is complete.
 void Sema::AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl) {
   if (ClassDecl->needsImplicitDefaultConstructor()) {
-

Re: r354795 - Make static counters in ASTContext non-static.

2019-02-25 Thread Alexander Kornienko via cfe-commits
Thank you for taking care of this! That's a bug indeed. Will recommit with
a fix.

On Mon, Feb 25, 2019 at 9:25 PM Vlad Tsyrklevich 
wrote:

> I've reverted this commit in r354812, it was causing MSan failures like
> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/29886/steps/check-clang%20msan/logs/stdio
>  Though
> these error reports don't clearly implicate this change, from your change
> it seems like the failure is occurring because you changed static
> (zero-initialized) variables to member (uninitialized) variables that were
> then never initialized before being used. The build recovered after the
> revert landed in
> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/29894
>
> On Mon, Feb 25, 2019 at 8:07 AM Alexander Kornienko via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: alexfh
>> Date: Mon Feb 25 08:08:46 2019
>> New Revision: 354795
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=354795=rev
>> Log:
>> Make static counters in ASTContext non-static.
>>
>> Summary:
>> Fixes a data race and makes it possible to run clang-based tools in
>> multithreaded environment with TSan.
>>
>> Reviewers: ilya-biryukov, riccibruno
>>
>> Reviewed By: riccibruno
>>
>> Subscribers: riccibruno, jfb, cfe-commits
>>
>> Tags: #clang
>>
>> Differential Revision: https://reviews.llvm.org/D58612
>>
>> Modified:
>> cfe/trunk/include/clang/AST/ASTContext.h
>> cfe/trunk/lib/AST/ASTContext.cpp
>> cfe/trunk/lib/Sema/SemaDeclCXX.cpp
>>
>> Modified: cfe/trunk/include/clang/AST/ASTContext.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=354795=354794=354795=diff
>>
>> ==
>> --- cfe/trunk/include/clang/AST/ASTContext.h (original)
>> +++ cfe/trunk/include/clang/AST/ASTContext.h Mon Feb 25 08:08:46 2019
>> @@ -2809,46 +2809,46 @@ public:
>>
>>  
>> //======//
>>
>>/// The number of implicitly-declared default constructors.
>> -  static unsigned NumImplicitDefaultConstructors;
>> +  unsigned NumImplicitDefaultConstructors;
>>
>>/// The number of implicitly-declared default constructors for
>>/// which declarations were built.
>> -  static unsigned NumImplicitDefaultConstructorsDeclared;
>> +  unsigned NumImplicitDefaultConstructorsDeclared;
>>
>>/// The number of implicitly-declared copy constructors.
>> -  static unsigned NumImplicitCopyConstructors;
>> +  unsigned NumImplicitCopyConstructors;
>>
>>/// The number of implicitly-declared copy constructors for
>>/// which declarations were built.
>> -  static unsigned NumImplicitCopyConstructorsDeclared;
>> +  unsigned NumImplicitCopyConstructorsDeclared;
>>
>>/// The number of implicitly-declared move constructors.
>> -  static unsigned NumImplicitMoveConstructors;
>> +  unsigned NumImplicitMoveConstructors;
>>
>>/// The number of implicitly-declared move constructors for
>>/// which declarations were built.
>> -  static unsigned NumImplicitMoveConstructorsDeclared;
>> +  unsigned NumImplicitMoveConstructorsDeclared;
>>
>>/// The number of implicitly-declared copy assignment operators.
>> -  static unsigned NumImplicitCopyAssignmentOperators;
>> +  unsigned NumImplicitCopyAssignmentOperators;
>>
>>/// The number of implicitly-declared copy assignment operators for
>>/// which declarations were built.
>> -  static unsigned NumImplicitCopyAssignmentOperatorsDeclared;
>> +  unsigned NumImplicitCopyAssignmentOperatorsDeclared;
>>
>>/// The number of implicitly-declared move assignment operators.
>> -  static unsigned NumImplicitMoveAssignmentOperators;
>> +  unsigned NumImplicitMoveAssignmentOperators;
>>
>>/// The number of implicitly-declared move assignment operators for
>>/// which declarations were built.
>> -  static unsigned NumImplicitMoveAssignmentOperatorsDeclared;
>> +  unsigned NumImplicitMoveAssignmentOperatorsDeclared;
>>
>>/// The number of implicitly-declared destructors.
>> -  static unsigned NumImplicitDestructors;
>> +  unsigned NumImplicitDestructors;
>>
>>/// The number of implicitly-declared destructors for which
>>/// declarations were built.
>> -  static unsigned NumImplicitDestructorsDeclared;
>> +  unsigned NumImplicitDestructorsDeclared;
>>
>>  public:
>>/// Initialize built-in types.
>>
>> Modified: cfe/trunk/lib/AST/ASTContext.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=354795=354794=354795=diff
>>
>> ==
>> --- cfe/trunk/lib/AST/ASTContext.cpp (original)
>> +++ cfe/trunk/lib/AST/ASTContext.cpp Mon Feb 25 08:08:46 2019
>> @@ -94,19 +94,6 @@
>>
>>  using namespace clang;
>>
>> -unsigned ASTContext::NumImplicitDefaultConstructors;
>> -unsigned ASTContext::NumImplicitDefaultConstructorsDeclared;
>> -unsigned 

r354826 - [CodeGenObjC] Fix a nullptr dyn_cast

2019-02-25 Thread Erik Pilkington via cfe-commits
Author: epilk
Date: Mon Feb 25 13:35:14 2019
New Revision: 354826

URL: http://llvm.org/viewvc/llvm-project?rev=354826=rev
Log:
[CodeGenObjC] Fix a nullptr dyn_cast

ObjCMessageExpr::getInstanceReceiver returns nullptr if the receiver
is 'super'. Make this check more strict, since we don't care about
messages to super here.

rdar://48247290

Modified:
cfe/trunk/lib/CodeGen/CGObjC.cpp
cfe/trunk/test/CodeGenObjC/objc-alloc-init.m

Modified: cfe/trunk/lib/CodeGen/CGObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjC.cpp?rev=354826=354825=354826=diff
==
--- cfe/trunk/lib/CodeGen/CGObjC.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp Mon Feb 25 13:35:14 2019
@@ -433,8 +433,9 @@ tryEmitSpecializedAllocInit(CodeGenFunct
 
   // Match the exact pattern '[[MyClass alloc] init]'.
   Selector Sel = OME->getSelector();
-  if (!OME->isInstanceMessage() || !OME->getType()->isObjCObjectPointerType() 
||
-  !Sel.isUnarySelector() || Sel.getNameForSlot(0) != "init")
+  if (OME->getReceiverKind() != ObjCMessageExpr::Instance ||
+  !OME->getType()->isObjCObjectPointerType() || !Sel.isUnarySelector() ||
+  Sel.getNameForSlot(0) != "init")
 return None;
 
   // Okay, this is '[receiver init]', check if 'receiver' is '[cls alloc]'.

Modified: cfe/trunk/test/CodeGenObjC/objc-alloc-init.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/objc-alloc-init.m?rev=354826=354825=354826=diff
==
--- cfe/trunk/test/CodeGenObjC/objc-alloc-init.m (original)
+++ cfe/trunk/test/CodeGenObjC/objc-alloc-init.m Mon Feb 25 13:35:14 2019
@@ -26,3 +26,16 @@ void f() {
   // EITHER: call {{.*}} @objc_msgSend
 }
 @end
+
+// rdar://48247290
+@interface Base
+-(instancetype)init;
+@end
+
+@interface Derived : Base
+@end
+@implementation Derived
+-(void)meth {
+  [super init];
+}
+@end


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


[PATCH] D58541: [CodeComplete] Propagate preferred type for function arguments in more cases

2019-02-25 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58541



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


[PATCH] D58089: Add missing library dependencies in CMakeLists.txt

2019-02-25 Thread Nicholas Allegra via Phabricator via cfe-commits
comex added a comment.

Ping.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D58089



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


[PATCH] D58321: [WIP] Support for relative vtables

2019-02-25 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

In D58321#1407362 , @pcc wrote:

> Can we start with a patch that just exposes a flag that enables the relative 
> ABI unconditionally, and remove all the platform ABI compatibility stuff?


Done. Removed the checks requiring LTO, checks in `checkClassABI`, and relevant 
tests for them.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58321



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


[PATCH] D58321: [WIP] Support for relative vtables

2019-02-25 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 188256.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58321

Files:
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/AST/VTableBuilder.h
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/DeclCXX.cpp
  clang/lib/CodeGen/CGClass.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGVTables.cpp
  clang/lib/CodeGen/CGVTables.h
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/CodeGen/MicrosoftCXXABI.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/CodeGenCXX/debug-info-virtual-fn-relative.cpp
  clang/test/CodeGenCXX/type-metadata.cpp
  clang/test/CodeGenCXX/vtable-relative-abi.cpp
  clang/test/Driver/unstable-cxx-abi-vtables.cpp

Index: clang/test/Driver/unstable-cxx-abi-vtables.cpp
===
--- /dev/null
+++ clang/test/Driver/unstable-cxx-abi-vtables.cpp
@@ -0,0 +1,2 @@
+// RUN: %clang -flto -flto-relative-c++-abi-vtables -### %s 2>&1 | FileCheck -check-prefix=LTO-CLASSES %s
+// LTO-CLASSES: "-flto-relative-c++-abi-vtables"
Index: clang/test/CodeGenCXX/vtable-relative-abi.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/vtable-relative-abi.cpp
@@ -0,0 +1,123 @@
+// RUN: %clang_cc1 %s -flto -flto-unit -triple x86_64-unknown-linux-gnu -fvisibility hidden -flto-relative-c++-abi-vtables -emit-llvm -o - | FileCheck --check-prefix=CHECK --check-prefix=CHECK-ITANIUM %s
+// RUN: %clang_cc1 %s -flto -flto-unit -triple x86_64-unknown-windows-msvc -flto-relative-c++-abi-vtables -emit-llvm -o - | FileCheck --check-prefix=CHECK --check-prefix=CHECK-MS %s
+// RUN: %clang_cc1 %s -flto -flto-unit -triple x86_64-unknown-linux-gnu -fvisibility hidden -emit-llvm -o - | FileCheck --check-prefix=CHECK-NOABI %s
+
+// CHECK-ITANIUM: @_ZTV1S = hidden unnamed_addr constant { { i8*, i8*, i32, i32 } } { { i8*, i8*, i32, i32 } { i8* null, i8* bitcast ({ i8*, i8* }* @_ZTI1S to i8*), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.S*)* @_ZN1S2f1Ev to i64), i64 ptrtoint (i32* getelementptr inbounds ({ { i8*, i8*, i32, i32 } }, { { i8*, i8*, i32, i32 } }* @_ZTV1S, i32 0, i32 0, i32 2) to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.S*)* @_ZN1S2f2Ev to i64), i64 ptrtoint (i32* getelementptr inbounds ({ { i8*, i8*, i32, i32 } }, { { i8*, i8*, i32, i32 } }* @_ZTV1S, i32 0, i32 0, i32 3) to i64)) to i32) } }, align 8
+// CHECK-MS: @anon.[[NUM:[a-z0-9]+]].0 = private unnamed_addr constant { { i8*, i32, i32 } } { { i8*, i32, i32 } { i8* bitcast (%rtti.CompleteObjectLocator* @"??_R4S@@6B@" to i8*), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.S*)* @"?f1@S@@UEAAXXZ" to i64), i64 ptrtoint (i32* getelementptr inbounds ({ { i8*, i32, i32 } }, { { i8*, i32, i32 } }* @anon.[[NUM]].0, i32 0, i32 0, i32 1) to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.S*)* @"?f2@S@@UEAAXXZ" to i64), i64 ptrtoint (i32* getelementptr inbounds ({ { i8*, i32, i32 } }, { { i8*, i32, i32 } }* @anon.[[NUM]].0, i32 0, i32 0, i32 2) to i64)) to i32) } }, comdat($"??_7S@@6B@")
+struct S {
+  S();
+  virtual void f1();
+  virtual void f2();
+};
+
+// CHECK-ITANIUM: @_ZTV1T = hidden unnamed_addr constant { { i8*, i8*, i32 } } { { i8*, i8*, i32 } { i8* null, i8* bitcast ({ i8*, i8* }* @_ZTI1T to i8*), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.T*)* @_ZN1T1gEv to i64), i64 ptrtoint (i32* getelementptr inbounds ({ { i8*, i8*, i32 } }, { { i8*, i8*, i32 } }* @_ZTV1T, i32 0, i32 0, i32 2) to i64)) to i32) } }, align 8
+// CHECK-MS: @anon.[[NUM]].1 = private unnamed_addr constant { { i8*, i32 } } { { i8*, i32 } { i8* bitcast (%rtti.CompleteObjectLocator* @"??_R4T@@6B@" to i8*), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.T*)* @"?g@T@@UEAAXXZ" to i64), i64 ptrtoint (i32* getelementptr inbounds ({ { i8*, i32 } }, { { i8*, i32 } }* @anon.[[NUM]].1, i32 0, i32 0, i32 1) to i64)) to i32) } }, comdat($"??_7T@@6B@")
+struct T {
+  T();
+  virtual void g();
+};
+
+// CHECK-ITANIUM: @_ZTV1U = hidden unnamed_addr constant { { i8*, i8*, i32, i32 }, { i8*, i8*, i32 } } { { i8*, i8*, i32, i32 } { i8* null, i8* bitcast ({ i8*, i8*, i32, i32, i8*, i64, i8*, i64 }* @_ZTI1U to i8*), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.U*)* @_ZN1U2f1Ev to i64), i64 ptrtoint (i32* getelementptr inbounds ({ { i8*, i8*, i32, i32 }, { i8*, i8*, i32 } }, { { i8*, i8*, i32, i32 }, { i8*, i8*, i32 } }* @_ZTV1U, i32 0, i32 0, i32 2) to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.S*)* @_ZN1S2f2Ev to i64), i64 ptrtoint (i32* getelementptr inbounds ({ { 

[PATCH] D58569: [libclang] Avoid crashing when getting layout info of an undeduced type.

2019-02-25 Thread Emilio Cobos Álvarez via Phabricator via cfe-commits
emilio updated this revision to Diff 188254.
emilio marked an inline comment as done.
emilio added a comment.

Add CHECK tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58569

Files:
  clang/include/clang-c/Index.h
  clang/test/Index/print-type-size.cpp
  clang/tools/c-index-test/c-index-test.c
  clang/tools/libclang/CXType.cpp

Index: clang/tools/libclang/CXType.cpp
===
--- clang/tools/libclang/CXType.cpp
+++ clang/tools/libclang/CXType.cpp
@@ -891,6 +891,9 @@
 return CXTypeLayoutError_Incomplete;
   if (QT->isDependentType())
 return CXTypeLayoutError_Dependent;
+  if (const auto *Deduced = dyn_cast(QT))
+if (Deduced->getDeducedType().isNull())
+  return CXTypeLayoutError_Undeduced;
   // Exceptions by GCC extension - see ASTContext.cpp:1313 getTypeInfoImpl
   // if (QT->isFunctionType()) return 4; // Bug #15511 - should be 1
   // if (QT->isVoidType()) return 1;
@@ -928,6 +931,9 @@
 return CXTypeLayoutError_Dependent;
   if (!QT->isConstantSizeType())
 return CXTypeLayoutError_NotConstantSize;
+  if (const auto *Deduced = dyn_cast(QT))
+if (Deduced->getDeducedType().isNull())
+  return CXTypeLayoutError_Undeduced;
   // [gcc extension] lib/AST/ExprConstant.cpp:1372
   // HandleSizeof : {voidtype,functype} == 1
   // not handled by ASTContext.cpp:1313 getTypeInfoImpl
Index: clang/tools/c-index-test/c-index-test.c
===
--- clang/tools/c-index-test/c-index-test.c
+++ clang/tools/c-index-test/c-index-test.c
@@ -1670,29 +1670,44 @@
   return CXChildVisit_Recurse;
 }
 
-static enum CXChildVisitResult PrintTypeSize(CXCursor cursor, CXCursor p,
- CXClientData d) {
-  CXType T;
-  enum CXCursorKind K = clang_getCursorKind(cursor);
-  if (clang_isInvalid(K))
-return CXChildVisit_Recurse;
-  T = clang_getCursorType(cursor);
-  PrintCursor(cursor, NULL);
-  PrintTypeAndTypeKind(T, " [type=%s] [typekind=%s]");
+static void PrintSingleTypeSize(CXType T, const char *TypeKindFormat,
+const char *SizeFormat,
+const char *AlignFormat) {
+  PrintTypeAndTypeKind(T, TypeKindFormat);
   /* Print the type sizeof if applicable. */
   {
 long long Size = clang_Type_getSizeOf(T);
 if (Size >= 0 || Size < -1 ) {
-  printf(" [sizeof=%lld]", Size);
+  printf(SizeFormat, Size);
 }
   }
   /* Print the type alignof if applicable. */
   {
 long long Align = clang_Type_getAlignOf(T);
 if (Align >= 0 || Align < -1) {
-  printf(" [alignof=%lld]", Align);
+  printf(AlignFormat, Align);
 }
   }
+
+  /* Print the return type if it exists. */
+  {
+CXType RT = clang_getResultType(T);
+if (RT.kind != CXType_Invalid)
+  PrintSingleTypeSize(RT, " [resulttype=%s] [resulttypekind=%s]",
+  " [resultsizeof=%lld]", " [resultalignof=%lld]");
+  }
+}
+
+static enum CXChildVisitResult PrintTypeSize(CXCursor cursor, CXCursor p,
+ CXClientData d) {
+  CXType T;
+  enum CXCursorKind K = clang_getCursorKind(cursor);
+  if (clang_isInvalid(K))
+return CXChildVisit_Recurse;
+  T = clang_getCursorType(cursor);
+  PrintCursor(cursor, NULL);
+  PrintSingleTypeSize(T, " [type=%s] [typekind=%s]", " [sizeof=%lld]",
+  " [alignof=%lld]");
   /* Print the record field offset if applicable. */
   {
 CXString FieldSpelling = clang_getCursorSpelling(cursor);
@@ -1730,7 +1745,9 @@
 if (IsBitfield)
   printf(" [BitFieldSize=%d]", clang_getFieldDeclBitWidth(cursor));
   }
+
   printf("\n");
+
   return CXChildVisit_Recurse;
 }
 
Index: clang/test/Index/print-type-size.cpp
===
--- clang/test/Index/print-type-size.cpp
+++ clang/test/Index/print-type-size.cpp
@@ -400,4 +400,10 @@
 struct lastValid {
 };
 
+// CHECK64: CXXMethod=Tie:[[@LINE+3]]:8 (const) [type=auto (void *) const] [typekind=FunctionProto] [sizeof=1] [alignof=4] [resulttype=auto] [resulttypekind=Auto] [resultsizeof=-6] [resultalignof=-6]
+// CHECK32: CXXMethod=Tie:[[@LINE+2]]:8 (const) [type=auto (void *) const] [typekind=FunctionProto] [sizeof=1] [alignof=4] [resulttype=auto] [resulttypekind=Auto] [resultsizeof=-6] [resultalignof=-6]
+class BrowsingContext {
+  auto Tie(void*) const;
+};
+
 }
Index: clang/include/clang-c/Index.h
===
--- clang/include/clang-c/Index.h
+++ clang/include/clang-c/Index.h
@@ -3841,7 +3841,11 @@
   /**
* The Field name is not valid for this record.
*/
-  CXTypeLayoutError_InvalidFieldName = -5
+  CXTypeLayoutError_InvalidFieldName = -5,
+  /**
+   * The type is undeduced.
+   */
+  CXTypeLayoutError_Undeduced = -6
 };
 

[PATCH] D58570: [libclang] Expose warn_unused and warn_unused_result attributes.

2019-02-25 Thread Emilio Cobos Álvarez via Phabricator via cfe-commits
emilio added a comment.

Landed with that change, thanks for the review @anastasia!


Repository:
  rC Clang

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

https://reviews.llvm.org/D58570



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


[PATCH] D58570: [libclang] Expose warn_unused and warn_unused_result attributes.

2019-02-25 Thread Emilio Cobos Álvarez via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC354824: [libclang] Expose warn_unused and warn_unused_result 
attributes. (authored by emilio, committed by ).
Herald added a reviewer: serge-sans-paille.

Changed prior to commit:
  https://reviews.llvm.org/D58570?vs=188026=188251#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D58570

Files:
  bindings/python/clang/cindex.py
  include/clang-c/Index.h
  test/Index/attributes.c
  tools/libclang/CIndex.cpp
  tools/libclang/CXCursor.cpp


Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -5477,6 +5477,10 @@
   return cxstring::createRef("FriendDecl");
   case CXCursor_ConvergentAttr:
   return cxstring::createRef("attribute(convergent)");
+  case CXCursor_WarnUnusedAttr:
+  return cxstring::createRef("attribute(warn_unused)");
+  case CXCursor_WarnUnusedResultAttr:
+  return cxstring::createRef("attribute(warn_unused_result)");
   }
 
   llvm_unreachable("Unhandled CXCursorKind");
Index: tools/libclang/CXCursor.cpp
===
--- tools/libclang/CXCursor.cpp
+++ tools/libclang/CXCursor.cpp
@@ -79,6 +79,8 @@
 case attr::ObjCBoxable: return CXCursor_ObjCBoxable;
 case attr::FlagEnum: return CXCursor_FlagEnum;
 case attr::Convergent: return CXCursor_ConvergentAttr;
+case attr::WarnUnused: return CXCursor_WarnUnusedAttr;
+case attr::WarnUnusedResult: return CXCursor_WarnUnusedResultAttr;
   }
 
   return CXCursor_UnexposedAttr;
Index: bindings/python/clang/cindex.py
===
--- bindings/python/clang/cindex.py
+++ bindings/python/clang/cindex.py
@@ -1343,6 +1343,8 @@
 CursorKind.DLLEXPORT_ATTR = CursorKind(418)
 CursorKind.DLLIMPORT_ATTR = CursorKind(419)
 CursorKind.CONVERGENT_ATTR = CursorKind(438)
+CursorKind.WARN_UNUSED_ATTR = CursorKind(439)
+CursorKind.WARN_UNUSED_RESULT_ATTR = CursorKind(440)
 
 ###
 # Preprocessing
Index: include/clang-c/Index.h
===
--- include/clang-c/Index.h
+++ include/clang-c/Index.h
@@ -32,7 +32,7 @@
  * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
  */
 #define CINDEX_VERSION_MAJOR 0
-#define CINDEX_VERSION_MINOR 51
+#define CINDEX_VERSION_MINOR 52
 
 #define CINDEX_VERSION_ENCODE(major, minor) ( \
   ((major) * 1)   \
@@ -2587,7 +2587,9 @@
   CXCursor_ObjCBoxable   = 436,
   CXCursor_FlagEnum  = 437,
   CXCursor_ConvergentAttr= 438,
-  CXCursor_LastAttr  = CXCursor_ConvergentAttr,
+  CXCursor_WarnUnusedAttr= 439,
+  CXCursor_WarnUnusedResultAttr  = 440,
+  CXCursor_LastAttr  = CXCursor_WarnUnusedResultAttr,
 
   /* Preprocessing */
   CXCursor_PreprocessingDirective= 500,
Index: test/Index/attributes.c
===
--- test/Index/attributes.c
+++ test/Index/attributes.c
@@ -14,6 +14,12 @@
 
 void convergent_fn() __attribute__((convergent));
 
+int warn_unused_result_fn() __attribute__((warn_unused_result));
+
+struct __attribute__((warn_unused)) WarnUnused {
+  int b;
+};
+
 // CHECK: attributes.c:3:32: StructDecl=Test2:3:32 (Definition) Extent=[3:1 - 
5:2]
 // CHECK: attributes.c:3:23: attribute(packed)=packed Extent=[3:23 - 3:29]
 // CHECK: attributes.c:4:8: FieldDecl=a:4:8 (Definition) Extent=[4:3 - 4:9] 
[access=public]
@@ -29,3 +35,7 @@
 // CHECK: attributes.c:12:3: EnumConstantDecl=Foo:12:3 (Definition) 
Extent=[12:3 - 12:6]
 // CHECK: attributes.c:15:6: FunctionDecl=convergent_fn:15:6 Extent=[15:1 - 
15:49]
 // CHECK: attributes.c:15:37: attribute(convergent)= Extent=[15:37 - 15:47]
+// CHECK: attributes.c:17:5: FunctionDecl=warn_unused_result_fn:17:5 
Extent=[17:1 - 17:64]
+// CHECK: attributes.c:17:44: attribute(warn_unused_result)= Extent=[17:44 - 
17:62]
+// CHECK: attributes.c:19:37: StructDecl=WarnUnused:19:37 (Definition) 
Extent=[19:1 - 21:2]
+// CHECK: attributes.c:19:23: attribute(warn_unused)= Extent=[19:23 - 19:34]


Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -5477,6 +5477,10 @@
   return cxstring::createRef("FriendDecl");
   case CXCursor_ConvergentAttr:
   return cxstring::createRef("attribute(convergent)");
+  case CXCursor_WarnUnusedAttr:
+  return cxstring::createRef("attribute(warn_unused)");
+  case CXCursor_WarnUnusedResultAttr:
+  return cxstring::createRef("attribute(warn_unused_result)");
   }
 
   llvm_unreachable("Unhandled CXCursorKind");
Index: tools/libclang/CXCursor.cpp

r354824 - [libclang] Expose warn_unused and warn_unused_result attributes.

2019-02-25 Thread Emilio Cobos Alvarez via cfe-commits
Author: emilio
Date: Mon Feb 25 13:24:52 2019
New Revision: 354824

URL: http://llvm.org/viewvc/llvm-project?rev=354824=rev
Log:
[libclang] Expose warn_unused and warn_unused_result attributes.

This is helpful to properly detect them, and fixing issues like
https://github.com/rust-lang/rust-bindgen/issues/1518.

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

Modified:
cfe/trunk/bindings/python/clang/cindex.py
cfe/trunk/include/clang-c/Index.h
cfe/trunk/test/Index/attributes.c
cfe/trunk/tools/libclang/CIndex.cpp
cfe/trunk/tools/libclang/CXCursor.cpp

Modified: cfe/trunk/bindings/python/clang/cindex.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/clang/cindex.py?rev=354824=354823=354824=diff
==
--- cfe/trunk/bindings/python/clang/cindex.py (original)
+++ cfe/trunk/bindings/python/clang/cindex.py Mon Feb 25 13:24:52 2019
@@ -1343,6 +1343,8 @@ CursorKind.VISIBILITY_ATTR = CursorKind(
 CursorKind.DLLEXPORT_ATTR = CursorKind(418)
 CursorKind.DLLIMPORT_ATTR = CursorKind(419)
 CursorKind.CONVERGENT_ATTR = CursorKind(438)
+CursorKind.WARN_UNUSED_ATTR = CursorKind(439)
+CursorKind.WARN_UNUSED_RESULT_ATTR = CursorKind(440)
 
 ###
 # Preprocessing

Modified: cfe/trunk/include/clang-c/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=354824=354823=354824=diff
==
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Mon Feb 25 13:24:52 2019
@@ -32,7 +32,7 @@
  * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
  */
 #define CINDEX_VERSION_MAJOR 0
-#define CINDEX_VERSION_MINOR 51
+#define CINDEX_VERSION_MINOR 52
 
 #define CINDEX_VERSION_ENCODE(major, minor) ( \
   ((major) * 1)   \
@@ -2587,7 +2587,9 @@ enum CXCursorKind {
   CXCursor_ObjCBoxable   = 436,
   CXCursor_FlagEnum  = 437,
   CXCursor_ConvergentAttr= 438,
-  CXCursor_LastAttr  = CXCursor_ConvergentAttr,
+  CXCursor_WarnUnusedAttr= 439,
+  CXCursor_WarnUnusedResultAttr  = 440,
+  CXCursor_LastAttr  = CXCursor_WarnUnusedResultAttr,
 
   /* Preprocessing */
   CXCursor_PreprocessingDirective= 500,

Modified: cfe/trunk/test/Index/attributes.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/attributes.c?rev=354824=354823=354824=diff
==
--- cfe/trunk/test/Index/attributes.c (original)
+++ cfe/trunk/test/Index/attributes.c Mon Feb 25 13:24:52 2019
@@ -14,6 +14,12 @@ enum __attribute((flag_enum)) FlagEnum {
 
 void convergent_fn() __attribute__((convergent));
 
+int warn_unused_result_fn() __attribute__((warn_unused_result));
+
+struct __attribute__((warn_unused)) WarnUnused {
+  int b;
+};
+
 // CHECK: attributes.c:3:32: StructDecl=Test2:3:32 (Definition) Extent=[3:1 - 
5:2]
 // CHECK: attributes.c:3:23: attribute(packed)=packed Extent=[3:23 - 3:29]
 // CHECK: attributes.c:4:8: FieldDecl=a:4:8 (Definition) Extent=[4:3 - 4:9] 
[access=public]
@@ -29,3 +35,7 @@ void convergent_fn() __attribute__((conv
 // CHECK: attributes.c:12:3: EnumConstantDecl=Foo:12:3 (Definition) 
Extent=[12:3 - 12:6]
 // CHECK: attributes.c:15:6: FunctionDecl=convergent_fn:15:6 Extent=[15:1 - 
15:49]
 // CHECK: attributes.c:15:37: attribute(convergent)= Extent=[15:37 - 15:47]
+// CHECK: attributes.c:17:5: FunctionDecl=warn_unused_result_fn:17:5 
Extent=[17:1 - 17:64]
+// CHECK: attributes.c:17:44: attribute(warn_unused_result)= Extent=[17:44 - 
17:62]
+// CHECK: attributes.c:19:37: StructDecl=WarnUnused:19:37 (Definition) 
Extent=[19:1 - 21:2]
+// CHECK: attributes.c:19:23: attribute(warn_unused)= Extent=[19:23 - 19:34]

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=354824=354823=354824=diff
==
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Mon Feb 25 13:24:52 2019
@@ -5477,6 +5477,10 @@ CXString clang_getCursorKindSpelling(enu
   return cxstring::createRef("FriendDecl");
   case CXCursor_ConvergentAttr:
   return cxstring::createRef("attribute(convergent)");
+  case CXCursor_WarnUnusedAttr:
+  return cxstring::createRef("attribute(warn_unused)");
+  case CXCursor_WarnUnusedResultAttr:
+  return cxstring::createRef("attribute(warn_unused_result)");
   }
 
   llvm_unreachable("Unhandled CXCursorKind");

Modified: cfe/trunk/tools/libclang/CXCursor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXCursor.cpp?rev=354824=354823=354824=diff
==
--- 

[PATCH] D58571: [libclang] Fix a trivial error introduced in D57946.

2019-02-25 Thread Emilio Cobos Álvarez via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354823: [libclang] Fix a trivial error introduced in D57946. 
(authored by emilio, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D58571?vs=188027=188249#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D58571

Files:
  cfe/trunk/bindings/python/clang/cindex.py


Index: cfe/trunk/bindings/python/clang/cindex.py
===
--- cfe/trunk/bindings/python/clang/cindex.py
+++ cfe/trunk/bindings/python/clang/cindex.py
@@ -1342,7 +1342,7 @@
 
 CursorKind.DLLEXPORT_ATTR = CursorKind(418)
 CursorKind.DLLIMPORT_ATTR = CursorKind(419)
-CursorKind.CONVERGENT_ATTR = CursorKind(420)
+CursorKind.CONVERGENT_ATTR = CursorKind(438)
 
 ###
 # Preprocessing


Index: cfe/trunk/bindings/python/clang/cindex.py
===
--- cfe/trunk/bindings/python/clang/cindex.py
+++ cfe/trunk/bindings/python/clang/cindex.py
@@ -1342,7 +1342,7 @@
 
 CursorKind.DLLEXPORT_ATTR = CursorKind(418)
 CursorKind.DLLIMPORT_ATTR = CursorKind(419)
-CursorKind.CONVERGENT_ATTR = CursorKind(420)
+CursorKind.CONVERGENT_ATTR = CursorKind(438)
 
 ###
 # Preprocessing
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r354823 - [libclang] Fix a trivial error introduced in D57946.

2019-02-25 Thread Emilio Cobos Alvarez via cfe-commits
Author: emilio
Date: Mon Feb 25 13:15:34 2019
New Revision: 354823

URL: http://llvm.org/viewvc/llvm-project?rev=354823=rev
Log:
[libclang] Fix a trivial error introduced in D57946.

The value for CXCursor_ConvergentAttr is not 420. I'm not really sure how easy
it is to test this, and I'm not familiar with the python bindings, just noticed
the error while looking at D57946 to write D58570.

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

Modified:
cfe/trunk/bindings/python/clang/cindex.py

Modified: cfe/trunk/bindings/python/clang/cindex.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/clang/cindex.py?rev=354823=354822=354823=diff
==
--- cfe/trunk/bindings/python/clang/cindex.py (original)
+++ cfe/trunk/bindings/python/clang/cindex.py Mon Feb 25 13:15:34 2019
@@ -1342,7 +1342,7 @@ CursorKind.VISIBILITY_ATTR = CursorKind(
 
 CursorKind.DLLEXPORT_ATTR = CursorKind(418)
 CursorKind.DLLIMPORT_ATTR = CursorKind(419)
-CursorKind.CONVERGENT_ATTR = CursorKind(420)
+CursorKind.CONVERGENT_ATTR = CursorKind(438)
 
 ###
 # Preprocessing


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


[PATCH] D58091: Customize warnings for missing built-in type

2019-02-25 Thread Brian Cain via Phabricator via cfe-commits
bcain added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:592
+: Warning<"declaration of built-in function '%0' requires the declaration"
+" of the 'jmp_buf' type, commonly proived in the header .">,
+  InGroup>;

"proived" should be "provided", I think?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58091



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


[PATCH] D58638: [OpenMP 5.0] Parsing/sema support for from clause with mapper modifier

2019-02-25 Thread Michael Kruse via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354817: [OpenMP 5.0] Parsing/sema support for from clause 
with mapper modifier. (authored by Meinersbur, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D58638?vs=188215=188241#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D58638

Files:
  cfe/trunk/include/clang/AST/OpenMPClause.h
  cfe/trunk/include/clang/Basic/OpenMPKinds.def
  cfe/trunk/include/clang/Basic/OpenMPKinds.h
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/lib/AST/OpenMPClause.cpp
  cfe/trunk/lib/Basic/OpenMPKinds.cpp
  cfe/trunk/lib/Parse/ParseOpenMP.cpp
  cfe/trunk/lib/Sema/SemaOpenMP.cpp
  cfe/trunk/lib/Sema/TreeTransform.h
  cfe/trunk/lib/Serialization/ASTReader.cpp
  cfe/trunk/lib/Serialization/ASTWriter.cpp
  cfe/trunk/test/OpenMP/declare_mapper_ast_print.c
  cfe/trunk/test/OpenMP/declare_mapper_ast_print.cpp
  cfe/trunk/test/OpenMP/declare_mapper_codegen.cpp
  cfe/trunk/test/OpenMP/declare_mapper_messages.c
  cfe/trunk/test/OpenMP/declare_mapper_messages.cpp

Index: cfe/trunk/lib/Basic/OpenMPKinds.cpp
===
--- cfe/trunk/lib/Basic/OpenMPKinds.cpp
+++ cfe/trunk/lib/Basic/OpenMPKinds.cpp
@@ -122,6 +122,12 @@
   .Case(#Name, static_cast(OMPC_TO_MODIFIER_##Name))
 #include "clang/Basic/OpenMPKinds.def"
 .Default(OMPC_TO_MODIFIER_unknown);
+  case OMPC_from:
+return llvm::StringSwitch(Str)
+#define OPENMP_FROM_MODIFIER_KIND(Name) \
+  .Case(#Name, static_cast(OMPC_FROM_MODIFIER_##Name))
+#include "clang/Basic/OpenMPKinds.def"
+.Default(OMPC_FROM_MODIFIER_unknown);
   case OMPC_dist_schedule:
 return llvm::StringSwitch(Str)
 #define OPENMP_DIST_SCHEDULE_KIND(Name) .Case(#Name, OMPC_DIST_SCHEDULE_##Name)
@@ -180,7 +186,6 @@
   case OMPC_num_tasks:
   case OMPC_hint:
   case OMPC_uniform:
-  case OMPC_from:
   case OMPC_use_device_ptr:
   case OMPC_is_device_ptr:
   case OMPC_unified_address:
@@ -277,6 +282,18 @@
   break;
 }
 llvm_unreachable("Invalid OpenMP 'to' clause type");
+  case OMPC_from:
+switch (Type) {
+case OMPC_FROM_MODIFIER_unknown:
+  return "unknown";
+#define OPENMP_FROM_MODIFIER_KIND(Name)\
+  case OMPC_FROM_MODIFIER_##Name:  \
+return #Name;
+#include "clang/Basic/OpenMPKinds.def"
+default:
+  break;
+}
+llvm_unreachable("Invalid OpenMP 'from' clause type");
   case OMPC_dist_schedule:
 switch (Type) {
 case OMPC_DIST_SCHEDULE_unknown:
@@ -350,7 +367,6 @@
   case OMPC_num_tasks:
   case OMPC_hint:
   case OMPC_uniform:
-  case OMPC_from:
   case OMPC_use_device_ptr:
   case OMPC_is_device_ptr:
   case OMPC_unified_address:
Index: cfe/trunk/lib/Serialization/ASTReader.cpp
===
--- cfe/trunk/lib/Serialization/ASTReader.cpp
+++ cfe/trunk/lib/Serialization/ASTReader.cpp
@@ -12448,6 +12448,10 @@
 
 void OMPClauseReader::VisitOMPFromClause(OMPFromClause *C) {
   C->setLParenLoc(Record.readSourceLocation());
+  C->setMapperQualifierLoc(Record.readNestedNameSpecifierLoc());
+  DeclarationNameInfo DNI;
+  Record.readDeclarationNameInfo(DNI);
+  C->setMapperIdInfo(DNI);
   auto NumVars = C->varlist_size();
   auto UniqueDecls = C->getUniqueDeclarationsNum();
   auto TotalLists = C->getTotalComponentListNum();
@@ -12459,6 +12463,12 @@
 Vars.push_back(Record.readSubExpr());
   C->setVarRefs(Vars);
 
+  SmallVector UDMappers;
+  UDMappers.reserve(NumVars);
+  for (unsigned I = 0; I < NumVars; ++I)
+UDMappers.push_back(Record.readSubExpr());
+  C->setUDMapperRefs(UDMappers);
+
   SmallVector Decls;
   Decls.reserve(UniqueDecls);
   for (unsigned i = 0; i < UniqueDecls; ++i)
Index: cfe/trunk/lib/Serialization/ASTWriter.cpp
===
--- cfe/trunk/lib/Serialization/ASTWriter.cpp
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp
@@ -6885,8 +6885,12 @@
   Record.push_back(C->getTotalComponentListNum());
   Record.push_back(C->getTotalComponentsNum());
   Record.AddSourceLocation(C->getLParenLoc());
+  Record.AddNestedNameSpecifierLoc(C->getMapperQualifierLoc());
+  Record.AddDeclarationNameInfo(C->getMapperIdInfo());
   for (auto *E : C->varlists())
 Record.AddStmt(E);
+  for (auto *E : C->mapperlists())
+Record.AddStmt(E);
   for (auto *D : C->all_decls())
 Record.AddDeclRef(D);
   for (auto N : C->all_num_lists())
Index: cfe/trunk/lib/Parse/ParseOpenMP.cpp
===
--- cfe/trunk/lib/Parse/ParseOpenMP.cpp
+++ cfe/trunk/lib/Parse/ParseOpenMP.cpp
@@ -2161,13 +2161,20 @@
 
 if (Tok.is(tok::colon))
   Data.ColonLoc = ConsumeToken();

r354817 - [OpenMP 5.0] Parsing/sema support for from clause with mapper modifier.

2019-02-25 Thread Michael Kruse via cfe-commits
Author: meinersbur
Date: Mon Feb 25 12:34:15 2019
New Revision: 354817

URL: http://llvm.org/viewvc/llvm-project?rev=354817=rev
Log:
[OpenMP 5.0] Parsing/sema support for from clause with mapper modifier.

This patch implements the parsing and sema support for the OpenMP
'from'-clause with potential user-defined mappers attached.
User-defined mappers are a new feature in OpenMP 5.0. A 'from'-clause
can have an explicit or implicit associated mapper, which instructs the
compiler to generate and use customized mapping functions. An example is
shown below:

struct S { int len; int *d; };
#pragma omp declare mapper(id: struct S s) map(s, s.d[0:s.len])
struct S ss;
#pragma omp target update from(mapper(id): ss) // use the mapper with name 
'id' to map ss from device

Contributed-by: Lingda Li 

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

Modified:
cfe/trunk/include/clang/AST/OpenMPClause.h
cfe/trunk/include/clang/Basic/OpenMPKinds.def
cfe/trunk/include/clang/Basic/OpenMPKinds.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/OpenMPClause.cpp
cfe/trunk/lib/Basic/OpenMPKinds.cpp
cfe/trunk/lib/Parse/ParseOpenMP.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/test/OpenMP/declare_mapper_ast_print.c
cfe/trunk/test/OpenMP/declare_mapper_ast_print.cpp
cfe/trunk/test/OpenMP/declare_mapper_codegen.cpp
cfe/trunk/test/OpenMP/declare_mapper_messages.c
cfe/trunk/test/OpenMP/declare_mapper_messages.cpp

Modified: cfe/trunk/include/clang/AST/OpenMPClause.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OpenMPClause.h?rev=354817=354816=354817=diff
==
--- cfe/trunk/include/clang/AST/OpenMPClause.h (original)
+++ cfe/trunk/include/clang/AST/OpenMPClause.h Mon Feb 25 12:34:15 2019
@@ -5082,6 +5082,9 @@ class OMPFromClause final
 
   /// Build clause with number of variables \a NumVars.
   ///
+  /// \param MapperQualifierLoc C++ nested name specifier for the associated
+  /// user-defined mapper.
+  /// \param MapperIdInfo The identifier of associated user-defined mapper.
   /// \param Locs Locations needed to build a mappable clause. It includes 1)
   /// StartLoc: starting location of the clause (the clause keyword); 2)
   /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
@@ -5090,9 +5093,12 @@ class OMPFromClause final
   /// NumUniqueDeclarations: number of unique base declarations in this clause;
   /// 3) NumComponentLists: number of component lists in this clause; and 4)
   /// NumComponents: total number of expression components in the clause.
-  explicit OMPFromClause(const OMPVarListLocTy ,
+  explicit OMPFromClause(NestedNameSpecifierLoc MapperQualifierLoc,
+ DeclarationNameInfo MapperIdInfo,
+ const OMPVarListLocTy ,
  const OMPMappableExprListSizeTy )
-  : OMPMappableExprListClause(OMPC_from, Locs, Sizes) {}
+  : OMPMappableExprListClause(OMPC_from, Locs, Sizes, ,
+  ) {}
 
   /// Build an empty clause.
   ///
@@ -5107,7 +5113,9 @@ class OMPFromClause final
   /// Define the sizes of each trailing object array except the last one. This
   /// is required for TrailingObjects to work properly.
   size_t numTrailingObjects(OverloadToken) const {
-return varlist_size();
+// There are varlist_size() of expressions, and varlist_size() of
+// user-defined mappers.
+return 2 * varlist_size();
   }
   size_t numTrailingObjects(OverloadToken) const {
 return getUniqueDeclarationsNum();
@@ -5126,10 +5134,18 @@ public:
   /// \param Vars The original expression used in the clause.
   /// \param Declarations Declarations used in the clause.
   /// \param ComponentLists Component lists used in the clause.
+  /// \param UDMapperRefs References to user-defined mappers associated with
+  /// expressions used in the clause.
+  /// \param UDMQualifierLoc C++ nested name specifier for the associated
+  /// user-defined mapper.
+  /// \param MapperId The identifier of associated user-defined mapper.
   static OMPFromClause *Create(const ASTContext , const OMPVarListLocTy 
,
ArrayRef Vars,
ArrayRef Declarations,
-   MappableExprComponentListsRef ComponentLists);
+   MappableExprComponentListsRef ComponentLists,
+   ArrayRef UDMapperRefs,
+   NestedNameSpecifierLoc UDMQualifierLoc,
+   DeclarationNameInfo MapperId);
 
   /// Creates an empty clause with the place for \a NumVars variables.
   ///

Modified: cfe/trunk/include/clang/Basic/OpenMPKinds.def
URL: 

[PATCH] D58404: [clang-format] Add basic support for formatting C# files

2019-02-25 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay updated this revision to Diff 188239.
MyDeveloperDay added a subscriber: llvm-commits.
MyDeveloperDay added a comment.

Fix a crash running clang-format over large C# code base
Add support for C# Null Coalescing


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

https://reviews.llvm.org/D58404

Files:
  docs/ClangFormat.rst
  docs/ClangFormatStyleOptions.rst
  docs/ReleaseNotes.rst
  include/clang/Basic/LangOptions.def
  include/clang/Basic/TokenKinds.def
  include/clang/Basic/TokenKinds.h
  include/clang/Format/Format.h
  lib/Format/ContinuationIndenter.cpp
  lib/Format/Format.cpp
  lib/Format/FormatToken.h
  lib/Format/FormatTokenLexer.cpp
  lib/Format/FormatTokenLexer.h
  lib/Format/TokenAnnotator.cpp
  lib/Format/UnwrappedLineFormatter.cpp
  lib/Format/UnwrappedLineParser.cpp
  lib/Lex/Lexer.cpp
  lib/Lex/LiteralSupport.cpp
  lib/Lex/TokenConcatenation.cpp
  tools/clang-format/ClangFormat.cpp
  unittests/Format/CMakeLists.txt
  unittests/Format/FormatTestCSharp.cpp

Index: unittests/Format/FormatTestCSharp.cpp
===
--- /dev/null
+++ unittests/Format/FormatTestCSharp.cpp
@@ -0,0 +1,176 @@
+//===- unittest/Format/FormatTestCSharp.cpp - Formatting tests for CSharp -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "FormatTestUtils.h"
+#include "clang/Format/Format.h"
+#include "llvm/Support/Debug.h"
+#include "gtest/gtest.h"
+
+#define DEBUG_TYPE "format-test"
+
+namespace clang {
+namespace format {
+
+class FormatTestCSharp : public ::testing::Test {
+protected:
+  static std::string format(llvm::StringRef Code, unsigned Offset,
+unsigned Length, const FormatStyle ) {
+LLVM_DEBUG(llvm::errs() << "---\n");
+LLVM_DEBUG(llvm::errs() << Code << "\n\n");
+std::vector Ranges(1, tooling::Range(Offset, Length));
+tooling::Replacements Replaces = reformat(Style, Code, Ranges);
+auto Result = applyAllReplacements(Code, Replaces);
+EXPECT_TRUE(static_cast(Result));
+LLVM_DEBUG(llvm::errs() << "\n" << *Result << "\n\n");
+return *Result;
+  }
+
+  static std::string
+  format(llvm::StringRef Code,
+ const FormatStyle  = getGoogleStyle(FormatStyle::LK_CSharp)) {
+return format(Code, 0, Code.size(), Style);
+  }
+
+  static FormatStyle getStyleWithColumns(unsigned ColumnLimit) {
+FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
+Style.ColumnLimit = ColumnLimit;
+return Style;
+  }
+
+  static void verifyFormat(
+  llvm::StringRef Code,
+  const FormatStyle  = getGoogleStyle(FormatStyle::LK_CSharp)) {
+EXPECT_EQ(Code.str(), format(Code, Style)) << "Expected code is not stable";
+EXPECT_EQ(Code.str(), format(test::messUp(Code), Style));
+  }
+};
+
+TEST_F(FormatTestCSharp, CSharpClass) {
+  verifyFormat("public class SomeClass {\n"
+   "  void f() {}\n"
+   "  int g() { return 0; }\n"
+   "  void h() {\n"
+   "while (true) f();\n"
+   "for (;;) f();\n"
+   "if (true) f();\n"
+   "  }\n"
+   "}");
+}
+
+TEST_F(FormatTestCSharp, AccessModifiers) {
+  verifyFormat("public String toString() {}");
+  verifyFormat("private String toString() {}");
+  verifyFormat("protected String toString() {}");
+  verifyFormat("internal String toString() {}");
+
+  verifyFormat("public override String toString() {}");
+  verifyFormat("private override String toString() {}");
+  verifyFormat("protected override String toString() {}");
+  verifyFormat("internal override String toString() {}");
+
+  verifyFormat("internal static String toString() {}");
+}
+
+TEST_F(FormatTestCSharp, NoStringLiteralBreaks) {
+  verifyFormat("foo("
+   "\"a"
+   "aa\");");
+}
+
+TEST_F(FormatTestCSharp, CSharpVerbatiumStringLiterals) {
+  verifyFormat("foo(@\"\\abc\\\");");
+  // @"ABC\" + ToString("B") - handle embedded \ in literal string at
+  // the end
+  verifyFormat("string s = @\"ABC\\\" + ToString(\"B\");");
+}
+
+TEST_F(FormatTestCSharp, CSharpInterpolatedStringLiterals) {
+  verifyFormat("foo($\"{aaa}\");");
+  verifyFormat("foo($\"{A}\");");
+  verifyFormat(
+  "foo($\"{A}"
+  "a\");");
+  verifyFormat("Name = $\"{firstName} {lastName}\";");
+
+  // $"ABC\" + ToString("B") - handle embedded \ in literal string at
+  // the end
+  verifyFormat("string s = $\"A{abc}BC\" + ToString(\"B\");");
+  verifyFormat("$\"{domain}{user}\"");
+  verifyFormat(
+  "var verbatimInterpolated = 

Re: r354795 - Make static counters in ASTContext non-static.

2019-02-25 Thread Vlad Tsyrklevich via cfe-commits
I've reverted this commit in r354812, it was causing MSan failures like
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/29886/steps/check-clang%20msan/logs/stdio
Though
these error reports don't clearly implicate this change, from your change
it seems like the failure is occurring because you changed static
(zero-initialized) variables to member (uninitialized) variables that were
then never initialized before being used. The build recovered after the
revert landed in
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/29894

On Mon, Feb 25, 2019 at 8:07 AM Alexander Kornienko via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: alexfh
> Date: Mon Feb 25 08:08:46 2019
> New Revision: 354795
>
> URL: http://llvm.org/viewvc/llvm-project?rev=354795=rev
> Log:
> Make static counters in ASTContext non-static.
>
> Summary:
> Fixes a data race and makes it possible to run clang-based tools in
> multithreaded environment with TSan.
>
> Reviewers: ilya-biryukov, riccibruno
>
> Reviewed By: riccibruno
>
> Subscribers: riccibruno, jfb, cfe-commits
>
> Tags: #clang
>
> Differential Revision: https://reviews.llvm.org/D58612
>
> Modified:
> cfe/trunk/include/clang/AST/ASTContext.h
> cfe/trunk/lib/AST/ASTContext.cpp
> cfe/trunk/lib/Sema/SemaDeclCXX.cpp
>
> Modified: cfe/trunk/include/clang/AST/ASTContext.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=354795=354794=354795=diff
>
> ==
> --- cfe/trunk/include/clang/AST/ASTContext.h (original)
> +++ cfe/trunk/include/clang/AST/ASTContext.h Mon Feb 25 08:08:46 2019
> @@ -2809,46 +2809,46 @@ public:
>
>  
> //======//
>
>/// The number of implicitly-declared default constructors.
> -  static unsigned NumImplicitDefaultConstructors;
> +  unsigned NumImplicitDefaultConstructors;
>
>/// The number of implicitly-declared default constructors for
>/// which declarations were built.
> -  static unsigned NumImplicitDefaultConstructorsDeclared;
> +  unsigned NumImplicitDefaultConstructorsDeclared;
>
>/// The number of implicitly-declared copy constructors.
> -  static unsigned NumImplicitCopyConstructors;
> +  unsigned NumImplicitCopyConstructors;
>
>/// The number of implicitly-declared copy constructors for
>/// which declarations were built.
> -  static unsigned NumImplicitCopyConstructorsDeclared;
> +  unsigned NumImplicitCopyConstructorsDeclared;
>
>/// The number of implicitly-declared move constructors.
> -  static unsigned NumImplicitMoveConstructors;
> +  unsigned NumImplicitMoveConstructors;
>
>/// The number of implicitly-declared move constructors for
>/// which declarations were built.
> -  static unsigned NumImplicitMoveConstructorsDeclared;
> +  unsigned NumImplicitMoveConstructorsDeclared;
>
>/// The number of implicitly-declared copy assignment operators.
> -  static unsigned NumImplicitCopyAssignmentOperators;
> +  unsigned NumImplicitCopyAssignmentOperators;
>
>/// The number of implicitly-declared copy assignment operators for
>/// which declarations were built.
> -  static unsigned NumImplicitCopyAssignmentOperatorsDeclared;
> +  unsigned NumImplicitCopyAssignmentOperatorsDeclared;
>
>/// The number of implicitly-declared move assignment operators.
> -  static unsigned NumImplicitMoveAssignmentOperators;
> +  unsigned NumImplicitMoveAssignmentOperators;
>
>/// The number of implicitly-declared move assignment operators for
>/// which declarations were built.
> -  static unsigned NumImplicitMoveAssignmentOperatorsDeclared;
> +  unsigned NumImplicitMoveAssignmentOperatorsDeclared;
>
>/// The number of implicitly-declared destructors.
> -  static unsigned NumImplicitDestructors;
> +  unsigned NumImplicitDestructors;
>
>/// The number of implicitly-declared destructors for which
>/// declarations were built.
> -  static unsigned NumImplicitDestructorsDeclared;
> +  unsigned NumImplicitDestructorsDeclared;
>
>  public:
>/// Initialize built-in types.
>
> Modified: cfe/trunk/lib/AST/ASTContext.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=354795=354794=354795=diff
>
> ==
> --- cfe/trunk/lib/AST/ASTContext.cpp (original)
> +++ cfe/trunk/lib/AST/ASTContext.cpp Mon Feb 25 08:08:46 2019
> @@ -94,19 +94,6 @@
>
>  using namespace clang;
>
> -unsigned ASTContext::NumImplicitDefaultConstructors;
> -unsigned ASTContext::NumImplicitDefaultConstructorsDeclared;
> -unsigned ASTContext::NumImplicitCopyConstructors;
> -unsigned ASTContext::NumImplicitCopyConstructorsDeclared;
> -unsigned ASTContext::NumImplicitMoveConstructors;
> -unsigned ASTContext::NumImplicitMoveConstructorsDeclared;
> -unsigned ASTContext::NumImplicitCopyAssignmentOperators;
> 

[PATCH] D57335: [IR] Don't assume all functions are 4 byte aligned

2019-02-25 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a subscriber: hfinkel.
efriedma added a comment.

Chandler, when you have a chance, can you look at the LangRef changes, since 
you put some thought into the design?

I think the DataLayout/LangRef changes look correct.

I agree it isn't necessary to fix every target in the initial patch; it would 
take a long time to get review, and no one person can properly test every 
target.  But I'm afraid we'll forget to fix some target if someone doesn't go 
through and post followup patches for every target.  (It doesn't really even 
matter if the initial patches are right, as long as there's something for the 
target maintainers to look at.)




Comment at: llvm/include/llvm/IR/ConstantFold.h:7
+//
+//===--===//
+//

Are you just moving this for the unittests?  You shouldn't need to; you can 
just check the result of `ConstantExpr::get(Instruction::And, ...`



Comment at: llvm/lib/IR/ConstantFold.cpp:1087
+  if (GVAlign == 0U && isa(GV))
+GVAlign = 4U;
 

michaelplatings wrote:
> efriedma wrote:
> > Using "4" as a default is dangerous; on x86, the alignment of the pointer 
> > corresponds to the alignment of the function, but might be less than 4 if 
> > it isn't explicitly specified.
> I've put in a comment to say as much. Sadly I'm not in a position to change 
> this behaviour without causing a code size regression.
From the discussion on D55115, adding the right default to x86 (Fn8) is 
probably enough to avoid the regression, but I guess we can deal with that as a 
followup.

Please add a comment like `// FIXME: This code should be deleted once existing 
targets have appropriate defaults`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D57335



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


[PATCH] D58091: Customize warnings for missing built-in type

2019-02-25 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

I did address the comments but I will wait until I hear back on the "warning vs 
warning + note question".

In D58091#1397586 , @jyknight wrote:

> I think this warning (-Wbuiltin-requires-header) doesn't really make sense as 
> its own warning.
>
> [...]
>
> I think for a declaration, if we cannot construct the appropriate type, we 
> should be treating all declarations as an incompatible redeclaration, and 
> explain why in an attached note, like:
>
>   warning: incompatible redeclaration of library function 'exit' 
> [-Wincompatible-library-redeclaration]
>   note: missing declaration of type 'jmp_buf' for argument 1 of standard 
> function signature.
>
>
> For a usage, we could emit something like:
>
>   warning: implicit declaration of library function 'setjmp' 
> [-Wimplicit-function-declaration]
>   note: missing declaration of type 'jmp_buf' for argument 1.
>   note: include the header  or explicitly provide a declaration for 
> 'setjmp'
>


I do not have strong feelings about this, either way is fine with me. However, 
I lack the 
clang expertise to make such a change happen anytime soon which makes this patch
(with actual fix for the warning on pthread_create) my prefered first step.




Comment at: clang/lib/Sema/SemaDecl.cpp:1971
   << Context.BuiltinInfo.getName(ID);
+  return nullptr;
+}

rsmith wrote:
> It'd be nice to produce `note_include_header_or_declare` here. (Ideally, that 
> note should be suppressed if we're transitively in a header with the right 
> name already, but I think it'll be clear enough what's wrong even if we 
> produce the note unconditionally.)
I did add the "include the header" part in the warning now. Does that make 
sense and address your issue or do you think we should have a separate note?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58091



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


[PATCH] D58091: Customize warnings for missing built-in type

2019-02-25 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert updated this revision to Diff 188238.
jdoerfert marked 3 inline comments as done.
jdoerfert added a comment.

Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58091

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDecl.cpp
  clang/test/Analysis/retain-release.m
  clang/test/Sema/builtin-setjmp.c
  clang/test/Sema/implicit-builtin-decl.c

Index: clang/test/Sema/implicit-builtin-decl.c
===
--- clang/test/Sema/implicit-builtin-decl.c
+++ clang/test/Sema/implicit-builtin-decl.c
@@ -55,14 +55,17 @@
 
 void snprintf() { }
 
-// PR8316
-void longjmp(); // expected-warning{{declaration of built-in function 'longjmp' requires inclusion of the header }}
+// PR8316 & PR40692
+void longjmp(); // expected-warning{{declaration of built-in function 'longjmp' requires the definition of the 'jmp_buf' type, commonly proived in the header .}}
 
 extern float fmaxf(float, float);
 
 struct __jmp_buf_tag {};
-void sigsetjmp(struct __jmp_buf_tag[1], int); // expected-warning{{declaration of built-in function 'sigsetjmp' requires inclusion of the header }}
+void sigsetjmp(struct __jmp_buf_tag[1], int); // expected-warning{{declaration of built-in function 'sigsetjmp' requires the declaration of the 'jmp_buf' type, commonly proived in the header .}}
 
 // CHECK: FunctionDecl {{.*}}  col:6 sigsetjmp '
 // CHECK-NOT: FunctionDecl
 // CHECK: ReturnsTwiceAttr {{.*}} <{{.*}}> Implicit
+
+// PR40692
+void pthread_create(); // no warning expected
Index: clang/test/Sema/builtin-setjmp.c
===
--- /dev/null
+++ clang/test/Sema/builtin-setjmp.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify -DNO_JMP_BUF %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify %s
+
+#ifdef NO_JMP_BUF
+extern long setjmp(long *);   // expected-warning {{declaration of built-in function 'setjmp' requires the declaration of the 'jmp_buf' type, commonly proived in the header .}}
+#else
+typedef long jmp_buf;
+extern int setjmp(char);  // expected-warning@8 {{incompatible redeclaration of library function 'setjmp'}}
+  // expected-note@8{{'setjmp' is a builtin with type 'int (jmp_buf)' (aka 'int (long)')}}
+#endif
Index: clang/test/Analysis/retain-release.m
===
--- clang/test/Analysis/retain-release.m
+++ clang/test/Analysis/retain-release.m
@@ -2,7 +2,7 @@
 // RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10\
 // RUN: -analyzer-checker=core,osx.coreFoundation.CFRetainRelease\
 // RUN: -analyzer-checker=osx.cocoa.ClassRelease,osx.cocoa.RetainCount\
-// RUN: -analyzer-checker=debug.ExprInspection -fblocks -verify=expected,C %s\
+// RUN: -analyzer-checker=debug.ExprInspection -fblocks -verify %s\
 // RUN: -Wno-objc-root-class -analyzer-output=plist -o %t.objc.plist
 // RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10\
 // RUN: -analyzer-checker=core,osx.coreFoundation.CFRetainRelease\
@@ -1231,7 +1231,7 @@
 typedef unsigned long __darwin_pthread_key_t;
 typedef __darwin_pthread_key_t pthread_key_t;
 
-int pthread_create(pthread_t *, const pthread_attr_t *,  // C-warning{{declaration of built-in function 'pthread_create' requires inclusion of the header }}
+int pthread_create(pthread_t *, const pthread_attr_t *,
void *(*)(void *), void *);
 
 int pthread_setspecific(pthread_key_t key, const void *value);
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -1955,10 +1955,27 @@
   ASTContext::GetBuiltinTypeError Error;
   QualType R = Context.GetBuiltinType(ID, Error);
   if (Error) {
-if (ForRedeclaration)
-  Diag(Loc, diag::warn_implicit_decl_requires_sysheader)
-  << getHeaderName(Context.BuiltinInfo, ID, Error)
+if (!ForRedeclaration)
+  return nullptr;
+
+// If we have a builtin without an associated type we should not emit a
+// warning when we were not able to find a type for it.
+if (Error == ASTContext::GE_Missing_type)
+  return nullptr;
+
+// If we could not find a type for setjmp it is because the jmp_buf type was
+// not defined prior to the setjmp declaration.
+if (Error == ASTContext::GE_Missing_setjmp) {
+  Diag(Loc, diag::warn_implicit_decl_no_jmp_buf)
   << Context.BuiltinInfo.getName(ID);
+  return nullptr;
+}
+
+// Generally, we emit a warning that the declaration requires the
+// appropriate header.
+Diag(Loc, diag::warn_implicit_decl_requires_sysheader)
+<< getHeaderName(Context.BuiltinInfo, ID, Error)
+<< Context.BuiltinInfo.getName(ID);
 

Re: [PATCH] D56933: [Tooling][RFC] Introduce Stencil library to simplify source code generation in refactorings.

2019-02-25 Thread Yitzhak Mandelbaum via cfe-commits
We're working out the details, but the intent is that the
Tree-transformation library would support the implementation of
Transformer. That is, this library is targeted at a lower-level/more
advanced user than Transformer.  Currently, Transformer is implemented
directly on the clang AST API, but we should be able to simplify it by
using this API once its ready.   Ideally, we'll hide any transition from
the user.  Conversely, we plan to expose relevant features from this API in
Transformer.

Ilya, the author of that proposal, will be the primary reviewer of the
Transformer patches, so we will be sure to keep the two proposals in
sync/complementary.

On Mon, Feb 25, 2019 at 2:58 PM Roman Lebedev via Phabricator <
revi...@reviews.llvm.org> wrote:

> lebedev.ri added subscribers: ilya-biryukov, gribozavr, lebedev.ri.
> lebedev.ri added a comment.
>
> See also:
> https://lists.llvm.org/pipermail/cfe-dev/2019-February/061414.html
> How are these two RFC's/API's supposed to interact/coexist/etc?
>
>
> Repository:
>   rG LLVM Github Monorepo
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D56933/new/
>
> https://reviews.llvm.org/D56933
>
>
>
>


smime.p7s
Description: S/MIME Cryptographic Signature
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50488: [Analyzer] Checker for non-determinism caused by sorting of pointer-like elements

2019-02-25 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang added a comment.

In D50488#1407975 , @Szelethus wrote:

> But, as a work-in-progress alpha checker, the direction is set and looks 
> great. Please let @NoQ have the final say.


Thanks a lot @Szelethus! I will wait for @NoQ 's comments.


Repository:
  rC Clang

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

https://reviews.llvm.org/D50488



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


[PATCH] D50488: [Analyzer] Checker for non-determinism caused by sorting of pointer-like elements

2019-02-25 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang added a comment.

In D50488#1407884 , @Szelethus wrote:

> In D50488#1405094 , @mgrang wrote:
>
> > So I was able compile a couple of C++ code bases through csa-testbench. I 
> > built cppcheck and tinyxml2 without any problems. cppcheck has one 
> > invocation std::sort but the keys are not pointers whereas tinyxml2 does 
> > not use std::sort. I tried bitcoin, rtags, xerces but run into a lot of 
> > configure/build errors.
>
>
> Thats great. How about LLVM+Clang? That'll be a pain in the butt to analyze, 
> but is pretty great for testing. Also, did you clone rtags with the git 
> option `--recursive`?


LLVM does not directly use std::sort. It calls llvm::sort which in-turn call 
std::sort (but it does have std::stable_sort, etc). However, I run into a host 
of errors while building LLVM inside csa-testbench. Maybe, once this patch 
lands, I could use llvm as a bootstrap stage1 compiler with this checker 
enabled.

>>   Also, did you clone rtags with the git option `--recursive`?

Yes, I followed the build instructions from 
https://github.com/Andersbakken/rtags. But run into these errors:

  ./configure //this invokes "cmake" "." -DCMAKE_EXPORT_COMPILE_COMMANDS=1)
The compiler uses a libstdc++ without c++11 regex support.
  
  ./configure --clang-cxxflags '-std=c++11' //this invokes "cmake" "." 
-DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DLIBCLANG_CXXFLAGS="-std=c++11"
It's likely that the include file  could not be found!

I tried installing libclang-dev, libclang-3.8-dev, libclang-6.0-dev as well as 
adding -I include paths for clang-c to configure but I am not able to go past 
the above error.


Repository:
  rC Clang

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

https://reviews.llvm.org/D50488



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


[PATCH] D50488: [Analyzer] Checker for non-determinism caused by sorting of pointer-like elements

2019-02-25 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang marked an inline comment as done.
mgrang added inline comments.



Comment at: include/clang/StaticAnalyzer/Checkers/Checkers.td:97
 
+def NonDeterminismAlpha : Package<"nondeterminism">, ParentPackage;
+

Szelethus wrote:
> Hmmm, okay, so your checker ks C++ exclusive I belive? How about making this 
> checker reside in `alpha.cplusplus`? Rgard this one as more of a question.
This particular checker is C++ exclusive. The reason behind creating a new 
non-determinism category was so that we could add more language-agnostic 
checkers for non-determinism in future.


Repository:
  rC Clang

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

https://reviews.llvm.org/D50488



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


[PATCH] D56933: [Tooling][RFC] Introduce Stencil library to simplify source code generation in refactorings.

2019-02-25 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added subscribers: ilya-biryukov, gribozavr, lebedev.ri.
lebedev.ri added a comment.

See also: https://lists.llvm.org/pipermail/cfe-dev/2019-February/061414.html
How are these two RFC's/API's supposed to interact/coexist/etc?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D56933



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


[PATCH] D50488: [Analyzer] Checker for non-determinism caused by sorting of pointer-like elements

2019-02-25 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang updated this revision to Diff 188232.
mgrang set the repository for this revision to rC Clang.

Repository:
  rC Clang

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

https://reviews.llvm.org/D50488

Files:
  docs/analyzer/checkers.rst
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/PointerSortingChecker.cpp
  test/Analysis/ptr-sort.cpp
  www/analyzer/alpha_checks.html

Index: www/analyzer/alpha_checks.html
===
--- www/analyzer/alpha_checks.html
+++ www/analyzer/alpha_checks.html
@@ -33,6 +33,7 @@
 OS X Alpha Checkers
 Security Alpha Checkers
 Unix Alpha Checkers
+Non-determinism Alpha Checkers
 
 
 
@@ -1174,6 +1175,28 @@
 
 
 
+
+Non-determinism Alpha Checkers
+
+
+Name, DescriptionExample
+
+
+
+alpha.nondeterminism.PointerSorting
+(C++)
+Check for non-determinism caused by sorting of pointers.
+
+
+// C++
+void test() {
+ int a = 1, b = 2;
+ std::vector V = {, };
+ std::sort(V.begin(), V.end()); // warn
+}
+
+
+
  
  
 
Index: test/Analysis/ptr-sort.cpp
===
--- /dev/null
+++ test/Analysis/ptr-sort.cpp
@@ -0,0 +1,57 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.nondeterminism.PointerSorting %s -analyzer-output=text -verify
+
+#include "Inputs/system-header-simulator-cxx.h"
+namespace std {
+  template
+  bool is_sorted(ForwardIt first, ForwardIt last);
+
+  template 
+  void nth_element(RandomIt first, RandomIt nth, RandomIt last);
+
+  template
+  void partial_sort(RandomIt first, RandomIt middle, RandomIt last);
+
+  template
+  void sort (RandomIt first, RandomIt last);
+
+  template
+  void stable_sort(RandomIt first, RandomIt last);
+
+  template
+  BidirIt partition(BidirIt first, BidirIt last, UnaryPredicate p);
+
+  template
+  BidirIt stable_partition(BidirIt first, BidirIt last, UnaryPredicate p);
+}
+
+bool f (int x) { return true; }
+bool g (int *x) { return true; }
+
+void PointerSorting() {
+  int a = 1, b = 2, c = 3;
+  std::vector V1 = {a, b};
+  std::vector V2 = {, };
+
+  std::is_sorted(V1.begin(), V1.end());// no-warning
+  std::nth_element(V1.begin(), V1.begin() + 1, V1.end());  // no-warning
+  std::partial_sort(V1.begin(), V1.begin() + 1, V1.end()); // no-warning
+  std::sort(V1.begin(), V1.end()); // no-warning
+  std::stable_sort(V1.begin(), V1.end());  // no-warning
+  std::partition(V1.begin(), V1.end(), f); // no-warning
+  std::stable_partition(V1.begin(), V1.end(), g);  // no-warning
+
+  std::is_sorted(V2.begin(), V2.end()); // expected-warning {{Sorting pointer-like elements can result in non-deterministic ordering}} [alpha.nondeterminism.PointerSorting]
+  // expected-note@-1 {{Sorting pointer-like elements can result in non-deterministic ordering}} [alpha.nondeterminism.PointerSorting]
+  std::nth_element(V2.begin(), V2.begin() + 1, V2.end()); // expected-warning {{Sorting pointer-like elements can result in non-deterministic ordering}} [alpha.nondeterminism.PointerSorting]
+  // expected-note@-1 {{Sorting pointer-like elements can result in non-deterministic ordering}} [alpha.nondeterminism.PointerSorting]
+  std::partial_sort(V2.begin(), V2.begin() + 1, V2.end()); // expected-warning {{Sorting pointer-like elements can result in non-deterministic ordering}} [alpha.nondeterminism.PointerSorting]
+  // expected-note@-1 {{Sorting pointer-like elements can result in non-deterministic ordering}} [alpha.nondeterminism.PointerSorting]
+  std::sort(V2.begin(), V2.end()); // expected-warning {{Sorting pointer-like elements can result in non-deterministic ordering}} [alpha.nondeterminism.PointerSorting]
+  // expected-note@-1 {{Sorting pointer-like elements can result in non-deterministic ordering}} [alpha.nondeterminism.PointerSorting]
+  std::stable_sort(V2.begin(), V2.end()); // expected-warning {{Sorting pointer-like elements can result in non-deterministic ordering}} [alpha.nondeterminism.PointerSorting]
+  // expected-note@-1 {{Sorting pointer-like elements can result in non-deterministic ordering}} [alpha.nondeterminism.PointerSorting]
+  std::partition(V2.begin(), V2.end(), f); // expected-warning {{Sorting pointer-like elements can result in non-deterministic ordering}} [alpha.nondeterminism.PointerSorting]
+  // expected-note@-1 {{Sorting pointer-like elements can result in non-deterministic ordering}} [alpha.nondeterminism.PointerSorting]
+  std::stable_partition(V2.begin(), V2.end(), g); // expected-warning {{Sorting pointer-like elements can result in non-deterministic ordering}} [alpha.nondeterminism.PointerSorting]
+  // expected-note@-1 {{Sorting pointer-like elements can result in non-deterministic ordering}} [alpha.nondeterminism.PointerSorting]
+}
Index: lib/StaticAnalyzer/Checkers/PointerSortingChecker.cpp

r354812 - Revert "Make static counters in ASTContext non-static."

2019-02-25 Thread Vlad Tsyrklevich via cfe-commits
Author: vlad.tsyrklevich
Date: Mon Feb 25 11:53:13 2019
New Revision: 354812

URL: http://llvm.org/viewvc/llvm-project?rev=354812=rev
Log:
Revert "Make static counters in ASTContext non-static."

This reverts commit r354795, I suspect it is causing test failures
on MSan sanitizer bots.

Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=354812=354811=354812=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Mon Feb 25 11:53:13 2019
@@ -2809,46 +2809,46 @@ public:
   
//======//
 
   /// The number of implicitly-declared default constructors.
-  unsigned NumImplicitDefaultConstructors;
+  static unsigned NumImplicitDefaultConstructors;
 
   /// The number of implicitly-declared default constructors for
   /// which declarations were built.
-  unsigned NumImplicitDefaultConstructorsDeclared;
+  static unsigned NumImplicitDefaultConstructorsDeclared;
 
   /// The number of implicitly-declared copy constructors.
-  unsigned NumImplicitCopyConstructors;
+  static unsigned NumImplicitCopyConstructors;
 
   /// The number of implicitly-declared copy constructors for
   /// which declarations were built.
-  unsigned NumImplicitCopyConstructorsDeclared;
+  static unsigned NumImplicitCopyConstructorsDeclared;
 
   /// The number of implicitly-declared move constructors.
-  unsigned NumImplicitMoveConstructors;
+  static unsigned NumImplicitMoveConstructors;
 
   /// The number of implicitly-declared move constructors for
   /// which declarations were built.
-  unsigned NumImplicitMoveConstructorsDeclared;
+  static unsigned NumImplicitMoveConstructorsDeclared;
 
   /// The number of implicitly-declared copy assignment operators.
-  unsigned NumImplicitCopyAssignmentOperators;
+  static unsigned NumImplicitCopyAssignmentOperators;
 
   /// The number of implicitly-declared copy assignment operators for
   /// which declarations were built.
-  unsigned NumImplicitCopyAssignmentOperatorsDeclared;
+  static unsigned NumImplicitCopyAssignmentOperatorsDeclared;
 
   /// The number of implicitly-declared move assignment operators.
-  unsigned NumImplicitMoveAssignmentOperators;
+  static unsigned NumImplicitMoveAssignmentOperators;
 
   /// The number of implicitly-declared move assignment operators for
   /// which declarations were built.
-  unsigned NumImplicitMoveAssignmentOperatorsDeclared;
+  static unsigned NumImplicitMoveAssignmentOperatorsDeclared;
 
   /// The number of implicitly-declared destructors.
-  unsigned NumImplicitDestructors;
+  static unsigned NumImplicitDestructors;
 
   /// The number of implicitly-declared destructors for which
   /// declarations were built.
-  unsigned NumImplicitDestructorsDeclared;
+  static unsigned NumImplicitDestructorsDeclared;
 
 public:
   /// Initialize built-in types.

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=354812=354811=354812=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Mon Feb 25 11:53:13 2019
@@ -94,6 +94,19 @@
 
 using namespace clang;
 
+unsigned ASTContext::NumImplicitDefaultConstructors;
+unsigned ASTContext::NumImplicitDefaultConstructorsDeclared;
+unsigned ASTContext::NumImplicitCopyConstructors;
+unsigned ASTContext::NumImplicitCopyConstructorsDeclared;
+unsigned ASTContext::NumImplicitMoveConstructors;
+unsigned ASTContext::NumImplicitMoveConstructorsDeclared;
+unsigned ASTContext::NumImplicitCopyAssignmentOperators;
+unsigned ASTContext::NumImplicitCopyAssignmentOperatorsDeclared;
+unsigned ASTContext::NumImplicitMoveAssignmentOperators;
+unsigned ASTContext::NumImplicitMoveAssignmentOperatorsDeclared;
+unsigned ASTContext::NumImplicitDestructors;
+unsigned ASTContext::NumImplicitDestructorsDeclared;
+
 enum FloatingRank {
   Float16Rank, HalfRank, FloatRank, DoubleRank, LongDoubleRank, Float128Rank
 };

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=354812=354811=354812=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Mon Feb 25 11:53:13 2019
@@ -7971,14 +7971,14 @@ void Sema::ActOnFinishCXXMemberSpecifica
 /// definition of the class is complete.
 void Sema::AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl) {
   if (ClassDecl->needsImplicitDefaultConstructor()) {
-++getASTContext().NumImplicitDefaultConstructors;
+

[PATCH] D58556: [LibTooling] Add "smart" retrieval of AST-node source to FixIt library

2019-02-25 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Thanks, the APIs totally make sense. And seem to fit into the other functions 
we have in `FixIt.h`, although the name of the file is somewhat misleading.
Mostly comments about naming and one comment about the necessity of using 
matchers from my side.




Comment at: clang/include/clang/Tooling/FixIt.h:60
+// future to include more associated text (like comments).
+CharSourceRange getSourceRangeAuto(const Stmt , ASTContext );
+

Do you have alternative names in mind? It would be nice to (1) not mention the 
SourceRange now that we return CharSourceRange, (2) change "auto" to something 
more descriptive.

Was thinking about `getNodeRange()` or `getSpannedRange()`, but that completely 
misses the "auto" part (maybe it's fine, though).
WDYT? Maybe other ideas?



Comment at: clang/include/clang/Tooling/FixIt.h:73
+// context. In contrast with \p getText(), this function selects a source range
+// "automatically", extracting text that a reader might intuitively associate
+// with a node.  Currently, only specialized for \p clang::Stmt, where it will

What are other tricky cases you have in mind for the future?



Comment at: clang/include/clang/Tooling/FixIt.h:77
+template 
+StringRef getTextAuto(const T , ASTContext ) {
+  return internal::getText(getSourceRangeAuto(Node, Context), Context);

Could you add an example of the API use here? The anticipated use-case are 
removing or textually replacing a node, right?



Comment at: clang/lib/Tooling/FixIt.cpp:52
+
+  auto NotCondition = unless(hasCondition(equalsNode()));
+  auto Standalone =

Do you expect this function to be on the hot path?
If so, I'd advice against using the matchers here. They do add enough overhead 
to be avoided in hot functions.

I guess the problem is that we can't get a hold of the parent node with using 
the matchers, right?
Not sure if there's an easy way out of it in that case.


Repository:
  rC Clang

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

https://reviews.llvm.org/D58556



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


[PATCH] D58541: [CodeComplete] Propagate preferred type for function arguments in more cases

2019-02-25 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clang/lib/Sema/SemaCodeComplete.cpp:494
   default:
 assert(false && "unhnalded unary op");
 return QualType();

xbolva00 wrote:
> Typo?
Fixed it. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58541



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


[PATCH] D58541: [CodeComplete] Propagate preferred type for function arguments in more cases

2019-02-25 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 188226.
ilya-biryukov marked 2 inline comments as done.
ilya-biryukov added a comment.

- Fix a typo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58541

Files:
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/unittests/Sema/CodeCompleteTest.cpp

Index: clang/unittests/Sema/CodeCompleteTest.cpp
===
--- clang/unittests/Sema/CodeCompleteTest.cpp
+++ clang/unittests/Sema/CodeCompleteTest.cpp
@@ -442,4 +442,41 @@
   )cpp";
   EXPECT_THAT(collectPreferredTypes(Code), Each("const int *"));
 }
+
+TEST(PreferredTypeTest, FunctionArguments) {
+  StringRef Code = R"cpp(
+void foo(const int*);
+
+void bar(const int*);
+void bar(const int*, int b);
+
+struct vector {
+  const int *data();
+};
+void test() {
+  foo(^(^(^(^vec^tor^().^da^ta^();
+  bar(^(^(^(^vec^tor^().^da^ta^();
+}
+  )cpp";
+  EXPECT_THAT(collectPreferredTypes(Code), Each("const int *"));
+
+  Code = R"cpp(
+void bar(int, volatile double *);
+void bar(int, volatile double *, int, int);
+
+struct vector {
+  double *data();
+};
+
+struct class_members {
+  void bar(int, volatile double *);
+  void bar(int, volatile double *, int, int);
+};
+void test() {
+  bar(10, ^(^(^(^vec^tor^().^da^ta^();
+  class_members().bar(10, ^(^(^(^vec^tor^().^da^ta^();
+}
+  )cpp";
+  EXPECT_THAT(collectPreferredTypes(Code), Each("volatile double *"));
+}
 } // namespace
Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -350,13 +350,16 @@
 void PreferredTypeBuilder::enterReturn(Sema , SourceLocation Tok) {
   if (isa(S.CurContext)) {
 if (sema::BlockScopeInfo *BSI = S.getCurBlock()) {
+  ComputeType = nullptr;
   Type = BSI->ReturnType;
   ExpectedLoc = Tok;
 }
   } else if (const auto *Function = dyn_cast(S.CurContext)) {
+ComputeType = nullptr;
 Type = Function->getReturnType();
 ExpectedLoc = Tok;
   } else if (const auto *Method = dyn_cast(S.CurContext)) {
+ComputeType = nullptr;
 Type = Method->getReturnType();
 ExpectedLoc = Tok;
   }
@@ -364,10 +367,18 @@
 
 void PreferredTypeBuilder::enterVariableInit(SourceLocation Tok, Decl *D) {
   auto *VD = llvm::dyn_cast_or_null(D);
+  ComputeType = nullptr;
   Type = VD ? VD->getType() : QualType();
   ExpectedLoc = Tok;
 }
 
+void PreferredTypeBuilder::enterFunctionArgument(
+SourceLocation Tok, llvm::function_ref ComputeType) {
+  this->ComputeType = ComputeType;
+  Type = QualType();
+  ExpectedLoc = Tok;
+}
+
 void PreferredTypeBuilder::enterParenExpr(SourceLocation Tok,
   SourceLocation LParLoc) {
   // expected type for parenthesized expression does not change.
@@ -480,13 +491,14 @@
   case tok::kw___imag:
 return QualType();
   default:
-assert(false && "unhnalded unary op");
+assert(false && "unhandled unary op");
 return QualType();
   }
 }
 
 void PreferredTypeBuilder::enterBinary(Sema , SourceLocation Tok, Expr *LHS,
tok::TokenKind Op) {
+  ComputeType = nullptr;
   Type = getPreferredTypeOfBinaryRHS(S, LHS, Op);
   ExpectedLoc = Tok;
 }
@@ -495,30 +507,38 @@
   Expr *Base) {
   if (!Base)
 return;
-  Type = this->get(Base->getBeginLoc());
+  // Do we have expected type for Base?
+  if (ExpectedLoc != Base->getBeginLoc())
+return;
+  // Keep the expected type, only update the location.
   ExpectedLoc = Tok;
+  return;
 }
 
 void PreferredTypeBuilder::enterUnary(Sema , SourceLocation Tok,
   tok::TokenKind OpKind,
   SourceLocation OpLoc) {
+  ComputeType = nullptr;
   Type = getPreferredTypeOfUnaryArg(S, this->get(OpLoc), OpKind);
   ExpectedLoc = Tok;
 }
 
 void PreferredTypeBuilder::enterSubscript(Sema , SourceLocation Tok,
   Expr *LHS) {
+  ComputeType = nullptr;
   Type = S.getASTContext().IntTy;
   ExpectedLoc = Tok;
 }
 
 void PreferredTypeBuilder::enterTypeCast(SourceLocation Tok,
  QualType CastType) {
+  ComputeType = nullptr;
   Type = !CastType.isNull() ? CastType.getCanonicalType() : QualType();
   ExpectedLoc = Tok;
 }
 
 void PreferredTypeBuilder::enterCondition(Sema , SourceLocation Tok) {
+  ComputeType = nullptr;
   Type = S.getASTContext().BoolTy;
   ExpectedLoc = Tok;
 }
Index: 

[PATCH] D58541: [CodeComplete] Propagate preferred type for function arguments in more cases

2019-02-25 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clang/include/clang/Sema/Sema.h:294
+  /// function_ref, clients should make sure all calls to get() with the same
+  /// location happen while function_ref is alive.
+  void enterFunctionArgument(SourceLocation Tok,

kadircet wrote:
> Is it only to avoid copy costs?
Using `std::function` won't help much, all functions we pass here actually 
capture local variables by reference.



Comment at: clang/lib/Parse/ParseDeclCXX.cpp:3490
-  CalledSignatureHelp = true;
-  Actions.CodeCompleteExpression(getCurScope(), PreferredType);
 })) {

kadircet wrote:
> IIUC, deleting this call is safe, since it is going to be called in 
> `ParseAssignmentExpression`. Could you add a comment stating that?(same for 
> other deleted call sites of this function.)
Exactly! I changed the description of the change instead of adding a comment.
In the new version `ParseExpressionList` is not responsible for the code 
completion anymore and leaving the comment merely for historical reasons does 
not look appealing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58541



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


[PATCH] D58541: [CodeComplete] Propagate preferred type for function arguments in more cases

2019-02-25 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 188225.
ilya-biryukov marked 3 inline comments as done.
ilya-biryukov added a comment.

- Check in the middle and at the end of identifiers.
- Add a test for the second parameter and a class member function


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58541

Files:
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/unittests/Sema/CodeCompleteTest.cpp

Index: clang/unittests/Sema/CodeCompleteTest.cpp
===
--- clang/unittests/Sema/CodeCompleteTest.cpp
+++ clang/unittests/Sema/CodeCompleteTest.cpp
@@ -442,4 +442,41 @@
   )cpp";
   EXPECT_THAT(collectPreferredTypes(Code), Each("const int *"));
 }
+
+TEST(PreferredTypeTest, FunctionArguments) {
+  StringRef Code = R"cpp(
+void foo(const int*);
+
+void bar(const int*);
+void bar(const int*, int b);
+
+struct vector {
+  const int *data();
+};
+void test() {
+  foo(^(^(^(^vec^tor^().^da^ta^();
+  bar(^(^(^(^vec^tor^().^da^ta^();
+}
+  )cpp";
+  EXPECT_THAT(collectPreferredTypes(Code), Each("const int *"));
+
+  Code = R"cpp(
+void bar(int, volatile double *);
+void bar(int, volatile double *, int, int);
+
+struct vector {
+  double *data();
+};
+
+struct class_members {
+  void bar(int, volatile double *);
+  void bar(int, volatile double *, int, int);
+};
+void test() {
+  bar(10, ^(^(^(^vec^tor^().^da^ta^();
+  class_members().bar(10, ^(^(^(^vec^tor^().^da^ta^();
+}
+  )cpp";
+  EXPECT_THAT(collectPreferredTypes(Code), Each("volatile double *"));
+}
 } // namespace
Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -350,13 +350,16 @@
 void PreferredTypeBuilder::enterReturn(Sema , SourceLocation Tok) {
   if (isa(S.CurContext)) {
 if (sema::BlockScopeInfo *BSI = S.getCurBlock()) {
+  ComputeType = nullptr;
   Type = BSI->ReturnType;
   ExpectedLoc = Tok;
 }
   } else if (const auto *Function = dyn_cast(S.CurContext)) {
+ComputeType = nullptr;
 Type = Function->getReturnType();
 ExpectedLoc = Tok;
   } else if (const auto *Method = dyn_cast(S.CurContext)) {
+ComputeType = nullptr;
 Type = Method->getReturnType();
 ExpectedLoc = Tok;
   }
@@ -364,10 +367,18 @@
 
 void PreferredTypeBuilder::enterVariableInit(SourceLocation Tok, Decl *D) {
   auto *VD = llvm::dyn_cast_or_null(D);
+  ComputeType = nullptr;
   Type = VD ? VD->getType() : QualType();
   ExpectedLoc = Tok;
 }
 
+void PreferredTypeBuilder::enterFunctionArgument(
+SourceLocation Tok, llvm::function_ref ComputeType) {
+  this->ComputeType = ComputeType;
+  Type = QualType();
+  ExpectedLoc = Tok;
+}
+
 void PreferredTypeBuilder::enterParenExpr(SourceLocation Tok,
   SourceLocation LParLoc) {
   // expected type for parenthesized expression does not change.
@@ -487,6 +498,7 @@
 
 void PreferredTypeBuilder::enterBinary(Sema , SourceLocation Tok, Expr *LHS,
tok::TokenKind Op) {
+  ComputeType = nullptr;
   Type = getPreferredTypeOfBinaryRHS(S, LHS, Op);
   ExpectedLoc = Tok;
 }
@@ -495,30 +507,38 @@
   Expr *Base) {
   if (!Base)
 return;
-  Type = this->get(Base->getBeginLoc());
+  // Do we have expected type for Base?
+  if (ExpectedLoc != Base->getBeginLoc())
+return;
+  // Keep the expected type, only update the location.
   ExpectedLoc = Tok;
+  return;
 }
 
 void PreferredTypeBuilder::enterUnary(Sema , SourceLocation Tok,
   tok::TokenKind OpKind,
   SourceLocation OpLoc) {
+  ComputeType = nullptr;
   Type = getPreferredTypeOfUnaryArg(S, this->get(OpLoc), OpKind);
   ExpectedLoc = Tok;
 }
 
 void PreferredTypeBuilder::enterSubscript(Sema , SourceLocation Tok,
   Expr *LHS) {
+  ComputeType = nullptr;
   Type = S.getASTContext().IntTy;
   ExpectedLoc = Tok;
 }
 
 void PreferredTypeBuilder::enterTypeCast(SourceLocation Tok,
  QualType CastType) {
+  ComputeType = nullptr;
   Type = !CastType.isNull() ? CastType.getCanonicalType() : QualType();
   ExpectedLoc = Tok;
 }
 
 void PreferredTypeBuilder::enterCondition(Sema , SourceLocation Tok) {
+  ComputeType = nullptr;
   Type = S.getASTContext().BoolTy;
   ExpectedLoc = Tok;
 }
Index: clang/lib/Parse/ParseOpenMP.cpp

[PATCH] D58292: Add support for importing ChooseExpr AST nodes.

2019-02-25 Thread Tom Roeder via Phabricator via cfe-commits
tmroeder updated this revision to Diff 188224.
tmroeder added a comment.

Changed to use llvm::find.

Given the disagreement about the destructuring assignment, I didn't make that 
change.


Repository:
  rC Clang

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

https://reviews.llvm.org/D58292

Files:
  docs/LibASTMatchersReference.html
  include/clang/ASTMatchers/ASTMatchers.h
  lib/AST/ASTImporter.cpp
  lib/ASTMatchers/ASTMatchersInternal.cpp
  lib/ASTMatchers/Dynamic/Registry.cpp
  test/ASTMerge/choose-expr/Inputs/choose.c
  test/ASTMerge/choose-expr/test.c
  unittests/AST/ASTImporterTest.cpp
  unittests/ASTMatchers/ASTMatchersNodeTest.cpp

Index: unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -754,6 +754,11 @@
   EXPECT_TRUE(matches("int* i = nullptr;", cxxNullPtrLiteralExpr()));
 }
 
+TEST(Matcher, ChooseExpr) {
+  EXPECT_TRUE(matchesC("void f() { (void)__builtin_choose_expr(1, 2, 3); }",
+   chooseExpr()));
+}
+
 TEST(Matcher, GNUNullExpr) {
   EXPECT_TRUE(matches("int* i = __null;", gnuNullExpr()));
 }
Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -563,6 +563,34 @@
   stringLiteral(hasType(asString("const char [7]"));
 }
 
+TEST_P(ImportExpr, ImportChooseExpr) {
+  MatchVerifier Verifier;
+
+  // This case tests C code that is not condition-dependent and has a true
+  // condition.
+  testImport(
+"void declToImport() { (void)__builtin_choose_expr(1, 2, 3); }",
+Lang_C, "", Lang_C, Verifier,
+functionDecl(hasDescendant(chooseExpr(;
+
+  ArgVector Args = getExtraArgs();
+  BindableMatcher Matcher =
+  functionTemplateDecl(hasDescendant(chooseExpr()));
+
+  // Don't try to match the template contents if template parsing is delayed.
+  if (llvm::find(Args, "-fdelayed-template-parsing") != Args.end()) {
+Matcher = functionTemplateDecl();
+  }
+
+  // Make sure that uses of (void)__builtin_choose_expr with dependent types in
+  // the condition are handled properly. This test triggers an assertion if the
+  // ASTImporter incorrectly tries to access isConditionTrue() when
+  // isConditionDependent() is true.
+  testImport("template void declToImport() { "
+ "(void)__builtin_choose_expr(N, 1, 0); }",
+ Lang_CXX, "", Lang_CXX, Verifier, Matcher);
+}
+
 TEST_P(ImportExpr, ImportGNUNullExpr) {
   MatchVerifier Verifier;
   testImport(
@@ -1312,6 +1340,27 @@
   ASSERT_EQ(ToTemplated1, ToTemplated);
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase, ImportChooseExpr) {
+  // This tests the import of isConditionTrue directly to make sure the importer
+  // gets it right.
+  Decl *From, *To;
+  std::tie(From, To) = getImportedDecl(
+"void declToImport() { (void)__builtin_choose_expr(1, 0, 1); }",
+Lang_C, "", Lang_C);
+
+  auto ToResults = match(chooseExpr().bind("choose"), To->getASTContext());
+  auto FromResults = match(chooseExpr().bind("choose"), From->getASTContext());
+
+  const ChooseExpr *FromChooseExpr =
+  selectFirst("choose", FromResults);
+  ASSERT_TRUE(FromChooseExpr);
+
+  const ChooseExpr *ToChooseExpr = selectFirst("choose", ToResults);
+  ASSERT_TRUE(ToChooseExpr);
+
+  EXPECT_EQ(FromChooseExpr->isConditionTrue(), ToChooseExpr->isConditionTrue());
+}
+
 TEST_P(ASTImporterOptionSpecificTestBase,
ImportFunctionWithBackReferringParameter) {
   Decl *From, *To;
Index: test/ASTMerge/choose-expr/test.c
===
--- /dev/null
+++ test/ASTMerge/choose-expr/test.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -std=c11 -emit-pch -o %t.ast %S/Inputs/choose.c
+// RUN: %clang_cc1 -std=c11 -ast-merge %t.ast -fsyntax-only -verify %s
+// expected-no-diagnostics
+
Index: test/ASTMerge/choose-expr/Inputs/choose.c
===
--- /dev/null
+++ test/ASTMerge/choose-expr/Inputs/choose.c
@@ -0,0 +1,2 @@
+_Static_assert(__builtin_choose_expr(1, 1, 0), "Incorrect semantics of __builtin_choose_expr");
+_Static_assert(__builtin_choose_expr(0, 0, 1), "Incorrect semantics of __builtin_choose_expr");
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -147,6 +147,7 @@
   REGISTER_MATCHER(caseStmt);
   REGISTER_MATCHER(castExpr);
   REGISTER_MATCHER(characterLiteral);
+  REGISTER_MATCHER(chooseExpr);
   REGISTER_MATCHER(classTemplateDecl);
   REGISTER_MATCHER(classTemplateSpecializationDecl);
   REGISTER_MATCHER(complexType);
Index: lib/ASTMatchers/ASTMatchersInternal.cpp
===
--- 

[PATCH] D57892: [analyzer] Fix macro printer crash when macro comes from another translation unit

2019-02-25 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

Whoops, incorrect commit title and description. Anyways, the committed code and 
the revision number is OK...


Repository:
  rL LLVM

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

https://reviews.llvm.org/D57892



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


[PATCH] D57892: [analyzer] Fix macro printer crash when macro comes from another translation unit

2019-02-25 Thread Kristóf Umann via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354806: [analyzer] Fix infinite recursion in printing macros 
(authored by Szelethus, committed by ).
Herald added subscribers: llvm-commits, Charusso.
Herald added a project: LLVM.

Changed prior to commit:
  https://reviews.llvm.org/D57892?vs=185758=188219#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D57892

Files:
  cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp


Index: cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
@@ -842,6 +842,9 @@
 
   MacroNameAndArgs Info = getMacroNameAndArgs(SM.getExpansionLoc(MacroLoc), 
PP);
 
+  if (!Info.MI)
+return Info.Name;
+
   // Manually expand its arguments from the previous macro.
   Info.Args.expandFromPrevMacro(PrevArgs);
 
@@ -936,7 +939,14 @@
   assert(II && "Failed to acquire the IndetifierInfo for the macro!");
 
   const MacroInfo *MI = getMacroInfoForLocation(PP, SM, II, ExpanLoc);
-  assert(MI && "The macro must've been defined at it's expansion location!");
+  // assert(MI && "The macro must've been defined at it's expansion 
location!");
+  //
+  // We should always be able to obtain the MacroInfo in a given TU, but if
+  // we're running the analyzer with CTU, the Preprocessor won't contain the
+  // directive history (or anything for that matter) from another TU.
+  // TODO: assert when we're not running with CTU.
+  if (!MI)
+return { MacroName, MI, {} };
 
   // Acquire the macro's arguments.
   //


Index: cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
@@ -842,6 +842,9 @@
 
   MacroNameAndArgs Info = getMacroNameAndArgs(SM.getExpansionLoc(MacroLoc), PP);
 
+  if (!Info.MI)
+return Info.Name;
+
   // Manually expand its arguments from the previous macro.
   Info.Args.expandFromPrevMacro(PrevArgs);
 
@@ -936,7 +939,14 @@
   assert(II && "Failed to acquire the IndetifierInfo for the macro!");
 
   const MacroInfo *MI = getMacroInfoForLocation(PP, SM, II, ExpanLoc);
-  assert(MI && "The macro must've been defined at it's expansion location!");
+  // assert(MI && "The macro must've been defined at it's expansion location!");
+  //
+  // We should always be able to obtain the MacroInfo in a given TU, but if
+  // we're running the analyzer with CTU, the Preprocessor won't contain the
+  // directive history (or anything for that matter) from another TU.
+  // TODO: assert when we're not running with CTU.
+  if (!MI)
+return { MacroName, MI, {} };
 
   // Acquire the macro's arguments.
   //
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r354806 - [analyzer] Fix infinite recursion in printing macros

2019-02-25 Thread Kristof Umann via cfe-commits
Author: szelethus
Date: Mon Feb 25 10:49:42 2019
New Revision: 354806

URL: http://llvm.org/viewvc/llvm-project?rev=354806=rev
Log:
[analyzer] Fix infinite recursion in printing macros

#define f(y) x
#define x f(x)
int main() { x; }

This example results a compilation error since "x" in the first line was not
defined earlier. However, the macro expression printer goes to an infinite
recursion on this example.

Patch by Tibor Brunner!

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp?rev=354806=354805=354806=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp Mon Feb 25 10:49:42 
2019
@@ -842,6 +842,9 @@ static std::string getMacroNameAndPrintE
 
   MacroNameAndArgs Info = getMacroNameAndArgs(SM.getExpansionLoc(MacroLoc), 
PP);
 
+  if (!Info.MI)
+return Info.Name;
+
   // Manually expand its arguments from the previous macro.
   Info.Args.expandFromPrevMacro(PrevArgs);
 
@@ -936,7 +939,14 @@ static MacroNameAndArgs getMacroNameAndA
   assert(II && "Failed to acquire the IndetifierInfo for the macro!");
 
   const MacroInfo *MI = getMacroInfoForLocation(PP, SM, II, ExpanLoc);
-  assert(MI && "The macro must've been defined at it's expansion location!");
+  // assert(MI && "The macro must've been defined at it's expansion 
location!");
+  //
+  // We should always be able to obtain the MacroInfo in a given TU, but if
+  // we're running the analyzer with CTU, the Preprocessor won't contain the
+  // directive history (or anything for that matter) from another TU.
+  // TODO: assert when we're not running with CTU.
+  if (!MI)
+return { MacroName, MI, {} };
 
   // Acquire the macro's arguments.
   //


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


[PATCH] D58638: [OpenMP 5.0] Parsing/sema support for from clause with mapper modifier

2019-02-25 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


Repository:
  rC Clang

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

https://reviews.llvm.org/D58638



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


[PATCH] D58638: [OpenMP 5.0] Parsing/sema support for from clause with mapper modifier

2019-02-25 Thread Lingda Li via Phabricator via cfe-commits
lildmh created this revision.
lildmh added reviewers: ABataev, hfinkel, Meinersbur, kkwli0.
lildmh added a project: OpenMP.
Herald added subscribers: cfe-commits, jdoerfert, guansong.
Herald added a project: clang.

This patch implements the parsing and sema support for OpenMP from clause with 
potential user-defined mappers attached. User defined mapper is a new feature 
in OpenMP 5.0. A from clause can have an explicit or implicit associated 
mapper, which instructs the compiler to generate and use customized mapping 
functions. An example is shown below:

  struct S { int len; int *d; };
  #pragma omp declare mapper(id: struct S s) map(s, s.d[0:s.len])
  struct S ss;
  #pragma omp target update from(mapper(id): ss) // use the mapper with name 
'id' to map ss from device


Repository:
  rC Clang

https://reviews.llvm.org/D58638

Files:
  include/clang/AST/OpenMPClause.h
  include/clang/Basic/OpenMPKinds.def
  include/clang/Basic/OpenMPKinds.h
  include/clang/Sema/Sema.h
  lib/AST/OpenMPClause.cpp
  lib/Basic/OpenMPKinds.cpp
  lib/Parse/ParseOpenMP.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTWriter.cpp
  test/OpenMP/declare_mapper_ast_print.c
  test/OpenMP/declare_mapper_ast_print.cpp
  test/OpenMP/declare_mapper_codegen.cpp
  test/OpenMP/declare_mapper_messages.c
  test/OpenMP/declare_mapper_messages.cpp

Index: test/OpenMP/declare_mapper_messages.cpp
===
--- test/OpenMP/declare_mapper_messages.cpp
+++ test/OpenMP/declare_mapper_messages.cpp
@@ -99,6 +99,19 @@
 #pragma omp target update to(mapper(aa) a:vv)   // expected-warning {{missing ':' after ) - ignoring}}
 #pragma omp target update to(mapper(aa):vv)
 #pragma omp target update to(mapper(N1::stack::id) :vv)
+
+#pragma omp target update from(mapper)  // expected-error {{expected '(' after 'mapper'}} expected-error {{expected expression}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+#pragma omp target update from(mapper() // expected-error {{illegal OpenMP user-defined mapper identifier}} expected-error {{expected expression}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+#pragma omp target update from(mapper:vv)   // expected-error {{expected '(' after 'mapper'}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+#pragma omp target update from(mapper(:vv)  // expected-error {{illegal OpenMP user-defined mapper identifier}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+#pragma omp target update from(mapper(aa :vv)   // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+#pragma omp target update from(mapper(N2:: :vv) // expected-error {{use of undeclared identifier 'N2'}} expected-error {{illegal OpenMP user-defined mapper identifier}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+#pragma omp target update from(mapper(N1:: :vv) // expected-error {{illegal OpenMP user-defined mapper identifier}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+#pragma omp target update from(mapper(N1::aa) :vv)  // expected-error {{cannot find a valid user-defined mapper for type 'vec' with name 'aa'}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+#pragma omp target update from(mapper(ab):vv)   // expected-error {{cannot find a valid user-defined mapper for type 'vec' with name 'ab'}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+#pragma omp target update from(mapper(aa) a:vv) // expected-warning {{missing ':' after ) - ignoring}}
+#pragma omp target update from(mapper(aa):vv)
+#pragma omp target update from(mapper(N1::stack::id) :vv)
 }
 #pragma omp declare mapper(id: vec v) map(v.len)// expected-error {{redefinition of user-defined mapper for type 'vec' with name 'id'}}
   }
Index: test/OpenMP/declare_mapper_messages.c
===
--- test/OpenMP/declare_mapper_messages.c
+++ test/OpenMP/declare_mapper_messages.c
@@ -58,6 +58,15 @@
 #pragma omp target update to(mapper(aa :vv) // expected-error {{expected ')'}} 

[PATCH] D56924: Special case ObjCPropertyDecl for printing

2019-02-25 Thread David Goldman via Phabricator via cfe-commits
dgoldman added a comment.

In D56924#1407836 , @arphaman wrote:

> Please add a test that covers the '(class extension)' output as well.


Removed the `(class extension)` output as the property getter if statement 
should now handle this.


Repository:
  rC Clang

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

https://reviews.llvm.org/D56924



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


[PATCH] D56924: Handle ObjCCategoryDecl class extensions for print

2019-02-25 Thread David Goldman via Phabricator via cfe-commits
dgoldman updated this revision to Diff 188213.
dgoldman added a comment.

- Remove (class extension) as it's no longer needed


Repository:
  rC Clang

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

https://reviews.llvm.org/D56924

Files:
  lib/AST/Decl.cpp
  unittests/AST/NamedDeclPrinterTest.cpp


Index: unittests/AST/NamedDeclPrinterTest.cpp
===
--- unittests/AST/NamedDeclPrinterTest.cpp
+++ unittests/AST/NamedDeclPrinterTest.cpp
@@ -115,6 +115,18 @@
  "input.cc");
 }
 
+::testing::AssertionResult
+PrintedWrittenPropertyDeclObjCMatches(StringRef Code, StringRef DeclName,
+   StringRef ExpectedPrinted) {
+  std::vector Args{"-std=c++11", "-xobjective-c++"};
+  return PrintedNamedDeclMatches(Code,
+ Args,
+ /*SuppressUnwrittenScope*/ true,
+ 
objcPropertyDecl(hasName(DeclName)).bind("id"),
+ ExpectedPrinted,
+ "input.m");
+}
+
 } // unnamed namespace
 
 TEST(NamedDeclPrinter, TestNamespace1) {
@@ -179,3 +191,31 @@
 "A",
 "X::A"));
 }
+
+TEST(NamedDeclPrinter, TestObjCClassExtension) {
+  ASSERT_TRUE(PrintedWrittenPropertyDeclObjCMatches(
+R"(
+  @interface Obj
+  @end
+
+  @interface Obj ()
+  @property(nonatomic) int property;
+  @end
+)",
+"property",
+"Obj::property"));
+}
+
+TEST(NamedDeclPrinter, TestObjCClassExtensionWithGetter) {
+  ASSERT_TRUE(PrintedWrittenPropertyDeclObjCMatches(
+R"(
+  @interface Obj
+  @end
+
+  @interface Obj ()
+  @property(nonatomic, getter=myPropertyGetter) int property;
+  @end
+)",
+"property",
+"Obj::property"));
+}
Index: lib/AST/Decl.cpp
===
--- lib/AST/Decl.cpp
+++ lib/AST/Decl.cpp
@@ -1531,10 +1531,16 @@
const PrintingPolicy ) const {
   const DeclContext *Ctx = getDeclContext();
 
-  // For ObjC methods, look through categories and use the interface as 
context.
+  // For ObjC methods and properties, look through categories and use the
+  // interface as context.
   if (auto *MD = dyn_cast(this))
 if (auto *ID = MD->getClassInterface())
   Ctx = ID;
+  if (auto *PD = dyn_cast(this)) {
+if (auto *MD = PD->getGetterMethodDecl())
+  if (auto *ID = MD->getClassInterface())
+Ctx = ID;
+  }
 
   if (Ctx->isFunctionOrMethod()) {
 printName(OS);


Index: unittests/AST/NamedDeclPrinterTest.cpp
===
--- unittests/AST/NamedDeclPrinterTest.cpp
+++ unittests/AST/NamedDeclPrinterTest.cpp
@@ -115,6 +115,18 @@
  "input.cc");
 }
 
+::testing::AssertionResult
+PrintedWrittenPropertyDeclObjCMatches(StringRef Code, StringRef DeclName,
+   StringRef ExpectedPrinted) {
+  std::vector Args{"-std=c++11", "-xobjective-c++"};
+  return PrintedNamedDeclMatches(Code,
+ Args,
+ /*SuppressUnwrittenScope*/ true,
+ objcPropertyDecl(hasName(DeclName)).bind("id"),
+ ExpectedPrinted,
+ "input.m");
+}
+
 } // unnamed namespace
 
 TEST(NamedDeclPrinter, TestNamespace1) {
@@ -179,3 +191,31 @@
 "A",
 "X::A"));
 }
+
+TEST(NamedDeclPrinter, TestObjCClassExtension) {
+  ASSERT_TRUE(PrintedWrittenPropertyDeclObjCMatches(
+R"(
+  @interface Obj
+  @end
+
+  @interface Obj ()
+  @property(nonatomic) int property;
+  @end
+)",
+"property",
+"Obj::property"));
+}
+
+TEST(NamedDeclPrinter, TestObjCClassExtensionWithGetter) {
+  ASSERT_TRUE(PrintedWrittenPropertyDeclObjCMatches(
+R"(
+  @interface Obj
+  @end
+
+  @interface Obj ()
+  @property(nonatomic, getter=myPropertyGetter) int property;
+  @end
+)",
+"property",
+"Obj::property"));
+}
Index: lib/AST/Decl.cpp
===
--- lib/AST/Decl.cpp
+++ lib/AST/Decl.cpp
@@ -1531,10 +1531,16 @@
const PrintingPolicy ) const {
   const DeclContext *Ctx = getDeclContext();
 
-  // For ObjC methods, look through categories and use the interface as context.
+  // For ObjC methods and properties, look through categories and use the
+  // interface as context.
   if (auto *MD = dyn_cast(this))
 if (auto *ID = MD->getClassInterface())
   Ctx = ID;
+  if (auto *PD = dyn_cast(this)) {
+if (auto *MD = PD->getGetterMethodDecl())
+  if (auto *ID = MD->getClassInterface())
+Ctx = ID;
+  }
 
   if (Ctx->isFunctionOrMethod()) {
 printName(OS);
___

[PATCH] D58612: Make the static counters in ASTContext non-static

2019-02-25 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

In D58612#1409216 , @riccibruno wrote:

> In D58612#1409215 , @alexfh wrote:
>
> > > In D58612#1409024 , @riccibruno 
> > > wrote:
> > > 
> > >> ...
> > >>  For example in `DeclBase.cpp`
> > >>
> > >>   #define DECL(DERIVED, BASE) static int n##DERIVED##s = 0;
> > >>   #define ABSTRACT_DECL(DECL)
> > >>   #include "clang/AST/DeclNodes.inc"
> > >>
> > >>
> > >> ...
> > > 
> > > 
> > > These are probably easier to convert to std::atomic, but I'd do this 
> > > separately.
> >
> > Just converting these to `std::atomic<>` will mute TSan, but won't fix the 
> > underlying issue: the stats should be collected per-compiler instance. 
> > Initialization will require a bit more locking as well. Not sure what would 
> > be a good solution here.
>
>
> I agree that making them atomic is not a good solution. I am not sure that 
> the stats should be stored in the compiler instance (is that what you are 
> suggesting ?). The number of declaration nodes of each kind seems to be 
> something that should be stored in the AST context.


Well, I wasn't talking about storing the metrics in the `CompilerInstance` 
class directly. Maybe in `ASTContext`. But after looking a bit closer I see 
that the problem is that an instance of `ASTContext` is not readily available 
where these stats are gathered. I'm not sure I'll get to change this any time 
soon though.


Repository:
  rC Clang

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

https://reviews.llvm.org/D58612



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


[PATCH] D58569: [libclang] Avoid crashing when getting layout info of an undeduced type.

2019-02-25 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/tools/c-index-test/c-index-test.c:1695
+CXType RT = clang_getResultType(T);
+if (RT.kind != CXType_Invalid)
+  PrintSingleTypeSize(RT, " [resulttype=%s] [resulttypekind=%s]",

emilio wrote:
> Anastasia wrote:
> > Should it not return undeduced error in the other case?
> I'm not sure what you mean, can you clarify?
> 
> The undeduced error is only returned when you try to access the `Auto` type 
> which is the return value, not the function type, which has a known layout.
> 
> So in the error case, `T` here is the `auto Tie(void*) const;` type, and `RT` 
> is the undeduced `auto` type, which is what crashed.
> 
> We had no way to exercise this in `c-index-test`, so I changed it to exercise 
> this codepath too. I can add a `CHECK` for the error code if you want.
Yep, error check would be good since it's covers better changes in your patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58569



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


[PATCH] D58634: [PR40778] Generate address space conversion when binding reference to a temporary value in different address space

2019-02-25 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia marked an inline comment as done.
Anastasia added inline comments.



Comment at: lib/CodeGen/CGCall.cpp:4067
+  IRFuncTy->getParamType(FirstIRArg)->isPointerTy())
+V = Builder.CreatePointerBitCastOrAddrSpaceCast(
+V, IRFuncTy->getParamType(FirstIRArg));

We have started using `performAddrSpaceCast` for those but, however, I was very 
confused about how to get address space of the Clang types correctly here.

I was using this function in a couple of places before but I must admit I am 
still a bit confused about the purpose of it. Mainly I was wondering if we 
could drop `LangAS` parameters from it? It would simplify its use a lot in 
multiple places. As far as I can see they are not used in the function at the 
moment. I am not sure if they are reserved for some development in the future 
though?

Altogether I quite like using `IRBuilder` directly because in combination with 
target address space map it allows to do what's needed here and keep consistent 
with the rest. Perhaps, I am missing some background info. I have tried to dig 
out a bit but no much success.


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

https://reviews.llvm.org/D58634



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


[PATCH] D58634: [PR40778] Generate address space conversion when binding reference to a temporary value in different address space

2019-02-25 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia created this revision.
Anastasia added reviewers: rjmccall, ebevhan.

This is fixing one of the issues reported in the bug:
https://bugs.llvm.org/show_bug.cgi?id=40778


https://reviews.llvm.org/D58634

Files:
  lib/CodeGen/CGCall.cpp
  test/CodeGenOpenCLCXX/addrspace-references.cl


Index: test/CodeGenOpenCLCXX/addrspace-references.cl
===
--- /dev/null
+++ test/CodeGenOpenCLCXX/addrspace-references.cl
@@ -0,0 +1,11 @@
+//RUN: %clang_cc1 %s -cl-std=c++ -triple spir -emit-llvm -o - | FileCheck %s
+
+int bar(const unsigned int );
+
+void foo() {
+  // The generic addr space reference parameter object will be bound
+  // to a temporary value allocated in private addr space. We need an
+  // addrspacecast before passing the value to the function.
+  // CHECK: addrspacecast i32* %ref.tmp to i32 addrspace(4)*
+  bar(1);
+}
Index: lib/CodeGen/CGCall.cpp
===
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -4058,12 +4058,16 @@
 if (ArgInfo.getCoerceToType() != V->getType() &&
 V->getType()->isIntegerTy())
   V = Builder.CreateZExt(V, ArgInfo.getCoerceToType());
-
 // If the argument doesn't match, perform a bitcast to coerce it.  This
 // can happen due to trivial type mismatches.
 if (FirstIRArg < IRFuncTy->getNumParams() &&
 V->getType() != IRFuncTy->getParamType(FirstIRArg))
-  V = Builder.CreateBitCast(V, IRFuncTy->getParamType(FirstIRArg));
+  if (V->getType()->isPointerTy() &&
+  IRFuncTy->getParamType(FirstIRArg)->isPointerTy())
+V = Builder.CreatePointerBitCastOrAddrSpaceCast(
+V, IRFuncTy->getParamType(FirstIRArg));
+  else
+V = Builder.CreateBitCast(V, IRFuncTy->getParamType(FirstIRArg));
 
 IRCallArgs[FirstIRArg] = V;
 break;


Index: test/CodeGenOpenCLCXX/addrspace-references.cl
===
--- /dev/null
+++ test/CodeGenOpenCLCXX/addrspace-references.cl
@@ -0,0 +1,11 @@
+//RUN: %clang_cc1 %s -cl-std=c++ -triple spir -emit-llvm -o - | FileCheck %s
+
+int bar(const unsigned int );
+
+void foo() {
+  // The generic addr space reference parameter object will be bound
+  // to a temporary value allocated in private addr space. We need an
+  // addrspacecast before passing the value to the function.
+  // CHECK: addrspacecast i32* %ref.tmp to i32 addrspace(4)*
+  bar(1);
+}
Index: lib/CodeGen/CGCall.cpp
===
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -4058,12 +4058,16 @@
 if (ArgInfo.getCoerceToType() != V->getType() &&
 V->getType()->isIntegerTy())
   V = Builder.CreateZExt(V, ArgInfo.getCoerceToType());
-
 // If the argument doesn't match, perform a bitcast to coerce it.  This
 // can happen due to trivial type mismatches.
 if (FirstIRArg < IRFuncTy->getNumParams() &&
 V->getType() != IRFuncTy->getParamType(FirstIRArg))
-  V = Builder.CreateBitCast(V, IRFuncTy->getParamType(FirstIRArg));
+  if (V->getType()->isPointerTy() &&
+  IRFuncTy->getParamType(FirstIRArg)->isPointerTy())
+V = Builder.CreatePointerBitCastOrAddrSpaceCast(
+V, IRFuncTy->getParamType(FirstIRArg));
+  else
+V = Builder.CreateBitCast(V, IRFuncTy->getParamType(FirstIRArg));
 
 IRCallArgs[FirstIRArg] = V;
 break;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D57335: [IR] Don't assume all functions are 4 byte aligned

2019-02-25 Thread Michael Platings via Phabricator via cfe-commits
michaelplatings marked 4 inline comments as done.
michaelplatings added inline comments.



Comment at: llvm/lib/IR/ConstantFold.cpp:1087
+  if (GVAlign == 0U && isa(GV))
+GVAlign = 4U;
 

efriedma wrote:
> Using "4" as a default is dangerous; on x86, the alignment of the pointer 
> corresponds to the alignment of the function, but might be less than 4 if it 
> isn't explicitly specified.
I've put in a comment to say as much. Sadly I'm not in a position to change 
this behaviour without causing a code size regression.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D57335



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


[PATCH] D58504: [OpenCL][8.0.0 Release] Notes for OpenCL

2019-02-25 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

Committed to the release branch r354799.

FYI, I did a couple of formatting changes and typo fixes.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D58504



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


[PATCH] D58504: [OpenCL][8.0.0 Release] Notes for OpenCL

2019-02-25 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354799: Release notes for OpenCL (authored by stulova, 
committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D58504?vs=188122=188194#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D58504

Files:
  cfe/branches/release_80/docs/ReleaseNotes.rst


Index: cfe/branches/release_80/docs/ReleaseNotes.rst
===
--- cfe/branches/release_80/docs/ReleaseNotes.rst
+++ cfe/branches/release_80/docs/ReleaseNotes.rst
@@ -11,7 +11,7 @@
 Introduction
 
 
-This document contains the release notes for the Clang C/C++/Objective-C
+This document contains the release notes for the Clang C/C++/Objective-C/OpenCL
 frontend, part of the LLVM Compiler Infrastructure, release 8.0.0. Here we
 describe the status of Clang in some detail, including major
 improvements from the previous release and new feature work. For the
@@ -259,10 +259,60 @@
 
 ...
 
-OpenCL C Language Changes in Clang
---
+OpenCL Kernel Language Changes in Clang
+---
+
+Misc:
+
+- Improved address space support with Clang builtins.
+
+- Improved various diagnostics for vectors with element types from extensions;
+  values used in attributes; duplicate address spaces.
+
+- Allow blocks to capture arrays.
+
+- Allow zero assignment and comparisons between variables of ``queue_t`` type.
+
+- Improved diagnostics of formatting specifiers and argument promotions for
+  vector types in ``printf``.
+
+- Fixed return type of enqueued kernel and pipe builtins.
+
+- Fixed address space of ``clk_event_t`` generated in the IR.
+
+- Fixed address space when passing/returning structs.
+
+Header file fixes:
+
+- Added missing extension guards around several builtin function overloads.
+
+- Fixed serialization support when registering vendor extensions using pragmas.
+
+- Fixed OpenCL version in declarations of builtin functions with sampler-less
+  image accesses.
+
+New vendor extensions added:
+
+- ``cl_intel_planar_yuv``
+
+- ``cl_intel_device_side_avc_motion_estimation``
+
+
+C++ for OpenCL:
+
+- Added support of address space conversions in C style casts.
+
+- Enabled address spaces for references.
+
+- Fixed use of address spaces in templates: address space deduction and 
diagnostics.
+
+- Changed default address space to work with C++ specific concepts: class 
members,
+  template parameters, etc.
+
+- Added generic address space by default to the generated hidden 'this' 
parameter.
+
+- Extend overload ranking rules for address spaces.
 
-...
 
 ABI Changes in Clang
 


Index: cfe/branches/release_80/docs/ReleaseNotes.rst
===
--- cfe/branches/release_80/docs/ReleaseNotes.rst
+++ cfe/branches/release_80/docs/ReleaseNotes.rst
@@ -11,7 +11,7 @@
 Introduction
 
 
-This document contains the release notes for the Clang C/C++/Objective-C
+This document contains the release notes for the Clang C/C++/Objective-C/OpenCL
 frontend, part of the LLVM Compiler Infrastructure, release 8.0.0. Here we
 describe the status of Clang in some detail, including major
 improvements from the previous release and new feature work. For the
@@ -259,10 +259,60 @@
 
 ...
 
-OpenCL C Language Changes in Clang
---
+OpenCL Kernel Language Changes in Clang
+---
+
+Misc:
+
+- Improved address space support with Clang builtins.
+
+- Improved various diagnostics for vectors with element types from extensions;
+  values used in attributes; duplicate address spaces.
+
+- Allow blocks to capture arrays.
+
+- Allow zero assignment and comparisons between variables of ``queue_t`` type.
+
+- Improved diagnostics of formatting specifiers and argument promotions for
+  vector types in ``printf``.
+
+- Fixed return type of enqueued kernel and pipe builtins.
+
+- Fixed address space of ``clk_event_t`` generated in the IR.
+
+- Fixed address space when passing/returning structs.
+
+Header file fixes:
+
+- Added missing extension guards around several builtin function overloads.
+
+- Fixed serialization support when registering vendor extensions using pragmas.
+
+- Fixed OpenCL version in declarations of builtin functions with sampler-less
+  image accesses.
+
+New vendor extensions added:
+
+- ``cl_intel_planar_yuv``
+
+- ``cl_intel_device_side_avc_motion_estimation``
+
+
+C++ for OpenCL:
+
+- Added support of address space conversions in C style casts.
+
+- Enabled address spaces for references.
+
+- Fixed use of address spaces in templates: address space deduction and diagnostics.
+
+- Changed default address space to work with C++ specific concepts: class members,
+  

[PATCH] D58612: Use std::atomic<> for static counters.

2019-02-25 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added a comment.

In D58612#1409215 , @alexfh wrote:

> > In D58612#1409024 , @riccibruno 
> > wrote:
> > 
> >> ...
> >>  For example in `DeclBase.cpp`
> >>
> >>   #define DECL(DERIVED, BASE) static int n##DERIVED##s = 0;
> >>   #define ABSTRACT_DECL(DECL)
> >>   #include "clang/AST/DeclNodes.inc"
> >>
> >>
> >> ...
> > 
> > 
> > These are probably easier to convert to std::atomic, but I'd do this 
> > separately.
>
> Just converting these to `std::atomic<>` will mute TSan, but won't fix the 
> underlying issue: the stats should be collected per-compiler instance. 
> Initialization will require a bit more locking as well. Not sure what would 
> be a good solution here.


I agree that making them atomic is not a good solution. I am not sure that the 
stats should be stored in the compiler instance (is that what you are 
suggesting ?). The number of declaration nodes of each kind seems to be 
something that should be stored in the AST context.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D58612



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


[PATCH] D58612: Use std::atomic<> for static counters.

2019-02-25 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

> In D58612#1409024 , @riccibruno 
> wrote:
> 
>> ...
>>  For example in `DeclBase.cpp`
>>
>>   #define DECL(DERIVED, BASE) static int n##DERIVED##s = 0;
>>   #define ABSTRACT_DECL(DECL)
>>   #include "clang/AST/DeclNodes.inc"
>>
>>
>> ...
> 
> 
> These are probably easier to convert to std::atomic, but I'd do this 
> separately.

Just converting these to `std::atomic<>` will mute TSan, but won't fix the 
underlying issue: the stats should be collected per-compiler instance. 
Initialization will require a bit more locking as well. Not sure what would be 
a good solution here.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D58612



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


[PATCH] D57590: [ASTImporter] Improve import of FileID.

2019-02-25 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.
Herald added a reviewer: martong.

Ping.

Please raise your objections if you have any until the 4th of March (that date 
we are going to commit if there are no objections). Also, please let us know if 
you find this deadline too strict.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57590



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


[PATCH] D57335: [IR] Don't assume all functions are 4 byte aligned

2019-02-25 Thread Michael Platings via Phabricator via cfe-commits
michaelplatings updated this revision to Diff 188184.
michaelplatings added a comment.
Herald added subscribers: cfe-commits, jdoerfert, mgorny, dschuff.
Herald added projects: clang, LLVM.

Hi @efriedma, sorry for the delayed response.
I've added the features you asked for to DataLayout.
It is intended that this patch preserves the existing behaviour if no function 
pointer alignment is specified.* Therefore I hope you'll agree that it isn't 
necessary for me to provide code to use the new feature on all platforms.
I did also look into using a target hook but doing so would require modifying a 
//lot// of functions to take a TargetTransformInfo argument. Given that we're 
in agreement that the DataLayout is an appropriate choice, it seemed like the 
best option.

- The exception to this is the case where the Function object doesn't have a 
parent - no alignment is assumed whereas previously 4-byte alignment was 
assumed. Hopefully this case is rare enough that code size won't be 
significantly impacted.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D57335

Files:
  clang/lib/Basic/Targets/ARM.cpp
  clang/test/CodeGen/armv7k-abi.c
  clang/test/CodeGen/target-data.c
  llvm/docs/LangRef.rst
  llvm/include/llvm/IR/ConstantFold.h
  llvm/include/llvm/IR/DataLayout.h
  llvm/lib/IR/ConstantFold.cpp
  llvm/lib/IR/ConstantFold.h
  llvm/lib/IR/Constants.cpp
  llvm/lib/IR/DataLayout.cpp
  llvm/lib/IR/Value.cpp
  llvm/lib/Target/ARM/ARMTargetMachine.cpp
  llvm/unittests/IR/CMakeLists.txt
  llvm/unittests/IR/ConstantFoldTest.cpp
  llvm/unittests/IR/DataLayoutTest.cpp
  llvm/unittests/IR/FunctionTest.cpp

Index: llvm/unittests/IR/FunctionTest.cpp
===
--- llvm/unittests/IR/FunctionTest.cpp
+++ llvm/unittests/IR/FunctionTest.cpp
@@ -129,4 +129,29 @@
   EXPECT_TRUE(F->hasSection());
 }
 
+TEST(FunctionTest, GetPointerAlignment) {
+  LLVMContext Context;
+  Type *VoidType(Type::getVoidTy(Context));
+  FunctionType *FuncType(FunctionType::get(VoidType, false));
+  Function *Func = Function::Create(
+  FuncType, GlobalValue::ExternalLinkage);
+  EXPECT_EQ(0U, Func->getPointerAlignment(DataLayout("")));
+  EXPECT_EQ(1U, Func->getPointerAlignment(DataLayout("Fi8")));
+  EXPECT_EQ(1U, Func->getPointerAlignment(DataLayout("Fn8")));
+  EXPECT_EQ(2U, Func->getPointerAlignment(DataLayout("Fi16")));
+  EXPECT_EQ(2U, Func->getPointerAlignment(DataLayout("Fn16")));
+  EXPECT_EQ(4U, Func->getPointerAlignment(DataLayout("Fi32")));
+  EXPECT_EQ(4U, Func->getPointerAlignment(DataLayout("Fn32")));
+
+  Func->setAlignment(4U);
+
+  EXPECT_EQ(0U, Func->getPointerAlignment(DataLayout("")));
+  EXPECT_EQ(1U, Func->getPointerAlignment(DataLayout("Fi8")));
+  EXPECT_EQ(4U, Func->getPointerAlignment(DataLayout("Fn8")));
+  EXPECT_EQ(2U, Func->getPointerAlignment(DataLayout("Fi16")));
+  EXPECT_EQ(4U, Func->getPointerAlignment(DataLayout("Fn16")));
+  EXPECT_EQ(4U, Func->getPointerAlignment(DataLayout("Fi32")));
+  EXPECT_EQ(4U, Func->getPointerAlignment(DataLayout("Fn32")));
+}
+
 } // end namespace
Index: llvm/unittests/IR/DataLayoutTest.cpp
===
--- /dev/null
+++ llvm/unittests/IR/DataLayoutTest.cpp
@@ -0,0 +1,47 @@
+//===- ConstantRangeTest.cpp - ConstantRange tests ===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "llvm/IR/DataLayout.h"
+#include "gtest/gtest.h"
+
+using namespace llvm;
+
+namespace {
+
+TEST(DataLayoutTest, FunctionPtrAlign) {
+  EXPECT_EQ(0U, DataLayout("").getFunctionPtrAlign());
+  EXPECT_EQ(1U, DataLayout("Fi8").getFunctionPtrAlign());
+  EXPECT_EQ(2U, DataLayout("Fi16").getFunctionPtrAlign());
+  EXPECT_EQ(4U, DataLayout("Fi32").getFunctionPtrAlign());
+  EXPECT_EQ(8U, DataLayout("Fi64").getFunctionPtrAlign());
+  EXPECT_EQ(1U, DataLayout("Fn8").getFunctionPtrAlign());
+  EXPECT_EQ(2U, DataLayout("Fn16").getFunctionPtrAlign());
+  EXPECT_EQ(4U, DataLayout("Fn32").getFunctionPtrAlign());
+  EXPECT_EQ(8U, DataLayout("Fn64").getFunctionPtrAlign());
+  EXPECT_EQ(DataLayout::FunctionPtrAlignType::Independent, \
+  DataLayout("").getFunctionPtrAlignType());
+  EXPECT_EQ(DataLayout::FunctionPtrAlignType::Independent, \
+  DataLayout("Fi8").getFunctionPtrAlignType());
+  EXPECT_EQ(DataLayout::FunctionPtrAlignType::MultipleOfFunctionAlign, \
+  DataLayout("Fn8").getFunctionPtrAlignType());
+  EXPECT_EQ(DataLayout("Fi8"), DataLayout("Fi8"));
+  EXPECT_NE(DataLayout("Fi8"), DataLayout("Fi16"));
+  EXPECT_NE(DataLayout("Fi8"), DataLayout("Fn8"));
+
+  DataLayout a(""), b("Fi8"), c("Fn8");
+  EXPECT_NE(a, b);
+  EXPECT_NE(a, 

[PATCH] D58612: Use std::atomic<> for static counters.

2019-02-25 Thread Alexander Kornienko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354795: Make static counters in ASTContext non-static. 
(authored by alexfh, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D58612?vs=188163=188185#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D58612

Files:
  cfe/trunk/include/clang/AST/ASTContext.h
  cfe/trunk/lib/AST/ASTContext.cpp
  cfe/trunk/lib/Sema/SemaDeclCXX.cpp

Index: cfe/trunk/include/clang/AST/ASTContext.h
===
--- cfe/trunk/include/clang/AST/ASTContext.h
+++ cfe/trunk/include/clang/AST/ASTContext.h
@@ -2809,46 +2809,46 @@
   //======//
 
   /// The number of implicitly-declared default constructors.
-  static unsigned NumImplicitDefaultConstructors;
+  unsigned NumImplicitDefaultConstructors;
 
   /// The number of implicitly-declared default constructors for
   /// which declarations were built.
-  static unsigned NumImplicitDefaultConstructorsDeclared;
+  unsigned NumImplicitDefaultConstructorsDeclared;
 
   /// The number of implicitly-declared copy constructors.
-  static unsigned NumImplicitCopyConstructors;
+  unsigned NumImplicitCopyConstructors;
 
   /// The number of implicitly-declared copy constructors for
   /// which declarations were built.
-  static unsigned NumImplicitCopyConstructorsDeclared;
+  unsigned NumImplicitCopyConstructorsDeclared;
 
   /// The number of implicitly-declared move constructors.
-  static unsigned NumImplicitMoveConstructors;
+  unsigned NumImplicitMoveConstructors;
 
   /// The number of implicitly-declared move constructors for
   /// which declarations were built.
-  static unsigned NumImplicitMoveConstructorsDeclared;
+  unsigned NumImplicitMoveConstructorsDeclared;
 
   /// The number of implicitly-declared copy assignment operators.
-  static unsigned NumImplicitCopyAssignmentOperators;
+  unsigned NumImplicitCopyAssignmentOperators;
 
   /// The number of implicitly-declared copy assignment operators for
   /// which declarations were built.
-  static unsigned NumImplicitCopyAssignmentOperatorsDeclared;
+  unsigned NumImplicitCopyAssignmentOperatorsDeclared;
 
   /// The number of implicitly-declared move assignment operators.
-  static unsigned NumImplicitMoveAssignmentOperators;
+  unsigned NumImplicitMoveAssignmentOperators;
 
   /// The number of implicitly-declared move assignment operators for
   /// which declarations were built.
-  static unsigned NumImplicitMoveAssignmentOperatorsDeclared;
+  unsigned NumImplicitMoveAssignmentOperatorsDeclared;
 
   /// The number of implicitly-declared destructors.
-  static unsigned NumImplicitDestructors;
+  unsigned NumImplicitDestructors;
 
   /// The number of implicitly-declared destructors for which
   /// declarations were built.
-  static unsigned NumImplicitDestructorsDeclared;
+  unsigned NumImplicitDestructorsDeclared;
 
 public:
   /// Initialize built-in types.
Index: cfe/trunk/lib/AST/ASTContext.cpp
===
--- cfe/trunk/lib/AST/ASTContext.cpp
+++ cfe/trunk/lib/AST/ASTContext.cpp
@@ -94,19 +94,6 @@
 
 using namespace clang;
 
-unsigned ASTContext::NumImplicitDefaultConstructors;
-unsigned ASTContext::NumImplicitDefaultConstructorsDeclared;
-unsigned ASTContext::NumImplicitCopyConstructors;
-unsigned ASTContext::NumImplicitCopyConstructorsDeclared;
-unsigned ASTContext::NumImplicitMoveConstructors;
-unsigned ASTContext::NumImplicitMoveConstructorsDeclared;
-unsigned ASTContext::NumImplicitCopyAssignmentOperators;
-unsigned ASTContext::NumImplicitCopyAssignmentOperatorsDeclared;
-unsigned ASTContext::NumImplicitMoveAssignmentOperators;
-unsigned ASTContext::NumImplicitMoveAssignmentOperatorsDeclared;
-unsigned ASTContext::NumImplicitDestructors;
-unsigned ASTContext::NumImplicitDestructorsDeclared;
-
 enum FloatingRank {
   Float16Rank, HalfRank, FloatRank, DoubleRank, LongDoubleRank, Float128Rank
 };
Index: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
===
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp
@@ -7971,14 +7971,14 @@
 /// definition of the class is complete.
 void Sema::AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl) {
   if (ClassDecl->needsImplicitDefaultConstructor()) {
-++ASTContext::NumImplicitDefaultConstructors;
+++getASTContext().NumImplicitDefaultConstructors;
 
 if (ClassDecl->hasInheritedConstructor())
   DeclareImplicitDefaultConstructor(ClassDecl);
   }
 
   if (ClassDecl->needsImplicitCopyConstructor()) {
-++ASTContext::NumImplicitCopyConstructors;
+++getASTContext().NumImplicitCopyConstructors;
 
 // If the properties or semantics of the copy 

[PATCH] D58612: Use std::atomic<> for static counters.

2019-02-25 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added a comment.

(With a commit message which actually reflect the change of course)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58612



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


r354795 - Make static counters in ASTContext non-static.

2019-02-25 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Mon Feb 25 08:08:46 2019
New Revision: 354795

URL: http://llvm.org/viewvc/llvm-project?rev=354795=rev
Log:
Make static counters in ASTContext non-static.

Summary:
Fixes a data race and makes it possible to run clang-based tools in
multithreaded environment with TSan.

Reviewers: ilya-biryukov, riccibruno

Reviewed By: riccibruno

Subscribers: riccibruno, jfb, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=354795=354794=354795=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Mon Feb 25 08:08:46 2019
@@ -2809,46 +2809,46 @@ public:
   
//======//
 
   /// The number of implicitly-declared default constructors.
-  static unsigned NumImplicitDefaultConstructors;
+  unsigned NumImplicitDefaultConstructors;
 
   /// The number of implicitly-declared default constructors for
   /// which declarations were built.
-  static unsigned NumImplicitDefaultConstructorsDeclared;
+  unsigned NumImplicitDefaultConstructorsDeclared;
 
   /// The number of implicitly-declared copy constructors.
-  static unsigned NumImplicitCopyConstructors;
+  unsigned NumImplicitCopyConstructors;
 
   /// The number of implicitly-declared copy constructors for
   /// which declarations were built.
-  static unsigned NumImplicitCopyConstructorsDeclared;
+  unsigned NumImplicitCopyConstructorsDeclared;
 
   /// The number of implicitly-declared move constructors.
-  static unsigned NumImplicitMoveConstructors;
+  unsigned NumImplicitMoveConstructors;
 
   /// The number of implicitly-declared move constructors for
   /// which declarations were built.
-  static unsigned NumImplicitMoveConstructorsDeclared;
+  unsigned NumImplicitMoveConstructorsDeclared;
 
   /// The number of implicitly-declared copy assignment operators.
-  static unsigned NumImplicitCopyAssignmentOperators;
+  unsigned NumImplicitCopyAssignmentOperators;
 
   /// The number of implicitly-declared copy assignment operators for
   /// which declarations were built.
-  static unsigned NumImplicitCopyAssignmentOperatorsDeclared;
+  unsigned NumImplicitCopyAssignmentOperatorsDeclared;
 
   /// The number of implicitly-declared move assignment operators.
-  static unsigned NumImplicitMoveAssignmentOperators;
+  unsigned NumImplicitMoveAssignmentOperators;
 
   /// The number of implicitly-declared move assignment operators for
   /// which declarations were built.
-  static unsigned NumImplicitMoveAssignmentOperatorsDeclared;
+  unsigned NumImplicitMoveAssignmentOperatorsDeclared;
 
   /// The number of implicitly-declared destructors.
-  static unsigned NumImplicitDestructors;
+  unsigned NumImplicitDestructors;
 
   /// The number of implicitly-declared destructors for which
   /// declarations were built.
-  static unsigned NumImplicitDestructorsDeclared;
+  unsigned NumImplicitDestructorsDeclared;
 
 public:
   /// Initialize built-in types.

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=354795=354794=354795=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Mon Feb 25 08:08:46 2019
@@ -94,19 +94,6 @@
 
 using namespace clang;
 
-unsigned ASTContext::NumImplicitDefaultConstructors;
-unsigned ASTContext::NumImplicitDefaultConstructorsDeclared;
-unsigned ASTContext::NumImplicitCopyConstructors;
-unsigned ASTContext::NumImplicitCopyConstructorsDeclared;
-unsigned ASTContext::NumImplicitMoveConstructors;
-unsigned ASTContext::NumImplicitMoveConstructorsDeclared;
-unsigned ASTContext::NumImplicitCopyAssignmentOperators;
-unsigned ASTContext::NumImplicitCopyAssignmentOperatorsDeclared;
-unsigned ASTContext::NumImplicitMoveAssignmentOperators;
-unsigned ASTContext::NumImplicitMoveAssignmentOperatorsDeclared;
-unsigned ASTContext::NumImplicitDestructors;
-unsigned ASTContext::NumImplicitDestructorsDeclared;
-
 enum FloatingRank {
   Float16Rank, HalfRank, FloatRank, DoubleRank, LongDoubleRank, Float128Rank
 };

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=354795=354794=354795=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Mon Feb 25 08:08:46 2019
@@ -7971,14 +7971,14 @@ void Sema::ActOnFinishCXXMemberSpecifica
 /// definition of the class is complete.
 void 

[PATCH] D58612: Use std::atomic<> for static counters.

2019-02-25 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov added a comment.

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58612



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


[PATCH] D58627: [git] Add top-level .gitignore

2019-02-25 Thread Michael Liao via Phabricator via cfe-commits
hliao abandoned this revision.
hliao added a comment.

by mistake, Ctrl-C is not fast enough to stop it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58627



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


[PATCH] D58627: [git] Add top-level .gitignore

2019-02-25 Thread Michael Liao via Phabricator via cfe-commits
hliao created this revision.
hliao added reviewers: kzhuravl, yaxunl.
hliao added a project: clang.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.

[D56411 ] Temp solution fixing CUDA template 
issue

- template with overloadable kernel function as the template function need 
revising CheckCUDACall checking.

[SelectionDAG] Harden the checking of RegClass when adding operand

- If the operand index is out-of-range, expect nullptr is returned.

[AMDGPU] Allow using integral non-type template parameters

- Allow using integral non-type template parameters in the following attributes

  __attribute__((amdgpu_flat_work_group_size(, ))) 
__attribute__((amdgpu_waves_per_eu([, ])))


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D58627

Files:
  .gitignore
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Sema/Sema.h
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/Sema/SemaCUDA.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/SemaCUDA/amdgpu-attrs.cu
  clang/test/SemaCUDA/kernel-template-with-func-arg.cu
  clang/test/SemaOpenCL/amdgpu-attrs.cl
  llvm/lib/CodeGen/SelectionDAG/InstrEmitter.cpp

Index: llvm/lib/CodeGen/SelectionDAG/InstrEmitter.cpp
===
--- llvm/lib/CodeGen/SelectionDAG/InstrEmitter.cpp
+++ llvm/lib/CodeGen/SelectionDAG/InstrEmitter.cpp
@@ -398,8 +398,9 @@
 const TargetRegisterClass *OpRC =
 TLI->isTypeLegal(OpVT) ? TLI->getRegClassFor(OpVT) : nullptr;
 const TargetRegisterClass *IIRC =
-II ? TRI->getAllocatableClass(TII->getRegClass(*II, IIOpNum, TRI, *MF))
-   : nullptr;
+II ? TII->getRegClass(*II, IIOpNum, TRI, *MF) : nullptr;
+assert(!II || IIOpNum < II->getNumOperands() || !IIRC);
+IIRC = TRI->getAllocatableClass(IIRC);
 
 if (OpRC && IIRC && OpRC != IIRC &&
 TargetRegisterInfo::isVirtualRegister(VReg)) {
Index: clang/test/SemaOpenCL/amdgpu-attrs.cl
===
--- clang/test/SemaOpenCL/amdgpu-attrs.cl
+++ clang/test/SemaOpenCL/amdgpu-attrs.cl
@@ -27,12 +27,12 @@
 __attribute__((amdgpu_num_sgpr(32))) void func_num_sgpr_32() {} // expected-error {{'amdgpu_num_sgpr' attribute only applies to kernel functions}}
 __attribute__((amdgpu_num_vgpr(64))) void func_num_vgpr_64() {} // expected-error {{'amdgpu_num_vgpr' attribute only applies to kernel functions}}
 
-__attribute__((amdgpu_flat_work_group_size("ABC", "ABC"))) kernel void kernel_flat_work_group_size_ABC_ABC() {} // expected-error {{'amdgpu_flat_work_group_size' attribute requires an integer constant}}
-__attribute__((amdgpu_flat_work_group_size(32, "ABC"))) kernel void kernel_flat_work_group_size_32_ABC() {} // expected-error {{'amdgpu_flat_work_group_size' attribute requires an integer constant}}
-__attribute__((amdgpu_flat_work_group_size("ABC", 64))) kernel void kernel_flat_work_group_size_ABC_64() {} // expected-error {{'amdgpu_flat_work_group_size' attribute requires an integer constant}}
-__attribute__((amdgpu_waves_per_eu("ABC"))) kernel void kernel_waves_per_eu_ABC() {} // expected-error {{'amdgpu_waves_per_eu' attribute requires an integer constant}}
-__attribute__((amdgpu_waves_per_eu(2, "ABC"))) kernel void kernel_waves_per_eu_2_ABC() {} // expected-error {{'amdgpu_waves_per_eu' attribute requires an integer constant}}
-__attribute__((amdgpu_waves_per_eu("ABC", 4))) kernel void kernel_waves_per_eu_ABC_4() {} // expected-error {{'amdgpu_waves_per_eu' attribute requires an integer constant}}
+__attribute__((amdgpu_flat_work_group_size("ABC", "ABC"))) kernel void kernel_flat_work_group_size_ABC_ABC() {} // expected-error {{'amdgpu_flat_work_group_size' attribute requires parameter 0 to be an integer constant}}
+__attribute__((amdgpu_flat_work_group_size(32, "ABC"))) kernel void kernel_flat_work_group_size_32_ABC() {} // expected-error {{'amdgpu_flat_work_group_size' attribute requires parameter 1 to be an integer constant}}
+__attribute__((amdgpu_flat_work_group_size("ABC", 64))) kernel void kernel_flat_work_group_size_ABC_64() {} // expected-error {{'amdgpu_flat_work_group_size' attribute requires parameter 0 to be an integer constant}}
+__attribute__((amdgpu_waves_per_eu("ABC"))) kernel void kernel_waves_per_eu_ABC() {} // expected-error {{'amdgpu_waves_per_eu' attribute requires parameter 0 to be an integer constant}}
+__attribute__((amdgpu_waves_per_eu(2, "ABC"))) kernel void kernel_waves_per_eu_2_ABC() {} // expected-error {{'amdgpu_waves_per_eu' attribute requires parameter 1 to be an integer constant}}
+__attribute__((amdgpu_waves_per_eu("ABC", 4))) kernel void kernel_waves_per_eu_ABC_4() {} // expected-error {{'amdgpu_waves_per_eu' attribute requires parameter 0 to be an integer constant}}
 __attribute__((amdgpu_num_sgpr("ABC"))) kernel void kernel_num_sgpr_ABC() {} // 

[PATCH] D56539: [clangd] Drop documentation in static index if symbols are not indexed for completion.

2019-02-25 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE354792: [clangd] Drop documentation in static index if 
symbols are not indexed for… (authored by hokein, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D56539?vs=188176=188180#toc

Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D56539

Files:
  clangd/index/FileIndex.cpp
  clangd/index/IndexAction.cpp
  clangd/index/SymbolCollector.cpp
  clangd/index/SymbolCollector.h
  unittests/clangd/SymbolCollectorTests.cpp

Index: unittests/clangd/SymbolCollectorTests.cpp
===
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -212,6 +212,12 @@
 return WrapperFrontendAction::CreateASTConsumer(CI, InFile);
   }
 
+  bool BeginInvocation(CompilerInstance ) override {
+// Make the compiler parse all comments.
+CI.getLangOpts().CommentOpts.ParseAllComments = true;
+return WrapperFrontendAction::BeginInvocation(CI);
+  }
+
 private:
   index::IndexingOptions IndexOpts;
   CommentHandler *PragmaHandler;
@@ -710,6 +716,31 @@
QName("main_f")));
 }
 
+TEST_F(SymbolCollectorTest, Documentation) {
+  const std::string Header = R"(
+// Doc Foo
+class Foo {
+  // Doc f
+  int f();
+};
+  )";
+  CollectorOpts.StoreAllDocumentation = false;
+  runSymbolCollector(Header, /* Main */ "");
+  EXPECT_THAT(Symbols,
+  UnorderedElementsAre(
+  AllOf(QName("Foo"), Doc("Doc Foo"), ForCodeCompletion(true)),
+  AllOf(QName("Foo::f"), Doc(""), ReturnType(""),
+ForCodeCompletion(false;
+
+  CollectorOpts.StoreAllDocumentation = true;
+  runSymbolCollector(Header, /* Main */ "");
+  EXPECT_THAT(Symbols,
+  UnorderedElementsAre(
+  AllOf(QName("Foo"), Doc("Doc Foo"), ForCodeCompletion(true)),
+  AllOf(QName("Foo::f"), Doc("Doc f"), ReturnType(""),
+ForCodeCompletion(false;
+}
+
 TEST_F(SymbolCollectorTest, ClassMembers) {
   const std::string Header = R"(
 class Foo {
Index: clangd/index/FileIndex.cpp
===
--- clangd/index/FileIndex.cpp
+++ clangd/index/FileIndex.cpp
@@ -45,9 +45,13 @@
   if (IsIndexMainAST) {
 // We only collect refs when indexing main AST.
 CollectorOpts.RefFilter = RefKind::All;
+// Comments for main file can always be obtained from sema, do not store
+// them in the index.
+CollectorOpts.StoreAllDocumentation = false;
   } else {
 IndexOpts.IndexMacrosInPreprocessor = true;
 CollectorOpts.CollectMacro = true;
+CollectorOpts.StoreAllDocumentation = true;
   }
 
   SymbolCollector Collector(std::move(CollectorOpts));
Index: clangd/index/IndexAction.cpp
===
--- clangd/index/IndexAction.cpp
+++ clangd/index/IndexAction.cpp
@@ -175,6 +175,7 @@
   Opts.CollectIncludePath = true;
   Opts.CountReferences = true;
   Opts.Origin = SymbolOrigin::Static;
+  Opts.StoreAllDocumentation = false;
   if (RefsCallback != nullptr) {
 Opts.RefFilter = RefKind::All;
 Opts.RefsInHeaders = true;
Index: clangd/index/SymbolCollector.h
===
--- clangd/index/SymbolCollector.h
+++ clangd/index/SymbolCollector.h
@@ -75,6 +75,10 @@
 /// Collect symbols local to main-files, such as static functions
 /// and symbols inside an anonymous namespace.
 bool CollectMainFileSymbols = true;
+/// If set to true, SymbolCollector will collect doc for all symbols.
+/// Note that documents of symbols being indexed for completion will always
+/// be collected regardless of this option.
+bool StoreAllDocumentation = false;
 /// If this is set, only collect symbols/references from a file if
 /// `FileFilter(SM, FID)` is true. If not set, all files are indexed.
 std::function FileFilter = nullptr;
Index: clangd/index/SymbolCollector.cpp
===
--- clangd/index/SymbolCollector.cpp
+++ clangd/index/SymbolCollector.cpp
@@ -566,18 +566,13 @@
   std::string Documentation =
   formatDocumentation(*CCS, getDocComment(Ctx, SymbolCompletion,
   /*CommentsFromHeaders=*/true));
-  // For symbols not indexed for completion (class members), we also store their
-  // docs in the index, because Sema doesn't load the docs from the preamble, we
-  // rely on the index to get the docs.
-  // FIXME: this can be optimized by only storing the docs in dynamic index --
-  // dynamic index should index these symbols when Sema completes a member
-  // completion.
-  

[PATCH] D58612: Use std::atomic<> for static counters.

2019-02-25 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Awesome, I was also surprised it's so easy to convert them.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58612



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


[PATCH] D42645: New simple Checker for mmap calls

2019-02-25 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added inline comments.
Herald added a subscriber: jdoerfert.
Herald added a project: LLVM.



Comment at: cfe/trunk/lib/StaticAnalyzer/Checkers/MmapWriteExecChecker.cpp:31-33
+  static int ProtWrite;
+  static int ProtExec;
+  static int ProtRead;

Can these be non-static members instead? These are one of just a few uses of 
static fields in Clang.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D42645



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


[clang-tools-extra] r354792 - [clangd] Drop documentation in static index if symbols are not indexed for completion.

2019-02-25 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Mon Feb 25 08:00:00 2019
New Revision: 354792

URL: http://llvm.org/viewvc/llvm-project?rev=354792=rev
Log:
[clangd] Drop documentation in static index if symbols are not indexed for 
completion.

Summary:
This is a further optimization of r350803, we drop docs in static index for
symbols not being indexed for completion, while keeping the docs in dynamic
index (we rely on dynamic index to get docs for class members).

Reviewers: ilya-biryukov

Reviewed By: ilya-biryukov

Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits

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

Modified:
clang-tools-extra/trunk/clangd/index/FileIndex.cpp
clang-tools-extra/trunk/clangd/index/IndexAction.cpp
clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp
clang-tools-extra/trunk/clangd/index/SymbolCollector.h
clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp

Modified: clang-tools-extra/trunk/clangd/index/FileIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/FileIndex.cpp?rev=354792=354791=354792=diff
==
--- clang-tools-extra/trunk/clangd/index/FileIndex.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/FileIndex.cpp Mon Feb 25 08:00:00 2019
@@ -45,9 +45,13 @@ indexSymbols(ASTContext , std::share
   if (IsIndexMainAST) {
 // We only collect refs when indexing main AST.
 CollectorOpts.RefFilter = RefKind::All;
+// Comments for main file can always be obtained from sema, do not store
+// them in the index.
+CollectorOpts.StoreAllDocumentation = false;
   } else {
 IndexOpts.IndexMacrosInPreprocessor = true;
 CollectorOpts.CollectMacro = true;
+CollectorOpts.StoreAllDocumentation = true;
   }
 
   SymbolCollector Collector(std::move(CollectorOpts));

Modified: clang-tools-extra/trunk/clangd/index/IndexAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/IndexAction.cpp?rev=354792=354791=354792=diff
==
--- clang-tools-extra/trunk/clangd/index/IndexAction.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/IndexAction.cpp Mon Feb 25 08:00:00 
2019
@@ -175,6 +175,7 @@ std::unique_ptr createSt
   Opts.CollectIncludePath = true;
   Opts.CountReferences = true;
   Opts.Origin = SymbolOrigin::Static;
+  Opts.StoreAllDocumentation = false;
   if (RefsCallback != nullptr) {
 Opts.RefFilter = RefKind::All;
 Opts.RefsInHeaders = true;

Modified: clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp?rev=354792=354791=354792=diff
==
--- clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp Mon Feb 25 
08:00:00 2019
@@ -566,18 +566,13 @@ const Symbol *SymbolCollector::addDeclar
   std::string Documentation =
   formatDocumentation(*CCS, getDocComment(Ctx, SymbolCompletion,
   /*CommentsFromHeaders=*/true));
-  // For symbols not indexed for completion (class members), we also store 
their
-  // docs in the index, because Sema doesn't load the docs from the preamble, 
we
-  // rely on the index to get the docs.
-  // FIXME: this can be optimized by only storing the docs in dynamic index --
-  // dynamic index should index these symbols when Sema completes a member
-  // completion.
-  S.Documentation = Documentation;
   if (!(S.Flags & Symbol::IndexedForCodeCompletion)) {
+if (Opts.StoreAllDocumentation)
+  S.Documentation = Documentation;
 Symbols.insert(S);
 return Symbols.find(S.ID);
   }
-
+  S.Documentation = Documentation;
   std::string Signature;
   std::string SnippetSuffix;
   getSignature(*CCS, , );

Modified: clang-tools-extra/trunk/clangd/index/SymbolCollector.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/SymbolCollector.h?rev=354792=354791=354792=diff
==
--- clang-tools-extra/trunk/clangd/index/SymbolCollector.h (original)
+++ clang-tools-extra/trunk/clangd/index/SymbolCollector.h Mon Feb 25 08:00:00 
2019
@@ -75,6 +75,10 @@ public:
 /// Collect symbols local to main-files, such as static functions
 /// and symbols inside an anonymous namespace.
 bool CollectMainFileSymbols = true;
+/// If set to true, SymbolCollector will collect doc for all symbols.
+/// Note that documents of symbols being indexed for completion will always
+/// be collected regardless of this option.
+bool StoreAllDocumentation = false;
 /// If this is set, only collect symbols/references from a file if
 /// `FileFilter(SM, FID)` is true. If not 

[PATCH] D58612: Use std::atomic<> for static counters.

2019-02-25 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno accepted this revision.
riccibruno added a comment.
This revision is now accepted and ready to land.

Sounds good. LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58612



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


[PATCH] D58569: [libclang] Avoid crashing when getting layout info of an undeduced type.

2019-02-25 Thread Emilio Cobos Álvarez via Phabricator via cfe-commits
emilio marked 2 inline comments as done.
emilio added inline comments.



Comment at: clang/tools/c-index-test/c-index-test.c:1695
+CXType RT = clang_getResultType(T);
+if (RT.kind != CXType_Invalid)
+  PrintSingleTypeSize(RT, " [resulttype=%s] [resulttypekind=%s]",

Anastasia wrote:
> Should it not return undeduced error in the other case?
I'm not sure what you mean, can you clarify?

The undeduced error is only returned when you try to access the `Auto` type 
which is the return value, not the function type, which has a known layout.

So in the error case, `T` here is the `auto Tie(void*) const;` type, and `RT` 
is the undeduced `auto` type, which is what crashed.

We had no way to exercise this in `c-index-test`, so I changed it to exercise 
this codepath too. I can add a `CHECK` for the error code if you want.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58569



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


[PATCH] D58612: Use std::atomic<> for static counters.

2019-02-25 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

In D58612#1409024 , @riccibruno wrote:

> In D58612#1408991 , @alexfh wrote:
>
> > In D58612#1408942 , @riccibruno 
> > wrote:
> >
> > > Okay, but what about the other similar uses of static members which have 
> > > the same problem ?
> >
> >
> > Do you have any example in mind? I've only seen TSan warnings for these 
> > counters, nothing else so far.
>
>
> For example in `DeclBase.cpp`
>
>   #define DECL(DERIVED, BASE) static int n##DERIVED##s = 0;
>   #define ABSTRACT_DECL(DECL)
>   #include "clang/AST/DeclNodes.inc"
>
>
> which count the number of declaration node of each kind.




In D58612#1409024 , @riccibruno wrote:

> In D58612#1408991 , @alexfh wrote:
>
> > In D58612#1408942 , @riccibruno 
> > wrote:
> >
> > > Okay, but what about the other similar uses of static members which have 
> > > the same problem ?
> >
> >
> > Do you have any example in mind? I've only seen TSan warnings for these 
> > counters, nothing else so far.
>
>
> For example in `DeclBase.cpp`
>
>   #define DECL(DERIVED, BASE) static int n##DERIVED##s = 0;
>   #define ABSTRACT_DECL(DECL)
>   #include "clang/AST/DeclNodes.inc"
>
>
> which count the number of declaration node of each kind.


These are probably easier to convert to std::atomic, but I'd do this 
separately.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58612



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


[PATCH] D58504: [OpenCL][8.0.0 Release] Notes for OpenCL

2019-02-25 Thread Hans Wennborg via Phabricator via cfe-commits
hans added inline comments.



Comment at: docs/ReleaseNotes.rst:228
 
-OpenCL C Language Changes in Clang
+OpenCL Language Changes in Clang
 --

Anastasia wrote:
> Anastasia wrote:
> > AlexeySotkin wrote:
> > > AlexeySotkin wrote:
> > > > Why the "C" is removed ?
> > > Should we call the section like: "OpenCL Support in Clang"?
> > I would like to leave "Changes" in as it described the difference in this 
> > release. And I think "Language" should stay to be more precise that this 
> > doesn't cover libraries or runtime.
> > 
> > So I was think of either:
> > `OpenCL Kernel Language Change in Clang`
> >  or
> > `'OpenCL C/C++ Language Changes in Clang'`
> > 
> > I am a bit worried about the last one since it might link to the OpenCL C++ 
> > spec... even though it was used in the past release notes... but now that 
> > the direction has been changed I am not sure. Any opinion?
> We might need to finalize this quickly. @hans when is the last day to commit 
> this to the release branch?
Within a day or two would be good.

But it looks like it got accepted now. Will you commit to the branch, or would 
you like me to do it for you?


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

https://reviews.llvm.org/D58504



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


[PATCH] D56539: [clangd] Drop documentation in static index if symbols are not indexed for completion.

2019-02-25 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 188176.
hokein marked an inline comment as done.
hokein added a comment.
Herald added a subscriber: jdoerfert.
Herald added a project: clang.

Rebase and address comment.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D56539

Files:
  clangd/index/FileIndex.cpp
  clangd/index/IndexAction.cpp
  clangd/index/SymbolCollector.cpp
  clangd/index/SymbolCollector.h
  unittests/clangd/SymbolCollectorTests.cpp

Index: unittests/clangd/SymbolCollectorTests.cpp
===
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -212,6 +212,12 @@
 return WrapperFrontendAction::CreateASTConsumer(CI, InFile);
   }
 
+  bool BeginInvocation(CompilerInstance ) override {
+// Make the compiler parse all comments.
+CI.getLangOpts().CommentOpts.ParseAllComments = true;
+return WrapperFrontendAction::BeginInvocation(CI);
+  }
+
 private:
   index::IndexingOptions IndexOpts;
   CommentHandler *PragmaHandler;
@@ -710,6 +716,31 @@
QName("main_f")));
 }
 
+TEST_F(SymbolCollectorTest, Documentation) {
+  const std::string Header = R"(
+// Doc Foo
+class Foo {
+  // Doc f
+  int f();
+};
+  )";
+  CollectorOpts.StoreAllDocumentation = false;
+  runSymbolCollector(Header, /* Main */ "");
+  EXPECT_THAT(Symbols,
+  UnorderedElementsAre(
+  AllOf(QName("Foo"), Doc("Doc Foo"), ForCodeCompletion(true)),
+  AllOf(QName("Foo::f"), Doc(""), ReturnType(""),
+ForCodeCompletion(false;
+
+  CollectorOpts.StoreAllDocumentation = true;
+  runSymbolCollector(Header, /* Main */ "");
+  EXPECT_THAT(Symbols,
+  UnorderedElementsAre(
+  AllOf(QName("Foo"), Doc("Doc Foo"), ForCodeCompletion(true)),
+  AllOf(QName("Foo::f"), Doc("Doc f"), ReturnType(""),
+ForCodeCompletion(false;
+}
+
 TEST_F(SymbolCollectorTest, ClassMembers) {
   const std::string Header = R"(
 class Foo {
Index: clangd/index/SymbolCollector.h
===
--- clangd/index/SymbolCollector.h
+++ clangd/index/SymbolCollector.h
@@ -75,6 +75,10 @@
 /// Collect symbols local to main-files, such as static functions
 /// and symbols inside an anonymous namespace.
 bool CollectMainFileSymbols = true;
+/// If set to true, SymbolCollector will collect doc for all symbols.
+/// Note that documents of symbols being indexed for completion will always
+/// be collected regardless of this option.
+bool StoreAllDocumentation = false;
 /// If this is set, only collect symbols/references from a file if
 /// `FileFilter(SM, FID)` is true. If not set, all files are indexed.
 std::function FileFilter = nullptr;
Index: clangd/index/SymbolCollector.cpp
===
--- clangd/index/SymbolCollector.cpp
+++ clangd/index/SymbolCollector.cpp
@@ -566,18 +566,13 @@
   std::string Documentation =
   formatDocumentation(*CCS, getDocComment(Ctx, SymbolCompletion,
   /*CommentsFromHeaders=*/true));
-  // For symbols not indexed for completion (class members), we also store their
-  // docs in the index, because Sema doesn't load the docs from the preamble, we
-  // rely on the index to get the docs.
-  // FIXME: this can be optimized by only storing the docs in dynamic index --
-  // dynamic index should index these symbols when Sema completes a member
-  // completion.
-  S.Documentation = Documentation;
   if (!(S.Flags & Symbol::IndexedForCodeCompletion)) {
+if (Opts.StoreAllDocumentation)
+  S.Documentation = Documentation;
 Symbols.insert(S);
 return Symbols.find(S.ID);
   }
-
+  S.Documentation = Documentation;
   std::string Signature;
   std::string SnippetSuffix;
   getSignature(*CCS, , );
Index: clangd/index/IndexAction.cpp
===
--- clangd/index/IndexAction.cpp
+++ clangd/index/IndexAction.cpp
@@ -175,6 +175,7 @@
   Opts.CollectIncludePath = true;
   Opts.CountReferences = true;
   Opts.Origin = SymbolOrigin::Static;
+  Opts.StoreAllDocumentation = false;
   if (RefsCallback != nullptr) {
 Opts.RefFilter = RefKind::All;
 Opts.RefsInHeaders = true;
Index: clangd/index/FileIndex.cpp
===
--- clangd/index/FileIndex.cpp
+++ clangd/index/FileIndex.cpp
@@ -45,9 +45,13 @@
   if (IsIndexMainAST) {
 // We only collect refs when indexing main AST.
 CollectorOpts.RefFilter = RefKind::All;
+// comments for main file can always be obtained from sema, do not store
+// them in the index.
+

[PATCH] D57914: [Driver] Allow enum SanitizerOrdinal to represent more than 64 different sanitizer checks, NFC.

2019-02-25 Thread pierre gousseau via Phabricator via cfe-commits
pgousseau marked 2 inline comments as done.
pgousseau added inline comments.



Comment at: include/clang/Basic/Sanitizers.h:54
+  static constexpr bool
+  checkBitPos(const SanitizerKind::SanitizerOrdinal ) {
+return Pos < kNumBits;

riccibruno wrote:
> `SanitizerOrdinal` should probably be passed by value here and elsewhere.
Yes I meant to initially, done now thanks!


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

https://reviews.llvm.org/D57914



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


[PATCH] D57914: [Driver] Allow enum SanitizerOrdinal to represent more than 64 different sanitizer checks, NFC.

2019-02-25 Thread pierre gousseau via Phabricator via cfe-commits
pgousseau updated this revision to Diff 188175.
pgousseau added a comment.

Keep `enum SanitizerOrdinal` as it was inside `SanitizerKind` namespace, fix 
comment.


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

https://reviews.llvm.org/D57914

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/Sanitizers.def
  include/clang/Basic/Sanitizers.h
  include/clang/Driver/ToolChain.h
  lib/Basic/SanitizerSpecialCaseList.cpp
  lib/Basic/Sanitizers.cpp
  lib/CodeGen/CGExpr.cpp
  lib/Driver/SanitizerArgs.cpp
  lib/Driver/ToolChain.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Sema/SemaDeclAttr.cpp

Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -6211,7 +6211,8 @@
 if (!S.checkStringLiteralArgumentAttr(AL, I, SanitizerName, ))
   return;
 
-if (parseSanitizerValue(SanitizerName, /*AllowGroups=*/true) == 0)
+if (parseSanitizerValue(SanitizerName, /*AllowGroups=*/true) ==
+SanitizerMask())
   S.Diag(LiteralLoc, diag::warn_unknown_sanitizer_ignored) << SanitizerName;
 else if (isGlobalVar(D) && SanitizerName != "address")
   S.Diag(D->getLocation(), diag::err_attribute_wrong_decl_type)
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -551,7 +551,7 @@
 DiagnosticsEngine , SanitizerSet ) {
   for (const auto  : Sanitizers) {
 SanitizerMask K = parseSanitizerValue(Sanitizer, /*AllowGroups=*/false);
-if (K == 0)
+if (K == SanitizerMask())
   Diags.Report(diag::err_drv_invalid_value) << FlagName << Sanitizer;
 else
   S.set(K, true);
Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -818,21 +818,23 @@
   // Return sanitizers which don't require runtime support and are not
   // platform dependent.
 
-  using namespace SanitizerKind;
-
-  SanitizerMask Res = (Undefined & ~Vptr & ~Function) | (CFI & ~CFIICall) |
-  CFICastStrict | UnsignedIntegerOverflow |
-  ImplicitConversion | Nullability | LocalBounds;
+  SanitizerMask Res = (SanitizerKind::Undefined & ~SanitizerKind::Vptr &
+   ~SanitizerKind::Function) |
+  (SanitizerKind::CFI & ~SanitizerKind::CFIICall) |
+  SanitizerKind::CFICastStrict |
+  SanitizerKind::UnsignedIntegerOverflow |
+  SanitizerKind::ImplicitConversion |
+  SanitizerKind::Nullability | SanitizerKind::LocalBounds;
   if (getTriple().getArch() == llvm::Triple::x86 ||
   getTriple().getArch() == llvm::Triple::x86_64 ||
   getTriple().getArch() == llvm::Triple::arm ||
   getTriple().getArch() == llvm::Triple::aarch64 ||
   getTriple().getArch() == llvm::Triple::wasm32 ||
   getTriple().getArch() == llvm::Triple::wasm64)
-Res |= CFIICall;
+Res |= SanitizerKind::CFIICall;
   if (getTriple().getArch() == llvm::Triple::x86_64 ||
   getTriple().getArch() == llvm::Triple::aarch64)
-Res |= ShadowCallStack;
+Res |= SanitizerKind::ShadowCallStack;
   return Res;
 }
 
Index: lib/Driver/SanitizerArgs.cpp
===
--- lib/Driver/SanitizerArgs.cpp
+++ lib/Driver/SanitizerArgs.cpp
@@ -21,33 +21,52 @@
 #include 
 
 using namespace clang;
-using namespace clang::SanitizerKind;
 using namespace clang::driver;
 using namespace llvm::opt;
 
-enum : SanitizerMask {
-  NeedsUbsanRt = Undefined | Integer | ImplicitConversion | Nullability | CFI,
-  NeedsUbsanCxxRt = Vptr | CFI,
-  NotAllowedWithTrap = Vptr,
-  NotAllowedWithMinimalRuntime = Vptr,
-  RequiresPIE = DataFlow | HWAddress | Scudo,
-  NeedsUnwindTables = Address | HWAddress | Thread | Memory | DataFlow,
-  SupportsCoverage = Address | HWAddress | KernelAddress | KernelHWAddress |
- Memory | KernelMemory | Leak | Undefined | Integer |
- ImplicitConversion | Nullability | DataFlow | Fuzzer |
- FuzzerNoLink,
-  RecoverableByDefault = Undefined | Integer | ImplicitConversion | Nullability,
-  Unrecoverable = Unreachable | Return,
-  AlwaysRecoverable = KernelAddress | KernelHWAddress,
-  LegacyFsanitizeRecoverMask = Undefined | Integer,
-  NeedsLTO = CFI,
-  TrappingSupported = (Undefined & ~Vptr) | UnsignedIntegerOverflow |
-  ImplicitConversion | Nullability | LocalBounds | CFI,
-  TrappingDefault = CFI,
-  CFIClasses =
-  CFIVCall | CFINVCall | CFIMFCall | CFIDerivedCast | CFIUnrelatedCast,
-  CompatibleWithMinimalRuntime = TrappingSupported | Scudo | ShadowCallStack,
-};
+static const SanitizerMask NeedsUbsanRt =
+SanitizerKind::Undefined | 

[PATCH] D58623: [AMDGPU] Allow using integral non-type template parameters

2019-02-25 Thread Michael Liao via Phabricator via cfe-commits
hliao added a comment.

non-type template parameter is used in these attributes in one of major 
workload. In addition, it also revises the constexpr support by allowing 
lvalue. The diagnostic message is refined too by pointing out which parameter 
violates the requirement of constant integer. Previous tests are revised and 
more tests are added to cover the cases fixed in this change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58623



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


[PATCH] D58612: Use std::atomic<> for static counters.

2019-02-25 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added a comment.

In D58612#1408991 , @alexfh wrote:

> In D58612#1408942 , @riccibruno 
> wrote:
>
> > Okay, but what about the other similar uses of static members which have 
> > the same problem ?
>
>
> Do you have any example in mind? I've only seen TSan warnings for these 
> counters, nothing else so far.


For example in `DeclBase.cpp`

  #define DECL(DERIVED, BASE) static int n##DERIVED##s = 0;
  #define ABSTRACT_DECL(DECL)
  #include "clang/AST/DeclNodes.inc"

which count the number of declaration node of each kind.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58612



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


  1   2   >