[PATCH] D58606: [clang-tidy] misc-string-integer-assignment: fix false positive

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

- add more tests
- Traverse using decls.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D58606

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
@@ -53,8 +53,8 @@
 
   std::basic_string as;
   as = 6;
-// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: an integer is interpreted as a 
chara
-// CHECK-FIXES: {{^}}  as = 6;{{$}}
+  as = static_cast(6);
+  as = 'a';
 
   s += toupper(x);
   s += tolower(x);
Index: clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
===
--- clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
+++ clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
@@ -26,7 +26,8 @@
 hasOverloadedOperatorName("+=")),
   callee(cxxMethodDecl(ofClass(classTemplateSpecializationDecl(
   hasName("::std::basic_string"),
-  hasTemplateArgument(0, 
refersToType(qualType().bind("type"))),
+  hasTemplateArgument(0, refersToType(hasCanonicalType(
+ qualType().bind("type",
   hasArgument(
   1,
   ignoringImpCasts(
@@ -34,7 +35,11 @@
// Ignore calls to tolower/toupper (see PR27723).
unless(callExpr(callee(functionDecl(
hasAnyName("tolower", "std::tolower", "toupper",
-  "std::toupper"))
+  "std::toupper"),
+   // Do not warn if assigning e.g. `CodePoint` to
+   // `basic_string`
+   unless(hasType(qualType(
+   hasCanonicalType(equalsBoundNode("type"))
   .bind("expr"))),
   unless(isInTemplateInstantiation())),
   this);


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
@@ -53,8 +53,8 @@
 
   std::basic_string as;
   as = 6;
-// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: an integer is interpreted as a chara
-// CHECK-FIXES: {{^}}  as = 6;{{$}}
+  as = static_cast(6);
+  as = 'a';
 
   s += toupper(x);
   s += tolower(x);
Index: clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
===
--- clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
+++ clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
@@ -26,7 +26,8 @@
 hasOverloadedOperatorName("+=")),
   callee(cxxMethodDecl(ofClass(classTemplateSpecializationDecl(
   hasName("::std::basic_string"),
-  hasTemplateArgument(0, refersToType(qualType().bind("type"))),
+  hasTemplateArgument(0, refersToType(hasCanonicalType(
+ qualType().bind("type",
   hasArgument(
   1,
   ignoringImpCasts(
@@ -34,7 +35,11 @@
// Ignore calls to tolower/toupper (see PR27723).
unless(callExpr(callee(functionDecl(
hasAnyName("tolower", "std::tolower", "toupper",
-  "std::toupper"))
+  "std::toupper"),
+   // Do not warn if assigning e.g. `CodePoint` to
+   // `basic_string`
+   unless(hasType(qualType(
+   hasCanonicalType(equalsBoundNode("type"))
   .bind("expr"))),
   unless(isInTemplateInstantiation())),
   this);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58448: [clangd] Improve global code completion when scope specifier is unresolved.

2019-02-26 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

LG

Do we have any metrics regarding change in completion quality?


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D58448



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


[PATCH] D58665: [analyzer] Handle comparison between non-default AS symbol and constant

2019-02-26 Thread David Stenberg via Phabricator via cfe-commits
dstenb created this revision.
dstenb added reviewers: NoQ, zaks.anna, george.karpenkov.
Herald added subscribers: cfe-commits, Charusso, jdoerfert, dkrupp, donat.nagy, 
Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun.
Herald added a project: clang.

When comparing a symbolic region and a constant, the constant would be
widened or truncated to the width of a void pointer, meaning that the
constant could be incorrectly truncated when handling symbols for
non-default address spaces. In the attached test case this resulted in a
false positive since the constant was truncated to zero. To fix this,
widen/truncate the constant to the width of the symbol expression's
type.

This commit does not consider non-symbolic regions as I'm not sure how
to generalize getting the type there.

This fixes PR40814.


Repository:
  rC Clang

https://reviews.llvm.org/D58665

Files:
  lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  test/Analysis/ptr-cmp-const-trunc.cl


Index: test/Analysis/ptr-cmp-const-trunc.cl
===
--- /dev/null
+++ test/Analysis/ptr-cmp-const-trunc.cl
@@ -0,0 +1,11 @@
+//RUN: %clang_analyze_cc1 -triple amdgcn-unknown-unknown -analyze 
-analyzer-checker=core -verify %s
+// expected-no-diagnostics
+
+#include 
+
+void bar(__global int *p) __attribute__((nonnull(1)));
+
+void foo(__global int *p) {
+  if ((uint64_t)p <= 1UL << 32)
+bar(p);
+}
Index: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -571,7 +571,11 @@
   // add 1 to a LocAsInteger, we'd better unpack the Loc and add to it,
   // then pack it back into a LocAsInteger.
   llvm::APSInt i = rhs.castAs().getValue();
-  BasicVals.getAPSIntType(Context.VoidPtrTy).apply(i);
+  // FIXME: Handle non-default address spaces for non-symbolic regions.
+  if (SymbolRef lSym = lhs.getAsLocSymbol(true))
+BasicVals.getAPSIntType(lSym->getType()).apply(i);
+  else
+BasicVals.getAPSIntType(Context.VoidPtrTy).apply(i);
   return evalBinOpLL(state, op, lhsL, makeLoc(i), resultTy);
 }
 default:


Index: test/Analysis/ptr-cmp-const-trunc.cl
===
--- /dev/null
+++ test/Analysis/ptr-cmp-const-trunc.cl
@@ -0,0 +1,11 @@
+//RUN: %clang_analyze_cc1 -triple amdgcn-unknown-unknown -analyze -analyzer-checker=core -verify %s
+// expected-no-diagnostics
+
+#include 
+
+void bar(__global int *p) __attribute__((nonnull(1)));
+
+void foo(__global int *p) {
+  if ((uint64_t)p <= 1UL << 32)
+bar(p);
+}
Index: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -571,7 +571,11 @@
   // add 1 to a LocAsInteger, we'd better unpack the Loc and add to it,
   // then pack it back into a LocAsInteger.
   llvm::APSInt i = rhs.castAs().getValue();
-  BasicVals.getAPSIntType(Context.VoidPtrTy).apply(i);
+  // FIXME: Handle non-default address spaces for non-symbolic regions.
+  if (SymbolRef lSym = lhs.getAsLocSymbol(true))
+BasicVals.getAPSIntType(lSym->getType()).apply(i);
+  else
+BasicVals.getAPSIntType(Context.VoidPtrTy).apply(i);
   return evalBinOpLL(state, op, lhsL, makeLoc(i), resultTy);
 }
 default:
___
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-26 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

Many thanks!


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] D58663: [ASTImporter] Add support for importing ChooseExpr AST nodes.

2019-02-26 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: clang/unittests/AST/ASTImporterTest.cpp:1344
+
+  EXPECT_EQ(FromChooseExpr->isConditionTrue(), 
ToChooseExpr->isConditionTrue());
+}

To  compensate the  skipping of the template test, perhaps we should have 
another expectation for the condition dependency of the expression:
```
EXPECT_EQ(FromChooseExpr->isConditionDependent(), 
ToChooseExpr->isConditionDependent());
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58663



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


[PATCH] D57883: [clang-tidy] refactor ExceptionAnalyzer further to give ternary answer

2019-02-26 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth marked an inline comment as done.
JonasToth added inline comments.



Comment at: clang-tidy/utils/ExceptionAnalyzer.h:112
+/// throw, if it's unknown or if it won't throw.
+enum State Behaviour : 2;
+

bjope wrote:
> (post-commit comments)
> 
> I've seen that @dyung did some VS2015 fixes related to this in 
> https://reviews.llvm.org/rCTE354545.
> 
> But I think there also is some history of problems with typed enums used in 
> bitfields with GCC (I'm not sure about the details, but it might be discussed 
> here https://reviews.llvm.org/D24289, and there have been workarounds applied 
> before, for example here https://reviews.llvm.org/rCTE319608).
> 
> I do not know if we actually have a goal to workaround such problems (no 
> warnings when using GCC), nor do I know if GCC produce correct code despite 
> all the warnings we see with GCC (7.4.0) after this patch, such as
> 
> ```
> ../tools/clang/tools/extra/clang-tidy/bugprone/../utils/ExceptionAnalyzer.h:112:23:
>  warning: 'clang::tidy::utils::ExceptionAnalyzer::ExceptionInfo::Behaviour' 
> is too small to hold all values of 'enum class 
> clang::tidy::utils::ExceptionAnalyzer::State'
>   State Behaviour : 2;
> ^
> ../tools/clang/tools/extra/clang-tidy/bugprone/../utils/ExceptionAnalyzer.h:112:23:
>  warning: 'clang::tidy::utils::ExceptionAnalyzer::ExceptionInfo::Behaviour' 
> is too small to hold all values of 'enum class 
> clang::tidy::utils::ExceptionAnalyzer::State'
>  State Behaviour : 2;
>^
> In file included from 
> ../tools/clang/tools/extra/clang-tidy/utils/ExceptionAnalyzer.cpp:9:0:
> ../tools/clang/tools/extra/clang-tidy/utils/ExceptionAnalyzer.h:112:23: 
> warning: 'clang::tidy::utils::ExceptionAnalyzer::ExceptionInfo::Behaviour' is 
> too small to hold all values of 'enum class 
> clang::tidy::utils::ExceptionAnalyzer::State'
>  State Behaviour : 2;
>^
> ../tools/clang/tools/extra/clang-tidy/utils/ExceptionAnalyzer.cpp: In member 
> function 'clang::tidy::utils::ExceptionAnalyzer::ExceptionInfo& 
> clang::tidy::utils::ExceptionAnalyzer::ExceptionInfo::merge(const 
> clang::tidy::utils::ExceptionAnalyzer::ExceptionInfo&)':
> ../tools/clang/tools/extra/clang-tidy/utils/ExceptionAnalyzer.cpp:40:28: 
> warning: comparison is always false due to limited range of data type 
> [-Wtype-limits]
>else if (Other.Behaviour == State::Unknown && Behaviour == 
> State::NotThrowing)
> ^~~~
> ../tools/clang/tools/extra/clang-tidy/utils/ExceptionAnalyzer.cpp:41:24: 
> warning: overflow in implicit constant conversion [-Woverflow]
>  Behaviour = State::Unknown;
> ^~~
> ../tools/clang/tools/extra/clang-tidy/utils/ExceptionAnalyzer.cpp: In member 
> function 'void 
> clang::tidy::utils::ExceptionAnalyzer::ExceptionInfo::reevaluateBehaviour()':
> ../tools/clang/tools/extra/clang-tidy/utils/ExceptionAnalyzer.cpp:105:26: 
> warning: overflow in implicit constant conversion [-Woverflow]
>Behaviour = State::Unknown;
>   ^~~
> ```
> 
> To sum up:
> The warning are a little bit annoying (but maybe something we have to live 
> with if this is known bugs in gcc).
> It seems like we have done other workarounds in the past (writing ugly code 
> to satisfy MSVC and GCC). So should we do that here as well?
> Might wanna check if GCC produce correct code for this.
I see. All i wanted to achieve was to make the object <= 64 bytes to fit in a 
cacheline. IMHO the bitfields can disapear. I dont want to sacrifice the `enum 
class` as I feel that gives more value then the (unmeasured) potential 
performance gain from shrinking the object sizes.

I will commit to remove the bitfields. Details can be figured out later.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D57883



___
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-26 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki added inline comments.



Comment at: llvm/lib/IR/Value.cpp:651
   if (auto *GO = dyn_cast(this)) {
 // Don't make any assumptions about function pointer alignment. Some
 // targets use the LSBs to store additional information.

This comment needs to be updated


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


Re: [PATCH] D58448: [clangd] Improve global code completion when scope specifier is unresolved.

2019-02-26 Thread Eric Liu via cfe-commits
Unfortunately, the evaluation tool I use only works on compilable code, so
it doesn't capture the unsolved specifier case in this patch. I didn't try
to collect the metrics because I think this is more of a bug fix than
quality improvement.

On Tue, Feb 26, 2019, 10:25 Kadir Cetinkaya via Phabricator <
revi...@reviews.llvm.org> wrote:

> kadircet added a comment.
>
> LG
>
> Do we have any metrics regarding change in completion quality?
>
>
> Repository:
>   rCTE Clang Tools Extra
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D58448/new/
>
> https://reviews.llvm.org/D58448
>
>
>
>
___
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-26 Thread Michael Platings via Phabricator via cfe-commits
michaelplatings updated this revision to Diff 188324.

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/DataLayout.h
  llvm/lib/IR/ConstantFold.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/ConstantsTest.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, c);
+  EXPECT_NE(b, c);
+
+  a = b;
+  EXPECT_EQ(a, b);
+  a = c;
+  EXPECT_EQ(a, c);
+}
+
+}  // anonymous namespace
Index: llvm/unittests/IR/ConstantsTest.cpp
===
--- llvm/unittests/IR/ConstantsTest.cpp
+++ llvm/unittests/IR/ConstantsTest.cpp
@@ -475,5 +475,105 @@
   ASSERT_EQ(cast(C)->getOpcode(), Instruction::BitCast);
 }
 
+bool foldFuncPtrAndConstToNull(LLVMContext &Context, Module *TheModule,
+   uint64_t AndValue, unsigned FunctionAlign = 0) {
+  Type *VoidType(Type::getVoidTy(Context));
+  FunctionType *FuncType(FunctionType::get(VoidType, false));
+  Function *Func(Function::Create(
+  FuncType, GlobalValue::ExternalLinkage, "", TheModule));
+
+  if (FunctionAlign) Func->setAlignment(FunctionAlign);
+
+  IntegerType *ConstantIntType(Type::getInt32Ty(Context));
+  ConstantInt *TheConstant(ConstantInt::get(ConstantIntType, AndValue));
+
+  Constant *TheConstantExpr(
+  ConstantExpr::getPtrToInt(Func, ConstantIntType));
+
+  return ConstantExpr::g

[PATCH] D58340: [clang][Index] Visit UsingDecls and generate USRs for them

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



Comment at: include/clang/Index/IndexSymbol.h:75
   UsingValue,
+  UsingDeclaration,
 };

We don't seem to use the subkind anywhere. Let's remove it.



Comment at: unittests/Index/IndexTests.cpp:253
+  tooling::runToolOnCode(new IndexAction(Index, Opts), Code);
+  EXPECT_THAT(Index->Symbols, Contains(QName("std::foo")));
+}

Could we also test the kind is correct here?


Repository:
  rC Clang

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

https://reviews.llvm.org/D58340



___
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-26 Thread Michael Platings via Phabricator via cfe-commits
michaelplatings updated this revision to Diff 188325.

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/DataLayout.h
  llvm/lib/IR/ConstantFold.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/ConstantsTest.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, c);
+  EXPECT_NE(b, c);
+
+  a = b;
+  EXPECT_EQ(a, b);
+  a = c;
+  EXPECT_EQ(a, c);
+}
+
+}  // anonymous namespace
Index: llvm/unittests/IR/ConstantsTest.cpp
===
--- llvm/unittests/IR/ConstantsTest.cpp
+++ llvm/unittests/IR/ConstantsTest.cpp
@@ -475,5 +475,105 @@
   ASSERT_EQ(cast(C)->getOpcode(), Instruction::BitCast);
 }
 
+bool foldFuncPtrAndConstToNull(LLVMContext &Context, Module *TheModule,
+   uint64_t AndValue, unsigned FunctionAlign = 0) {
+  Type *VoidType(Type::getVoidTy(Context));
+  FunctionType *FuncType(FunctionType::get(VoidType, false));
+  Function *Func(Function::Create(
+  FuncType, GlobalValue::ExternalLinkage, "", TheModule));
+
+  if (FunctionAlign) Func->setAlignment(FunctionAlign);
+
+  IntegerType *ConstantIntType(Type::getInt32Ty(Context));
+  ConstantInt *TheConstant(ConstantInt::get(ConstantIntType, AndValue));
+
+  Constant *TheConstantExpr(
+  ConstantExpr::getPtrToInt(Func, ConstantIntType));
+
+  return ConstantExpr::g

Re: [PATCH] D58448: [clangd] Improve global code completion when scope specifier is unresolved.

2019-02-26 Thread Ilya Biryukov via cfe-commits
Slightly offtopic.

It would be nice to add a way to collect quality during actual completion
sessions, rather than simulated ones.
I'm thinking about clients sending a message to the server mentioning the
completion item user ended up selecting in a completion list (would require
an LSP extension).
I believe this should be enough information to collect metrics for the use
of code completion in the wild.


On Tue, Feb 26, 2019 at 11:04 AM Eric Liu  wrote:

> Unfortunately, the evaluation tool I use only works on compilable code, so
> it doesn't capture the unsolved specifier case in this patch. I didn't try
> to collect the metrics because I think this is more of a bug fix than
> quality improvement.
>
> On Tue, Feb 26, 2019, 10:25 Kadir Cetinkaya via Phabricator <
> revi...@reviews.llvm.org> wrote:
>
>> kadircet added a comment.
>>
>> LG
>>
>> Do we have any metrics regarding change in completion quality?
>>
>>
>> Repository:
>>   rCTE Clang Tools Extra
>>
>> CHANGES SINCE LAST ACTION
>>   https://reviews.llvm.org/D58448/new/
>>
>> https://reviews.llvm.org/D58448
>>
>>
>>
>>

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


Re: r354721 - Remove sanitizer context workaround no longer necessary

2019-02-26 Thread Hans Wennborg via cfe-commits
Merged to release_80 in r354858.

On Sat, Feb 23, 2019 at 7:18 AM Brad Smith via cfe-commits
 wrote:
>
> Author: brad
> Date: Fri Feb 22 22:19:28 2019
> New Revision: 354721
>
> URL: http://llvm.org/viewvc/llvm-project?rev=354721&view=rev
> Log:
> Remove sanitizer context workaround no longer necessary
>
> The base linker is now lld.
>
> Modified:
> cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp
>
> Modified: cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp?rev=354721&r1=354720&r2=354721&view=diff
> ==
> --- cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp (original)
> +++ cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp Fri Feb 22 22:19:28 2019
> @@ -226,9 +226,7 @@ void openbsd::Linker::ConstructJob(Compi
>  CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(crtend)));
>}
>
> -  const char *Exec = Args.MakeArgString(
> -  !NeedsSanitizerDeps ? ToolChain.GetLinkerPath()
> -  : ToolChain.GetProgramPath("ld.lld"));
> +  const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
>C.addCommand(llvm::make_unique(JA, *this, Exec, CmdArgs, Inputs));
>  }
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r354723 - Remove OpenBSD case for old system libstdc++ header path as OpenBSD

2019-02-26 Thread Hans Wennborg via cfe-commits
Merged to release_80 in r354859.

On Sat, Feb 23, 2019 at 8:20 AM Brad Smith via cfe-commits
 wrote:
>
> Author: brad
> Date: Fri Feb 22 23:21:19 2019
> New Revision: 354723
>
> URL: http://llvm.org/viewvc/llvm-project?rev=354723&view=rev
> Log:
> Remove OpenBSD case for old system libstdc++ header path as OpenBSD
> has switched to libc++.
>
> Modified:
> cfe/trunk/lib/Frontend/InitHeaderSearch.cpp
>
> Modified: cfe/trunk/lib/Frontend/InitHeaderSearch.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitHeaderSearch.cpp?rev=354723&r1=354722&r2=354723&view=diff
> ==
> --- cfe/trunk/lib/Frontend/InitHeaderSearch.cpp (original)
> +++ cfe/trunk/lib/Frontend/InitHeaderSearch.cpp Fri Feb 22 23:21:19 2019
> @@ -432,14 +432,6 @@ void InitHeaderSearch::AddDefaultCPlusPl
>case llvm::Triple::DragonFly:
>  AddPath("/usr/include/c++/5.0", CXXSystem, false);
>  break;
> -  case llvm::Triple::OpenBSD: {
> -std::string t = triple.getTriple();
> -if (t.substr(0, 6) == "x86_64")
> -  t.replace(0, 6, "amd64");
> -AddGnuCPlusPlusIncludePaths("/usr/include/g++",
> -t, "", "", triple);
> -break;
> -  }
>case llvm::Triple::Minix:
>  AddGnuCPlusPlusIncludePaths("/usr/gnu/include/c++/4.4.3",
>  "", "", "", triple);
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r354861 - CodeGen: Explicitly initialize structure padding in the -ftrivial-auto-var-init mode

2019-02-26 Thread Alexander Potapenko via cfe-commits
Author: glider
Date: Tue Feb 26 02:46:21 2019
New Revision: 354861

URL: http://llvm.org/viewvc/llvm-project?rev=354861&view=rev
Log:
CodeGen: Explicitly initialize structure padding in the -ftrivial-auto-var-init 
mode

When generating initializers for local structures in the
-ftrivial-auto-var-init mode, explicitly wipe the padding bytes with
either 0x00 or 0xAA.

This will allow us to automatically handle the padding when splitting
the initialization stores (see https://reviews.llvm.org/D57898).

Reviewed at https://reviews.llvm.org/D58188

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

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=354861&r1=354860&r2=354861&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Tue Feb 26 02:46:21 2019
@@ -1048,6 +1048,98 @@ static llvm::Constant *patternFor(CodeGe
   return llvm::ConstantStruct::get(StructTy, Struct);
 }
 
+enum class IsPattern { No, Yes };
+
+/// Generate a constant filled with either a pattern or zeroes.
+static llvm::Constant *patternOrZeroFor(CodeGenModule &CGM, IsPattern 
isPattern,
+llvm::Type *Ty) {
+  if (isPattern == IsPattern::Yes)
+return patternFor(CGM, Ty);
+  else
+return llvm::Constant::getNullValue(Ty);
+}
+
+static llvm::Constant *constWithPadding(CodeGenModule &CGM, IsPattern 
isPattern,
+llvm::Constant *constant);
+
+/// Helper function for constWithPadding() to deal with padding in structures.
+static llvm::Constant *constStructWithPadding(CodeGenModule &CGM,
+  IsPattern isPattern,
+  llvm::StructType *STy,
+  llvm::Constant *constant) {
+  const llvm::DataLayout &DL = CGM.getDataLayout();
+  const llvm::StructLayout *Layout = DL.getStructLayout(STy);
+  llvm::Type *Int8Ty = llvm::IntegerType::getInt8Ty(CGM.getLLVMContext());
+  unsigned SizeSoFar = 0;
+  SmallVector Values;
+  bool NestedIntact = true;
+  for (unsigned i = 0, e = STy->getNumElements(); i != e; i++) {
+unsigned CurOff = Layout->getElementOffset(i);
+if (SizeSoFar < CurOff) {
+  assert(!STy->isPacked());
+  auto *PadTy = llvm::ArrayType::get(Int8Ty, CurOff - SizeSoFar);
+  Values.push_back(patternOrZeroFor(CGM, isPattern, PadTy));
+}
+llvm::Constant *CurOp;
+if (constant->isZeroValue())
+  CurOp = llvm::Constant::getNullValue(STy->getElementType(i));
+else
+  CurOp = cast(constant->getAggregateElement(i));
+auto *NewOp = constWithPadding(CGM, isPattern, CurOp);
+if (CurOp != NewOp)
+  NestedIntact = false;
+Values.push_back(NewOp);
+SizeSoFar = CurOff + DL.getTypeAllocSize(CurOp->getType());
+  }
+  unsigned TotalSize = Layout->getSizeInBytes();
+  if (SizeSoFar < TotalSize) {
+auto *PadTy = llvm::ArrayType::get(Int8Ty, TotalSize - SizeSoFar);
+Values.push_back(patternOrZeroFor(CGM, isPattern, PadTy));
+  }
+  if (NestedIntact && Values.size() == STy->getNumElements())
+return constant;
+  return llvm::ConstantStruct::getAnon(Values);
+}
+
+/// Replace all padding bytes in a given constant with either a pattern byte or
+/// 0x00.
+static llvm::Constant *constWithPadding(CodeGenModule &CGM, IsPattern 
isPattern,
+llvm::Constant *constant) {
+  llvm::Type *OrigTy = constant->getType();
+  if (const auto STy = dyn_cast(OrigTy))
+return constStructWithPadding(CGM, isPattern, STy, constant);
+  if (auto *STy = dyn_cast(OrigTy)) {
+llvm::SmallVector Values;
+unsigned Size = STy->getNumElements();
+if (!Size)
+  return constant;
+llvm::Type *ElemTy = STy->getElementType();
+bool ZeroInitializer = constant->isZeroValue();
+llvm::Constant *OpValue, *PaddedOp;
+if (ZeroInitializer) {
+  OpValue = llvm::Constant::getNullValue(ElemTy);
+  PaddedOp = constWithPadding(CGM, isPattern, OpValue);
+}
+for (unsigned Op = 0; Op != Size; ++Op) {
+  if (!ZeroInitializer) {
+OpValue = constant->getAggregateElement(Op);
+PaddedOp = constWithPadding(CGM, isPattern, OpValue);
+  }
+  Values.push_back(PaddedOp);
+}
+auto *NewElemTy = Values[0]->getType();
+if (NewElemTy == ElemTy)
+  return constant;
+if (OrigTy->isArrayTy()) {
+  auto *ArrayTy = llvm::ArrayType::get(NewElemTy, Size);
+  return llvm::ConstantArray::get(ArrayTy, Values);
+} else {
+  return llvm::ConstantVector::get(Values);
+}
+  }
+  return constant;
+}
+
 static Address createUnnamedGlobalFrom(CodeGenModule &CGM, const VarDecl &D,
CGBuilderTy &Builder,
llvm:

r354864 - [CodeComplete] Propagate preferred type for function arguments in more cases

2019-02-26 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Tue Feb 26 03:01:50 2019
New Revision: 354864

URL: http://llvm.org/viewvc/llvm-project?rev=354864&view=rev
Log:
[CodeComplete] Propagate preferred type for function arguments in more cases

Summary:
See the added test for some new cases.
This change also removes special code completion calls inside the
ParseExpressionList function now that we properly propagate expected
type to the function responsible for parsing elements of the expression list
(ParseAssignmentExpression).

Reviewers: kadircet

Reviewed By: kadircet

Subscribers: xbolva00, jdoerfert, cfe-commits

Tags: #clang

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

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

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=354864&r1=354863&r2=354864&view=diff
==
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Tue Feb 26 03:01:50 2019
@@ -1680,10 +1680,10 @@ private:
   typedef SmallVector CommaLocsTy;
 
   /// ParseExpressionList - Used for C/C++ (argument-)expression-list.
-  bool ParseExpressionList(
-  SmallVectorImpl &Exprs,
-  SmallVectorImpl &CommaLocs,
-  llvm::function_ref Completer = llvm::function_ref());
+  bool ParseExpressionList(SmallVectorImpl &Exprs,
+   SmallVectorImpl &CommaLocs,
+   llvm::function_ref ExpressionStarts =
+   llvm::function_ref());
 
   /// ParseSimpleExpressionList - A simple comma-separated list of expressions,
   /// used for misc language extensions.

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=354864&r1=354863&r2=354864&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Tue Feb 26 03:01:50 2019
@@ -286,6 +286,14 @@ public:
   void enterCondition(Sema &S, SourceLocation Tok);
   void enterReturn(Sema &S, SourceLocation Tok);
   void enterVariableInit(SourceLocation Tok, Decl *D);
+  /// Computing a type for the function argument may require running
+  /// overloading, so we postpone its computation until it is actually needed.
+  ///
+  /// Clients should be very careful when using this funciton, as it stores a
+  /// function_ref, clients should make sure all calls to get() with the same
+  /// location happen while function_ref is alive.
+  void enterFunctionArgument(SourceLocation Tok,
+ llvm::function_ref ComputeType);
 
   void enterParenExpr(SourceLocation Tok, SourceLocation LParLoc);
   void enterUnary(Sema &S, SourceLocation Tok, tok::TokenKind OpKind,
@@ -297,8 +305,12 @@ public:
   void enterTypeCast(SourceLocation Tok, QualType CastType);
 
   QualType get(SourceLocation Tok) const {
-if (Tok == ExpectedLoc)
+if (Tok != ExpectedLoc)
+  return QualType();
+if (!Type.isNull())
   return Type;
+if (ComputeType)
+  return ComputeType();
 return QualType();
   }
 
@@ -307,6 +319,9 @@ private:
   SourceLocation ExpectedLoc;
   /// Expected type for a token starting at ExpectedLoc.
   QualType Type;
+  /// A function to compute expected type at ExpectedLoc. It is only considered
+  /// if Type is null.
+  llvm::function_ref ComputeType;
 };
 
 /// Sema - This implements semantic analysis and AST building for C.
@@ -9280,7 +9295,7 @@ public:
SourceLocation StartLoc,
SourceLocation LParenLoc,
SourceLocation EndLoc);
-  
+
   OMPClause *ActOnOpenMPSingleExprWithArgClause(
   OpenMPClauseKind Kind, ArrayRef Arguments, Expr *Expr,
   SourceLocation StartLoc, SourceLocation LParenLoc,
@@ -9335,7 +9350,7 @@ public:
   /// Called on well-formed 'unified_address' clause.
   OMPClause *ActOnOpenMPUnifiedSharedMemoryClause(SourceLocation StartLoc,
   SourceLocation EndLoc);
-  
+
   /// Called on well-formed 'reverse_offload' clause.
   OMPClause *ActOnOpenMPReverseOffloadClause(SourceLocation StartLoc,
  SourceLocation EndLoc);

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=354864&r1=354863&r2=354864&view=diff
===

[PATCH] D56718: [clangd] Update docs to mention YCM integration and new LSP features

2019-02-26 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 188327.
kadircet added a comment.
Herald added a project: clang.

- Revert YCM related parts


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D56718

Files:
  docs/clangd.rst


Index: docs/clangd.rst
===
--- docs/clangd.rst
+++ docs/clangd.rst
@@ -77,35 +77,35 @@
 +-++--+
 | Source hover| Yes|   Yes|
 +-++--+
-| Find References | Yes|   No |
-+-++--+
-| Code Lens   | Yes|   No |
+| Find References | Yes|   Yes|
 +-++--+
 | Document Symbols| Yes|   Yes|
 +-++--+
 | Workspace Symbols   | Yes|   Yes|
 +-++--+
-| Syntax and Semantic Coloring| No |   No |
+| Code Lens   | Yes|   No |
 +-++--+
-| Code folding| No |   No |
+| Code folding| Yes|   No |
 +-++--+
-| Call hierarchy  | No |   No |
+| Extract Local Variable  | Yes|   No |
 +-++--+
-| Type hierarchy  | No |   No |
+| Extract Function/Method | Yes|   No |
 +-++--+
-| Organize Includes   | No |   No |
+| Quick Assist| Yes|   No |
++-++--+
+| Hide Method | Yes|   No |
 +-++--+
-| Quick Assist| No |   No |
+| Implement Method| Yes|   No |
 +-++--+
-| Extract Local Variable  | No |   No |
+| Gen. Getters/Setters| Yes|   No |
 +-++--+
-| Extract Function/Method | No |   No |
+| Syntax and Semantic Coloring| No |   No |
 +-++--+
-| Hide Method | No |   No |
+| Call hierarchy  | No |   No |
 +-++--+
-| Implement Method| No |   No |
+| Type hierarchy  | No |   No |
 +-++--+
-| Gen. Getters/Setters| No |   No |
+| Organize Includes   | No |   No |
 +-++--+
 
 Editor Integration


Index: docs/clangd.rst
===
--- docs/clangd.rst
+++ docs/clangd.rst
@@ -77,35 +77,35 @@
 +-++--+
 | Source hover| Yes|   Yes|
 +-++--+
-| Find References | Yes|   No |
-+-++--+
-| Code Lens   | Yes|   No |
+| Find References | Yes|   Yes|
 +-++--+
 | Document Symbols| Yes|   Yes|
 +-++--+
 | Workspace Symbols   | Yes|   Yes|
 +-++--+
-| Syntax and Semantic Coloring| No |   No |
+| Code Lens   | Yes|   No |
 +-++--+
-| Code folding| No |   No |
+| Code folding| Yes|   No |
 +-++--+
-| Call hierarchy  | No |   No |
+| Extract Local Variable  | Yes|   No |
 +--

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

2019-02-26 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354864: [CodeComplete] Propagate preferred type for function 
arguments in more cases (authored by ibiryukov, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D58541?vs=188226&id=188328#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D58541

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

Index: cfe/trunk/include/clang/Parse/Parser.h
===
--- cfe/trunk/include/clang/Parse/Parser.h
+++ cfe/trunk/include/clang/Parse/Parser.h
@@ -1680,10 +1680,10 @@
   typedef SmallVector CommaLocsTy;
 
   /// ParseExpressionList - Used for C/C++ (argument-)expression-list.
-  bool ParseExpressionList(
-  SmallVectorImpl &Exprs,
-  SmallVectorImpl &CommaLocs,
-  llvm::function_ref Completer = llvm::function_ref());
+  bool ParseExpressionList(SmallVectorImpl &Exprs,
+   SmallVectorImpl &CommaLocs,
+   llvm::function_ref ExpressionStarts =
+   llvm::function_ref());
 
   /// ParseSimpleExpressionList - A simple comma-separated list of expressions,
   /// used for misc language extensions.
Index: cfe/trunk/include/clang/Sema/Sema.h
===
--- cfe/trunk/include/clang/Sema/Sema.h
+++ cfe/trunk/include/clang/Sema/Sema.h
@@ -286,6 +286,14 @@
   void enterCondition(Sema &S, SourceLocation Tok);
   void enterReturn(Sema &S, SourceLocation Tok);
   void enterVariableInit(SourceLocation Tok, Decl *D);
+  /// Computing a type for the function argument may require running
+  /// overloading, so we postpone its computation until it is actually needed.
+  ///
+  /// Clients should be very careful when using this funciton, as it stores a
+  /// function_ref, clients should make sure all calls to get() with the same
+  /// location happen while function_ref is alive.
+  void enterFunctionArgument(SourceLocation Tok,
+ llvm::function_ref ComputeType);
 
   void enterParenExpr(SourceLocation Tok, SourceLocation LParLoc);
   void enterUnary(Sema &S, SourceLocation Tok, tok::TokenKind OpKind,
@@ -297,8 +305,12 @@
   void enterTypeCast(SourceLocation Tok, QualType CastType);
 
   QualType get(SourceLocation Tok) const {
-if (Tok == ExpectedLoc)
+if (Tok != ExpectedLoc)
+  return QualType();
+if (!Type.isNull())
   return Type;
+if (ComputeType)
+  return ComputeType();
 return QualType();
   }
 
@@ -307,6 +319,9 @@
   SourceLocation ExpectedLoc;
   /// Expected type for a token starting at ExpectedLoc.
   QualType Type;
+  /// A function to compute expected type at ExpectedLoc. It is only considered
+  /// if Type is null.
+  llvm::function_ref ComputeType;
 };
 
 /// Sema - This implements semantic analysis and AST building for C.
@@ -9280,7 +9295,7 @@
SourceLocation StartLoc,
SourceLocation LParenLoc,
SourceLocation EndLoc);
-  
+
   OMPClause *ActOnOpenMPSingleExprWithArgClause(
   OpenMPClauseKind Kind, ArrayRef Arguments, Expr *Expr,
   SourceLocation StartLoc, SourceLocation LParenLoc,
@@ -9335,7 +9350,7 @@
   /// Called on well-formed 'unified_address' clause.
   OMPClause *ActOnOpenMPUnifiedSharedMemoryClause(SourceLocation StartLoc,
   SourceLocation EndLoc);
-  
+
   /// Called on well-formed 'reverse_offload' clause.
   OMPClause *ActOnOpenMPReverseOffloadClause(SourceLocation StartLoc,
  SourceLocation EndLoc);
Index: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
===
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp
@@ -350,13 +350,16 @@
 void PreferredTypeBuilder::enterReturn(Sema &S, 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 +

[clang-tools-extra] r354865 - [clangd] Update docs to mention YCM integration and new LSP features

2019-02-26 Thread Kadir Cetinkaya via cfe-commits
Author: kadircet
Date: Tue Feb 26 03:08:04 2019
New Revision: 354865

URL: http://llvm.org/viewvc/llvm-project?rev=354865&view=rev
Log:
[clangd] Update docs to mention YCM integration and new LSP features

Reviewers: gribozavr

Reviewed By: gribozavr

Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

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

Modified:
clang-tools-extra/trunk/docs/clangd/index.rst

Modified: clang-tools-extra/trunk/docs/clangd/index.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clangd/index.rst?rev=354865&r1=354864&r2=354865&view=diff
==
--- clang-tools-extra/trunk/docs/clangd/index.rst (original)
+++ clang-tools-extra/trunk/docs/clangd/index.rst Tue Feb 26 03:08:04 2019
@@ -77,35 +77,35 @@ extension to the protocol.
 +-++--+
 | Source hover| Yes|   Yes|
 +-++--+
-| Find References | Yes|   No |
-+-++--+
-| Code Lens   | Yes|   No |
+| Find References | Yes|   Yes|
 +-++--+
 | Document Symbols| Yes|   Yes|
 +-++--+
 | Workspace Symbols   | Yes|   Yes|
 +-++--+
-| Syntax and Semantic Coloring| No |   No |
+| Code Lens   | Yes|   No |
 +-++--+
-| Code folding| No |   No |
+| Code folding| Yes|   No |
 +-++--+
-| Call hierarchy  | No |   No |
+| Extract Local Variable  | Yes|   No |
 +-++--+
-| Type hierarchy  | No |   No |
+| Extract Function/Method | Yes|   No |
 +-++--+
-| Organize Includes   | No |   No |
+| Quick Assist| Yes|   No |
++-++--+
+| Hide Method | Yes|   No |
 +-++--+
-| Quick Assist| No |   No |
+| Implement Method| Yes|   No |
 +-++--+
-| Extract Local Variable  | No |   No |
+| Gen. Getters/Setters| Yes|   No |
 +-++--+
-| Extract Function/Method | No |   No |
+| Syntax and Semantic Coloring| No |   No |
 +-++--+
-| Hide Method | No |   No |
+| Call hierarchy  | No |   No |
 +-++--+
-| Implement Method| No |   No |
+| Type hierarchy  | No |   No |
 +-++--+
-| Gen. Getters/Setters| No |   No |
+| Organize Includes   | No |   No |
 +-++--+
 
 Editor Integration


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


[PATCH] D56718: [clangd] Update docs to mention YCM integration and new LSP features

2019-02-26 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 188329.
kadircet added a comment.

- Rebase


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D56718

Files:
  docs/clangd/index.rst


Index: docs/clangd/index.rst
===
--- docs/clangd/index.rst
+++ docs/clangd/index.rst
@@ -77,35 +77,35 @@
 +-++--+
 | Source hover| Yes|   Yes|
 +-++--+
-| Find References | Yes|   No |
-+-++--+
-| Code Lens   | Yes|   No |
+| Find References | Yes|   Yes|
 +-++--+
 | Document Symbols| Yes|   Yes|
 +-++--+
 | Workspace Symbols   | Yes|   Yes|
 +-++--+
-| Syntax and Semantic Coloring| No |   No |
+| Code Lens   | Yes|   No |
 +-++--+
-| Code folding| No |   No |
+| Code folding| Yes|   No |
 +-++--+
-| Call hierarchy  | No |   No |
+| Extract Local Variable  | Yes|   No |
 +-++--+
-| Type hierarchy  | No |   No |
+| Extract Function/Method | Yes|   No |
 +-++--+
-| Organize Includes   | No |   No |
+| Quick Assist| Yes|   No |
++-++--+
+| Hide Method | Yes|   No |
 +-++--+
-| Quick Assist| No |   No |
+| Implement Method| Yes|   No |
 +-++--+
-| Extract Local Variable  | No |   No |
+| Gen. Getters/Setters| Yes|   No |
 +-++--+
-| Extract Function/Method | No |   No |
+| Syntax and Semantic Coloring| No |   No |
 +-++--+
-| Hide Method | No |   No |
+| Call hierarchy  | No |   No |
 +-++--+
-| Implement Method| No |   No |
+| Type hierarchy  | No |   No |
 +-++--+
-| Gen. Getters/Setters| No |   No |
+| Organize Includes   | No |   No |
 +-++--+
 
 Editor Integration


Index: docs/clangd/index.rst
===
--- docs/clangd/index.rst
+++ docs/clangd/index.rst
@@ -77,35 +77,35 @@
 +-++--+
 | Source hover| Yes|   Yes|
 +-++--+
-| Find References | Yes|   No |
-+-++--+
-| Code Lens   | Yes|   No |
+| Find References | Yes|   Yes|
 +-++--+
 | Document Symbols| Yes|   Yes|
 +-++--+
 | Workspace Symbols   | Yes|   Yes|
 +-++--+
-| Syntax and Semantic Coloring| No |   No |
+| Code Lens   | Yes|   No |
 +-++--+
-| Code folding| No |   No |
+| Code folding| Yes|   No |
 +-++--+
-| Call hierarchy  | No |   No |
+| Extract Local Variable  | Yes|   No |
 +-

[PATCH] D56718: [clangd] Update docs to mention YCM integration and new LSP features

2019-02-26 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354865: [clangd] Update docs to mention YCM integration and 
new LSP features (authored by kadircet, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D56718

Files:
  clang-tools-extra/trunk/docs/clangd/index.rst


Index: clang-tools-extra/trunk/docs/clangd/index.rst
===
--- clang-tools-extra/trunk/docs/clangd/index.rst
+++ clang-tools-extra/trunk/docs/clangd/index.rst
@@ -77,35 +77,35 @@
 +-++--+
 | Source hover| Yes|   Yes|
 +-++--+
-| Find References | Yes|   No |
-+-++--+
-| Code Lens   | Yes|   No |
+| Find References | Yes|   Yes|
 +-++--+
 | Document Symbols| Yes|   Yes|
 +-++--+
 | Workspace Symbols   | Yes|   Yes|
 +-++--+
-| Syntax and Semantic Coloring| No |   No |
+| Code Lens   | Yes|   No |
 +-++--+
-| Code folding| No |   No |
+| Code folding| Yes|   No |
 +-++--+
-| Call hierarchy  | No |   No |
+| Extract Local Variable  | Yes|   No |
 +-++--+
-| Type hierarchy  | No |   No |
+| Extract Function/Method | Yes|   No |
 +-++--+
-| Organize Includes   | No |   No |
+| Quick Assist| Yes|   No |
++-++--+
+| Hide Method | Yes|   No |
 +-++--+
-| Quick Assist| No |   No |
+| Implement Method| Yes|   No |
 +-++--+
-| Extract Local Variable  | No |   No |
+| Gen. Getters/Setters| Yes|   No |
 +-++--+
-| Extract Function/Method | No |   No |
+| Syntax and Semantic Coloring| No |   No |
 +-++--+
-| Hide Method | No |   No |
+| Call hierarchy  | No |   No |
 +-++--+
-| Implement Method| No |   No |
+| Type hierarchy  | No |   No |
 +-++--+
-| Gen. Getters/Setters| No |   No |
+| Organize Includes   | No |   No |
 +-++--+
 
 Editor Integration


Index: clang-tools-extra/trunk/docs/clangd/index.rst
===
--- clang-tools-extra/trunk/docs/clangd/index.rst
+++ clang-tools-extra/trunk/docs/clangd/index.rst
@@ -77,35 +77,35 @@
 +-++--+
 | Source hover| Yes|   Yes|
 +-++--+
-| Find References | Yes|   No |
-+-++--+
-| Code Lens   | Yes|   No |
+| Find References | Yes|   Yes|
 +-++--+
 | Document Symbols| Yes|   Yes|
 +-++--+
 | Workspace Symbols   | Yes|   Yes|
 +-++--+
-| Syntax and Semantic Coloring| No |   No |
+| Code Lens   | Yes|   No |
 +-++--+
-|

[PATCH] D58666: [OpenCL] Undefine cl_intel_planar_yuv extension

2019-02-26 Thread Dmitry Sidorov via Phabricator via cfe-commits
sidorovd created this revision.
sidorovd added reviewers: Anastasia, yaxunl.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Consider the code:

  #pragma OPENCL EXTENSION cl_intel_planar_yuv : begin
  // some declarations
  #pragma OPENCL EXTENSION cl_intel_planar_yuv : end

is enough for extension to become known for clang.

Remove unnecessary definition (otherwise the extension will be define where 
it's not supposed to be defined).


Repository:
  rC Clang

https://reviews.llvm.org/D58666

Files:
  lib/Headers/opencl-c-common.h
  test/Headers/opencl-c-header.cl
  test/SemaOpenCL/extension-begin.cl


Index: test/SemaOpenCL/extension-begin.cl
===
--- test/SemaOpenCL/extension-begin.cl
+++ test/SemaOpenCL/extension-begin.cl
@@ -16,6 +16,13 @@
 //
 // RUN: %clang_cc1 -cl-std=CL2.0 -DIMPLICIT_INCLUDE -include 
%S/extension-begin.h -triple spir-unknown-unknown -O0 -emit-llvm -o - -fmodules 
-fimplicit-module-maps -fmodules-cache-path=%t.modules %s -verify -pedantic
 
+#pragma OPENCL EXTENSION my_ext : enable
+#ifndef IMPLICIT_INCLUDE
+// expected-warning@-2 {{unknown OpenCL extension 'my_ext' - ignoring}}
+// expected-warning@+2 {{unknown OpenCL extension 'my_ext' - ignoring}}
+#endif // IMPLICIT_INCLUDE
+#pragma OPENCL EXTENSION my_ext : disable
+
 #ifndef IMPLICIT_INCLUDE
 #include "extension-begin.h"
 #endif // IMPLICIT_INCLUDE
@@ -31,8 +38,8 @@
   f();
   g(0);
 }
+#pragma OPENCL EXTENSION my_ext : disable
 
-#pragma OPENCL EXTENSION my_ext : disable 
 void test_f2(void) {
   struct A test_A2; // expected-error {{use of type 'struct A' requires my_ext 
extension to be enabled}}
   const struct A test_A_local; // expected-error {{use of type 'struct A' 
requires my_ext extension to be enabled}}
@@ -43,4 +50,3 @@
 // expected-note@extension-begin.h:18 {{candidate unavailable as it 
requires OpenCL extension 'my_ext' to be enabled}}
 // expected-note@extension-begin.h:23 {{candidate function not viable: 
requires 0 arguments, but 1 was provided}}
 }
-
Index: test/Headers/opencl-c-header.cl
===
--- test/Headers/opencl-c-header.cl
+++ test/Headers/opencl-c-header.cl
@@ -77,9 +77,6 @@
 // OpenCL 1.2 onwards.
 #if (__OPENCL_C_VERSION__ >= CL_VERSION_1_2)
 // expected-no-diagnostics
-#ifndef cl_intel_planar_yuv
-#error "Missing cl_intel_planar_yuv define"
-#endif
 #else //__OPENCL_C_VERSION__
 // expected-warning@+2{{unknown OpenCL extension 'cl_intel_planar_yuv' - 
ignoring}}
 #endif //__OPENCL_C_VERSION__
Index: lib/Headers/opencl-c-common.h
===
--- lib/Headers/opencl-c-common.h
+++ lib/Headers/opencl-c-common.h
@@ -21,9 +21,6 @@
 #endif //__OPENCL_C_VERSION__ < CL_VERSION_2_0
 
 #if __OPENCL_C_VERSION__ >= CL_VERSION_1_2
-#ifndef cl_intel_planar_yuv
-#define cl_intel_planar_yuv
-#endif // cl_intel_planar_yuv
 #pragma OPENCL EXTENSION cl_intel_planar_yuv : begin
 #pragma OPENCL EXTENSION cl_intel_planar_yuv : end
 #endif // __OPENCL_C_VERSION__ >= CL_VERSION_1_2


Index: test/SemaOpenCL/extension-begin.cl
===
--- test/SemaOpenCL/extension-begin.cl
+++ test/SemaOpenCL/extension-begin.cl
@@ -16,6 +16,13 @@
 //
 // RUN: %clang_cc1 -cl-std=CL2.0 -DIMPLICIT_INCLUDE -include %S/extension-begin.h -triple spir-unknown-unknown -O0 -emit-llvm -o - -fmodules -fimplicit-module-maps -fmodules-cache-path=%t.modules %s -verify -pedantic
 
+#pragma OPENCL EXTENSION my_ext : enable
+#ifndef IMPLICIT_INCLUDE
+// expected-warning@-2 {{unknown OpenCL extension 'my_ext' - ignoring}}
+// expected-warning@+2 {{unknown OpenCL extension 'my_ext' - ignoring}}
+#endif // IMPLICIT_INCLUDE
+#pragma OPENCL EXTENSION my_ext : disable
+
 #ifndef IMPLICIT_INCLUDE
 #include "extension-begin.h"
 #endif // IMPLICIT_INCLUDE
@@ -31,8 +38,8 @@
   f();
   g(0);
 }
+#pragma OPENCL EXTENSION my_ext : disable
 
-#pragma OPENCL EXTENSION my_ext : disable 
 void test_f2(void) {
   struct A test_A2; // expected-error {{use of type 'struct A' requires my_ext extension to be enabled}}
   const struct A test_A_local; // expected-error {{use of type 'struct A' requires my_ext extension to be enabled}}
@@ -43,4 +50,3 @@
 // expected-note@extension-begin.h:18 {{candidate unavailable as it requires OpenCL extension 'my_ext' to be enabled}}
 // expected-note@extension-begin.h:23 {{candidate function not viable: requires 0 arguments, but 1 was provided}}
 }
-
Index: test/Headers/opencl-c-header.cl
===
--- test/Headers/opencl-c-header.cl
+++ test/Headers/opencl-c-header.cl
@@ -77,9 +77,6 @@
 // OpenCL 1.2 onwards.
 #if (__OPENCL_C_VERSION__ >= CL_VERSION_1_2)
 // expected-no-diagnostics
-#ifndef cl_intel_planar_yuv
-#error "Missing cl_intel_planar_yuv define"
-#endif
 #else //__OPENCL_C_VERSION__

[PATCH] D58666: [OpenCL] Undefine cl_intel_planar_yuv extension

2019-02-26 Thread Dmitry Sidorov via Phabricator via cfe-commits
sidorovd updated this revision to Diff 188338.

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

https://reviews.llvm.org/D58666

Files:
  lib/Headers/opencl-c.h
  test/Headers/opencl-c-header.cl
  test/SemaOpenCL/extension-begin.cl


Index: test/SemaOpenCL/extension-begin.cl
===
--- test/SemaOpenCL/extension-begin.cl
+++ test/SemaOpenCL/extension-begin.cl
@@ -16,6 +16,13 @@
 //
 // RUN: %clang_cc1 -cl-std=CL2.0 -DIMPLICIT_INCLUDE -include 
%S/extension-begin.h -triple spir-unknown-unknown -O0 -emit-llvm -o - -fmodules 
-fimplicit-module-maps -fmodules-cache-path=%t.modules %s -verify -pedantic
 
+#pragma OPENCL EXTENSION my_ext : enable
+#ifndef IMPLICIT_INCLUDE
+// expected-warning@-2 {{unknown OpenCL extension 'my_ext' - ignoring}}
+// expected-warning@+2 {{unknown OpenCL extension 'my_ext' - ignoring}}
+#endif // IMPLICIT_INCLUDE
+#pragma OPENCL EXTENSION my_ext : disable
+
 #ifndef IMPLICIT_INCLUDE
 #include "extension-begin.h"
 #endif // IMPLICIT_INCLUDE
Index: test/Headers/opencl-c-header.cl
===
--- test/Headers/opencl-c-header.cl
+++ test/Headers/opencl-c-header.cl
@@ -77,9 +77,6 @@
 // OpenCL 1.2 onwards.
 #if (__OPENCL_C_VERSION__ >= CL_VERSION_1_2)
 // expected-no-diagnostics
-#ifndef cl_intel_planar_yuv
-#error "Missing cl_intel_planar_yuv define"
-#endif
 #else //__OPENCL_C_VERSION__
 // expected-warning@+2{{unknown OpenCL extension 'cl_intel_planar_yuv' - 
ignoring}}
 #endif //__OPENCL_C_VERSION__
Index: lib/Headers/opencl-c.h
===
--- lib/Headers/opencl-c.h
+++ lib/Headers/opencl-c.h
@@ -22,9 +22,6 @@
 #endif //__OPENCL_C_VERSION__ < CL_VERSION_2_0
 
 #if __OPENCL_C_VERSION__ >= CL_VERSION_1_2
-#ifndef cl_intel_planar_yuv
-#define cl_intel_planar_yuv
-#endif // cl_intel_planar_yuv
 #pragma OPENCL EXTENSION cl_intel_planar_yuv : begin
 #pragma OPENCL EXTENSION cl_intel_planar_yuv : end
 #endif // __OPENCL_C_VERSION__ >= CL_VERSION_1_2


Index: test/SemaOpenCL/extension-begin.cl
===
--- test/SemaOpenCL/extension-begin.cl
+++ test/SemaOpenCL/extension-begin.cl
@@ -16,6 +16,13 @@
 //
 // RUN: %clang_cc1 -cl-std=CL2.0 -DIMPLICIT_INCLUDE -include %S/extension-begin.h -triple spir-unknown-unknown -O0 -emit-llvm -o - -fmodules -fimplicit-module-maps -fmodules-cache-path=%t.modules %s -verify -pedantic
 
+#pragma OPENCL EXTENSION my_ext : enable
+#ifndef IMPLICIT_INCLUDE
+// expected-warning@-2 {{unknown OpenCL extension 'my_ext' - ignoring}}
+// expected-warning@+2 {{unknown OpenCL extension 'my_ext' - ignoring}}
+#endif // IMPLICIT_INCLUDE
+#pragma OPENCL EXTENSION my_ext : disable
+
 #ifndef IMPLICIT_INCLUDE
 #include "extension-begin.h"
 #endif // IMPLICIT_INCLUDE
Index: test/Headers/opencl-c-header.cl
===
--- test/Headers/opencl-c-header.cl
+++ test/Headers/opencl-c-header.cl
@@ -77,9 +77,6 @@
 // OpenCL 1.2 onwards.
 #if (__OPENCL_C_VERSION__ >= CL_VERSION_1_2)
 // expected-no-diagnostics
-#ifndef cl_intel_planar_yuv
-#error "Missing cl_intel_planar_yuv define"
-#endif
 #else //__OPENCL_C_VERSION__
 // expected-warning@+2{{unknown OpenCL extension 'cl_intel_planar_yuv' - ignoring}}
 #endif //__OPENCL_C_VERSION__
Index: lib/Headers/opencl-c.h
===
--- lib/Headers/opencl-c.h
+++ lib/Headers/opencl-c.h
@@ -22,9 +22,6 @@
 #endif //__OPENCL_C_VERSION__ < CL_VERSION_2_0
 
 #if __OPENCL_C_VERSION__ >= CL_VERSION_1_2
-#ifndef cl_intel_planar_yuv
-#define cl_intel_planar_yuv
-#endif // cl_intel_planar_yuv
 #pragma OPENCL EXTENSION cl_intel_planar_yuv : begin
 #pragma OPENCL EXTENSION cl_intel_planar_yuv : end
 #endif // __OPENCL_C_VERSION__ >= CL_VERSION_1_2
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58666: [OpenCL] Undefine cl_intel_planar_yuv extension

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



Comment at: test/SemaOpenCL/extension-begin.cl:26
+
 #ifndef IMPLICIT_INCLUDE
 #include "extension-begin.h"

Can we also test that macro `my_ext` is not defined here but defined above?

It seems we are not testing anything like this...


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

https://reviews.llvm.org/D58666



___
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-26 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks!


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-26 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));

rjmccall wrote:
> 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?
> 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.

Would this mean we can map AST address spaces into different IR ones from what 
is the the target address space map? Ok right, null pointer value can't be 
handled by the target address space map at all. I am a bit confused though why 
we are not using these LangAS at the moment. I guess we just don't have 
upstream targets requiring that...


> is there maybe a missing implicit conversions somewhere?

Ok, the AST dump doesn't seem right for the test case I included. 
`MaterializeTemporaryExpr` is in `generic` addr space. I guess it should be 
`private`... and then converted to `generic`.

```
`-FunctionDecl 0x712608  line:5:6 foo 'void ()'
  `-CompoundStmt 0x712810 
`-ExprWithCleanups 0x7127f8  'int'
  `-CallExpr 0x7127a0  'int'
|-ImplicitCastExpr 0x712788  'int (*)(const __generic unsigned 
int &)' 
| `-DeclRefExpr 0x712710  'int (const __generic unsigned int &)' 
lvalue Function 0x7124d0 'bar' 'int (const __generic unsigned int &)'
`-MaterializeTemporaryExpr 0x7127e0  'const __generic unsigned 
int' lvalue
  `-ImplicitCastExpr 0x7127c8  'const __generic unsigned int' 

`-IntegerLiteral 0x7126f0  'int' 1
```

I will fix it!


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] D58658: [OpenCL] Fix assertion due to blocks

2019-02-26 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks!


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

https://reviews.llvm.org/D58658



___
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-26 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.

I think this looks good 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] D58668: [ASTImporter] Fix redecl failures of FunctionTemplateSpec

2019-02-26 Thread Gabor Marton via Phabricator via cfe-commits
martong created this revision.
martong added reviewers: a_sidorin, shafik.
Herald added subscribers: cfe-commits, gamesh411, Szelethus, dkrupp, rnkovacs.
Herald added a reviewer: a.sidorin.
Herald added a project: clang.

Redecl chains of function template specializations are not handled well
currently. We want to handle them similarly to functions, i.e. try to
keep the structure of the original AST as much as possible. The aim is
to not squash a prototype with a definition, rather we create both and
put them in a redecl chain.


Repository:
  rC Clang

https://reviews.llvm.org/D58668

Files:
  lib/AST/ASTImporter.cpp
  unittests/AST/ASTImporterTest.cpp

Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -3859,6 +3859,47 @@
   std::string getDefinition() { return TypeParam::Definition; }
   BindableMatcher getPattern() const { return TypeParam().getPattern(); }
 
+  void CheckPreviousDecl(Decl *To0, Decl *To1) {
+ASSERT_NE(To0, To1);
+ASSERT_EQ(&To0->getASTContext(), &To1->getASTContext());
+
+auto *ToTU = To0->getTranslationUnitDecl();
+
+// Templates.
+if (auto *ToT0 = dyn_cast(To0)) {
+  EXPECT_EQ(To1->getPreviousDecl(), To0);
+  auto *ToT1 = cast(To1);
+  ASSERT_TRUE(ToT0->getTemplatedDecl());
+  ASSERT_TRUE(ToT1->getTemplatedDecl());
+  EXPECT_EQ(ToT1->getTemplatedDecl()->getPreviousDecl(),
+ToT0->getTemplatedDecl());
+  return;
+}
+
+// Specializations.
+if (auto *From0F = dyn_cast(To0)) {
+  auto *To0F = cast(To0);
+  if (From0F->getTemplatedKind() ==
+  FunctionDecl::TK_FunctionTemplateSpecialization) {
+EXPECT_EQ(To0->getCanonicalDecl(), To1->getCanonicalDecl());
+// There may be a hidden fwd spec decl before a spec decl.
+// In that case the previous visible decl can be reached through that
+// invisible one.
+EXPECT_THAT(To0,
+testing::AnyOf(To1->getPreviousDecl(),
+   To1->getPreviousDecl()->getPreviousDecl()));
+auto *TemplateD = FirstDeclMatcher().match(
+ToTU, functionTemplateDecl());
+auto *FirstSpecD = *(TemplateD->spec_begin());
+EXPECT_EQ(FirstSpecD->getCanonicalDecl(), To0F->getCanonicalDecl());
+return;
+  }
+}
+
+// The rest: Classes, Functions, etc.
+EXPECT_EQ(To1->getPreviousDecl(), To0);
+  }
+
   void
   TypedTest_PrototypeShouldBeImportedAsAPrototypeWhenThereIsNoDefinition() {
 Decl *FromTU = getTuDecl(getPrototype(), Lang_CXX);
@@ -3911,14 +3952,8 @@
 EXPECT_TRUE(Imported1 == To1);
 EXPECT_FALSE(To0->isThisDeclarationADefinition());
 EXPECT_FALSE(To1->isThisDeclarationADefinition());
-EXPECT_EQ(To1->getPreviousDecl(), To0);
-if (auto *ToT0 = dyn_cast(To0)) {
-  auto *ToT1 = cast(To1);
-  ASSERT_TRUE(ToT0->getTemplatedDecl());
-  ASSERT_TRUE(ToT1->getTemplatedDecl());
-  EXPECT_EQ(ToT1->getTemplatedDecl()->getPreviousDecl(),
-ToT0->getTemplatedDecl());
-}
+
+CheckPreviousDecl(To0, To1);
   }
 
   void TypedTest_ImportDefinitionAfterImportedPrototype() {
@@ -3940,14 +3975,8 @@
 EXPECT_TRUE(ImportedDef == ToDef);
 EXPECT_FALSE(ToProto->isThisDeclarationADefinition());
 EXPECT_TRUE(ToDef->isThisDeclarationADefinition());
-EXPECT_EQ(ToDef->getPreviousDecl(), ToProto);
-if (auto *ToProtoT = dyn_cast(ToProto)) {
-  auto *ToDefT = cast(ToDef);
-  ASSERT_TRUE(ToProtoT->getTemplatedDecl());
-  ASSERT_TRUE(ToDefT->getTemplatedDecl());
-  EXPECT_EQ(ToDefT->getTemplatedDecl()->getPreviousDecl(),
-ToProtoT->getTemplatedDecl());
-}
+
+CheckPreviousDecl(ToProto, ToDef);
   }
 
   void TypedTest_ImportPrototypeAfterImportedDefinition() {
@@ -3969,14 +3998,8 @@
 EXPECT_TRUE(ImportedProto == ToProto);
 EXPECT_TRUE(ToDef->isThisDeclarationADefinition());
 EXPECT_FALSE(ToProto->isThisDeclarationADefinition());
-EXPECT_EQ(ToProto->getPreviousDecl(), ToDef);
-if (auto *ToDefT = dyn_cast(ToDef)) {
-  auto *ToProtoT = cast(ToProto);
-  ASSERT_TRUE(ToDefT->getTemplatedDecl());
-  ASSERT_TRUE(ToProtoT->getTemplatedDecl());
-  EXPECT_EQ(ToProtoT->getTemplatedDecl()->getPreviousDecl(),
-ToDefT->getTemplatedDecl());
-}
+
+CheckPreviousDecl(ToDef, ToProto);
   }
 
   void TypedTest_ImportPrototypes() {
@@ -3998,27 +4021,8 @@
 EXPECT_TRUE(Imported1 == To1);
 EXPECT_FALSE(To0->isThisDeclarationADefinition());
 EXPECT_FALSE(To1->isThisDeclarationADefinition());
-EXPECT_EQ(To1->getPreviousDecl(), To0);
-if (auto *ToT0 = dyn_cast(To0)) {
-  auto *ToT1 = cast(To1);
-  ASSERT_TRUE(ToT0->getTemplatedDecl());
-  ASSERT_TRUE(ToT1->getTemplatedDecl());
-  EXPECT_EQ(ToT1->getTemplatedDecl()->getPreviousDecl(),
-ToT0->ge

[PATCH] D58666: [OpenCL] Undefine cl_intel_planar_yuv extension

2019-02-26 Thread Dmitry Sidorov via Phabricator via cfe-commits
sidorovd marked an inline comment as done.
sidorovd added inline comments.



Comment at: test/SemaOpenCL/extension-begin.cl:26
+
 #ifndef IMPLICIT_INCLUDE
 #include "extension-begin.h"

Anastasia wrote:
> Can we also test that macro `my_ext` is not defined here but defined above?
> 
> It seems we are not testing anything like this...
#pragma OPENCL EXTENSION my_ext : begin doesn't define an appropriate macro. 
And so cl-ext=+my_ext.


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

https://reviews.llvm.org/D58666



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


r354873 - [Driver] Allow enum SanitizerOrdinal to represent more than 64 different sanitizer checks, NFC.

2019-02-26 Thread Pierre Gousseau via cfe-commits
Author: pgousseau
Date: Tue Feb 26 05:30:14 2019
New Revision: 354873

URL: http://llvm.org/viewvc/llvm-project?rev=354873&view=rev
Log:
[Driver] Allow enum SanitizerOrdinal to represent more than 64 different 
sanitizer checks, NFC.

enum SanitizerOrdinal has reached maximum capacity, this change extends the 
capacity to 128 sanitizer checks.
This can eventually allow us to add gcc 8's options 
"-fsanitize=pointer-substract" and "-fsanitize=pointer-compare".

Fixes: https://llvm.org/PR39425

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

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

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=354873&r1=354872&r2=354873&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Tue Feb 26 05:30:14 2019
@@ -2366,7 +2366,7 @@ def NoSanitize : InheritableAttr {
   let Documentation = [NoSanitizeDocs];
   let AdditionalMembers = [{
 SanitizerMask getMask() const {
-  SanitizerMask Mask = 0;
+  SanitizerMask Mask;
   for (auto SanitizerName : sanitizers()) {
 SanitizerMask ParsedMask =
 parseSanitizerValue(SanitizerName, /*AllowGroups=*/true);

Modified: cfe/trunk/include/clang/Basic/Sanitizers.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Sanitizers.def?rev=354873&r1=354872&r2=354873&view=diff
==
--- cfe/trunk/include/clang/Basic/Sanitizers.def (original)
+++ cfe/trunk/include/clang/Basic/Sanitizers.def Tue Feb 26 05:30:14 2019
@@ -177,7 +177,7 @@ SANITIZER("scudo", Scudo)
 
 // Magic group, containing all sanitizers. For example, "-fno-sanitize=all"
 // can be used to disable all the sanitizers.
-SANITIZER_GROUP("all", All, ~0ULL)
+SANITIZER_GROUP("all", All, ~SanitizerMask())
 
 #undef SANITIZER
 #undef SANITIZER_GROUP

Modified: cfe/trunk/include/clang/Basic/Sanitizers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Sanitizers.h?rev=354873&r1=354872&r2=354873&view=diff
==
--- cfe/trunk/include/clang/Basic/Sanitizers.h (original)
+++ cfe/trunk/include/clang/Basic/Sanitizers.h Tue Feb 26 05:30:14 2019
@@ -21,44 +21,167 @@
 #include 
 
 namespace clang {
+class SanitizerMask;
+}
 
-using SanitizerMask = uint64_t;
+namespace llvm {
+class hashcode;
+hash_code hash_value(const clang::SanitizerMask &Arg);
+} // namespace llvm
 
-namespace SanitizerKind {
+namespace clang {
 
-// Assign ordinals to possible values of -fsanitize= flag, which we will use as
-// bit positions.
-enum SanitizerOrdinal : uint64_t {
-#define SANITIZER(NAME, ID) SO_##ID,
-#define SANITIZER_GROUP(NAME, ID, ALIAS) SO_##ID##Group,
-#include "clang/Basic/Sanitizers.def"
-  SO_Count
+class SanitizerMask {
+  /// Number of array elements.
+  static constexpr unsigned kNumElem = 2;
+  /// Mask value initialized to 0.
+  uint64_t maskLoToHigh[kNumElem]{};
+  /// Number of bits in a mask.
+  static constexpr unsigned kNumBits = sizeof(decltype(maskLoToHigh)) * 8;
+  /// Number of bits in a mask element.
+  static constexpr unsigned kNumBitElem = sizeof(decltype(maskLoToHigh[0])) * 
8;
+
+public:
+  static constexpr bool checkBitPos(const unsigned Pos) {
+return Pos < kNumBits;
+  }
+
+  /// Create a mask with a bit enabled at position Pos.
+  static SanitizerMask bitPosToMask(const unsigned Pos) {
+assert(Pos < kNumBits && "Bit position too big.");
+SanitizerMask mask;
+mask.maskLoToHigh[Pos / kNumBitElem] = 1ULL << Pos % kNumBitElem;
+return mask;
+  }
+
+  unsigned countPopulation() const {
+unsigned total = 0;
+for (const auto &Val : maskLoToHigh)
+  total += llvm::countPopulation(Val);
+return total;
+  }
+
+  void flipAllBits() {
+for (auto &Val : maskLoToHigh)
+  Val = ~Val;
+  }
+
+  bool isPowerOf2() const {
+return countPopulation() == 1;
+  }
+
+  llvm::hash_code hash_value() const;
+
+  explicit operator bool() const {
+for (const auto &Val : maskLoToHigh)
+  if (Val)
+return true;
+return false;
+  };
+
+  bool operator==(const SanitizerMask &V) const {
+for (unsigned k = 0; k < kNumElem; k++) {
+  if (maskLoToHigh[k] != V.maskLoToHigh[k])
+return false;
+}
+return true;
+  }
+
+  SanitizerMask &operator&=(const 

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

2019-02-26 Thread pierre gousseau via Phabricator via cfe-commits
pgousseau added a comment.

In D57914#1410387 , @riccibruno wrote:

> I think this looks good now. Thanks !


Pushed at r354873, thanks for the help!


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-26 Thread pierre gousseau via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC354873: [Driver] Allow enum SanitizerOrdinal to represent 
more than 64 different… (authored by pgousseau, committed by ).

Repository:
  rC Clang

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: include/clang/Basic/Attr.td
===
--- include/clang/Basic/Attr.td
+++ include/clang/Basic/Attr.td
@@ -2366,7 +2366,7 @@
   let Documentation = [NoSanitizeDocs];
   let AdditionalMembers = [{
 SanitizerMask getMask() const {
-  SanitizerMask Mask = 0;
+  SanitizerMask Mask;
   for (auto SanitizerName : sanitizers()) {
 SanitizerMask ParsedMask =
 parseSanitizerValue(SanitizerName, /*AllowGroups=*/true);
Index: include/clang/Basic/Sanitizers.h
===
--- include/clang/Basic/Sanitizers.h
+++ include/clang/Basic/Sanitizers.h
@@ -21,44 +21,167 @@
 #include 
 
 namespace clang {
+class SanitizerMask;
+}
 
-using SanitizerMask = uint64_t;
+namespace llvm {
+class hashcode;
+hash_code hash_value(const clang::SanitizerMask &Arg);
+} // namespace llvm
 
-namespace SanitizerKind {
+namespace clang {
 
-// Assign ordinals to possible values of -fsanitize= flag, which we will use as
-// bit positions.
-enum SanitizerOrdinal : uint64_t {
-#define SANITIZER(NAME, ID) SO_##ID,
-#define SANITIZER_GROUP(NAME, ID, ALIAS) SO_##ID##Group,
-#include "clang/Basic/Sanitizers.def"
-  SO_Count
+class SanitizerMask {
+  /// Number of array elements.
+  static constexpr unsigned kNumElem = 2;
+  /// Mask value initialized to 0.
+  uint64_t maskLoToHigh[kNumElem]{};
+  /// Number of bits in a mask.
+  static constexpr unsigned kNumBits = sizeof(decltype(maskLoToHigh)) * 8;
+  /// Number of bits in a mask element.
+  static constexpr unsigned kNumBitElem = sizeof(decltype(maskLoToHigh[0])) * 8;
+
+public:
+  static constexpr bool checkBitPos(const unsigned Pos) {
+return Pos < kNumBits;
+  }
+
+  /// Create a mask with a bit enabled at position Pos.
+  static SanitizerMask bitPosToMask(const unsigned Pos) {
+assert(Pos < kNumBits && "Bit position too big.");
+SanitizerMask mask;
+mask.maskLoToHigh[Pos / kNumBitElem] = 1ULL << Pos % kNumBitElem;
+return mask;
+  }
+
+  unsigned countPopulation() const {
+unsigned total = 0;
+for (const auto &Val : maskLoToHigh)
+  total += llvm::countPopulation(Val);
+return total;
+  }
+
+  void flipAllBits() {
+for (auto &Val : maskLoToHigh)
+  Val = ~Val;
+  }
+
+  bool isPowerOf2() const {
+return countPopulation() == 1;
+  }
+
+  llvm::hash_code hash_value() const;
+
+  explicit operator bool() const {
+for (const auto &Val : maskLoToHigh)
+  if (Val)
+return true;
+return false;
+  };
+
+  bool operator==(const SanitizerMask &V) const {
+for (unsigned k = 0; k < kNumElem; k++) {
+  if (maskLoToHigh[k] != V.maskLoToHigh[k])
+return false;
+}
+return true;
+  }
+
+  SanitizerMask &operator&=(const SanitizerMask &RHS) {
+for (unsigned k = 0; k < kNumElem; k++)
+  maskLoToHigh[k] &= RHS.maskLoToHigh[k];
+return *this;
+  }
+
+  SanitizerMask &operator|=(const SanitizerMask &RHS) {
+for (unsigned k = 0; k < kNumElem; k++)
+  maskLoToHigh[k] |= RHS.maskLoToHigh[k];
+return *this;
+  }
+
+  bool operator!() const {
+for (const auto &Val : maskLoToHigh)
+  if (Val)
+return false;
+return true;
+  }
+
+  bool operator!=(const SanitizerMask &RHS) const { return !((*this) == RHS); }
 };
 
+inline SanitizerMask operator~(SanitizerMask v) {
+  v.flipAllBits();
+  return v;
+}
+
+inline SanitizerMask operator&(SanitizerMask a, const SanitizerMask &b) {
+  a &= b;
+  return a;
+}
+
+inline SanitizerMask operator|(SanitizerMask a, const SanitizerMask &b) {
+  a |= b;
+  return a;
+}
+
 // Define the set of sanitizer kinds, as well as the set of sanitizers each
 // sanitizer group expands into.
-#define SANITIZER(NAME, ID) \
-  const SanitizerMask ID = 1ULL << SO_##ID;
-#define SANITIZER_GROUP(NAME, ID, ALIAS) \
-  const SanitizerMask ID = ALIAS; \
-  const SanitizerMask ID##Group = 1ULL << SO_##ID##Group;
+// Uses static data member of a class template as recommended in second
+// workaround from n4424 to avoid odr issues.
+// FIXME: Can be marked as constexpr once c++14 can be used in llvm.
+// FIXME: n4424 workaround can be replaced by c++17 inline variable.
+template  struct SanitizerMasks {
+
+  // Assign ordinals to possibl

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

2019-02-26 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel marked 4 inline comments as done.
ymandel added inline comments.



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

ilya-biryukov wrote:
> 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?
I completely agree. I went through quite a few iterations on this name and 
disliked this one the least.  ;)  I think you're right, though, that once we're 
choosing a different name, the "auto" part doesn't really need to be in it.  I 
like `getSpannedRange` better than this. Other thoughts:

getLogicalRange
getExtendedRange
getAssociatedRange

any preference?



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

ilya-biryukov wrote:
> What are other tricky cases you have in mind for the future?
I just assumed that we'd hit more as we dig into them, but, I'm not so sure 
now.  The two others I can think of offhand are 1) extending to include 
associated comments, 2) semicolons after declarations.  Commas present a 
similar challenge (if a bit simpler) when used in a list (vs. the comma 
operator).  Are there any other separators in C++? 

At a higher level, it would be nice to align this with your work on tree 
transformations. That is, think of these functions as short-term shims to 
simulate the behavior we'll ultimately get from that new library. However, it 
might be premature to consider those details here.



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

ilya-biryukov wrote:
> Could you add an example of the API use here? The anticipated use-case are 
> removing or textually replacing a node, right?
Yes, that's right.  Will do (on next edit, once we've resolved naming, etc.)



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

ilya-biryukov wrote:
> 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.
In the context of transformer, I expect that this will be called in proportion 
to the number of times that a match callback is invoked.  so, I expect there to 
already be matcher use in the control flow.

Yes, I'm using the matchers almost entirely for the hasParent() functionality.

Note that we can change the order of the guards in lines 67-69 and first check 
for a trailing semi which I'd guess is cheaper than calling the matcher. In 
that case, matching will only happen for expressions followed by semicolons.

Alternatively, I think I could restructure the uses of this function to 
*provide* the parent node. In that case, callers can decide what makes the most 
sense performance-wise for getting the parent. 


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


r354875 - revert r354873 as this breaks lldb builds.

2019-02-26 Thread Pierre Gousseau via cfe-commits
Author: pgousseau
Date: Tue Feb 26 05:50:29 2019
New Revision: 354875

URL: http://llvm.org/viewvc/llvm-project?rev=354875&view=rev
Log:
revert r354873 as this breaks lldb builds.

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

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=354875&r1=354874&r2=354875&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Tue Feb 26 05:50:29 2019
@@ -2366,7 +2366,7 @@ def NoSanitize : InheritableAttr {
   let Documentation = [NoSanitizeDocs];
   let AdditionalMembers = [{
 SanitizerMask getMask() const {
-  SanitizerMask Mask;
+  SanitizerMask Mask = 0;
   for (auto SanitizerName : sanitizers()) {
 SanitizerMask ParsedMask =
 parseSanitizerValue(SanitizerName, /*AllowGroups=*/true);

Modified: cfe/trunk/include/clang/Basic/Sanitizers.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Sanitizers.def?rev=354875&r1=354874&r2=354875&view=diff
==
--- cfe/trunk/include/clang/Basic/Sanitizers.def (original)
+++ cfe/trunk/include/clang/Basic/Sanitizers.def Tue Feb 26 05:50:29 2019
@@ -177,7 +177,7 @@ SANITIZER("scudo", Scudo)
 
 // Magic group, containing all sanitizers. For example, "-fno-sanitize=all"
 // can be used to disable all the sanitizers.
-SANITIZER_GROUP("all", All, ~SanitizerMask())
+SANITIZER_GROUP("all", All, ~0ULL)
 
 #undef SANITIZER
 #undef SANITIZER_GROUP

Modified: cfe/trunk/include/clang/Basic/Sanitizers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Sanitizers.h?rev=354875&r1=354874&r2=354875&view=diff
==
--- cfe/trunk/include/clang/Basic/Sanitizers.h (original)
+++ cfe/trunk/include/clang/Basic/Sanitizers.h Tue Feb 26 05:50:29 2019
@@ -21,167 +21,44 @@
 #include 
 
 namespace clang {
-class SanitizerMask;
-}
 
-namespace llvm {
-class hashcode;
-hash_code hash_value(const clang::SanitizerMask &Arg);
-} // namespace llvm
+using SanitizerMask = uint64_t;
 
-namespace clang {
-
-class SanitizerMask {
-  /// Number of array elements.
-  static constexpr unsigned kNumElem = 2;
-  /// Mask value initialized to 0.
-  uint64_t maskLoToHigh[kNumElem]{};
-  /// Number of bits in a mask.
-  static constexpr unsigned kNumBits = sizeof(decltype(maskLoToHigh)) * 8;
-  /// Number of bits in a mask element.
-  static constexpr unsigned kNumBitElem = sizeof(decltype(maskLoToHigh[0])) * 
8;
-
-public:
-  static constexpr bool checkBitPos(const unsigned Pos) {
-return Pos < kNumBits;
-  }
-
-  /// Create a mask with a bit enabled at position Pos.
-  static SanitizerMask bitPosToMask(const unsigned Pos) {
-assert(Pos < kNumBits && "Bit position too big.");
-SanitizerMask mask;
-mask.maskLoToHigh[Pos / kNumBitElem] = 1ULL << Pos % kNumBitElem;
-return mask;
-  }
-
-  unsigned countPopulation() const {
-unsigned total = 0;
-for (const auto &Val : maskLoToHigh)
-  total += llvm::countPopulation(Val);
-return total;
-  }
-
-  void flipAllBits() {
-for (auto &Val : maskLoToHigh)
-  Val = ~Val;
-  }
-
-  bool isPowerOf2() const {
-return countPopulation() == 1;
-  }
-
-  llvm::hash_code hash_value() const;
-
-  explicit operator bool() const {
-for (const auto &Val : maskLoToHigh)
-  if (Val)
-return true;
-return false;
-  };
-
-  bool operator==(const SanitizerMask &V) const {
-for (unsigned k = 0; k < kNumElem; k++) {
-  if (maskLoToHigh[k] != V.maskLoToHigh[k])
-return false;
-}
-return true;
-  }
-
-  SanitizerMask &operator&=(const SanitizerMask &RHS) {
-for (unsigned k = 0; k < kNumElem; k++)
-  maskLoToHigh[k] &= RHS.maskLoToHigh[k];
-return *this;
-  }
+namespace SanitizerKind {
 
-  SanitizerMask &operator|=(const SanitizerMask &RHS) {
-for (unsigned k = 0; k < kNumElem; k++)
-  maskLoToHigh[k] |= RHS.maskLoToHigh[k];
-return *this;
-  }
-
-  bool operator!() const {
-for (const auto &Val : maskLoToHigh)
-  if (Val)
-return false;
-return true;
-  }
-
-  bool operator!=(const SanitizerMask &RHS) const { return !((*this) == RHS); }
-};
-
-inline SanitizerMask operator~(SanitizerMask v) {
-  v.flipAllBits();
-  return v;
-}
-
-inline SanitizerMask operator&

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

2019-02-26 Thread pierre gousseau via Phabricator via cfe-commits
pgousseau added a comment.

reverted at r354875 at this break lldb build.


Repository:
  rC Clang

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] D58673: [ASTImporter] Fix redecl failures of ClassTemplateSpec

2019-02-26 Thread Gabor Marton via Phabricator via cfe-commits
martong created this revision.
martong added reviewers: a_sidorin, shafik.
Herald added subscribers: cfe-commits, jdoerfert, gamesh411, Szelethus, dkrupp, 
rnkovacs.
Herald added a reviewer: a.sidorin.
Herald added a project: clang.

Redecl chains of class template specializations are not handled well
currently. We want to handle them similarly to functions, i.e. try to
keep the structure of the original AST as much as possible. The aim is
to not squash a prototype with a definition, rather we create both and
put them in a redecl chain.


Repository:
  rC Clang

https://reviews.llvm.org/D58673

Files:
  lib/AST/ASTImporter.cpp
  unittests/AST/ASTImporterTest.cpp

Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -3471,12 +3471,10 @@
   // The second specialization is different from the first, thus it violates
   // ODR, consequently we expect to keep the first specialization only, which is
   // already in the "To" context.
-  EXPECT_TRUE(ImportedSpec);
-  auto *ToSpec = FirstDeclMatcher().match(
-  ToTU, classTemplateSpecializationDecl(hasName("X")));
-  EXPECT_EQ(ImportedSpec, ToSpec);
-  EXPECT_EQ(1u, DeclCounter().match(
-ToTU, classTemplateSpecializationDecl()));
+  EXPECT_FALSE(ImportedSpec);
+  EXPECT_EQ(1u,
+DeclCounter().match(
+ToTU, classTemplateSpecializationDecl(hasName("X";
 }
 
 TEST_P(ASTImporterOptionSpecificTestBase,
@@ -3851,6 +3849,23 @@
   }
 };
 
+struct ClassTemplateSpec {
+  using DeclTy = ClassTemplateSpecializationDecl;
+  static constexpr auto *Prototype =
+R"(
+template  class X;
+template <> class X;
+)";
+  static constexpr auto *Definition =
+R"(
+template  class X;
+template <> class X {};
+)";
+  BindableMatcher getPattern() {
+return classTemplateSpecializationDecl(hasName("X"), unless(isImplicit()));
+  }
+};
+
 template 
 struct RedeclChain : ASTImporterOptionSpecificTestBase {
 
@@ -4173,6 +4188,9 @@
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(
 RedeclChain, FunctionTemplateSpec, ,
 PrototypeShouldBeImportedAsAPrototypeWhenThereIsNoDefinition)
+ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(
+RedeclChain, ClassTemplateSpec, ,
+PrototypeShouldBeImportedAsAPrototypeWhenThereIsNoDefinition)
 
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(
 RedeclChain, Function, , DefinitionShouldBeImportedAsADefinition)
@@ -4189,6 +4207,8 @@
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(
 RedeclChain, FunctionTemplateSpec, ,
 DefinitionShouldBeImportedAsADefinition)
+ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(
+RedeclChain, ClassTemplateSpec, , DefinitionShouldBeImportedAsADefinition)
 
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, Function, ,
 ImportPrototypeAfterImportedPrototype)
@@ -4204,6 +4224,8 @@
 ImportPrototypeAfterImportedPrototype)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, FunctionTemplateSpec, ,
 ImportPrototypeAfterImportedPrototype)
+ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, ClassTemplateSpec, ,
+ImportPrototypeAfterImportedPrototype)
 
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, Function, ,
 ImportDefinitionAfterImportedPrototype)
@@ -4221,6 +4243,8 @@
 ImportDefinitionAfterImportedPrototype)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, FunctionTemplateSpec, ,
 ImportDefinitionAfterImportedPrototype)
+ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, ClassTemplateSpec, ,
+ImportDefinitionAfterImportedPrototype)
 
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, Function, ,
 ImportPrototypeAfterImportedDefinition)
@@ -4238,6 +4262,8 @@
 ImportPrototypeAfterImportedDefinition)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, FunctionTemplateSpec, ,
 ImportPrototypeAfterImportedDefinition)
+ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, ClassTemplateSpec, ,
+ImportPrototypeAfterImportedDefinition)
 
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, Function, ,
 ImportPrototypes)
@@ -4252,6 +4278,8 @@
 // FIXME This does not pass, possible error with Spec import.
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, FunctionTemplateSpec,
 DISABLED_, ImportPrototypes)
+ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, ClassTemplateSpec, ,
+ImportPrototypes)
 
 ASTIMPORTER_INSTANTI

r354878 - [clang][Index] Visit UsingDecls and generate USRs for them

2019-02-26 Thread Kadir Cetinkaya via cfe-commits
Author: kadircet
Date: Tue Feb 26 06:23:12 2019
New Revision: 354878

URL: http://llvm.org/viewvc/llvm-project?rev=354878&view=rev
Log:
[clang][Index] Visit UsingDecls and generate USRs for them

Summary:
Add indexing of UsingDecl itself.
Also enable generation of USRs for UsingDecls, using the qualified name of the
decl.

Reviewers: ilya-biryukov, akyrtzi

Subscribers: arphaman, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/lib/Index/IndexDecl.cpp
cfe/trunk/lib/Index/IndexSymbol.cpp
cfe/trunk/lib/Index/USRGeneration.cpp
cfe/trunk/test/Index/usrs.cpp
cfe/trunk/unittests/Index/IndexTests.cpp

Modified: cfe/trunk/lib/Index/IndexDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexDecl.cpp?rev=354878&r1=354877&r2=354878&view=diff
==
--- cfe/trunk/lib/Index/IndexDecl.cpp (original)
+++ cfe/trunk/lib/Index/IndexDecl.cpp Tue Feb 26 06:23:12 2019
@@ -580,9 +580,10 @@ public:
   }
 
   bool VisitUsingDecl(const UsingDecl *D) {
+IndexCtx.handleDecl(D);
+
 const DeclContext *DC = D->getDeclContext()->getRedeclContext();
 const NamedDecl *Parent = dyn_cast(DC);
-
 IndexCtx.indexNestedNameSpecifierLoc(D->getQualifierLoc(), Parent,
  D->getLexicalDeclContext());
 for (const auto *I : D->shadows())

Modified: cfe/trunk/lib/Index/IndexSymbol.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexSymbol.cpp?rev=354878&r1=354877&r2=354878&view=diff
==
--- cfe/trunk/lib/Index/IndexSymbol.cpp (original)
+++ cfe/trunk/lib/Index/IndexSymbol.cpp Tue Feb 26 06:23:12 2019
@@ -316,6 +316,10 @@ SymbolInfo index::getSymbolInfo(const De
   Info.Lang = SymbolLanguage::CXX;
   Info.Properties |= (SymbolPropertySet)SymbolProperty::Generic;
   break;
+case Decl::Using:
+  Info.Kind = SymbolKind::Using;
+  Info.Lang = SymbolLanguage::CXX;
+  break;
 case Decl::Binding:
   Info.Kind = SymbolKind::Variable;
   Info.Lang = SymbolLanguage::CXX;

Modified: cfe/trunk/lib/Index/USRGeneration.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/USRGeneration.cpp?rev=354878&r1=354877&r2=354878&view=diff
==
--- cfe/trunk/lib/Index/USRGeneration.cpp (original)
+++ cfe/trunk/lib/Index/USRGeneration.cpp Tue Feb 26 06:23:12 2019
@@ -111,7 +111,12 @@ public:
   }
 
   void VisitUsingDecl(const UsingDecl *D) {
-IgnoreResults = true;
+VisitDeclContext(D->getDeclContext());
+Out << "@UD@";
+
+bool EmittedDeclName = !EmitDeclName(D);
+assert(EmittedDeclName && "EmitDeclName can not fail for UsingDecls");
+(void)EmittedDeclName;
   }
 
   bool ShouldGenerateLocation(const NamedDecl *D);

Modified: cfe/trunk/test/Index/usrs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/usrs.cpp?rev=354878&r1=354877&r2=354878&view=diff
==
--- cfe/trunk/test/Index/usrs.cpp (original)
+++ cfe/trunk/test/Index/usrs.cpp Tue Feb 26 06:23:12 2019
@@ -158,7 +158,7 @@ __m128 vectorOverload(__m128 f);
 // CHECK: usrs.cpp c:@NA@foo_alias
 // CHECK-NOT: foo
 // CHECK: usrs.cpp c:@NA@foo_alias2
-// CHECK-NOT: ClsB
+// CHECK: usrs.cpp c:@UD@ClsB Extent=[64:1 - 64:16]
 // CHECK: usrs.cpp c:@NA@foo_alias3
 // CHECK: usrs.cpp c:@aN Extent=[68:1 - 73:2]
 // CHECK: usrs.cpp c:usrs.cpp@aN@S@RDar9371763_Foo Extent=[69:1 - 72:2]

Modified: cfe/trunk/unittests/Index/IndexTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Index/IndexTests.cpp?rev=354878&r1=354877&r2=354878&view=diff
==
--- cfe/trunk/unittests/Index/IndexTests.cpp (original)
+++ cfe/trunk/unittests/Index/IndexTests.cpp Tue Feb 26 06:23:12 2019
@@ -57,6 +57,7 @@ struct TestSymbol {
   std::string QName;
   Position WrittenPos;
   Position DeclPos;
+  SymbolInfo SymInfo;
   // FIXME: add more information.
 };
 
@@ -78,6 +79,7 @@ public:
 if (!ND)
   return true;
 TestSymbol S;
+S.SymInfo = getSymbolInfo(D);
 S.QName = ND->getQualifiedNameAsString();
 S.WrittenPos = Position::fromSourceLocation(Loc, AST->getSourceManager());
 S.DeclPos =
@@ -140,6 +142,7 @@ using testing::UnorderedElementsAre;
 MATCHER_P(QName, Name, "") { return arg.QName == Name; }
 MATCHER_P(WrittenAt, Pos, "") { return arg.WrittenPos == Pos; }
 MATCHER_P(DeclAt, Pos, "") { return arg.DeclPos == Pos; }
+MATCHER_P(Kind, SymKind, "") { return arg.SymInfo.Kind == SymKind; }
 
 TEST(IndexTest, Simple) {
   auto Index = std::make_shared();
@@ -240,6 +243,20 @@ TEST(IndexTest, IndexTypeParmDecls) {
 Contains(QName("Foo::C")), Contains(QName("Foo::NoRef";
 }
 

[clang-tools-extra] r354879 - [clangd] Index UsingDecls

2019-02-26 Thread Kadir Cetinkaya via cfe-commits
Author: kadircet
Date: Tue Feb 26 06:23:47 2019
New Revision: 354879

URL: http://llvm.org/viewvc/llvm-project?rev=354879&view=rev
Log:
[clangd] Index UsingDecls

Summary:
D58340 enables indexing of USRs, this makes sure test in clangd are
aligned with the change

Reviewers: hokein

Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, jdoerfert, 
cfe-commits

Tags: #clang

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

Modified:
clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
clang-tools-extra/trunk/unittests/clangd/FindSymbolsTests.cpp
clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp
clang-tools-extra/trunk/unittests/clangd/SymbolInfoTests.cpp

Modified: clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp?rev=354879&r1=354878&r2=354879&view=diff
==
--- clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp Tue Feb 26 
06:23:47 2019
@@ -17,6 +17,7 @@
 #include "SyncAPI.h"
 #include "TestFS.h"
 #include "TestIndex.h"
+#include "TestTU.h"
 #include "index/MemIndex.h"
 #include "clang/Sema/CodeCompleteConsumer.h"
 #include "llvm/Support/Error.h"
@@ -2314,6 +2315,26 @@ TEST(CompletionTest, WorksWithNullType)
   EXPECT_THAT(R.Completions, ElementsAre(Named("loopVar")));
 }
 
+TEST(CompletionTest, UsingDecl) {
+  const char *Header(R"cpp(
+void foo(int);
+namespace std {
+  using ::foo;
+})cpp");
+  const char *Source(R"cpp(
+void bar() {
+  std::^;
+})cpp");
+  auto Index = TestTU::withHeaderCode(Header).index();
+  clangd::CodeCompleteOptions Opts;
+  Opts.Index = Index.get();
+  Opts.AllScopes = true;
+  auto R = completions(Source, {}, Opts);
+  EXPECT_THAT(R.Completions,
+  ElementsAre(AllOf(Scope("std::"), Named("foo"),
+Kind(CompletionItemKind::Reference;
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang

Modified: clang-tools-extra/trunk/unittests/clangd/FindSymbolsTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/FindSymbolsTests.cpp?rev=354879&r1=354878&r2=354879&view=diff
==
--- clang-tools-extra/trunk/unittests/clangd/FindSymbolsTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/FindSymbolsTests.cpp Tue Feb 26 
06:23:47 2019
@@ -368,9 +368,6 @@ TEST_F(DocumentSymbolsTest, BasicSymbols
   // Namespace alias
   namespace baz = bar;
 
-  // FIXME: using declaration is not supported as the IndexAction will 
ignore
-  // implicit declarations (the implicit using shadow declaration) by 
default,
-  // and there is no way to customize this behavior at the moment.
   using bar::v2;
   } // namespace foo
 )");
@@ -415,7 +412,7 @@ TEST_F(DocumentSymbolsTest, BasicSymbols
   Children(,
  AllOf(WithName("baz"), WithKind(SymbolKind::Namespace),
Children()),
- AllOf(WithName("v2"), 
WithKind(SymbolKind::Variable}));
+ AllOf(WithName("v2"), 
WithKind(SymbolKind::Namespace}));
 }
 
 TEST_F(DocumentSymbolsTest, DeclarationDefinition) {

Modified: clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp?rev=354879&r1=354878&r2=354879&view=diff
==
--- clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp Tue Feb 
26 06:23:47 2019
@@ -331,9 +331,6 @@ TEST_F(SymbolCollectorTest, CollectSymbo
 // Namespace alias
 namespace baz = bar;
 
-// FIXME: using declaration is not supported as the IndexAction will ignore
-// implicit declarations (the implicit using shadow declaration) by 
default,
-// and there is no way to customize this behavior at the moment.
 using bar::v2;
 } // namespace foo
   )";
@@ -360,6 +357,7 @@ TEST_F(SymbolCollectorTest, CollectSymbo
AllOf(QName("foo::int32_t"), ForCodeCompletion(true)),
AllOf(QName("foo::v1"), ForCodeCompletion(true)),
AllOf(QName("foo::bar::v2"), ForCodeCompletion(true)),
+   AllOf(QName("foo::v2"), ForCodeCompletion(true)),
AllOf(QName("foo::baz"), ForCodeCompletion(true))}));
 }
 
@@ -1149,6 +1147,16 @@ TEST_F(SymbolCollectorTest, Implementati
   AllOf(QName("Public"), Not(ImplementationDetail();
 }
 
+TEST_F(SymbolCollectorTest

[PATCH] D58340: [clang][Index] Visit UsingDecls and generate USRs for them

2019-02-26 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354878: [clang][Index] Visit UsingDecls and generate USRs 
for them (authored by kadircet, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D58340

Files:
  cfe/trunk/lib/Index/IndexDecl.cpp
  cfe/trunk/lib/Index/IndexSymbol.cpp
  cfe/trunk/lib/Index/USRGeneration.cpp
  cfe/trunk/test/Index/usrs.cpp
  cfe/trunk/unittests/Index/IndexTests.cpp

Index: cfe/trunk/test/Index/usrs.cpp
===
--- cfe/trunk/test/Index/usrs.cpp
+++ cfe/trunk/test/Index/usrs.cpp
@@ -158,7 +158,7 @@
 // CHECK: usrs.cpp c:@NA@foo_alias
 // CHECK-NOT: foo
 // CHECK: usrs.cpp c:@NA@foo_alias2
-// CHECK-NOT: ClsB
+// CHECK: usrs.cpp c:@UD@ClsB Extent=[64:1 - 64:16]
 // CHECK: usrs.cpp c:@NA@foo_alias3
 // CHECK: usrs.cpp c:@aN Extent=[68:1 - 73:2]
 // CHECK: usrs.cpp c:usrs.cpp@aN@S@RDar9371763_Foo Extent=[69:1 - 72:2]
Index: cfe/trunk/lib/Index/IndexDecl.cpp
===
--- cfe/trunk/lib/Index/IndexDecl.cpp
+++ cfe/trunk/lib/Index/IndexDecl.cpp
@@ -580,9 +580,10 @@
   }
 
   bool VisitUsingDecl(const UsingDecl *D) {
+IndexCtx.handleDecl(D);
+
 const DeclContext *DC = D->getDeclContext()->getRedeclContext();
 const NamedDecl *Parent = dyn_cast(DC);
-
 IndexCtx.indexNestedNameSpecifierLoc(D->getQualifierLoc(), Parent,
  D->getLexicalDeclContext());
 for (const auto *I : D->shadows())
Index: cfe/trunk/lib/Index/IndexSymbol.cpp
===
--- cfe/trunk/lib/Index/IndexSymbol.cpp
+++ cfe/trunk/lib/Index/IndexSymbol.cpp
@@ -316,6 +316,10 @@
   Info.Lang = SymbolLanguage::CXX;
   Info.Properties |= (SymbolPropertySet)SymbolProperty::Generic;
   break;
+case Decl::Using:
+  Info.Kind = SymbolKind::Using;
+  Info.Lang = SymbolLanguage::CXX;
+  break;
 case Decl::Binding:
   Info.Kind = SymbolKind::Variable;
   Info.Lang = SymbolLanguage::CXX;
Index: cfe/trunk/lib/Index/USRGeneration.cpp
===
--- cfe/trunk/lib/Index/USRGeneration.cpp
+++ cfe/trunk/lib/Index/USRGeneration.cpp
@@ -111,7 +111,12 @@
   }
 
   void VisitUsingDecl(const UsingDecl *D) {
-IgnoreResults = true;
+VisitDeclContext(D->getDeclContext());
+Out << "@UD@";
+
+bool EmittedDeclName = !EmitDeclName(D);
+assert(EmittedDeclName && "EmitDeclName can not fail for UsingDecls");
+(void)EmittedDeclName;
   }
 
   bool ShouldGenerateLocation(const NamedDecl *D);
Index: cfe/trunk/unittests/Index/IndexTests.cpp
===
--- cfe/trunk/unittests/Index/IndexTests.cpp
+++ cfe/trunk/unittests/Index/IndexTests.cpp
@@ -57,6 +57,7 @@
   std::string QName;
   Position WrittenPos;
   Position DeclPos;
+  SymbolInfo SymInfo;
   // FIXME: add more information.
 };
 
@@ -78,6 +79,7 @@
 if (!ND)
   return true;
 TestSymbol S;
+S.SymInfo = getSymbolInfo(D);
 S.QName = ND->getQualifiedNameAsString();
 S.WrittenPos = Position::fromSourceLocation(Loc, AST->getSourceManager());
 S.DeclPos =
@@ -140,6 +142,7 @@
 MATCHER_P(QName, Name, "") { return arg.QName == Name; }
 MATCHER_P(WrittenAt, Pos, "") { return arg.WrittenPos == Pos; }
 MATCHER_P(DeclAt, Pos, "") { return arg.DeclPos == Pos; }
+MATCHER_P(Kind, SymKind, "") { return arg.SymInfo.Kind == SymKind; }
 
 TEST(IndexTest, Simple) {
   auto Index = std::make_shared();
@@ -240,6 +243,20 @@
 Contains(QName("Foo::C")), Contains(QName("Foo::NoRef";
 }
 
+TEST(IndexTest, UsingDecls) {
+  std::string Code = R"cpp(
+void foo(int bar);
+namespace std {
+  using ::foo;
+}
+  )cpp";
+  auto Index = std::make_shared();
+  IndexingOptions Opts;
+  tooling::runToolOnCode(new IndexAction(Index, Opts), Code);
+  EXPECT_THAT(Index->Symbols,
+  Contains(AllOf(QName("std::foo"), Kind(SymbolKind::Using;
+}
+
 } // namespace
 } // namespace index
 } // namespace clang
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58340: [clang][Index] Visit UsingDecls and generate USRs for them

2019-02-26 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 188361.
kadircet marked an inline comment as done.
kadircet added a comment.

- Revert SymbolSubKind change
- Add test to check for SymbolKind


Repository:
  rC Clang

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

https://reviews.llvm.org/D58340

Files:
  lib/Index/IndexDecl.cpp
  lib/Index/IndexSymbol.cpp
  lib/Index/USRGeneration.cpp
  test/Index/usrs.cpp
  unittests/Index/IndexTests.cpp

Index: unittests/Index/IndexTests.cpp
===
--- unittests/Index/IndexTests.cpp
+++ unittests/Index/IndexTests.cpp
@@ -57,6 +57,7 @@
   std::string QName;
   Position WrittenPos;
   Position DeclPos;
+  SymbolInfo SymInfo;
   // FIXME: add more information.
 };
 
@@ -78,6 +79,7 @@
 if (!ND)
   return true;
 TestSymbol S;
+S.SymInfo = getSymbolInfo(D);
 S.QName = ND->getQualifiedNameAsString();
 S.WrittenPos = Position::fromSourceLocation(Loc, AST->getSourceManager());
 S.DeclPos =
@@ -140,6 +142,7 @@
 MATCHER_P(QName, Name, "") { return arg.QName == Name; }
 MATCHER_P(WrittenAt, Pos, "") { return arg.WrittenPos == Pos; }
 MATCHER_P(DeclAt, Pos, "") { return arg.DeclPos == Pos; }
+MATCHER_P(Kind, SymKind, "") { return arg.SymInfo.Kind == SymKind; }
 
 TEST(IndexTest, Simple) {
   auto Index = std::make_shared();
@@ -240,6 +243,20 @@
 Contains(QName("Foo::C")), Contains(QName("Foo::NoRef";
 }
 
+TEST(IndexTest, UsingDecls) {
+  std::string Code = R"cpp(
+void foo(int bar);
+namespace std {
+  using ::foo;
+}
+  )cpp";
+  auto Index = std::make_shared();
+  IndexingOptions Opts;
+  tooling::runToolOnCode(new IndexAction(Index, Opts), Code);
+  EXPECT_THAT(Index->Symbols,
+  Contains(AllOf(QName("std::foo"), Kind(SymbolKind::Using;
+}
+
 } // namespace
 } // namespace index
 } // namespace clang
Index: test/Index/usrs.cpp
===
--- test/Index/usrs.cpp
+++ test/Index/usrs.cpp
@@ -158,7 +158,7 @@
 // CHECK: usrs.cpp c:@NA@foo_alias
 // CHECK-NOT: foo
 // CHECK: usrs.cpp c:@NA@foo_alias2
-// CHECK-NOT: ClsB
+// CHECK: usrs.cpp c:@UD@ClsB Extent=[64:1 - 64:16]
 // CHECK: usrs.cpp c:@NA@foo_alias3
 // CHECK: usrs.cpp c:@aN Extent=[68:1 - 73:2]
 // CHECK: usrs.cpp c:usrs.cpp@aN@S@RDar9371763_Foo Extent=[69:1 - 72:2]
Index: lib/Index/USRGeneration.cpp
===
--- lib/Index/USRGeneration.cpp
+++ lib/Index/USRGeneration.cpp
@@ -111,7 +111,12 @@
   }
 
   void VisitUsingDecl(const UsingDecl *D) {
-IgnoreResults = true;
+VisitDeclContext(D->getDeclContext());
+Out << "@UD@";
+
+bool EmittedDeclName = !EmitDeclName(D);
+assert(EmittedDeclName && "EmitDeclName can not fail for UsingDecls");
+(void)EmittedDeclName;
   }
 
   bool ShouldGenerateLocation(const NamedDecl *D);
Index: lib/Index/IndexSymbol.cpp
===
--- lib/Index/IndexSymbol.cpp
+++ lib/Index/IndexSymbol.cpp
@@ -316,6 +316,10 @@
   Info.Lang = SymbolLanguage::CXX;
   Info.Properties |= (SymbolPropertySet)SymbolProperty::Generic;
   break;
+case Decl::Using:
+  Info.Kind = SymbolKind::Using;
+  Info.Lang = SymbolLanguage::CXX;
+  break;
 case Decl::Binding:
   Info.Kind = SymbolKind::Variable;
   Info.Lang = SymbolLanguage::CXX;
Index: lib/Index/IndexDecl.cpp
===
--- lib/Index/IndexDecl.cpp
+++ lib/Index/IndexDecl.cpp
@@ -580,9 +580,10 @@
   }
 
   bool VisitUsingDecl(const UsingDecl *D) {
+IndexCtx.handleDecl(D);
+
 const DeclContext *DC = D->getDeclContext()->getRedeclContext();
 const NamedDecl *Parent = dyn_cast(DC);
-
 IndexCtx.indexNestedNameSpecifierLoc(D->getQualifierLoc(), Parent,
  D->getLexicalDeclContext());
 for (const auto *I : D->shadows())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58341: [clangd] Index UsingDecls

2019-02-26 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE354879: [clangd] Index UsingDecls (authored by kadircet, 
committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D58341?vs=188170&id=188363#toc

Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D58341

Files:
  unittests/clangd/CodeCompleteTests.cpp
  unittests/clangd/FindSymbolsTests.cpp
  unittests/clangd/SymbolCollectorTests.cpp
  unittests/clangd/SymbolInfoTests.cpp

Index: unittests/clangd/SymbolCollectorTests.cpp
===
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -331,9 +331,6 @@
 // Namespace alias
 namespace baz = bar;
 
-// FIXME: using declaration is not supported as the IndexAction will ignore
-// implicit declarations (the implicit using shadow declaration) by default,
-// and there is no way to customize this behavior at the moment.
 using bar::v2;
 } // namespace foo
   )";
@@ -360,6 +357,7 @@
AllOf(QName("foo::int32_t"), ForCodeCompletion(true)),
AllOf(QName("foo::v1"), ForCodeCompletion(true)),
AllOf(QName("foo::bar::v2"), ForCodeCompletion(true)),
+   AllOf(QName("foo::v2"), ForCodeCompletion(true)),
AllOf(QName("foo::baz"), ForCodeCompletion(true))}));
 }
 
@@ -1149,6 +1147,16 @@
   AllOf(QName("Public"), Not(ImplementationDetail();
 }
 
+TEST_F(SymbolCollectorTest, UsingDecl) {
+  const char *Header = R"(
+  void foo();
+  namespace std {
+using ::foo;
+  })";
+  runSymbolCollector(Header, /**/ "");
+  EXPECT_THAT(Symbols, Contains(QName("std::foo")));
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: unittests/clangd/CodeCompleteTests.cpp
===
--- unittests/clangd/CodeCompleteTests.cpp
+++ unittests/clangd/CodeCompleteTests.cpp
@@ -17,6 +17,7 @@
 #include "SyncAPI.h"
 #include "TestFS.h"
 #include "TestIndex.h"
+#include "TestTU.h"
 #include "index/MemIndex.h"
 #include "clang/Sema/CodeCompleteConsumer.h"
 #include "llvm/Support/Error.h"
@@ -2314,6 +2315,26 @@
   EXPECT_THAT(R.Completions, ElementsAre(Named("loopVar")));
 }
 
+TEST(CompletionTest, UsingDecl) {
+  const char *Header(R"cpp(
+void foo(int);
+namespace std {
+  using ::foo;
+})cpp");
+  const char *Source(R"cpp(
+void bar() {
+  std::^;
+})cpp");
+  auto Index = TestTU::withHeaderCode(Header).index();
+  clangd::CodeCompleteOptions Opts;
+  Opts.Index = Index.get();
+  Opts.AllScopes = true;
+  auto R = completions(Source, {}, Opts);
+  EXPECT_THAT(R.Completions,
+  ElementsAre(AllOf(Scope("std::"), Named("foo"),
+Kind(CompletionItemKind::Reference;
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: unittests/clangd/FindSymbolsTests.cpp
===
--- unittests/clangd/FindSymbolsTests.cpp
+++ unittests/clangd/FindSymbolsTests.cpp
@@ -368,9 +368,6 @@
   // Namespace alias
   namespace baz = bar;
 
-  // FIXME: using declaration is not supported as the IndexAction will ignore
-  // implicit declarations (the implicit using shadow declaration) by default,
-  // and there is no way to customize this behavior at the moment.
   using bar::v2;
   } // namespace foo
 )");
@@ -415,7 +412,7 @@
   Children(,
  AllOf(WithName("baz"), WithKind(SymbolKind::Namespace),
Children()),
- AllOf(WithName("v2"), WithKind(SymbolKind::Variable}));
+ AllOf(WithName("v2"), WithKind(SymbolKind::Namespace}));
 }
 
 TEST_F(DocumentSymbolsTest, DeclarationDefinition) {
Index: unittests/clangd/SymbolInfoTests.cpp
===
--- unittests/clangd/SymbolInfoTests.cpp
+++ unittests/clangd/SymbolInfoTests.cpp
@@ -167,7 +167,8 @@
 )cpp",
   {CreateExpectedSymbolDetails("foo", "", "c:@F@foo#"),
CreateExpectedSymbolDetails("foo", "", "c:@F@foo#b#"),
-   CreateExpectedSymbolDetails("foo", "", "c:@F@foo#I#")}},
+   CreateExpectedSymbolDetails("foo", "", "c:@F@foo#I#"),
+   CreateExpectedSymbolDetails("foo", "bar::", "c:@N@bar@UD@foo")}},
   {
   R"cpp( // Multiple symbols returned - implicit conversion
   struct foo {};
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D57765: [ARM] Add Cortex-M35P Support

2019-02-26 Thread Luke Cheeseman via Phabricator via cfe-commits
LukeCheeseman updated this revision to Diff 188364.
LukeCheeseman added a comment.

- Test cpus Cortex-M33 and Cortex-M35P seperately


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

https://reviews.llvm.org/D57765

Files:
  test/Driver/arm-cortex-cpus.c


Index: test/Driver/arm-cortex-cpus.c
===
--- test/Driver/arm-cortex-cpus.c
+++ test/Driver/arm-cortex-cpus.c
@@ -822,8 +822,10 @@
 // RUN: %clang -target arm -mcpu=cortex-m23 -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-CPUV8MBASE %s
 // CHECK-CPUV8MBASE:  "-cc1"{{.*}} "-triple" "thumbv8m.base-
 
-// RUN: %clang -target arm -mcpu=cortex-m33 -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-CPUV8MMAIN %s
-// CHECK-CPUV8MMAIN:  "-cc1"{{.*}} "-triple" "thumbv8m.main-
+// RUN: %clang -target arm -mcpu=cortex-m33 -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-CORTEX-M33 %s
+// RUN: %clang -target arm -mcpu=cortex-m35p -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-CORTEX-M35P %s
+// CHECK-CORTEX-M33:  "-cc1"{{.*}} "-triple" "thumbv8m.main-{{.*}} 
"-target-cpu" "cortex-m33"
+// CHECK-CORTEX-M35P:  "-cc1"{{.*}} "-triple" "thumbv8m.main-{{.*}} 
"-target-cpu" "cortex-m35p"
 
 // == Check whether -mcpu accepts mixed-case values.
 // RUN: %clang -target arm-linux-gnueabi -mcpu=Cortex-a5 -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-CASE-INSENSITIVE-CPUV7A %s


Index: test/Driver/arm-cortex-cpus.c
===
--- test/Driver/arm-cortex-cpus.c
+++ test/Driver/arm-cortex-cpus.c
@@ -822,8 +822,10 @@
 // RUN: %clang -target arm -mcpu=cortex-m23 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV8MBASE %s
 // CHECK-CPUV8MBASE:  "-cc1"{{.*}} "-triple" "thumbv8m.base-
 
-// RUN: %clang -target arm -mcpu=cortex-m33 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV8MMAIN %s
-// CHECK-CPUV8MMAIN:  "-cc1"{{.*}} "-triple" "thumbv8m.main-
+// RUN: %clang -target arm -mcpu=cortex-m33 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-M33 %s
+// RUN: %clang -target arm -mcpu=cortex-m35p -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-M35P %s
+// CHECK-CORTEX-M33:  "-cc1"{{.*}} "-triple" "thumbv8m.main-{{.*}} "-target-cpu" "cortex-m33"
+// CHECK-CORTEX-M35P:  "-cc1"{{.*}} "-triple" "thumbv8m.main-{{.*}} "-target-cpu" "cortex-m35p"
 
 // == Check whether -mcpu accepts mixed-case values.
 // RUN: %clang -target arm-linux-gnueabi -mcpu=Cortex-a5 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CASE-INSENSITIVE-CPUV7A %s
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r354880 - [clang-format] SpaceBeforeParens for lambda expressions

2019-02-26 Thread Andrew Ng via cfe-commits
Author: anng
Date: Tue Feb 26 06:34:49 2019
New Revision: 354880

URL: http://llvm.org/viewvc/llvm-project?rev=354880&view=rev
Log:
[clang-format] SpaceBeforeParens for lambda expressions

Add support for lambda expressions to the SpaceBeforeParens formatting
option.

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

Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=354880&r1=354879&r2=354880&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Tue Feb 26 06:34:49 2019
@@ -2547,7 +2547,9 @@ bool TokenAnnotator::spaceRequiredBetwee
   (!Left.Previous || Left.Previous->isNot(tok::period) ||
(Style.SpaceBeforeParens == FormatStyle::SBPO_Always &&
 (Left.is(tok::identifier) || Left.isFunctionLikeKeyword() ||
- Left.is(tok::r_paren)) &&
+ Left.is(tok::r_paren) ||
+ (Left.is(tok::r_square) && Left.MatchingParen &&
+  Left.MatchingParen->is(TT_LambdaLSquare))) &&
 Line.Type != LT_PreprocessorDirective);
   }
   if (Left.is(tok::at) && Right.Tok.getObjCKeywordID() != 
tok::objc_not_keyword)

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=354880&r1=354879&r2=354880&view=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Tue Feb 26 06:34:49 2019
@@ -9238,6 +9238,7 @@ TEST_F(FormatTest, ConfigurableSpaceBefo
   verifyFormat("typedef void (*cb)(int);", NoSpace);
   verifyFormat("T A::operator()();", NoSpace);
   verifyFormat("X A::operator++(T);", NoSpace);
+  verifyFormat("auto lambda = []() { return 0; };", NoSpace);
 
   FormatStyle Space = getLLVMStyle();
   Space.SpaceBeforeParens = FormatStyle::SBPO_Always;
@@ -9285,6 +9286,7 @@ TEST_F(FormatTest, ConfigurableSpaceBefo
   verifyFormat("typedef void (*cb) (int);", Space);
   verifyFormat("T A::operator() ();", Space);
   verifyFormat("X A::operator++ (T);", Space);
+  verifyFormat("auto lambda = [] () { return 0; };", Space);
 }
 
 TEST_F(FormatTest, ConfigurableSpacesInParentheses) {


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


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

2019-02-26 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp:79
+return;
+  }
+

elide {} on small if statements


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D58609



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


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

2019-02-26 Thread Clement Courbet via Phabricator via cfe-commits
courbet updated this revision to Diff 188367.
courbet marked an inline comment as done.
courbet added a comment.

- cosmetics


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,41 @@
   this);
 }
 
+static bool isLikelyCharExpression(const Expr *Argument,
+   const ASTContext &Ctx) {
+  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 &Result) {
   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,41 @@
   this);
 }
 
+static bool isLikelyCharExpression(const Expr *Argument,
+   const ASTContext &Ctx) {
+  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 &Result) {
   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


r354885 - [libclang] Avoid crashing when getting layout info of an undeduced type.

2019-02-26 Thread Emilio Cobos Alvarez via cfe-commits
Author: emilio
Date: Tue Feb 26 07:04:18 2019
New Revision: 354885

URL: http://llvm.org/viewvc/llvm-project?rev=354885&view=rev
Log:
[libclang] Avoid crashing when getting layout info of an undeduced type.

When the type is not deducible, return an error instead of crashing.

This fixes https://bugs.llvm.org/show_bug.cgi?id=40813.

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

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

Modified: cfe/trunk/include/clang-c/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=354885&r1=354884&r2=354885&view=diff
==
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Tue Feb 26 07:04:18 2019
@@ -32,7 +32,7 @@
  * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
  */
 #define CINDEX_VERSION_MAJOR 0
-#define CINDEX_VERSION_MINOR 52
+#define CINDEX_VERSION_MINOR 53
 
 #define CINDEX_VERSION_ENCODE(major, minor) ( \
   ((major) * 1)   \
@@ -3841,7 +3841,11 @@ enum CXTypeLayoutError {
   /**
* The Field name is not valid for this record.
*/
-  CXTypeLayoutError_InvalidFieldName = -5
+  CXTypeLayoutError_InvalidFieldName = -5,
+  /**
+   * The type is undeduced.
+   */
+  CXTypeLayoutError_Undeduced = -6
 };
 
 /**

Modified: cfe/trunk/test/Index/print-type-size.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/print-type-size.cpp?rev=354885&r1=354884&r2=354885&view=diff
==
--- cfe/trunk/test/Index/print-type-size.cpp (original)
+++ cfe/trunk/test/Index/print-type-size.cpp Tue Feb 26 07:04:18 2019
@@ -400,4 +400,10 @@ plopplop;
 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;
+};
+
 }

Modified: cfe/trunk/tools/c-index-test/c-index-test.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/c-index-test.c?rev=354885&r1=354884&r2=354885&view=diff
==
--- cfe/trunk/tools/c-index-test/c-index-test.c (original)
+++ cfe/trunk/tools/c-index-test/c-index-test.c Tue Feb 26 07:04:18 2019
@@ -1670,29 +1670,44 @@ static enum CXChildVisitResult PrintType
   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 @@ static enum CXChildVisitResult PrintType
 if (IsBitfield)
   printf(" [BitFieldSize=%d]", clang_getFieldDeclBitWidth(cursor));
   }
+
  

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

2019-02-26 Thread Emilio Cobos Álvarez via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
emilio marked an inline comment as done.
Closed by commit rC354885: [libclang] Avoid crashing when getting layout info 
of an undeduced type. (authored by emilio, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D58569?vs=188254&id=188371#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D58569

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

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 52
+#define CINDEX_VERSION_MINOR 53
 
 #define CINDEX_VERSION_ENCODE(major, minor) ( \
   ((major) * 1)   \
@@ -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
 };
 
 /**
Index: test/Index/print-type-size.cpp
===
--- test/Index/print-type-size.cpp
+++ 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: tools/c-index-test/c-index-test.c
===
--- tools/c-index-test/c-index-test.c
+++ 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: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ 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

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

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

Thank you for all the reviews! :)


Repository:
  rC Clang

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] D56943: [clang-format][NFC] Allow getLLVMStyle() to take a language

2019-02-26 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.
Herald added a subscriber: jdoerfert.



Comment at: clang/lib/Format/ContinuationIndenter.cpp:193
   RawStringFormat.Language, &PredefinedStyle)) {
-PredefinedStyle = getLLVMStyle();
+PredefinedStyle = getLLVMStyle(FormatStyle::LK_Cpp);
 PredefinedStyle.Language = RawStringFormat.Language;

if you've set up a default argument of LK_Cpp do you need to keep supplying it? 
if your going to supply it everywhere don't make it a default argument or vice 
versa

This might make a much smaller patch, a little more digestable and all the 
tests can remain as they are.


Repository:
  rC Clang

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

https://reviews.llvm.org/D56943



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


[PATCH] D58035: [clang/DIVar] Emit flag for params that have unchanged values

2019-02-26 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro marked an inline comment as done.
djtodoro added inline comments.



Comment at: lib/Sema/SemaExpr.cpp:11292
+}
+
+/// Argument's value might be modified, so update the info.

riccibruno wrote:
> Hmm, I don't think that this will work. Suppose that you have an expression 
> like `(a, b) += c`  You want to mark `b` as modified, but not `a`. What is 
> needed I believe is:
> 
> Given an expression `E` find the variable that this expression designate if 
> any, and if it is a function parameter mark it "known to be modified".
> 
> Visiting all of the children just looking for `DeclRefExpr`s is a bit too 
> blunt I believe.
You are right. We thought it is possible implementing this with some basic 
analysis (with low overhead), but in order to support all cases it would take 
much time and it is not good idea.

I tried to use `ExprMutationAnalyzer ` (that @lebedev.ri mentioned) and it 
seems to be useful for this. It seems that it can be used a little bit later 
than in this phase, because it takes ASTContext, but in this stage we have 
ASTContext finished up to node we are currently observing (an expression from 
which we are extracting DeclRef). But, even using it in the right time, it 
seems that `ExprMutationAnalyzer ` does not have support for comma operator. 
I'm trying to extend this analyzer in order to add support for that. ASAP I 
will post new changes.
For the other cases I tried, it works.


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

https://reviews.llvm.org/D58035



___
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-26 Thread Hyrum Wright via Phabricator via cfe-commits
hwright updated this revision to Diff 188372.

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 = absl::Seconds(absl::ToUnixMicros(t) - x);
+
+  // Variou

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

2019-02-26 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D56411#1410153 , @rjmccall wrote:

> 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.


Currently there are two host-ness related issues about function type template 
arguments:

1. when there are two or more candidates for the template argument, clang goes 
through host-ness based overloading resolution, which does not work properly

2. when there is only one candidate for the template argument, clang does not 
go through overloading resolution, therefore the first issue does not show up. 
However, clang still checks host-ness of template argument. As discussed 
before, clang should not check host-ness in non-evaluation or 
constant-evaluation context. Instead, clang should check host-ness in template 
instantiation.

I refer the first issue as host-ness overloading resolution issue and the 
second issue as host-ness validation issue. They are related but separate.

The first issue only happens when host-ness based overloading resolution is 
used. For applications which can be compiled with nvcc, this cannot happen, 
therefore it is less common and less urgent.

The second issue can happen to applications which can be compiled with nvcc, 
therefore is more imminent.

Fixing the second issue is relatively straightforward. It does not need to 
introduce new AST types for host-ness. Also it is orthogonal to fixing the 
first 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] D58137: [clang-tidy] Add the abseil-time-subtraction check

2019-02-26 Thread Hyrum Wright via Phabricator via cfe-commits
hwright marked an inline comment as done.
hwright added inline comments.



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

hwright wrote:
> 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?
I've pulled out the common duplicated functionality which actually emits the 
diagnostic, and I think that's simplified these branches a bit more.


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] D58675: [clang] Adds `-ftime-trace` option to clang that produces Chrome `chrome://tracing` compatible JSON profiling output dumps

2019-02-26 Thread Anton Afanasyev via Phabricator via cfe-commits
anton-afanasyev created this revision.
Herald added subscribers: llvm-commits, cfe-commits, jdoerfert, arphaman, 
mgrang, hiraditya, mgorny, mehdi_amini.
Herald added projects: clang, LLVM.

This is the first part of time tracing system, I have splitted them cause this 
part is mostly written by Aras Pranckevicius except of several minor fixes 
concerning formatting. I'm to commit this in behalf of Aras, we have an 
arrangment with him.
The second part extends this option adding terminal output making no need for 
profiling visualization. I can also add xray support though this need is 
arguable.
The third part is for cleaning up previous attempts of such implementations 
(like https://reviews.llvm.org/D45619, https://reviews.llvm.org/D43578 and 
https://reviews.llvm.org/D47196).

This is taken from GitHub PR: 
https://github.com/aras-p/llvm-project-20170507/pull/2
Here is cfe maillist subject discussion: 
http://lists.llvm.org/pipermail/cfe-dev/2019-January/060836.html


Repository:
  rC Clang

https://reviews.llvm.org/D58675

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/include/clang/Frontend/FrontendOptions.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Parse/ParseAST.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseTemplate.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/lib/Serialization/GlobalModuleIndex.cpp
  clang/tools/driver/cc1_main.cpp
  llvm/lib/IR/LegacyPassManager.cpp
  llvm/lib/Support/CMakeLists.txt
  llvm/lib/Support/TimeProfiler.cpp
  llvm/lib/Support/TimeProfiler.h

Index: llvm/lib/Support/TimeProfiler.h
===
--- /dev/null
+++ llvm/lib/Support/TimeProfiler.h
@@ -0,0 +1,71 @@
+//===- llvm/Support/TimeProfiler.h - Hierarchical Time Profiler -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_SUPPORT_TIME_PROFILER_H
+#define LLVM_SUPPORT_TIME_PROFILER_H
+
+#include "llvm/Support/raw_ostream.h"
+
+namespace llvm {
+
+struct TimeTraceProfiler;
+extern TimeTraceProfiler *TimeTraceProfilerInstance;
+
+/// Initialize the time trace profiler.
+/// This sets up the global \p TimeTraceProfilerInstance
+/// variable to be the profiler instance.
+void TimeTraceProfilerInitialize();
+
+/// Cleanup the time trace profiler, if it was initialized.
+void TimeTraceProfilerCleanup();
+
+/// Is the time trace profiler enabled, i.e. initialized?
+inline bool TimeTraceProfilerEnabled() {
+  return TimeTraceProfilerInstance != nullptr;
+}
+
+/// Write profiling data to output file.
+/// Data produced is JSON, in Chrome "Trace Event" format, see
+/// https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview
+void TimeTraceProfilerWrite(std::unique_ptr &OS);
+
+/// Manually begin a time section, with the given \p name and \p detail.
+/// Profiler copies the string data, so the pointers can be given into
+/// temporaries. Time sections can be hierarchical; every Begin must have a
+/// matching End pair but they can nest.
+void TimeTraceProfilerBegin(const char *name, const char *detail);
+
+/// Manually end the last time section.
+void TimeTraceProfilerEnd();
+
+/// The TimeTraceScope is a helper class to call the begin and end functions.
+/// of the time trace profiler.  When the object is constructed, it
+/// begins the section; and wen it is destroyed, it stops
+/// it.  If the time profiler is not initialized, the overhead
+/// is a single branch.
+struct TimeTraceScope {
+  TimeTraceScope(const char *name, const char *detail) {
+if (TimeTraceProfilerInstance != nullptr)
+  TimeTraceProfilerBegin(name, detail);
+  }
+  ~TimeTraceScope() {
+if (TimeTraceProfilerInstance != nullptr)
+  TimeTraceProfilerEnd();
+  }
+};
+
+/// Evaluates expression if time trace profiler is enabled, or passed null when
+/// it is not. Useful to avoid possibly expensive work in creating a string for
+/// profiling, when profiler is not enabled at all.
+#define TIME_TRACE_OR_NULL(expr)   \
+  (llvm::TimeTraceProfilerInstance != nullptr ? (expr) : nullptr)
+
+} // end namespace llvm
+
+#endif
Index: llvm/lib/Support/TimeProfiler.cpp
===
--- /dev/null
+++ llvm/lib/Support/TimeProfiler.cpp
@@ -0,0 +1,178 @@
+//===-- TimeProfiler.cpp - Hierarchical Time Profiler -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University

[PATCH] D58494: [ASTImporter] Handle redecl chain of FunctionTemplateDecls

2019-02-26 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 188379.
martong marked 4 inline comments as done.
martong added a comment.

- getDefinition -> getTemplateDefinition
- Remove comments for braces, added FIXME


Repository:
  rC Clang

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

https://reviews.llvm.org/D58494

Files:
  lib/AST/ASTImporter.cpp
  unittests/AST/ASTImporterTest.cpp

Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -4163,9 +4163,8 @@
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(
 RedeclChain, Variable, ,
 PrototypeShouldBeImportedAsAPrototypeWhenThereIsNoDefinition)
-// FIXME Enable this test, once we import function templates chains correctly.
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(
-RedeclChain, FunctionTemplate, DISABLED_,
+RedeclChain, FunctionTemplate, ,
 PrototypeShouldBeImportedAsAPrototypeWhenThereIsNoDefinition)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(
 RedeclChain, ClassTemplate, ,
@@ -4180,9 +4179,8 @@
 RedeclChain, Class, , DefinitionShouldBeImportedAsADefinition)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(
 RedeclChain, Variable, , DefinitionShouldBeImportedAsADefinition)
-// FIXME Enable this test, once we import function templates chains correctly.
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(
-RedeclChain, FunctionTemplate, DISABLED_,
+RedeclChain, FunctionTemplate, ,
 DefinitionShouldBeImportedAsADefinition)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(
 RedeclChain, ClassTemplate, , DefinitionShouldBeImportedAsADefinition)
@@ -4196,9 +4194,7 @@
 ImportPrototypeAfterImportedPrototype)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, Variable, ,
 ImportPrototypeAfterImportedPrototype)
-// FIXME Enable this test, once we import function templates chains correctly.
-ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, FunctionTemplate,
-DISABLED_,
+ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, FunctionTemplate, ,
 ImportPrototypeAfterImportedPrototype)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, ClassTemplate, ,
 ImportPrototypeAfterImportedPrototype)
@@ -4212,9 +4208,7 @@
 ImportDefinitionAfterImportedPrototype)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, Variable, ,
 ImportDefinitionAfterImportedPrototype)
-// FIXME Enable this test, once we import function templates chains correctly.
-ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, FunctionTemplate,
-DISABLED_,
+ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, FunctionTemplate, ,
 ImportDefinitionAfterImportedPrototype)
 // FIXME This does not pass, possible error with ClassTemplate import.
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, ClassTemplate, DISABLED_,
@@ -4229,9 +4223,7 @@
 ImportPrototypeAfterImportedDefinition)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, Variable, ,
 ImportPrototypeAfterImportedDefinition)
-// FIXME Enable this test, once we import function templates chains correctly.
-ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, FunctionTemplate,
-DISABLED_,
+ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, FunctionTemplate, ,
 ImportPrototypeAfterImportedDefinition)
 // FIXME This does not pass, possible error with ClassTemplate import.
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, ClassTemplate, DISABLED_,
@@ -4244,9 +4236,8 @@
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, Class, , ImportPrototypes)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, Variable, ,
 ImportPrototypes)
-// FIXME Enable this test, once we import function templates chains correctly.
-ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, FunctionTemplate,
-DISABLED_, ImportPrototypes)
+ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, FunctionTemplate, ,
+ImportPrototypes)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, ClassTemplate, ,
 ImportPrototypes)
 // FIXME This does not pass, possible error with Spec import.
@@ -4259,9 +4250,8 @@
 ImportDefinitions)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, Variable, ,
 ImportDefinitions)
-// FIXME Enable this test, once we import function templates chains corr

r354893 - [OpenCL] Fix assertion due to blocks

2019-02-26 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Tue Feb 26 08:20:41 2019
New Revision: 354893

URL: http://llvm.org/viewvc/llvm-project?rev=354893&view=rev
Log:
[OpenCL] Fix assertion due to blocks

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

There is code

  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.

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

Modified:
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/test/CodeGenOpenCL/blocks.cl

Modified: cfe/trunk/lib/AST/Expr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=354893&r1=354892&r2=354893&view=diff
==
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Tue Feb 26 08:20:41 2019
@@ -1358,6 +1358,8 @@ Decl *Expr::getReferencedDeclOfCallee()
 return DRE->getDecl();
   if (MemberExpr *ME = dyn_cast(CEE))
 return ME->getMemberDecl();
+  if (auto *BE = dyn_cast(CEE))
+return BE->getBlockDecl();
 
   return nullptr;
 }

Modified: cfe/trunk/test/CodeGenOpenCL/blocks.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/blocks.cl?rev=354893&r1=354892&r2=354893&view=diff
==
--- cfe/trunk/test/CodeGenOpenCL/blocks.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/blocks.cl Tue Feb 26 08:20:41 2019
@@ -90,6 +90,12 @@ int get42() {
   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"
 


___
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-26 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC354893: [OpenCL] Fix assertion due to blocks (authored by 
yaxunl, committed by ).
Herald added a project: clang.

Repository:
  rC Clang

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

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] D58494: [ASTImporter] Handle redecl chain of FunctionTemplateDecls

2019-02-26 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: lib/AST/ASTImporter.cpp:4966
 // it has any definition in the redecl chain.
-static ClassTemplateDecl *getDefinition(ClassTemplateDecl *D) {
-  CXXRecordDecl *ToTemplatedDef = D->getTemplatedDecl()->getDefinition();
+template  static auto getDefinition(T *D) -> T * {
+  auto *ToTemplatedDef = D->getTemplatedDecl()->getDefinition();

a_sidorin wrote:
> We should point that this function is for TemplateDecls only somehow. But we 
> can't just pass TemplateDecl as the parameter due to loss of the actual 
> return type. Maybewe should rename this function into 
> "getTemplateDefinition()"?
Ok, I changed that to `getTemplateDefinition`.



Comment at: lib/AST/ASTImporter.cpp:5563
+  // TODO: handle conflicting names
+} // linkage
+  }   // template

a_sidorin wrote:
> We don't usually put such comments after control flow statements. If they are 
> really needed, it is a good sign that a function must be split, and it's 
> better to leave a FIXME for this (or do the split).
Ok, I removed these comments and added a FIXME.


Repository:
  rC Clang

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

https://reviews.llvm.org/D58494



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


[PATCH] D57716: [CUDA][HIP] Check calling convention based on function target

2019-02-26 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

ping


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

https://reviews.llvm.org/D57716



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


[PATCH] D58343: Enablement for AMD znver2 architecture - skeleton patch

2019-02-26 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354897: [X86] AMD znver2 enablement (authored by ggopala, 
committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D58343?vs=187389&id=188391#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D58343

Files:
  llvm/trunk/include/llvm/Support/X86TargetParser.def
  llvm/trunk/lib/Support/Host.cpp
  llvm/trunk/lib/Target/X86/X86.td
  llvm/trunk/test/CodeGen/X86/cpus-amd.ll
  llvm/trunk/test/CodeGen/X86/lzcnt-zext-cmp.ll
  llvm/trunk/test/CodeGen/X86/slow-unaligned-mem.ll
  llvm/trunk/test/CodeGen/X86/x86-64-double-shifts-var.ll

Index: llvm/trunk/include/llvm/Support/X86TargetParser.def
===
--- llvm/trunk/include/llvm/Support/X86TargetParser.def
+++ llvm/trunk/include/llvm/Support/X86TargetParser.def
@@ -98,6 +98,7 @@
 X86_CPU_SUBTYPE_COMPAT("cannonlake", INTEL_COREI7_CANNONLAKE, "cannonlake")
 X86_CPU_SUBTYPE_COMPAT("icelake-client", INTEL_COREI7_ICELAKE_CLIENT, "icelake-client")
 X86_CPU_SUBTYPE_COMPAT("icelake-server", INTEL_COREI7_ICELAKE_SERVER, "icelake-server")
+X86_CPU_SUBTYPE_COMPAT("znver2", AMDFAM17H_ZNVER2,"znver2")
 // Entries below this are not in libgcc/compiler-rt.
 X86_CPU_SUBTYPE   ("core2",  INTEL_CORE2_65)
 X86_CPU_SUBTYPE   ("penryn", INTEL_CORE2_45)
Index: llvm/trunk/test/CodeGen/X86/x86-64-double-shifts-var.ll
===
--- llvm/trunk/test/CodeGen/X86/x86-64-double-shifts-var.ll
+++ llvm/trunk/test/CodeGen/X86/x86-64-double-shifts-var.ll
@@ -13,8 +13,9 @@
 ; RUN: llc < %s -mtriple=x86_64-- -mcpu=bdver3 | FileCheck %s
 ; RUN: llc < %s -mtriple=x86_64-- -mcpu=bdver4 | FileCheck %s
 ; RUN: llc < %s -mtriple=x86_64-- -mcpu=znver1 | FileCheck %s
+; RUN: llc < %s -mtriple=x86_64-- -mcpu=znver2 | FileCheck %s
 
-; Verify that for the X86_64 processors that are known to have poor latency 
+; Verify that for the X86_64 processors that are known to have poor latency
 ; double precision shift instructions we do not generate 'shld' or 'shrd'
 ; instructions.
 
@@ -25,7 +26,7 @@
 
 define i64 @lshift(i64 %a, i64 %b, i32 %c) nounwind readnone {
 entry:
-; CHECK-NOT: shld 
+; CHECK-NOT: shld
   %sh_prom = zext i32 %c to i64
   %shl = shl i64 %a, %sh_prom
   %sub = sub nsw i32 64, %c
Index: llvm/trunk/test/CodeGen/X86/cpus-amd.ll
===
--- llvm/trunk/test/CodeGen/X86/cpus-amd.ll
+++ llvm/trunk/test/CodeGen/X86/cpus-amd.ll
@@ -26,6 +26,7 @@
 ; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=btver1 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=btver2 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=znver1 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=znver2 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 
 define void @foo() {
   ret void
Index: llvm/trunk/test/CodeGen/X86/lzcnt-zext-cmp.ll
===
--- llvm/trunk/test/CodeGen/X86/lzcnt-zext-cmp.ll
+++ llvm/trunk/test/CodeGen/X86/lzcnt-zext-cmp.ll
@@ -5,6 +5,8 @@
 ; RUN: llc < %s -mtriple=x86_64-pc-linux -mcpu=btver2 -mattr=-fast-lzcnt | FileCheck --check-prefix=ALL --check-prefix=NOFASTLZCNT %s
 ; RUN: llc < %s -mtriple=x86_64-pc-linux -mcpu=znver1 | FileCheck --check-prefix=ALL --check-prefix=FASTLZCNT %s
 ; RUN: llc < %s -mtriple=x86_64-pc-linux -mcpu=znver1 -mattr=-fast-lzcnt | FileCheck --check-prefix=ALL --check-prefix=NOFASTLZCNT %s
+; RUN: llc < %s -mtriple=x86_64-pc-linux -mcpu=znver2 | FileCheck --check-prefix=ALL --check-prefix=FASTLZCNT %s
+; RUN: llc < %s -mtriple=x86_64-pc-linux -mcpu=znver2 -mattr=-fast-lzcnt | FileCheck --check-prefix=ALL --check-prefix=NOFASTLZCNT %s
 
 ; Test one 32-bit input, output is 32-bit, no transformations expected.
 define i32 @test_zext_cmp0(i32 %a) {
Index: llvm/trunk/test/CodeGen/X86/slow-unaligned-mem.ll
===
--- llvm/trunk/test/CodeGen/X86/slow-unaligned-mem.ll
+++ llvm/trunk/test/CodeGen/X86/slow-unaligned-mem.ll
@@ -47,6 +47,7 @@
 ; RUN: llc < %s -mtriple=i386-unknown-unknown -mcpu=bdver32>&1 | FileCheck %s --check-prefix=FAST
 ; RUN: llc < %s -mtriple=i386-unknown-unknown -mcpu=bdver42>&1 | FileCheck %s --check-prefix=FAST
 ; RUN: llc < %s -mtriple=i386-unknown-unknown -mcpu=znver12>&1 | FileCheck %s --check-prefix=FAST
+; RUN: llc < %s -mtriple=i386-unknown-unknown -mcpu=znver22>&1 | FileCheck %s --check-prefix=FAST
 
 ; Other chips with slow unaligned memory accesse

[PATCH] D58344: Enablement for AMD znver2 architecture - skeleton

2019-02-26 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354899: [X86] AMD znver2 enablement (authored by ggopala, 
committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D58344?vs=187387&id=188394#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D58344

Files:
  cfe/trunk/include/clang/Basic/X86Target.def
  cfe/trunk/lib/Basic/Targets/X86.cpp
  cfe/trunk/test/CodeGen/target-builtin-noerror.c
  cfe/trunk/test/Driver/x86-march.c
  cfe/trunk/test/Frontend/x86-target-cpu.c
  cfe/trunk/test/Misc/target-invalid-cpu-note.c
  cfe/trunk/test/Preprocessor/predefined-arch-macros.c

Index: cfe/trunk/include/clang/Basic/X86Target.def
===
--- cfe/trunk/include/clang/Basic/X86Target.def
+++ cfe/trunk/include/clang/Basic/X86Target.def
@@ -236,6 +236,7 @@
 /// Zen architecture processors.
 //@{
 PROC_WITH_FEAT(ZNVER1, "znver1", PROC_64_BIT, FEATURE_AVX2)
+PROC_WITH_FEAT(ZNVER2, "znver2", PROC_64_BIT, FEATURE_AVX2)
 //@}
 
 /// This specification is deprecated and will be removed in the future.
Index: cfe/trunk/test/Driver/x86-march.c
===
--- cfe/trunk/test/Driver/x86-march.c
+++ cfe/trunk/test/Driver/x86-march.c
@@ -159,3 +159,7 @@
 // RUN: %clang -target x86_64-unknown-unknown -c -### %s -march=znver1 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=znver1
 // znver1: "-target-cpu" "znver1"
+//
+// RUN: %clang -target x86_64-unknown-unknown -c -### %s -march=znver2 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=znver2
+// znver2: "-target-cpu" "znver2"
Index: cfe/trunk/test/Frontend/x86-target-cpu.c
===
--- cfe/trunk/test/Frontend/x86-target-cpu.c
+++ cfe/trunk/test/Frontend/x86-target-cpu.c
@@ -35,5 +35,6 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu btver1 -verify %s
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu btver2 -verify %s
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu znver1 -verify %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu znver2 -verify %s
 //
 // expected-no-diagnostics
Index: cfe/trunk/test/CodeGen/target-builtin-noerror.c
===
--- cfe/trunk/test/CodeGen/target-builtin-noerror.c
+++ cfe/trunk/test/CodeGen/target-builtin-noerror.c
@@ -120,4 +120,5 @@
   (void)__builtin_cpu_is("tremont");
   (void)__builtin_cpu_is("westmere");
   (void)__builtin_cpu_is("znver1");
+  (void)__builtin_cpu_is("znver2");
 }
Index: cfe/trunk/test/Misc/target-invalid-cpu-note.c
===
--- cfe/trunk/test/Misc/target-invalid-cpu-note.c
+++ cfe/trunk/test/Misc/target-invalid-cpu-note.c
@@ -19,7 +19,7 @@
 // X86-SAME: skx, cascadelake, cannonlake, icelake-client, icelake-server, knl, knm, lakemont, k6, k6-2, k6-3,
 // X86-SAME: athlon, athlon-tbird, athlon-xp, athlon-mp, athlon-4, k8, athlon64,
 // X86-SAME: athlon-fx, opteron, k8-sse3, athlon64-sse3, opteron-sse3, amdfam10,
-// X86-SAME: barcelona, btver1, btver2, bdver1, bdver2, bdver3, bdver4, znver1,
+// X86-SAME: barcelona, btver1, btver2, bdver1, bdver2, bdver3, bdver4, znver1, znver2,
 // X86-SAME: x86-64, geode
 
 // RUN: not %clang_cc1 -triple x86_64--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix X86_64
@@ -30,7 +30,7 @@
 // X86_64-SAME: core-avx2, broadwell, skylake, skylake-avx512, skx, cascadelake, cannonlake,
 // X86_64-SAME: icelake-client, icelake-server, knl, knm, k8, athlon64, athlon-fx, opteron, k8-sse3,
 // X86_64-SAME: athlon64-sse3, opteron-sse3, amdfam10, barcelona, btver1,
-// X86_64-SAME: btver2, bdver1, bdver2, bdver3, bdver4, znver1, x86-64
+// X86_64-SAME: btver2, bdver1, bdver2, bdver3, bdver4, znver1, znver2, x86-64
 
 // RUN: not %clang_cc1 -triple nvptx--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix NVPTX
 // NVPTX: error: unknown target CPU 'not-a-cpu'
Index: cfe/trunk/test/Preprocessor/predefined-arch-macros.c
===
--- cfe/trunk/test/Preprocessor/predefined-arch-macros.c
+++ cfe/trunk/test/Preprocessor/predefined-arch-macros.c
@@ -2676,6 +2676,100 @@
 // CHECK_ZNVER1_M64: #define __znver1 1
 // CHECK_ZNVER1_M64: #define __znver1__ 1
 
+// RUN: %clang -march=znver2 -m32 -E -dM %s -o - 2>&1 \
+// RUN: -target i386-unknown-linux \
+// RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_ZNVER2_M32
+// CHECK_ZNVER2_M32-NOT: #define __3dNOW_A__ 1
+// CHECK_ZNVER2_M32-NOT: #define __3dNOW__ 1
+// CHECK_ZNVER2_M32: #define __ADX__ 1
+// CHECK_ZNVER2_M32: #define __AES__ 1
+// CHECK_ZNVER2_M32: #define __AVX2__ 1
+// CHECK_ZNVER2_M32: #define __AVX__ 1
+// CHE

[PATCH] D58683: [clangd] Set thread priority on Windows

2019-02-26 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added reviewers: kadircet, gribozavr.
Herald added subscribers: arphaman, jkorous, MaskRay, ioeric.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D58683

Files:
  clang-tools-extra/clangd/Threading.cpp


Index: clang-tools-extra/clangd/Threading.cpp
===
--- clang-tools-extra/clangd/Threading.cpp
+++ clang-tools-extra/clangd/Threading.cpp
@@ -9,6 +9,8 @@
 #include 
 #elif defined(__APPLE__)
 #include 
+#elif defined (_WIN32)
+#include 
 #endif
 
 namespace clang {
@@ -129,6 +131,11 @@
   Priority == ThreadPriority::Low && !AvoidThreadStarvation
   ? PRIO_DARWIN_BG
   : 0);
+#elif defined(_WIN32)
+  SetThreadPriority(GetCurrentThread(),
+Priority == ThreadPriority::Low && !AvoidThreadStarvation
+? THREAD_MODE_BACKGROUND_BEGIN
+: THREAD_MODE_BACKGROUND_END);
 #endif
 }
 


Index: clang-tools-extra/clangd/Threading.cpp
===
--- clang-tools-extra/clangd/Threading.cpp
+++ clang-tools-extra/clangd/Threading.cpp
@@ -9,6 +9,8 @@
 #include 
 #elif defined(__APPLE__)
 #include 
+#elif defined (_WIN32)
+#include 
 #endif
 
 namespace clang {
@@ -129,6 +131,11 @@
   Priority == ThreadPriority::Low && !AvoidThreadStarvation
   ? PRIO_DARWIN_BG
   : 0);
+#elif defined(_WIN32)
+  SetThreadPriority(GetCurrentThread(),
+Priority == ThreadPriority::Low && !AvoidThreadStarvation
+? THREAD_MODE_BACKGROUND_BEGIN
+: THREAD_MODE_BACKGROUND_END);
 #endif
 }
 
___
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-26 Thread Tom Roeder via Phabricator via cfe-commits
tmroeder updated this revision to Diff 188397.
tmroeder added a comment.

Added the other expectation, as suggested.


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,29 @@
   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());
+  EXPECT_EQ(FromChooseExpr->isConditionDependent(),
+ToChooseExpr->isConditionDependent());
+}
+
 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;
 const internal::VariadicDynCastAllOfMatcher atomicExpr;
 const internal::VariadicDynCastAllOfMatcher stmtExpr;
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++

[PATCH] D57906: [CTU] Do not allow different CPP dialects in CTU

2019-02-26 Thread Gabor Marton via Phabricator via cfe-commits
martong marked 2 inline comments as done.
martong added inline comments.



Comment at: lib/CrossTU/CrossTranslationUnit.cpp:255
+  // in the other unit it has none.
+  if (LangTo.CPlusPlus11 != LangFrom.CPlusPlus11 ||
+  LangTo.CPlusPlus14 != LangFrom.CPlusPlus14 ||

r.stahl wrote:
> This is likely to become a bug in the future, but I didn't see a better way 
> to compare dialects.
> 
> Is there a way to add a test that lights up once there is a new dialect?
> 
> Would it be too pessimistic to compare the entire LangOpts? Some stuff in 
> there should even still produce errors, right? For example "GnuMode". I 
> skimmed over them and didn't find an obvious one that would differ between 
> translation units of the same project. Maybe the template depth could be set 
> selectively, but to fix that we could mask "COMPATIBLE_" and "BENIGN_" opts.
> This is likely to become a bug in the future, but I didn't see a better way 
> to compare dialects.
> Is there a way to add a test that lights up once there is a new dialect?

`LANGOPTS` are defined as bitfields: `#define LANGOPT(Name, Bits, Default, 
Description) unsigned Name : Bits;`
I can't think of any solution to avoid the future bug, because there is no way 
to enumerate all the C++ dialects.
I am going to ask around about this on cfe-dev, maybe somebody will have an 
idea.

> Would it be too pessimistic to compare the entire LangOpts?
I think that would be too pessimistic.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57906



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


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

2019-02-26 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks!


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


[clang-tools-extra] r354903 - [clang-tidy] undo bitfields in ExceptionAnalyzer

2019-02-26 Thread Jonas Toth via cfe-commits
Author: jonastoth
Date: Tue Feb 26 10:15:17 2019
New Revision: 354903

URL: http://llvm.org/viewvc/llvm-project?rev=354903&view=rev
Log:
[clang-tidy] undo bitfields in ExceptionAnalyzer

Scoped enums do induce some problems with some MSVC and GCC versions
if used as bitfields. Therefor this is deactivated for now.

Modified:
clang-tools-extra/trunk/clang-tidy/utils/ExceptionAnalyzer.h

Modified: clang-tools-extra/trunk/clang-tidy/utils/ExceptionAnalyzer.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/utils/ExceptionAnalyzer.h?rev=354903&r1=354902&r2=354903&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/utils/ExceptionAnalyzer.h (original)
+++ clang-tools-extra/trunk/clang-tidy/utils/ExceptionAnalyzer.h Tue Feb 26 
10:15:17 2019
@@ -109,19 +109,17 @@ public:
 
 /// Keep track if the entity related to this 'ExceptionInfo' can in 
princple
 /// throw, if it's unknown or if it won't throw.
-State Behaviour : 2;
+State Behaviour;
 
 /// Keep track if the entity contains any unknown elements to keep track
 /// of the certainty of decisions and/or correct 'Behaviour' transition
 /// after filtering.
-bool ContainsUnknown : 1;
+bool ContainsUnknown;
 
 /// 'ThrownException' is empty if the 'Behaviour' is either 'NotThrowing' 
or
 /// 'Unknown'.
 Throwables ThrownExceptions;
   };
-  static_assert(sizeof(ExceptionInfo) <= 64u,
-"size of exceptioninfo shall be at max one cache line");
 
   ExceptionAnalyzer() = default;
 


___
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-26 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert updated this revision to Diff 188411.
jdoerfert marked an inline comment as done.
jdoerfert added a comment.

Fix typo


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);
 return nullpt

[PATCH] D58463: [CUDA]Delayed diagnostics for the asm instructions.

2019-02-26 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

There's a new quirk we've ran into after this patch landed. Consider this code:

  int foo() {
int prev;
__asm__ __volatile__("whatever" : "=a" (prev)::);
return prev;
  }

When we compile for device, asm constraint is not valid for NVPTX, we emit 
delayed diag and move on. The function is never code-gen'ed so the diag never 
shows up. So far so good.

Now we add `-Werror -Wininitialized` and things break -- because we bail out 
early, `prev` is left uninitialized and is reported as such.

  $ bin/clang++ -c --cuda-gpu-arch=sm_35 asm.cu -nocudainc --cuda-device-only 
-Wuninitialized -Werror
  asm.cu:4:10: error: variable 'prev' is uninitialized when used here 
[-Werror,-Wuninitialized]
return prev;
   ^~~~
  asm.cu:2:11: note: initialize the variable 'prev' to silence this warning
int prev;
^
 = 0
  1 error generated when compiling for sm_35.

I think this should also show up in the test case in this patch, too, if you 
add -Wuninitialized


Repository:
  rL LLVM

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

https://reviews.llvm.org/D58463



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


r354909 - [AMDGPU] Allow using integral non-type template parameters

2019-02-26 Thread Michael Liao via cfe-commits
Author: hliao
Date: Tue Feb 26 10:49:36 2019
New Revision: 354909

URL: http://llvm.org/viewvc/llvm-project?rev=354909&view=rev
Log:
[AMDGPU] Allow using integral non-type template parameters

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

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

Reviewers: kzhuravl, yaxunl

Subscribers: jvesely, wdng, nhaehnle, dstuttard, tpr, t-tye, jdoerfert, 
cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/test/SemaCUDA/amdgpu-attrs.cu
cfe/trunk/test/SemaOpenCL/amdgpu-attrs.cl

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=354909&r1=354908&r2=354909&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Tue Feb 26 10:49:36 2019
@@ -1484,14 +1484,14 @@ def RISCVInterrupt : InheritableAttr, Ta
 
 def AMDGPUFlatWorkGroupSize : InheritableAttr {
   let Spellings = [Clang<"amdgpu_flat_work_group_size", 0>];
-  let Args = [UnsignedArgument<"Min">, UnsignedArgument<"Max">];
+  let Args = [ExprArgument<"Min">, ExprArgument<"Max">];
   let Documentation = [AMDGPUFlatWorkGroupSizeDocs];
   let Subjects = SubjectList<[Function], ErrorDiag, "kernel functions">;
 }
 
 def AMDGPUWavesPerEU : InheritableAttr {
   let Spellings = [Clang<"amdgpu_waves_per_eu", 0>];
-  let Args = [UnsignedArgument<"Min">, UnsignedArgument<"Max", 1>];
+  let Args = [ExprArgument<"Min">, ExprArgument<"Max", 1>];
   let Documentation = [AMDGPUWavesPerEUDocs];
   let Subjects = SubjectList<[Function], ErrorDiag, "kernel functions">;
 }

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=354909&r1=354908&r2=354909&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Tue Feb 26 10:49:36 2019
@@ -8674,6 +8674,16 @@ public:
   void AddXConsumedAttr(Decl *D, SourceRange SR, unsigned SpellingIndex,
 RetainOwnershipKind K, bool IsTemplateInstantiation);
 
+  /// addAMDGPUFlatWorkGroupSizeAttr - Adds an amdgpu_flat_work_group_size
+  /// attribute to a particular declaration.
+  void addAMDGPUFlatWorkGroupSizeAttr(SourceRange AttrRange, Decl *D, Expr 
*Min,
+  Expr *Max, unsigned SpellingListIndex);
+
+  /// addAMDGPUWavePersEUAttr - Adds an amdgpu_waves_per_eu attribute to a
+  /// particular declaration.
+  void addAMDGPUWavesPerEUAttr(SourceRange AttrRange, Decl *D, Expr *Min,
+   Expr *Max, unsigned SpellingListIndex);
+
   bool checkNSReturnsRetainedReturnType(SourceLocation loc, QualType type);
 
   
//======//

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=354909&r1=354908&r2=354909&view=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Tue Feb 26 10:49:36 2019
@@ -7797,8 +7797,16 @@ void AMDGPUTargetCodeGenInfo::setTargetA
 
   const auto *FlatWGS = FD->getAttr();
   if (ReqdWGS || FlatWGS) {
-unsigned Min = FlatWGS ? FlatWGS->getMin() : 0;
-unsigned Max = FlatWGS ? FlatWGS->getMax() : 0;
+unsigned Min = 0;
+unsigned Max = 0;
+if (FlatWGS) {
+  Min = FlatWGS->getMin()
+->EvaluateKnownConstInt(M.getContext())
+.getExtValue();
+  Max = FlatWGS->getMax()
+->EvaluateKnownConstInt(M.getContext())
+.getExtValue();
+}
 if (ReqdWGS && Min == 0 && Max == 0)
   Min = Max = ReqdWGS->getXDim() * ReqdWGS->getYDim() * ReqdWGS->getZDim();
 
@@ -7812,8 +7820,12 @@ void AMDGPUTargetCodeGenInfo::setTargetA
   }
 
   if (const auto *Attr = FD->getAttr()) {
-unsigned Min = Attr->getMin();
-unsigned Max = Attr->getMax();
+unsigned Min =
+Attr->getMin()->EvaluateKnownConstInt(M.getContext()).getExtValue();
+unsigned Max = Attr->getMax() ? Attr->getMax()
+->EvaluateKnownConstInt(M.getContext())
+.getExtValue()
+  : 0;
 
 if (Min != 0) {
   assert((Max == 0 || Min <= Max) && "Min must be less than or equal Max");

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp

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

2019-02-26 Thread Michael Liao via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC354909: [AMDGPU] Allow using integral non-type template 
parameters (authored by hliao, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D58623?vs=188172&id=188416#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D58623

Files:
  include/clang/Basic/Attr.td
  include/clang/Sema/Sema.h
  lib/CodeGen/TargetInfo.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  test/SemaCUDA/amdgpu-attrs.cu
  test/SemaOpenCL/amdgpu-attrs.cl

Index: include/clang/Sema/Sema.h
===
--- include/clang/Sema/Sema.h
+++ include/clang/Sema/Sema.h
@@ -8674,6 +8674,16 @@
   void AddXConsumedAttr(Decl *D, SourceRange SR, unsigned SpellingIndex,
 RetainOwnershipKind K, bool IsTemplateInstantiation);
 
+  /// addAMDGPUFlatWorkGroupSizeAttr - Adds an amdgpu_flat_work_group_size
+  /// attribute to a particular declaration.
+  void addAMDGPUFlatWorkGroupSizeAttr(SourceRange AttrRange, Decl *D, Expr *Min,
+  Expr *Max, unsigned SpellingListIndex);
+
+  /// addAMDGPUWavePersEUAttr - Adds an amdgpu_waves_per_eu attribute to a
+  /// particular declaration.
+  void addAMDGPUWavesPerEUAttr(SourceRange AttrRange, Decl *D, Expr *Min,
+   Expr *Max, unsigned SpellingListIndex);
+
   bool checkNSReturnsRetainedReturnType(SourceLocation loc, QualType type);
 
   //======//
Index: include/clang/Basic/Attr.td
===
--- include/clang/Basic/Attr.td
+++ include/clang/Basic/Attr.td
@@ -1484,14 +1484,14 @@
 
 def AMDGPUFlatWorkGroupSize : InheritableAttr {
   let Spellings = [Clang<"amdgpu_flat_work_group_size", 0>];
-  let Args = [UnsignedArgument<"Min">, UnsignedArgument<"Max">];
+  let Args = [ExprArgument<"Min">, ExprArgument<"Max">];
   let Documentation = [AMDGPUFlatWorkGroupSizeDocs];
   let Subjects = SubjectList<[Function], ErrorDiag, "kernel functions">;
 }
 
 def AMDGPUWavesPerEU : InheritableAttr {
   let Spellings = [Clang<"amdgpu_waves_per_eu", 0>];
-  let Args = [UnsignedArgument<"Min">, UnsignedArgument<"Max", 1>];
+  let Args = [ExprArgument<"Min">, ExprArgument<"Max", 1>];
   let Documentation = [AMDGPUWavesPerEUDocs];
   let Subjects = SubjectList<[Function], ErrorDiag, "kernel functions">;
 }
Index: test/SemaOpenCL/amdgpu-attrs.cl
===
--- test/SemaOpenCL/amdgpu-attrs.cl
+++ 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' attrib

[PATCH] D58665: [analyzer] Handle comparison between non-default AS symbol and constant

2019-02-26 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Hi, thanks!, i think this is correct. As in, `LocAsInteger` was clearly a 
mistake to begin with, but this change shouldn't make it worse.

You should be able to get away with not supporting comparisons between regions 
without symbolic base [as integers] and concrete integers because they usually 
yield fairly dumb values anyway. Eg., it's //impossible// for an address of a 
variable to be equal to a null pointer, and whether a variable's address is 
currently equal to `0xbadf00d` is //undefined// anyway - it will cause problems 
when we try to symbolicate our undefined values, but for now we prefer to 
interrupt the analysis whenever they actually end up being used (which causes 
the problem to disappear because symbolication only matters when we use the 
symbol more than once).




Comment at: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp:574
   llvm::APSInt i = rhs.castAs().getValue();
-  BasicVals.getAPSIntType(Context.VoidPtrTy).apply(i);
+  // FIXME: Handle non-default address spaces for non-symbolic regions.
+  if (SymbolRef lSym = lhs.getAsLocSymbol(true))

Pls be more specific in this comment that we're making this extra check in 
order to support non-default address spaces. Eg., "If the region has a symbolic 
base, pay attention to the type; it might be coming from a non-default address 
space. For non-symbolic regions it doesn't matter that much because such 
comparisons would most likely evaluate to concrete false anyway. FIXME: We 
might still need to handle the non-comparison case."



Comment at: test/Analysis/ptr-cmp-const-trunc.cl:10
+  if ((uint64_t)p <= 1UL << 32)
+bar(p);
+}

Pls add a `// no-warning` here, so that it was clear what the test is about.


Repository:
  rC Clang

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

https://reviews.llvm.org/D58665



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


[PATCH] D58463: [CUDA]Delayed diagnostics for the asm instructions.

2019-02-26 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D58463#1410900 , @tra wrote:

> There's a new quirk we've ran into after this patch landed. Consider this 
> code:
>
>   int foo() {
> int prev;
> __asm__ __volatile__("mov %0, 0" : "=a" (prev)::);
> return prev;
>   }
>
>
> When we compile for device, asm constraint is not valid for NVPTX, we emit 
> delayed diag and move on. The function is never code-gen'ed so the diag never 
> shows up. So far so good.
>
> Now we add `-Werror -Wininitialized` and things break -- because we bail out 
> early, `prev` is left uninitialized and is reported as such.
>
>   $ bin/clang++ -c --cuda-gpu-arch=sm_35 asm.cu -nocudainc --cuda-device-only 
> -Wuninitialized -Werror
>   asm.cu:4:10: error: variable 'prev' is uninitialized when used here 
> [-Werror,-Wuninitialized]
> return prev;
>^~~~
>   asm.cu:2:11: note: initialize the variable 'prev' to silence this warning
> int prev;
> ^
>  = 0
>   1 error generated when compiling for sm_35.
>  
>
>
> I think this should also show up in the test case in this patch, too, if you 
> add -Wuninitialized


Hi Artem, I think we can just delay emission of this warning to solve this 
problem.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D58463



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


[PATCH] D58418: [clang][DirectoryWatcher] Upstream DirectoryWatcher

2019-02-26 Thread Jan Korous via Phabricator via cfe-commits
jkorous marked 18 inline comments as done.
jkorous added inline comments.



Comment at: clang/lib/DirectoryWatcher/DirectoryWatcher-linux.inc.h:116
+
+  DirectoryWatcher::EventKind K = DirectoryWatcher::EventKind::Added;
+  if (ievt->mask & IN_MODIFY) {

jkorous wrote:
> mgorny wrote:
> > I don't think I understand this assumption. Have you any specific event in 
> > mind that is supposed to be treated as added here? If not, maybe it'd be 
> > better to have no default and instead assert that one of the conditions 
> > below matched.
> SGTM. Will rewrite to Optional<> and assert.
Reconsidered and replaced with one-off closure in order not to complicate 
following code with Optional.



Comment at: clang/lib/DirectoryWatcher/DirectoryWatcher-linux.inc.h:135
+if (!statusOpt.hasValue())
+  K = DirectoryWatcher::EventKind::Removed;
+  }

akyrtzi wrote:
> mgorny wrote:
> > akyrtzi wrote:
> > > mgorny wrote:
> > > > akyrtzi wrote:
> > > > > mgorny wrote:
> > > > > > akyrtzi wrote:
> > > > > > > mgorny wrote:
> > > > > > > > jkorous wrote:
> > > > > > > > > mgorny wrote:
> > > > > > > > > > Why? I suppose this deserves a comment.
> > > > > > > > > I'll add this comment:
> > > > > > > > > 
> > > > > > > > > // The file might have been removed just after we received 
> > > > > > > > > the event.
> > > > > > > > Wouldn't that cause removals to be reported twice?
> > > > > > > Not quite sure if it can happen in practice but I'd suggest to 
> > > > > > > accept this as potential occurrence and add it to documentation 
> > > > > > > ("a 'removed' event may be reported twice). I think it is better 
> > > > > > > to handle a definite "fact" (the file doesn't exist) than ignore 
> > > > > > > it and assume the 'removed' event will eventually show up, or try 
> > > > > > > to eliminate the double reporting which would over-complicate the 
> > > > > > > implementation.
> > > > > > > 
> > > > > > > After all, if inotify() is not 100% reliable then there's already 
> > > > > > > the possibility that you'll get a 'removed' event for a file that 
> > > > > > > was not reported as 'added' before.
> > > > > > I see this as a partial workaround for race condition. You 'fix' it 
> > > > > > if removal happens between inotify reporting the event and you 
> > > > > > returning it. You don't if removal happens after you push it to 
> > > > > > events. Therefore, the caller still needs to account for 'added' 
> > > > > > event being obsolete. I don't really see a purpose in trying to 
> > > > > > workaround the problem partially here if the caller still needs to 
> > > > > > account for it. Effectively, you're replacing one normal case and 
> > > > > > one corner case with one normal case and two corner cases.
> > > > > I was mainly pointing out that the client already has to be prepared 
> > > > > for a 'removed' event that does not have an associated 'added' event, 
> > > > > regardless of what this code is doing. Therefore a potential double 
> > > > > 'removed' event doesn't add complexity to the client.
> > > > > 
> > > > > Could you clarify how the code should handle the inability to get the 
> > > > > mod time ? Should it ignore the event ?
> > > > Given the code is supposed to wrap filesystem notification layer, I'd 
> > > > say it should pass the events unmodified and not double-guess what the 
> > > > client expects. The client needs to be prepared for non-atomicity of 
> > > > this anyway.
> > > So it should report an 'added' event but with optional mod-time, 
> > > essentially reporting that something was added that doesn't exist ?
> > > I'd prefer not to do that because it complicates the client without any 
> > > real benefit. It was great that you pointed out this part of the code but 
> > > I'd recommend that if the file is gone we should ignore the 'added' 
> > > event, instead of complicating the API for a corner case.
> > Except that is technically impossible to avoid reporting something that 
> > doesn't exist because it can be removed just after you check for it. So the 
> > client needs to *always* support it, otherwise it's fragile to race 
> > conditions.
> > 
> > This extra check just covers the short period (-> 0) between reporting and 
> > checking. It's needless complexity that doesn't solve the problem. If it 
> > does anything, then it gives you false security that you've solved the 
> > problem when actually the file may still disappear 1 ns after you've 
> > checked that it existed.
> Ok, that's fair, @jkorous I'm fine with removing the mod-time from the 
> DirectoryWatcher API. We can get and report the mod-time at the index-store 
> library layer.
Removed the conditional event kind change and removed ModTime.



Comment at: clang/lib/DirectoryWatcher/DirectoryWatcher-linux.inc.h:154
+errorMsg += llvm::sys::StrError();
+return true;
+  };

dexonsmith wrote:
> jkorous wrote

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

2019-02-26 Thread Tom Roeder via Phabricator via cfe-commits
tmroeder added a comment.

I'm going to submit this patch again, since that I believe I understand the 
problem, and I have tested this version on Win10 with the latest MSVC (other 
than the expectation that I just added, but that test wasn't a problem on the 
Windows builders, and the new expectation passes on my Linux dev box). I'll 
watch the Windows build at 
http://lab.llvm.org:8011/builders/clang-x64-windows-msvc and revert if there 
are problems.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58663



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


[PATCH] D58418: [clang][DirectoryWatcher] Upstream DirectoryWatcher

2019-02-26 Thread Jan Korous via Phabricator via cfe-commits
jkorous updated this revision to Diff 188423.
jkorous marked 4 inline comments as done.
jkorous added a comment.

- Use RetryAfterSignal
- Propagate events from inotify directly
- Remove ModTime
- Add assert for unknown event kinds


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

https://reviews.llvm.org/D58418

Files:
  clang/include/clang/DirectoryWatcher/DirectoryWatcher.h
  clang/lib/CMakeLists.txt
  clang/lib/DirectoryWatcher/CMakeLists.txt
  clang/lib/DirectoryWatcher/DirectoryWatcher-linux.inc.h
  clang/lib/DirectoryWatcher/DirectoryWatcher-mac.inc.h
  clang/lib/DirectoryWatcher/DirectoryWatcher.cpp
  clang/unittests/CMakeLists.txt
  clang/unittests/DirectoryWatcher/CMakeLists.txt
  clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp

Index: clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
===
--- /dev/null
+++ clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
@@ -0,0 +1,327 @@
+//===- unittests/DirectoryWatcher/DirectoryWatcherTest.cpp ===//
+//
+// 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 "clang/DirectoryWatcher/DirectoryWatcher.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
+#include "gtest/gtest.h"
+#include 
+#include 
+#include 
+
+using namespace llvm;
+using namespace llvm::sys;
+using namespace llvm::sys::fs;
+using namespace clang;
+
+namespace {
+
+class EventCollection {
+  SmallVector Events;
+
+public:
+  EventCollection() = default;
+  explicit EventCollection(ArrayRef events) {
+append(events);
+  }
+
+  void append(ArrayRef events) {
+Events.append(events.begin(), events.end());
+  }
+
+  bool empty() const { return Events.empty(); }
+  size_t size() const { return Events.size(); }
+  void clear() { Events.clear(); }
+
+  bool hasEvents(ArrayRef filenames,
+ ArrayRef kinds,
+ ArrayRef stats) const {
+assert(filenames.size() == kinds.size());
+assert(filenames.size() == stats.size());
+SmallVector evts = Events;
+bool hadError = false;
+for (unsigned i = 0, e = filenames.size(); i < e; ++i) {
+  StringRef fname = filenames[i];
+  DirectoryWatcher::EventKind kind = kinds[i];
+  auto it = std::find_if(evts.begin(), evts.end(),
+ [&](const DirectoryWatcher::Event &evt) -> bool {
+   return path::filename(evt.Filename) == fname;
+ });
+  if (it == evts.end()) {
+hadError = err(Twine("expected filename '" + fname + "' not found"));
+continue;
+  }
+  if (it->Kind != kind) {
+hadError = err(Twine("filename '" + fname + "' has event kind " +
+ std::to_string((int)it->Kind) + ", expected ") +
+   std::to_string((int)kind));
+  }
+  evts.erase(it);
+}
+for (const auto &evt : evts) {
+  hadError = err(Twine("unexpected filename '" +
+   path::filename(evt.Filename) + "' found"));
+}
+return !hadError;
+  }
+
+  bool hasAdded(ArrayRef filenames,
+ArrayRef stats) const {
+std::vector kinds{
+filenames.size(), DirectoryWatcher::EventKind::Added};
+return hasEvents(filenames, kinds, stats);
+  }
+
+  bool hasRemoved(ArrayRef filenames) const {
+std::vector kinds{
+filenames.size(), DirectoryWatcher::EventKind::Removed};
+std::vector stats{filenames.size(), file_status{}};
+return hasEvents(filenames, kinds, stats);
+  }
+
+private:
+  bool err(Twine msg) const {
+SmallString<128> buf;
+llvm::errs() << msg.toStringRef(buf) << '\n';
+return true;
+  }
+};
+
+struct EventOccurrence {
+  std::vector Events;
+  bool IsInitial;
+};
+
+class DirectoryWatcherTest
+: public std::enable_shared_from_this {
+  std::string WatchedDir;
+  std::string TempDir;
+  std::unique_ptr DirWatcher;
+
+  std::condition_variable Condition;
+  std::mutex Mutex;
+  std::deque EvtOccurs;
+
+public:
+  void init() {
+SmallString<128> pathBuf;
+std::error_code EC = createUniqueDirectory("dirwatcher", pathBuf);
+ASSERT_FALSE(EC);
+TempDir = pathBuf.str();
+path::append(pathBuf, "watch");
+WatchedDir = pathBuf.str();
+EC = create_directory(WatchedDir);
+ASSERT_FALSE(EC);
+  }
+
+  ~DirectoryWatcherTest() {
+stopWatching();
+remove_directories(TempDir);
+  }
+
+public:
+  StringRef getWatchedDir() const { return WatchedDir; }
+
+  void addFile(StringRef filename, file_status &stat) {
+SmallString<128> pathBuf;
+pathBuf = TempDir;
+path::append(pathBuf, filename);
+Expected ft =
+openNativeFileForWrite(pathBuf, CD_Cre

r354915 - [X86] Add 'znver2' and 'cascadelake' to the __builtin_cpu_is test.

2019-02-26 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Tue Feb 26 11:20:04 2019
New Revision: 354915

URL: http://llvm.org/viewvc/llvm-project?rev=354915&view=rev
Log:
[X86] Add 'znver2' and 'cascadelake' to the __builtin_cpu_is test.

These are supported by at least libgcc trunk so we can include them now.

Modified:
cfe/trunk/test/CodeGen/target-builtin-noerror.c

Modified: cfe/trunk/test/CodeGen/target-builtin-noerror.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/target-builtin-noerror.c?rev=354915&r1=354914&r2=354915&view=diff
==
--- cfe/trunk/test/CodeGen/target-builtin-noerror.c (original)
+++ cfe/trunk/test/CodeGen/target-builtin-noerror.c Tue Feb 26 11:20:04 2019
@@ -98,6 +98,7 @@ void verifycpustrings() {
   (void)__builtin_cpu_is("btver1");
   (void)__builtin_cpu_is("btver2");
   (void)__builtin_cpu_is("cannonlake");
+  (void)__builtin_cpu_is("cascadelake");
   (void)__builtin_cpu_is("core2");
   (void)__builtin_cpu_is("corei7");
   (void)__builtin_cpu_is("goldmont");


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


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

2019-02-26 Thread Tom Roeder via cfe-commits
Author: tmroeder
Date: Tue Feb 26 11:26:41 2019
New Revision: 354916

URL: http://llvm.org/viewvc/llvm-project?rev=354916&view=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.

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, which were caused by
differences in template expansion between versions of clang on different
OSes. The version of clang built with MSVC and running on Windows never
expands the template in the C++ test in ImportExpr.ImportChooseExpr in
clang/unittests/AST/ASTImporter.cpp, but the version on Linux does for
the empty arguments and -fms-compatibility.

So, this version of the patch drops the C++ test for
__builtin_choose_expr, since that version was written to catch
regressions of the logic for isConditionTrue() in the AST import code
for ChooseExpr, and those regressions are also caught by
ASTImporterOptionSpecificTestBase.ImportChooseExpr, which does work on
Windows.

Reviewers: shafik, a_sidorin, martong, aaron.ballman, rnk, a.sidorin

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

Tags: #clang

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

Added:
cfe/trunk/test/ASTMerge/
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=354916&r1=354915&r2=354916&view=diff
==
--- cfe/trunk/docs/LibASTMatchersReference.html (original)
+++ cfe/trunk/docs/LibASTMatchersReference.html Tue Feb 26 11:26:41 2019
@@ -788,6 +788,11 @@ Example matches 'a', L'a'
 
 
 
+MatcherStmt>chooseExprMatcherChooseExpr>...
+Matches GNU 
__builtin_choose_expr.
+
+
+
 MatcherStmt>compoundLiteralExprMatcherCompoundLiteralExpr>...
 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=354916&r1=354915&r2=354916&view=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Tue Feb 26 11:26:41 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=354916&r1=354915&r2=354916&view=diff
==
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Tue Feb 26 11:26:41 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.takeEr

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

2019-02-26 Thread Tom Roeder via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354916: [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/D58663?vs=188397&id=188425#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D58663

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/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/ASTMatchersInternal.cpp
===
--- cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -727,6 +727,7 @@
 compoundLiteralExpr;
 const internal::VariadicDynCastAllOfMatcher
 cxxNullPtrLiteralExpr;
+const internal::VariadicDynCastAllOfMatcher chooseExpr;
 const internal::VariadicDynCastAllOfMatcher gnuNullExpr;
 const internal::VariadicDynCastAllOfMatcher atomicExpr;
 const internal::VariadicDynCastAllOfMatcher stmtExpr;
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);
   REGISTER_MATCHER(castExpr);
   REGISTER_MATCHER(characterLiteral);
+  REGISTER_MATCHER(chooseExpr);
   REGISTER_MATCHER(classTemplateDecl);
   REGISTER_MATCHER(classTemplateSpecializationDecl);
   REGISTER_MATCHER(complexType);
Index: cfe/trunk/unittests/AST/ASTImporterTest.cpp
===
--- cfe/trunk/unittests/AST/ASTImporterTest.cpp
+++ cfe/trunk/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,29 @@
   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 Fro

Re: r354915 - [X86] Add 'znver2' and 'cascadelake' to the __builtin_cpu_is test.

2019-02-26 Thread Roman Lebedev via cfe-commits
Doesn't look like this patch added 'znver2'?

On Tue, Feb 26, 2019 at 10:20 PM Craig Topper via cfe-commits
 wrote:
>
> Author: ctopper
> Date: Tue Feb 26 11:20:04 2019
> New Revision: 354915
>
> URL: http://llvm.org/viewvc/llvm-project?rev=354915&view=rev
> Log:
> [X86] Add 'znver2' and 'cascadelake' to the __builtin_cpu_is test.
>
> These are supported by at least libgcc trunk so we can include them now.
>
> Modified:
> cfe/trunk/test/CodeGen/target-builtin-noerror.c
>
> Modified: cfe/trunk/test/CodeGen/target-builtin-noerror.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/target-builtin-noerror.c?rev=354915&r1=354914&r2=354915&view=diff
> ==
> --- cfe/trunk/test/CodeGen/target-builtin-noerror.c (original)
> +++ cfe/trunk/test/CodeGen/target-builtin-noerror.c Tue Feb 26 11:20:04 2019
> @@ -98,6 +98,7 @@ void verifycpustrings() {
>(void)__builtin_cpu_is("btver1");
>(void)__builtin_cpu_is("btver2");
>(void)__builtin_cpu_is("cannonlake");
> +  (void)__builtin_cpu_is("cascadelake");
>(void)__builtin_cpu_is("core2");
>(void)__builtin_cpu_is("corei7");
>(void)__builtin_cpu_is("goldmont");
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58691: [MS] Don't emit coverage for deleting dtors

2019-02-26 Thread Reid Kleckner via Phabricator via cfe-commits
rnk created this revision.
rnk added a reviewer: vsk.
Herald added a subscriber: jdoerfert.
Herald added a project: clang.

The MS C++ ABI has no constructor variants, but it has destructor
variants, so we should move the deleting destructor variant check
outside the check for "does the ABI have constructor variants".

Fixes PR37561, so basic code coverage works on Windows with C++.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D58691

Files:
  clang/lib/CodeGen/CodeGenPGO.cpp
  clang/test/Profile/cxx-abc-deleting-dtor.cpp

Index: clang/test/Profile/cxx-abc-deleting-dtor.cpp
===
--- /dev/null
+++ clang/test/Profile/cxx-abc-deleting-dtor.cpp
@@ -0,0 +1,86 @@
+// RUN: %clang_cc1 -emit-llvm %s -std=c++11 -o - -fno-rtti \
+// RUN: -fprofile-instrument=clang -fcoverage-mapping -disable-llvm-passes \
+// RUN: -triple=x86_64-windows-msvc | FileCheck %s --check-prefix=MSVC
+// RUN: %clang_cc1 -emit-llvm %s -std=c++11 -o - -fno-rtti \
+// RUN: -fprofile-instrument=clang -fcoverage-mapping -disable-llvm-passes \
+// RUN: -triple=x86_64-linux-gnu | FileCheck %s --check-prefix=LINUX
+
+// Check that clang doesn't emit counters or __profn_ variables for deleting
+// destructor variants in both C++ ABIs.
+
+struct ABC {
+  virtual ~ABC() = default;
+  virtual void pure() = 0;
+};
+struct DerivedABC : ABC {
+  ~DerivedABC() override = default;
+  void pure() override {}
+};
+DerivedABC *useABCVTable() { return new DerivedABC(); }
+
+// MSVC-NOT: @"__profn_??_G{{.*}}" =
+// MSVC: @"__profn_??1DerivedABC@@{{.*}}" =
+// MSVC-NOT: @"__profn_??_G{{.*}}" =
+// MSVC: @"__profn_??1ABC@@{{.*}}" =
+// MSVC-NOT: @"__profn_??_G{{.*}}" =
+
+// FIXME: Should we emit coverage info for deleting dtors? They do contain
+// conditional branches. LLVM IR PGO will insrument them just fine, though.
+
+// MSVC-LABEL: define linkonce_odr dso_local i8* @"??_GDerivedABC@@UEAAPEAXI@Z"(%struct.DerivedABC* %this, {{.*}})
+// MSVC-NOT:   call void @llvm.instrprof.increment({{.*}})
+// MSVC:   call void @"??1DerivedABC@@UEAA@XZ"({{.*}})
+// MSVC:   ret void
+
+// MSVC-LABEL: define linkonce_odr dso_local i8* @"??_GABC@@UEAAPEAXI@Z"(%struct.ABC* %this, {{.*}})
+// MSVC-NOT:   call void @llvm.instrprof.increment({{.*}})
+// MSVC:   call void @llvm.trap()
+// MSVC-NEXT:   unreachable
+
+// MSVC-LABEL: define linkonce_odr dso_local void @"??1DerivedABC@@UEAA@XZ"({{.*}})
+// MSVC:   call void @llvm.instrprof.increment({{.*}})
+// MSVC:   call void @"??1ABC@@UEAA@XZ"({{.*}})
+// MSVC:   ret void
+
+// MSVC-LABEL: define linkonce_odr dso_local void @"??1ABC@@UEAA@XZ"({{.*}})
+// MSVC:   call void @llvm.instrprof.increment({{.*}})
+// MSVC:   ret void
+
+
+// D2 is the base, D1 and D0 are deleting and complete dtors.
+
+// LINUX-NOT: @__profn_{{.*}}D[01]Ev =
+// LINUX: @__profn__ZN10DerivedABCD2Ev =
+// LINUX-NOT: @__profn_{{.*}}D[01]Ev =
+// LINUX: @__profn__ZN3ABCD2Ev =
+// LINUX-NOT: @__profn_{{.*}}D[01]Ev =
+
+// LINUX-LABEL: define linkonce_odr void @_ZN10DerivedABCD1Ev(%struct.DerivedABC* %this)
+// LINUX-NOT:   call void @llvm.instrprof.increment({{.*}})
+// LINUX:   call void @_ZN10DerivedABCD2Ev({{.*}})
+// LINUX:   ret void
+
+// LINUX-LABEL: define linkonce_odr void @_ZN10DerivedABCD0Ev(%struct.DerivedABC* %this)
+// LINUX-NOT:   call void @llvm.instrprof.increment({{.*}})
+// LINUX:   call void @_ZN10DerivedABCD1Ev({{.*}})
+// LINUX:   call void @_ZdlPv({{.*}})
+// LINUX:   ret void
+
+// LINUX-LABEL: define linkonce_odr void @_ZN3ABCD1Ev(%struct.ABC* %this)
+// LINUX-NOT:   call void @llvm.instrprof.increment({{.*}})
+// LINUX:   call void @llvm.trap()
+// LINUX-NEXT:   unreachable
+
+// LINUX-LABEL: define linkonce_odr void @_ZN3ABCD0Ev(%struct.ABC* %this)
+// LINUX-NOT:   call void @llvm.instrprof.increment({{.*}})
+// LINUX:   call void @llvm.trap()
+// LINUX-NEXT:   unreachable
+
+// LINUX-LABEL: define linkonce_odr void @_ZN10DerivedABCD2Ev(%struct.DerivedABC* %this)
+// LINUX:   call void @llvm.instrprof.increment({{.*}})
+// LINUX:   call void @_ZN3ABCD2Ev({{.*}})
+// LINUX:   ret void
+
+// LINUX-LABEL: define linkonce_odr void @_ZN3ABCD2Ev(%struct.ABC* %this)
+// LINUX:   call void @llvm.instrprof.increment({{.*}})
+// LINUX:   ret void
Index: clang/lib/CodeGen/CodeGenPGO.cpp
===
--- clang/lib/CodeGen/CodeGenPGO.cpp
+++ clang/lib/CodeGen/CodeGenPGO.cpp
@@ -771,14 +771,14 @@
   // If so, instrument only base variant, others are implemented by delegation
   // to the base one, it would be counted twice otherwise.
   if (CGM.getTarget().getCXXABI().hasConstructorVariants()) {
-if (isa(D) && GD.getDtorType() != Dtor_Base)
-  return;
-
 if (const auto *CCD = dyn_cast(D))
   if (GD.getCtorType() != Ctor_Base &&
   CodeGenFunction::IsConstructorDelegationValid(CCD))
 return;
   }
+  if (isa(D) && GD.getDtorType() != Dtor_Base)
+return;
+
   CGM.Cle

RE: r354915 - [X86] Add 'znver2' and 'cascadelake' to the __builtin_cpu_is test.

2019-02-26 Thread Topper, Craig via cfe-commits
You're right. It was already there after Ganesh's patch this morning. I hadn't 
updated my clang tree so I thought it was missing. Sorry.

-Original Message-
From: Roman Lebedev [mailto:lebedev...@gmail.com] 
Sent: Tuesday, February 26, 2019 11:29 AM
To: Topper, Craig 
Cc: cfe-commits@lists.llvm.org
Subject: Re: r354915 - [X86] Add 'znver2' and 'cascadelake' to the 
__builtin_cpu_is test.

Doesn't look like this patch added 'znver2'?

On Tue, Feb 26, 2019 at 10:20 PM Craig Topper via cfe-commits
 wrote:
>
> Author: ctopper
> Date: Tue Feb 26 11:20:04 2019
> New Revision: 354915
>
> URL: http://llvm.org/viewvc/llvm-project?rev=354915&view=rev
> Log:
> [X86] Add 'znver2' and 'cascadelake' to the __builtin_cpu_is test.
>
> These are supported by at least libgcc trunk so we can include them now.
>
> Modified:
> cfe/trunk/test/CodeGen/target-builtin-noerror.c
>
> Modified: cfe/trunk/test/CodeGen/target-builtin-noerror.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/target-builtin-noerror.c?rev=354915&r1=354914&r2=354915&view=diff
> ==
> --- cfe/trunk/test/CodeGen/target-builtin-noerror.c (original)
> +++ cfe/trunk/test/CodeGen/target-builtin-noerror.c Tue Feb 26 11:20:04 2019
> @@ -98,6 +98,7 @@ void verifycpustrings() {
>(void)__builtin_cpu_is("btver1");
>(void)__builtin_cpu_is("btver2");
>(void)__builtin_cpu_is("cannonlake");
> +  (void)__builtin_cpu_is("cascadelake");
>(void)__builtin_cpu_is("core2");
>(void)__builtin_cpu_is("corei7");
>(void)__builtin_cpu_is("goldmont");
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

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

Sounds good, thanks for debugging this.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D58663



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


[PATCH] D57628: [index] Improve indexing support for MSPropertyDecl.

2019-02-26 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.
Herald added a subscriber: jdoerfert.

Ping.


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

https://reviews.llvm.org/D57628



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


[PATCH] D58463: [CUDA]Delayed diagnostics for the asm instructions.

2019-02-26 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

> Hi Artem, I think we can just delay emission of this warning to solve this 
> problem.

I'm not sure we can always tell whether the warning is real or if it's the 
consequence of failing to parse inline asm.

E.g.:

  namespace {
  __host__ __device__ a() {
int prev;
__asm__ __volatile__("mov %0, 0" : "=a" (prev)::);
return prev;
  }
  
  __host__ __device__ b() {
int prev;
return prev;
  }
  
  } //namespace

Ideally we should always emit uninitialized diagnostics for `b`, but never for 
`a` in both host and device compilation modes.
I think we may want to propagate assignment from the inline asm statement -- we 
may not know the meaning of the constraint, but we do know which argument gets 
used/modified by the asm statement. Perhaps we can construct a fake GCCAsmStmt 
but bail out before we attempt to validate the asm string.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D58463



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


[PATCH] D58375: [Clang][NewPM] Disable tests that are broken under new PM

2019-02-26 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

Ping?


Repository:
  rC Clang

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

https://reviews.llvm.org/D58375



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


[PATCH] D58374: [Clang][NewPM] Don't bail out if the target machine is empty

2019-02-26 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

Ping?


Repository:
  rC Clang

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

https://reviews.llvm.org/D58374



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


[PATCH] D58691: [MS] Don't emit coverage for deleting dtors

2019-02-26 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added inline comments.



Comment at: clang/test/Profile/cxx-abc-deleting-dtor.cpp:28
+// FIXME: Should we emit coverage info for deleting dtors? They do contain
+// conditional branches. LLVM IR PGO will insrument them just fine, though.
+

Probably not. IIUC the branches aren't visible at the source-level?



Comment at: clang/test/Profile/cxx-abc-deleting-dtor.cpp:52
+
+// LINUX-NOT: @__profn_{{.*}}D[01]Ev =
+// LINUX: @__profn__ZN10DerivedABCD2Ev =

Do you need {{[01]}}?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58691



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


[PATCH] D56900: [Fixed Point Arithmetic] Fixed Point and Integer Conversions

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

@rjmccall @ebevhan @bjope *ping* any other comments on this patch?


Repository:
  rC Clang

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

https://reviews.llvm.org/D56900



___
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-26 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

I don't know anything about this particular patch, but you aren't allowed to 
set deadlines like that; the patch review process requires that the patch is 
actually reviewed.  If you aren't getting a response, ask on cfe-dev.


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] D58463: [CUDA]Delayed diagnostics for the asm instructions.

2019-02-26 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D58463#1411039 , @tra wrote:

> > Hi Artem, I think we can just delay emission of this warning to solve this 
> > problem.
>
> I'm not sure we can always tell whether the warning is real or if it's the 
> consequence of failing to parse inline asm.
>
> E.g.:
>
>   namespace {
>   __host__ __device__ a() {
> int prev;
> __asm__ __volatile__("mov %0, 0" : "=a" (prev)::);
> return prev;
>   }
>  
>   __host__ __device__ b() {
> int prev;
> return prev;
>   }
>  
>   } //namespace
>
>
> Ideally we should always emit uninitialized diagnostics for `b`, but never 
> for `a` in both host and device compilation modes.
>  I think we may want to propagate assignment from the inline asm statement -- 
> we may not know the meaning of the constraint, but we do know which argument 
> gets used/modified by the asm statement. Perhaps we can construct a fake 
> GCCAsmStmt but bail out before we attempt to validate the asm string.


But it is going to be emitted for b() if b() is really used on the host or on 
the device. For a() the warning is going to be emitted only if it is really 
used on device, otherwise it is not.
Instead, we can try to do what we did before: construct GCCAsmStmt object, just 
like you said. What option do you prefer?


Repository:
  rL LLVM

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

https://reviews.llvm.org/D58463



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


[PATCH] D58375: [Clang][NewPM] Disable tests that are broken under new PM

2019-02-26 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

I thought the plan was to fix whatever issue was causing the -O0 tests to fail, 
then rebase on top of that?


Repository:
  rC Clang

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

https://reviews.llvm.org/D58375



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


[PATCH] D58691: [MS] Don't emit coverage for deleting dtors

2019-02-26 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: clang/test/Profile/cxx-abc-deleting-dtor.cpp:28
+// FIXME: Should we emit coverage info for deleting dtors? They do contain
+// conditional branches. LLVM IR PGO will insrument them just fine, though.
+

vsk wrote:
> Probably not. IIUC the branches aren't visible at the source-level?
You're right, they aren't, so I'll remove this.



Comment at: clang/test/Profile/cxx-abc-deleting-dtor.cpp:52
+
+// LINUX-NOT: @__profn_{{.*}}D[01]Ev =
+// LINUX: @__profn__ZN10DerivedABCD2Ev =

vsk wrote:
> Do you need {{[01]}}?
Yes, thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58691



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


[PATCH] D58691: [MS] Don't emit coverage for deleting dtors

2019-02-26 Thread Reid Kleckner via Phabricator via cfe-commits
rnk updated this revision to Diff 188434.
rnk marked 3 inline comments as done.
rnk added a comment.

- fix CHECK-NOT
- FIXME that isn't needed


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58691

Files:
  clang/lib/CodeGen/CodeGenPGO.cpp
  clang/test/Profile/cxx-abc-deleting-dtor.cpp

Index: clang/test/Profile/cxx-abc-deleting-dtor.cpp
===
--- /dev/null
+++ clang/test/Profile/cxx-abc-deleting-dtor.cpp
@@ -0,0 +1,83 @@
+// RUN: %clang_cc1 -emit-llvm %s -std=c++11 -o - -fno-rtti \
+// RUN: -fprofile-instrument=clang -fcoverage-mapping -disable-llvm-passes \
+// RUN: -triple=x86_64-windows-msvc | FileCheck %s --check-prefix=MSVC
+// RUN: %clang_cc1 -emit-llvm %s -std=c++11 -o - -fno-rtti \
+// RUN: -fprofile-instrument=clang -fcoverage-mapping -disable-llvm-passes \
+// RUN: -triple=x86_64-linux-gnu | FileCheck %s --check-prefix=LINUX
+
+// Check that clang doesn't emit counters or __profn_ variables for deleting
+// destructor variants in both C++ ABIs.
+
+struct ABC {
+  virtual ~ABC() = default;
+  virtual void pure() = 0;
+};
+struct DerivedABC : ABC {
+  ~DerivedABC() override = default;
+  void pure() override {}
+};
+DerivedABC *useABCVTable() { return new DerivedABC(); }
+
+// MSVC-NOT: @"__profn_??_G{{.*}}" =
+// MSVC: @"__profn_??1DerivedABC@@{{.*}}" =
+// MSVC-NOT: @"__profn_??_G{{.*}}" =
+// MSVC: @"__profn_??1ABC@@{{.*}}" =
+// MSVC-NOT: @"__profn_??_G{{.*}}" =
+
+// MSVC-LABEL: define linkonce_odr dso_local i8* @"??_GDerivedABC@@UEAAPEAXI@Z"(%struct.DerivedABC* %this, {{.*}})
+// MSVC-NOT:   call void @llvm.instrprof.increment({{.*}})
+// MSVC:   call void @"??1DerivedABC@@UEAA@XZ"({{.*}})
+// MSVC:   ret void
+
+// MSVC-LABEL: define linkonce_odr dso_local i8* @"??_GABC@@UEAAPEAXI@Z"(%struct.ABC* %this, {{.*}})
+// MSVC-NOT:   call void @llvm.instrprof.increment({{.*}})
+// MSVC:   call void @llvm.trap()
+// MSVC-NEXT:   unreachable
+
+// MSVC-LABEL: define linkonce_odr dso_local void @"??1DerivedABC@@UEAA@XZ"({{.*}})
+// MSVC:   call void @llvm.instrprof.increment({{.*}})
+// MSVC:   call void @"??1ABC@@UEAA@XZ"({{.*}})
+// MSVC:   ret void
+
+// MSVC-LABEL: define linkonce_odr dso_local void @"??1ABC@@UEAA@XZ"({{.*}})
+// MSVC:   call void @llvm.instrprof.increment({{.*}})
+// MSVC:   ret void
+
+
+// D2 is the base, D1 and D0 are deleting and complete dtors.
+
+// LINUX-NOT: @__profn_{{.*D[01]Ev}} =
+// LINUX: @__profn__ZN10DerivedABCD2Ev =
+// LINUX-NOT: @__profn_{{.*D[01]Ev}} =
+// LINUX: @__profn__ZN3ABCD2Ev =
+// LINUX-NOT: @__profn_{{.*D[01]Ev}} =
+
+// LINUX-LABEL: define linkonce_odr void @_ZN10DerivedABCD1Ev(%struct.DerivedABC* %this)
+// LINUX-NOT:   call void @llvm.instrprof.increment({{.*}})
+// LINUX:   call void @_ZN10DerivedABCD2Ev({{.*}})
+// LINUX:   ret void
+
+// LINUX-LABEL: define linkonce_odr void @_ZN10DerivedABCD0Ev(%struct.DerivedABC* %this)
+// LINUX-NOT:   call void @llvm.instrprof.increment({{.*}})
+// LINUX:   call void @_ZN10DerivedABCD1Ev({{.*}})
+// LINUX:   call void @_ZdlPv({{.*}})
+// LINUX:   ret void
+
+// LINUX-LABEL: define linkonce_odr void @_ZN3ABCD1Ev(%struct.ABC* %this)
+// LINUX-NOT:   call void @llvm.instrprof.increment({{.*}})
+// LINUX:   call void @llvm.trap()
+// LINUX-NEXT:   unreachable
+
+// LINUX-LABEL: define linkonce_odr void @_ZN3ABCD0Ev(%struct.ABC* %this)
+// LINUX-NOT:   call void @llvm.instrprof.increment({{.*}})
+// LINUX:   call void @llvm.trap()
+// LINUX-NEXT:   unreachable
+
+// LINUX-LABEL: define linkonce_odr void @_ZN10DerivedABCD2Ev(%struct.DerivedABC* %this)
+// LINUX:   call void @llvm.instrprof.increment({{.*}})
+// LINUX:   call void @_ZN3ABCD2Ev({{.*}})
+// LINUX:   ret void
+
+// LINUX-LABEL: define linkonce_odr void @_ZN3ABCD2Ev(%struct.ABC* %this)
+// LINUX:   call void @llvm.instrprof.increment({{.*}})
+// LINUX:   ret void
Index: clang/lib/CodeGen/CodeGenPGO.cpp
===
--- clang/lib/CodeGen/CodeGenPGO.cpp
+++ clang/lib/CodeGen/CodeGenPGO.cpp
@@ -771,14 +771,14 @@
   // If so, instrument only base variant, others are implemented by delegation
   // to the base one, it would be counted twice otherwise.
   if (CGM.getTarget().getCXXABI().hasConstructorVariants()) {
-if (isa(D) && GD.getDtorType() != Dtor_Base)
-  return;
-
 if (const auto *CCD = dyn_cast(D))
   if (GD.getCtorType() != Ctor_Base &&
   CodeGenFunction::IsConstructorDelegationValid(CCD))
 return;
   }
+  if (isa(D) && GD.getDtorType() != Dtor_Base)
+return;
+
   CGM.ClearUnusedCoverageMapping(D);
   setFuncName(Fn);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58463: [CUDA]Delayed diagnostics for the asm instructions.

2019-02-26 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

>> E.g.:
>> 
>>   namespace {
>>   __host__ __device__ a() {
>> int prev;
>> __asm__ __volatile__("mov %0, 0" : "=a" (prev)::);
>> return prev;
>>   }
>>   
>>   __host__ __device__ b() {
>> int prev;
>> return prev;
>>   }
>>   
>>   } //namespace
>> 
>> 
>> Ideally we should always emit uninitialized diagnostics for `b`, but never 
>> for `a` in both host and device compilation modes.
>>  I think we may want to propagate assignment from the inline asm statement 
>> -- we may not know the meaning of the constraint, but we do know which 
>> argument gets used/modified by the asm statement. Perhaps we can construct a 
>> fake GCCAsmStmt but bail out before we attempt to validate the asm string.
> 
> But it is going to be emitted for b() if b() is really used on the host or on 
> the device.

Clang also emits the uninitialized warnings for `b` when it is not used -- as 
in the example above.
I'm OK with that as `b` is a valid function on both sides.

Suppressing uninitialized warning in this case would be wrong, IMO -- that 
would diverge from what clang would do if `b` didn't have `__host__ __device__` 
attributes.

> For a() the warning is going to be emitted only if it is really used on 
> device, otherwise it is not.



> Instead, we can try to do what we did before: construct GCCAsmStmt object, 
> just like you said. What option do you prefer?

I think creating a GCCAsmStmt() is the right way to deal with this as it gives 
compiler the correct (well, as correct as we can at that point) info about the 
code, as opposed to giving compiler broken pieces and trying to suppress the 
fallout.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D58463



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


[PATCH] D58463: [CUDA]Delayed diagnostics for the asm instructions.

2019-02-26 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D58463#1411086 , @tra wrote:

> >> E.g.:
> >> 
> >>   namespace {
> >>   __host__ __device__ a() {
> >> int prev;
> >> __asm__ __volatile__("mov %0, 0" : "=a" (prev)::);
> >> return prev;
> >>   }
> >>   
> >>   __host__ __device__ b() {
> >> int prev;
> >> return prev;
> >>   }
> >>   
> >>   } //namespace
> >> 
> >> 
> >> Ideally we should always emit uninitialized diagnostics for `b`, but never 
> >> for `a` in both host and device compilation modes.
> >>  I think we may want to propagate assignment from the inline asm statement 
> >> -- we may not know the meaning of the constraint, but we do know which 
> >> argument gets used/modified by the asm statement. Perhaps we can construct 
> >> a fake GCCAsmStmt but bail out before we attempt to validate the asm 
> >> string.
> > 
> > But it is going to be emitted for b() if b() is really used on the host or 
> > on the device.
>
> Clang also emits the uninitialized warnings for `b` when it is not used -- as 
> in the example above.
>  I'm OK with that as `b` is a valid function on both sides.
>
> Suppressing uninitialized warning in this case would be wrong, IMO -- that 
> would diverge from what clang would do if `b` didn't have `__host__ 
> __device__` attributes.
>
> > For a() the warning is going to be emitted only if it is really used on 
> > device, otherwise it is not.
>
>
>
> > Instead, we can try to do what we did before: construct GCCAsmStmt object, 
> > just like you said. What option do you prefer?
>
> I think creating a GCCAsmStmt() is the right way to deal with this as it 
> gives compiler the correct (well, as correct as we can at that point) info 
> about the code, as opposed to giving compiler broken pieces and trying to 
> suppress the fallout.


Ok, will prepare a fix shortly.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D58463



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


[PATCH] D58691: [MS] Don't emit coverage for deleting dtors

2019-02-26 Thread Vedant Kumar via Phabricator via cfe-commits
vsk accepted this revision.
vsk added a comment.
This revision is now accepted and ready to land.

Thanks! Lgtm.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58691



___
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-26 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

In D57590#1411055 , @efriedma wrote:

> I don't know anything about this particular patch, but you aren't allowed to 
> set deadlines like that; the patch review process requires that the patch is 
> actually reviewed.  If you aren't getting a response, ask on cfe-dev.


Okay sorry about that, I will not commit until we get an approve. I think I was 
mislead by the "LLVM Developer Policy" 
(https://llvm.org/docs/DeveloperPolicy.html)

> Do not assume silent approval, or request active objections to the patch with 
> a deadline.

I interpreted this as after several pings setting a deadline is okay, 
especially if the patch is small and getting old.
Perhaps the policy should be updated to avoid such misinterpretation in the 
future.

Unfortunately this part of Clang (ASTImporter) has quite a few active 
developers other than my colleges. Obviously my colleges could review these 
patches (and they have done that in our fork) but we thought it would be better 
to have accept from devs of other organizations. One of the clients of 
ASTImporter is cross translation unit (CTU) static analysis, the other is LLDB. 
We hope to have more users and developers of CTU by reaching a point where it 
is mature enough to attract more developers. At the moment CTU analysis is not 
successful even on a simple C project like tmux with the upstream master. But 
that is successful on complex C++ projects like protobuf since a long time in 
our fork. Upstreaming to master takes painfully too much time. Our fork is 
already ahead at least 25 commits and it is growing.


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] D54176: [PGO] clang part of change for context-sensitive PGO.

2019-02-26 Thread David Li via Phabricator via cfe-commits
davidxl added a comment.

Please add changes to option documentation.


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

https://reviews.llvm.org/D54176



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


r354924 - [MS] Don't emit coverage for deleting dtors

2019-02-26 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Tue Feb 26 12:42:52 2019
New Revision: 354924

URL: http://llvm.org/viewvc/llvm-project?rev=354924&view=rev
Log:
[MS] Don't emit coverage for deleting dtors

Summary:
The MS C++ ABI has no constructor variants, but it has destructor
variants, so we should move the deleting destructor variant check
outside the check for "does the ABI have constructor variants".

Fixes PR37561, so basic code coverage works on Windows with C++.

Reviewers: vsk

Subscribers: jdoerfert, cfe-commits

Tags: #clang

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

Added:
cfe/trunk/test/Profile/cxx-abc-deleting-dtor.cpp
Modified:
cfe/trunk/lib/CodeGen/CodeGenPGO.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenPGO.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenPGO.cpp?rev=354924&r1=354923&r2=354924&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenPGO.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenPGO.cpp Tue Feb 26 12:42:52 2019
@@ -771,14 +771,14 @@ void CodeGenPGO::assignRegionCounters(Gl
   // If so, instrument only base variant, others are implemented by delegation
   // to the base one, it would be counted twice otherwise.
   if (CGM.getTarget().getCXXABI().hasConstructorVariants()) {
-if (isa(D) && GD.getDtorType() != Dtor_Base)
-  return;
-
 if (const auto *CCD = dyn_cast(D))
   if (GD.getCtorType() != Ctor_Base &&
   CodeGenFunction::IsConstructorDelegationValid(CCD))
 return;
   }
+  if (isa(D) && GD.getDtorType() != Dtor_Base)
+return;
+
   CGM.ClearUnusedCoverageMapping(D);
   setFuncName(Fn);
 

Added: cfe/trunk/test/Profile/cxx-abc-deleting-dtor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/cxx-abc-deleting-dtor.cpp?rev=354924&view=auto
==
--- cfe/trunk/test/Profile/cxx-abc-deleting-dtor.cpp (added)
+++ cfe/trunk/test/Profile/cxx-abc-deleting-dtor.cpp Tue Feb 26 12:42:52 2019
@@ -0,0 +1,83 @@
+// RUN: %clang_cc1 -emit-llvm %s -std=c++11 -o - -fno-rtti \
+// RUN: -fprofile-instrument=clang -fcoverage-mapping -disable-llvm-passes 
\
+// RUN: -triple=x86_64-windows-msvc | FileCheck %s --check-prefix=MSVC
+// RUN: %clang_cc1 -emit-llvm %s -std=c++11 -o - -fno-rtti \
+// RUN: -fprofile-instrument=clang -fcoverage-mapping -disable-llvm-passes 
\
+// RUN: -triple=x86_64-linux-gnu | FileCheck %s --check-prefix=LINUX
+
+// Check that clang doesn't emit counters or __profn_ variables for deleting
+// destructor variants in both C++ ABIs.
+
+struct ABC {
+  virtual ~ABC() = default;
+  virtual void pure() = 0;
+};
+struct DerivedABC : ABC {
+  ~DerivedABC() override = default;
+  void pure() override {}
+};
+DerivedABC *useABCVTable() { return new DerivedABC(); }
+
+// MSVC-NOT: @"__profn_??_G{{.*}}" =
+// MSVC: @"__profn_??1DerivedABC@@{{.*}}" =
+// MSVC-NOT: @"__profn_??_G{{.*}}" =
+// MSVC: @"__profn_??1ABC@@{{.*}}" =
+// MSVC-NOT: @"__profn_??_G{{.*}}" =
+
+// MSVC-LABEL: define linkonce_odr dso_local i8* 
@"??_GDerivedABC@@UEAAPEAXI@Z"(%struct.DerivedABC* %this, {{.*}})
+// MSVC-NOT:   call void @llvm.instrprof.increment({{.*}})
+// MSVC:   call void @"??1DerivedABC@@UEAA@XZ"({{.*}})
+// MSVC:   ret void
+
+// MSVC-LABEL: define linkonce_odr dso_local i8* 
@"??_GABC@@UEAAPEAXI@Z"(%struct.ABC* %this, {{.*}})
+// MSVC-NOT:   call void @llvm.instrprof.increment({{.*}})
+// MSVC:   call void @llvm.trap()
+// MSVC-NEXT:   unreachable
+
+// MSVC-LABEL: define linkonce_odr dso_local void 
@"??1DerivedABC@@UEAA@XZ"({{.*}})
+// MSVC:   call void @llvm.instrprof.increment({{.*}})
+// MSVC:   call void @"??1ABC@@UEAA@XZ"({{.*}})
+// MSVC:   ret void
+
+// MSVC-LABEL: define linkonce_odr dso_local void @"??1ABC@@UEAA@XZ"({{.*}})
+// MSVC:   call void @llvm.instrprof.increment({{.*}})
+// MSVC:   ret void
+
+
+// D2 is the base, D1 and D0 are deleting and complete dtors.
+
+// LINUX-NOT: @__profn_{{.*D[01]Ev}} =
+// LINUX: @__profn__ZN10DerivedABCD2Ev =
+// LINUX-NOT: @__profn_{{.*D[01]Ev}} =
+// LINUX: @__profn__ZN3ABCD2Ev =
+// LINUX-NOT: @__profn_{{.*D[01]Ev}} =
+
+// LINUX-LABEL: define linkonce_odr void 
@_ZN10DerivedABCD1Ev(%struct.DerivedABC* %this)
+// LINUX-NOT:   call void @llvm.instrprof.increment({{.*}})
+// LINUX:   call void @_ZN10DerivedABCD2Ev({{.*}})
+// LINUX:   ret void
+
+// LINUX-LABEL: define linkonce_odr void 
@_ZN10DerivedABCD0Ev(%struct.DerivedABC* %this)
+// LINUX-NOT:   call void @llvm.instrprof.increment({{.*}})
+// LINUX:   call void @_ZN10DerivedABCD1Ev({{.*}})
+// LINUX:   call void @_ZdlPv({{.*}})
+// LINUX:   ret void
+
+// LINUX-LABEL: define linkonce_odr void @_ZN3ABCD1Ev(%struct.ABC* %this)
+// LINUX-NOT:   call void @llvm.instrprof.increment({{.*}})
+// LINUX:   call void @llvm.trap()
+// LINUX-NEXT:   unreachable
+
+// LINUX-LABEL: define linkonce_odr void @_ZN3ABCD0Ev(%struct.ABC* %this)
+// LINUX-NOT:   call void @llvm.ins

  1   2   >