[PATCH] D50205: [libc++] Add availability markup for aligned new/delete

2018-08-06 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

In https://reviews.llvm.org/D50205#1188454, @EricWF wrote:

> How does this work when a user provides their own definitions? Does the 
> attribute from the declaration still produce a warning? If so, then I think 
> an in-compiler approach is better.


Yes. I do agree that not warning when the user provides their own definition is 
a better user experience, however I think that is already the behavior we have 
for sized new/delete (with `_LIBCPP_AVAILABILITY_SIZED_NEW_DELETE`). Is it any 
different?

If we were to go for an in-compiler approach, what would be the behavior we 
want? Any TU that uses the operator but defines it would not get a warning, but 
any TU that uses it without defining it would still get a warning, right? If 
so, it doesn't seem like such a huge improvement.


Repository:
  rCXX libc++

https://reviews.llvm.org/D50205



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


r339016 - [clang] Fix broken include_next in float.h

2018-08-06 Thread Louis Dionne via cfe-commits
Author: ldionne
Date: Mon Aug  6 07:29:47 2018
New Revision: 339016

URL: http://llvm.org/viewvc/llvm-project?rev=339016&view=rev
Log:
[clang] Fix broken include_next in float.h

Summary:
The code defines __FLOAT_H and then includes the next , which is
guarded on __FLOAT_H so it gets skipped entirely. This commit uses the header
guard __CLANG_FLOAT_H, like other headers (such as limits.h) do.

Reviewers: jfb

Subscribers: dexonsmith, cfe-commits

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

Modified:
cfe/trunk/lib/Headers/float.h

Modified: cfe/trunk/lib/Headers/float.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/float.h?rev=339016&r1=339015&r2=339016&view=diff
==
--- cfe/trunk/lib/Headers/float.h (original)
+++ cfe/trunk/lib/Headers/float.h Mon Aug  6 07:29:47 2018
@@ -21,8 +21,8 @@
  *===---===
  */
 
-#ifndef __FLOAT_H
-#define __FLOAT_H
+#ifndef __CLANG_FLOAT_H
+#define __CLANG_FLOAT_H
 
 /* If we're on MinGW, fall back to the system's float.h, which might have
  * additional definitions provided for Windows.
@@ -157,4 +157,4 @@
 #  define FLT16_TRUE_MIN__FLT16_TRUE_MIN__
 #endif /* __STDC_WANT_IEC_60559_TYPES_EXT__ */
 
-#endif /* __FLOAT_H */
+#endif /* __CLANG_FLOAT_H */


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


[PATCH] D50276: [clang] Fix broken include_next in float.h

2018-08-06 Thread Louis Dionne via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL339016: [clang] Fix broken include_next in float.h (authored 
by ldionne, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D50276?vs=159109&id=159299#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50276

Files:
  cfe/trunk/lib/Headers/float.h


Index: cfe/trunk/lib/Headers/float.h
===
--- cfe/trunk/lib/Headers/float.h
+++ cfe/trunk/lib/Headers/float.h
@@ -21,8 +21,8 @@
  *===---===
  */
 
-#ifndef __FLOAT_H
-#define __FLOAT_H
+#ifndef __CLANG_FLOAT_H
+#define __CLANG_FLOAT_H
 
 /* If we're on MinGW, fall back to the system's float.h, which might have
  * additional definitions provided for Windows.
@@ -157,4 +157,4 @@
 #  define FLT16_TRUE_MIN__FLT16_TRUE_MIN__
 #endif /* __STDC_WANT_IEC_60559_TYPES_EXT__ */
 
-#endif /* __FLOAT_H */
+#endif /* __CLANG_FLOAT_H */


Index: cfe/trunk/lib/Headers/float.h
===
--- cfe/trunk/lib/Headers/float.h
+++ cfe/trunk/lib/Headers/float.h
@@ -21,8 +21,8 @@
  *===---===
  */
 
-#ifndef __FLOAT_H
-#define __FLOAT_H
+#ifndef __CLANG_FLOAT_H
+#define __CLANG_FLOAT_H
 
 /* If we're on MinGW, fall back to the system's float.h, which might have
  * additional definitions provided for Windows.
@@ -157,4 +157,4 @@
 #  define FLT16_TRUE_MIN__FLT16_TRUE_MIN__
 #endif /* __STDC_WANT_IEC_60559_TYPES_EXT__ */
 
-#endif /* __FLOAT_H */
+#endif /* __CLANG_FLOAT_H */
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r339017 - [AST] Move the enum in ObjCMethodDeclBitfields

2018-08-06 Thread Bruno Ricci via cfe-commits
Author: brunoricci
Date: Mon Aug  6 07:33:45 2018
New Revision: 339017

URL: http://llvm.org/viewvc/llvm-project?rev=339017&view=rev
Log:
[AST] Move the enum in ObjCMethodDeclBitfields

Move the enum { ObjCMethodFamilyBitWidth = 4 } to the top of
the class. For some dark reason having the enum between the
bitfields breaks the packing with gcc version 7.3-win32 20180312.

Reported by: Abramo Bagnara (by email)

Modified:
cfe/trunk/include/clang/AST/DeclBase.h

Modified: cfe/trunk/include/clang/AST/DeclBase.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=339017&r1=339016&r2=339017&view=diff
==
--- cfe/trunk/include/clang/AST/DeclBase.h (original)
+++ cfe/trunk/include/clang/AST/DeclBase.h Mon Aug  6 07:33:45 2018
@@ -1554,8 +1554,6 @@ class DeclContext {
   /// methods in ObjCMethodDecl should be updated appropriately.
   class ObjCMethodDeclBitfields {
 friend class ObjCMethodDecl;
-/// For the bits in DeclContextBitfields.
-uint64_t : NumDeclContextBits;
 
 /// This is needed for the bitwidth of Family below but
 /// is defined in Basic/IdentifierTable.h which we do not include.
@@ -1564,6 +1562,9 @@ class DeclContext {
 /// that these two ObjCMethodFamilyBitWidth are equal.
 enum { ObjCMethodFamilyBitWidth = 4 };
 
+/// For the bits in DeclContextBitfields.
+uint64_t : NumDeclContextBits;
+
 /// The conventional meaning of this method; an ObjCMethodFamily.
 /// This is not serialized; instead, it is computed on demand and
 /// cached.


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


Re: r338899 - [OpenCL] Always emit alloca in entry block for enqueue_kernel builtin

2018-08-06 Thread via cfe-commits
I can't seem to reproduce the ASan failure locally, even after building 
a clang with the latest compiler-rt, and then rebuilding my patch with 
LLVM_USE_SANITIZER=Address


I am pretty confident the problem should be fixed with a one-line change 
to my patch:


-auto CreateArrayForSizeVar = [=](unsigned First) {
+auto CreateArrayForSizeVar = [=](unsigned First)
+-> std::tuple {

I don't want to commit something and then immediately have to revert, 
though. Can you think of anything I might be missing locally to 
reproduce the ASan failure?


Thanks,
Scott

On 2018-08-03 13:48, Vlad Tsyrklevich wrote:

This change is causing ASan failures on the sanitizer bots:
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/21898/steps/check-clang%20asan/logs/stdio
[9]

I've reverted it in r338904.

On Fri, Aug 3, 2018 at 8:51 AM Scott Linder via cfe-commits
 wrote:


Author: scott.linder
Date: Fri Aug 3 08:50:52 2018
New Revision: 338899

URL: http://llvm.org/viewvc/llvm-project?rev=338899&view=rev [1]
Log:
[OpenCL] Always emit alloca in entry block for enqueue_kernel
builtin

Ensures the statically sized alloca is not converted to
DYNAMIC_STACKALLOC
later because it is not in the entry block.

Differential Revision: https://reviews.llvm.org/D50104 [2]

Added:
cfe/trunk/test/CodeGenOpenCL/enqueue-kernel-non-entry-block.cl
[3]
Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGenOpenCL/cl20-device-side-enqueue.cl [4]

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL:


http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=338899&r1=338898&r2=338899&view=diff

[5]


==

--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Fri Aug 3 08:50:52 2018
@@ -3338,23 +3338,29 @@ RValue CodeGenFunction::EmitBuiltinExpr(
// Create a temporary array to hold the sizes of local pointer
arguments
// for the block. \p First is the position of the first size
argument.
auto CreateArrayForSizeVar = [=](unsigned First) {
- auto *AT = llvm::ArrayType::get(SizeTy, NumArgs - First);
- auto *Arr = Builder.CreateAlloca(AT);
- llvm::Value *Ptr;
+ llvm::APInt ArraySize(32, NumArgs - First);
+ QualType SizeArrayTy = getContext().getConstantArrayType(
+ getContext().getSizeType(), ArraySize, ArrayType::Normal,
+ /*IndexTypeQuals=*/0);
+ auto Tmp = CreateMemTemp(SizeArrayTy, "block_sizes");
+ llvm::Value *TmpPtr = Tmp.getPointer();
+ llvm::Value *TmpSize = EmitLifetimeStart(
+
CGM.getDataLayout().getTypeAllocSize(Tmp.getElementType()), TmpPtr);
+ llvm::Value *ElemPtr;
// Each of the following arguments specifies the size of the
corresponding
// argument passed to the enqueued block.
auto *Zero = llvm::ConstantInt::get(IntTy, 0);
for (unsigned I = First; I < NumArgs; ++I) {
auto *Index = llvm::ConstantInt::get(IntTy, I - First);
- auto *GEP = Builder.CreateGEP(Arr, {Zero, Index});
+ auto *GEP = Builder.CreateGEP(TmpPtr, {Zero, Index});
if (I == First)
- Ptr = GEP;
+ ElemPtr = GEP;
auto *V =
Builder.CreateZExtOrTrunc(EmitScalarExpr(E->getArg(I)),
SizeTy);
Builder.CreateAlignedStore(
V, GEP,
CGM.getDataLayout().getPrefTypeAlignment(SizeTy));
}
- return Ptr;
+ return std::tie(ElemPtr, TmpSize, TmpPtr);
};

// Could have events and/or varargs.
@@ -3366,24 +3372,27 @@ RValue CodeGenFunction::EmitBuiltinExpr(
llvm::Value *Kernel =
Builder.CreatePointerCast(Info.Kernel, GenericVoidPtrTy);
auto *Block = Builder.CreatePointerCast(Info.BlockArg,
GenericVoidPtrTy);
- auto *PtrToSizeArray = CreateArrayForSizeVar(4);
+ llvm::Value *ElemPtr, *TmpSize, *TmpPtr;
+ std::tie(ElemPtr, TmpSize, TmpPtr) =
CreateArrayForSizeVar(4);

// Create a vector of the arguments, as well as a constant
value to
// express to the runtime the number of variadic arguments.
std::vector Args = {
Queue, Flags, Range,
Kernel, Block, ConstantInt::get(IntTy, NumArgs - 4),
- PtrToSizeArray};
+ ElemPtr};
std::vector ArgTys = {
- QueueTy, IntTy, RangeTy,
- GenericVoidPtrTy, GenericVoidPtrTy, IntTy,
- PtrToSizeArray->getType()};
+ QueueTy, IntTy, RangeTy,
GenericVoidPtrTy,
+ GenericVoidPtrTy, IntTy, ElemPtr->getType()};

llvm::FunctionType *FTy = llvm::FunctionType::get(
Int32Ty, llvm::ArrayRef(ArgTys), false);
- return RValue::get(
- Builder.CreateCall(CGM.CreateRuntimeFunction(FTy, Name),
- llvm::ArrayRef(Args)));
+ auto Call =
+
RValue::get(Builder.CreateCall(CGM.CreateRuntimeFunction(FTy, Name),
+ llvm::ArrayRef(Args)));
+ if (TmpSize)
+ EmitLifetimeEnd(TmpSize, TmpPtr);
+ return Call;
}
// Any calls now have event arguments passed.
if (NumArgs >= 7) {
@@ -3430,15 +3439,19 @@ RValue CodeGenFunction::EmitBuiltinExpr(
ArgTys.push_back(Int32Ty);
Name = "__enqueue_kernel_events_varargs";

- auto *PtrToSizeArray = CreateArrayForSizeVar(7);
- Args.push_back(PtrToSizeArray);
- ArgTys.push_back(PtrToSizeArray->getType());
+ llvm::Value *ElemPtr, *TmpSize, *TmpPtr;
+ std::tie(ElemPtr, TmpSize, TmpPtr) =
CreateArrayForSi

r339018 - [ASTmporter] SourceRange-free function parameter checking for declarations

2018-08-06 Thread Gabor Marton via cfe-commits
Author: martong
Date: Mon Aug  6 07:38:37 2018
New Revision: 339018

URL: http://llvm.org/viewvc/llvm-project?rev=339018&view=rev
Log:
[ASTmporter] SourceRange-free function parameter checking for declarations

Summary: The previous code which avoided infinite recursion (because of 
reparsing declarations in function parameter lists) contained SourceRange 
dependent code which had some problems when parameter types were coming from 
macros. The new solution is not using macros and therefore much safer. A couple 
of importer problems are fixed in redis and tmux by this fix. Various unittests 
are included.

Reviewers: a.sidorin, r.stahl, a_sidorin

Reviewed By: a_sidorin

Subscribers: cfe-commits, dkrupp, balazske, martong

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

Patch by Zoltan Gera!

Modified:
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/unittests/AST/ASTImporterTest.cpp

Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=339018&r1=339017&r2=339018&view=diff
==
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Mon Aug  6 07:38:37 2018
@@ -1147,15 +1147,21 @@ bool ASTNodeImporter::ImportDeclParts(Na
   FunctionDecl *FunDecl;
   if (isa(D) && (FunDecl = dyn_cast(OrigDC)) &&
   FunDecl->hasBody()) {
-SourceRange RecR = D->getSourceRange();
-SourceRange BodyR = FunDecl->getBody()->getSourceRange();
-// If RecordDecl is not in Body (it is a param), we bail out.
-if (RecR.isValid() && BodyR.isValid() &&
-(RecR.getBegin() < BodyR.getBegin() ||
- BodyR.getEnd() < RecR.getEnd())) {
-  Importer.FromDiag(D->getLocation(), diag::err_unsupported_ast_node)
-  << D->getDeclKindName();
-  return true;
+auto getLeafPointeeType = [](const Type *T) {
+  while (T->isPointerType() || T->isArrayType()) {
+T = T->getPointeeOrArrayElementType();
+  }
+  return T;
+};
+for (const ParmVarDecl *P : FunDecl->parameters()) {
+  const Type *LeafT =
+  getLeafPointeeType(P->getType().getCanonicalType().getTypePtr());
+  auto *RT = dyn_cast(LeafT);
+  if (RT && RT->getDecl() == D) {
+Importer.FromDiag(D->getLocation(), diag::err_unsupported_ast_node)
+<< D->getDeclKindName();
+return true;
+  }
 }
   }
 

Modified: cfe/trunk/unittests/AST/ASTImporterTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/ASTImporterTest.cpp?rev=339018&r1=339017&r2=339018&view=diff
==
--- cfe/trunk/unittests/AST/ASTImporterTest.cpp (original)
+++ cfe/trunk/unittests/AST/ASTImporterTest.cpp Mon Aug  6 07:38:37 2018
@@ -989,7 +989,7 @@ TEST_P(ASTImporterTestBase, ImportRecord
"  return 0;"
"}",
Lang_C, "input.c");
-  auto FromVar =
+  auto *FromVar =
   FirstDeclMatcher().match(FromTU, varDecl(hasName("d")));
   ASSERT_TRUE(FromVar);
   auto ToType =
@@ -999,12 +999,41 @@ TEST_P(ASTImporterTestBase, ImportRecord
 
 TEST_P(ASTImporterTestBase, ImportRecordDeclInFuncParams) {
   // This construct is not supported by ASTImporter.
-  Decl *FromTU =
-  getTuDecl("int declToImport(struct data_t{int a;int b;} *d){ return 0; 
}",
-Lang_C, "input.c");
-  auto From = FirstDeclMatcher().match(FromTU, functionDecl());
+  Decl *FromTU = getTuDecl(
+  "int declToImport(struct data_t{int a;int b;} ***d){ return 0; }",
+  Lang_C, "input.c");
+  auto *From = FirstDeclMatcher().match(
+  FromTU, functionDecl(hasName("declToImport")));
   ASSERT_TRUE(From);
-  auto To = Import(From, Lang_C);
+  auto *To = Import(From, Lang_C);
+  EXPECT_EQ(To, nullptr);
+}
+
+TEST_P(ASTImporterTestBase, ImportRecordDeclInFuncFromMacro) {
+  Decl *FromTU = getTuDecl(
+  "#define NONAME_SIZEOF(type) sizeof(struct{type *dummy;}) \n"
+  "int declToImport(){ return NONAME_SIZEOF(int); }",
+  Lang_C, "input.c");
+  auto *From = FirstDeclMatcher().match(
+  FromTU, functionDecl(hasName("declToImport")));
+  ASSERT_TRUE(From);
+  auto *To = Import(From, Lang_C);
+  ASSERT_TRUE(To);
+  EXPECT_TRUE(MatchVerifier().match(
+  To, functionDecl(hasName("declToImport"),
+   hasDescendant(unaryExprOrTypeTraitExpr();
+}
+
+TEST_P(ASTImporterTestBase, ImportRecordDeclInFuncParamsFromMacro) {
+  // This construct is not supported by ASTImporter.
+  Decl *FromTU = getTuDecl(
+  "#define PAIR_STRUCT(type) struct data_t{type a;type b;} \n"
+  "int declToImport(PAIR_STRUCT(int) ***d){ return 0; }",
+  Lang_C, "input.c");
+  auto *From = FirstDeclMatcher().match(
+  FromTU, functionDecl(hasName("declToImport")));
+  ASSERT_TRUE(From);
+  auto *To = Import(From, Lang_C);
   EXPECT_EQ(To, nullptr);
 }
 


[PATCH] D49792: [ASTmporter] SourceRange-free function parameter checking for declarations

2018-08-06 Thread Gabor Marton via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL339018: [ASTmporter] SourceRange-free function parameter 
checking for declarations (authored by martong, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D49792?vs=157236&id=159303#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D49792

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


Index: cfe/trunk/lib/AST/ASTImporter.cpp
===
--- cfe/trunk/lib/AST/ASTImporter.cpp
+++ cfe/trunk/lib/AST/ASTImporter.cpp
@@ -1147,15 +1147,21 @@
   FunctionDecl *FunDecl;
   if (isa(D) && (FunDecl = dyn_cast(OrigDC)) &&
   FunDecl->hasBody()) {
-SourceRange RecR = D->getSourceRange();
-SourceRange BodyR = FunDecl->getBody()->getSourceRange();
-// If RecordDecl is not in Body (it is a param), we bail out.
-if (RecR.isValid() && BodyR.isValid() &&
-(RecR.getBegin() < BodyR.getBegin() ||
- BodyR.getEnd() < RecR.getEnd())) {
-  Importer.FromDiag(D->getLocation(), diag::err_unsupported_ast_node)
-  << D->getDeclKindName();
-  return true;
+auto getLeafPointeeType = [](const Type *T) {
+  while (T->isPointerType() || T->isArrayType()) {
+T = T->getPointeeOrArrayElementType();
+  }
+  return T;
+};
+for (const ParmVarDecl *P : FunDecl->parameters()) {
+  const Type *LeafT =
+  getLeafPointeeType(P->getType().getCanonicalType().getTypePtr());
+  auto *RT = dyn_cast(LeafT);
+  if (RT && RT->getDecl() == D) {
+Importer.FromDiag(D->getLocation(), diag::err_unsupported_ast_node)
+<< D->getDeclKindName();
+return true;
+  }
 }
   }
 
Index: cfe/trunk/unittests/AST/ASTImporterTest.cpp
===
--- cfe/trunk/unittests/AST/ASTImporterTest.cpp
+++ cfe/trunk/unittests/AST/ASTImporterTest.cpp
@@ -989,7 +989,7 @@
"  return 0;"
"}",
Lang_C, "input.c");
-  auto FromVar =
+  auto *FromVar =
   FirstDeclMatcher().match(FromTU, varDecl(hasName("d")));
   ASSERT_TRUE(FromVar);
   auto ToType =
@@ -999,12 +999,41 @@
 
 TEST_P(ASTImporterTestBase, ImportRecordDeclInFuncParams) {
   // This construct is not supported by ASTImporter.
-  Decl *FromTU =
-  getTuDecl("int declToImport(struct data_t{int a;int b;} *d){ return 0; 
}",
-Lang_C, "input.c");
-  auto From = FirstDeclMatcher().match(FromTU, functionDecl());
+  Decl *FromTU = getTuDecl(
+  "int declToImport(struct data_t{int a;int b;} ***d){ return 0; }",
+  Lang_C, "input.c");
+  auto *From = FirstDeclMatcher().match(
+  FromTU, functionDecl(hasName("declToImport")));
+  ASSERT_TRUE(From);
+  auto *To = Import(From, Lang_C);
+  EXPECT_EQ(To, nullptr);
+}
+
+TEST_P(ASTImporterTestBase, ImportRecordDeclInFuncFromMacro) {
+  Decl *FromTU = getTuDecl(
+  "#define NONAME_SIZEOF(type) sizeof(struct{type *dummy;}) \n"
+  "int declToImport(){ return NONAME_SIZEOF(int); }",
+  Lang_C, "input.c");
+  auto *From = FirstDeclMatcher().match(
+  FromTU, functionDecl(hasName("declToImport")));
+  ASSERT_TRUE(From);
+  auto *To = Import(From, Lang_C);
+  ASSERT_TRUE(To);
+  EXPECT_TRUE(MatchVerifier().match(
+  To, functionDecl(hasName("declToImport"),
+   hasDescendant(unaryExprOrTypeTraitExpr();
+}
+
+TEST_P(ASTImporterTestBase, ImportRecordDeclInFuncParamsFromMacro) {
+  // This construct is not supported by ASTImporter.
+  Decl *FromTU = getTuDecl(
+  "#define PAIR_STRUCT(type) struct data_t{type a;type b;} \n"
+  "int declToImport(PAIR_STRUCT(int) ***d){ return 0; }",
+  Lang_C, "input.c");
+  auto *From = FirstDeclMatcher().match(
+  FromTU, functionDecl(hasName("declToImport")));
   ASSERT_TRUE(From);
-  auto To = Import(From, Lang_C);
+  auto *To = Import(From, Lang_C);
   EXPECT_EQ(To, nullptr);
 }
 


Index: cfe/trunk/lib/AST/ASTImporter.cpp
===
--- cfe/trunk/lib/AST/ASTImporter.cpp
+++ cfe/trunk/lib/AST/ASTImporter.cpp
@@ -1147,15 +1147,21 @@
   FunctionDecl *FunDecl;
   if (isa(D) && (FunDecl = dyn_cast(OrigDC)) &&
   FunDecl->hasBody()) {
-SourceRange RecR = D->getSourceRange();
-SourceRange BodyR = FunDecl->getBody()->getSourceRange();
-// If RecordDecl is not in Body (it is a param), we bail out.
-if (RecR.isValid() && BodyR.isValid() &&
-(RecR.getBegin() < BodyR.getBegin() ||
- BodyR.getEnd() < RecR.getEnd())) {
-  Importer.FromDiag(D->getLocation(), diag::err_unsupported_ast_node)
-  << D->getDeclKindName();
-  return true;
+auto getLeafPointeeType = [](const Type *T) {
+  while (T->isPointerType() || T->isArrayType()) {
+T = T->getPoin

[PATCH] D49840: [AST] Add MatchFinder::matchSubtree

2018-08-06 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

Ping.

Manuel, I still don't see how could we apply `match(anyOf(node), 
hasDescendant(node))` to the problem of general subtree traversal. 
(I'd like to have support for not just `decl()` but other kind of nodes too.)
Could you please advise how to move on? Also, could you please describe your 
specific technical arguments against this patch?


Repository:
  rC Clang

https://reviews.llvm.org/D49840



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


[PATCH] D50205: [libc++] Add availability markup for aligned new/delete

2018-08-06 Thread Louis Dionne via Phabricator via cfe-commits
ldionne abandoned this revision.
ldionne added a comment.

Nevermind, it looks like this patch is not necessary anymore since 
https://reviews.llvm.org/D45015 landed.


Repository:
  rCXX libc++

https://reviews.llvm.org/D50205



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


[PATCH] D50337: [clangd] DexIndex implementation prototype

2018-08-06 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev created this revision.
kbobyrev added reviewers: ioeric, ilya-biryukov.
kbobyrev added a project: clang-tools-extra.
Herald added subscribers: arphaman, mgrang, jkorous, MaskRay, mgorny.

This patch is a proof-of-concept Dex index implementation. It has several 
flaws, which don't allow replacing static MemIndex yet, such as:

- Not being able to handle queries of small size (less than 3 symbols); a way 
to solve this is generating trigrams of smaller size and having such incomplete 
trigrams in the index structure.
- Speed measurements: while manually editing files in Vim and requesting 
autocompletion gives an impression that the performance is at least comparable 
with the current static index, having actual numbers is important because we 
don't want to hurt the users and roll out slow code. Eric (@ioeric) suggested 
that we should only replace MemIndex as soon as we have the evidence that this 
is not a regression in terms of performance. An approach which is likely to be 
successful here is to wait until we have benchmark library in the LLVM core 
repository, which is something I have suggested in the LLVM mailing lists, 
received positive feedback on and started working on. I will add a dependency 
as soon as the suggested patch is out for a review (currently there's at least 
one complication which is being addressed by 
https://github.com/google/benchmark/pull/649). Key performance improvements for 
iterators are sorting by cost and the limit iterator.
- Quality measurements: currently, boosting iterator and two-phase lookup stage 
are not implemented, without these the quality is likely to be worse than the 
current implementation can yield. Measuring quality is tricky, but another 
suggestion in the offline discussion was that the drop-in replacement should 
only happen after Boosting iterators implementation (and subsequent query 
enhancement).

The proposed changes do not affect Clangd functionality or performance, 
`DexIndex` is only used in unit tests and not in production code.


https://reviews.llvm.org/D50337

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/index/MemIndex.h
  clang-tools-extra/clangd/index/dex/DexIndex.cpp
  clang-tools-extra/clangd/index/dex/DexIndex.h
  clang-tools-extra/clangd/index/dex/Token.cpp
  clang-tools-extra/clangd/index/dex/Token.h
  clang-tools-extra/unittests/clangd/CMakeLists.txt
  clang-tools-extra/unittests/clangd/DexIndexTests.cpp
  clang-tools-extra/unittests/clangd/IndexHelpers.cpp
  clang-tools-extra/unittests/clangd/IndexHelpers.h
  clang-tools-extra/unittests/clangd/IndexTests.cpp

Index: clang-tools-extra/unittests/clangd/IndexTests.cpp
===
--- clang-tools-extra/unittests/clangd/IndexTests.cpp
+++ clang-tools-extra/unittests/clangd/IndexTests.cpp
@@ -7,33 +7,20 @@
 //
 //===--===//
 
+#include "IndexHelpers.h"
 #include "index/Index.h"
 #include "index/MemIndex.h"
 #include "index/Merge.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
-using testing::UnorderedElementsAre;
 using testing::Pointee;
+using testing::UnorderedElementsAre;
 
 namespace clang {
 namespace clangd {
 namespace {
 
-Symbol symbol(llvm::StringRef QName) {
-  Symbol Sym;
-  Sym.ID = SymbolID(QName.str());
-  size_t Pos = QName.rfind("::");
-  if (Pos == llvm::StringRef::npos) {
-Sym.Name = QName;
-Sym.Scope = "";
-  } else {
-Sym.Name = QName.substr(Pos + 2);
-Sym.Scope = QName.substr(0, Pos + 2);
-  }
-  return Sym;
-}
-
 MATCHER_P(Named, N, "") { return arg.Name == N; }
 
 TEST(SymbolSlab, FindAndIterate) {
@@ -52,59 +39,6 @@
 EXPECT_THAT(*S.find(SymbolID(Sym)), Named(Sym));
 }
 
-struct SlabAndPointers {
-  SymbolSlab Slab;
-  std::vector Pointers;
-};
-
-// Create a slab of symbols with the given qualified names as both IDs and
-// names. The life time of the slab is managed by the returned shared pointer.
-// If \p WeakSymbols is provided, it will be pointed to the managed object in
-// the returned shared pointer.
-std::shared_ptr>
-generateSymbols(std::vector QualifiedNames,
-std::weak_ptr *WeakSymbols = nullptr) {
-  SymbolSlab::Builder Slab;
-  for (llvm::StringRef QName : QualifiedNames)
-Slab.insert(symbol(QName));
-
-  auto Storage = std::make_shared();
-  Storage->Slab = std::move(Slab).build();
-  for (const auto &Sym : Storage->Slab)
-Storage->Pointers.push_back(&Sym);
-  if (WeakSymbols)
-*WeakSymbols = Storage;
-  auto *Pointers = &Storage->Pointers;
-  return {std::move(Storage), Pointers};
-}
-
-// Create a slab of symbols with IDs and names [Begin, End], otherwise identical
-// to the `generateSymbols` above.
-std::shared_ptr>
-generateNumSymbols(int Begin, int End,
-   std::weak_ptr *WeakSymbols = nullptr) {
-  std::vector Names;
-  for (int i = Begin; i <= End; i++)
-Names.push_back(std::to_string(i));
-  return ge

r339024 - [AST] Add individual size info for Types in -print-stats

2018-08-06 Thread Bruno Ricci via cfe-commits
Author: brunoricci
Date: Mon Aug  6 08:17:32 2018
New Revision: 339024

URL: http://llvm.org/viewvc/llvm-project?rev=339024&view=rev
Log:
[AST] Add individual size info for Types in -print-stats

This mirrors what is done for Decls and Stmts in the -print-stats
output, ie instead of printing "57426 LValueReference types"
we print "57426 LValueReference types, 40 each (2297040 bytes)".


Modified:
cfe/trunk/lib/AST/ASTContext.cpp

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=339024&r1=339023&r2=339024&view=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Mon Aug  6 08:17:32 2018
@@ -885,7 +885,9 @@ void ASTContext::PrintStats() const {
 #define TYPE(Name, Parent)  \
   if (counts[Idx])  \
 llvm::errs() << "" << counts[Idx] << " " << #Name   \
- << " types\n"; \
+ << " types, " << sizeof(Name##Type) << " each "\
+ << "(" << counts[Idx] * sizeof(Name##Type) \
+ << " bytes)\n";\
   TotalBytes += counts[Idx] * sizeof(Name##Type);   \
   ++Idx;
 #define ABSTRACT_TYPE(Name, Parent)


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


[PATCH] D50337: [clangd] DexIndex implementation prototype

2018-08-06 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev planned changes to this revision.
kbobyrev added a comment.

The patch is currently in preview-mode; I have to make few changes:

- Improve testing infrastructure; one possible way would be to use exactly the 
same code `MemIndex` currently does as it is meant to be a drop-in replacement. 
An existing obstacle would be not handling <3 long queries, but it's not hard 
to fix.
- Documenting `DexIndex` implementation and thinking about how to abstract out 
very similar code pieces shared with `MemIndex`. The proposed implementation is 
rather straightforward, but few pieces are identical to `MemIndex` which causes 
some code duplication.


https://reviews.llvm.org/D50337



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


[PATCH] D50144: Add Windows support for the GNUstep Objective-C ABI V2.

2018-08-06 Thread David Chisnall via Phabricator via cfe-commits
theraven updated this revision to Diff 159312.
theraven added a comment.

- Fix failing test.


Repository:
  rC Clang

https://reviews.llvm.org/D50144

Files:
  include/clang/Driver/Options.td
  lib/AST/MicrosoftMangle.cpp
  lib/CodeGen/CGBlocks.cpp
  lib/CodeGen/CGException.cpp
  lib/CodeGen/CGObjCGNU.cpp
  lib/CodeGen/CGObjCRuntime.cpp
  lib/CodeGen/CGObjCRuntime.h
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/EHScopeStack.h
  lib/Driver/ToolChains/Clang.cpp
  test/CodeGenObjC/gnu-init.m
  test/CodeGenObjC/gnustep2-proto.m
  test/CodeGenObjCXX/arc-marker-funclet.mm
  test/CodeGenObjCXX/microsoft-abi-arc-param-order.mm
  test/CodeGenObjCXX/msabi-objc-extensions.mm
  test/CodeGenObjCXX/msabi-objc-types.mm

Index: test/CodeGenObjCXX/msabi-objc-types.mm
===
--- test/CodeGenObjCXX/msabi-objc-types.mm
+++ test/CodeGenObjCXX/msabi-objc-types.mm
@@ -3,166 +3,166 @@
 @class I;
 
 id kid;
-// CHECK: @"?kid@@3PAUobjc_object@@A" =  dso_local global
+// CHECK: @"?kid@@3PAU.objc_object@@A" =  dso_local global
 
 Class klass;
-// CHECK: @"?klass@@3PAUobjc_class@@A" = dso_local global
+// CHECK: @"?klass@@3PAU.objc_class@@A" = dso_local global
 
 I *kI;
-// CHECK: @"?kI@@3PAUI@@A" = dso_local global
+// CHECK: @"?kI@@3PAU.objc_cls_I@@A" = dso_local global
 
 void f(I *) {}
-// CHECK-LABEL: "?f@@YAXPAUI@@@Z"
+// CHECK-LABEL: "?f@@YAXPAU.objc_cls_I@@@Z"
 
 void f(const I *) {}
-// CHECK-LABEL: "?f@@YAXPBUI@@@Z"
+// CHECK-LABEL: "?f@@YAXPBU.objc_cls_I@@@Z"
 
 void f(I &) {}
-// CHECK-LABEL: "?f@@YAXAAUI@@@Z"
+// CHECK-LABEL: "?f@@YAXAAU.objc_cls_I@@@Z"
 
 void f(const I &) {}
-// CHECK-LABEL: "?f@@YAXABUI@@@Z"
+// CHECK-LABEL: "?f@@YAXABU.objc_cls_I@@@Z"
 
 void f(const I &&) {}
-// CHECK-LABEL: "?f@@YAX$$QBUI@@@Z"
+// CHECK-LABEL: "?f@@YAX$$QBU.objc_cls_I@@@Z"
 
 void g(id) {}
-// CHECK-LABEL: "?g@@YAXPAUobjc_object@@@Z"
+// CHECK-LABEL: "?g@@YAXPAU.objc_object@@@Z"
 
 void g(id &) {}
-// CHECK-LABEL: "?g@@YAXAAPAUobjc_object@@@Z"
+// CHECK-LABEL: "?g@@YAXAAPAU.objc_object@@@Z"
 
 void g(const id &) {}
-// CHECK-LABEL: "?g@@YAXABQAUobjc_object@@@Z"
+// CHECK-LABEL: "?g@@YAXABQAU.objc_object@@@Z"
 
 void g(id &&) {}
-// CHECK-LABEL: "?g@@YAX$$QAPAUobjc_object@@@Z"
+// CHECK-LABEL: "?g@@YAX$$QAPAU.objc_object@@@Z"
 
 void h(Class) {}
-// CHECK-LABEL: "?h@@YAXPAUobjc_class@@@Z"
+// CHECK-LABEL: "?h@@YAXPAU.objc_class@@@Z"
 
 void h(Class &) {}
-// CHECK-LABEL: "?h@@YAXAAPAUobjc_class@@@Z"
+// CHECK-LABEL: "?h@@YAXAAPAU.objc_class@@@Z"
 
 void h(const Class &) {}
-// CHECK-LABEL: "?h@@YAXABQAUobjc_class@@@Z"
+// CHECK-LABEL: "?h@@YAXABQAU.objc_class@@@Z"
 
 void h(Class &&) {}
-// CHECK-LABEL: "?h@@YAX$$QAPAUobjc_class@@@Z"
+// CHECK-LABEL: "?h@@YAX$$QAPAU.objc_class@@@Z"
 
 I *i() { return nullptr; }
-// CHECK-LABEL: "?i@@YAPAUI@@XZ"
+// CHECK-LABEL: "?i@@YAPAU.objc_cls_I@@XZ"
 
 const I *j() { return nullptr; }
-// CHECK-LABEL: "?j@@YAPBUI@@XZ"
+// CHECK-LABEL: "?j@@YAPBU.objc_cls_I@@XZ"
 
 I &k() { return *kI; }
-// CHECK-LABEL: "?k@@YAAAUI@@XZ"
+// CHECK-LABEL: "?k@@YAAAU.objc_cls_I@@XZ"
 
 const I &l() { return *kI; }
-// CHECK-LABEL: "?l@@YAABUI@@XZ"
+// CHECK-LABEL: "?l@@YAABU.objc_cls_I@@XZ"
 
 void m(const id) {}
-// CHECK-LABEL: "?m@@YAXQAUobjc_object@@@Z"
+// CHECK-LABEL: "?m@@YAXQAU.objc_object@@@Z"
 
 void m(const I *) {}
-// CHECK-LABEL: "?m@@YAXPBUI@@@Z"
+// CHECK-LABEL: "?m@@YAXPBU.objc_cls_I@@@Z"
 
 void n(SEL) {}
-// CHECK-LABEL: "?n@@YAXPAUobjc_selector@@@Z"
+// CHECK-LABEL: "?n@@YAXPAU.objc_selector@@@Z"
 
 void n(SEL *) {}
-// CHECK-LABEL: "?n@@YAXPAPAUobjc_selector@@@Z"
+// CHECK-LABEL: "?n@@YAXPAPAU.objc_selector@@@Z"
 
 void n(const SEL *) {}
-// CHECK-LABEL: "?n@@YAXPBQAUobjc_selector@@@Z"
+// CHECK-LABEL: "?n@@YAXPBQAU.objc_selector@@@Z"
 
 void n(SEL &) {}
-// CHECK-LABEL: "?n@@YAXAAPAUobjc_selector@@@Z"
+// CHECK-LABEL: "?n@@YAXAAPAU.objc_selector@@@Z"
 
 void n(const SEL &) {}
-// CHECK-LABEL: "?n@@YAXABQAUobjc_selector@@@Z"
+// CHECK-LABEL: "?n@@YAXABQAU.objc_selector@@@Z"
 
 void n(SEL &&) {}
-// CHECK-LABEL: "?n@@YAX$$QAPAUobjc_selector@@@Z"
+// CHECK-LABEL: "?n@@YAX$$QAPAU.objc_selector@@@Z"
 
 struct __declspec(dllexport) s {
   struct s &operator=(const struct s &) = delete;
 
   void m(I *) {}
-  // CHECK-LABEL: "?m@s@@QAAXPAUI@@@Z"
+  // CHECK-LABEL: "?m@s@@QAAXPAU.objc_cls_I@@@Z"
 
   void m(const I *) {}
-  // CHECK-LABEL: "?m@s@@QAAXPBUI@@@Z"
+  // CHECK-LABEL: "?m@s@@QAAXPBU.objc_cls_I@@@Z"
 
   void m(I &) {}
-  // CHECK-LABEL: "?m@s@@QAAXAAUI@@@Z"
+  // CHECK-LABEL: "?m@s@@QAAXAAU.objc_cls_I@@@Z"
 
   void m(const I &) {}
-  // CHECK-LABEL: "?m@s@@QAAXABUI@@@Z"
+  // CHECK-LABEL: "?m@s@@QAAXABU.objc_cls_I@@@Z"
 
   void m(I &&) {}
-  // CHECK-LABEL: "?m@s@@QAAX$$QAUI@@@Z"
+  // CHECK-LABEL: "?m@s@@QAAX$$QAU.objc_cls_I@@@Z"
 
   void m(const I &&) {}
-  // CHECK-LABEL: "?m@s@@QAAX$$QBUI@@@Z"
+  // CHECK-LABEL: "?m@s@@QAAX$$QBU.objc_cls_I@@@Z"
 
   void m(id) {}
-  // CHECK-LABEL: "?m@s@@QAAXPAUobjc_object@@@Z"
+  // CHEC

[PATCH] D49945: [Fixed Point Arithmetic] Fix for FixedPointValueToString

2018-08-06 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan marked an inline comment as done.
leonardchan added inline comments.



Comment at: lib/AST/Expr.cpp:788
   FixedPointValueToString(
-  S, llvm::APSInt::getUnsigned(getValue().getZExtValue()), Scale, Radix);
+  S, llvm::APSInt::getUnsigned(getValue().getZExtValue()), Scale);
   return S.str();

ebevhan wrote:
> Unrelated to this patch specifically, but using `getZExtValue` here is a bit 
> limiting.
I'll make another small patch to change this since should also do signed values 
now,


Repository:
  rC Clang

https://reviews.llvm.org/D49945



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


r339026 - [Fixed Point Arithmetic] Fix for FixedPointValueToString

2018-08-06 Thread Leonard Chan via cfe-commits
Author: leonardchan
Date: Mon Aug  6 09:05:08 2018
New Revision: 339026

URL: http://llvm.org/viewvc/llvm-project?rev=339026&view=rev
Log:
[Fixed Point Arithmetic] Fix for FixedPointValueToString

- Print negative numbers correctly
- Handle APInts of different sizes
- Add formal unit tests for FixedPointValueToString
- Add tests for checking correct printing when padding is set
- Restrict to printing in radix 10 since that's all we need for now

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

Added:
cfe/trunk/test/Frontend/fixed_point_to_string.c
cfe/trunk/unittests/Frontend/FixedPointString.cpp
Modified:
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/unittests/Frontend/CMakeLists.txt

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=339026&r1=339025&r2=339026&view=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Mon Aug  6 09:05:08 2018
@@ -6604,9 +6604,8 @@ QualType DecayedType::getPointeeType() c
 
 // Get the decimal string representation of a fixed point type, represented
 // as a scaled integer.
-void FixedPointValueToString(SmallVectorImpl &Str,
- const llvm::APSInt &Val,
- unsigned Scale, unsigned Radix);
+void FixedPointValueToString(SmallVectorImpl &Str, llvm::APSInt Val,
+ unsigned Scale);
 
 } // namespace clang
 

Modified: cfe/trunk/lib/AST/Expr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=339026&r1=339025&r2=339026&view=diff
==
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Mon Aug  6 09:05:08 2018
@@ -785,7 +785,7 @@ std::string FixedPointLiteral::getValueA
   // which is 43 characters.
   SmallString<64> S;
   FixedPointValueToString(
-  S, llvm::APSInt::getUnsigned(getValue().getZExtValue()), Scale, Radix);
+  S, llvm::APSInt::getUnsigned(getValue().getZExtValue()), Scale);
   return S.str();
 }
 

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=339026&r1=339025&r2=339026&view=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Mon Aug  6 09:05:08 2018
@@ -9698,8 +9698,7 @@ bool FixedPointExprEvaluator::VisitUnary
   if (Value.isSigned() && Value.isMinSignedValue() && E->canOverflow()) {
 SmallString<64> S;
 FixedPointValueToString(S, Value,
-Info.Ctx.getTypeInfo(E->getType()).Width,
-/*Radix=*/10);
+Info.Ctx.getTypeInfo(E->getType()).Width);
 Info.CCEDiag(E, diag::note_constexpr_overflow) << S << E->getType();
 if (Info.noteUndefinedBehavior()) return false;
   }

Modified: cfe/trunk/lib/AST/Type.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=339026&r1=339025&r2=339026&view=diff
==
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Mon Aug  6 09:05:08 2018
@@ -4032,17 +4032,26 @@ CXXRecordDecl *MemberPointerType::getMos
 }
 
 void clang::FixedPointValueToString(SmallVectorImpl &Str,
-const llvm::APSInt &Val, unsigned Scale,
-unsigned Radix) {
-  llvm::APSInt ScaleVal = llvm::APSInt::getUnsigned(1ULL << Scale);
-  llvm::APSInt IntPart = Val / ScaleVal;
-  llvm::APSInt FractPart = Val % ScaleVal;
-  llvm::APSInt RadixInt = llvm::APSInt::getUnsigned(Radix);
+llvm::APSInt Val, unsigned Scale) {
+  if (Val.isSigned() && Val.isNegative() && Val != -Val) {
+Val = -Val;
+Str.push_back('-');
+  }
 
-  IntPart.toString(Str, Radix);
+  llvm::APSInt IntPart = Val >> Scale;
+
+  // Add 4 digits to hold the value after multiplying 10 (the radix)
+  unsigned Width = Val.getBitWidth() + 4;
+  llvm::APInt FractPart = Val.zextOrTrunc(Scale).zext(Width);
+  llvm::APInt FractPartMask = llvm::APInt::getAllOnesValue(Scale).zext(Width);
+  llvm::APInt RadixInt = llvm::APInt(Width, 10);
+
+  IntPart.toString(Str, /*radix=*/10);
   Str.push_back('.');
   do {
-(FractPart * RadixInt / ScaleVal).toString(Str, Radix);
-FractPart = (FractPart * RadixInt) % ScaleVal;
-  } while (FractPart.getExtValue());
+(FractPart * RadixInt)
+.lshr(Scale)
+.toString(Str, /*radix=*/10, Val.isSigned());
+FractPart = (FractPart * RadixInt) & FractPartMask;
+  } while (FractPart != 0);
 }

Added:

[PATCH] D49945: [Fixed Point Arithmetic] Fix for FixedPointValueToString

2018-08-06 Thread Leonard Chan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
leonardchan marked an inline comment as done.
Closed by commit rC339026: [Fixed Point Arithmetic] Fix for 
FixedPointValueToString (authored by leonardchan, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D49945

Files:
  include/clang/AST/Type.h
  lib/AST/Expr.cpp
  lib/AST/ExprConstant.cpp
  lib/AST/Type.cpp
  test/Frontend/fixed_point_to_string.c
  unittests/Frontend/CMakeLists.txt
  unittests/Frontend/FixedPointString.cpp

Index: test/Frontend/fixed_point_to_string.c
===
--- test/Frontend/fixed_point_to_string.c
+++ test/Frontend/fixed_point_to_string.c
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -ast-dump -ffixed-point %s | FileCheck %s
+// RUN: %clang_cc1 -ast-dump -ffixed-point -fpadding-on-unsigned-fixed-point %s | FileCheck %s
+
+/**
+ * Check the same values are printed in the AST regardless of if unsigned types
+ * have the same number of fractional bits as signed types.
+ */
+
+unsigned short _Accum u_short_accum = 0.5uhk;
+unsigned _Accum u_accum = 0.5uk;
+unsigned long _Accum u_long_accum = 0.5ulk;
+unsigned short _Fract u_short_fract = 0.5uhr;
+unsigned _Fract u_fract = 0.5ur;
+unsigned long _Fract u_long_fract = 0.5ulr;
+
+//CHECK: FixedPointLiteral {{.*}} 'unsigned short _Accum' 0.5
+//CHECK: FixedPointLiteral {{.*}} 'unsigned _Accum' 0.5
+//CHECK: FixedPointLiteral {{.*}} 'unsigned long _Accum' 0.5
+//CHECK: FixedPointLiteral {{.*}} 'unsigned short _Fract' 0.5
+//CHECK: FixedPointLiteral {{.*}} 'unsigned _Fract' 0.5
+//CHECK: FixedPointLiteral {{.*}} 'unsigned long _Fract' 0.5
Index: lib/AST/Type.cpp
===
--- lib/AST/Type.cpp
+++ lib/AST/Type.cpp
@@ -4032,17 +4032,26 @@
 }
 
 void clang::FixedPointValueToString(SmallVectorImpl &Str,
-const llvm::APSInt &Val, unsigned Scale,
-unsigned Radix) {
-  llvm::APSInt ScaleVal = llvm::APSInt::getUnsigned(1ULL << Scale);
-  llvm::APSInt IntPart = Val / ScaleVal;
-  llvm::APSInt FractPart = Val % ScaleVal;
-  llvm::APSInt RadixInt = llvm::APSInt::getUnsigned(Radix);
+llvm::APSInt Val, unsigned Scale) {
+  if (Val.isSigned() && Val.isNegative() && Val != -Val) {
+Val = -Val;
+Str.push_back('-');
+  }
+
+  llvm::APSInt IntPart = Val >> Scale;
+
+  // Add 4 digits to hold the value after multiplying 10 (the radix)
+  unsigned Width = Val.getBitWidth() + 4;
+  llvm::APInt FractPart = Val.zextOrTrunc(Scale).zext(Width);
+  llvm::APInt FractPartMask = llvm::APInt::getAllOnesValue(Scale).zext(Width);
+  llvm::APInt RadixInt = llvm::APInt(Width, 10);
 
-  IntPart.toString(Str, Radix);
+  IntPart.toString(Str, /*radix=*/10);
   Str.push_back('.');
   do {
-(FractPart * RadixInt / ScaleVal).toString(Str, Radix);
-FractPart = (FractPart * RadixInt) % ScaleVal;
-  } while (FractPart.getExtValue());
+(FractPart * RadixInt)
+.lshr(Scale)
+.toString(Str, /*radix=*/10, Val.isSigned());
+FractPart = (FractPart * RadixInt) & FractPartMask;
+  } while (FractPart != 0);
 }
Index: lib/AST/Expr.cpp
===
--- lib/AST/Expr.cpp
+++ lib/AST/Expr.cpp
@@ -785,7 +785,7 @@
   // which is 43 characters.
   SmallString<64> S;
   FixedPointValueToString(
-  S, llvm::APSInt::getUnsigned(getValue().getZExtValue()), Scale, Radix);
+  S, llvm::APSInt::getUnsigned(getValue().getZExtValue()), Scale);
   return S.str();
 }
 
Index: lib/AST/ExprConstant.cpp
===
--- lib/AST/ExprConstant.cpp
+++ lib/AST/ExprConstant.cpp
@@ -9698,8 +9698,7 @@
   if (Value.isSigned() && Value.isMinSignedValue() && E->canOverflow()) {
 SmallString<64> S;
 FixedPointValueToString(S, Value,
-Info.Ctx.getTypeInfo(E->getType()).Width,
-/*Radix=*/10);
+Info.Ctx.getTypeInfo(E->getType()).Width);
 Info.CCEDiag(E, diag::note_constexpr_overflow) << S << E->getType();
 if (Info.noteUndefinedBehavior()) return false;
   }
Index: unittests/Frontend/FixedPointString.cpp
===
--- unittests/Frontend/FixedPointString.cpp
+++ unittests/Frontend/FixedPointString.cpp
@@ -0,0 +1,107 @@
+#include "clang/AST/Type.h"
+#include "llvm/ADT/APSInt.h"
+#include "llvm/ADT/SmallString.h"
+#include "gtest/gtest.h"
+
+using clang::FixedPointValueToString;
+using llvm::APSInt;
+using llvm::SmallString;
+
+namespace {
+
+TEST(FixedPointString, DifferentTypes) {
+  SmallString<64> S;
+  FixedPointValueToString(S, APSInt::get(320), 7);
+  ASSERT_STREQ(S.c_str(), "2.5");
+
+  S.clear();
+  FixedPointValueToString(S, APSInt::get(0), 7);
+  ASSERT_STREQ(S.c_str(), "0.0")

[PATCH] D50278: [Sema] Fix for crash on conditional operation with address_space pointer

2018-08-06 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 159315.
leonardchan added reviewers: ebevhan, rjmccall.
leonardchan removed a subscriber: ebevhan.
leonardchan added a comment.

- Changed diff such that an error is dumped instead. The code shouldn't compile 
in the first place since it involves conversion between pointers from different 
address_spaces.


Repository:
  rC Clang

https://reviews.llvm.org/D50278

Files:
  lib/Sema/SemaExpr.cpp
  test/Sema/address_spaces.c
  test/Sema/conditional-expr.c


Index: test/Sema/conditional-expr.c
===
--- test/Sema/conditional-expr.c
+++ test/Sema/conditional-expr.c
@@ -74,9 +74,12 @@
   int __attribute__((address_space(2))) *adr2;
   int __attribute__((address_space(3))) *adr3;
   test0 ? adr2 : adr3; // expected-warning {{pointer type mismatch}} 
expected-warning {{expression result unused}}
+   // expected-error@-1{{converting 
'__attribute__((address_space(2))) int *' to type 'void *' changes address 
space of pointer}}
+   // expected-error@-2{{converting 
'__attribute__((address_space(3))) int *' to type 'void *' changes address 
space of pointer}}
 
   // Make sure address-space mask ends up in the result type
   (test0 ? (test0 ? adr2 : adr2) : nonconst_int); // expected-warning 
{{pointer type mismatch}} expected-warning {{expression result unused}}
+  // 
expected-error@-1{{converting '__attribute__((address_space(2))) int *' to type 
'void *' changes address space of pointer}}
 }
 
 int Postgresql() {
Index: test/Sema/address_spaces.c
===
--- test/Sema/address_spaces.c
+++ test/Sema/address_spaces.c
@@ -72,4 +72,6 @@
 // Clang extension doesn't forbid operations on pointers to different address 
spaces.
 char* cmp(_AS1 char *x,  _AS2 char *y) {
   return x < y ? x : y; // expected-warning {{pointer type mismatch 
('__attribute__((address_space(1))) char *' and 
'__attribute__((address_space(2))) char *')}}
+// expected-error@-1{{converting 
'__attribute__((address_space(1))) char *' to type 'void *' changes address 
space of pointer}}
+// expected-error@-2{{converting 
'__attribute__((address_space(2))) char *' to type 'void *' changes address 
space of pointer}}
 }
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -6527,6 +6527,21 @@
 S.Diag(Loc, diag::ext_typecheck_cond_incompatible_pointers)
 << LHSTy << RHSTy << LHS.get()->getSourceRange()
 << RHS.get()->getSourceRange();
+
+// If the addresse spacesare different, we do not allow a bitcast.
+if (!S.getLangOpts().OpenCL) {
+  if (LAddrSpace != ResultAddrSpace) {
+S.Diag(Loc, diag::err_typecheck_incompatible_address_space)
+<< LHSTy << incompatTy << Sema::AA_Converting
+<< LHS.get()->getSourceRange();
+  }
+  if (RAddrSpace != ResultAddrSpace) {
+S.Diag(Loc, diag::err_typecheck_incompatible_address_space)
+<< RHSTy << incompatTy << Sema::AA_Converting
+<< RHS.get()->getSourceRange();
+  }
+}
+
 return incompatTy;
   }
 


Index: test/Sema/conditional-expr.c
===
--- test/Sema/conditional-expr.c
+++ test/Sema/conditional-expr.c
@@ -74,9 +74,12 @@
   int __attribute__((address_space(2))) *adr2;
   int __attribute__((address_space(3))) *adr3;
   test0 ? adr2 : adr3; // expected-warning {{pointer type mismatch}} expected-warning {{expression result unused}}
+   // expected-error@-1{{converting '__attribute__((address_space(2))) int *' to type 'void *' changes address space of pointer}}
+   // expected-error@-2{{converting '__attribute__((address_space(3))) int *' to type 'void *' changes address space of pointer}}
 
   // Make sure address-space mask ends up in the result type
   (test0 ? (test0 ? adr2 : adr2) : nonconst_int); // expected-warning {{pointer type mismatch}} expected-warning {{expression result unused}}
+  // expected-error@-1{{converting '__attribute__((address_space(2))) int *' to type 'void *' changes address space of pointer}}
 }
 
 int Postgresql() {
Index: test/Sema/address_spaces.c
===
--- test/Sema/address_spaces.c
+++ test/Sema/address_spaces.c
@@ -72,4 +72,6 @@
 // Clang extension doesn't forbid operations on pointers to different address spaces.
 char* cmp(_AS1 char *x,  _AS2 char *y) {
   return x < y ? x : y; // expected-warning {{pointer type mismatch ('__attribute__((address_space(1))) char *' and '__attribute__((address_space(2))) char *')}}
+// expected-error@-1{{converting '_

[PATCH] D48661: [Fixed Point Arithmetic] Fixed Point Constant

2018-08-06 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 159320.
leonardchan marked an inline comment as done.
leonardchan added a comment.

- Fixed `Accumum` names


Repository:
  rC Clang

https://reviews.llvm.org/D48661

Files:
  include/clang/AST/ASTContext.h
  include/clang/Basic/FixedPoint.h
  include/clang/Basic/TargetInfo.h
  lib/AST/ASTContext.cpp
  lib/Basic/CMakeLists.txt
  lib/Basic/FixedPoint.cpp
  lib/Sema/SemaExpr.cpp
  test/Frontend/fixed_point_declarations.c
  unittests/Basic/CMakeLists.txt
  unittests/Basic/FixedPointTest.cpp

Index: unittests/Basic/FixedPointTest.cpp
===
--- /dev/null
+++ unittests/Basic/FixedPointTest.cpp
@@ -0,0 +1,683 @@
+//===- unittests/Basic/FixedPointTest.cpp -- fixed point number tests -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "clang/Basic/FixedPoint.h"
+#include "llvm/ADT/APSInt.h"
+#include "gtest/gtest.h"
+
+using clang::APFixedPoint;
+using clang::FixedPointSemantics;
+using llvm::APInt;
+using llvm::APSInt;
+
+namespace {
+
+FixedPointSemantics Saturated(FixedPointSemantics Sema) {
+  Sema.setSaturated(true);
+  return Sema;
+}
+
+FixedPointSemantics getSAccumSema() {
+  return FixedPointSemantics(/*width=*/16, /*scale=*/7, /*isSigned=*/true,
+ /*isSaturated=*/false,
+ /*hasUnsignedPadding=*/false);
+}
+
+FixedPointSemantics getAccumSema() {
+  return FixedPointSemantics(/*width=*/32, /*scale=*/15, /*isSigned=*/true,
+ /*isSaturated=*/false,
+ /*hasUnsignedPadding=*/false);
+}
+
+FixedPointSemantics getLAccumSema() {
+  return FixedPointSemantics(/*width=*/64, /*scale=*/31, /*isSigned=*/true,
+ /*isSaturated=*/false,
+ /*hasUnsignedPadding=*/false);
+}
+
+FixedPointSemantics getSFractSema() {
+  return FixedPointSemantics(/*width=*/8, /*scale=*/7, /*isSigned=*/true,
+ /*isSaturated=*/false,
+ /*hasUnsignedPadding=*/false);
+}
+
+FixedPointSemantics getFractSema() {
+  return FixedPointSemantics(/*width=*/16, /*scale=*/15, /*isSigned=*/true,
+ /*isSaturated=*/false,
+ /*hasUnsignedPadding=*/false);
+}
+
+FixedPointSemantics getLFractSema() {
+  return FixedPointSemantics(/*width=*/32, /*scale=*/31, /*isSigned=*/true,
+ /*isSaturated=*/false,
+ /*hasUnsignedPadding=*/false);
+}
+
+FixedPointSemantics getUSAccumSema() {
+  return FixedPointSemantics(/*width=*/16, /*scale=*/8, /*isSigned=*/false,
+ /*isSaturated=*/false,
+ /*hasUnsignedPadding=*/false);
+}
+
+FixedPointSemantics getUAccumSema() {
+  return FixedPointSemantics(/*width=*/32, /*scale=*/16, /*isSigned=*/false,
+ /*isSaturated=*/false,
+ /*hasUnsignedPadding=*/false);
+}
+
+FixedPointSemantics getULAccumSema() {
+  return FixedPointSemantics(/*width=*/64, /*scale=*/32, /*isSigned=*/false,
+ /*isSaturated=*/false,
+ /*hasUnsignedPadding=*/false);
+}
+
+FixedPointSemantics getUSFractSema() {
+  return FixedPointSemantics(/*width=*/8, /*scale=*/8, /*isSigned=*/false,
+ /*isSaturated=*/false,
+ /*hasUnsignedPadding=*/false);
+}
+
+FixedPointSemantics getUFractSema() {
+  return FixedPointSemantics(/*width=*/16, /*scale=*/16, /*isSigned=*/false,
+ /*isSaturated=*/false,
+ /*hasUnsignedPadding=*/false);
+}
+
+FixedPointSemantics getULFractSema() {
+  return FixedPointSemantics(/*width=*/32, /*scale=*/32, /*isSigned=*/false,
+ /*isSaturated=*/false,
+ /*hasUnsignedPadding=*/false);
+}
+
+FixedPointSemantics getPadUSAccumSema() {
+  return FixedPointSemantics(/*width=*/16, /*scale=*/7, /*isSigned=*/false,
+ /*isSaturated=*/false,
+ /*hasUnsignedPadding=*/true);
+}
+
+FixedPointSemantics getPadUAccumSema() {
+  return FixedPointSemantics(/*width=*/32, /*scale=*/15, /*isSigned=*/false,
+ /*isSaturated=*/false,
+ /*hasUnsignedPadding=*/true);
+}
+
+FixedPointSemantics getPadULAccumSema() {
+  return FixedPointSemantics(/*width=*/64, /*scale=*/31, /*isSigned=*/false,
+ /*isSaturated=*/false,
+ /*hasUnsignedPadding=*/true);
+}
+
+FixedPointSemantics getPadUSFractSema() {
+  return FixedPointSemanti

[PATCH] D48661: [Fixed Point Arithmetic] Fixed Point Constant

2018-08-06 Thread Leonard Chan 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 rL339028: [Fixed Point Arithmetic] Fixed Point Constant 
(authored by leonardchan, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D48661?vs=159320&id=159321#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D48661

Files:
  cfe/trunk/include/clang/AST/ASTContext.h
  cfe/trunk/include/clang/Basic/FixedPoint.h
  cfe/trunk/include/clang/Basic/TargetInfo.h
  cfe/trunk/lib/AST/ASTContext.cpp
  cfe/trunk/lib/Basic/CMakeLists.txt
  cfe/trunk/lib/Basic/FixedPoint.cpp
  cfe/trunk/lib/Sema/SemaExpr.cpp
  cfe/trunk/test/Frontend/fixed_point_declarations.c
  cfe/trunk/unittests/Basic/CMakeLists.txt
  cfe/trunk/unittests/Basic/FixedPointTest.cpp

Index: cfe/trunk/test/Frontend/fixed_point_declarations.c
===
--- cfe/trunk/test/Frontend/fixed_point_declarations.c
+++ cfe/trunk/test/Frontend/fixed_point_declarations.c
@@ -1,5 +1,4 @@
 // RUN: %clang -ffixed-point -S -emit-llvm %s -o - --target=x86_64-linux | FileCheck %s
-// RUN: %clang -ffixed-point -S -emit-llvm %s -o - --target=x86_64-scei-ps4-ubuntu-fast | FileCheck %s
 
 // Primary fixed point types
 signed short _Accum   s_short_accum;  // CHECK-DAG: @s_short_accum  = {{.*}}global i16 0, align 2
@@ -111,3 +110,18 @@
 unsigned short _Fract u_short_fract_eps = 0x1p-8uhr;// CHECK-DAG: @u_short_fract_eps = {{.*}}global i8  1, align 1
 unsigned _Fract   u_fract_eps   = 0x1p-16ur;// CHECK-DAG: @u_fract_eps   = {{.*}}global i16 1, align 2
 unsigned long _Fract  u_long_fract_eps  = 0x1p-32ulr;   // CHECK-DAG: @u_long_fract_eps  = {{.*}}global i32 1, align 4
+
+// Zero
+short _Accum  short_accum_zero= 0.0hk;// CHECK-DAG: @short_accum_zero = {{.*}}global i16 0, align 2
+ _Accum   accum_zero  = 0.0k; // CHECK-DAG: @accum_zero   = {{.*}}global i32 0, align 4
+long _Accum   long_accum_zero = 0.0lk;// CHECK-DAG: @long_accum_zero  = {{.*}}global i64 0, align 8
+unsigned short _Accum u_short_accum_zero  = 0.0uhk;   // CHECK-DAG: @u_short_accum_zero   = {{.*}}global i16 0, align 2
+unsigned  _Accum  u_accum_zero= 0.0uk;// CHECK-DAG: @u_accum_zero = {{.*}}global i32 0, align 4
+unsigned long _Accum  u_long_accum_zero   = 0.0ulk;   // CHECK-DAG: @u_long_accum_zero= {{.*}}global i64 0, align 8
+
+short _Fract  short_fract_zero= 0.0hr;// CHECK-DAG: @short_fract_zero = {{.*}}global i8  0, align 1
+ _Fract   fract_zero  = 0.0r; // CHECK-DAG: @fract_zero   = {{.*}}global i16 0, align 2
+long _Fract   long_fract_zero = 0.0lr;// CHECK-DAG: @long_fract_zero  = {{.*}}global i32 0, align 4
+unsigned short _Fract u_short_fract_zero  = 0.0uhr;   // CHECK-DAG: @u_short_fract_zero   = {{.*}}global i8  0, align 1
+unsigned  _Fract  u_fract_zero= 0.0ur;// CHECK-DAG: @u_fract_zero = {{.*}}global i16 0, align 2
+unsigned long _Fract  u_long_fract_zero   = 0.0ulr;   // CHECK-DAG: @u_long_fract_zero= {{.*}}global i32 0, align 4
Index: cfe/trunk/lib/AST/ASTContext.cpp
===
--- cfe/trunk/lib/AST/ASTContext.cpp
+++ cfe/trunk/lib/AST/ASTContext.cpp
@@ -48,6 +48,7 @@
 #include "clang/Basic/Builtins.h"
 #include "clang/Basic/CommentOptions.h"
 #include "clang/Basic/ExceptionSpecificationType.h"
+#include "clang/Basic/FixedPoint.h"
 #include "clang/Basic/IdentifierTable.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/LangOptions.h"
@@ -10433,3 +10434,22 @@
   return 0;
   }
 }
+
+FixedPointSemantics ASTContext::getFixedPointSemantics(QualType Ty) const {
+  assert(Ty->isFixedPointType());
+  bool isSigned = Ty->isSignedFixedPointType();
+  return FixedPointSemantics(
+  static_cast(getTypeSize(Ty)), getFixedPointScale(Ty), isSigned,
+  Ty->isSaturatedFixedPointType(),
+  !isSigned && getTargetInfo().doUnsignedFixedPointTypesHavePadding());
+}
+
+APFixedPoint ASTContext::getFixedPointMax(QualType Ty) const {
+  assert(Ty->isFixedPointType());
+  return APFixedPoint::getMax(getFixedPointSemantics(Ty));
+}
+
+APFixedPoint ASTContext::getFixedPointMin(QualType Ty) const {
+  assert(Ty->isFixedPointType());
+  return APFixedPoint::getMin(getFixedPointSemantics(Ty));
+}
Index: cfe/trunk/lib/Sema/SemaExpr.cpp
===
--- cfe/trunk/lib/Sema/SemaExpr.cpp
+++ cfe/trunk/lib/Sema/SemaExpr.cpp
@@ -26,6 +26,7 @@
 #include "clang/AST/ExprOpenMP.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/AST/TypeLoc.h"
+#include "clang/Basic/FixedPoint.h"
 #include "clang/Basic/PartialDiagnostic.h"
 #include "clang/Basic/SourceManager.h"
 #include "cla

r339028 - [Fixed Point Arithmetic] Fixed Point Constant

2018-08-06 Thread Leonard Chan via cfe-commits
Author: leonardchan
Date: Mon Aug  6 09:42:37 2018
New Revision: 339028

URL: http://llvm.org/viewvc/llvm-project?rev=339028&view=rev
Log:
[Fixed Point Arithmetic] Fixed Point Constant

This patch proposes an abstract type that represents fixed point numbers, 
similar to APInt or APSInt that was discussed in 
https://reviews.llvm.org/D48456#inline-425585. This type holds a value, scale, 
and saturation and is meant to perform intermediate calculations on constant 
fixed point values.

Currently this class is used as a way for handling the conversions between 
fixed point numbers with different sizes and radixes. For example, if I'm 
casting from a signed _Accum to a saturated unsigned short _Accum, I will need 
to check the value of the signed _Accum to see if it fits into the short _Accum 
which involves getting and comparing against the max/min values of the short 
_Accum. The FixedPointNumber class currently handles the radix shifting and 
extension when converting to a signed _Accum.

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

Added:
cfe/trunk/include/clang/Basic/FixedPoint.h
cfe/trunk/lib/Basic/FixedPoint.cpp
cfe/trunk/unittests/Basic/FixedPointTest.cpp
Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/Basic/CMakeLists.txt
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/Frontend/fixed_point_declarations.c
cfe/trunk/unittests/Basic/CMakeLists.txt

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=339028&r1=339027&r2=339028&view=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Mon Aug  6 09:42:37 2018
@@ -79,6 +79,7 @@ struct fltSemantics;
 
 namespace clang {
 
+class APFixedPoint;
 class APValue;
 class ASTMutationListener;
 class ASTRecordLayout;
@@ -92,6 +93,7 @@ class CXXMethodDecl;
 class CXXRecordDecl;
 class DiagnosticsEngine;
 class Expr;
+class FixedPointSemantics;
 class MangleContext;
 class MangleNumberingContext;
 class MaterializeTemporaryExpr;
@@ -1961,6 +1963,9 @@ public:
 
   unsigned char getFixedPointScale(QualType Ty) const;
   unsigned char getFixedPointIBits(QualType Ty) const;
+  FixedPointSemantics getFixedPointSemantics(QualType Ty) const;
+  APFixedPoint getFixedPointMax(QualType Ty) const;
+  APFixedPoint getFixedPointMin(QualType Ty) const;
 
   DeclarationNameInfo getNameForTemplate(TemplateName Name,
  SourceLocation NameLoc) const;

Added: cfe/trunk/include/clang/Basic/FixedPoint.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/FixedPoint.h?rev=339028&view=auto
==
--- cfe/trunk/include/clang/Basic/FixedPoint.h (added)
+++ cfe/trunk/include/clang/Basic/FixedPoint.h Mon Aug  6 09:42:37 2018
@@ -0,0 +1,138 @@
+//===- FixedPoint.h - Fixed point constant handling -*- C++ 
-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+/// \file
+/// Defines the fixed point number interface.
+/// This is a class for abstracting various operations performed on fixed point
+/// types described in ISO/IEC JTC1 SC22 WG14 N1169 starting at clause 4.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_BASIC_FIXEDPOINT_H
+#define LLVM_CLANG_BASIC_FIXEDPOINT_H
+
+#include "llvm/ADT/APSInt.h"
+
+namespace clang {
+
+class ASTContext;
+class QualType;
+
+/// The fixed point semantics work similarly to llvm::fltSemantics. The width
+/// specifies the whole bit width of the underlying scaled integer (with 
padding
+/// if any). The scale represents the number of fractional bits in this type.
+/// When HasUnsignedPadding is true and this type is signed, the first bit
+/// in the value this represents is treaded as padding.
+class FixedPointSemantics {
+public:
+  FixedPointSemantics(unsigned Width, unsigned Scale, bool IsSigned,
+  bool IsSaturated, bool HasUnsignedPadding)
+  : Width(Width), Scale(Scale), IsSigned(IsSigned),
+IsSaturated(IsSaturated), HasUnsignedPadding(HasUnsignedPadding) {
+assert(Width >= Scale && "Not enough room for the scale");
+  }
+
+  unsigned getWidth() const { return Width; }
+  unsigned getScale() const { return Scale; }
+  bool isSigned() const { return IsSigned; }
+  bool isSaturated() const { return IsSaturated; }
+  bool hasUnsignedPadding() const { return HasUnsignedPadding; }
+
+  void setSaturated(bool Saturated) { IsSaturated = Saturated; }

r339030 - [AST] Remove unnecessary indirections in DeclarationNameTable

2018-08-06 Thread Bruno Ricci via cfe-commits
Author: brunoricci
Date: Mon Aug  6 09:47:31 2018
New Revision: 339030

URL: http://llvm.org/viewvc/llvm-project?rev=339030&view=rev
Log:
[AST] Remove unnecessary indirections in DeclarationNameTable

DeclarationNameTable currently hold 3 "void *" to
FoldingSet, FoldingSet
and FoldingSet.

CXXSpecialName, CXXLiteralOperatorIdName and
CXXDeductionGuideNameExtra are private classes holding extra
information about a "special" declaration name and are in
AST/DeclarationName.cpp. The original intent seems to have
been to keep these classes private and only expose
DeclarationNameExtra and DeclarationName (the code dates from
2008 and has not been significantly changed since).

However this make the code less straightforward than necessary
because of the need to have "void *" in DeclarationNameTable
(with 1 of 3 comments wrong) and to manually allocate/deallocate
the FoldingSets.

Moreover removing the extra indirections reduce the run-time of
an fsyntax-only on all of Boost by 2.3% which is not totally
unexpected given how frequently this data structure is used
(especially for C++).

A concern raised by erichkeane during the review was that
including Type.h would increase the compile time unreasonably.
However test builds (both clean and incremental) showed that
this patch did not result in any compile time increase.

Reviewed By: erichkeane

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

Modified:
cfe/trunk/include/clang/AST/DeclarationName.h
cfe/trunk/lib/AST/DeclarationName.cpp

Modified: cfe/trunk/include/clang/AST/DeclarationName.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclarationName.h?rev=339030&r1=339029&r2=339030&view=diff
==
--- cfe/trunk/include/clang/AST/DeclarationName.h (original)
+++ cfe/trunk/include/clang/AST/DeclarationName.h Mon Aug  6 09:47:31 2018
@@ -14,11 +14,13 @@
 #ifndef LLVM_CLANG_AST_DECLARATIONNAME_H
 #define LLVM_CLANG_AST_DECLARATIONNAME_H
 
+#include "clang/AST/Type.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/IdentifierTable.h"
 #include "clang/Basic/PartialDiagnostic.h"
 #include "clang/Basic/SourceLocation.h"
 #include "llvm/ADT/DenseMapInfo.h"
+#include "llvm/ADT/FoldingSet.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/type_traits.h"
 #include 
@@ -39,9 +41,7 @@ class IdentifierInfo;
 class MultiKeywordSelector;
 enum OverloadedOperatorKind : int;
 struct PrintingPolicy;
-class QualType;
 class TemplateDecl;
-class Type;
 class TypeSourceInfo;
 class UsingDirectiveDecl;
 
@@ -343,33 +343,113 @@ inline bool operator>=(DeclarationName L
   return DeclarationName::compare(LHS, RHS) >= 0;
 }
 
+/// CXXSpecialName - Records the type associated with one of the
+/// "special" kinds of declaration names in C++, e.g., constructors,
+/// destructors, and conversion functions.
+class CXXSpecialName : public DeclarationNameExtra,
+   public llvm::FoldingSetNode {
+public:
+  /// Type - The type associated with this declaration name.
+  QualType Type;
+
+  /// FETokenInfo - Extra information associated with this declaration
+  /// name that can be used by the front end. All bits are really needed
+  /// so it is not possible to stash something in the low order bits.
+  void *FETokenInfo;
+
+  void Profile(llvm::FoldingSetNodeID &ID) {
+ID.AddInteger(ExtraKindOrNumArgs);
+ID.AddPointer(Type.getAsOpaquePtr());
+  }
+};
+
+/// Contains extra information for the name of a C++ deduction guide.
+class CXXDeductionGuideNameExtra : public DeclarationNameExtra,
+   public llvm::FoldingSetNode {
+public:
+  /// The template named by the deduction guide.
+  TemplateDecl *Template;
+
+  /// FETokenInfo - Extra information associated with this operator
+  /// name that can be used by the front end. All bits are really needed
+  /// so it is not possible to stash something in the low order bits.
+  void *FETokenInfo;
+
+  void Profile(llvm::FoldingSetNodeID &ID) { ID.AddPointer(Template); }
+};
+
+/// CXXOperatorIdName - Contains extra information for the name of an
+/// overloaded operator in C++, such as "operator+.
+class CXXOperatorIdName : public DeclarationNameExtra {
+public:
+  /// FETokenInfo - Extra information associated with this operator
+  /// name that can be used by the front end. All bits are really needed
+  /// so it is not possible to stash something in the low order bits.
+  void *FETokenInfo;
+};
+
+/// CXXLiteralOperatorName - Contains the actual identifier that makes up the
+/// name.
+///
+/// This identifier is stored here rather than directly in DeclarationName so 
as
+/// to allow Objective-C selectors, which are about a million times more 
common,
+/// to consume minimal memory.
+class CXXLiteralOperatorIdName : public DeclarationNameExtra,
+ public llvm::FoldingSetNode {
+public:
+  IdentifierInfo *ID;
+
+  /// FETokenInfo - E

[PATCH] D50261: [AST] Remove unnecessary indirections in DeclarationNameTable

2018-08-06 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL339030: [AST] Remove unnecessary indirections in 
DeclarationNameTable (authored by brunoricci, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D50261?vs=159044&id=159322#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50261

Files:
  cfe/trunk/include/clang/AST/DeclarationName.h
  cfe/trunk/lib/AST/DeclarationName.cpp

Index: cfe/trunk/lib/AST/DeclarationName.cpp
===
--- cfe/trunk/lib/AST/DeclarationName.cpp
+++ cfe/trunk/lib/AST/DeclarationName.cpp
@@ -39,74 +39,6 @@
 
 using namespace clang;
 
-namespace clang {
-
-/// CXXSpecialName - Records the type associated with one of the
-/// "special" kinds of declaration names in C++, e.g., constructors,
-/// destructors, and conversion functions.
-class CXXSpecialName
-  : public DeclarationNameExtra, public llvm::FoldingSetNode {
-public:
-  /// Type - The type associated with this declaration name.
-  QualType Type;
-
-  /// FETokenInfo - Extra information associated with this declaration
-  /// name that can be used by the front end.
-  void *FETokenInfo;
-
-  void Profile(llvm::FoldingSetNodeID &ID) {
-ID.AddInteger(ExtraKindOrNumArgs);
-ID.AddPointer(Type.getAsOpaquePtr());
-  }
-};
-
-/// Contains extra information for the name of a C++ deduction guide.
-class CXXDeductionGuideNameExtra : public DeclarationNameExtra,
-   public llvm::FoldingSetNode {
-public:
-  /// The template named by the deduction guide.
-  TemplateDecl *Template;
-
-  /// FETokenInfo - Extra information associated with this operator
-  /// name that can be used by the front end.
-  void *FETokenInfo;
-
-  void Profile(llvm::FoldingSetNodeID &ID) {
-ID.AddPointer(Template);
-  }
-};
-
-/// CXXOperatorIdName - Contains extra information for the name of an
-/// overloaded operator in C++, such as "operator+.
-class CXXOperatorIdName : public DeclarationNameExtra {
-public:
-  /// FETokenInfo - Extra information associated with this operator
-  /// name that can be used by the front end.
-  void *FETokenInfo;
-};
-
-/// CXXLiteralOperatorName - Contains the actual identifier that makes up the
-/// name.
-///
-/// This identifier is stored here rather than directly in DeclarationName so as
-/// to allow Objective-C selectors, which are about a million times more common,
-/// to consume minimal memory.
-class CXXLiteralOperatorIdName
-  : public DeclarationNameExtra, public llvm::FoldingSetNode {
-public:
-  IdentifierInfo *ID;
-
-  /// FETokenInfo - Extra information associated with this operator
-  /// name that can be used by the front end.
-  void *FETokenInfo;
-
-  void Profile(llvm::FoldingSetNodeID &FSID) {
-FSID.AddPointer(ID);
-  }
-};
-
-} // namespace clang
-
 static int compareInt(unsigned A, unsigned B) {
   return (A < B ? -1 : (A > B ? 1 : 0));
 }
@@ -436,10 +368,6 @@
 }
 
 DeclarationNameTable::DeclarationNameTable(const ASTContext &C) : Ctx(C) {
-  CXXSpecialNamesImpl = new llvm::FoldingSet;
-  CXXLiteralOperatorNames = new llvm::FoldingSet;
-  CXXDeductionGuideNames = new llvm::FoldingSet;
-
   // Initialize the overloaded operator names.
   CXXOperatorNames = new (Ctx) CXXOperatorIdName[NUM_OVERLOADED_OPERATORS];
   for (unsigned Op = 0; Op < NUM_OVERLOADED_OPERATORS; ++Op) {
@@ -449,21 +377,6 @@
   }
 }
 
-DeclarationNameTable::~DeclarationNameTable() {
-  auto *SpecialNames =
-  static_cast *>(CXXSpecialNamesImpl);
-  auto *LiteralNames =
-  static_cast *>(
-  CXXLiteralOperatorNames);
-  auto *DeductionGuideNames =
-  static_cast *>(
-  CXXDeductionGuideNames);
-
-  delete SpecialNames;
-  delete LiteralNames;
-  delete DeductionGuideNames;
-}
-
 DeclarationName DeclarationNameTable::getCXXConstructorName(CanQualType Ty) {
   return getCXXSpecialName(DeclarationName::CXXConstructorName,
Ty.getUnqualifiedType());
@@ -478,23 +391,19 @@
 DeclarationNameTable::getCXXDeductionGuideName(TemplateDecl *Template) {
   Template = cast(Template->getCanonicalDecl());
 
-  auto *DeductionGuideNames =
-  static_cast *>(
-  CXXDeductionGuideNames);
-
   llvm::FoldingSetNodeID ID;
   ID.AddPointer(Template);
 
   void *InsertPos = nullptr;
-  if (auto *Name = DeductionGuideNames->FindNodeOrInsertPos(ID, InsertPos))
+  if (auto *Name = CXXDeductionGuideNames.FindNodeOrInsertPos(ID, InsertPos))
 return DeclarationName(Name);
 
   auto *Name = new (Ctx) CXXDeductionGuideNameExtra;
   Name->ExtraKindOrNumArgs = DeclarationNameExtra::CXXDeductionGuide;
   Name->Template = Template;
   Name->FETokenInfo = nullptr;
 
-  DeductionGuideNames->InsertNode(Name, InsertPos);
+  CXXDeductionGuideNames.InsertNode(Name, InsertPos);
   return DeclarationName(Name);
 }
 
@@ -509,8 +418,6 @@
   assert(Kind >= DeclarationName::CXXConstructorName &&
  Kind

[PATCH] D41910: [Concepts] Constrained partial specializations and function overloads.

2018-08-06 Thread Saar Raz via Phabricator via cfe-commits
saar.raz updated this revision to Diff 159323.
saar.raz added a comment.
Herald added a subscriber: jfb.

Adjusted to switch to ASTTemplateArgumentListInfo


Repository:
  rC Clang

https://reviews.llvm.org/D41910

Files:
  include/clang/AST/DeclTemplate.h
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/AST/ASTContext.cpp
  lib/AST/DeclTemplate.cpp
  lib/Sema/SemaConcept.cpp
  lib/Sema/SemaTemplate.cpp
  lib/Sema/SemaTemplateDeduction.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriterDecl.cpp
  test/CXX/concepts-ts/temp/temp.constr/temp.constr.decl/func-template-decl.cpp
  test/CXX/concepts-ts/temp/temp.constr/temp.constr.normal/p1.cpp
  
test/CXX/concepts-ts/temp/temp.constr/temp.constr.order/class-template-partial-specializations.cpp
  test/CXX/concepts-ts/temp/temp.constr/temp.constr.order/function-templates.cpp
  
test/CXX/concepts-ts/temp/temp.constr/temp.constr.order/var-template-partial-specializations.cpp

Index: test/CXX/concepts-ts/temp/temp.constr/temp.constr.order/var-template-partial-specializations.cpp
===
--- /dev/null
+++ test/CXX/concepts-ts/temp/temp.constr/temp.constr.order/var-template-partial-specializations.cpp
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -std=c++2a -fconcepts-ts -x c++ -verify %s
+
+template requires sizeof(T) >= 4
+bool a = false; // expected-note{{template is declared here}}
+
+template requires sizeof(T) >= 4 && sizeof(T) <= 10
+bool a = true; // expected-error{{variable template partial specialization is not more specialized than the primary template}}
+
+template
+concept C1 = sizeof(T) >= 4;
+
+template requires C1
+bool b = false;
+
+template requires C1 && sizeof(T) <= 10
+bool b = true;
+
+template
+concept C2 = sizeof(T) > 1 && sizeof(T) <= 8;
+
+template
+bool c = false;
+
+template requires C1
+bool c = true;
+
+template
+bool d = false;
+
+template
+bool d = true; // expected-error{{variable template partial specialization does not specialize any template argument; to define the primary template, remove the template argument list}}
+
+template requires C1
+bool e = false;
+
+template
+bool e = true; // expected-error{{variable template partial specialization does not specialize any template argument; to define the primary template, remove the template argument list}}
+
+template
+constexpr int f = 1;
+
+template requires C1 && C2
+constexpr int f = 2;
+
+template requires C1 || C2
+constexpr int f = 3;
+
+static_assert(f == 2);
+static_assert(f == 3);
+static_assert(f == 1);
+
+
+
Index: test/CXX/concepts-ts/temp/temp.constr/temp.constr.order/function-templates.cpp
===
--- /dev/null
+++ test/CXX/concepts-ts/temp/temp.constr/temp.constr.order/function-templates.cpp
@@ -0,0 +1,54 @@
+// RUN: %clang_cc1 -std=c++2a -fconcepts-ts -x c++ -verify %s
+
+template requires sizeof(T) >= 4
+bool a() { return false; } // expected-note {{candidate function [with T = unsigned int]}}
+
+template requires sizeof(T) >= 4 && sizeof(T) <= 10
+bool a() { return true; } // expected-note {{candidate function [with T = unsigned int]}}
+
+bool av = a(); // expected-error {{call to 'a' is ambiguous}}
+
+template
+concept C1 = sizeof(T) >= 4;
+
+template requires C1
+constexpr bool b() { return false; }
+
+template requires C1 && sizeof(T) <= 10
+constexpr bool b() { return true; }
+
+static_assert(b());
+static_assert(!b());
+
+template
+concept C2 = sizeof(T) > 1 && sizeof(T) <= 8;
+
+template
+bool c() { return false; }
+
+template requires C1
+bool c() { return true; }
+
+template requires C1
+constexpr bool d() { return false; }
+
+template
+constexpr bool d() { return true; }
+
+static_assert(!d());
+
+template
+constexpr int e() { return 1; }
+
+template requires C1 && C2
+constexpr int e() { return 2; }
+
+template requires C1 || C2
+constexpr int e() { return 3; }
+
+static_assert(e() == 2);
+static_assert(e() == 3);
+static_assert(e() == 1);
+
+
+
Index: test/CXX/concepts-ts/temp/temp.constr/temp.constr.order/class-template-partial-specializations.cpp
===
--- /dev/null
+++ test/CXX/concepts-ts/temp/temp.constr/temp.constr.order/class-template-partial-specializations.cpp
@@ -0,0 +1,84 @@
+// RUN: %clang_cc1 -std=c++2a -fconcepts-ts -x c++ -verify %s
+
+template requires sizeof(T) >= 4
+class A{}; // expected-note{{template is declared here}}
+
+template requires sizeof(T) >= 4 && sizeof(T) <= 10
+class A{}; // expected-error{{class template partial specialization is not more specialized than the primary template}}
+
+template
+concept C1 = sizeof(T) >= 4;
+
+template requires C1
+class B{};
+
+template requires C1 && sizeof(T) <= 10
+class B{};
+
+template
+concept C2 = sizeof(T) > 1 && sizeof(T) <= 8;
+
+template
+class C{};
+
+template requires C1
+class C{};
+
+template
+class D{}; // expected-n

Re: r338899 - [OpenCL] Always emit alloca in entry block for enqueue_kernel builtin

2018-08-06 Thread Vlad Tsyrklevich via cfe-commits
Have you tried setting detect_stack_use_after_return in ASAN_OPTIONS? The
ASan buildbot sets the following ASAN_OPTIONS prior to running tests:
export
ASAN_OPTIONS="check_initialization_order=true:detect_stack_use_after_return=1:detect_leaks=1"

On Mon, Aug 6, 2018 at 7:34 AM  wrote:

> I can't seem to reproduce the ASan failure locally, even after building
> a clang with the latest compiler-rt, and then rebuilding my patch with
> LLVM_USE_SANITIZER=Address
>
> I am pretty confident the problem should be fixed with a one-line change
> to my patch:
>
> -auto CreateArrayForSizeVar = [=](unsigned First) {
> +auto CreateArrayForSizeVar = [=](unsigned First)
> +-> std::tuple {
>
> I don't want to commit something and then immediately have to revert,
> though. Can you think of anything I might be missing locally to
> reproduce the ASan failure?
>
> Thanks,
> Scott
>
> On 2018-08-03 13:48, Vlad Tsyrklevich wrote:
> > This change is causing ASan failures on the sanitizer bots:
> >
> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/21898/steps/check-clang%20asan/logs/stdio
> > [9]
> >
> > I've reverted it in r338904.
> >
> > On Fri, Aug 3, 2018 at 8:51 AM Scott Linder via cfe-commits
> >  wrote:
> >
> >> Author: scott.linder
> >> Date: Fri Aug 3 08:50:52 2018
> >> New Revision: 338899
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=338899&view=rev [1]
> >> Log:
> >> [OpenCL] Always emit alloca in entry block for enqueue_kernel
> >> builtin
> >>
> >> Ensures the statically sized alloca is not converted to
> >> DYNAMIC_STACKALLOC
> >> later because it is not in the entry block.
> >>
> >> Differential Revision: https://reviews.llvm.org/D50104 [2]
> >>
> >> Added:
> >> cfe/trunk/test/CodeGenOpenCL/enqueue-kernel-non-entry-block.cl
> >> [3]
> >> Modified:
> >> cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> >> cfe/trunk/test/CodeGenOpenCL/cl20-device-side-enqueue.cl [4]
> >>
> >> Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> >> URL:
> >>
> >
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=338899&r1=338898&r2=338899&view=diff
> >> [5]
> >>
> >
> ==
> >> --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
> >> +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Fri Aug 3 08:50:52 2018
> >> @@ -3338,23 +3338,29 @@ RValue CodeGenFunction::EmitBuiltinExpr(
> >> // Create a temporary array to hold the sizes of local pointer
> >> arguments
> >> // for the block. \p First is the position of the first size
> >> argument.
> >> auto CreateArrayForSizeVar = [=](unsigned First) {
> >> - auto *AT = llvm::ArrayType::get(SizeTy, NumArgs - First);
> >> - auto *Arr = Builder.CreateAlloca(AT);
> >> - llvm::Value *Ptr;
> >> + llvm::APInt ArraySize(32, NumArgs - First);
> >> + QualType SizeArrayTy = getContext().getConstantArrayType(
> >> + getContext().getSizeType(), ArraySize, ArrayType::Normal,
> >> + /*IndexTypeQuals=*/0);
> >> + auto Tmp = CreateMemTemp(SizeArrayTy, "block_sizes");
> >> + llvm::Value *TmpPtr = Tmp.getPointer();
> >> + llvm::Value *TmpSize = EmitLifetimeStart(
> >> +
> >> CGM.getDataLayout().getTypeAllocSize(Tmp.getElementType()), TmpPtr);
> >> + llvm::Value *ElemPtr;
> >> // Each of the following arguments specifies the size of the
> >> corresponding
> >> // argument passed to the enqueued block.
> >> auto *Zero = llvm::ConstantInt::get(IntTy, 0);
> >> for (unsigned I = First; I < NumArgs; ++I) {
> >> auto *Index = llvm::ConstantInt::get(IntTy, I - First);
> >> - auto *GEP = Builder.CreateGEP(Arr, {Zero, Index});
> >> + auto *GEP = Builder.CreateGEP(TmpPtr, {Zero, Index});
> >> if (I == First)
> >> - Ptr = GEP;
> >> + ElemPtr = GEP;
> >> auto *V =
> >> Builder.CreateZExtOrTrunc(EmitScalarExpr(E->getArg(I)),
> >> SizeTy);
> >> Builder.CreateAlignedStore(
> >> V, GEP,
> >> CGM.getDataLayout().getPrefTypeAlignment(SizeTy));
> >> }
> >> - return Ptr;
> >> + return std::tie(ElemPtr, TmpSize, TmpPtr);
> >> };
> >>
> >> // Could have events and/or varargs.
> >> @@ -3366,24 +3372,27 @@ RValue CodeGenFunction::EmitBuiltinExpr(
> >> llvm::Value *Kernel =
> >> Builder.CreatePointerCast(Info.Kernel, GenericVoidPtrTy);
> >> auto *Block = Builder.CreatePointerCast(Info.BlockArg,
> >> GenericVoidPtrTy);
> >> - auto *PtrToSizeArray = CreateArrayForSizeVar(4);
> >> + llvm::Value *ElemPtr, *TmpSize, *TmpPtr;
> >> + std::tie(ElemPtr, TmpSize, TmpPtr) =
> >> CreateArrayForSizeVar(4);
> >>
> >> // Create a vector of the arguments, as well as a constant
> >> value to
> >> // express to the runtime the number of variadic arguments.
> >> std::vector Args = {
> >> Queue, Flags, Range,
> >> Kernel, Block, ConstantInt::get(IntTy, NumArgs - 4),
> >> - PtrToSizeArray};
> >> + ElemPtr};
> >> std::vector ArgTys = {
> >> - QueueTy, IntTy, RangeTy,
> >> - GenericVoidPtrTy, GenericVoidPtrTy, IntTy,
> >> - PtrToSizeArray->getType()};
> >> + QueueTy, IntTy, RangeTy,
> >> GenericVoidPtrTy,
> >> + GenericVoidPtrTy, IntTy, ElemPtr-

r339031 - [Fixed Point Arithmetic] Remove unused include.

2018-08-06 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Mon Aug  6 09:53:21 2018
New Revision: 339031

URL: http://llvm.org/viewvc/llvm-project?rev=339031&view=rev
Log:
[Fixed Point Arithmetic] Remove unused include.

lib/Basic cannot depend on lib/AST.

Modified:
cfe/trunk/lib/Basic/FixedPoint.cpp

Modified: cfe/trunk/lib/Basic/FixedPoint.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FixedPoint.cpp?rev=339031&r1=339030&r2=339031&view=diff
==
--- cfe/trunk/lib/Basic/FixedPoint.cpp (original)
+++ cfe/trunk/lib/Basic/FixedPoint.cpp Mon Aug  6 09:53:21 2018
@@ -12,7 +12,6 @@
 //
 
//===--===//
 
-#include "clang/AST/ASTContext.h"
 #include "clang/Basic/FixedPoint.h"
 
 namespace clang {


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


[PATCH] D48661: [Fixed Point Arithmetic] Fixed Point Constant

2018-08-06 Thread Bruno Ricci via Phabricator via cfe-commits
bricci added a comment.

Just a nit but could you please add new-lines to your commit messages.
Also the 3 bools in FixedPointSemantics are a little bit wasteful.


Repository:
  rL LLVM

https://reviews.llvm.org/D48661



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


[PATCH] D49438: [analyzer][UninitializedObjectChecker] New flag to turn off dereferencing

2018-08-06 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov accepted this revision.
george.karpenkov added a comment.
This revision is now accepted and ready to land.

Great, thanks a lot!


https://reviews.llvm.org/D49438



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


[PATCH] D48661: [Fixed Point Arithmetic] Fixed Point Constant

2018-08-06 Thread Bruno Ricci via Phabricator via cfe-commits
bricci added a comment.

And using the name Sema is a bad idea IMHO since this has a totally different 
meaning in clang.


Repository:
  rL LLVM

https://reviews.llvm.org/D48661



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


[PATCH] D48661: [Fixed Point Arithmetic] Fixed Point Constant

2018-08-06 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

In https://reviews.llvm.org/D48661#1189537, @bricci wrote:

> Just a nit but could you please add new-lines to your commit messages.


My bad, will remember this for future commits.

> Also the 3 bools in FixedPointSemantics are a little bit wasteful.
>  I don't know here if it matter but I have been spending the last weeks
>  cleaning up this kind of thing and this already cut the time of an 
> fsyntax-only
>  by ~3.5%.

Would you recommend something along the lines of having a bitmask instead of 3 
bools? What should I keep in mind to avoid making fsyntax-only longer?

> And using the name Sema is a bad idea IMHO since this has a totally different 
> meaning in clang.

I'll make another small patch where I rename this.


Repository:
  rL LLVM

https://reviews.llvm.org/D48661



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


[PATCH] D37302: [Headers] Define *_HAS_SUBNORM for FLT, DBL, LDBL

2018-08-06 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama updated this revision to Diff 159330.
pirama added a comment.

Rebase


Repository:
  rC Clang

https://reviews.llvm.org/D37302

Files:
  lib/Headers/float.h
  test/Headers/float.c


Index: test/Headers/float.c
===
--- test/Headers/float.c
+++ test/Headers/float.c
@@ -61,6 +61,21 @@
 #if ((FLT_DECIMAL_DIG > DBL_DECIMAL_DIG) || (DBL_DECIMAL_DIG > 
LDBL_DECIMAL_DIG))
 #error "Mandatory macros {FLT,DBL,LDBL}_DECIMAL_DIG are invalid."
 #endif
+#ifndef FLT_HAS_SUBNORM
+#error "Mandatory macro FLT_HAS_SUBNORM is missing."
+#elif FLT_HAS_SUBNORM != __FLT_HAS_DENORM__
+#error "Mandatory macro FLT_HAS_SUBNORM is invalid."
+#endif
+#ifndef LDBL_HAS_SUBNORM
+#error "Mandatory macro LDBL_HAS_SUBNORM is missing."
+#elif LDBL_HAS_SUBNORM != __LDBL_HAS_DENORM__
+#error "Mandatory macro LDBL_HAS_SUBNORM is invalid."
+#endif
+#ifndef DBL_HAS_SUBNORM
+#error "Mandatory macro DBL_HAS_SUBNORM is missing."
+#elif DBL_HAS_SUBNORM != __DBL_HAS_DENORM__
+#error "Mandatory macro DBL_HAS_SUBNORM is invalid."
+#endif
 #else
 #ifdef FLT_DECIMAL_DIG
 #error "Macro FLT_DECIMAL_DIG should not be defined."
@@ -71,6 +86,15 @@
 #ifdef LDBL_DECIMAL_DIG
 #error "Macro LDBL_DECIMAL_DIG should not be defined."
 #endif
+#ifdef FLT_HAS_SUBNORM
+#error "Macro FLT_HAS_SUBNORM should not be defined."
+#endif
+#ifdef DBL_HAS_SUBNORM
+#error "Macro DBL_HAS_SUBNORM should not be defined."
+#endif
+#ifdef LDBL_HAS_SUBNORM
+#error "Macro LDBL_HAS_SUBNORM should not be defined."
+#endif
 #endif
 
 
Index: lib/Headers/float.h
===
--- lib/Headers/float.h
+++ lib/Headers/float.h
@@ -85,6 +85,9 @@
 #undef FLT_DECIMAL_DIG
 #undef DBL_DECIMAL_DIG
 #undef LDBL_DECIMAL_DIG
+#undef FLT_HAS_SUBNORM
+#undef DBL_HAS_SUBNORM
+#undef LDBL_HAS_SUBNORM
 #  endif
 #endif
 
@@ -141,6 +144,9 @@
 #  define FLT_DECIMAL_DIG __FLT_DECIMAL_DIG__
 #  define DBL_DECIMAL_DIG __DBL_DECIMAL_DIG__
 #  define LDBL_DECIMAL_DIG __LDBL_DECIMAL_DIG__
+#  define FLT_HAS_SUBNORM __FLT_HAS_DENORM__
+#  define DBL_HAS_SUBNORM __DBL_HAS_DENORM__
+#  define LDBL_HAS_SUBNORM __LDBL_HAS_DENORM__
 #endif
 
 #ifdef __STDC_WANT_IEC_60559_TYPES_EXT__


Index: test/Headers/float.c
===
--- test/Headers/float.c
+++ test/Headers/float.c
@@ -61,6 +61,21 @@
 #if ((FLT_DECIMAL_DIG > DBL_DECIMAL_DIG) || (DBL_DECIMAL_DIG > LDBL_DECIMAL_DIG))
 #error "Mandatory macros {FLT,DBL,LDBL}_DECIMAL_DIG are invalid."
 #endif
+#ifndef FLT_HAS_SUBNORM
+#error "Mandatory macro FLT_HAS_SUBNORM is missing."
+#elif FLT_HAS_SUBNORM != __FLT_HAS_DENORM__
+#error "Mandatory macro FLT_HAS_SUBNORM is invalid."
+#endif
+#ifndef LDBL_HAS_SUBNORM
+#error "Mandatory macro LDBL_HAS_SUBNORM is missing."
+#elif LDBL_HAS_SUBNORM != __LDBL_HAS_DENORM__
+#error "Mandatory macro LDBL_HAS_SUBNORM is invalid."
+#endif
+#ifndef DBL_HAS_SUBNORM
+#error "Mandatory macro DBL_HAS_SUBNORM is missing."
+#elif DBL_HAS_SUBNORM != __DBL_HAS_DENORM__
+#error "Mandatory macro DBL_HAS_SUBNORM is invalid."
+#endif
 #else
 #ifdef FLT_DECIMAL_DIG
 #error "Macro FLT_DECIMAL_DIG should not be defined."
@@ -71,6 +86,15 @@
 #ifdef LDBL_DECIMAL_DIG
 #error "Macro LDBL_DECIMAL_DIG should not be defined."
 #endif
+#ifdef FLT_HAS_SUBNORM
+#error "Macro FLT_HAS_SUBNORM should not be defined."
+#endif
+#ifdef DBL_HAS_SUBNORM
+#error "Macro DBL_HAS_SUBNORM should not be defined."
+#endif
+#ifdef LDBL_HAS_SUBNORM
+#error "Macro LDBL_HAS_SUBNORM should not be defined."
+#endif
 #endif
 
 
Index: lib/Headers/float.h
===
--- lib/Headers/float.h
+++ lib/Headers/float.h
@@ -85,6 +85,9 @@
 #undef FLT_DECIMAL_DIG
 #undef DBL_DECIMAL_DIG
 #undef LDBL_DECIMAL_DIG
+#undef FLT_HAS_SUBNORM
+#undef DBL_HAS_SUBNORM
+#undef LDBL_HAS_SUBNORM
 #  endif
 #endif
 
@@ -141,6 +144,9 @@
 #  define FLT_DECIMAL_DIG __FLT_DECIMAL_DIG__
 #  define DBL_DECIMAL_DIG __DBL_DECIMAL_DIG__
 #  define LDBL_DECIMAL_DIG __LDBL_DECIMAL_DIG__
+#  define FLT_HAS_SUBNORM __FLT_HAS_DENORM__
+#  define DBL_HAS_SUBNORM __DBL_HAS_DENORM__
+#  define LDBL_HAS_SUBNORM __LDBL_HAS_DENORM__
 #endif
 
 #ifdef __STDC_WANT_IEC_60559_TYPES_EXT__
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D37302: [Headers] Define *_HAS_SUBNORM for FLT, DBL, LDBL

2018-08-06 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama added a comment.

Sorry this fell of my radar.  I've rebased the patch.

Since this has been inactive for a while, lets wait for a couple of days to see 
if there are any other comments.  If there are no objections, I'll submit this 
on Wednesday.


Repository:
  rC Clang

https://reviews.llvm.org/D37302



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


[PATCH] D37302: [Headers] Define *_HAS_SUBNORM for FLT, DBL, LDBL

2018-08-06 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

In https://reviews.llvm.org/D37302#1189576, @pirama wrote:

> Sorry this fell of my radar.  I've rebased the patch.
>
> Since this has been inactive for a while, lets wait for a couple of days to 
> see if there are any other comments.  If there are no objections, I'll submit 
> this on Wednesday.


Ok. FWIW, I was about to submit exactly the same patch when I found yours. This 
solves a problem for me.


Repository:
  rC Clang

https://reviews.llvm.org/D37302



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


[PATCH] D49223: [AST] Check described template at structural equivalence check.

2018-08-06 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin accepted this revision.
a.sidorin added a comment.

Hi Balazs,
I have only two nits. Otherwise, the patch is OK and can be committed without 
additional approval after the comments are fixed. Thank you!




Comment at: lib/AST/ASTStructuralEquivalence.cpp:1500
 
+bool StructuralEquivalenceContext::CommonCheckAtFinish(Decl *D1, Decl *D2) {
+  // Check for equivalent described template.

CheckCommonEquivalence/CheckKindSpecificEquivalence?



Comment at: lib/AST/ASTStructuralEquivalence.cpp:1643
 
 bool Equivalent = true;
 

`Equivalent = CommonCheckAtFinish(D1, D2) && SpecialCheckAtFinish(D1, D2))`?


Repository:
  rC Clang

https://reviews.llvm.org/D49223



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


[PATCH] D41910: [Concepts] Constrained partial specializations and function overloads.

2018-08-06 Thread Saar Raz via Phabricator via cfe-commits
saar.raz updated this revision to Diff 159331.
saar.raz added a comment.

- Fix bad handling of checking of deduced arguments in function templates


Repository:
  rC Clang

https://reviews.llvm.org/D41910

Files:
  include/clang/AST/DeclTemplate.h
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/AST/ASTContext.cpp
  lib/AST/DeclTemplate.cpp
  lib/Sema/SemaConcept.cpp
  lib/Sema/SemaTemplate.cpp
  lib/Sema/SemaTemplateDeduction.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriterDecl.cpp
  test/CXX/concepts-ts/temp/temp.constr/temp.constr.decl/func-template-decl.cpp
  test/CXX/concepts-ts/temp/temp.constr/temp.constr.normal/p1.cpp
  
test/CXX/concepts-ts/temp/temp.constr/temp.constr.order/class-template-partial-specializations.cpp
  test/CXX/concepts-ts/temp/temp.constr/temp.constr.order/function-templates.cpp
  
test/CXX/concepts-ts/temp/temp.constr/temp.constr.order/var-template-partial-specializations.cpp

Index: test/CXX/concepts-ts/temp/temp.constr/temp.constr.order/var-template-partial-specializations.cpp
===
--- /dev/null
+++ test/CXX/concepts-ts/temp/temp.constr/temp.constr.order/var-template-partial-specializations.cpp
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -std=c++2a -fconcepts-ts -x c++ -verify %s
+
+template requires sizeof(T) >= 4
+bool a = false; // expected-note{{template is declared here}}
+
+template requires sizeof(T) >= 4 && sizeof(T) <= 10
+bool a = true; // expected-error{{variable template partial specialization is not more specialized than the primary template}}
+
+template
+concept C1 = sizeof(T) >= 4;
+
+template requires C1
+bool b = false;
+
+template requires C1 && sizeof(T) <= 10
+bool b = true;
+
+template
+concept C2 = sizeof(T) > 1 && sizeof(T) <= 8;
+
+template
+bool c = false;
+
+template requires C1
+bool c = true;
+
+template
+bool d = false;
+
+template
+bool d = true; // expected-error{{variable template partial specialization does not specialize any template argument; to define the primary template, remove the template argument list}}
+
+template requires C1
+bool e = false;
+
+template
+bool e = true; // expected-error{{variable template partial specialization does not specialize any template argument; to define the primary template, remove the template argument list}}
+
+template
+constexpr int f = 1;
+
+template requires C1 && C2
+constexpr int f = 2;
+
+template requires C1 || C2
+constexpr int f = 3;
+
+static_assert(f == 2);
+static_assert(f == 3);
+static_assert(f == 1);
+
+
+
Index: test/CXX/concepts-ts/temp/temp.constr/temp.constr.order/function-templates.cpp
===
--- /dev/null
+++ test/CXX/concepts-ts/temp/temp.constr/temp.constr.order/function-templates.cpp
@@ -0,0 +1,54 @@
+// RUN: %clang_cc1 -std=c++2a -fconcepts-ts -x c++ -verify %s
+
+template requires sizeof(T) >= 4
+bool a() { return false; } // expected-note {{candidate function [with T = unsigned int]}}
+
+template requires sizeof(T) >= 4 && sizeof(T) <= 10
+bool a() { return true; } // expected-note {{candidate function [with T = unsigned int]}}
+
+bool av = a(); // expected-error {{call to 'a' is ambiguous}}
+
+template
+concept C1 = sizeof(T) >= 4;
+
+template requires C1
+constexpr bool b() { return false; }
+
+template requires C1 && sizeof(T) <= 10
+constexpr bool b() { return true; }
+
+static_assert(b());
+static_assert(!b());
+
+template
+concept C2 = sizeof(T) > 1 && sizeof(T) <= 8;
+
+template
+bool c() { return false; }
+
+template requires C1
+bool c() { return true; }
+
+template requires C1
+constexpr bool d() { return false; }
+
+template
+constexpr bool d() { return true; }
+
+static_assert(!d());
+
+template
+constexpr int e() { return 1; }
+
+template requires C1 && C2
+constexpr int e() { return 2; }
+
+template requires C1 || C2
+constexpr int e() { return 3; }
+
+static_assert(e() == 2);
+static_assert(e() == 3);
+static_assert(e() == 1);
+
+
+
Index: test/CXX/concepts-ts/temp/temp.constr/temp.constr.order/class-template-partial-specializations.cpp
===
--- /dev/null
+++ test/CXX/concepts-ts/temp/temp.constr/temp.constr.order/class-template-partial-specializations.cpp
@@ -0,0 +1,84 @@
+// RUN: %clang_cc1 -std=c++2a -fconcepts-ts -x c++ -verify %s
+
+template requires sizeof(T) >= 4
+class A{}; // expected-note{{template is declared here}}
+
+template requires sizeof(T) >= 4 && sizeof(T) <= 10
+class A{}; // expected-error{{class template partial specialization is not more specialized than the primary template}}
+
+template
+concept C1 = sizeof(T) >= 4;
+
+template requires C1
+class B{};
+
+template requires C1 && sizeof(T) <= 10
+class B{};
+
+template
+concept C2 = sizeof(T) > 1 && sizeof(T) <= 8;
+
+template
+class C{};
+
+template requires C1
+class C{};
+
+template
+class D{}; // expected-note{{pre

[PATCH] D50341: [libcxx] Mark aligned allocation tests as XFAIL on old OSX versions

2018-08-06 Thread Louis Dionne via Phabricator via cfe-commits
ldionne created this revision.
ldionne added a reviewer: vsapsai.
Herald added a reviewer: EricWF.
Herald added subscribers: cfe-commits, dexonsmith, christof.

Since r338934, Clang emits an error when aligned allocation functions are
used in conjunction with a system libc++ dylib that does not support those
functions. This causes some tests to fail when testing against older libc++
dylibs. This commit marks those tests as XFAIL.


Repository:
  rCXX libc++

https://reviews.llvm.org/D50341

Files:
  
libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_size_align.fail.cpp
  
libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_size_align_nothrow.fail.cpp
  
libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_size_align.fail.cpp
  
libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_size_align_nothrow.fail.cpp


Index: 
libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_size_align_nothrow.fail.cpp
===
--- 
libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_size_align_nothrow.fail.cpp
+++ 
libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_size_align_nothrow.fail.cpp
@@ -14,6 +14,12 @@
 
 // UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
 // UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, 
clang-3.8
+// XFAIL: with_system_cxx_lib=macosx10.12
+// XFAIL: with_system_cxx_lib=macosx10.11
+// XFAIL: with_system_cxx_lib=macosx10.10
+// XFAIL: with_system_cxx_lib=macosx10.9
+// XFAIL: with_system_cxx_lib=macosx10.8
+// XFAIL: with_system_cxx_lib=macosx10.7
 
 #include 
 
Index: 
libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_size_align.fail.cpp
===
--- 
libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_size_align.fail.cpp
+++ 
libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_size_align.fail.cpp
@@ -14,6 +14,12 @@
 
 // UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
 // UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, 
clang-3.8
+// XFAIL: with_system_cxx_lib=macosx10.12
+// XFAIL: with_system_cxx_lib=macosx10.11
+// XFAIL: with_system_cxx_lib=macosx10.10
+// XFAIL: with_system_cxx_lib=macosx10.9
+// XFAIL: with_system_cxx_lib=macosx10.8
+// XFAIL: with_system_cxx_lib=macosx10.7
 
 #include 
 
Index: 
libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_size_align_nothrow.fail.cpp
===
--- 
libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_size_align_nothrow.fail.cpp
+++ 
libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_size_align_nothrow.fail.cpp
@@ -14,6 +14,12 @@
 
 // UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
 // UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, 
clang-3.8
+// XFAIL: with_system_cxx_lib=macosx10.12
+// XFAIL: with_system_cxx_lib=macosx10.11
+// XFAIL: with_system_cxx_lib=macosx10.10
+// XFAIL: with_system_cxx_lib=macosx10.9
+// XFAIL: with_system_cxx_lib=macosx10.8
+// XFAIL: with_system_cxx_lib=macosx10.7
 
 #include 
 
Index: 
libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_size_align.fail.cpp
===
--- 
libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_size_align.fail.cpp
+++ 
libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_size_align.fail.cpp
@@ -14,6 +14,12 @@
 
 // UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
 // UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, 
clang-3.8
+// XFAIL: with_system_cxx_lib=macosx10.12
+// XFAIL: with_system_cxx_lib=macosx10.11
+// XFAIL: with_system_cxx_lib=macosx10.10
+// XFAIL: with_system_cxx_lib=macosx10.9
+// XFAIL: with_system_cxx_lib=macosx10.8
+// XFAIL: with_system_cxx_lib=macosx10.7
 
 #include 
 


Index: libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_size_align_nothrow.fail.cpp
===
--- libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_size_align_nothrow.fail.cpp
+++ libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_size_align_nothrow.fail.cpp
@@ -14,6 +14,12 @@
 
 // UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
 // UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, clang-3.8
+// XFAIL: with_system_cxx_lib=macosx10.12
+// XFAIL: with_system_cxx_lib=macosx10.11
+// XFAIL: with_system_cxx_lib=macosx10.10
+// XFAIL: with_system_cxx_lib=macosx10.9
+// XFAIL:

r339036 - Force test/Driver/fuchsia.c(pp) to use lld

2018-08-06 Thread David Greene via cfe-commits
Author: greened
Date: Mon Aug  6 10:35:44 2018
New Revision: 339036

URL: http://llvm.org/viewvc/llvm-project?rev=339036&view=rev
Log:
Force test/Driver/fuchsia.c(pp) to use lld

The Fuchsia driver relies on lld so invoke clang with
-fuse-ld=lld. This gets the test passing when the clang default linker
is something other than lld.

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


Modified:
cfe/trunk/test/Driver/fuchsia.c
cfe/trunk/test/Driver/fuchsia.cpp

Modified: cfe/trunk/test/Driver/fuchsia.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fuchsia.c?rev=339036&r1=339035&r2=339036&view=diff
==
--- cfe/trunk/test/Driver/fuchsia.c (original)
+++ cfe/trunk/test/Driver/fuchsia.c Mon Aug  6 10:35:44 2018
@@ -1,10 +1,10 @@
 // RUN: %clang %s -### -no-canonical-prefixes --target=x86_64-fuchsia \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
-// RUN: --sysroot=%S/platform 2>&1 \
+// RUN: --sysroot=%S/platform -fuse-ld=lld 2>&1 \
 // RUN: | FileCheck -check-prefixes=CHECK,CHECK-X86_64 %s
 // RUN: %clang %s -### -no-canonical-prefixes --target=aarch64-fuchsia \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
-// RUN: --sysroot=%S/platform 2>&1 \
+// RUN: --sysroot=%S/platform -fuse-ld=lld 2>&1 \
 // RUN: | FileCheck -check-prefixes=CHECK,CHECK-AARCH64 %s
 // CHECK: {{.*}}clang{{.*}}" "-cc1"
 // CHECK: "--mrelax-relocations"
@@ -31,22 +31,22 @@
 // CHECK-NOT: crtend.o
 // CHECK-NOT: crtn.o
 
-// RUN: %clang %s -### --target=x86_64-fuchsia -rtlib=libgcc 2>&1 \
+// RUN: %clang %s -### --target=x86_64-fuchsia -rtlib=libgcc -fuse-ld=lld 2>&1 
\
 // RUN: | FileCheck %s -check-prefix=CHECK-RTLIB
 // CHECK-RTLIB: error: invalid runtime library name in argument '-rtlib=libgcc'
 
-// RUN: %clang %s -### --target=x86_64-fuchsia -static 2>&1 \
+// RUN: %clang %s -### --target=x86_64-fuchsia -static -fuse-ld=lld 2>&1 \
 // RUN: | FileCheck %s -check-prefix=CHECK-STATIC
 // CHECK-STATIC: "-Bstatic"
 // CHECK-STATIC: "-Bdynamic"
 // CHECK-STATIC: "-lc"
 
-// RUN: %clang %s -### --target=x86_64-fuchsia -shared 2>&1 \
+// RUN: %clang %s -### --target=x86_64-fuchsia -shared -fuse-ld=lld 2>&1 \
 // RUN: | FileCheck %s -check-prefix=CHECK-SHARED
 // CHECK-SHARED-NOT: "-pie"
 // CHECK-SHARED: "-shared"
 
-// RUN: %clang %s -### --target=x86_64-fuchsia -r 2>&1 \
+// RUN: %clang %s -### --target=x86_64-fuchsia -r -fuse-ld=lld 2>&1 \
 // RUN: | FileCheck %s -check-prefix=CHECK-RELOCATABLE
 // CHECK-RELOCATABLE-NOT: "-pie"
 // CHECK-RELOCATABLE-NOT: "--build-id"
@@ -55,6 +55,7 @@
 // RUN: %clang %s -### --target=x86_64-fuchsia \
 // RUN: -fsanitize=safe-stack 2>&1 \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
+// RUN: -fuse-ld=lld \
 // RUN: | FileCheck %s -check-prefix=CHECK-SAFESTACK
 // CHECK-SAFESTACK: "-fsanitize=safe-stack"
 // CHECK-SAFESTACK-NOT: "{{.*[/\\]}}libclang_rt.safestack.a"
@@ -63,6 +64,7 @@
 // RUN: %clang %s -### --target=x86_64-fuchsia \
 // RUN: -fsanitize=address 2>&1 \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
+// RUN: -fuse-ld=lld \
 // RUN: | FileCheck %s -check-prefix=CHECK-ASAN-X86
 // CHECK-ASAN-X86: "-fsanitize=address"
 // CHECK-ASAN-X86: "-fsanitize-address-globals-dead-stripping"
@@ -73,6 +75,7 @@
 // RUN: %clang %s -### --target=aarch64-fuchsia \
 // RUN: -fsanitize=address 2>&1 \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
+// RUN: -fuse-ld=lld \
 // RUN: | FileCheck %s -check-prefix=CHECK-ASAN-AARCH64
 // CHECK-ASAN-AARCH64: "-fsanitize=address"
 // CHECK-ASAN-AARCH64: "-fsanitize-address-globals-dead-stripping"
@@ -83,6 +86,7 @@
 // RUN: %clang %s -### --target=x86_64-fuchsia \
 // RUN: -fsanitize=address -fPIC -shared 2>&1 \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
+// RUN: -fuse-ld=lld \
 // RUN: | FileCheck %s -check-prefix=CHECK-ASAN-SHARED
 // CHECK-ASAN-SHARED: "-fsanitize=address"
 // CHECK-ASAN-SHARED: "-fsanitize-address-globals-dead-stripping"
@@ -92,6 +96,7 @@
 // RUN: %clang %s -### --target=x86_64-fuchsia \
 // RUN: -fsanitize=fuzzer 2>&1 \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
+// RUN: -fuse-ld=lld \
 // RUN: | FileCheck %s -check-prefix=CHECK-FUZZER-X86
 // CHECK-FUZZER-X86: "-fsanitize=fuzzer,fuzzer-no-link,safe-stack"
 // CHECK-FUZZER-X86: "{{.*[/\\]}}libclang_rt.fuzzer.a"
@@ -99,6 +104,7 @@
 // RUN: %clang %s -### --target=aarch64-fuchsia \
 // RUN: -fsanitize=fuzzer 2>&1 \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
+// RUN: -fuse-ld=lld \
 // RUN: | FileCheck %s -check-prefix=CHECK-FUZZER-AARCH64
 // CHECK-FUZZER-AARCH64: "-fsanitize=fuzzer,fuzzer-no-link,safe-stack"
 // CHECK-FUZZER-AARCH64: "{{.*[/\\]}}libclang_rt.fu

[PATCH] D47849: [OpenMP][Clang][NVPTX] Enable math functions called in an OpenMP NVPTX target device region to be resolved as device-native function calls

2018-08-06 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 159335.
gtbercea added a comment.

  Fix function call.


Repository:
  rC Clang

https://reviews.llvm.org/D47849

Files:
  include/clang/Driver/ToolChain.h
  lib/Driver/ToolChains/Clang.cpp
  lib/Driver/ToolChains/Cuda.cpp
  lib/Driver/ToolChains/Cuda.h
  lib/Headers/CMakeLists.txt
  lib/Headers/__clang_cuda_device_functions.h
  lib/Headers/__clang_cuda_libdevice_declares.h
  test/CodeGen/nvptx_device_math_functions.c
  test/Driver/openmp-offload-gpu.c

Index: test/Driver/openmp-offload-gpu.c
===
--- test/Driver/openmp-offload-gpu.c
+++ test/Driver/openmp-offload-gpu.c
@@ -76,9 +76,9 @@
 // RUN:  -no-canonical-prefixes -save-temps %t.o -fopenmp-use-target-bundling 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-CUBIN-UNBUNDLING-NVLINK %s
 
-/// Use DAG to ensure that cubin file has been unbundled.
+/// Use DAG to ensure that object file has not been unbundled.
 // CHK-CUBIN-UNBUNDLING-NVLINK-DAG: nvlink{{.*}}" {{.*}}"[[CUBIN:.*\.cubin]]"
-// CHK-CUBIN-UNBUNDLING-NVLINK-DAG: clang-offload-bundler{{.*}}" "-type=o" {{.*}}"-outputs={{.*}}[[CUBIN]]
+// CHK-CUBIN-UNBUNDLING-NVLINK-DAG: clang-offload-bundler{{.*}}" "-type=o" {{.*}}[[CUBIN]]
 // CHK-CUBIN-UNBUNDLING-NVLINK-DAG-SAME: "-unbundle"
 
 /// ###
Index: test/CodeGen/nvptx_device_math_functions.c
===
--- /dev/null
+++ test/CodeGen/nvptx_device_math_functions.c
@@ -0,0 +1,20 @@
+// Test calling of device math functions.
+///==///
+
+// RUN: %clang -fmath-errno -S -emit-llvm -o - %s -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda | FileCheck -check-prefix CHECK-YES %s
+
+void test_sqrt(double a1) {
+  #pragma omp target
+  {
+// CHECK-YES: call double @llvm.nvvm.sqrt.rn.d(double
+double l1 = sqrt(a1);
+  }
+}
+
+void test_pow(float a0, double a1, long double a2) {
+  #pragma omp target
+  {
+// CHECK-YES: call double @__internal_accurate_pow(double
+double l1 = pow(a1, a1);
+  }
+}
Index: lib/Headers/__clang_cuda_libdevice_declares.h
===
--- lib/Headers/__clang_cuda_libdevice_declares.h
+++ lib/Headers/__clang_cuda_libdevice_declares.h
@@ -24,443 +24,455 @@
 #ifndef __CLANG_CUDA_LIBDEVICE_DECLARES_H__
 #define __CLANG_CUDA_LIBDEVICE_DECLARES_H__
 
+#if defined(_OPENMP)
+#define __DEVICE__
+#elif defined(__CUDA__)
+#define __DEVICE__ __device__
+#endif
+
+#if defined(__cplusplus)
 extern "C" {
+#endif
 
-__device__ int __nv_abs(int __a);
-__device__ double __nv_acos(double __a);
-__device__ float __nv_acosf(float __a);
-__device__ double __nv_acosh(double __a);
-__device__ float __nv_acoshf(float __a);
-__device__ double __nv_asin(double __a);
-__device__ float __nv_asinf(float __a);
-__device__ double __nv_asinh(double __a);
-__device__ float __nv_asinhf(float __a);
-__device__ double __nv_atan2(double __a, double __b);
-__device__ float __nv_atan2f(float __a, float __b);
-__device__ double __nv_atan(double __a);
-__device__ float __nv_atanf(float __a);
-__device__ double __nv_atanh(double __a);
-__device__ float __nv_atanhf(float __a);
-__device__ int __nv_brev(int __a);
-__device__ long long __nv_brevll(long long __a);
-__device__ int __nv_byte_perm(int __a, int __b, int __c);
-__device__ double __nv_cbrt(double __a);
-__device__ float __nv_cbrtf(float __a);
-__device__ double __nv_ceil(double __a);
-__device__ float __nv_ceilf(float __a);
-__device__ int __nv_clz(int __a);
-__device__ int __nv_clzll(long long __a);
-__device__ double __nv_copysign(double __a, double __b);
-__device__ float __nv_copysignf(float __a, float __b);
-__device__ double __nv_cos(double __a);
-__device__ float __nv_cosf(float __a);
-__device__ double __nv_cosh(double __a);
-__device__ float __nv_coshf(float __a);
-__device__ double __nv_cospi(double __a);
-__device__ float __nv_cospif(float __a);
-__device__ double __nv_cyl_bessel_i0(double __a);
-__device__ float __nv_cyl_bessel_i0f(float __a);
-__device__ double __nv_cyl_bessel_i1(double __a);
-__device__ float __nv_cyl_bessel_i1f(float __a);
-__device__ double __nv_dadd_rd(double __a, double __b);
-__device__ double __nv_dadd_rn(double __a, double __b);
-__device__ double __nv_dadd_ru(double __a, double __b);
-__device__ double __nv_dadd_rz(double __a, double __b);
-__device__ double __nv_ddiv_rd(double __a, double __b);
-__device__ double __nv_ddiv_rn(double __a, double __b);
-__device__ double __nv_ddiv_ru(double __a, double __b);
-__device__ double __nv_ddiv_rz(double __a, double __b);
-__device__ double __nv_dmul_rd(double __a, double __b);
-__device__ double __nv_dmul_rn(double __a, double __b);
-__device__ double __nv_dmul_ru(double __a, double __b);
-__device__ double __nv_dmul_rz(double __a, double __b);
-__device__ float __nv_do

[PATCH] D49899: Force test/Driver/fuchsia.c(pp) to use lld

2018-08-06 Thread David Greene via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL339036: Force test/Driver/fuchsia.c(pp) to use lld (authored 
by greened, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D49899?vs=157689&id=159336#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D49899

Files:
  cfe/trunk/test/Driver/fuchsia.c
  cfe/trunk/test/Driver/fuchsia.cpp

Index: cfe/trunk/test/Driver/fuchsia.cpp
===
--- cfe/trunk/test/Driver/fuchsia.cpp
+++ cfe/trunk/test/Driver/fuchsia.cpp
@@ -1,5 +1,5 @@
 // RUN: %clangxx %s -### -no-canonical-prefixes --target=x86_64-unknown-fuchsia \
-// RUN: --sysroot=%S/platform 2>&1 | FileCheck %s
+// RUN: --sysroot=%S/platform -fuse-ld=lld 2>&1 | FileCheck %s
 // CHECK: {{.*}}clang{{.*}}" "-cc1"
 // CHECK: "-triple" "x86_64-fuchsia"
 // CHECK: "-fuse-init-array"
@@ -21,11 +21,13 @@
 // CHECK-NOT: crtend.o
 // CHECK-NOT: crtn.o
 
-// RUN: %clangxx %s -### --target=x86_64-unknown-fuchsia -stdlib=libstdc++ 2>&1 \
+// RUN: %clangxx %s -### --target=x86_64-unknown-fuchsia -stdlib=libstdc++ \
+// RUN: -fuse-ld=lld 2>&1 \
 // RUN: | FileCheck %s -check-prefix=CHECK-STDLIB
 // CHECK-STDLIB: error: invalid library name in argument '-stdlib=libstdc++'
 
-// RUN: %clangxx %s -### --target=x86_64-unknown-fuchsia -static-libstdc++ 2>&1 \
+// RUN: %clangxx %s -### --target=x86_64-unknown-fuchsia -static-libstdc++ \
+// RUN: -fuse-ld=lld 2>&1 \
 // RUN: | FileCheck %s -check-prefix=CHECK-STATIC
 // CHECK-STATIC: "-Bstatic"
 // CHECK-STATIC: "-lc++"
Index: cfe/trunk/test/Driver/fuchsia.c
===
--- cfe/trunk/test/Driver/fuchsia.c
+++ cfe/trunk/test/Driver/fuchsia.c
@@ -1,10 +1,10 @@
 // RUN: %clang %s -### -no-canonical-prefixes --target=x86_64-fuchsia \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
-// RUN: --sysroot=%S/platform 2>&1 \
+// RUN: --sysroot=%S/platform -fuse-ld=lld 2>&1 \
 // RUN: | FileCheck -check-prefixes=CHECK,CHECK-X86_64 %s
 // RUN: %clang %s -### -no-canonical-prefixes --target=aarch64-fuchsia \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
-// RUN: --sysroot=%S/platform 2>&1 \
+// RUN: --sysroot=%S/platform -fuse-ld=lld 2>&1 \
 // RUN: | FileCheck -check-prefixes=CHECK,CHECK-AARCH64 %s
 // CHECK: {{.*}}clang{{.*}}" "-cc1"
 // CHECK: "--mrelax-relocations"
@@ -31,38 +31,40 @@
 // CHECK-NOT: crtend.o
 // CHECK-NOT: crtn.o
 
-// RUN: %clang %s -### --target=x86_64-fuchsia -rtlib=libgcc 2>&1 \
+// RUN: %clang %s -### --target=x86_64-fuchsia -rtlib=libgcc -fuse-ld=lld 2>&1 \
 // RUN: | FileCheck %s -check-prefix=CHECK-RTLIB
 // CHECK-RTLIB: error: invalid runtime library name in argument '-rtlib=libgcc'
 
-// RUN: %clang %s -### --target=x86_64-fuchsia -static 2>&1 \
+// RUN: %clang %s -### --target=x86_64-fuchsia -static -fuse-ld=lld 2>&1 \
 // RUN: | FileCheck %s -check-prefix=CHECK-STATIC
 // CHECK-STATIC: "-Bstatic"
 // CHECK-STATIC: "-Bdynamic"
 // CHECK-STATIC: "-lc"
 
-// RUN: %clang %s -### --target=x86_64-fuchsia -shared 2>&1 \
+// RUN: %clang %s -### --target=x86_64-fuchsia -shared -fuse-ld=lld 2>&1 \
 // RUN: | FileCheck %s -check-prefix=CHECK-SHARED
 // CHECK-SHARED-NOT: "-pie"
 // CHECK-SHARED: "-shared"
 
-// RUN: %clang %s -### --target=x86_64-fuchsia -r 2>&1 \
+// RUN: %clang %s -### --target=x86_64-fuchsia -r -fuse-ld=lld 2>&1 \
 // RUN: | FileCheck %s -check-prefix=CHECK-RELOCATABLE
 // CHECK-RELOCATABLE-NOT: "-pie"
 // CHECK-RELOCATABLE-NOT: "--build-id"
 // CHECK-RELOCATABLE: "-r"
 
 // RUN: %clang %s -### --target=x86_64-fuchsia \
 // RUN: -fsanitize=safe-stack 2>&1 \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
+// RUN: -fuse-ld=lld \
 // RUN: | FileCheck %s -check-prefix=CHECK-SAFESTACK
 // CHECK-SAFESTACK: "-fsanitize=safe-stack"
 // CHECK-SAFESTACK-NOT: "{{.*[/\\]}}libclang_rt.safestack.a"
 // CHECK-SAFESTACK-NOT: "__safestack_init"
 
 // RUN: %clang %s -### --target=x86_64-fuchsia \
 // RUN: -fsanitize=address 2>&1 \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
+// RUN: -fuse-ld=lld \
 // RUN: | FileCheck %s -check-prefix=CHECK-ASAN-X86
 // CHECK-ASAN-X86: "-fsanitize=address"
 // CHECK-ASAN-X86: "-fsanitize-address-globals-dead-stripping"
@@ -73,6 +75,7 @@
 // RUN: %clang %s -### --target=aarch64-fuchsia \
 // RUN: -fsanitize=address 2>&1 \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
+// RUN: -fuse-ld=lld \
 // RUN: | FileCheck %s -check-prefix=CHECK-ASAN-AARCH64
 // CHECK-ASAN-AARCH64: "-fsanitize=address"
 // CHECK-ASAN-AARCH64: "-fsanitize-address-globals-dead-stripping"
@@ -83,6 +86,7 @@
 // RUN: %clang %s -### --target=x86_64-fuchsia \
 // RUN: -fsanitize=address -fPIC -shared 2>&1 \
 // RUN:  

[PATCH] D49244: Always search sysroot for GCC installs

2018-08-06 Thread David Greene via Phabricator via cfe-commits
greened added a comment.

Ping...


Repository:
  rC Clang

https://reviews.llvm.org/D49244



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


[PATCH] D49897: [WebAssembly] Force use of lld for test/Driver/wasm-toolchain.c(pp)

2018-08-06 Thread David Greene via Phabricator via cfe-commits
greened added a comment.

In https://reviews.llvm.org/D49897#1180338, @sbc100 wrote:

> How do you configure clang to use a different linker?  It looks like 
> getDefaultLinker() is hardcoded, but maybe I'm missing something.


I pass -fuse-ld in the test RUN lines.


Repository:
  rC Clang

https://reviews.llvm.org/D49897



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


[PATCH] D50321: AMDGPU: Add builtin for s_dcache_wb

2018-08-06 Thread Konstantin Zhuravlyov via Phabricator via cfe-commits
kzhuravl accepted this revision.
kzhuravl added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D50321



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


[PATCH] D50320: AMDGPU: Add builtin for s_dcache_inv_vol

2018-08-06 Thread Konstantin Zhuravlyov via Phabricator via cfe-commits
kzhuravl accepted this revision.
kzhuravl added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D50320



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


[PATCH] D50342: Changed how LLVM IR was generated to increase vectorization

2018-08-06 Thread Emmett Neyman via Phabricator via cfe-commits
emmettneyman created this revision.
emmettneyman added reviewers: morehouse, kcc.
Herald added a subscriber: cfe-commits.

Changed the structure of the generated IR to make it easier to vectorize


Repository:
  rC Clang

https://reviews.llvm.org/D50342

Files:
  clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp


Index: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp
===
--- clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp
+++ clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp
@@ -43,17 +43,17 @@
   std::string arr;
   switch(x.arr()) {
   case VarRef::ARR_A:
-arr = "%a";
+arr = "%0";
 break;
   case VarRef::ARR_B:
-arr = "%b";
+arr = "%1";
 break;
   case VarRef::ARR_C:
-arr = "%c";
+arr = "%2";
 break;
   }
   std::string ptr_var = get_var();
-  os << ptr_var << " = getelementptr i32, i32* " << arr << ", i64 %ct\n";
+  os << ptr_var << " = getelementptr inbounds i32, i32* " << arr << ", i64 
%ct\n";
   return ptr_var;
 }
 std::string RvalueToString(std::ostream &os, const Rvalue &x) {
@@ -122,21 +122,22 @@
   return os;
 }
 std::ostream &operator<<(std::ostream &os, const LoopFunction &x) {
-  return os << "define void @foo(i32* %a, i32* %b, i32* noalias %c, i64 %s) 
{\n"
-<< "%i = alloca i64\n"
-<< "store i64 0, i64* %i\n"
-<< "br label %loop\n\n"
-<< "loop:\n"
-<< "%ct = load i64, i64* %i\n"
-<< "%comp = icmp eq i64 %ct, %s\n"
-<< "br i1 %comp, label %endloop, label %body\n\n"
-<< "body:\n"
+  return os << "target triple = \"x86_64-pc-linux-gnu\"\n"
+<< "define void @foo(i32*, i32*, i32*, i64) {\n"
+<< "%5 = icmp sgt i64 %3, 0\n"
+<< "br i1 %5, label %6, label %8\n"
+<< "; :6:\n"
+<< "br label %9\n"
+<< "; :7:\n"
+<< "br label %8\n"
+<< "; :8:\n"
+<< "ret void\n"
+<< "; :9:\n"
+<< " %ct   = phi i64 [ %10, %9 ], [ 0, %6 ]\n"
 << x.statements()
-<< "%z = add i64 1, %ct\n"
-<< "store i64 %z, i64* %i\n"
-<< "br label %loop\n\n"
-<< "endloop:\n"
-<< "ret void\n}\n";
+<< "%10 = add nuw nsw i64 %ct, 1\n"
+<< "%11 = icmp eq i64 %10, %3\n"
+<< "br i1 %11, label %7, label %9\n}\n";
 }
 
 // -


Index: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp
===
--- clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp
+++ clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp
@@ -43,17 +43,17 @@
   std::string arr;
   switch(x.arr()) {
   case VarRef::ARR_A:
-arr = "%a";
+arr = "%0";
 break;
   case VarRef::ARR_B:
-arr = "%b";
+arr = "%1";
 break;
   case VarRef::ARR_C:
-arr = "%c";
+arr = "%2";
 break;
   }
   std::string ptr_var = get_var();
-  os << ptr_var << " = getelementptr i32, i32* " << arr << ", i64 %ct\n";
+  os << ptr_var << " = getelementptr inbounds i32, i32* " << arr << ", i64 %ct\n";
   return ptr_var;
 }
 std::string RvalueToString(std::ostream &os, const Rvalue &x) {
@@ -122,21 +122,22 @@
   return os;
 }
 std::ostream &operator<<(std::ostream &os, const LoopFunction &x) {
-  return os << "define void @foo(i32* %a, i32* %b, i32* noalias %c, i64 %s) {\n"
-<< "%i = alloca i64\n"
-<< "store i64 0, i64* %i\n"
-<< "br label %loop\n\n"
-<< "loop:\n"
-<< "%ct = load i64, i64* %i\n"
-<< "%comp = icmp eq i64 %ct, %s\n"
-<< "br i1 %comp, label %endloop, label %body\n\n"
-<< "body:\n"
+  return os << "target triple = \"x86_64-pc-linux-gnu\"\n"
+<< "define void @foo(i32*, i32*, i32*, i64) {\n"
+<< "%5 = icmp sgt i64 %3, 0\n"
+<< "br i1 %5, label %6, label %8\n"
+<< "; :6:\n"
+<< "br label %9\n"
+<< "; :7:\n"
+<< "br label %8\n"
+<< "; :8:\n"
+<< "ret void\n"
+<< "; :9:\n"
+<< " %ct   = phi i64 [ %10, %9 ], [ 0, %6 ]\n"
 << x.statements()
-<< "%z = add i64 1, %ct\n"
-<< "store i64 %z, i64* %i\n"
-<< "br label %loop\n\n"
-<< "endloop:\n"
-<< "ret void\n}\n";
+<< "%10 = add nuw nsw i64 %ct, 1\n"
+<< "%11 = icmp eq i64 %10, %3\n"
+<< "br i1 %11, label %7, label %9\n}\n";
 }
 
 // -
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r339037 - Fix for failing test from sanitizer-x86_64-linux-fast where there was a

2018-08-06 Thread Leonard Chan via cfe-commits
Author: leonardchan
Date: Mon Aug  6 10:55:38 2018
New Revision: 339037

URL: http://llvm.org/viewvc/llvm-project?rev=339037&view=rev
Log:
Fix for failing test from sanitizer-x86_64-linux-fast where there was a
left shift on a negative value.

Modified:
cfe/trunk/unittests/Basic/FixedPointTest.cpp

Modified: cfe/trunk/unittests/Basic/FixedPointTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Basic/FixedPointTest.cpp?rev=339037&r1=339036&r2=339037&view=diff
==
--- cfe/trunk/unittests/Basic/FixedPointTest.cpp (original)
+++ cfe/trunk/unittests/Basic/FixedPointTest.cpp Mon Aug  6 10:55:38 2018
@@ -364,12 +364,19 @@ TEST(FixedPoint, compare) {
 void CheckUnsaturatedConversion(FixedPointSemantics Src,
 FixedPointSemantics Dst, int64_t TestVal) {
   int64_t ScaledVal = TestVal;
+  bool IsNegative = ScaledVal < 0;
+  if (IsNegative)
+ScaledVal = -ScaledVal;
+
   if (Dst.getScale() > Src.getScale()) {
 ScaledVal <<= (Dst.getScale() - Src.getScale());
   } else {
 ScaledVal >>= (Src.getScale() - Dst.getScale());
   }
 
+  if (IsNegative)
+ScaledVal = -ScaledVal;
+
   APFixedPoint Fixed(TestVal, Src);
   APFixedPoint Expected(ScaledVal, Dst);
   ASSERT_EQ(Fixed.convert(Dst), Expected);


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


Re: r337005 - [NFC] Rename clang::AttributeList to clang::ParsedAttr

2018-08-06 Thread Michael Kruse via cfe-commits
2018-07-13 10:07 GMT-05:00 Erich Keane via cfe-commits
:
> -class AttributeList { // TODO: This should really be called ParsedAttribute
> +class ParsedAttr { // TODO: This should really be called ParsedAttribute

Should this TODO be removed/ParsedAttr really be called ParsedAttribute?

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


[PATCH] D50199: [MinGW] Predefine UNICODE if -municode is specified during compilation

2018-08-06 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm, thanks!


https://reviews.llvm.org/D50199



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


r339038 - Removed the OverflowConversionsToFract tests for now. Will add them back

2018-08-06 Thread Leonard Chan via cfe-commits
Author: leonardchan
Date: Mon Aug  6 11:02:16 2018
New Revision: 339038

URL: http://llvm.org/viewvc/llvm-project?rev=339038&view=rev
Log:
Removed the OverflowConversionsToFract tests for now. Will add them back
in once I figure out why this doesn't work on windows.

Modified:
cfe/trunk/unittests/Basic/FixedPointTest.cpp

Modified: cfe/trunk/unittests/Basic/FixedPointTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Basic/FixedPointTest.cpp?rev=339038&r1=339037&r2=339038&view=diff
==
--- cfe/trunk/unittests/Basic/FixedPointTest.cpp (original)
+++ cfe/trunk/unittests/Basic/FixedPointTest.cpp Mon Aug  6 11:02:16 2018
@@ -601,51 +601,6 @@ TEST(FixedPoint, SAccumConversionOverflo
   -549755813888);
 }
 
-void CheckSaturatedConversionToFractMax(FixedPointSemantics Src,
-int64_t OneVal) {
-  CheckSaturatedConversionMax(Src, Saturated(getSFractSema()), OneVal);
-  CheckSaturatedConversionMax(Src, Saturated(getFractSema()), OneVal);
-  CheckSaturatedConversionMax(Src, Saturated(getLFractSema()), OneVal);
-  CheckSaturatedConversionMax(Src, Saturated(getUSFractSema()), OneVal);
-  CheckSaturatedConversionMax(Src, Saturated(getUFractSema()), OneVal);
-  CheckSaturatedConversionMax(Src, Saturated(getPadULFractSema()), OneVal);
-  CheckSaturatedConversionMax(Src, Saturated(getPadUSFractSema()), OneVal);
-  CheckSaturatedConversionMax(Src, Saturated(getPadUFractSema()), OneVal);
-  CheckSaturatedConversionMax(Src, Saturated(getPadULFractSema()), OneVal);
-}
-
-void CheckSaturatedConversionToFractMin(FixedPointSemantics Src,
-int64_t MinusOneVal) {
-  CheckSaturatedConversionMin(Src, Saturated(getSFractSema()), MinusOneVal);
-  CheckSaturatedConversionMin(Src, Saturated(getFractSema()), MinusOneVal);
-  CheckSaturatedConversionMin(Src, Saturated(getLFractSema()), MinusOneVal);
-  CheckSaturatedConversionMin(Src, Saturated(getUSFractSema()), MinusOneVal);
-  CheckSaturatedConversionMin(Src, Saturated(getUFractSema()), MinusOneVal);
-  CheckSaturatedConversionMin(Src, Saturated(getPadULFractSema()), 
MinusOneVal);
-  CheckSaturatedConversionMin(Src, Saturated(getPadUSFractSema()), 
MinusOneVal);
-  CheckSaturatedConversionMin(Src, Saturated(getPadUFractSema()), MinusOneVal);
-  CheckSaturatedConversionMin(Src, Saturated(getPadULFractSema()), 
MinusOneVal);
-}
-
-TEST(FixedPoint, OverflowConversionsToFract) {
-  CheckSaturatedConversionToFractMax(getSAccumSema(), 128);
-  CheckSaturatedConversionToFractMin(getSAccumSema(), -128);
-  CheckSaturatedConversionToFractMax(getAccumSema(), 32768);
-  CheckSaturatedConversionToFractMin(getAccumSema(), -32768);
-  CheckSaturatedConversionToFractMax(getLAccumSema(), 2147483648);
-  CheckSaturatedConversionToFractMin(getLAccumSema(), -2147483648);
-
-  // Unsigned
-  CheckSaturatedConversionToFractMax(getUSAccumSema(), 256);
-  CheckSaturatedConversionToFractMax(getUAccumSema(), 65536);
-  CheckSaturatedConversionToFractMax(getULAccumSema(), 4294967296);
-
-  // Padded unsigned
-  CheckSaturatedConversionToFractMax(getPadUSAccumSema(), 128);
-  CheckSaturatedConversionToFractMax(getPadUAccumSema(), 32768);
-  CheckSaturatedConversionToFractMax(getPadULAccumSema(), 2147483648);
-}
-
 TEST(FixedPoint, GetValueSignAfterConversion) {
   APFixedPoint Fixed(255 << 7, getSAccumSema());
   ASSERT_TRUE(Fixed.getValue().isSigned());


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


r339039 - [NFC] Remove TODO comment that no longer applies (ParsedAttr)

2018-08-06 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Mon Aug  6 11:11:48 2018
New Revision: 339039

URL: http://llvm.org/viewvc/llvm-project?rev=339039&view=rev
Log:
[NFC] Remove TODO comment that no longer applies (ParsedAttr)

Modified:
cfe/trunk/include/clang/Sema/ParsedAttr.h

Modified: cfe/trunk/include/clang/Sema/ParsedAttr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/ParsedAttr.h?rev=339039&r1=339038&r2=339039&view=diff
==
--- cfe/trunk/include/clang/Sema/ParsedAttr.h (original)
+++ cfe/trunk/include/clang/Sema/ParsedAttr.h Mon Aug  6 11:11:48 2018
@@ -102,7 +102,7 @@ using ArgsVector = llvm::SmallVectorhttp://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


RE: r337005 - [NFC] Rename clang::AttributeList to clang::ParsedAttr

2018-08-06 Thread Keane, Erich via cfe-commits
Good grief... I even made a note to remove this 'TODO' on my whiteboard!

I discussed the name with AaronBallman who preferred ParsedAttr over 
ParsedAttribute (since ParsedAttributes is also a type).

Fixed in r339039.

-Original Message-
From: meiners...@googlemail.com [mailto:meiners...@googlemail.com] On Behalf Of 
Michael Kruse
Sent: Monday, August 6, 2018 11:00 AM
To: Keane, Erich 
Cc: cfe-commits 
Subject: Re: r337005 - [NFC] Rename clang::AttributeList to clang::ParsedAttr

2018-07-13 10:07 GMT-05:00 Erich Keane via cfe-commits
:
> -class AttributeList { // TODO: This should really be called ParsedAttribute
> +class ParsedAttr { // TODO: This should really be called ParsedAttribute

Should this TODO be removed/ParsedAttr really be called ParsedAttribute?

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


[PATCH] D50099: [DebugInfo][OpenCL] Address post-commit review of D49930

2018-08-06 Thread Scott Linder via Phabricator via cfe-commits
scott.linder added a comment.

When I went to mark these as static I noticed they use 
`CGDebugInfo::CreateMemberType` which uses a couple other non-static member 
functions, and it starts to become difficult to tease things out into nice 
clean static functions.




Comment at: lib/CodeGen/CGDebugInfo.cpp:997
   llvm::DINode::DIFlags Flags = llvm::DINode::FlagAppleBlock;
   unsigned LineNo = 0;
 

echristo wrote:
> Just noticed that LineNo is 0... for the entire function.
What should it be instead? My understanding is that LineNo=0 indicates there is 
no corresponding source, and these fields seem to be implementation details.


https://reviews.llvm.org/D50099



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


[PATCH] D50261: [AST] Remove unnecessary indirections in DeclarationNameTable

2018-08-06 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

Neat, thanks for the optimization. My only concern would be to find a way to 
avoid including Type.h, but it's already a very popular and very necessary 
header, so I don't think there is any issue here.


Repository:
  rL LLVM

https://reviews.llvm.org/D50261



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


[PATCH] D50099: [DebugInfo][OpenCL] Address post-commit review of D49930

2018-08-06 Thread Eric Christopher via Phabricator via cfe-commits
echristo added a comment.

In https://reviews.llvm.org/D50099#1189667, @scott.linder wrote:

> When I went to mark these as static I noticed they use 
> `CGDebugInfo::CreateMemberType` which uses a couple other non-static member 
> functions, and it starts to become difficult to tease things out into nice 
> clean static functions.


Ah. Fair. No worries then.




Comment at: lib/CodeGen/CGDebugInfo.cpp:997
   llvm::DINode::DIFlags Flags = llvm::DINode::FlagAppleBlock;
   unsigned LineNo = 0;
 

scott.linder wrote:
> echristo wrote:
> > Just noticed that LineNo is 0... for the entire function.
> What should it be instead? My understanding is that LineNo=0 indicates there 
> is no corresponding source, and these fields seem to be implementation 
> details.
Could probably just replace it with a constant 0 in the calls rather than 
having the local?


https://reviews.llvm.org/D50099



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


[PATCH] D50342: Changed how LLVM IR was generated to increase vectorization

2018-08-06 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse added inline comments.



Comment at: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp:125
 std::ostream &operator<<(std::ostream &os, const LoopFunction &x) {
-  return os << "define void @foo(i32* %a, i32* %b, i32* noalias %c, i64 %s) 
{\n"
-<< "%i = alloca i64\n"
-<< "store i64 0, i64* %i\n"
-<< "br label %loop\n\n"
-<< "loop:\n"
-<< "%ct = load i64, i64* %i\n"
-<< "%comp = icmp eq i64 %ct, %s\n"
-<< "br i1 %comp, label %endloop, label %body\n\n"
-<< "body:\n"
+  return os << "target triple = \"x86_64-pc-linux-gnu\"\n"
+<< "define void @foo(i32*, i32*, i32*, i64) {\n"

What does `pc` mean in this triple?  I'm used to seeing 
`x86_64-unknown-linux-gnu`.



Comment at: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp:126
+  return os << "target triple = \"x86_64-pc-linux-gnu\"\n"
+<< "define void @foo(i32*, i32*, i32*, i64) {\n"
+<< "%5 = icmp sgt i64 %3, 0\n"

Does removing the variable names really make this easier to vectorize?



Comment at: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp:129
+<< "br i1 %5, label %6, label %8\n"
+<< "; :6:\n"
+<< "br label %9\n"

Does removing branch names really make this easier to vectorize?


Repository:
  rC Clang

https://reviews.llvm.org/D50342



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


[PATCH] D50055: Update the coding standard about NFC changes and whitespace

2018-08-06 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

In https://reviews.llvm.org/D50055#1188479, @chandlerc wrote:

> Maybe double check with Reid and/or Hal to make sure we've all ended up on 
> the same page before landing though.


lgtm, thanks


https://reviews.llvm.org/D50055



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


[PATCH] D50099: [DebugInfo][OpenCL] Address post-commit review of D49930

2018-08-06 Thread Scott Linder via Phabricator via cfe-commits
scott.linder added inline comments.



Comment at: lib/CodeGen/CGDebugInfo.cpp:997
   llvm::DINode::DIFlags Flags = llvm::DINode::FlagAppleBlock;
   unsigned LineNo = 0;
 

echristo wrote:
> scott.linder wrote:
> > echristo wrote:
> > > Just noticed that LineNo is 0... for the entire function.
> > What should it be instead? My understanding is that LineNo=0 indicates 
> > there is no corresponding source, and these fields seem to be 
> > implementation details.
> Could probably just replace it with a constant 0 in the calls rather than 
> having the local?
Oh, I see what you mean; I will make that change, and I am also working out how 
to enable ASan correctly to check the patch, then I will post a new diff.


https://reviews.llvm.org/D50099



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


[PATCH] D49897: [WebAssembly] Force use of lld for test/Driver/wasm-toolchain.c(pp)

2018-08-06 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 added a comment.

But in the CL description you say "..when configuring clang to use a different 
linker by default".  How is this possible?i.e. do you have a config where 
these tests are currently failing?


Repository:
  rC Clang

https://reviews.llvm.org/D49897



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


[PATCH] D50261: [AST] Remove unnecessary indirections in DeclarationNameTable

2018-08-06 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added a comment.

Yes it would be nice indeed. IIRC it is only needed for
QualType in one of the moved class.

This patch is especially nice since it both cleanup the code and
speed up clang :)


Repository:
  rL LLVM

https://reviews.llvm.org/D50261



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


Re: r338899 - [OpenCL] Always emit alloca in entry block for enqueue_kernel builtin

2018-08-06 Thread via cfe-commits
That's what I was missing; I should have looked more closely at the 
buildbot logs, I see the export there now.


Thanks!
Scott

On 2018-08-06 12:51, Vlad Tsyrklevich wrote:

Have you tried setting detect_stack_use_after_return in ASAN_OPTIONS?
The ASan buildbot sets the following ASAN_OPTIONS prior to running
tests:
export
ASAN_OPTIONS="check_initialization_order=true:detect_stack_use_after_return=1:detect_leaks=1"

On Mon, Aug 6, 2018 at 7:34 AM  wrote:


I can't seem to reproduce the ASan failure locally, even after
building
a clang with the latest compiler-rt, and then rebuilding my patch
with
LLVM_USE_SANITIZER=Address

I am pretty confident the problem should be fixed with a one-line
change
to my patch:

- auto CreateArrayForSizeVar = [=](unsigned First) {
+ auto CreateArrayForSizeVar = [=](unsigned First)
+ -> std::tuple
{

I don't want to commit something and then immediately have to
revert,
though. Can you think of anything I might be missing locally to
reproduce the ASan failure?

Thanks,
Scott

On 2018-08-03 13:48, Vlad Tsyrklevich wrote:

This change is causing ASan failures on the sanitizer bots:




http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/21898/steps/check-clang%20asan/logs/stdio

[1]

[9]

I've reverted it in r338904.

On Fri, Aug 3, 2018 at 8:51 AM Scott Linder via cfe-commits
 wrote:


Author: scott.linder
Date: Fri Aug 3 08:50:52 2018
New Revision: 338899

URL: http://llvm.org/viewvc/llvm-project?rev=338899&view=rev [2]

[1]

Log:
[OpenCL] Always emit alloca in entry block for enqueue_kernel
builtin

Ensures the statically sized alloca is not converted to
DYNAMIC_STACKALLOC
later because it is not in the entry block.

Differential Revision: https://reviews.llvm.org/D50104 [3] [2]

Added:
cfe/trunk/test/CodeGenOpenCL/enqueue-kernel-non-entry-block.cl

[4]

[3]
Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGenOpenCL/cl20-device-side-enqueue.cl [5] [4]

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL:






http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=338899&r1=338898&r2=338899&view=diff

[6]

[5]






==

--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Fri Aug 3 08:50:52 2018
@@ -3338,23 +3338,29 @@ RValue CodeGenFunction::EmitBuiltinExpr(
// Create a temporary array to hold the sizes of local pointer
arguments
// for the block. \p First is the position of the first size
argument.
auto CreateArrayForSizeVar = [=](unsigned First) {
- auto *AT = llvm::ArrayType::get(SizeTy, NumArgs - First);
- auto *Arr = Builder.CreateAlloca(AT);
- llvm::Value *Ptr;
+ llvm::APInt ArraySize(32, NumArgs - First);
+ QualType SizeArrayTy = getContext().getConstantArrayType(
+ getContext().getSizeType(), ArraySize, ArrayType::Normal,
+ /*IndexTypeQuals=*/0);
+ auto Tmp = CreateMemTemp(SizeArrayTy, "block_sizes");
+ llvm::Value *TmpPtr = Tmp.getPointer();
+ llvm::Value *TmpSize = EmitLifetimeStart(
+
CGM.getDataLayout().getTypeAllocSize(Tmp.getElementType()),

TmpPtr);

+ llvm::Value *ElemPtr;
// Each of the following arguments specifies the size of the
corresponding
// argument passed to the enqueued block.
auto *Zero = llvm::ConstantInt::get(IntTy, 0);
for (unsigned I = First; I < NumArgs; ++I) {
auto *Index = llvm::ConstantInt::get(IntTy, I - First);
- auto *GEP = Builder.CreateGEP(Arr, {Zero, Index});
+ auto *GEP = Builder.CreateGEP(TmpPtr, {Zero, Index});
if (I == First)
- Ptr = GEP;
+ ElemPtr = GEP;
auto *V =
Builder.CreateZExtOrTrunc(EmitScalarExpr(E->getArg(I)),
SizeTy);
Builder.CreateAlignedStore(
V, GEP,
CGM.getDataLayout().getPrefTypeAlignment(SizeTy));
}
- return Ptr;
+ return std::tie(ElemPtr, TmpSize, TmpPtr);
};

// Could have events and/or varargs.
@@ -3366,24 +3372,27 @@ RValue CodeGenFunction::EmitBuiltinExpr(
llvm::Value *Kernel =
Builder.CreatePointerCast(Info.Kernel, GenericVoidPtrTy);
auto *Block = Builder.CreatePointerCast(Info.BlockArg,
GenericVoidPtrTy);
- auto *PtrToSizeArray = CreateArrayForSizeVar(4);
+ llvm::Value *ElemPtr, *TmpSize, *TmpPtr;
+ std::tie(ElemPtr, TmpSize, TmpPtr) =
CreateArrayForSizeVar(4);

// Create a vector of the arguments, as well as a constant
value to
// express to the runtime the number of variadic arguments.
std::vector Args = {
Queue, Flags, Range,
Kernel, Block, ConstantInt::get(IntTy, NumArgs - 4),
- PtrToSizeArray};
+ ElemPtr};
std::vector ArgTys = {
- QueueTy, IntTy, RangeTy,
- GenericVoidPtrTy, GenericVoidPtrTy, IntTy,
- PtrToSizeArray->getType()};
+ QueueTy, IntTy, RangeTy,
GenericVoidPtrTy,
+ GenericVoidPtrTy, IntTy, ElemPtr->getType()};

llvm::FunctionType *FTy = llvm::FunctionType::get(
Int32Ty, llvm::ArrayRef(ArgTys), false);
- return RValue::get(
- Builder.CreateCall(CGM.CreateRuntimeFunction(FTy, Name),
- llvm::ArrayRef(Args)));
+ auto Call =
+
RValue::get(Builder.CreateCall(CGM.CreateRuntimeFunction(FTy,

Name),

+ llvm::ArrayRef(Args)));
+ if (TmpSi

[PATCH] D50344: [libc++] Enable aligned allocation based on feature test macro, irrespective of standard

2018-08-06 Thread Louis Dionne via Phabricator via cfe-commits
ldionne created this revision.
ldionne added a reviewer: vsapsai.
Herald added a reviewer: EricWF.
Herald added subscribers: cfe-commits, dexonsmith, christof.

The current code enables aligned allocation functions when compiling in C++17
and later. This is a problem because aligned allocation functions might not
be supported on the target platform, which leads to an error at link time.

Since r338934, Clang knows not to define __cpp_aligned_new when it's not
available on the target platform -- this commit takes advantage of that to
only use aligned allocation functions when they are available.


Repository:
  rCXX libc++

https://reviews.llvm.org/D50344

Files:
  libcxx/include/__config
  libcxx/include/new
  libcxx/test/libcxx/memory/aligned_allocation_macro.pass.cpp


Index: libcxx/test/libcxx/memory/aligned_allocation_macro.pass.cpp
===
--- /dev/null
+++ libcxx/test/libcxx/memory/aligned_allocation_macro.pass.cpp
@@ -0,0 +1,25 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+// XFAIL: with_system_cxx_lib=macosx10.12
+// XFAIL: with_system_cxx_lib=macosx10.11
+// XFAIL: with_system_cxx_lib=macosx10.10
+// XFAIL: with_system_cxx_lib=macosx10.9
+// XFAIL: with_system_cxx_lib=macosx10.8
+// XFAIL: with_system_cxx_lib=macosx10.7
+
+#include 
+
+
+#ifdef _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
+#   error "libc++ should have aligned allocation in C++17 and up when 
targeting a platform that supports it"
+#endif
+
+int main() { }
Index: libcxx/include/new
===
--- libcxx/include/new
+++ libcxx/include/new
@@ -108,13 +108,6 @@
 # define _LIBCPP_HAS_NO_SIZED_DEALLOCATION
 #endif
 
-#if !defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION) && \
-(!(defined(_LIBCPP_BUILDING_LIBRARY) || _LIBCPP_STD_VER > 14 || \
-(defined(__cpp_aligned_new) && __cpp_aligned_new >= 201606)))
-# define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
-#endif
-
-
 #if !__has_builtin(__builtin_operator_new) || \
__has_builtin(__builtin_operator_new) < 201802L || \
defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION) || \
Index: libcxx/include/__config
===
--- libcxx/include/__config
+++ libcxx/include/__config
@@ -988,6 +988,11 @@
 #  endif
 #endif // defined(__APPLE__)
 
+#if !defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION) && \
+!defined(_LIBCPP_BUILDING_LIBRARY) && \
+!defined(__cpp_aligned_new)
+#  define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
+#endif
 
 #if defined(__APPLE__) || defined(__FreeBSD__)
 #define _LIBCPP_HAS_DEFAULTRUNELOCALE


Index: libcxx/test/libcxx/memory/aligned_allocation_macro.pass.cpp
===
--- /dev/null
+++ libcxx/test/libcxx/memory/aligned_allocation_macro.pass.cpp
@@ -0,0 +1,25 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+// XFAIL: with_system_cxx_lib=macosx10.12
+// XFAIL: with_system_cxx_lib=macosx10.11
+// XFAIL: with_system_cxx_lib=macosx10.10
+// XFAIL: with_system_cxx_lib=macosx10.9
+// XFAIL: with_system_cxx_lib=macosx10.8
+// XFAIL: with_system_cxx_lib=macosx10.7
+
+#include 
+
+
+#ifdef _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
+#   error "libc++ should have aligned allocation in C++17 and up when targeting a platform that supports it"
+#endif
+
+int main() { }
Index: libcxx/include/new
===
--- libcxx/include/new
+++ libcxx/include/new
@@ -108,13 +108,6 @@
 # define _LIBCPP_HAS_NO_SIZED_DEALLOCATION
 #endif
 
-#if !defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION) && \
-(!(defined(_LIBCPP_BUILDING_LIBRARY) || _LIBCPP_STD_VER > 14 || \
-(defined(__cpp_aligned_new) && __cpp_aligned_new >= 201606)))
-# define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
-#endif
-
-
 #if !__has_builtin(__builtin_operator_new) || \
__has_builtin(__builtin_operator_new) < 201802L || \
defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION) || \
Index: libcxx/include/__config
===
--- libcxx/include/__config
+++ libcxx/include/__config
@@ -988,6 +988,11 @@
 #  endif
 #endif // defined(__APPLE__)
 
+#if !defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION) && \
+!defined(_LIBCPP_BUILDI

[PATCH] D43357: [Concepts] Function trailing requires clauses

2018-08-06 Thread Saar Raz via Phabricator via cfe-commits
saar.raz updated this revision to Diff 159349.
saar.raz added a comment.
Herald added a subscriber: jfb.

- Fix bad diagnostic detection and suppression


Repository:
  rC Clang

https://reviews.llvm.org/D43357

Files:
  include/clang/AST/Decl.h
  include/clang/AST/DeclCXX.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/DeclSpec.h
  include/clang/Sema/Overload.h
  include/clang/Sema/Sema.h
  lib/AST/ASTDumper.cpp
  lib/AST/ASTImporter.cpp
  lib/AST/Decl.cpp
  lib/AST/DeclCXX.cpp
  lib/AST/DeclPrinter.cpp
  lib/AST/DeclTemplate.cpp
  lib/AST/ODRHash.cpp
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseTentative.cpp
  lib/Sema/DeclSpec.cpp
  lib/Sema/SemaCast.cpp
  lib/Sema/SemaConcept.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaOverload.cpp
  lib/Sema/SemaTemplateDeduction.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  lib/Sema/SemaTemplateVariadic.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriterDecl.cpp
  test/CXX/concepts-ts/class.derived/class.virtual/p6.cpp
  test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
  test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p2.cpp
  test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp
  test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p6.cpp
  test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p7.cpp
  test/CXX/concepts-ts/dcl.dcl/lit.cfg.py
  test/CXX/concepts-ts/dcl/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
  test/CXX/concepts-ts/dcl/dcl.dcl/dcl.spec/dcl.spec.concept/p2.cpp
  test/CXX/concepts-ts/dcl/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp
  test/CXX/concepts-ts/dcl/dcl.dcl/dcl.spec/dcl.spec.concept/p6.cpp
  test/CXX/concepts-ts/dcl/dcl.dcl/dcl.spec/dcl.spec.concept/p7.cpp
  test/CXX/concepts-ts/dcl/dcl.dcl/lit.cfg.py
  test/CXX/concepts-ts/dcl/dcl.decl/p3.cpp
  test/CXX/concepts-ts/expr/expr.prim/expr.prim.id/mixed-constraints.cpp
  test/CXX/concepts-ts/expr/expr.prim/expr.prim.id/p4.cpp
  test/CXX/concepts-ts/over/over.match/over.match.best/p1.cpp
  test/CXX/concepts-ts/over/over.over/p4.cpp

Index: test/CXX/concepts-ts/over/over.over/p4.cpp
===
--- /dev/null
+++ test/CXX/concepts-ts/over/over.over/p4.cpp
@@ -0,0 +1,56 @@
+// RUN:  %clang_cc1 -std=c++2a -fconcepts-ts -verify %s
+
+
+template
+constexpr static bool is_same_v = false;
+
+template
+constexpr static bool is_same_v = true;
+
+template
+concept AtLeast2 = sizeof(T) >= 2;
+
+template
+concept AtMost8 = sizeof(T) <= 8;
+
+int foo() requires AtLeast2 && AtMost8 {
+  return 0;
+}
+
+double foo() requires AtLeast2 {
+  return 0.0;
+}
+
+char bar() requires AtLeast2 { // expected-note {{possible target for call}}
+  return 1.0;
+}
+
+short bar() requires AtLeast2 && AtMost8 { // expected-note {{possible target for call}} expected-note {{candidate function}}
+  return 0.0;
+}
+
+int bar() requires AtMost8 && AtLeast2 { // expected-note {{possible target for call}} expected-note {{candidate function}}
+  return 0.0;
+}
+
+char baz() requires AtLeast2 {
+  return 1.0;
+}
+
+short baz() requires AtLeast2 && AtMost8 {
+  return 0.0;
+}
+
+int baz() requires AtMost8 && AtLeast2 {
+  return 0.0;
+}
+
+long baz() requires AtMost8 && AtLeast2 && AtLeast2 {
+  return 3.0;
+}
+
+void a() {
+  static_assert(is_same_v);
+  static_assert(is_same_v); // expected-error {{reference to overloaded function could not be resolved; did you mean to call it with no arguments?}} expected-error{{call to 'bar' is ambiguous}}
+  static_assert(is_same_v);
+}
\ No newline at end of file
Index: test/CXX/concepts-ts/over/over.match/over.match.best/p1.cpp
===
--- /dev/null
+++ test/CXX/concepts-ts/over/over.match/over.match.best/p1.cpp
@@ -0,0 +1,65 @@
+// RUN:  %clang_cc1 -std=c++2a -fconcepts-ts -verify %s
+
+
+template
+constexpr static bool is_same_v = false;
+
+template
+constexpr static bool is_same_v = true;
+
+namespace templates
+{
+  template
+  concept AtLeast1 = sizeof(T) >= 1;
+
+  template
+  int foo(T t) requires sizeof(T) == 4 { // expected-note {{candidate function}}
+return 0;
+  }
+
+  template
+  char foo(T t) requires AtLeast1 { // expected-note {{candidate function}}
+return 'a';
+  }
+
+  template
+  double foo(T t) requires AtLeast1 && sizeof(T) <= 2 {
+return 'a';
+  }
+
+  void bar() {
+static_assert(is_same_v); // expected-error {{call to 'foo' is ambiguous}}
+static_assert(is_same_v);
+  }
+}
+
+namespace non_template
+{
+  template
+  concept AtLeast2 = sizeof(T) >= 2;
+
+  template
+  concept AtMost8 = sizeof(T) <= 8;
+
+  int foo() requires AtLeast2 && AtMost8 {
+return 0;
+  }
+
+  double foo() requires AtLeast2 {
+return 0.0;
+  }
+
+  double baz() requires AtLeast2 && AtMost8 { // expected-note {{candidate function}}
+

[PATCH] D49438: [analyzer][UninitializedObjectChecker] New flag to turn off dereferencing

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

I think what pointer chasing should do, is check whether that pointer owns the 
pointee. In that case, it should be fine to analyze it. Do you mind if I put a 
TODO around flag's description stating that this should be implemented and 
pointer chasing should be enabled by default once that's done?


https://reviews.llvm.org/D49438



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


r339044 - Fix for broken build on clang-hexagon-elf for ambiguous call to

2018-08-06 Thread Leonard Chan via cfe-commits
Author: leonardchan
Date: Mon Aug  6 12:31:00 2018
New Revision: 339044

URL: http://llvm.org/viewvc/llvm-project?rev=339044&view=rev
Log:
Fix for broken build on clang-hexagon-elf for ambiguous call to
std::abs.

Modified:
cfe/trunk/lib/Basic/FixedPoint.cpp

Modified: cfe/trunk/lib/Basic/FixedPoint.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FixedPoint.cpp?rev=339044&r1=339043&r2=339044&view=diff
==
--- cfe/trunk/lib/Basic/FixedPoint.cpp (original)
+++ cfe/trunk/lib/Basic/FixedPoint.cpp Mon Aug  6 12:31:00 2018
@@ -59,7 +59,8 @@ int APFixedPoint::compare(const APFixedP
   unsigned CommonWidth = std::max(Val.getBitWidth(), OtherWidth);
 
   // Prevent overflow in the event the widths are the same but the scales 
differ
-  CommonWidth += std::abs(static_cast(getScale() - OtherScale));
+  CommonWidth += getScale() >= OtherScale ? getScale() - OtherScale
+  : OtherScale - getScale();
 
   ThisVal = ThisVal.extOrTrunc(CommonWidth);
   OtherVal = OtherVal.extOrTrunc(CommonWidth);


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


[PATCH] D49438: [analyzer][UninitializedObjectChecker] New flag to turn off dereferencing

2018-08-06 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov added a comment.

> I think what pointer chasing should do, is check whether that pointer owns 
> the pointee

But ownership is a convention, and it's not always deducible from a codebase.
I think of those as two separate checks, and I think we should only talk about 
enabling the pointer-chasing after we had established that just checking for 
uninitialized fields finds lots of valid bugs (and we can only do that after it 
gets enabled for many projects)


https://reviews.llvm.org/D49438



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


[PATCH] D49952: Check for NULL Destination-Type when creating ArrayConstant

2018-08-06 Thread Balaji Iyer via Phabricator via cfe-commits
bviyer updated this revision to Diff 159353.

https://reviews.llvm.org/D49952

Files:
  lib/CodeGen/CGExprConstant.cpp
  test/CodeGenCXX/empty-struct-init-list.cpp


Index: test/CodeGenCXX/empty-struct-init-list.cpp
===
--- /dev/null
+++ test/CodeGenCXX/empty-struct-init-list.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -std=c++11 -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -std=c++14 -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -std=c++17 -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: struct.a
+typedef struct { } a;
+typedef struct {
+  a b[];
+} c;
+
+// CHECK: global %struct.c zeroinitializer, align 1
+c d{ };
Index: lib/CodeGen/CGExprConstant.cpp
===
--- lib/CodeGen/CGExprConstant.cpp
+++ lib/CodeGen/CGExprConstant.cpp
@@ -2119,6 +2119,16 @@
   Elts.push_back(C);
 }
 
+// This means that the array type is probably "IncompleteType" or some
+// type that is not ConstantArray.
+if (CAT == nullptr && CommonElementType == nullptr && !NumInitElts) {
+  const ArrayType *AT = CGM.getContext().getAsArrayType(DestType);
+  CommonElementType = CGM.getTypes().ConvertType(AT->getElementType());
+  llvm::ArrayType *AType = llvm::ArrayType::get(CommonElementType,
+NumElements);
+  return llvm::ConstantAggregateZero::get(AType);
+}
+
 return EmitArrayConstant(CGM, CAT, CommonElementType, NumElements, Elts,
  Filler);
   }


Index: test/CodeGenCXX/empty-struct-init-list.cpp
===
--- /dev/null
+++ test/CodeGenCXX/empty-struct-init-list.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -std=c++11 -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -std=c++14 -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -std=c++17 -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: struct.a
+typedef struct { } a;
+typedef struct {
+  a b[];
+} c;
+
+// CHECK: global %struct.c zeroinitializer, align 1
+c d{ };
Index: lib/CodeGen/CGExprConstant.cpp
===
--- lib/CodeGen/CGExprConstant.cpp
+++ lib/CodeGen/CGExprConstant.cpp
@@ -2119,6 +2119,16 @@
   Elts.push_back(C);
 }
 
+// This means that the array type is probably "IncompleteType" or some
+// type that is not ConstantArray.
+if (CAT == nullptr && CommonElementType == nullptr && !NumInitElts) {
+  const ArrayType *AT = CGM.getContext().getAsArrayType(DestType);
+  CommonElementType = CGM.getTypes().ConvertType(AT->getElementType());
+  llvm::ArrayType *AType = llvm::ArrayType::get(CommonElementType,
+NumElements);
+  return llvm::ConstantAggregateZero::get(AType);
+}
+
 return EmitArrayConstant(CGM, CAT, CommonElementType, NumElements, Elts,
  Filler);
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D49952: Check for NULL Destination-Type when creating ArrayConstant

2018-08-06 Thread Balaji Iyer via Phabricator via cfe-commits
bviyer marked an inline comment as done.
bviyer added a comment.

John, I have updated the test case as you requested (I think). I am a bit new 
to Clang, so apologize if I mistook your request.


https://reviews.llvm.org/D49952



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


[PATCH] D50346: Add getBeginLoc API to replace getLocStart

2018-08-06 Thread Stephen Kelly via Phabricator via cfe-commits
steveire created this revision.
Herald added a subscriber: cfe-commits.

Repository:
  rC Clang

https://reviews.llvm.org/D50346

Files:
  include/clang/AST/Comment.h
  include/clang/AST/Decl.h
  include/clang/AST/DeclBase.h
  include/clang/AST/DeclCXX.h
  include/clang/AST/DeclObjC.h
  include/clang/AST/DeclarationName.h
  include/clang/AST/Expr.h
  include/clang/AST/ExprCXX.h
  include/clang/AST/ExprObjC.h
  include/clang/AST/ExprOpenMP.h
  include/clang/AST/OpenMPClause.h
  include/clang/AST/RawCommentList.h
  include/clang/AST/Stmt.h
  include/clang/AST/StmtCXX.h
  include/clang/AST/StmtObjC.h
  include/clang/AST/StmtOpenMP.h
  include/clang/AST/TypeLoc.h
  include/clang/Sema/DeclSpec.h
  lib/AST/Expr.cpp
  lib/AST/ExprCXX.cpp
  lib/AST/Stmt.cpp
  lib/Sema/SemaChecking.cpp

Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -6121,7 +6121,8 @@
 StartToken, StartTokenByteOffset);
   }
 
-  SourceLocation getLocStart() const LLVM_READONLY {
+  SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc();  }
+  SourceLocation getBeginLoc() const LLVM_READONLY {
 return FExpr->getLocStart().getLocWithOffset(Offset);
   }
 
Index: lib/AST/Stmt.cpp
===
--- lib/AST/Stmt.cpp
+++ lib/AST/Stmt.cpp
@@ -275,8 +275,8 @@
   llvm_unreachable("unknown statement kind!");
 }
 
-SourceLocation Stmt::getLocStart() const {
-//  llvm::errs() << "getLocStart() for " << getStmtClassName() << "\n";
+SourceLocation Stmt::getBeginLoc() const {
+//  llvm::errs() << "getBeginLoc() for " << getStmtClassName() << "\n";
   switch (getStmtClass()) {
   case Stmt::NoStmtClass: llvm_unreachable("statement without class");
 #define ABSTRACT_STMT(type)
Index: lib/AST/ExprCXX.cpp
===
--- lib/AST/ExprCXX.cpp
+++ lib/AST/ExprCXX.cpp
@@ -89,7 +89,7 @@
 }
 
 // CXXScalarValueInitExpr
-SourceLocation CXXScalarValueInitExpr::getLocStart() const {
+SourceLocation CXXScalarValueInitExpr::getBeginLoc() const {
   return TypeInfo ? TypeInfo->getTypeLoc().getBeginLoc() : RParenLoc;
 }
 
@@ -450,7 +450,7 @@
   return E;
 }
 
-SourceLocation CXXConstructExpr::getLocStart() const {
+SourceLocation CXXConstructExpr::getBeginLoc() const {
   if (isa(this))
 return cast(this)->getLocStart();
   return Loc;
@@ -691,7 +691,7 @@
   return new (Buffer) CXXFunctionalCastExpr(EmptyShell(), PathSize);
 }
 
-SourceLocation CXXFunctionalCastExpr::getLocStart() const {
+SourceLocation CXXFunctionalCastExpr::getBeginLoc() const {
   return getTypeInfoAsWritten()->getTypeLoc().getLocStart();
 }
 
@@ -776,7 +776,7 @@
CXXConstructExpr::CK_Complete, ParenOrBraceRange),
   Type(TSI) {}
 
-SourceLocation CXXTemporaryObjectExpr::getLocStart() const {
+SourceLocation CXXTemporaryObjectExpr::getBeginLoc() const {
   return Type->getTypeLoc().getBeginLoc();
 }
 
@@ -1104,7 +1104,7 @@
   return new (Mem) CXXUnresolvedConstructExpr(Empty, NumArgs);
 }
 
-SourceLocation CXXUnresolvedConstructExpr::getLocStart() const {
+SourceLocation CXXUnresolvedConstructExpr::getBeginLoc() const {
   return Type->getTypeLoc().getBeginLoc();
 }
 
Index: lib/AST/Expr.cpp
===
--- lib/AST/Expr.cpp
+++ lib/AST/Expr.cpp
@@ -447,7 +447,7 @@
   return new (Mem) DeclRefExpr(EmptyShell());
 }
 
-SourceLocation DeclRefExpr::getLocStart() const {
+SourceLocation DeclRefExpr::getBeginLoc() const {
   if (hasQualifier())
 return getQualifierLoc().getBeginLoc();
   return getNameInfo().getLocStart();
@@ -1358,7 +1358,7 @@
   return FnType->getReturnType();
 }
 
-SourceLocation CallExpr::getLocStart() const {
+SourceLocation CallExpr::getBeginLoc() const {
   if (isa(this))
 return cast(this)->getLocStart();
 
@@ -1529,7 +1529,7 @@
   return E;
 }
 
-SourceLocation MemberExpr::getLocStart() const {
+SourceLocation MemberExpr::getBeginLoc() const {
   if (isImplicitAccess()) {
 if (hasQualifier())
   return getQualifierLoc().getBeginLoc();
@@ -2016,7 +2016,7 @@
   return Lit && Lit->getValue() == 0;
 }
 
-SourceLocation InitListExpr::getLocStart() const {
+SourceLocation InitListExpr::getBeginLoc() const {
   if (InitListExpr *SyntacticForm = getSyntacticForm())
 return SyntacticForm->getLocStart();
   SourceLocation Beg = LBraceLoc;
@@ -3847,7 +3847,7 @@
  DIE->getDesignator(size()-1)->getLocEnd());
 }
 
-SourceLocation DesignatedInitExpr::getLocStart() const {
+SourceLocation DesignatedInitExpr::getBeginLoc() const {
   SourceLocation StartLoc;
   auto *DIE = const_cast(this);
   Designator &First = *DIE->getDesignator(0);
@@ -3921,7 +3921,7 @@
   BaseAndUpdaterExprs[1] = ILE;
 }
 
-SourceLocation DesignatedInitUpdateExpr::getLocStart() const {
+SourceLocation DesignatedInitUpdateExpr::get

[PATCH] D50348: :Add getEndLoc API to replace getLocEnd

2018-08-06 Thread Stephen Kelly via Phabricator via cfe-commits
steveire created this revision.
Herald added a subscriber: cfe-commits.

Repository:
  rC Clang

https://reviews.llvm.org/D50348

Files:
  include/clang/AST/Comment.h
  include/clang/AST/Decl.h
  include/clang/AST/DeclBase.h
  include/clang/AST/DeclCXX.h
  include/clang/AST/DeclObjC.h
  include/clang/AST/DeclarationName.h
  include/clang/AST/Expr.h
  include/clang/AST/ExprCXX.h
  include/clang/AST/ExprObjC.h
  include/clang/AST/ExprOpenMP.h
  include/clang/AST/OpenMPClause.h
  include/clang/AST/RawCommentList.h
  include/clang/AST/Stmt.h
  include/clang/AST/StmtCXX.h
  include/clang/AST/StmtObjC.h
  include/clang/AST/StmtOpenMP.h
  include/clang/AST/TypeLoc.h
  include/clang/Sema/DeclSpec.h
  lib/AST/DeclObjC.cpp
  lib/AST/Expr.cpp
  lib/AST/ExprCXX.cpp
  lib/AST/Stmt.cpp
  lib/AST/StmtObjC.cpp
  lib/Sema/SemaChecking.cpp

Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -6126,7 +6126,8 @@
 return FExpr->getLocStart().getLocWithOffset(Offset);
   }
 
-  SourceLocation getLocEnd() const LLVM_READONLY { return FExpr->getLocEnd(); }
+  SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc();  }
+  SourceLocation getEndLoc() const LLVM_READONLY { return FExpr->getLocEnd(); }
 };
 
 }  // namespace
Index: lib/AST/StmtObjC.cpp
===
--- lib/AST/StmtObjC.cpp
+++ lib/AST/StmtObjC.cpp
@@ -64,7 +64,7 @@
   return new (Mem) ObjCAtTryStmt(EmptyShell(), NumCatchStmts, HasFinally);
 }
 
-SourceLocation ObjCAtTryStmt::getLocEnd() const {
+SourceLocation ObjCAtTryStmt::getEndLoc() const {
   if (HasFinally)
 return getFinallyStmt()->getLocEnd();
   if (NumCatchStmts)
Index: lib/AST/Stmt.cpp
===
--- lib/AST/Stmt.cpp
+++ lib/AST/Stmt.cpp
@@ -288,7 +288,7 @@
   llvm_unreachable("unknown statement kind");
 }
 
-SourceLocation Stmt::getLocEnd() const {
+SourceLocation Stmt::getEndLoc() const {
   switch (getStmtClass()) {
   case Stmt::NoStmtClass: llvm_unreachable("statement without class");
 #define ABSTRACT_STMT(type)
Index: lib/AST/ExprCXX.cpp
===
--- lib/AST/ExprCXX.cpp
+++ lib/AST/ExprCXX.cpp
@@ -250,7 +250,7 @@
   return QualType();
 }
 
-SourceLocation CXXPseudoDestructorExpr::getLocEnd() const {
+SourceLocation CXXPseudoDestructorExpr::getEndLoc() const {
   SourceLocation End = DestroyedType.getLocation();
   if (TypeSourceInfo *TInfo = DestroyedType.getTypeSourceInfo())
 End = TInfo->getTypeLoc().getLocalSourceRange().getEnd();
@@ -456,7 +456,7 @@
   return Loc;
 }
 
-SourceLocation CXXConstructExpr::getLocEnd() const {
+SourceLocation CXXConstructExpr::getEndLoc() const {
   if (isa(this))
 return cast(this)->getLocEnd();
 
@@ -695,7 +695,7 @@
   return getTypeInfoAsWritten()->getTypeLoc().getLocStart();
 }
 
-SourceLocation CXXFunctionalCastExpr::getLocEnd() const {
+SourceLocation CXXFunctionalCastExpr::getEndLoc() const {
   return RParenLoc.isValid() ? RParenLoc : getSubExpr()->getLocEnd();
 }
 
@@ -780,7 +780,7 @@
   return Type->getTypeLoc().getBeginLoc();
 }
 
-SourceLocation CXXTemporaryObjectExpr::getLocEnd() const {
+SourceLocation CXXTemporaryObjectExpr::getEndLoc() const {
   SourceLocation Loc = getParenOrBraceRange().getEnd();
   if (Loc.isInvalid() && getNumArgs())
 Loc = getArg(getNumArgs()-1)->getLocEnd();
Index: lib/AST/Expr.cpp
===
--- lib/AST/Expr.cpp
+++ lib/AST/Expr.cpp
@@ -452,7 +452,7 @@
 return getQualifierLoc().getBeginLoc();
   return getNameInfo().getLocStart();
 }
-SourceLocation DeclRefExpr::getLocEnd() const {
+SourceLocation DeclRefExpr::getEndLoc() const {
   if (hasExplicitTemplateArgs())
 return getRAngleLoc();
   return getNameInfo().getLocEnd();
@@ -1367,7 +1367,7 @@
 begin = getArg(0)->getLocStart();
   return begin;
 }
-SourceLocation CallExpr::getLocEnd() const {
+SourceLocation CallExpr::getEndLoc() const {
   if (isa(this))
 return cast(this)->getLocEnd();
 
@@ -1543,7 +1543,7 @@
 return BaseStartLoc;
   return MemberLoc;
 }
-SourceLocation MemberExpr::getLocEnd() const {
+SourceLocation MemberExpr::getEndLoc() const {
   SourceLocation EndLoc = getMemberNameInfo().getEndLoc();
   if (hasExplicitTemplateArgs())
 EndLoc = getRAngleLoc();
@@ -2034,7 +2034,7 @@
   return Beg;
 }
 
-SourceLocation InitListExpr::getLocEnd() const {
+SourceLocation InitListExpr::getEndLoc() const {
   if (InitListExpr *SyntacticForm = getSyntacticForm())
 return SyntacticForm->getLocEnd();
   SourceLocation End = RBraceLoc;
@@ -3862,7 +3862,7 @@
   return StartLoc;
 }
 
-SourceLocation DesignatedInitExpr::getLocEnd() const {
+SourceLocation DesignatedInitExpr::getEndLoc() const {
   return getInit()->getLocEnd();
 }
 
@@ -3925,7 +3925,7 @@
   return getBase()->getLocStart();

[PATCH] D50349: Port getStartLoc -> getBeginLoc

2018-08-06 Thread Stephen Kelly via Phabricator via cfe-commits
steveire created this revision.
Herald added a reviewer: teemperor.
Herald added a subscriber: cfe-commits.

Repository:
  rC Clang

https://reviews.llvm.org/D50349

Files:
  include/clang/AST/Decl.h
  lib/AST/ASTImporter.cpp
  lib/Analysis/CloneDetection.cpp
  lib/CodeGen/CoverageMappingGen.cpp
  lib/Sema/SemaStmt.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTWriterStmt.cpp
  lib/StaticAnalyzer/Core/ExprEngineCXX.cpp

Index: lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
+++ lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
@@ -530,7 +530,7 @@
   ProgramStateRef State = Pred->getState();
   const LocationContext *LCtx = Pred->getLocationContext();
   PrettyStackTraceLoc CrashInfo(getContext().getSourceManager(),
-CNE->getStartLoc(),
+CNE->getBeginLoc(),
 "Error evaluating New Allocator Call");
   CallEventManager &CEMgr = getStateManager().getCallEventManager();
   CallEventRef Call =
Index: lib/Serialization/ASTWriterStmt.cpp
===
--- lib/Serialization/ASTWriterStmt.cpp
+++ lib/Serialization/ASTWriterStmt.cpp
@@ -223,7 +223,7 @@
 
 void ASTStmtWriter::VisitDeclStmt(DeclStmt *S) {
   VisitStmt(S);
-  Record.AddSourceLocation(S->getStartLoc());
+  Record.AddSourceLocation(S->getBeginLoc());
   Record.AddSourceLocation(S->getEndLoc());
   DeclGroupRef DG = S->getDeclGroup();
   for (DeclGroupRef::iterator D = DG.begin(), DEnd = DG.end(); D != DEnd; ++D)
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -6875,7 +6875,7 @@
   if (!getDerived().AlwaysRebuild() && !DeclChanged)
 return S;
 
-  return getDerived().RebuildDeclStmt(Decls, S->getStartLoc(), S->getEndLoc());
+  return getDerived().RebuildDeclStmt(Decls, S->getBeginLoc(), S->getEndLoc());
 }
 
 template
Index: lib/Sema/SemaStmt.cpp
===
--- lib/Sema/SemaStmt.cpp
+++ lib/Sema/SemaStmt.cpp
@@ -2066,7 +2066,7 @@
   assert(DS && "first part of for range not a decl stmt");
 
   if (!DS->isSingleDecl()) {
-Diag(DS->getStartLoc(), diag::err_type_defined_in_for_range);
+Diag(DS->getBeginLoc(), diag::err_type_defined_in_for_range);
 return StmtError();
   }
 
Index: lib/CodeGen/CoverageMappingGen.cpp
===
--- lib/CodeGen/CoverageMappingGen.cpp
+++ lib/CodeGen/CoverageMappingGen.cpp
@@ -117,7 +117,7 @@
   }
 
   SpellingRegion(SourceManager &SM, SourceMappingRegion &R)
-  : SpellingRegion(SM, R.getStartLoc(), R.getEndLoc()) {}
+  : SpellingRegion(SM, R.getBeginLoc(), R.getEndLoc()) {}
 
   /// Check if the start and end locations appear in source order, i.e
   /// top->bottom, left->right.
@@ -230,7 +230,7 @@
 llvm::SmallSet Visited;
 SmallVector, 8> FileLocs;
 for (const auto &Region : SourceRegions) {
-  SourceLocation Loc = Region.getStartLoc();
+  SourceLocation Loc = Region.getBeginLoc();
   FileID File = SM.getFileID(Loc);
   if (!Visited.insert(File).second)
 continue;
@@ -312,7 +312,7 @@
 for (const auto &Region : SourceRegions) {
   assert(Region.hasEndLoc() && "incomplete region");
 
-  SourceLocation LocStart = Region.getStartLoc();
+  SourceLocation LocStart = Region.getBeginLoc();
   assert(SM.getFileID(LocStart).isValid() && "region in invalid file");
 
   // Ignore regions from system headers.
@@ -503,7 +503,7 @@
 DeferredRegion = None;
 
 // If the region ends in an expansion, find the expansion site.
-FileID StartFile = SM.getFileID(DR.getStartLoc());
+FileID StartFile = SM.getFileID(DR.getBeginLoc());
 if (SM.getFileID(DeferredEndLoc) != StartFile) {
   if (isNestedIn(DeferredEndLoc, StartFile)) {
 do {
@@ -516,12 +516,12 @@
 
 // The parent of this deferred region ends where the containing decl ends,
 // so the region isn't useful.
-if (DR.getStartLoc() == DeferredEndLoc)
+if (DR.getBeginLoc() == DeferredEndLoc)
   return Index;
 
 // If we're visiting statements in non-source order (e.g switch cases or
 // a loop condition) we can't construct a sensible deferred region.
-if (!SpellingRegion(SM, DR.getStartLoc(), DeferredEndLoc).isInSourceOrder())
+if (!SpellingRegion(SM, DR.getBeginLoc(), DeferredEndLoc).isInSourceOrder())
   return Index;
 
 DR.setGap(true);
@@ -563,7 +563,7 @@
 while (RegionStack.size() > ParentIndex) {
   SourceMappingRegion &Region = RegionStack.back();
   if (Region.hasStartLoc()) {
-SourceLocation StartLoc = Region.getStartLoc();
+SourceLocation StartLoc = Region.getBeginLoc();
 SourceLocation EndLoc = Region.hasEndLoc()
 

[PATCH] D50347: Add getBeginLoc API to replace getStartLoc

2018-08-06 Thread Stephen Kelly via Phabricator via cfe-commits
steveire created this revision.
Herald added a reviewer: teemperor.
Herald added a subscriber: cfe-commits.

Repository:
  rC Clang

https://reviews.llvm.org/D50347

Files:
  include/clang/AST/ExprCXX.h
  include/clang/AST/Stmt.h
  include/clang/Analysis/CloneDetection.h
  lib/CodeGen/CoverageMappingGen.cpp


Index: lib/CodeGen/CoverageMappingGen.cpp
===
--- lib/CodeGen/CoverageMappingGen.cpp
+++ lib/CodeGen/CoverageMappingGen.cpp
@@ -67,7 +67,8 @@
 
   void setStartLoc(SourceLocation Loc) { LocStart = Loc; }
 
-  SourceLocation getStartLoc() const {
+  SourceLocation getStartLoc() const LLVM_READONLY { return getBeginLoc();  }
+  SourceLocation getBeginLoc() const {
 assert(LocStart && "Region has no start location");
 return *LocStart;
   }
Index: include/clang/Analysis/CloneDetection.h
===
--- include/clang/Analysis/CloneDetection.h
+++ include/clang/Analysis/CloneDetection.h
@@ -122,7 +122,8 @@
   /// Returns the start sourcelocation of the first statement in this sequence.
   ///
   /// This method should only be called on a non-empty StmtSequence object.
-  SourceLocation getStartLoc() const;
+  SourceLocation getStartLoc() const LLVM_READONLY { return getBeginLoc();  }
+  SourceLocation getBeginLoc() const;
 
   /// Returns the end sourcelocation of the last statement in this sequence.
   ///
Index: include/clang/AST/Stmt.h
===
--- include/clang/AST/Stmt.h
+++ include/clang/AST/Stmt.h
@@ -523,7 +523,7 @@
   DeclGroupRef getDeclGroup() { return DG; }
   void setDeclGroup(DeclGroupRef DGR) { DG = DGR; }
 
-  SourceLocation getStartLoc() const { return StartLoc; }
+  SourceLocation getStartLoc() const LLVM_READONLY { return getBeginLoc();  }
   void setStartLoc(SourceLocation L) { StartLoc = L; }
   SourceLocation getEndLoc() const { return EndLoc; }
   void setEndLoc(SourceLocation L) { EndLoc = L; }
Index: include/clang/AST/ExprCXX.h
===
--- include/clang/AST/ExprCXX.h
+++ include/clang/AST/ExprCXX.h
@@ -2069,7 +2069,8 @@
 return SubExprs + Array + hasInitializer() + getNumPlacementArgs();
   }
 
-  SourceLocation getStartLoc() const { return Range.getBegin(); }
+  SourceLocation getStartLoc() const LLVM_READONLY { return getBeginLoc();  }
+  SourceLocation getBeginLoc() const { return Range.getBegin(); }
   SourceLocation getEndLoc() const { return Range.getEnd(); }
 
   SourceRange getDirectInitRange() const { return DirectInitRange; }
@@ -2079,7 +2080,6 @@
   }
 
   SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc();  }
-  SourceLocation getBeginLoc() const LLVM_READONLY { return getStartLoc(); }
   SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
 
   static bool classof(const Stmt *T) {


Index: lib/CodeGen/CoverageMappingGen.cpp
===
--- lib/CodeGen/CoverageMappingGen.cpp
+++ lib/CodeGen/CoverageMappingGen.cpp
@@ -67,7 +67,8 @@
 
   void setStartLoc(SourceLocation Loc) { LocStart = Loc; }
 
-  SourceLocation getStartLoc() const {
+  SourceLocation getStartLoc() const LLVM_READONLY { return getBeginLoc();  }
+  SourceLocation getBeginLoc() const {
 assert(LocStart && "Region has no start location");
 return *LocStart;
   }
Index: include/clang/Analysis/CloneDetection.h
===
--- include/clang/Analysis/CloneDetection.h
+++ include/clang/Analysis/CloneDetection.h
@@ -122,7 +122,8 @@
   /// Returns the start sourcelocation of the first statement in this sequence.
   ///
   /// This method should only be called on a non-empty StmtSequence object.
-  SourceLocation getStartLoc() const;
+  SourceLocation getStartLoc() const LLVM_READONLY { return getBeginLoc();  }
+  SourceLocation getBeginLoc() const;
 
   /// Returns the end sourcelocation of the last statement in this sequence.
   ///
Index: include/clang/AST/Stmt.h
===
--- include/clang/AST/Stmt.h
+++ include/clang/AST/Stmt.h
@@ -523,7 +523,7 @@
   DeclGroupRef getDeclGroup() { return DG; }
   void setDeclGroup(DeclGroupRef DGR) { DG = DGR; }
 
-  SourceLocation getStartLoc() const { return StartLoc; }
+  SourceLocation getStartLoc() const LLVM_READONLY { return getBeginLoc();  }
   void setStartLoc(SourceLocation L) { StartLoc = L; }
   SourceLocation getEndLoc() const { return EndLoc; }
   void setEndLoc(SourceLocation L) { EndLoc = L; }
Index: include/clang/AST/ExprCXX.h
===
--- include/clang/AST/ExprCXX.h
+++ include/clang/AST/ExprCXX.h
@@ -2069,7 +2069,8 @@
 return SubExprs + Array + hasInitializer() + getNumPlacementArgs();
   }
 
-  SourceLocation getStartLoc() const { return

[PATCH] D50350: Port getLocStart -> getBeginLoc

2018-08-06 Thread Stephen Kelly via Phabricator via cfe-commits
steveire created this revision.
Herald added subscribers: cfe-commits, jfb, whisperity, jholewinski.
Herald added a reviewer: teemperor.

Repository:
  rC Clang

https://reviews.llvm.org/D50350

Files:
  docs/RAVFrontendAction.rst
  include/clang/AST/Comment.h
  include/clang/AST/Decl.h
  include/clang/AST/DeclCXX.h
  include/clang/AST/DeclObjC.h
  include/clang/AST/DeclarationName.h
  include/clang/AST/Expr.h
  include/clang/AST/ExprCXX.h
  include/clang/AST/ExprObjC.h
  include/clang/AST/ExprOpenMP.h
  include/clang/AST/LexicallyOrderedRecursiveASTVisitor.h
  include/clang/AST/RawCommentList.h
  include/clang/AST/Stmt.h
  include/clang/AST/StmtCXX.h
  include/clang/AST/StmtDataCollectors.td
  include/clang/ASTMatchers/ASTMatchers.h
  include/clang/Sema/Initialization.h
  include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
  lib/ARCMigrate/ObjCMT.cpp
  lib/ARCMigrate/TransAPIUses.cpp
  lib/ARCMigrate/TransAutoreleasePool.cpp
  lib/ARCMigrate/TransGCCalls.cpp
  lib/ARCMigrate/TransProtectedScope.cpp
  lib/ARCMigrate/TransRetainReleaseDealloc.cpp
  lib/ARCMigrate/TransUnbridgedCasts.cpp
  lib/ARCMigrate/TransformActions.cpp
  lib/AST/ASTContext.cpp
  lib/AST/ASTDumper.cpp
  lib/AST/ASTImporter.cpp
  lib/AST/ASTStructuralEquivalence.cpp
  lib/AST/Decl.cpp
  lib/AST/DeclObjC.cpp
  lib/AST/DeclOpenMP.cpp
  lib/AST/DeclTemplate.cpp
  lib/AST/Expr.cpp
  lib/AST/ExprCXX.cpp
  lib/AST/ExprConstant.cpp
  lib/AST/RawCommentList.cpp
  lib/AST/SelectorLocationsKind.cpp
  lib/AST/Stmt.cpp
  lib/AST/StmtPrinter.cpp
  lib/Analysis/AnalysisDeclContext.cpp
  lib/Analysis/CloneDetection.cpp
  lib/Analysis/Consumed.cpp
  lib/Analysis/LiveVariables.cpp
  lib/Analysis/ReachableCode.cpp
  lib/Analysis/ThreadSafety.cpp
  lib/CodeGen/CGAtomic.cpp
  lib/CodeGen/CGBlocks.cpp
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGClass.cpp
  lib/CodeGen/CGCoroutine.cpp
  lib/CodeGen/CGDeclCXX.cpp
  lib/CodeGen/CGException.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprCXX.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/CodeGen/CGObjC.cpp
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  lib/CodeGen/CGStmt.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenPGO.cpp
  lib/CodeGen/CoverageMappingGen.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/Edit/RewriteObjCFoundationAPI.cpp
  lib/Frontend/Rewrite/RewriteModernObjC.cpp
  lib/Frontend/Rewrite/RewriteObjC.cpp
  lib/Index/IndexBody.cpp
  lib/Index/IndexDecl.cpp
  lib/Index/USRGeneration.cpp
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseExpr.cpp
  lib/Parse/ParseExprCXX.cpp
  lib/Parse/ParseObjc.cpp
  lib/Parse/ParseStmt.cpp
  lib/Sema/AnalysisBasedWarnings.cpp
  lib/Sema/JumpDiagnostics.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaAttr.cpp
  lib/Sema/SemaCast.cpp
  lib/Sema/SemaChecking.cpp
  lib/Sema/SemaCoroutine.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaDeclObjC.cpp
  lib/Sema/SemaExceptionSpec.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaExprObjC.cpp
  lib/Sema/SemaInit.cpp
  lib/Sema/SemaLambda.cpp
  lib/Sema/SemaLookup.cpp
  lib/Sema/SemaObjCProperty.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Sema/SemaOverload.cpp
  lib/Sema/SemaPseudoObject.cpp
  lib/Sema/SemaStmt.cpp
  lib/Sema/SemaStmtAsm.cpp
  lib/Sema/SemaStmtAttr.cpp
  lib/Sema/SemaTemplate.cpp
  lib/Sema/SemaTemplateDeduction.cpp
  lib/Sema/SemaTemplateInstantiate.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  lib/Sema/SemaTemplateVariadic.cpp
  lib/Sema/SemaType.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTWriter.cpp
  lib/Serialization/ASTWriterDecl.cpp
  lib/Serialization/ASTWriterStmt.cpp
  lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
  lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
  lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp
  lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
  lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp
  lib/StaticAnalyzer/Checkers/ObjCUnusedIVarsChecker.cpp
  lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
  lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
  lib/StaticAnalyzer/Checkers/TraversalChecker.cpp
  lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
  lib/StaticAnalyzer/Core/BugReporter.cpp
  lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  lib/StaticAnalyzer/Core/CheckerHelpers.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
  lib/StaticAnalyzer/Core/PathDiagnostic.cpp
  lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
  lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
  lib/Tooling/Refactoring/Extract/Extract.cpp
  lib/Tooling/Refactoring/Rename/USRFinder.cpp
  lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
  tools/clang-func-mapping/ClangFnMapGen.cpp
  tools/libclang/CIndex.cpp
  tools/libclang/CXIndexDataConsumer.cpp
  unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cp

[PATCH] D50353: Remove deprecated API

2018-08-06 Thread Stephen Kelly via Phabricator via cfe-commits
steveire created this revision.
Herald added a reviewer: teemperor.
Herald added a subscriber: cfe-commits.
Herald added a reviewer: teemperor.

Repository:
  rC Clang

https://reviews.llvm.org/D50353

Files:
  include/clang/AST/Comment.h
  include/clang/AST/Decl.h
  include/clang/AST/DeclBase.h
  include/clang/AST/DeclCXX.h
  include/clang/AST/DeclObjC.h
  include/clang/AST/DeclarationName.h
  include/clang/AST/Expr.h
  include/clang/AST/ExprCXX.h
  include/clang/AST/ExprObjC.h
  include/clang/AST/ExprOpenMP.h
  include/clang/AST/OpenMPClause.h
  include/clang/AST/RawCommentList.h
  include/clang/AST/Stmt.h
  include/clang/AST/StmtCXX.h
  include/clang/AST/StmtObjC.h
  include/clang/AST/StmtOpenMP.h
  include/clang/AST/TypeLoc.h
  include/clang/Analysis/CloneDetection.h
  include/clang/Sema/DeclSpec.h
  lib/CodeGen/CoverageMappingGen.cpp
  lib/Sema/SemaChecking.cpp

Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -6121,12 +6121,10 @@
 StartToken, StartTokenByteOffset);
   }
 
-  [[deprecated]] SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc();  }
   SourceLocation getBeginLoc() const LLVM_READONLY {
 return FExpr->getBeginLoc().getLocWithOffset(Offset);
   }
 
-  [[deprecated]] SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc();  }
   SourceLocation getEndLoc() const LLVM_READONLY { return FExpr->getEndLoc(); }
 };
 
Index: lib/CodeGen/CoverageMappingGen.cpp
===
--- lib/CodeGen/CoverageMappingGen.cpp
+++ lib/CodeGen/CoverageMappingGen.cpp
@@ -67,7 +67,6 @@
 
   void setStartLoc(SourceLocation Loc) { LocStart = Loc; }
 
-  [[deprecated]] SourceLocation getStartLoc() const LLVM_READONLY { return getBeginLoc();  }
   SourceLocation getBeginLoc() const {
 assert(LocStart && "Region has no start location");
 return *LocStart;
Index: include/clang/Sema/DeclSpec.h
===
--- include/clang/Sema/DeclSpec.h
+++ include/clang/Sema/DeclSpec.h
@@ -505,9 +505,7 @@
   const CXXScopeSpec &getTypeSpecScope() const { return TypeScope; }
 
   SourceRange getSourceRange() const LLVM_READONLY { return Range; }
-  [[deprecated]] SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc();  }
   SourceLocation getBeginLoc() const LLVM_READONLY { return Range.getBegin(); }
-  [[deprecated]] SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc();  }
   SourceLocation getEndLoc() const LLVM_READONLY { return Range.getEnd(); }
 
   SourceLocation getTypeSpecWidthLoc() const { return TSWRange.getBegin(); }
@@ -1122,9 +1120,7 @@
   SourceRange getSourceRange() const LLVM_READONLY {
 return SourceRange(StartLocation, EndLocation);
   }
-  [[deprecated]] SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc();  }
   SourceLocation getBeginLoc() const LLVM_READONLY { return StartLocation; }
-  [[deprecated]] SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc();  }
   SourceLocation getEndLoc() const LLVM_READONLY { return EndLocation; }
 };
 
@@ -1874,9 +1870,7 @@
 
   /// Get the source range that spans this declarator.
   SourceRange getSourceRange() const LLVM_READONLY { return Range; }
-  [[deprecated]] SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc();  }
   SourceLocation getBeginLoc() const LLVM_READONLY { return Range.getBegin(); }
-  [[deprecated]] SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc();  }
   SourceLocation getEndLoc() const LLVM_READONLY { return Range.getEnd(); }
 
   void SetSourceRange(SourceRange R) { Range = R; }
Index: include/clang/Analysis/CloneDetection.h
===
--- include/clang/Analysis/CloneDetection.h
+++ include/clang/Analysis/CloneDetection.h
@@ -122,7 +122,6 @@
   /// Returns the start sourcelocation of the first statement in this sequence.
   ///
   /// This method should only be called on a non-empty StmtSequence object.
-  [[deprecated]] SourceLocation getStartLoc() const LLVM_READONLY { return getBeginLoc();  }
   SourceLocation getBeginLoc() const;
 
   /// Returns the end sourcelocation of the last statement in this sequence.
Index: include/clang/AST/TypeLoc.h
===
--- include/clang/AST/TypeLoc.h
+++ include/clang/AST/TypeLoc.h
@@ -151,8 +151,6 @@
 return SourceRange(getBeginLoc(), getEndLoc());
   }
 
-  [[deprecated]] SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc();  }
-  [[deprecated]] SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc();  }
 
   /// Get the local source range.
   SourceRange getLocalSourceRange() const {
Index: include/clang/AST/StmtOpenMP.h

[PATCH] D50355: Port getLocEnd -> getEndLoc

2018-08-06 Thread Stephen Kelly via Phabricator via cfe-commits
steveire created this revision.
Herald added subscribers: cfe-commits, kbarton, ioeric, nemanjai.

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50355

Files:
  change-namespace/ChangeNamespace.cpp
  clang-move/ClangMove.cpp
  clang-tidy/android/CloexecCheck.cpp
  clang-tidy/bugprone/ArgumentCommentCheck.cpp
  clang-tidy/bugprone/CopyConstructorInitCheck.cpp
  clang-tidy/bugprone/InaccurateEraseCheck.cpp
  clang-tidy/bugprone/MoveForwardingReferenceCheck.cpp
  clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
  clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp
  clang-tidy/bugprone/UnusedRaiiCheck.cpp
  clang-tidy/cppcoreguidelines/NoMallocCheck.cpp
  clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
  clang-tidy/cppcoreguidelines/ProTypeCstyleCastCheck.cpp
  clang-tidy/fuchsia/DefaultArgumentsCheck.cpp
  clang-tidy/google/AvoidCStyleCastsCheck.cpp
  clang-tidy/google/ExplicitConstructorCheck.cpp
  clang-tidy/llvm/TwineLocalCheck.cpp
  clang-tidy/misc/RedundantExpressionCheck.cpp
  clang-tidy/misc/StaticAssertCheck.cpp
  clang-tidy/misc/UnusedAliasDeclsCheck.cpp
  clang-tidy/misc/UnusedParametersCheck.cpp
  clang-tidy/misc/UnusedUsingDeclsCheck.cpp
  clang-tidy/modernize/AvoidBindCheck.cpp
  clang-tidy/modernize/MakeSmartPtrCheck.cpp
  clang-tidy/modernize/PassByValueCheck.cpp
  clang-tidy/modernize/RedundantVoidArgCheck.cpp
  clang-tidy/modernize/UseEmplaceCheck.cpp
  clang-tidy/modernize/UseEqualsDeleteCheck.cpp
  clang-tidy/modernize/UseNullptrCheck.cpp
  clang-tidy/modernize/UseUncaughtExceptionsCheck.cpp
  clang-tidy/performance/FasterStringFindCheck.cpp
  clang-tidy/performance/MoveConstArgCheck.cpp
  clang-tidy/readability/AvoidConstParamsInDecls.cpp
  clang-tidy/readability/BracesAroundStatementsCheck.cpp
  clang-tidy/readability/DeleteNullPointerCheck.cpp
  clang-tidy/readability/FunctionSizeCheck.cpp
  clang-tidy/readability/ImplicitBoolConversionCheck.cpp
  clang-tidy/readability/MisleadingIndentationCheck.cpp
  clang-tidy/readability/RedundantControlFlowCheck.cpp
  clang-tidy/readability/SimplifyBooleanExprCheck.cpp
  clang-tidy/readability/SimplifySubscriptExprCheck.cpp
  clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp
  unittests/clang-tidy/OverlappingReplacementsTest.cpp

Index: unittests/clang-tidy/OverlappingReplacementsTest.cpp
===
--- unittests/clang-tidy/OverlappingReplacementsTest.cpp
+++ unittests/clang-tidy/OverlappingReplacementsTest.cpp
@@ -52,7 +52,7 @@
 auto *Cond = If->getCond();
 SourceRange Range = Cond->getSourceRange();
 if (auto *D = If->getConditionVariable()) {
-  Range = SourceRange(D->getBeginLoc(), D->getLocEnd());
+  Range = SourceRange(D->getBeginLoc(), D->getEndLoc());
 }
 diag(Range.getBegin(), "the cake is a lie") << FixItHint::CreateReplacement(
 CharSourceRange::getTokenRange(Range), "false");
Index: clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp
===
--- clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp
+++ clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp
@@ -52,15 +52,15 @@
 return;
 
   SourceLocation AfterPtr = Lexer::getLocForEndOfToken(
-  PtrExpr->getLocEnd(), 0, *Result.SourceManager, getLangOpts());
+  PtrExpr->getEndLoc(), 0, *Result.SourceManager, getLangOpts());
 
   diag(DeleteExpr->getBeginLoc(),
"prefer '= nullptr' to 'delete x.release()' to reset unique_ptr<> "
"objects")
   << FixItHint::CreateRemoval(CharSourceRange::getCharRange(
  DeleteExpr->getBeginLoc(), PtrExpr->getBeginLoc()))
   << FixItHint::CreateReplacement(
- CharSourceRange::getTokenRange(AfterPtr, DeleteExpr->getLocEnd()),
+ CharSourceRange::getTokenRange(AfterPtr, DeleteExpr->getEndLoc()),
  " = nullptr");
 }
 
Index: clang-tidy/readability/SimplifySubscriptExprCheck.cpp
===
--- clang-tidy/readability/SimplifySubscriptExprCheck.cpp
+++ clang-tidy/readability/SimplifySubscriptExprCheck.cpp
@@ -63,7 +63,7 @@
 DiagBuilder << FixItHint::CreateInsertion(Member->getBeginLoc(), "(*")
 << FixItHint::CreateInsertion(Member->getOperatorLoc(), ")");
   DiagBuilder << FixItHint::CreateRemoval(
-  {Member->getOperatorLoc(), Call->getLocEnd()});
+  {Member->getOperatorLoc(), Call->getEndLoc()});
 }
 
 void SimplifySubscriptExprCheck::storeOptions(
Index: clang-tidy/readability/SimplifyBooleanExprCheck.cpp
===
--- clang-tidy/readability/SimplifyBooleanExprCheck.cpp
+++ clang-tidy/readability/SimplifyBooleanExprCheck.cpp
@@ -385,7 +385,7 @@
const Expr *ReplaceWith, bool Negated) {
 std::string Replacement =
 replacementExpression(Result, Negated, ReplaceWith);
-SourceRange Range(LHS->getB

r339048 - [MinGW] Predefine UNICODE if -municode is specified during compilation

2018-08-06 Thread Martin Storsjo via cfe-commits
Author: mstorsjo
Date: Mon Aug  6 12:48:44 2018
New Revision: 339048

URL: http://llvm.org/viewvc/llvm-project?rev=339048&view=rev
Log:
[MinGW] Predefine UNICODE if -municode is specified during compilation

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/test/Driver/mingw.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=339048&r1=339047&r2=339048&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Mon Aug  6 12:48:44 2018
@@ -3346,6 +3346,9 @@ void Clang::ConstructJob(Compilation &C,
   if (Args.hasArg(options::OPT_static))
 CmdArgs.push_back("-static-define");
 
+  if (Args.hasArg(options::OPT_municode))
+CmdArgs.push_back("-DUNICODE");
+
   if (isa(JA))
 RenderAnalyzerOptions(Args, CmdArgs, Triple, Input);
 

Modified: cfe/trunk/test/Driver/mingw.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/mingw.cpp?rev=339048&r1=339047&r2=339048&view=diff
==
--- cfe/trunk/test/Driver/mingw.cpp (original)
+++ cfe/trunk/test/Driver/mingw.cpp Mon Aug  6 12:48:44 2018
@@ -56,3 +56,8 @@
 // CHECK_MINGW_UBUNTU_POSIX_TREE: 
"{{.*}}/Inputs/mingw_ubuntu_posix_tree/usr{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}5.3-posix{{/|}}include{{/|}}c++{{/|}}x86_64-w64-mingw32"
 // CHECK_MINGW_UBUNTU_POSIX_TREE: 
"{{.*}}/Inputs/mingw_ubuntu_posix_tree/usr{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}5.3-posix{{/|}}include{{/|}}c++{{/|}}backward"
 // CHECK_MINGW_UBUNTU_POSIX_TREE: 
"{{.*}}/Inputs/mingw_ubuntu_posix_tree/usr{{/|}}x86_64-w64-mingw32{{/|}}include"
+
+// RUN: %clang -target i686-windows-gnu -E -### %s 2>&1 | FileCheck 
-check-prefix=CHECK_MINGW_NO_UNICODE %s
+// RUN: %clang -target i686-windows-gnu -E -### %s -municode 2>&1 | FileCheck 
-check-prefix=CHECK_MINGW_UNICODE %s
+// CHECK_MINGW_NO_UNICODE-NOT: "-DUNICODE"
+// CHECK_MINGW_UNICODE: "-DUNICODE"


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


[PATCH] D50199: [MinGW] Predefine UNICODE if -municode is specified during compilation

2018-08-06 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC339048: [MinGW] Predefine UNICODE if -municode is specified 
during compilation (authored by mstorsjo, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D50199

Files:
  lib/Driver/ToolChains/Clang.cpp
  test/Driver/mingw.cpp


Index: test/Driver/mingw.cpp
===
--- test/Driver/mingw.cpp
+++ test/Driver/mingw.cpp
@@ -56,3 +56,8 @@
 // CHECK_MINGW_UBUNTU_POSIX_TREE: 
"{{.*}}/Inputs/mingw_ubuntu_posix_tree/usr{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}5.3-posix{{/|}}include{{/|}}c++{{/|}}x86_64-w64-mingw32"
 // CHECK_MINGW_UBUNTU_POSIX_TREE: 
"{{.*}}/Inputs/mingw_ubuntu_posix_tree/usr{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}5.3-posix{{/|}}include{{/|}}c++{{/|}}backward"
 // CHECK_MINGW_UBUNTU_POSIX_TREE: 
"{{.*}}/Inputs/mingw_ubuntu_posix_tree/usr{{/|}}x86_64-w64-mingw32{{/|}}include"
+
+// RUN: %clang -target i686-windows-gnu -E -### %s 2>&1 | FileCheck 
-check-prefix=CHECK_MINGW_NO_UNICODE %s
+// RUN: %clang -target i686-windows-gnu -E -### %s -municode 2>&1 | FileCheck 
-check-prefix=CHECK_MINGW_UNICODE %s
+// CHECK_MINGW_NO_UNICODE-NOT: "-DUNICODE"
+// CHECK_MINGW_UNICODE: "-DUNICODE"
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -3346,6 +3346,9 @@
   if (Args.hasArg(options::OPT_static))
 CmdArgs.push_back("-static-define");
 
+  if (Args.hasArg(options::OPT_municode))
+CmdArgs.push_back("-DUNICODE");
+
   if (isa(JA))
 RenderAnalyzerOptions(Args, CmdArgs, Triple, Input);
 


Index: test/Driver/mingw.cpp
===
--- test/Driver/mingw.cpp
+++ test/Driver/mingw.cpp
@@ -56,3 +56,8 @@
 // CHECK_MINGW_UBUNTU_POSIX_TREE: "{{.*}}/Inputs/mingw_ubuntu_posix_tree/usr{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}5.3-posix{{/|}}include{{/|}}c++{{/|}}x86_64-w64-mingw32"
 // CHECK_MINGW_UBUNTU_POSIX_TREE: "{{.*}}/Inputs/mingw_ubuntu_posix_tree/usr{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}5.3-posix{{/|}}include{{/|}}c++{{/|}}backward"
 // CHECK_MINGW_UBUNTU_POSIX_TREE: "{{.*}}/Inputs/mingw_ubuntu_posix_tree/usr{{/|}}x86_64-w64-mingw32{{/|}}include"
+
+// RUN: %clang -target i686-windows-gnu -E -### %s 2>&1 | FileCheck -check-prefix=CHECK_MINGW_NO_UNICODE %s
+// RUN: %clang -target i686-windows-gnu -E -### %s -municode 2>&1 | FileCheck -check-prefix=CHECK_MINGW_UNICODE %s
+// CHECK_MINGW_NO_UNICODE-NOT: "-DUNICODE"
+// CHECK_MINGW_UNICODE: "-DUNICODE"
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -3346,6 +3346,9 @@
   if (Args.hasArg(options::OPT_static))
 CmdArgs.push_back("-static-define");
 
+  if (Args.hasArg(options::OPT_municode))
+CmdArgs.push_back("-DUNICODE");
+
   if (isa(JA))
 RenderAnalyzerOptions(Args, CmdArgs, Triple, Input);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50347: Add getBeginLoc API to replace getStartLoc

2018-08-06 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor resigned from this revision.
teemperor added a comment.
This revision now requires review to proceed.

Woops, I wanted to resign actually (and not accept this).


Repository:
  rC Clang

https://reviews.llvm.org/D50347



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


[PATCH] D50342: Changed how LLVM IR was generated to increase vectorization

2018-08-06 Thread Emmett Neyman via Phabricator via cfe-commits
emmettneyman added inline comments.



Comment at: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp:125
 std::ostream &operator<<(std::ostream &os, const LoopFunction &x) {
-  return os << "define void @foo(i32* %a, i32* %b, i32* noalias %c, i64 %s) 
{\n"
-<< "%i = alloca i64\n"
-<< "store i64 0, i64* %i\n"
-<< "br label %loop\n\n"
-<< "loop:\n"
-<< "%ct = load i64, i64* %i\n"
-<< "%comp = icmp eq i64 %ct, %s\n"
-<< "br i1 %comp, label %endloop, label %body\n\n"
-<< "body:\n"
+  return os << "target triple = \"x86_64-pc-linux-gnu\"\n"
+<< "define void @foo(i32*, i32*, i32*, i64) {\n"

morehouse wrote:
> What does `pc` mean in this triple?  I'm used to seeing 
> `x86_64-unknown-linux-gnu`.
It's probably generating `pc` since I'm using my desktop. I'll change it to 
`unknown` so it's not platform-specific.



Comment at: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp:126
+  return os << "target triple = \"x86_64-pc-linux-gnu\"\n"
+<< "define void @foo(i32*, i32*, i32*, i64) {\n"
+<< "%5 = icmp sgt i64 %3, 0\n"

morehouse wrote:
> Does removing the variable names really make this easier to vectorize?
It doesn't, I just thought it was cleaner and produced slightly smaller IR. It 
also more closely mimics the behavior of the `-emit-llvm` flag.



Comment at: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp:129
+<< "br i1 %5, label %6, label %8\n"
+<< "; :6:\n"
+<< "br label %9\n"

morehouse wrote:
> Does removing branch names really make this easier to vectorize?
Same answer as above. Should I change these back?


Repository:
  rC Clang

https://reviews.llvm.org/D50342



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


[PATCH] D50342: Changed how LLVM IR was generated to increase vectorization

2018-08-06 Thread Emmett Neyman via Phabricator via cfe-commits
emmettneyman updated this revision to Diff 159373.
emmettneyman added a comment.

Changed pc to unknown


Repository:
  rC Clang

https://reviews.llvm.org/D50342

Files:
  clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp


Index: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp
===
--- clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp
+++ clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp
@@ -43,17 +43,17 @@
   std::string arr;
   switch(x.arr()) {
   case VarRef::ARR_A:
-arr = "%a";
+arr = "%0";
 break;
   case VarRef::ARR_B:
-arr = "%b";
+arr = "%1";
 break;
   case VarRef::ARR_C:
-arr = "%c";
+arr = "%2";
 break;
   }
   std::string ptr_var = get_var();
-  os << ptr_var << " = getelementptr i32, i32* " << arr << ", i64 %ct\n";
+  os << ptr_var << " = getelementptr inbounds i32, i32* " << arr << ", i64 
%ct\n";
   return ptr_var;
 }
 std::string RvalueToString(std::ostream &os, const Rvalue &x) {
@@ -122,21 +122,22 @@
   return os;
 }
 std::ostream &operator<<(std::ostream &os, const LoopFunction &x) {
-  return os << "define void @foo(i32* %a, i32* %b, i32* noalias %c, i64 %s) 
{\n"
-<< "%i = alloca i64\n"
-<< "store i64 0, i64* %i\n"
-<< "br label %loop\n\n"
-<< "loop:\n"
-<< "%ct = load i64, i64* %i\n"
-<< "%comp = icmp eq i64 %ct, %s\n"
-<< "br i1 %comp, label %endloop, label %body\n\n"
-<< "body:\n"
+  return os << "target triple = \"x86_64-unknown-linux-gnu\"\n"
+<< "define void @foo(i32*, i32*, i32*, i64) {\n"
+<< "%5 = icmp sgt i64 %3, 0\n"
+<< "br i1 %5, label %6, label %8\n"
+<< "; :6:\n"
+<< "br label %9\n"
+<< "; :7:\n"
+<< "br label %8\n"
+<< "; :8:\n"
+<< "ret void\n"
+<< "; :9:\n"
+<< " %ct   = phi i64 [ %10, %9 ], [ 0, %6 ]\n"
 << x.statements()
-<< "%z = add i64 1, %ct\n"
-<< "store i64 %z, i64* %i\n"
-<< "br label %loop\n\n"
-<< "endloop:\n"
-<< "ret void\n}\n";
+<< "%10 = add nuw nsw i64 %ct, 1\n"
+<< "%11 = icmp eq i64 %10, %3\n"
+<< "br i1 %11, label %7, label %9\n}\n";
 }
 
 // -


Index: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp
===
--- clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp
+++ clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp
@@ -43,17 +43,17 @@
   std::string arr;
   switch(x.arr()) {
   case VarRef::ARR_A:
-arr = "%a";
+arr = "%0";
 break;
   case VarRef::ARR_B:
-arr = "%b";
+arr = "%1";
 break;
   case VarRef::ARR_C:
-arr = "%c";
+arr = "%2";
 break;
   }
   std::string ptr_var = get_var();
-  os << ptr_var << " = getelementptr i32, i32* " << arr << ", i64 %ct\n";
+  os << ptr_var << " = getelementptr inbounds i32, i32* " << arr << ", i64 %ct\n";
   return ptr_var;
 }
 std::string RvalueToString(std::ostream &os, const Rvalue &x) {
@@ -122,21 +122,22 @@
   return os;
 }
 std::ostream &operator<<(std::ostream &os, const LoopFunction &x) {
-  return os << "define void @foo(i32* %a, i32* %b, i32* noalias %c, i64 %s) {\n"
-<< "%i = alloca i64\n"
-<< "store i64 0, i64* %i\n"
-<< "br label %loop\n\n"
-<< "loop:\n"
-<< "%ct = load i64, i64* %i\n"
-<< "%comp = icmp eq i64 %ct, %s\n"
-<< "br i1 %comp, label %endloop, label %body\n\n"
-<< "body:\n"
+  return os << "target triple = \"x86_64-unknown-linux-gnu\"\n"
+<< "define void @foo(i32*, i32*, i32*, i64) {\n"
+<< "%5 = icmp sgt i64 %3, 0\n"
+<< "br i1 %5, label %6, label %8\n"
+<< "; :6:\n"
+<< "br label %9\n"
+<< "; :7:\n"
+<< "br label %8\n"
+<< "; :8:\n"
+<< "ret void\n"
+<< "; :9:\n"
+<< " %ct   = phi i64 [ %10, %9 ], [ 0, %6 ]\n"
 << x.statements()
-<< "%z = add i64 1, %ct\n"
-<< "store i64 %z, i64* %i\n"
-<< "br label %loop\n\n"
-<< "endloop:\n"
-<< "ret void\n}\n";
+<< "%10 = add nuw nsw i64 %ct, 1\n"
+<< "%11 = icmp eq i64 %10, %3\n"
+<< "br i1 %11, label %7, label %9\n}\n";
 }
 
 // -
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D49952: Check for NULL Destination-Type when creating ArrayConstant

2018-08-06 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

Sure, that's fine.


https://reviews.llvm.org/D49952



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


[PATCH] D50278: [Sema] Fix for crash on conditional operation with address_space pointer

2018-08-06 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

I would expect this to replace the existing warning, not to appear together 
with it.


Repository:
  rC Clang

https://reviews.llvm.org/D50278



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


[PATCH] D50278: [Sema] Fix for crash on conditional operation with address_space pointer

2018-08-06 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: test/Sema/conditional-expr.c:78
+   // expected-error@-1{{converting 
'__attribute__((address_space(2))) int *' to type 'void *' changes address 
space of pointer}}
+   // expected-error@-2{{converting 
'__attribute__((address_space(3))) int *' to type 'void *' changes address 
space of pointer}}
 

Also, these diagnostics seem wrong.  Where is `void *` coming from?


Repository:
  rC Clang

https://reviews.llvm.org/D50278



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


[PATCH] D50152: [CodeGen] Merge equivalent block copy/helper functions

2018-08-06 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/CodeGen/CGBlocks.cpp:1630
+if (const CXXDestructorDecl *DD = RD->getDestructor())
+  if (const auto FPT = DD->getType()->getAs())
+// Conservatively assume the destructor can throw if the exception

I'm pretty sure this step can't fail.



Comment at: lib/CodeGen/CGBlocks.cpp:1643
+if (Ctx.getBlockVarCopyInits(VD))
+  return true;
+  return false;

Can you just ask Sema to check `canThrow` for the expression and pass it down?


Repository:
  rC Clang

https://reviews.llvm.org/D50152



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


[PATCH] D50342: Changed how LLVM IR was generated to increase vectorization

2018-08-06 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse added inline comments.



Comment at: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp:129
+<< "br i1 %5, label %6, label %8\n"
+<< "; :6:\n"
+<< "br label %9\n"

emmettneyman wrote:
> morehouse wrote:
> > Does removing branch names really make this easier to vectorize?
> Same answer as above. Should I change these back?
I think the previous labels were more human-readable.


Repository:
  rC Clang

https://reviews.llvm.org/D50342



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


[PATCH] D44352: [Concepts] Constrained template parameters

2018-08-06 Thread Saar Raz via Phabricator via cfe-commits
saar.raz updated this revision to Diff 159378.
saar.raz added a comment.

Split TryParseConstrainedParameter and ParseConstrainedTemplateParameter in 
preparation for requries expressions.


Repository:
  rC Clang

https://reviews.llvm.org/D44352

Files:
  include/clang/AST/DeclTemplate.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/AST/TemplateBase.h
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Parse/Parser.h
  include/clang/Sema/Sema.h
  lib/AST/ASTContext.cpp
  lib/AST/ASTDumper.cpp
  lib/AST/ASTImporter.cpp
  lib/AST/DeclTemplate.cpp
  lib/AST/ODRHash.cpp
  lib/Parse/ParseExprCXX.cpp
  lib/Parse/ParseTemplate.cpp
  lib/Sema/SemaCXXScopeSpec.cpp
  lib/Sema/SemaConcept.cpp
  lib/Sema/SemaTemplate.cpp
  lib/Sema/SemaTemplateDeduction.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriter.cpp
  lib/Serialization/ASTWriterDecl.cpp
  test/CXX/concepts-ts/temp/temp.constr/temp.constr.decl/class-template-decl.cpp
  test/CXX/concepts-ts/temp/temp.param/p10.cpp
  test/Parser/cxx-constrained-template-param-with-partial-id.cpp
  test/Parser/cxx-constrained-template-param.cpp
  tools/libclang/CIndex.cpp

Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -750,6 +750,10 @@
 }
 
 bool CursorVisitor::VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D) {
+  if (Expr *CE = D->getConstraintExpression())
+if (Visit(MakeCXCursor(CE, StmtParent, TU, RegionOfInterest)))
+  return true;
+
   // Visit the default argument.
   if (D->hasDefaultArgument() && !D->defaultArgumentWasInherited())
 if (TypeSourceInfo *DefArg = D->getDefaultArgumentInfo())
@@ -898,6 +902,10 @@
 bool CursorVisitor::VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D) {
   if (VisitDeclaratorDecl(D))
 return true;
+
+  if (Expr *CE = D->getConstraintExpression())
+if (Visit(MakeCXCursor(CE, StmtParent, TU, RegionOfInterest)))
+  return true;
   
   if (D->hasDefaultArgument() && !D->defaultArgumentWasInherited())
 if (Expr *DefArg = D->getDefaultArgument())
@@ -929,7 +937,11 @@
 bool CursorVisitor::VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D) {
   if (VisitTemplateParameters(D->getTemplateParameters()))
 return true;
-  
+
+  if (Expr *CE = D->getConstraintExpression())
+if (Visit(MakeCXCursor(CE, StmtParent, TU, RegionOfInterest)))
+  return true;
+
   if (D->hasDefaultArgument() && !D->defaultArgumentWasInherited() &&
   VisitTemplateArgumentLoc(D->getDefaultArgument()))
 return true;
Index: test/Parser/cxx-constrained-template-param.cpp
===
--- /dev/null
+++ test/Parser/cxx-constrained-template-param.cpp
@@ -0,0 +1,90 @@
+// RUN: %clang_cc1 -std=c++2a -fconcepts-ts -x c++ %s -verify
+// expected-no-diagnostics
+
+namespace type
+{
+  template
+  concept C1 = true;
+
+  template
+  using A = T[10];
+
+  using a = A;
+
+  namespace ns {
+template
+concept C2 = true;
+  }
+
+  template requires sizeof(T1) <= sizeof(T2)
+  struct B { };
+
+  using b = B;
+
+  template
+  struct C { };
+
+  using c1 = C;
+  using c2 = C;
+}
+
+namespace non_type
+{
+  template
+  concept C1 = true;
+
+  template
+  int A = v;
+
+  int& a = A<1>;
+
+  namespace ns {
+template
+concept C2 = true;
+  }
+
+  template requires sizeof(v1) <= sizeof(v2)
+  struct B { };
+
+  using b = B;
+
+  template
+  struct C { };
+
+  using c1 = C;
+  using c2 = C;
+}
+
+namespace temp
+{
+  template
+  struct test1 { };
+
+  template
+  struct test2 { };
+
+  template typename T>
+  concept C1 = true;
+
+  template
+  using A = TT;
+
+  using a = A;
+
+  namespace ns {
+template typename... TT>
+concept C2 = true;
+  }
+
+  template
+requires sizeof(TT1) <= sizeof(TT2)
+  struct B { };
+
+  using b = B;
+
+  template
+  struct C { };
+
+  using c1 = C;
+  using c2 = C;
+}
\ No newline at end of file
Index: test/Parser/cxx-constrained-template-param-with-partial-id.cpp
===
--- /dev/null
+++ test/Parser/cxx-constrained-template-param-with-partial-id.cpp
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -std=c++2a -fconcepts-ts -x c++ %s -verify
+
+template
+concept C1 = true;
+
+template // expected-error {{concept 'C1' requires more than 1 template argument; provide the remaining arguments explicitly to use it here}} expected-error{{explicit specialization of alias templates is not permitted}}
+using badA = T[10];
+
+template T>
+using A = T[10];
+
+using a = A;
+
+namespace ns {
+  template
+  concept C2 = true;
+}
+
+template // expected-error 2{{concept 'C2' requires more than 1 template argument; provide the remaining arguments explicitly to use it here}}
+requires sizeof(T1) <= sizeof(T2) // expected-error{{expected unqualified-id}}
+struct badB { }

[PATCH] D50352: Mark up deprecated methods as such

2018-08-06 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor added a comment.

I don't think Clang/LLVM use `[[deprecated]]` anywhere. Just change the API and 
people have to migrate their code.


Repository:
  rC Clang

https://reviews.llvm.org/D50352



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


[PATCH] D50278: [Sema] Fix for crash on conditional operation with address_space pointer

2018-08-06 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

In https://reviews.llvm.org/D50278#1189919, @rjmccall wrote:

> I would expect this to replace the existing warning, not to appear together 
> with it.


Will do.




Comment at: test/Sema/conditional-expr.c:78
+   // expected-error@-1{{converting 
'__attribute__((address_space(2))) int *' to type 'void *' changes address 
space of pointer}}
+   // expected-error@-2{{converting 
'__attribute__((address_space(3))) int *' to type 'void *' changes address 
space of pointer}}
 

rjmccall wrote:
> Also, these diagnostics seem wrong.  Where is `void *` coming from?
When dumping the AST this is what the resulting type is for the conditional 
expression already is if the operands are 2 pointers with different address 
spaces.

According to this comment, the reason seems to be because this is what GCC does:

```
 6512 // In this situation, we assume void* type. No especially good
 6513 // reason, but this is what gcc does, and we do have to pick
 6514 // to get a consistent AST.
```


Repository:
  rC Clang

https://reviews.llvm.org/D50278



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


[PATCH] D49438: [analyzer][UninitializedObjectChecker] New flag to turn off dereferencing

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

In https://reviews.llvm.org/D49438#1189772, @george.karpenkov wrote:

> > I think what pointer chasing should do, is check whether that pointer owns 
> > the pointee
>
> But ownership is a convention, and it's not always deducible from a codebase.


How about the following case:

  struct A {
struct B {
  int b;
};
std::unique_ptr ptr;
A() : ptr(new B) {}
  };
  
  A a;

Here, `a->ptr->b` is clearly uninitialized, and I think it's fine to assume in 
most cases that no other pointer points to it right after `a`'s construction.

> I think of those as two separate checks, and I think we should only talk 
> about enabling the pointer-chasing after we had established that just 
> checking for uninitialized fields finds lots of valid bugs (and we can only 
> do that after it gets enabled for many projects)

I think in the earlier case `*this->ptr` should be regarded as a regular field, 
and it could be analyzed without fear of spamming too many reports. Currently 
the biggest problem is that many objects could contain references to the same 
object:

  struct A { int x; };
  struct B {
A &a;
B(A &a) : a(a) {}
  };
  struct C {
A &a;
C(A &a) : a(a) {}
  };
  
  A a;
  B b(a);
  C c(a); // a.x reported twice


https://reviews.llvm.org/D49438



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


[PATCH] D50278: [Sema] Fix for crash on conditional operation with address_space pointer

2018-08-06 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: test/Sema/conditional-expr.c:78
+   // expected-error@-1{{converting 
'__attribute__((address_space(2))) int *' to type 'void *' changes address 
space of pointer}}
+   // expected-error@-2{{converting 
'__attribute__((address_space(3))) int *' to type 'void *' changes address 
space of pointer}}
 

leonardchan wrote:
> rjmccall wrote:
> > Also, these diagnostics seem wrong.  Where is `void *` coming from?
> When dumping the AST this is what the resulting type is for the conditional 
> expression already is if the operands are 2 pointers with different address 
> spaces.
> 
> According to this comment, the reason seems to be because this is what GCC 
> does:
> 
> ```
>  6512 // In this situation, we assume void* type. No especially good
>  6513 // reason, but this is what gcc does, and we do have to pick
>  6514 // to get a consistent AST.
> ```
That makes sense in general, but in this case it's not a great diagnostic; we 
should just emit an error when trying to pick a common type.


Repository:
  rC Clang

https://reviews.llvm.org/D50278



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


[PATCH] D50359: Add a new library, libclang-cxx

2018-08-06 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama created this revision.
Herald added a subscriber: mgorny.

The current libclang.so exports only the symbols required for the stable
C api.  This is opposed to libLLVM.so, which exports all the symbols
from the LLVM libraries, including those from the C++ API.  This patch
adds libclang-cxx.so that is similar to libLLVM.so and exports all
symbols from the clang libraries.  The motivation for this library is to
be used by Clang tools that use Clang's C++ api.  They no longer need to
link against the individual static libraries.


Repository:
  rC Clang

https://reviews.llvm.org/D50359

Files:
  CMakeLists.txt
  tools/CMakeLists.txt
  tools/libclang-cxx/CMakeLists.txt

Index: tools/libclang-cxx/CMakeLists.txt
===
--- /dev/null
+++ tools/libclang-cxx/CMakeLists.txt
@@ -0,0 +1,74 @@
+set(LIBS
+  clangBasic
+  clangCodeGen
+  clangDriver
+  clangFrontend
+  clangFrontendTool
+)
+
+if (CLANG_ENABLE_ARCMT)
+  list(APPEND LIBS clangARCMigrate)
+endif ()
+
+if (TARGET clangTidyPlugin)
+  add_definitions(-DCLANG_TOOL_EXTRA_BUILD)
+  list(APPEND LIBS clangTidyPlugin)
+  list(APPEND LIBS clangIncludeFixerPlugin)
+  if(LLVM_ENABLE_MODULES)
+list(APPEND LLVM_COMPILE_FLAGS "-fmodules-ignore-macro=CLANG_TOOL_EXTRA_BUILD")
+  endif()
+endif ()
+
+find_library(DL_LIBRARY_PATH dl)
+if (DL_LIBRARY_PATH)
+  list(APPEND LIBS dl)
+endif()
+
+if( LLVM_ENABLE_PIC )
+  set(ENABLE_SHARED SHARED)
+endif()
+
+if(NOT LLVM_ENABLE_PIC AND NOT WIN32)
+  set(ENABLE_STATIC STATIC)
+endif()
+
+if(WIN32)
+  set(output_name "libclang_cxx")
+else()
+  set(output_name "clang_cxx")
+endif()
+
+set(LIBS -Wl,--whole-archive ${LIBS} -Wl,--no-whole-archive)
+
+add_clang_library(libclang_cxx ${ENABLE_SHARED} ${ENABLE_STATIC}
+  OUTPUT_NAME ${output_name}
+
+  LINK_LIBS
+  ${LIBS}
+  )
+
+if(ENABLE_SHARED)
+  if(WIN32)
+set_target_properties(libclang_cxx
+  PROPERTIES
+  VERSION ${LIBCLANG_LIBRARY_VERSION}
+  DEFINE_SYMBOL _CINDEX_LIB_)
+  elseif(APPLE)
+  set(LIBCLANG_CXX_LINK_FLAGS " -Wl,-compatibility_version -Wl,1")
+  set(LIBCLANG_CXX_LINK_FLAGS "${LIBCLANG_CXX_LINK_FLAGS} -Wl,-current_version -Wl,${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}")
+
+set_property(TARGET libclang_cxx APPEND_STRING PROPERTY
+LINK_FLAGS ${LIBCLANG_CXX_LINK_FLAGS})
+  else()
+set_target_properties(libclang_cxx
+  PROPERTIES
+  VERSION ${LIBCLANG_LIBRARY_VERSION}
+  DEFINE_SYMBOL _CINDEX_LIB_)
+# FIXME: _CINDEX_LIB_ affects dllexport/dllimport on Win32.
+if(LLVM_ENABLE_MODULES AND NOT WIN32)
+  target_compile_options(libclang_cxx PRIVATE
+"-fmodules-ignore-macro=_CINDEX_LIB_"
+)
+endif()
+  endif()
+endif()
Index: tools/CMakeLists.txt
===
--- tools/CMakeLists.txt
+++ tools/CMakeLists.txt
@@ -35,3 +35,4 @@
 
 # libclang may require clang-tidy in clang-tools-extra.
 add_clang_subdirectory(libclang)
+add_clang_subdirectory(libclang-cxx)
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -431,7 +431,7 @@
 "Major version number that will be appended to the clang executable name")
 set(LIBCLANG_LIBRARY_VERSION
 "${CLANG_VERSION_MAJOR}" CACHE STRING
-"Major version number that will be appended to the libclang library")
+"Major version number that will be appended to the libclang, libclang_cxx libraries")
 mark_as_advanced(CLANG_EXECUTABLE_VERSION LIBCLANG_LIBRARY_VERSION)
 
 option(CLANG_INCLUDE_TESTS
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D49438: [analyzer][UninitializedObjectChecker] New flag to turn off dereferencing

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

If we ignore references, check whether the pointee was constructed within the 
constructor, and maybe add some other clever heuristics, I'm very much in favor 
of enabling pointer chasing by enabled. But I totally support disabling it for 
now.


https://reviews.llvm.org/D49438



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


[PATCH] D50359: Add a new library, libclang-cxx

2018-08-06 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama added a comment.

This implements the new library proposed in 
http://lists.llvm.org/pipermail/cfe-dev/2018-August/058736.html.


Repository:
  rC Clang

https://reviews.llvm.org/D50359



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


[PATCH] D50152: [CodeGen] Merge equivalent block copy/helper functions

2018-08-06 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added inline comments.



Comment at: lib/CodeGen/CGBlocks.cpp:1643
+if (Ctx.getBlockVarCopyInits(VD))
+  return true;
+  return false;

rjmccall wrote:
> Can you just ask Sema to check `canThrow` for the expression and pass it down?
Since this changes the existing behavior, I made changes to 
test/CodeGenCXX/block-byref-cxx-objc.cpp to test it. Previously, IRGen would 
emit an invoke to call `_Block_object_assign` when the constructor was marked 
as noexcept.


Repository:
  rC Clang

https://reviews.llvm.org/D50152



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


[PATCH] D50152: [CodeGen] Merge equivalent block copy/helper functions

2018-08-06 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 159388.
ahatanak marked 2 inline comments as done.
ahatanak added a comment.

Address review comments.


Repository:
  rC Clang

https://reviews.llvm.org/D50152

Files:
  lib/CodeGen/CGBlocks.cpp
  lib/CodeGen/CGBlocks.h
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CGNonTrivialStruct.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGen/blocks-1.c
  test/CodeGen/blocks.c
  test/CodeGen/sanitize-thread-no-checking-at-run-time.m
  test/CodeGenCXX/block-byref-cxx-objc.cpp
  test/CodeGenCXX/blocks.cpp
  test/CodeGenCXX/cxx-block-objects.cpp
  test/CodeGenObjC/arc-blocks.m
  test/CodeGenObjC/debug-info-block-helper.m
  test/CodeGenObjC/debug-info-blocks.m
  test/CodeGenObjC/mrc-weak.m
  test/CodeGenObjC/strong-in-c-struct.m
  test/CodeGenObjCXX/arc-blocks.mm
  test/CodeGenObjCXX/lambda-to-block.mm
  test/CodeGenObjCXX/mrc-weak.mm

Index: test/CodeGenObjCXX/mrc-weak.mm
===
--- test/CodeGenObjCXX/mrc-weak.mm
+++ test/CodeGenObjCXX/mrc-weak.mm
@@ -119,10 +119,10 @@
 // CHECK:   call void @use_block
 // CHECK:   call void @objc_destroyWeak
 
-// CHECK-LABEL: define internal void @__copy_helper_block
+// CHECK-LABEL: define linkonce_odr hidden void @__copy_helper_block
 // CHECK:   @objc_copyWeak
 
-// CHECK-LABEL: define internal void @__destroy_helper_block
+// CHECK-LABEL: define linkonce_odr hidden void @__destroy_helper_block
 // CHECK:   @objc_destroyWeak
 
 void test8(void) {
@@ -142,8 +142,8 @@
 // CHECK:   call void @objc_destroyWeak
 
 // CHECK-LABEL: define void @_Z14test9_baselinev()
-// CHECK:   define internal void @__copy_helper
-// CHECK:   define internal void @__destroy_helper
+// CHECK:   define linkonce_odr hidden void @__copy_helper
+// CHECK:   define linkonce_odr hidden void @__destroy_helper
 void test9_baseline(void) {
   Foo *p = get_object();
   use_block(^{ [p run]; });
Index: test/CodeGenObjCXX/lambda-to-block.mm
===
--- test/CodeGenObjCXX/lambda-to-block.mm
+++ test/CodeGenObjCXX/lambda-to-block.mm
@@ -12,7 +12,7 @@
 void hasLambda(Copyable x) {
   takesBlock([x] () { });
 }
-// CHECK-LABEL: define internal void @__copy_helper_block_
+// CHECK-LABEL: define internal void @"__copy_helper_block_
 // CHECK: call void @"_ZZ9hasLambda8CopyableEN3$_0C1ERKS0_"
 // CHECK-LABEL: define internal void @"_ZZ9hasLambda8CopyableEN3$_0C2ERKS0_"
 // CHECK: call void @_ZN8CopyableC1ERKS_
Index: test/CodeGenObjCXX/arc-blocks.mm
===
--- test/CodeGenObjCXX/arc-blocks.mm
+++ test/CodeGenObjCXX/arc-blocks.mm
@@ -1,8 +1,10 @@
 // RUN: %clang_cc1 -std=gnu++98 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-runtime-has-weak -fblocks -fobjc-arc -fexceptions -fobjc-arc-exceptions -o - %s | FileCheck -check-prefix CHECK %s
 // RUN: %clang_cc1 -std=gnu++98 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-runtime-has-weak -fblocks -fobjc-arc -fexceptions -fobjc-arc-exceptions -O1 -o - %s | FileCheck -check-prefix CHECK-O1 %s
+// RUN: %clang_cc1 -std=gnu++98 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-runtime-has-weak -fblocks -fobjc-arc -o - %s | FileCheck -check-prefix CHECK-NOEXCP %s
 
 // CHECK: [[A:.*]] = type { i64, [10 x i8*] }
 // CHECK: %[[STRUCT_TEST1_S0:.*]] = type { i32 }
+// CHECK: %[[STRUCT_TRIVIAL_INTERNAL:.*]] = type { i32 }
 // CHECK: %[[STRUCT_BLOCK_DESCRIPTOR:.*]] = type { i64, i64 }
 
 // CHECK: [[LAYOUT0:@.*]] = private unnamed_addr constant [3 x i8] c" 9\00"
@@ -55,34 +57,34 @@
 
 // Check that copy/dispose helper functions are exception safe.
 
-// CHECK-LABEL: define internal void @__copy_helper_block_(
-// CHECK: %[[BLOCK_SOURCE:.*]] = bitcast i8* %{{.*}} to <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8*, i8*, i8*, %[[STRUCT_TEST1_S0]], %[[STRUCT_TEST1_S0]] }>*
-// CHECK: %[[BLOCK_DEST:.*]] = bitcast i8* %{{.*}} to <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8*, i8*, i8*, %[[STRUCT_TEST1_S0]], %[[STRUCT_TEST1_S0]] }>*
+// CHECK-LABEL: define linkonce_odr hidden void @__copy_helper_block_ea8_32s40b48w56c15_ZTSN5test12S0E60c15_ZTSN5test12S0E(
+// CHECK: %[[BLOCK_SOURCE:.*]] = bitcast i8* %{{.*}} to <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8*, i8*, i8*, %[[STRUCT_TEST1_S0]], %[[STRUCT_TEST1_S0]], %[[STRUCT_TRIVIAL_INTERNAL]] }>*
+// CHECK: %[[BLOCK_DEST:.*]] = bitcast i8* %{{.*}} to <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8*, i8*, i8*, %[[STRUCT_TEST1_S0]], %[[STRUCT_TEST1_S0]], %[[STRUCT_TRIVIAL_INTERNAL]] }>*
 
-// CHECK: %[[V4:.*]] = getelementptr inbounds <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8*, i8*, i8*, %[[STRUCT_TEST1_S0]], %[[STRUCT_TEST1_S0]] }>, <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8*, i8*, i8*, %[[STRUCT_TEST1_S0]], %[[STRUCT_TEST1_S0]] }>* %[[BLOCK_SOURCE]], i32 0, i32 6
-// CHECK: %[[V5:.*]] = getelementptr 

[PATCH] D50342: Changed how LLVM IR was generated to increase vectorization

2018-08-06 Thread Emmett Neyman via Phabricator via cfe-commits
emmettneyman updated this revision to Diff 159389.
emmettneyman added a comment.

Added back more descriptive variable and loop names


Repository:
  rC Clang

https://reviews.llvm.org/D50342

Files:
  clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp


Index: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp
===
--- clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp
+++ clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp
@@ -53,7 +53,7 @@
 break;
   }
   std::string ptr_var = get_var();
-  os << ptr_var << " = getelementptr i32, i32* " << arr << ", i64 %ct\n";
+  os << ptr_var << " = getelementptr inbounds i32, i32* " << arr << ", i64 
%ct\n";
   return ptr_var;
 }
 std::string RvalueToString(std::ostream &os, const Rvalue &x) {
@@ -122,21 +122,22 @@
   return os;
 }
 std::ostream &operator<<(std::ostream &os, const LoopFunction &x) {
-  return os << "define void @foo(i32* %a, i32* %b, i32* noalias %c, i64 %s) 
{\n"
-<< "%i = alloca i64\n"
-<< "store i64 0, i64* %i\n"
-<< "br label %loop\n\n"
+  return os << "target triple = \"x86_64-unknown-linux-gnu\"\n"
+<< "define void @foo(i32* %a, i32* %b, i32* %c, i64 %s) {\n"
+<< "%1 = icmp sgt i64 %s, 0\n"
+<< "br i1 %1, label %start, label %end\n"
+<< "start:\n"
+<< "br label %loop\n"
+<< "endloop:\n"
+<< "br label %end\n"
+<< "end:\n"
+<< "ret void\n"
 << "loop:\n"
-<< "%ct = load i64, i64* %i\n"
-<< "%comp = icmp eq i64 %ct, %s\n"
-<< "br i1 %comp, label %endloop, label %body\n\n"
-<< "body:\n"
+<< " %ct   = phi i64 [ %ctnew, %loop ], [ 0, %start ]\n"
 << x.statements()
-<< "%z = add i64 1, %ct\n"
-<< "store i64 %z, i64* %i\n"
-<< "br label %loop\n\n"
-<< "endloop:\n"
-<< "ret void\n}\n";
+<< "%ctnew = add nuw nsw i64 %ct, 1\n"
+<< "%j = icmp eq i64 %ctnew, %s\n"
+<< "br i1 %j, label %endloop, label %loop\n}\n";
 }
 
 // -


Index: clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp
===
--- clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp
+++ clang/tools/clang-fuzzer/proto-to-llvm/loop_proto_to_llvm.cpp
@@ -53,7 +53,7 @@
 break;
   }
   std::string ptr_var = get_var();
-  os << ptr_var << " = getelementptr i32, i32* " << arr << ", i64 %ct\n";
+  os << ptr_var << " = getelementptr inbounds i32, i32* " << arr << ", i64 %ct\n";
   return ptr_var;
 }
 std::string RvalueToString(std::ostream &os, const Rvalue &x) {
@@ -122,21 +122,22 @@
   return os;
 }
 std::ostream &operator<<(std::ostream &os, const LoopFunction &x) {
-  return os << "define void @foo(i32* %a, i32* %b, i32* noalias %c, i64 %s) {\n"
-<< "%i = alloca i64\n"
-<< "store i64 0, i64* %i\n"
-<< "br label %loop\n\n"
+  return os << "target triple = \"x86_64-unknown-linux-gnu\"\n"
+<< "define void @foo(i32* %a, i32* %b, i32* %c, i64 %s) {\n"
+<< "%1 = icmp sgt i64 %s, 0\n"
+<< "br i1 %1, label %start, label %end\n"
+<< "start:\n"
+<< "br label %loop\n"
+<< "endloop:\n"
+<< "br label %end\n"
+<< "end:\n"
+<< "ret void\n"
 << "loop:\n"
-<< "%ct = load i64, i64* %i\n"
-<< "%comp = icmp eq i64 %ct, %s\n"
-<< "br i1 %comp, label %endloop, label %body\n\n"
-<< "body:\n"
+<< " %ct   = phi i64 [ %ctnew, %loop ], [ 0, %start ]\n"
 << x.statements()
-<< "%z = add i64 1, %ct\n"
-<< "store i64 %z, i64* %i\n"
-<< "br label %loop\n\n"
-<< "endloop:\n"
-<< "ret void\n}\n";
+<< "%ctnew = add nuw nsw i64 %ct, 1\n"
+<< "%j = icmp eq i64 %ctnew, %s\n"
+<< "br i1 %j, label %endloop, label %loop\n}\n";
 }
 
 // -
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45444: [clang-tidy] implement new check for const-correctness

2018-08-06 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth marked an inline comment as done.
JonasToth added inline comments.



Comment at: clang-tidy/cppcoreguidelines/ConstCorrectnessCheck.cpp:147
+  // Example: `int i = 10`, `int i` (will be used if program is correct)
+  const auto LocalValDecl = varDecl(unless(anyOf(
+  isLocal(), hasInitializer(anything()), unless(ConstType),

aaron.ballman wrote:
> JonasToth wrote:
> > @aaron.ballman The change was not valid for some reason. I leave it like it 
> > is if thats ok with you.
> That's really odd. I am fine leaving it as-is for this patch, but it 
> would be good to understand why that code fails as it seems like a reasonable 
> exposition.
Added a TODO. But maybe i did the transformation incorrectly too. Not all 
conditions are negative. Maybe all the negative ones can be inverted by 
demorgan. That should be correct.

I will check this out later.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45444



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


[PATCH] D45444: [clang-tidy] implement new check for const-correctness

2018-08-06 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth marked an inline comment as done.
JonasToth added inline comments.



Comment at: clang-tidy/cppcoreguidelines/ConstCorrectnessCheck.cpp:183
+  // TODO Implement automatic code transformation to add the 'const'.
+  diag(Variable->getLocStart(), "variable %0 of type %1 can be declared const")
+  << Variable << Variable->getType();

aaron.ballman wrote:
> Still missing the single quotes around `const` in the diagnostic.
Ups. The comment has them :D


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45444



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


[PATCH] D45444: [clang-tidy] implement new check for const-correctness

2018-08-06 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 159390.
JonasToth marked 4 inline comments as done.
JonasToth added a comment.

- address review issues, todos/fixmes and diag nit


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45444

Files:
  clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tidy/cppcoreguidelines/ConstCorrectnessCheck.cpp
  clang-tidy/cppcoreguidelines/ConstCorrectnessCheck.h
  clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/cppcoreguidelines-const-correctness.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/cppcoreguidelines-const-correctness-pointer-as-values.cpp
  test/clang-tidy/cppcoreguidelines-const-correctness-values.cpp

Index: test/clang-tidy/cppcoreguidelines-const-correctness-values.cpp
===
--- /dev/null
+++ test/clang-tidy/cppcoreguidelines-const-correctness-values.cpp
@@ -0,0 +1,557 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-const-correctness %t
+
+// --- Provide test samples for primitive builtins -
+// - every 'p_*' variable is a 'potential_const_*' variable
+// - every 'np_*' variable is a 'non_potential_const_*' variable
+
+bool global;
+char np_global = 0; // globals can't be known to be const
+
+namespace foo {
+int scoped;
+float np_scoped = 1; // namespace variables are like globals
+} // namespace foo
+
+void some_function(double, wchar_t);
+
+void some_function(double np_arg0, wchar_t np_arg1) {
+  int p_local0 = 2;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int' can be declared const
+
+  int np_local0;
+  const int np_local1 = 42;
+
+  unsigned int np_local2 = 3;
+  np_local2 <<= 4;
+
+  int np_local3 = 4;
+  ++np_local3;
+  int np_local4 = 4;
+  np_local4++;
+
+  int np_local5 = 4;
+  --np_local5;
+  int np_local6 = 4;
+  np_local6--;
+}
+
+void nested_scopes() {
+  int p_local0 = 2;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int' can be declared const
+  int np_local0 = 42;
+
+  {
+int p_local1 = 42;
+// CHECK-MESSAGES: [[@LINE-1]]:5: warning: variable 'p_local1' of type 'int' can be declared const
+np_local0 *= 2;
+  }
+}
+
+void some_lambda_environment_capture_all_by_reference(double np_arg0) {
+  int np_local0 = 0;
+  int p_local0 = 1;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int' can be declared const
+
+  int np_local2;
+  const int np_local3 = 2;
+
+  // Capturing all variables by reference prohibits making them const.
+  [&]() { ++np_local0; };
+
+  int p_local1 = 0;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local1' of type 'int' can be declared const
+}
+
+void some_lambda_environment_capture_all_by_value(double np_arg0) {
+  int np_local0 = 0;
+  int p_local0 = 1;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int' can be declared const
+
+  int np_local1;
+  const int np_local2 = 2;
+
+  // Capturing by value has no influence on them.
+  [=]() { (void)p_local0; };
+
+  np_local0 += 10;
+}
+
+void function_inout_pointer(int *inout);
+void function_in_pointer(const int *in);
+
+void some_pointer_taking(int *out) {
+  int np_local0 = 42;
+  const int *const p0_np_local0 = &np_local0;
+  int *const p1_np_local0 = &np_local0;
+
+  int np_local1 = 42;
+  const int *const p0_np_local1 = &np_local1;
+  int *const p1_np_local1 = &np_local1;
+  *p1_np_local0 = 43;
+
+  int np_local2 = 42;
+  function_inout_pointer(&np_local2);
+
+  // Prevents const.
+  int np_local3 = 42;
+  out = &np_local3; // This returns and invalid address, its just about the AST
+
+  int p_local1 = 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local1' of type 'int' can be declared const
+  const int *const p0_p_local1 = &p_local1;
+
+  int p_local2 = 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local2' of type 'int' can be declared const
+  function_in_pointer(&p_local2);
+}
+
+void function_inout_ref(int &inout);
+void function_in_ref(const int &in);
+
+void some_reference_taking() {
+  int np_local0 = 42;
+  const int &r0_np_local0 = np_local0;
+  int &r1_np_local0 = np_local0;
+  r1_np_local0 = 43;
+  const int &r2_np_local0 = r1_np_local0;
+
+  int np_local1 = 42;
+  function_inout_ref(np_local1);
+
+  int p_local0 = 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int' can be declared const
+  const int &r0_p_local0 = p_local0;
+
+  int p_local1 = 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local1' of type 'int' can be declared const
+  function_in_ref(p_local1);
+}
+
+double *non_const_pointer_return() {
+  double p_local0 = 0.0;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'double' can be declared const
+  double np_local0 = 24.4;
+
+  return &np_local0;
+}
+
+const double *const_pointer_return() {
+  double p_local0 = 0.0;
+  // CHECK-MESSAGES: [[@LINE-1]]:3:

[PATCH] D50152: [CodeGen] Merge equivalent block copy/helper functions

2018-08-06 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added inline comments.



Comment at: lib/CodeGen/CGBlocks.cpp:1643
+if (Ctx.getBlockVarCopyInits(VD))
+  return true;
+  return false;

ahatanak wrote:
> rjmccall wrote:
> > Can you just ask Sema to check `canThrow` for the expression and pass it 
> > down?
> Since this changes the existing behavior, I made changes to 
> test/CodeGenCXX/block-byref-cxx-objc.cpp to test it. Previously, IRGen would 
> emit an invoke to call `_Block_object_assign` when the constructor was marked 
> as noexcept.
Perhaps I misunderstood your comment, should I have Sema set a flag or 
something in Expr when it calls a function that can throw?


Repository:
  rC Clang

https://reviews.llvm.org/D50152



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


[PATCH] D45444: [clang-tidy] implement new check for const-correctness

2018-08-06 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

In https://reviews.llvm.org/D45444#1189262, @aaron.ballman wrote:

> However, I'm wondering how this should integrate with other const-correctness 
> efforts like `readability-non-const-parameter`?


I think this check/functionality will kinda replace the 
`readability-non-const-parameter` check. The readability check does not a full 
const-analysis too and i think only works on pointers or sth like this.
Maybe the check name will still exist, but use the `ExprMutAnalyzer` or it will 
become an alias to this with special configuration.
I would like to add support for marking methods `const` plus the ability for 
code transformation. Currently looking into `clang-refactor` framework to 
implement general refactoring primitives necessary for that.
In general its probably better to have one check, that handles all `const` 
issues.

> Also, I'm wondering how this check performs over a large code base like LLVM 
> -- how chatty are the diagnostics, and how bad is the false positive rate 
> (roughly)?

I will prepare a report for this tomorrow. Currently the LLVM builds take very 
long on my laptop :(


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45444



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


[PATCH] D50349: Port getStartLoc -> getBeginLoc

2018-08-06 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

+Hans (release manager for LLVM 7)

Hans, this patch series will affect the API of common Clang classes, resulting 
in patches to Clang SVN needing some (mechanical) modifications to be applied 
to the Clang 7 release branch if we land it now. What do you think about that? 
Would you prefer that we wait until after the 7.0.0 release to make 
cherry-picks easier?


Repository:
  rC Clang

https://reviews.llvm.org/D50349



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


Re: r337005 - [NFC] Rename clang::AttributeList to clang::ParsedAttr

2018-08-06 Thread Michael Kruse via cfe-commits
Thank you.

Michael


2018-08-06 13:13 GMT-05:00 Keane, Erich :
> Good grief... I even made a note to remove this 'TODO' on my whiteboard!
>
> I discussed the name with AaronBallman who preferred ParsedAttr over 
> ParsedAttribute (since ParsedAttributes is also a type).
>
> Fixed in r339039.
>
> -Original Message-
> From: meiners...@googlemail.com [mailto:meiners...@googlemail.com] On Behalf 
> Of Michael Kruse
> Sent: Monday, August 6, 2018 11:00 AM
> To: Keane, Erich 
> Cc: cfe-commits 
> Subject: Re: r337005 - [NFC] Rename clang::AttributeList to clang::ParsedAttr
>
> 2018-07-13 10:07 GMT-05:00 Erich Keane via cfe-commits
> :
>> -class AttributeList { // TODO: This should really be called ParsedAttribute
>> +class ParsedAttr { // TODO: This should really be called ParsedAttribute
>
> Should this TODO be removed/ParsedAttr really be called ParsedAttribute?
>
> Michael
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >