[PATCH] D41537: Optionally add code completion results for arrow instead of dot

2018-02-22 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan added a comment.

Or is your idea is to return the char sequence instead to use this correction 
in some universal way?


https://reviews.llvm.org/D41537



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


[PATCH] D43547: [Indexing] Fixing inconsistencies between FUNCDNAME and generated code by improving ASTContext's API for MangleContext

2018-02-22 Thread Michael Haidl via Phabricator via cfe-commits
pacxx updated this revision to Diff 135372.
pacxx retitled this revision from "[NameMangling] Make ASTContext owning the 
ManglingContext during entire compilation" to "[Indexing] Fixing 
inconsistencies between FUNCDNAME and generated code by improving ASTContext's 
API for MangleContext".
pacxx edited the summary of this revision.
pacxx added a comment.

Refactored as suggested.


https://reviews.llvm.org/D43547

Files:
  include/clang/AST/ASTContext.h
  lib/AST/ASTContext.cpp
  lib/AST/Expr.cpp
  lib/CodeGen/CGCXXABI.h
  lib/Index/CodegenNameGenerator.cpp

Index: lib/Index/CodegenNameGenerator.cpp
===
--- lib/Index/CodegenNameGenerator.cpp
+++ lib/Index/CodegenNameGenerator.cpp
@@ -26,11 +26,11 @@
 using namespace clang::index;
 
 struct CodegenNameGenerator::Implementation {
-  std::unique_ptr MC;
+  MangleContext& MC;
   llvm::DataLayout DL;
 
   Implementation(ASTContext )
-: MC(Ctx.createMangleContext()),
+: MC(Ctx.getMangleContext()),
   DL(Ctx.getTargetInfo().getDataLayout()) {}
 
   bool writeName(const Decl *D, raw_ostream ) {
@@ -46,7 +46,7 @@
   if (writeFuncOrVarName(VD, FrontendBufOS))
 return true;
 } else if (auto *MD = dyn_cast(D)) {
-  MC->mangleObjCMethodNameWithoutSize(MD, OS);
+  MC.mangleObjCMethodNameWithoutSize(MD, OS);
   return false;
 } else if (auto *ID = dyn_cast(D)) {
   writeObjCClassName(ID, FrontendBufOS);
@@ -106,7 +106,6 @@
 const NamedDecl *ND = cast(D);
 
 ASTContext  = ND->getASTContext();
-std::unique_ptr M(Ctx.createMangleContext());
 
 std::vector Manglings;
 
@@ -148,13 +147,13 @@
 
 private:
   bool writeFuncOrVarName(const NamedDecl *D, raw_ostream ) {
-if (MC->shouldMangleDeclName(D)) {
+if (MC.shouldMangleDeclName(D)) {
   if (const auto *CtorD = dyn_cast(D))
-MC->mangleCXXCtor(CtorD, Ctor_Complete, OS);
+MC.mangleCXXCtor(CtorD, Ctor_Complete, OS);
   else if (const auto *DtorD = dyn_cast(D))
-MC->mangleCXXDtor(DtorD, Dtor_Complete, OS);
+MC.mangleCXXDtor(DtorD, Dtor_Complete, OS);
   else
-MC->mangleName(D, OS);
+MC.mangleName(D, OS);
   return false;
 } else {
   IdentifierInfo *II = D->getIdentifier();
@@ -181,9 +180,9 @@
 llvm::raw_string_ostream FOS(FrontendBuf);
 
 if (const auto *CD = dyn_cast_or_null(ND))
-  MC->mangleCXXCtor(CD, static_cast(StructorType), FOS);
+  MC.mangleCXXCtor(CD, static_cast(StructorType), FOS);
 else if (const auto *DD = dyn_cast_or_null(ND))
-  MC->mangleCXXDtor(DD, static_cast(StructorType), FOS);
+  MC.mangleCXXDtor(DD, static_cast(StructorType), FOS);
 
 std::string BackendBuf;
 llvm::raw_string_ostream BOS(BackendBuf);
@@ -197,7 +196,7 @@
 std::string FrontendBuf;
 llvm::raw_string_ostream FOS(FrontendBuf);
 
-MC->mangleThunk(MD, T, FOS);
+MC.mangleThunk(MD, T, FOS);
 
 std::string BackendBuf;
 llvm::raw_string_ostream BOS(BackendBuf);
Index: lib/CodeGen/CGCXXABI.h
===
--- lib/CodeGen/CGCXXABI.h
+++ lib/CodeGen/CGCXXABI.h
@@ -44,10 +44,10 @@
 class CGCXXABI {
 protected:
   CodeGenModule 
-  std::unique_ptr MangleCtx;
+  MangleContext 
 
   CGCXXABI(CodeGenModule )
-: CGM(CGM), MangleCtx(CGM.getContext().createMangleContext()) {}
+: CGM(CGM), MangleCtx(CGM.getContext().getMangleContext()) {}
 
 protected:
   ImplicitParamDecl *getThisDecl(CodeGenFunction ) {
@@ -95,7 +95,7 @@
 
   /// Gets the mangle context.
   MangleContext () {
-return *MangleCtx;
+return MangleCtx;
   }
 
   /// Returns true if the given constructor or destructor is one of the
Index: lib/AST/Expr.cpp
===
--- lib/AST/Expr.cpp
+++ lib/AST/Expr.cpp
@@ -497,18 +497,17 @@
 
   if (IT == PredefinedExpr::FuncDName) {
 if (const NamedDecl *ND = dyn_cast(CurrentDecl)) {
-  std::unique_ptr MC;
-  MC.reset(Context.createMangleContext());
+  MangleContext& MC = Context.getMangleContext();
 
-  if (MC->shouldMangleDeclName(ND)) {
+  if (MC.shouldMangleDeclName(ND)) {
 SmallString<256> Buffer;
 llvm::raw_svector_ostream Out(Buffer);
 if (const CXXConstructorDecl *CD = dyn_cast(ND))
-  MC->mangleCXXCtor(CD, Ctor_Base, Out);
+  MC.mangleCXXCtor(CD, Ctor_Base, Out);
 else if (const CXXDestructorDecl *DD = dyn_cast(ND))
-  MC->mangleCXXDtor(DD, Dtor_Base, Out);
+  MC.mangleCXXDtor(DD, Dtor_Base, Out);
 else
-  MC->mangleName(ND, Out);
+  MC.mangleName(ND, Out);
 
 if (!Buffer.empty() && Buffer.front() == '\01')
   return Buffer.substr(1);
Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -9570,6 +9570,12 @@
   

[PATCH] D43579: [libcxx] Do not include the C math.h header before __config

2018-02-22 Thread Mikhail Maltsev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL325760: [libcxx] Do not include the C math.h header before 
__config (authored by miyuki, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D43579?vs=135264=135376#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D43579

Files:
  libcxx/trunk/include/math.h


Index: libcxx/trunk/include/math.h
===
--- libcxx/trunk/include/math.h
+++ libcxx/trunk/include/math.h
@@ -8,16 +8,6 @@
 //
 
//===--===//
 
-// This include lives outside the header guard in order to support an MSVC
-// extension which allows users to do:
-//
-// #define _USE_MATH_DEFINES
-// #include 
-//
-// and receive the definitions of mathematical constants, even if 
-// has previously been included.
-#include_next 
-
 #ifndef _LIBCPP_MATH_H
 #define _LIBCPP_MATH_H
 
@@ -308,6 +298,8 @@
 #pragma GCC system_header
 #endif
 
+#include_next 
+
 #ifdef __cplusplus
 
 // We support including .h headers inside 'extern "C"' contexts, so switch
@@ -1494,4 +1486,18 @@
 
 #endif // __cplusplus
 
+#else // _LIBCPP_MATH_H
+
+// This include lives outside the header guard in order to support an MSVC
+// extension which allows users to do:
+//
+// #define _USE_MATH_DEFINES
+// #include 
+//
+// and receive the definitions of mathematical constants, even if 
+// has previously been included.
+#if defined(_LIBCPP_MSVCRT) && defined(_USE_MATH_DEFINES)
+#include_next 
+#endif
+
 #endif  // _LIBCPP_MATH_H


Index: libcxx/trunk/include/math.h
===
--- libcxx/trunk/include/math.h
+++ libcxx/trunk/include/math.h
@@ -8,16 +8,6 @@
 //
 //===--===//
 
-// This include lives outside the header guard in order to support an MSVC
-// extension which allows users to do:
-//
-// #define _USE_MATH_DEFINES
-// #include 
-//
-// and receive the definitions of mathematical constants, even if 
-// has previously been included.
-#include_next 
-
 #ifndef _LIBCPP_MATH_H
 #define _LIBCPP_MATH_H
 
@@ -308,6 +298,8 @@
 #pragma GCC system_header
 #endif
 
+#include_next 
+
 #ifdef __cplusplus
 
 // We support including .h headers inside 'extern "C"' contexts, so switch
@@ -1494,4 +1486,18 @@
 
 #endif // __cplusplus
 
+#else // _LIBCPP_MATH_H
+
+// This include lives outside the header guard in order to support an MSVC
+// extension which allows users to do:
+//
+// #define _USE_MATH_DEFINES
+// #include 
+//
+// and receive the definitions of mathematical constants, even if 
+// has previously been included.
+#if defined(_LIBCPP_MSVCRT) && defined(_USE_MATH_DEFINES)
+#include_next 
+#endif
+
 #endif  // _LIBCPP_MATH_H
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D39571: [clangd] DidChangeConfiguration Notification

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

Thanks for fixing all the comments! LGTM!


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D39571



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


[PATCH] D43614: Define _PTHREADS for -pthread on NetBSD

2018-02-22 Thread Kamil Rytarowski via Phabricator via cfe-commits
krytarowski created this revision.
krytarowski added reviewers: joerg, rnk.
krytarowski added a project: clang.
Herald added a subscriber: llvm-commits.

GCC and PCC define _PTHREADS for -pthreads
on NetBSD.

The _PTHREADS preprocessor macro is used in
the NetBSD header in .

NetBSD uses both: _REENTRANT and _PTHREAD
for the -pthreads command line option.

Sponsored by 


Repository:
  rL LLVM

https://reviews.llvm.org/D43614

Files:
  lib/Basic/Targets/OSTargets.h
  test/Driver/netbsd.c


Index: test/Driver/netbsd.c
===
--- test/Driver/netbsd.c
+++ test/Driver/netbsd.c
@@ -431,5 +431,6 @@
 // S-POWERPC64: "{{.*}}/usr/lib{{/|}}crtend.o" 
"{{.*}}/usr/lib{{/|}}crtn.o"
 
 // PTHREAD-NOT: _POSIX_THREADS
+// PTHREAD: _PTHREADS
 // PTHREAD: _REENTRANT
 // PTHREAD-NOT: _POSIX_THREADS
Index: lib/Basic/Targets/OSTargets.h
===
--- lib/Basic/Targets/OSTargets.h
+++ lib/Basic/Targets/OSTargets.h
@@ -362,8 +362,10 @@
 Builder.defineMacro("__NetBSD__");
 Builder.defineMacro("__unix__");
 Builder.defineMacro("__ELF__");
-if (Opts.POSIXThreads)
+if (Opts.POSIXThreads) {
   Builder.defineMacro("_REENTRANT");
+  Builder.defineMacro("_PTHREADS");
+}
   }
 
 public:


Index: test/Driver/netbsd.c
===
--- test/Driver/netbsd.c
+++ test/Driver/netbsd.c
@@ -431,5 +431,6 @@
 // S-POWERPC64: "{{.*}}/usr/lib{{/|}}crtend.o" "{{.*}}/usr/lib{{/|}}crtn.o"
 
 // PTHREAD-NOT: _POSIX_THREADS
+// PTHREAD: _PTHREADS
 // PTHREAD: _REENTRANT
 // PTHREAD-NOT: _POSIX_THREADS
Index: lib/Basic/Targets/OSTargets.h
===
--- lib/Basic/Targets/OSTargets.h
+++ lib/Basic/Targets/OSTargets.h
@@ -362,8 +362,10 @@
 Builder.defineMacro("__NetBSD__");
 Builder.defineMacro("__unix__");
 Builder.defineMacro("__ELF__");
-if (Opts.POSIXThreads)
+if (Opts.POSIXThreads) {
   Builder.defineMacro("_REENTRANT");
+  Builder.defineMacro("_PTHREADS");
+}
   }
 
 public:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43570: [OpenCL] Add '-cl-uniform-work-group-size' compile option

2018-02-22 Thread Kristina Bessonova via Phabricator via cfe-commits
krisb updated this revision to Diff 135375.
krisb added a comment.
Herald added a subscriber: nhaehnle.

Updated one more test where attributes became mismatched.


Repository:
  rC Clang

https://reviews.llvm.org/D43570

Files:
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CGCall.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGenOpenCL/amdgpu-abi-struct-coerce.cl
  test/CodeGenOpenCL/cl-uniform-wg-size.cl
  test/CodeGenOpenCL/convergent.cl
  test/Driver/opencl.cl

Index: test/Driver/opencl.cl
===
--- test/Driver/opencl.cl
+++ test/Driver/opencl.cl
@@ -13,6 +13,7 @@
 // RUN: %clang -S -### -cl-no-signed-zeros %s 2>&1 | FileCheck --check-prefix=CHECK-NO-SIGNED-ZEROS %s
 // RUN: %clang -S -### -cl-denorms-are-zero %s 2>&1 | FileCheck --check-prefix=CHECK-DENORMS-ARE-ZERO %s
 // RUN: %clang -S -### -cl-fp32-correctly-rounded-divide-sqrt %s 2>&1 | FileCheck --check-prefix=CHECK-ROUND-DIV %s
+// RUN: %clang -S -### -cl-uniform-work-group-size %s 2>&1 | FileCheck --check-prefix=CHECK-UNIFORM-WG %s
 // RUN: not %clang -cl-std=c99 -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-C99 %s
 // RUN: not %clang -cl-std=invalid -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID %s
 
@@ -31,6 +32,7 @@
 // CHECK-NO-SIGNED-ZEROS: "-cc1" {{.*}} "-cl-no-signed-zeros"
 // CHECK-DENORMS-ARE-ZERO: "-cc1" {{.*}} "-cl-denorms-are-zero"
 // CHECK-ROUND-DIV: "-cc1" {{.*}} "-cl-fp32-correctly-rounded-divide-sqrt"
+// CHECK-UNIFORM-WG: "-cc1" {{.*}} "-cl-uniform-work-group-size"
 // CHECK-C99: error: invalid value 'c99' in '-cl-std=c99'
 // CHECK-INVALID: error: invalid value 'invalid' in '-cl-std=invalid'
 
Index: test/CodeGenOpenCL/convergent.cl
===
--- test/CodeGenOpenCL/convergent.cl
+++ test/CodeGenOpenCL/convergent.cl
@@ -127,7 +127,7 @@
 // CHECK: declare spir_func void @nodupfun(){{[^#]*}} #[[attr3:[0-9]+]]
 
 // CHECK-LABEL: @assume_convergent_asm
-// CHECK: tail call void asm sideeffect "s_barrier", ""() #4
+// CHECK: tail call void asm sideeffect "s_barrier", ""() #5
 kernel void assume_convergent_asm()
 {
   __asm__ volatile("s_barrier");
@@ -138,4 +138,5 @@
 // CHECK: attributes #2 = { {{[^}]*}}convergent{{[^}]*}} }
 // CHECK: attributes #3 = { {{[^}]*}}convergent noduplicate{{[^}]*}} }
 // CHECK: attributes #4 = { {{[^}]*}}convergent{{[^}]*}} }
-// CHECK: attributes #5 = { {{[^}]*}}convergent noduplicate{{[^}]*}} }
+// CHECK: attributes #5 = { {{[^}]*}}convergent{{[^}]*}} }
+// CHECK: attributes #6 = { {{[^}]*}}convergent noduplicate{{[^}]*}} }
Index: test/CodeGenOpenCL/cl-uniform-wg-size.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/cl-uniform-wg-size.cl
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -emit-llvm -O0 -cl-std=CL1.2 -o - %s 2>&1 | FileCheck %s -check-prefixes CHECK,CHECK-UNIFORM
+// RUN: %clang_cc1 -emit-llvm -O0 -cl-std=CL2.0 -o - %s 2>&1 | FileCheck %s -check-prefixes CHECK,CHECK-NONUNIFORM
+// RUN: %clang_cc1 -emit-llvm -O0 -cl-std=CL2.0 -cl-uniform-work-group-size -o - %s 2>&1 | FileCheck %s -check-prefixes CHECK,CHECK-UNIFORM
+
+kernel void ker() {};
+// CHECK: define{{.*}}@ker() #0
+
+void foo() {};
+// CHECK: define{{.*}}@foo() #1
+
+// CHECK-LABEL: attributes #0
+// CHECK-UNIFORM: "uniform-work-group-size"="true"
+// CHECK-NONUNIFORM: "uniform-work-group-size"="false"
+
+// CHECK-LABEL: attributes #1
+// CHECK-NOT: uniform-work-group-size
Index: test/CodeGenOpenCL/amdgpu-abi-struct-coerce.cl
===
--- test/CodeGenOpenCL/amdgpu-abi-struct-coerce.cl
+++ test/CodeGenOpenCL/amdgpu-abi-struct-coerce.cl
@@ -425,7 +425,7 @@
   return s;
 }
 
-// CHECK: define i32 @func_transparent_union_ret() local_unnamed_addr #0 {
+// CHECK: define i32 @func_transparent_union_ret() local_unnamed_addr #1 {
 // CHECK: ret i32 0
 transparent_u func_transparent_union_ret()
 {
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -659,6 +659,8 @@
   Opts.FlushDenorm = Args.hasArg(OPT_cl_denorms_are_zero);
   Opts.CorrectlyRoundedDivSqrt =
   Args.hasArg(OPT_cl_fp32_correctly_rounded_divide_sqrt);
+  Opts.UniformWGSize =
+  Args.hasArg(OPT_cl_uniform_work_group_size);
   Opts.Reciprocals = Args.getAllArgValues(OPT_mrecip_EQ);
   Opts.ReciprocalMath = Args.hasArg(OPT_freciprocal_math);
   Opts.NoTrappingMath = Args.hasArg(OPT_fno_trapping_math);
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -2379,6 +2379,7 @@
   options::OPT_cl_no_signed_zeros,
   options::OPT_cl_denorms_are_zero,
   

[PATCH] D43518: [clangd] Allow embedders some control over when diagnostics are generated.

2018-02-22 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Not convinced about the flow control stuff - I think you might be 
underestimating the complexity of the cancellation-based approach with the 
extra functionality.
But if you think it would still be more readable the other way, happy to get a 
third opinion.




Comment at: clangd/ClangdServer.h:282
   scheduleReparseAndDiags(PathRef File, VersionedDraft Contents,
+  WantDiagnostics,
   Tagged 
TaggedFS);

ilya-biryukov wrote:
> Maybe add a parameter name here?
> It's mostly a personal preference, I tend to copy-paste parameter lists 
> between declaration/definition site if I change them. Missing parameter names 
> totally break this workflow for me :-)
Done.
My preference is to optimise for reading rather than writing the code, and a 
name that carries no extra semantics is just noise. But I don't care that much.



Comment at: clangd/TUScheduler.cpp:298
+  while (shouldSkipHeadLocked())
+Requests.pop_front();
+  assert(!Requests.empty() && "skipped the whole queue");

ilya-biryukov wrote:
> Instead of skipping requests here we could try removing them from back of the 
> queue in `startTask` (or rewriting the last request instead of adding a new 
> one).
> It feels the code could be simpler, as we will only ever have to remove a 
> single request from the queue. And it could also keep the queue smaller in 
> case of many subsequent `Auto` requests.
> WDYT?
Having startTask look ahead to find things to cancel was the thing I found most 
confusing/limiting in the previous code, so I'd rather not go back there :-)
That said, I did try this first, trying to limit the scope of this patch, but 
it got hard.

The main problems are:
- you're not just looking ahead one task, or even to a fixed one. After [auto 
no], no cancels no, auto cancels both, read cancels neither. The states and the 
state machine are hard to reason about. (unless you just loop over the whole 
queue, which seems just as complex)
- the decision of "should task X run" is distributed over time via mutating 
state, rather than happening at one point via reads
 - when looking at startTask time, you have to reason about the (possibly) 
concurrently running task. In run(), no task is running and nothing can be 
enqueued, so there's no concurrency issues.

>And it could also keep the queue smaller in case of many subsequent Auto 
>requests.
This is true, but it doesn't seem like a practical concern.



Comment at: clangd/TUScheduler.cpp:339
+// Used unless followed by an update that generates diagnostics.
+for (; Next != Requests.end(); ++Next)
+  if (Next->UpdateType == WantDiagnostics::Yes ||

ilya-biryukov wrote:
> Maybe skip updates directly in this function and make it return void?
> Calling a function in a loop that loops through elements itself is a little 
> confusing.
Returning bool constrains the contract of this class to choosing to run one 
item or not, and the type system forces a specific decision.
Returning void leaves the option of purging one or no or multiple items. The 
only void function with a clear contract would be "drop all dead requests at 
the start", which is too complex to get right in one go. (happy to pull the 
loop out of run into such a function if you think it would help, though.)


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43518



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


[clang-tools-extra] r325764 - [clangd] Not collect include headers for dynamic index for now.

2018-02-22 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Thu Feb 22 02:14:05 2018
New Revision: 325764

URL: http://llvm.org/viewvc/llvm-project?rev=325764=rev
Log:
[clangd] Not collect include headers for dynamic index for now.

Summary:
The new behaviors introduced by this patch:
o When include collection is enabled, we always set IncludeHeader field in 
Symbol
even if it's the same as FileURI in decl.
o Disable include collection in FileIndex which is currently only used to build
dynamic index. We should revisit when we actually want to use FileIndex to 
global
index.
o Code-completion only uses IncludeHeader to insert headers but not FileURI in
CanonicalDeclaration. This ensures that inserted headers are always 
canonicalized.
Note that include insertion can still be triggered for symbols that are already
included if they are merged from dynamic index and static index, but we would
only use includes that are already canonicalized (e.g. from static index).

Reason for change:
Collecting header includes in dynamic index enables inserting includes for 
headers
that are not indexed but opened in the editor. Comparing to inserting includes 
for
symbols in global/static index, this is nice-to-have but would probably require
non-trivial amount of work to get right. For example:
o Currently it's not easy to fully support CanonicalIncludes in dynamic index, 
given the way
we run dynamic index.
o It's also harder to reason about the correctness of include canonicalization 
for dynamic index
(i.e. symbols in the current file/TU) than static index where symbols are 
collected
offline and sanity check is possible before shipping to production.
o We have less control/flexibility over symbol info in the dynamic index
(e.g. URIs, path normalization), which could be used to help make decision when 
inserting includes.

As header collection (especially canonicalization) is relatively new, and 
enabling
it for dynamic index would immediately affect current users with only dynamic
index support, I propose we disable it for dynamic index for now to avoid
compromising other hot features like code completion and only support it for
static index where include insertion would likely to bring more value.

Reviewers: ilya-biryukov, sammccall, hokein

Subscribers: klimek, jkorous-apple, cfe-commits

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

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

Modified: clang-tools-extra/trunk/clangd/CodeComplete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CodeComplete.cpp?rev=325764=325763=325764=diff
==
--- clang-tools-extra/trunk/clangd/CodeComplete.cpp (original)
+++ clang-tools-extra/trunk/clangd/CodeComplete.cpp Thu Feb 22 02:14:05 2018
@@ -286,13 +286,9 @@ struct CompletionCandidate {
   I.documentation = D->Documentation;
 if (I.detail.empty())
   I.detail = D->CompletionDetail;
-// We only insert #include for items with details, since we can't tell
-// whether the file URI of the canonical declaration would be the
-// canonical #include without checking IncludeHeader in the detail.
 // FIXME: delay creating include insertion command to
 // "completionItem/resolve", when it is supported
-if (!D->IncludeHeader.empty() ||
-!IndexResult->CanonicalDeclaration.FileURI.empty()) {
+if (!D->IncludeHeader.empty()) {
   // LSP favors additionalTextEdits over command. But we are still 
using
   // command here because it would be expensive to calculate #include
   // insertion edits for all candidates, and the include insertion edit
@@ -301,9 +297,7 @@ struct CompletionCandidate {
   // Command title is not added since this is not a user-facing 
command.
   Cmd.command = ExecuteCommandParams::CLANGD_INSERT_HEADER_INCLUDE;
   IncludeInsertion Insertion;
-  Insertion.header = D->IncludeHeader.empty()
- ? IndexResult->CanonicalDeclaration.FileURI
- : D->IncludeHeader;
+  Insertion.header = D->IncludeHeader;
   Insertion.textDocument.uri = URIForFile(FileName);
   Cmd.includeInsertion = std::move(Insertion);
   I.command = std::move(Cmd);

Modified: clang-tools-extra/trunk/clangd/index/FileIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/FileIndex.cpp?rev=325764=325763=325764=diff
==
--- clang-tools-extra/trunk/clangd/index/FileIndex.cpp (original)
+++ 

[PATCH] D43518: [clangd] Allow embedders some control over when diagnostics are generated.

2018-02-22 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 135382.
sammccall marked an inline comment as done.
sammccall added a comment.

add param names to decls


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43518

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/TUScheduler.cpp
  clangd/TUScheduler.h
  clangd/Threading.cpp
  clangd/Threading.h
  unittests/clangd/TUSchedulerTests.cpp

Index: unittests/clangd/TUSchedulerTests.cpp
===
--- unittests/clangd/TUSchedulerTests.cpp
+++ unittests/clangd/TUSchedulerTests.cpp
@@ -50,7 +50,7 @@
   auto Missing = testPath("missing.cpp");
   Files[Missing] = "";
 
-  S.update(Added, getInputs(Added, ""), ignoreUpdate);
+  S.update(Added, getInputs(Added, ""), WantDiagnostics::No, ignoreUpdate);
 
   // Assert each operation for missing file is an error (even if it's available
   // in VFS).
@@ -88,6 +88,37 @@
   S.remove(Added);
 }
 
+TEST_F(TUSchedulerTests, WantDiagnostics) {
+  std::atomic CallbackCount(0);
+  {
+TUScheduler S(getDefaultAsyncThreadsCount(),
+  /*StorePreamblesInMemory=*/true,
+  /*ASTParsedCallback=*/nullptr);
+auto Path = testPath("foo.cpp");
+
+// To avoid a racy test, don't allow tasks to actualy run on the worker
+// thread until we've scheduled them all.
+Notification Ready;
+S.update(Path, getInputs(Path, ""), WantDiagnostics::Yes,
+ [&](std::vector) { Ready.wait(); });
+
+S.update(Path, getInputs(Path, "request diags"), WantDiagnostics::Yes,
+ [&](std::vector Diags) { ++CallbackCount; });
+S.update(Path, getInputs(Path, "auto (clobbered)"), WantDiagnostics::Auto,
+ [&](std::vector Diags) {
+   ADD_FAILURE() << "auto should have been cancelled by auto";
+ });
+S.update(Path, getInputs(Path, "request no diags"), WantDiagnostics::No,
+ [&](std::vector Diags) {
+   ADD_FAILURE() << "no diags should not be called back";
+ });
+S.update(Path, getInputs(Path, "auto (produces)"), WantDiagnostics::Auto,
+ [&](std::vector Diags) { ++CallbackCount; });
+Ready.notify();
+  }
+  EXPECT_EQ(2, CallbackCount);
+}
+
 TEST_F(TUSchedulerTests, ManyUpdates) {
   const int FilesCount = 3;
   const int UpdatesPerFile = 10;
@@ -132,7 +163,7 @@
 
 {
   WithContextValue WithNonce(NonceKey, ++Nonce);
-  S.update(File, Inputs,
+  S.update(File, Inputs, WantDiagnostics::Auto,
[Nonce, , ](
llvm::Optional Diags) {
  EXPECT_THAT(Context::current().get(NonceKey),
Index: clangd/Threading.h
===
--- clangd/Threading.h
+++ clangd/Threading.h
@@ -13,7 +13,6 @@
 #include "Context.h"
 #include "Function.h"
 #include "llvm/ADT/Twine.h"
-#include 
 #include 
 #include 
 #include 
@@ -23,24 +22,18 @@
 namespace clang {
 namespace clangd {
 
-/// A shared boolean flag indicating if the computation was cancelled.
-/// Once cancelled, cannot be returned to the previous state.
-class CancellationFlag {
+/// A threadsafe flag that is initially clear.
+class Notification {
 public:
-  CancellationFlag();
-
-  void cancel() {
-assert(WasCancelled && "the object was moved");
-WasCancelled->store(true);
-  }
-
-  bool isCancelled() const {
-assert(WasCancelled && "the object was moved");
-return WasCancelled->load();
-  }
+  // Sets the flag. No-op if already set.
+  void notify();
+  // Blocks until flag is set.
+  void wait() const;
 
 private:
-  std::shared_ptr WasCancelled;
+  bool Notified = false;
+  mutable std::condition_variable CV;
+  mutable std::mutex Mu;
 };
 
 /// Limits the number of threads that can acquire the lock at the same time.
Index: clangd/Threading.cpp
===
--- clangd/Threading.cpp
+++ clangd/Threading.cpp
@@ -7,8 +7,18 @@
 namespace clang {
 namespace clangd {
 
-CancellationFlag::CancellationFlag()
-: WasCancelled(std::make_shared(false)) {}
+void Notification::notify() {
+  {
+std::lock_guard Lock(Mu);
+Notified = true;
+  }
+  CV.notify_all();
+}
+
+void Notification::wait() const {
+  std::unique_lock Lock(Mu);
+  CV.wait(Lock, [this] { return Notified; });
+}
 
 Semaphore::Semaphore(std::size_t MaxLocks) : FreeSlots(MaxLocks) {}
 
Index: clangd/TUScheduler.h
===
--- clangd/TUScheduler.h
+++ clangd/TUScheduler.h
@@ -32,6 +32,14 @@
   const PreambleData *Preamble;
 };
 
+/// Determines whether diagnostics should be generated for a file snapshot.
+enum class WantDiagnostics {
+  Yes,  /// Diagnostics must be generated for this snapshot.
+  No,   /// Diagnostics must not be generated for this snapshot.
+  Auto, /// Diagnostics 

[PATCH] D43550: [clangd] Not collect include headers for dynamic index for now.

2018-02-22 Thread Eric Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL325764: [clangd] Not collect include headers for dynamic 
index for now. (authored by ioeric, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D43550

Files:
  clang-tools-extra/trunk/clangd/CodeComplete.cpp
  clang-tools-extra/trunk/clangd/index/FileIndex.cpp
  clang-tools-extra/trunk/clangd/index/Index.h
  clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp
  clang-tools-extra/trunk/unittests/clangd/FileIndexTests.cpp
  clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp

Index: clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp
@@ -585,7 +585,7 @@
   runSymbolCollector("class Foo {};", /*Main=*/"");
   EXPECT_THAT(Symbols,
   UnorderedElementsAre(AllOf(QName("Foo"), DeclURI(TestHeaderURI),
- IncludeHeader("";
+ IncludeHeader(TestHeaderURI;
 }
 
 #ifndef LLVM_ON_WIN32
Index: clang-tools-extra/trunk/unittests/clangd/FileIndexTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/FileIndexTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/FileIndexTests.cpp
@@ -181,19 +181,19 @@
   EXPECT_THAT(match(M, Req), UnorderedElementsAre("X"));
 }
 
-#ifndef LLVM_ON_WIN32
-TEST(FileIndexTest, CanonicalizeSystemHeader) {
+TEST(FileIndexTest, NoIncludeCollected) {
   FileIndex M;
-  std::string File = testPath("bits/basic_string");
-  M.update(File, build(File, "class string {};").getPointer());
+  M.update("f", build("f", "class string {};").getPointer());
 
   FuzzyFindRequest Req;
   Req.Query = "";
+  bool SeenSymbol = false;
   M.fuzzyFind(Req, [&](const Symbol ) {
-EXPECT_EQ(Sym.Detail->IncludeHeader, "");
+EXPECT_TRUE(Sym.Detail->IncludeHeader.empty());
+SeenSymbol = true;
   });
+  EXPECT_TRUE(SeenSymbol);
 }
-#endif
 
 } // namespace
 } // namespace clangd
Index: clang-tools-extra/trunk/clangd/CodeComplete.cpp
===
--- clang-tools-extra/trunk/clangd/CodeComplete.cpp
+++ clang-tools-extra/trunk/clangd/CodeComplete.cpp
@@ -286,24 +286,18 @@
   I.documentation = D->Documentation;
 if (I.detail.empty())
   I.detail = D->CompletionDetail;
-// We only insert #include for items with details, since we can't tell
-// whether the file URI of the canonical declaration would be the
-// canonical #include without checking IncludeHeader in the detail.
 // FIXME: delay creating include insertion command to
 // "completionItem/resolve", when it is supported
-if (!D->IncludeHeader.empty() ||
-!IndexResult->CanonicalDeclaration.FileURI.empty()) {
+if (!D->IncludeHeader.empty()) {
   // LSP favors additionalTextEdits over command. But we are still using
   // command here because it would be expensive to calculate #include
   // insertion edits for all candidates, and the include insertion edit
   // is unlikely to conflict with the code completion edits.
   Command Cmd;
   // Command title is not added since this is not a user-facing command.
   Cmd.command = ExecuteCommandParams::CLANGD_INSERT_HEADER_INCLUDE;
   IncludeInsertion Insertion;
-  Insertion.header = D->IncludeHeader.empty()
- ? IndexResult->CanonicalDeclaration.FileURI
- : D->IncludeHeader;
+  Insertion.header = D->IncludeHeader;
   Insertion.textDocument.uri = URIForFile(FileName);
   Cmd.includeInsertion = std::move(Insertion);
   I.command = std::move(Cmd);
Index: clang-tools-extra/trunk/clangd/index/FileIndex.cpp
===
--- clang-tools-extra/trunk/clangd/index/FileIndex.cpp
+++ clang-tools-extra/trunk/clangd/index/FileIndex.cpp
@@ -15,29 +15,22 @@
 namespace clangd {
 namespace {
 
-const CanonicalIncludes *canonicalIncludesForSystemHeaders() {
-  static const auto *Includes = [] {
-auto *I = new CanonicalIncludes();
-addSystemHeadersMapping(I);
-return I;
-  }();
-  return Includes;
-}
-
 /// Retrieves namespace and class level symbols in \p Decls.
 std::unique_ptr indexAST(ASTContext ,
  std::shared_ptr PP,
  llvm::ArrayRef Decls) {
   SymbolCollector::Options CollectorOpts;
   // Although we do not index symbols in main files (e.g. cpp file), information
   // in main files like definition locations of class declarations will still 

[clang-tools-extra] r325774 - [clangd] Allow embedders some control over when diagnostics are generated.

2018-02-22 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Thu Feb 22 05:11:12 2018
New Revision: 325774

URL: http://llvm.org/viewvc/llvm-project?rev=325774=rev
Log:
[clangd] Allow embedders some control over when diagnostics are generated.

Summary:
Through the C++ API, we support for a given snapshot version:
 - Yes: make sure we generate diagnostics for exactly this version
 - Auto: generate eventually-consistent diagnostics for at least this version
 - No: don't generate diagnostics for this version
Eventually auto should be debounced for better UX.

Through LSP, we force diagnostics for initial load (bypassing future debouncing)
and all updates follow the "auto" policy.

This is complicated to implement under the CancellationFlag design, so
rewrote that part to just inspect the queue instead.

It turns out we never pass None to the diagnostics callback, so remove Optional
from the signature. The questionable behavior of not invoking the callback at
all if CppFile::rebuild fails is not changed.

Reviewers: ilya-biryukov

Subscribers: klimek, jkorous-apple, ioeric, cfe-commits

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

Modified:
clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
clang-tools-extra/trunk/clangd/ClangdServer.cpp
clang-tools-extra/trunk/clangd/ClangdServer.h
clang-tools-extra/trunk/clangd/TUScheduler.cpp
clang-tools-extra/trunk/clangd/TUScheduler.h
clang-tools-extra/trunk/clangd/Threading.cpp
clang-tools-extra/trunk/clangd/Threading.h
clang-tools-extra/trunk/unittests/clangd/TUSchedulerTests.cpp

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=325774=325773=325774=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Thu Feb 22 05:11:12 2018
@@ -141,7 +141,8 @@ void ClangdLSPServer::onDocumentDidOpen(
   if (Params.metadata && !Params.metadata->extraFlags.empty())
 CDB.setExtraFlagsForFile(Params.textDocument.uri.file(),
  std::move(Params.metadata->extraFlags));
-  Server.addDocument(Params.textDocument.uri.file(), Params.textDocument.text);
+  Server.addDocument(Params.textDocument.uri.file(), Params.textDocument.text,
+ WantDiagnostics::Yes);
 }
 
 void ClangdLSPServer::onDocumentDidChange(DidChangeTextDocumentParams ) 
{
@@ -150,7 +151,7 @@ void ClangdLSPServer::onDocumentDidChang
   "can only apply one change at a time");
   // We only support full syncing right now.
   Server.addDocument(Params.textDocument.uri.file(),
- Params.contentChanges[0].text);
+ Params.contentChanges[0].text, WantDiagnostics::Auto);
 }
 
 void ClangdLSPServer::onFileEvent(DidChangeWatchedFilesParams ) {

Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=325774=325773=325774=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Thu Feb 22 05:11:12 2018
@@ -110,11 +110,12 @@ void ClangdServer::setRootPath(PathRef R
 this->RootPath = NewRootPath;
 }
 
-void ClangdServer::addDocument(PathRef File, StringRef Contents) {
+void ClangdServer::addDocument(PathRef File, StringRef Contents,
+   WantDiagnostics WantDiags) {
   DocVersion Version = DraftMgr.updateDraft(File, Contents);
   auto TaggedFS = FSProvider.getTaggedFileSystem(File);
   scheduleReparseAndDiags(File, VersionedDraft{Version, Contents.str()},
-  std::move(TaggedFS));
+  WantDiags, std::move(TaggedFS));
 }
 
 void ClangdServer::removeDocument(PathRef File) {
@@ -133,7 +134,8 @@ void ClangdServer::forceReparse(PathRef
   CompileArgs.invalidate(File);
 
   auto TaggedFS = FSProvider.getTaggedFileSystem(File);
-  scheduleReparseAndDiags(File, std::move(FileContents), std::move(TaggedFS));
+  scheduleReparseAndDiags(File, std::move(FileContents), WantDiagnostics::Yes,
+  std::move(TaggedFS));
 }
 
 void ClangdServer::codeComplete(
@@ -519,20 +521,16 @@ void ClangdServer::findHover(
 }
 
 void ClangdServer::scheduleReparseAndDiags(
-PathRef File, VersionedDraft Contents,
+PathRef File, VersionedDraft Contents, WantDiagnostics WantDiags,
 Tagged TaggedFS) {
   tooling::CompileCommand Command = CompileArgs.getCompileCommand(File);
 
-  using OptDiags = llvm::Optional;
-
   DocVersion Version = Contents.Version;
   Path FileStr = File.str();
   VFSTag Tag = std::move(TaggedFS.Tag);
 
-  auto Callback = [this, Version, FileStr, Tag](OptDiags Diags) {
-if (!Diags)
-  return; // A new 

[PATCH] D43569: [clangd] Correct setting ignoreWarnings in CodeCompletion.

2018-02-22 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 135399.
hokein added a comment.

- add a comment
- find one more incorrect usage, and fix it.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43569

Files:
  clangd/CodeComplete.cpp
  clangd/Headers.cpp


Index: clangd/Headers.cpp
===
--- clangd/Headers.cpp
+++ clangd/Headers.cpp
@@ -71,12 +71,12 @@
   // added more than once.
   CI->getPreprocessorOpts().SingleFileParseMode = true;
 
+  // The diagnostic options must be set before creating a CompilerInstance.
+  CI->getDiagnosticOpts().IgnoreWarnings = true;
   auto Clang = prepareCompilerInstance(
   std::move(CI), /*Preamble=*/nullptr,
   llvm::MemoryBuffer::getMemBuffer(Code, File),
   std::make_shared(), FS, IgnoreDiags);
-  auto  = Clang->getDiagnosticOpts();
-  DiagOpts.IgnoreWarnings = true;
 
   if (Clang->getFrontendOpts().Inputs.empty())
 return llvm::make_error(
Index: clangd/CodeComplete.cpp
===
--- clangd/CodeComplete.cpp
+++ clangd/CodeComplete.cpp
@@ -702,11 +702,11 @@
 Input.Preamble->CanReuse(*CI, ContentsBuffer.get(), Bounds,
  Input.VFS.get());
   }
+  // The diagnostic options must be set before creating a CompilerInstance.
+  CI->getDiagnosticOpts().IgnoreWarnings = true;
   auto Clang = prepareCompilerInstance(
   std::move(CI), Input.Preamble, std::move(ContentsBuffer),
   std::move(Input.PCHs), std::move(Input.VFS), DummyDiagsConsumer);
-  auto  = Clang->getDiagnosticOpts();
-  DiagOpts.IgnoreWarnings = true;
 
   // Disable typo correction in Sema.
   Clang->getLangOpts().SpellChecking = false;


Index: clangd/Headers.cpp
===
--- clangd/Headers.cpp
+++ clangd/Headers.cpp
@@ -71,12 +71,12 @@
   // added more than once.
   CI->getPreprocessorOpts().SingleFileParseMode = true;
 
+  // The diagnostic options must be set before creating a CompilerInstance.
+  CI->getDiagnosticOpts().IgnoreWarnings = true;
   auto Clang = prepareCompilerInstance(
   std::move(CI), /*Preamble=*/nullptr,
   llvm::MemoryBuffer::getMemBuffer(Code, File),
   std::make_shared(), FS, IgnoreDiags);
-  auto  = Clang->getDiagnosticOpts();
-  DiagOpts.IgnoreWarnings = true;
 
   if (Clang->getFrontendOpts().Inputs.empty())
 return llvm::make_error(
Index: clangd/CodeComplete.cpp
===
--- clangd/CodeComplete.cpp
+++ clangd/CodeComplete.cpp
@@ -702,11 +702,11 @@
 Input.Preamble->CanReuse(*CI, ContentsBuffer.get(), Bounds,
  Input.VFS.get());
   }
+  // The diagnostic options must be set before creating a CompilerInstance.
+  CI->getDiagnosticOpts().IgnoreWarnings = true;
   auto Clang = prepareCompilerInstance(
   std::move(CI), Input.Preamble, std::move(ContentsBuffer),
   std::move(Input.PCHs), std::move(Input.VFS), DummyDiagsConsumer);
-  auto  = Clang->getDiagnosticOpts();
-  DiagOpts.IgnoreWarnings = true;
 
   // Disable typo correction in Sema.
   Clang->getLangOpts().SpellChecking = false;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43569: [clangd] Correct setting ignoreWarnings in CodeCompletion.

2018-02-22 Thread Haojian Wu via Phabricator via cfe-commits
hokein marked an inline comment as done.
hokein added inline comments.



Comment at: clangd/CodeComplete.cpp:705
   }
+  CI->getDiagnosticOpts().IgnoreWarnings = true;
   auto Clang = prepareCompilerInstance(

ilya-biryukov wrote:
> Could we add a comment that this should be done before calling 
> `prepareCompilerInstance`?
> I'm afraid this can be accidentally reordered when changing the code.
Yeah! Done.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43569



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


[clang-tools-extra] r325779 - [clangd] Correct setting ignoreWarnings in CodeCompletion.

2018-02-22 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Thu Feb 22 05:35:01 2018
New Revision: 325779

URL: http://llvm.org/viewvc/llvm-project?rev=325779=rev
Log:
[clangd] Correct setting ignoreWarnings in CodeCompletion.

Summary:
We should set the flag before creating ComplierInstance -- when
CopmilerInstance gets initialized, it also initializes the DiagnosticsEngine
using the DiagnosticOptions.

This was hidden deeply -- as clang suppresses all diagnostics when we
hit the code-completion (but internally it does do unnecessary analysis stuff).

As a bonus point, this fix will optmize the completion speed -- clang won't do
any analysis (e.g. -Wunreachable-code, -Wthread-safety-analysisi) at all 
internally.

Reviewers: ilya-biryukov

Reviewed By: ilya-biryukov

Subscribers: klimek, jkorous-apple, ioeric, cfe-commits

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

Modified:
clang-tools-extra/trunk/clangd/CodeComplete.cpp
clang-tools-extra/trunk/clangd/Headers.cpp

Modified: clang-tools-extra/trunk/clangd/CodeComplete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CodeComplete.cpp?rev=325779=325778=325779=diff
==
--- clang-tools-extra/trunk/clangd/CodeComplete.cpp (original)
+++ clang-tools-extra/trunk/clangd/CodeComplete.cpp Thu Feb 22 05:35:01 2018
@@ -696,11 +696,11 @@ bool semaCodeComplete(std::unique_ptrCanReuse(*CI, ContentsBuffer.get(), Bounds,
  Input.VFS.get());
   }
+  // The diagnostic options must be set before creating a CompilerInstance.
+  CI->getDiagnosticOpts().IgnoreWarnings = true;
   auto Clang = prepareCompilerInstance(
   std::move(CI), Input.Preamble, std::move(ContentsBuffer),
   std::move(Input.PCHs), std::move(Input.VFS), DummyDiagsConsumer);
-  auto  = Clang->getDiagnosticOpts();
-  DiagOpts.IgnoreWarnings = true;
 
   // Disable typo correction in Sema.
   Clang->getLangOpts().SpellChecking = false;

Modified: clang-tools-extra/trunk/clangd/Headers.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Headers.cpp?rev=325779=325778=325779=diff
==
--- clang-tools-extra/trunk/clangd/Headers.cpp (original)
+++ clang-tools-extra/trunk/clangd/Headers.cpp Thu Feb 22 05:35:01 2018
@@ -79,12 +79,12 @@ calculateIncludePath(llvm::StringRef Fil
   // added more than once.
   CI->getPreprocessorOpts().SingleFileParseMode = true;
 
+  // The diagnostic options must be set before creating a CompilerInstance.
+  CI->getDiagnosticOpts().IgnoreWarnings = true;
   auto Clang = prepareCompilerInstance(
   std::move(CI), /*Preamble=*/nullptr,
   llvm::MemoryBuffer::getMemBuffer(Code, File),
   std::make_shared(), FS, IgnoreDiags);
-  auto  = Clang->getDiagnosticOpts();
-  DiagOpts.IgnoreWarnings = true;
 
   if (Clang->getFrontendOpts().Inputs.empty())
 return llvm::make_error(


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


[PATCH] D41102: Setup clang-doc frontend framework

2018-02-22 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: clang-doc/BitcodeWriter.cpp:149
+
+/// \brief Emits a record ID in the BLOCKINFO block.
+void ClangDocBitcodeWriter::emitRecordID(RecordId ID) {

For me, with no prior knowledge of llvm's bitstreams, it was not obvious that 
the differences with `emitBlockID()` are intentional.
Maybe add a comment noting that for blocks, we do output their ID, but for 
records, we only output their name.



Comment at: clang-doc/BitcodeWriter.cpp:178
+void ClangDocBitcodeWriter::emitLocationAbbrev(RecordId ID, BlockId Block) {
+  auto EmitString = [](std::shared_ptr ) {
+Abbrev->Add(

That should be `EmitLocation`



Comment at: clang-doc/BitcodeWriter.cpp:191
+void ClangDocBitcodeWriter::emitIntAbbrev(RecordId ID, BlockId Block) {
+  auto EmitString = [](std::shared_ptr ) {
+Abbrev->Add(

`EmitInt`



Comment at: clang-doc/BitcodeWriter.cpp:219
+
+void ClangDocBitcodeWriter::emitIntRecord(int Value, RecordId ID) {
+  if (!Value) return;

Now, all these three `emit*Record` functions now have the 'same signature':
```
template 
void ClangDocBitcodeWriter::emitRecord(const T& Record, RecordId ID);

template <>
void ClangDocBitcodeWriter::emitRecord(StringRef Str, RecordId ID) {
...
```

**Assuming there are no implicit conversions going on**, i'd make that change.
It, again, may open the road for further generalizations.



Comment at: clang-doc/BitcodeWriter.h:24
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/Bitcode/BitstreamReader.h"
+#include "llvm/Bitcode/BitstreamWriter.h"

Is `BitstreamReader.h` include needed here?



Comment at: clang-doc/BitcodeWriter.h:142
+AbbreviationMap() {}
+void add(RecordId RID, unsigned abbrevID);
+unsigned get(RecordId RID) const;

`void add(RecordId RID, unsigned AbbrevID);`




Comment at: clang-doc/BitcodeWriter.h:175
+  void emitStringRecord(StringRef Str, RecordId ID);
+  void emitLocationRecord(int LineNumber, StringRef File, RecordId ID);
+  void emitIntRecord(int Value, RecordId ID);

You have already included `"Representation.h"` here.
Why don't you just pass `const Location& Loc` into this function?



Comment at: clang-doc/BitcodeWriter.h:177
+  void emitIntRecord(int Value, RecordId ID);
+  void emitTypeBlock(const std::unique_ptr );
+  void emitMemberTypeBlock(const std::unique_ptr );

New line
```
void emitIntRecord(int Value, RecordId ID);

void emitTypeBlock(const std::unique_ptr );
```



Comment at: clang-doc/BitcodeWriter.h:178
+  void emitTypeBlock(const std::unique_ptr );
+  void emitMemberTypeBlock(const std::unique_ptr );
+  void emitFieldTypeBlock(const std::unique_ptr );

Let's continue cracking down on duplication.
I think these four functions need the same template treatment as 
`writeBitstreamForInfo()`

(please feel free to use better names)
```
template
void emitBlock(const std::unique_ptr );

template
void emitTypedBlock(const std::unique_ptr ) {
  StreamSubBlockGuard Block(Stream, MapFromInfoToBlockId::ID);
  emitBlock(B);
}

template<>
void ClangDocBitcodeWriter::emitBlock(const std::unique_ptr ) {
  emitStringRecord(T->TypeUSR, FIELD_TYPE_TYPE);
  for (const auto  : T->Description) emitCommentBlock(CI);
}
```

I agree that it seems strange, and seem to actually increase the code size so 
far,
but i believe by exposing similar functionality under one function,
later, it will open the road for more opportunities of further consolidation.


https://reviews.llvm.org/D41102



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


[PATCH] D43518: [clangd] Allow embedders some control over when diagnostics are generated.

2018-02-22 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov added a comment.
This revision is now accepted and ready to land.

LGTM (just one more possibly useful nit about const)




Comment at: clangd/TUScheduler.cpp:298
+  while (shouldSkipHeadLocked())
+Requests.pop_front();
+  assert(!Requests.empty() && "skipped the whole queue");

ilya-biryukov wrote:
> sammccall wrote:
> > ilya-biryukov wrote:
> > > Instead of skipping requests here we could try removing them from back of 
> > > the queue in `startTask` (or rewriting the last request instead of adding 
> > > a new one).
> > > It feels the code could be simpler, as we will only ever have to remove a 
> > > single request from the queue. And it could also keep the queue smaller 
> > > in case of many subsequent `Auto` requests.
> > > WDYT?
> > Having startTask look ahead to find things to cancel was the thing I found 
> > most confusing/limiting in the previous code, so I'd rather not go back 
> > there :-)
> > That said, I did try this first, trying to limit the scope of this patch, 
> > but it got hard.
> > 
> > The main problems are:
> > - you're not just looking ahead one task, or even to a fixed one. After 
> > [auto no], no cancels no, auto cancels both, read cancels neither. The 
> > states and the state machine are hard to reason about. (unless you just 
> > loop over the whole queue, which seems just as complex)
> > - the decision of "should task X run" is distributed over time via mutating 
> > state, rather than happening at one point via reads
> >  - when looking at startTask time, you have to reason about the (possibly) 
> > concurrently running task. In run(), no task is running and nothing can be 
> > enqueued, so there's no concurrency issues.
> > 
> > >And it could also keep the queue smaller in case of many subsequent Auto 
> > >requests.
> > This is true, but it doesn't seem like a practical concern.
> Thanks for clarifying. The first bullet point shouldn't be a big a problem. 
> Yes, the new task can remove multiple items from the back of the queue, but 
> the implementation still looks more natural as it only needs to inspect the 
> **last**  item on the queue on each of the outer loop iterations. (While the 
> current implementation has to do an inner loop through multiple items on the 
> queue in addition to the outer loop).
> 
> The second point makes it hard, though. I would probably go with calling 
> `pop_front()` when removing the request and signalling empty queue separately.
> 
> > This is true, but it doesn't seem like a practical concern.
> It isn't, but I still think it's a nice-to-have.
As discussed offline, I totally missed the case when the new request comes in 
and has to cancel requests from the middle of the queue. So the implementation 
I proposed would probably still have two loops and not be less complex.

So LGTM here, my suggestions won't make things simpler.



Comment at: clangd/TUScheduler.cpp:105
+  /// Should the first task in the queue be skipped instead of run?
+  bool shouldSkipHeadLocked();
 

NIT: this could be made `const`


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43518



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


[PATCH] D43569: [clangd] Correct setting ignoreWarnings in CodeCompletion.

2018-02-22 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov added a comment.
This revision is now accepted and ready to land.

LGTM with a minor nit.




Comment at: clangd/CodeComplete.cpp:705
   }
+  CI->getDiagnosticOpts().IgnoreWarnings = true;
   auto Clang = prepareCompilerInstance(

Could we add a comment that this should be done before calling 
`prepareCompilerInstance`?
I'm afraid this can be accidentally reordered when changing the code.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43569



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


[PATCH] D43518: [clangd] Allow embedders some control over when diagnostics are generated.

2018-02-22 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL325774: [clangd] Allow embedders some control over when 
diagnostics are generated. (authored by sammccall, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D43518?vs=135382=135398#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D43518

Files:
  clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
  clang-tools-extra/trunk/clangd/ClangdServer.cpp
  clang-tools-extra/trunk/clangd/ClangdServer.h
  clang-tools-extra/trunk/clangd/TUScheduler.cpp
  clang-tools-extra/trunk/clangd/TUScheduler.h
  clang-tools-extra/trunk/clangd/Threading.cpp
  clang-tools-extra/trunk/clangd/Threading.h
  clang-tools-extra/trunk/unittests/clangd/TUSchedulerTests.cpp

Index: clang-tools-extra/trunk/unittests/clangd/TUSchedulerTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/TUSchedulerTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/TUSchedulerTests.cpp
@@ -50,7 +50,7 @@
   auto Missing = testPath("missing.cpp");
   Files[Missing] = "";
 
-  S.update(Added, getInputs(Added, ""), ignoreUpdate);
+  S.update(Added, getInputs(Added, ""), WantDiagnostics::No, ignoreUpdate);
 
   // Assert each operation for missing file is an error (even if it's available
   // in VFS).
@@ -88,6 +88,37 @@
   S.remove(Added);
 }
 
+TEST_F(TUSchedulerTests, WantDiagnostics) {
+  std::atomic CallbackCount(0);
+  {
+TUScheduler S(getDefaultAsyncThreadsCount(),
+  /*StorePreamblesInMemory=*/true,
+  /*ASTParsedCallback=*/nullptr);
+auto Path = testPath("foo.cpp");
+
+// To avoid a racy test, don't allow tasks to actualy run on the worker
+// thread until we've scheduled them all.
+Notification Ready;
+S.update(Path, getInputs(Path, ""), WantDiagnostics::Yes,
+ [&](std::vector) { Ready.wait(); });
+
+S.update(Path, getInputs(Path, "request diags"), WantDiagnostics::Yes,
+ [&](std::vector Diags) { ++CallbackCount; });
+S.update(Path, getInputs(Path, "auto (clobbered)"), WantDiagnostics::Auto,
+ [&](std::vector Diags) {
+   ADD_FAILURE() << "auto should have been cancelled by auto";
+ });
+S.update(Path, getInputs(Path, "request no diags"), WantDiagnostics::No,
+ [&](std::vector Diags) {
+   ADD_FAILURE() << "no diags should not be called back";
+ });
+S.update(Path, getInputs(Path, "auto (produces)"), WantDiagnostics::Auto,
+ [&](std::vector Diags) { ++CallbackCount; });
+Ready.notify();
+  }
+  EXPECT_EQ(2, CallbackCount);
+}
+
 TEST_F(TUSchedulerTests, ManyUpdates) {
   const int FilesCount = 3;
   const int UpdatesPerFile = 10;
@@ -132,7 +163,7 @@
 
 {
   WithContextValue WithNonce(NonceKey, ++Nonce);
-  S.update(File, Inputs,
+  S.update(File, Inputs, WantDiagnostics::Auto,
[Nonce, , ](
llvm::Optional Diags) {
  EXPECT_THAT(Context::current().get(NonceKey),
Index: clang-tools-extra/trunk/clangd/TUScheduler.h
===
--- clang-tools-extra/trunk/clangd/TUScheduler.h
+++ clang-tools-extra/trunk/clangd/TUScheduler.h
@@ -32,6 +32,14 @@
   const PreambleData *Preamble;
 };
 
+/// Determines whether diagnostics should be generated for a file snapshot.
+enum class WantDiagnostics {
+  Yes,  /// Diagnostics must be generated for this snapshot.
+  No,   /// Diagnostics must not be generated for this snapshot.
+  Auto, /// Diagnostics must be generated for this snapshot or a subsequent one,
+/// within a bounded amount of time.
+};
+
 /// Handles running tasks for ClangdServer and managing the resources (e.g.,
 /// preambles and ASTs) for opened files.
 /// TUScheduler is not thread-safe, only one thread should be providing updates
@@ -51,9 +59,8 @@
   /// Schedule an update for \p File. Adds \p File to a list of tracked files if
   /// \p File was not part of it before.
   /// FIXME(ibiryukov): remove the callback from this function.
-  void update(PathRef File, ParseInputs Inputs,
-  UniqueFunction)>
-  OnUpdated);
+  void update(PathRef File, ParseInputs Inputs, WantDiagnostics WD,
+  UniqueFunction OnUpdated);
 
   /// Remove \p File from the list of tracked files and schedule removal of its
   /// resources.
Index: clang-tools-extra/trunk/clangd/ClangdServer.h
===
--- clang-tools-extra/trunk/clangd/ClangdServer.h
+++ clang-tools-extra/trunk/clangd/ClangdServer.h
@@ -150,7 +150,8 @@
   /// \p File is already tracked. Also schedules parsing of the AST for it on a
   /// separate thread. When the parsing is complete, 

[PATCH] D43500: [clang-tidy]: modernize-use-default-member-init: Remove trailing comma and colon.

2018-02-22 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a reviewer: ioeric.
alexfh added a comment.

In https://reviews.llvm.org/D43500#1013497, @aaron.ballman wrote:

> > It seems, when they are apply directly from clang-tidy, the RefactoringTool 
> > engine is smart enough to remove trailing tokens. However, when fixes are 
> > exported, clang-apply-replacements cannot do the same trick and will lead 
> > trailing commas and colon
>
> Is there a way to make clang-apply-replacements smarter rather than forcing 
> every check to jump through hoops? I'm worried that if we have to fix 
> individual checks we'll just run into the same bug later.


Eric was going to look at this, IIRC.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43500



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


[PATCH] D43569: [clangd] Correct setting ignoreWarnings in CodeCompletion.

2018-02-22 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
hokein marked an inline comment as done.
Closed by commit rL325779: [clangd] Correct setting ignoreWarnings in 
CodeCompletion. (authored by hokein, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D43569

Files:
  clang-tools-extra/trunk/clangd/CodeComplete.cpp
  clang-tools-extra/trunk/clangd/Headers.cpp


Index: clang-tools-extra/trunk/clangd/Headers.cpp
===
--- clang-tools-extra/trunk/clangd/Headers.cpp
+++ clang-tools-extra/trunk/clangd/Headers.cpp
@@ -79,12 +79,12 @@
   // added more than once.
   CI->getPreprocessorOpts().SingleFileParseMode = true;
 
+  // The diagnostic options must be set before creating a CompilerInstance.
+  CI->getDiagnosticOpts().IgnoreWarnings = true;
   auto Clang = prepareCompilerInstance(
   std::move(CI), /*Preamble=*/nullptr,
   llvm::MemoryBuffer::getMemBuffer(Code, File),
   std::make_shared(), FS, IgnoreDiags);
-  auto  = Clang->getDiagnosticOpts();
-  DiagOpts.IgnoreWarnings = true;
 
   if (Clang->getFrontendOpts().Inputs.empty())
 return llvm::make_error(
Index: clang-tools-extra/trunk/clangd/CodeComplete.cpp
===
--- clang-tools-extra/trunk/clangd/CodeComplete.cpp
+++ clang-tools-extra/trunk/clangd/CodeComplete.cpp
@@ -696,11 +696,11 @@
 Input.Preamble->CanReuse(*CI, ContentsBuffer.get(), Bounds,
  Input.VFS.get());
   }
+  // The diagnostic options must be set before creating a CompilerInstance.
+  CI->getDiagnosticOpts().IgnoreWarnings = true;
   auto Clang = prepareCompilerInstance(
   std::move(CI), Input.Preamble, std::move(ContentsBuffer),
   std::move(Input.PCHs), std::move(Input.VFS), DummyDiagsConsumer);
-  auto  = Clang->getDiagnosticOpts();
-  DiagOpts.IgnoreWarnings = true;
 
   // Disable typo correction in Sema.
   Clang->getLangOpts().SpellChecking = false;


Index: clang-tools-extra/trunk/clangd/Headers.cpp
===
--- clang-tools-extra/trunk/clangd/Headers.cpp
+++ clang-tools-extra/trunk/clangd/Headers.cpp
@@ -79,12 +79,12 @@
   // added more than once.
   CI->getPreprocessorOpts().SingleFileParseMode = true;
 
+  // The diagnostic options must be set before creating a CompilerInstance.
+  CI->getDiagnosticOpts().IgnoreWarnings = true;
   auto Clang = prepareCompilerInstance(
   std::move(CI), /*Preamble=*/nullptr,
   llvm::MemoryBuffer::getMemBuffer(Code, File),
   std::make_shared(), FS, IgnoreDiags);
-  auto  = Clang->getDiagnosticOpts();
-  DiagOpts.IgnoreWarnings = true;
 
   if (Clang->getFrontendOpts().Inputs.empty())
 return llvm::make_error(
Index: clang-tools-extra/trunk/clangd/CodeComplete.cpp
===
--- clang-tools-extra/trunk/clangd/CodeComplete.cpp
+++ clang-tools-extra/trunk/clangd/CodeComplete.cpp
@@ -696,11 +696,11 @@
 Input.Preamble->CanReuse(*CI, ContentsBuffer.get(), Bounds,
  Input.VFS.get());
   }
+  // The diagnostic options must be set before creating a CompilerInstance.
+  CI->getDiagnosticOpts().IgnoreWarnings = true;
   auto Clang = prepareCompilerInstance(
   std::move(CI), Input.Preamble, std::move(ContentsBuffer),
   std::move(Input.PCHs), std::move(Input.VFS), DummyDiagsConsumer);
-  auto  = Clang->getDiagnosticOpts();
-  DiagOpts.IgnoreWarnings = true;
 
   // Disable typo correction in Sema.
   Clang->getLangOpts().SpellChecking = false;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D41537: Optionally add code completion results for arrow instead of dot

2018-02-22 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

In https://reviews.llvm.org/D41537#1015563, @yvvan wrote:

> Or is your idea is to return the char sequence instead to use this correction 
> in some universal way?


Exactly. Editors that implement corrections would pick up any new corrections 
automatically, rather than implementing each specific correction separately.


https://reviews.llvm.org/D41537



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


Re: r324308 - Fix crash on invalid.

2018-02-22 Thread Hans Wennborg via cfe-commits
Seems safe. Merged in r325766.

On Thu, Feb 22, 2018 at 1:15 AM, Richard Trieu  wrote:
> Hi Hans,
>
> If there's still time for rc3, I'd like to get this crash fix in.  This adds
> a null check to prevent a crash on invalid.
>
> Richard
>
> On Mon, Feb 5, 2018 at 6:58 PM, Richard Trieu via cfe-commits
>  wrote:
>>
>> Author: rtrieu
>> Date: Mon Feb  5 18:58:21 2018
>> New Revision: 324308
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=324308=rev
>> Log:
>> Fix crash on invalid.
>>
>> Don't call a method when the pointer is null.
>>
>> Modified:
>> cfe/trunk/lib/Sema/SemaExpr.cpp
>> cfe/trunk/test/SemaCXX/lambda-expressions.cpp
>>
>> Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=324308=324307=324308=diff
>>
>> ==
>> --- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Feb  5 18:58:21 2018
>> @@ -14958,7 +14958,8 @@ static void DoMarkVarDeclReferenced(Sema
>>  if (RefersToEnclosingScope) {
>>LambdaScopeInfo *const LSI =
>>SemaRef.getCurLambda(/*IgnoreNonLambdaCapturingScope=*/true);
>> -  if (LSI && !LSI->CallOperator->Encloses(Var->getDeclContext())) {
>> +  if (LSI && (!LSI->CallOperator ||
>> +  !LSI->CallOperator->Encloses(Var->getDeclContext( {
>>  // If a variable could potentially be odr-used, defer marking it
>> so
>>  // until we finish analyzing the full expression for any
>>  // lvalue-to-rvalue
>>
>> Modified: cfe/trunk/test/SemaCXX/lambda-expressions.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/lambda-expressions.cpp?rev=324308=324307=324308=diff
>>
>> ==
>> --- cfe/trunk/test/SemaCXX/lambda-expressions.cpp (original)
>> +++ cfe/trunk/test/SemaCXX/lambda-expressions.cpp Mon Feb  5 18:58:21 2018
>> @@ -608,3 +608,18 @@ namespace ConversionOperatorDoesNotHaveD
>>// This used to crash in return type deduction for the conversion
>> opreator.
>>struct A { int n; void f() { +[](decltype(n)) {}; } };
>>  }
>> +
>> +namespace TypoCorrection {
>> +template  struct X {};
>> +// expected-note@-1 {{template parameter is declared here}}
>> +
>> +template 
>> +void Run(const int& points) {
>> +// expected-note@-1 {{'points' declared here}}
>> +  auto outer_lambda = []() {
>> +auto inner_lambda = [](const X&) {};
>> +// expected-error@-1 {{use of undeclared identifier 'Points'; did you
>> mean 'points'?}}
>> +// expected-error@-2 {{template argument for template type parameter
>> must be a type}}
>> +  };
>> +}
>> +}
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D41880: Adding nocf_check attribute for cf-protection fine tuning

2018-02-22 Thread Oren Ben Simhon via Phabricator via cfe-commits
oren_ben_simhon updated this revision to Diff 135386.
oren_ben_simhon added a comment.

Implemented comments posted until 02/22 (Thanks Aaron).


Repository:
  rL LLVM

https://reviews.llvm.org/D41880

Files:
  include/clang/AST/Type.h
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/LangOptions.def
  include/clang/CodeGen/CGFunctionInfo.h
  include/clang/Sema/Sema.h
  lib/AST/ASTContext.cpp
  lib/AST/Type.cpp
  lib/AST/TypePrinter.cpp
  lib/CodeGen/CGCall.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaType.cpp
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTWriter.cpp
  test/CodeGen/attributes.c
  test/CodeGen/cetintrin.c
  test/CodeGen/x86-cf-protection.c
  test/Misc/pragma-attribute-supported-attributes-list.test
  test/Sema/attr-nocf_check.c
  test/Sema/attr-nocf_check.cpp

Index: test/Sema/attr-nocf_check.cpp
===
--- /dev/null
+++ test/Sema/attr-nocf_check.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -verify -fcf-protection=branch -target-feature +ibt -fsyntax-only %s
+
+// Function pointer definition.
+typedef void (*FuncPointerWithNoCfCheck)(void) __attribute__((nocf_check)); // no-warning
+typedef void (*FuncPointer)(void);
+
+// Dont allow function declaration and definition mismatch.
+void __attribute__((nocf_check)) testNoCfCheck();   // expected-note {{previous declaration is here}}
+void testNoCfCheck(){}; //  expected-error {{conflicting types for 'testNoCfCheck'}}
+
+// No variable or parameter declaration
+__attribute__((nocf_check)) int i;  // expected-warning {{'nocf_check' attribute only applies to function}}
+void testNoCfCheckImpl(double __attribute__((nocf_check)) i) {} // expected-warning {{'nocf_check' attribute only applies to function}}
+
+// Allow attributed function pointers as well as casting between attributed
+// and non-attributed function pointers.
+void testNoCfCheckMismatch(FuncPointer f) {
+  FuncPointerWithNoCfCheck fNoCfCheck = f; // expected-error {{cannot initialize a variable of type 'FuncPointerWithNoCfCheck'}}
+  (*fNoCfCheck)(); // no-warning
+}
+
+// 'nocf_check' Attribute has no parameters.
+int testNoCfCheckParams() __attribute__((nocf_check(1))); // expected-error {{'nocf_check' attribute takes no arguments}}
Index: test/Sema/attr-nocf_check.c
===
--- /dev/null
+++ test/Sema/attr-nocf_check.c
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -verify -fcf-protection=branch -target-feature +ibt -fsyntax-only %s
+
+// Function pointer definition.
+typedef void (*FuncPointerWithNoCfCheck)(void) __attribute__((nocf_check)); // no-warning
+typedef void (*FuncPointer)(void);
+
+// Dont allow function declaration and definition mismatch.
+void __attribute__((nocf_check)) testNoCfCheck();   // expected-note {{previous declaration is here}}
+void testNoCfCheck(){}; //  expected-error {{conflicting types for 'testNoCfCheck'}}
+
+// No variable or parameter declaration
+__attribute__((nocf_check)) int i;  // expected-warning {{'nocf_check' attribute only applies to function}}
+void testNoCfCheckImpl(double __attribute__((nocf_check)) i) {} // expected-warning {{'nocf_check' attribute only applies to function}}
+
+// Allow attributed function pointers as well as casting between attributed
+// and non-attributed function pointers.
+void testNoCfCheckMismatch(FuncPointer f) {
+  FuncPointerWithNoCfCheck fNoCfCheck = f; // expected-warning {{incompatible function pointer types}}
+  (*fNoCfCheck)(); // no-warning
+}
+
+// 'nocf_check' Attribute has no parameters.
+int testNoCfCheckParams() __attribute__((nocf_check(1))); // expected-error {{'nocf_check' attribute takes no arguments}}
Index: test/Misc/pragma-attribute-supported-attributes-list.test
===
--- test/Misc/pragma-attribute-supported-attributes-list.test
+++ test/Misc/pragma-attribute-supported-attributes-list.test
@@ -2,7 +2,7 @@
 
 // The number of supported attributes should never go down!
 
-// CHECK: #pragma clang attribute supports 66 attributes:
+// CHECK: #pragma clang attribute supports 67 attributes:
 // CHECK-NEXT: AMDGPUFlatWorkGroupSize (SubjectMatchRule_function)
 // CHECK-NEXT: AMDGPUNumSGPR (SubjectMatchRule_function)
 // CHECK-NEXT: AMDGPUNumVGPR (SubjectMatchRule_function)
@@ -12,6 +12,7 @@
 // CHECK-NEXT: AlignValue (SubjectMatchRule_variable, SubjectMatchRule_type_alias)
 // CHECK-NEXT: AllocSize (SubjectMatchRule_function)
 // CHECK-NEXT: Annotate ()
+// CHECK-NEXT: AnyX86NoCfCheck (SubjectMatchRule_hasType_functionType)
 // CHECK-NEXT: AssumeAligned (SubjectMatchRule_objc_method, SubjectMatchRule_function)
 // CHECK-NEXT: Availability ((SubjectMatchRule_record, SubjectMatchRule_enum, 

[PATCH] D41880: Adding nocf_check attribute for cf-protection fine tuning

2018-02-22 Thread Oren Ben Simhon via Phabricator via cfe-commits
oren_ben_simhon marked 2 inline comments as done.
oren_ben_simhon added a comment.

I added a comment ignoring nocf_check attribute in case -fcf-protection is not 
set.
Now LLVM is identical to GCC.




Comment at: test/Sema/attr-nocf_check.c:18-20
+  FuncPointerWithNoCfCheck fNoCfCheck = f; // no-warning
+  (*fNoCfCheck)();   // no-warning
+  f = fNoCfCheck;// no-warning

aaron.ballman wrote:
> aaron.ballman wrote:
> > oren_ben_simhon wrote:
> > > aaron.ballman wrote:
> > > > oren_ben_simhon wrote:
> > > > > aaron.ballman wrote:
> > > > > > oren_ben_simhon wrote:
> > > > > > > aaron.ballman wrote:
> > > > > > > > These are an error in GCC and I think we should match that 
> > > > > > > > behavior. https://godbolt.org/g/r3pf4X
> > > > > > > I will create a warning however in LLVM we don't create an error 
> > > > > > > upon incompatible pointer due to function attribute types.
> > > > > > It should be an error -- Clang does error on this sort of thing 
> > > > > > when appropriate (which I believe it is, here). For instance, 
> > > > > > calling convention attributes do this: https://godbolt.org/g/mkTGLg
> > > > > In Clang there is Sema::IncompatiblePointer in case to pointers are 
> > > > > not compatible. This flag emits warning message. In the time i check 
> > > > > for pointer incompatibility (checkPointerTypesForAssignment()), i 
> > > > > don;t have a handle to the attributes. Any suggestion how to 
> > > > > implement the exception for nocf_check attribute?
> > > > I believe this is handled in `ASTContext::mergeFunctionType()`. See:
> > > > ```
> > > >   // Compatible functions must have compatible calling conventions
> > > >   if (lbaseInfo.getCC() != rbaseInfo.getCC())
> > > > return QualType();
> > > > ```
> > > > Somewhere around there is likely where you should be.
> > > I already added there getnocfcheck.
> > > 
> > > After double checking, I see that nocf_check behavior is identical to 
> > > other function attributes.
> > > For some reason in the clang tests they give warning but in godbolt it 
> > > gives an error.
> > > I am not sure what is the difference between the flags in godbolt and in 
> > > my test but this is what causing the warning/error message difference.
> > > 
> > > So basically my behavior is identical to other function type attributes 
> > > (e.g. no_caller_saved_registers). I believe it is also identical to GCC 
> > > but i can't prove it because i don't know the flags that godbolt is using.
> > > 
> > You can see the flags being passed in godbolt by passing -v on the command 
> > line. FWIW, I get the same error behavior elsewhere as well:
> > 
> > http://coliru.stacked-crooked.com/a/d28234385fa68374
> > https://wandbox.org/permlink/SRLM82l2uJ8q3o1Q
> > 
> > I think you should do some more investigation into what's going on there. 
> > Ultimately, I want to avoid clang accepting the `nocf_check` attribute 
> > (even with a warning) in cases where GCC doesn't accept it, because that 
> > leads to incompatibilities when switching between the two compilers. We 
> > should accept what GCC accepts and reject what GCC rejects unless there's a 
> > good reason to deviate.
> Ah, I think the distinction here is C++ vs C code. In C, this code should 
> warn, in C++ this code should err. I'm guessing that if you add a C++ test 
> case, the behavior will be to err on this without any other code changes.
Indeed the difference is C++ Vs C. I added a new test that checks for C++ as 
well.


Repository:
  rL LLVM

https://reviews.llvm.org/D41880



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


[PATCH] D43570: [OpenCL] Add '-cl-uniform-work-group-size' compile option

2018-02-22 Thread Alexey Sotkin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL325771: [OpenCL] Add -cl-uniform-work-group-size 
compile option (authored by AlexeySotkin, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D43570

Files:
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/include/clang/Frontend/CodeGenOptions.def
  cfe/trunk/lib/CodeGen/CGCall.cpp
  cfe/trunk/lib/Driver/ToolChains/Clang.cpp
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/test/CodeGenOpenCL/amdgpu-abi-struct-coerce.cl
  cfe/trunk/test/CodeGenOpenCL/cl-uniform-wg-size.cl
  cfe/trunk/test/CodeGenOpenCL/convergent.cl
  cfe/trunk/test/Driver/opencl.cl

Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -518,6 +518,8 @@
   HelpText<"OpenCL only. Allow denormals to be flushed to zero.">;
 def cl_fp32_correctly_rounded_divide_sqrt : Flag<["-"], "cl-fp32-correctly-rounded-divide-sqrt">, Group, Flags<[CC1Option]>,
   HelpText<"OpenCL only. Specify that single precision floating-point divide and sqrt used in the program source are correctly rounded.">;
+def cl_uniform_work_group_size : Flag<["-"], "cl-uniform-work-group-size">, Group, Flags<[CC1Option]>,
+  HelpText<"OpenCL only. Defines that the global work-size be a multiple of the work-group size specified to clEnqueueNDRangeKernel">;
 def client__name : JoinedOrSeparate<["-"], "client_name">;
 def combine : Flag<["-", "--"], "combine">, Flags<[DriverOption, Unsupported]>;
 def compatibility__version : JoinedOrSeparate<["-"], "compatibility_version">;
Index: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
===
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def
@@ -128,6 +128,7 @@
 CODEGENOPT(NoNaNsFPMath  , 1, 0) ///< Assume FP arguments, results not NaN.
 CODEGENOPT(FlushDenorm   , 1, 0) ///< Allow FP denorm numbers to be flushed to zero
 CODEGENOPT(CorrectlyRoundedDivSqrt, 1, 0) ///< -cl-fp32-correctly-rounded-divide-sqrt
+CODEGENOPT(UniformWGSize , 1, 0) ///< -cl-uniform-work-group-size
 CODEGENOPT(NoZeroInitializedInBSS , 1, 0) ///< -fno-zero-initialized-in-bss.
 /// \brief Method of Objective-C dispatch to use.
 ENUM_CODEGENOPT(ObjCDispatchMethod, ObjCDispatchMethodKind, 2, Legacy)
Index: cfe/trunk/test/Driver/opencl.cl
===
--- cfe/trunk/test/Driver/opencl.cl
+++ cfe/trunk/test/Driver/opencl.cl
@@ -13,6 +13,7 @@
 // RUN: %clang -S -### -cl-no-signed-zeros %s 2>&1 | FileCheck --check-prefix=CHECK-NO-SIGNED-ZEROS %s
 // RUN: %clang -S -### -cl-denorms-are-zero %s 2>&1 | FileCheck --check-prefix=CHECK-DENORMS-ARE-ZERO %s
 // RUN: %clang -S -### -cl-fp32-correctly-rounded-divide-sqrt %s 2>&1 | FileCheck --check-prefix=CHECK-ROUND-DIV %s
+// RUN: %clang -S -### -cl-uniform-work-group-size %s 2>&1 | FileCheck --check-prefix=CHECK-UNIFORM-WG %s
 // RUN: not %clang -cl-std=c99 -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-C99 %s
 // RUN: not %clang -cl-std=invalid -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID %s
 
@@ -31,6 +32,7 @@
 // CHECK-NO-SIGNED-ZEROS: "-cc1" {{.*}} "-cl-no-signed-zeros"
 // CHECK-DENORMS-ARE-ZERO: "-cc1" {{.*}} "-cl-denorms-are-zero"
 // CHECK-ROUND-DIV: "-cc1" {{.*}} "-cl-fp32-correctly-rounded-divide-sqrt"
+// CHECK-UNIFORM-WG: "-cc1" {{.*}} "-cl-uniform-work-group-size"
 // CHECK-C99: error: invalid value 'c99' in '-cl-std=c99'
 // CHECK-INVALID: error: invalid value 'invalid' in '-cl-std=invalid'
 
Index: cfe/trunk/test/CodeGenOpenCL/convergent.cl
===
--- cfe/trunk/test/CodeGenOpenCL/convergent.cl
+++ cfe/trunk/test/CodeGenOpenCL/convergent.cl
@@ -127,7 +127,7 @@
 // CHECK: declare spir_func void @nodupfun(){{[^#]*}} #[[attr3:[0-9]+]]
 
 // CHECK-LABEL: @assume_convergent_asm
-// CHECK: tail call void asm sideeffect "s_barrier", ""() #4
+// CHECK: tail call void asm sideeffect "s_barrier", ""() #5
 kernel void assume_convergent_asm()
 {
   __asm__ volatile("s_barrier");
@@ -138,4 +138,5 @@
 // CHECK: attributes #2 = { {{[^}]*}}convergent{{[^}]*}} }
 // CHECK: attributes #3 = { {{[^}]*}}convergent noduplicate{{[^}]*}} }
 // CHECK: attributes #4 = { {{[^}]*}}convergent{{[^}]*}} }
-// CHECK: attributes #5 = { {{[^}]*}}convergent noduplicate{{[^}]*}} }
+// CHECK: attributes #5 = { {{[^}]*}}convergent{{[^}]*}} }
+// CHECK: attributes #6 = { {{[^}]*}}convergent noduplicate{{[^}]*}} }
Index: cfe/trunk/test/CodeGenOpenCL/cl-uniform-wg-size.cl
===
--- cfe/trunk/test/CodeGenOpenCL/cl-uniform-wg-size.cl
+++ cfe/trunk/test/CodeGenOpenCL/cl-uniform-wg-size.cl
@@ -0,0 +1,16 @@
+// RUN: 

[PATCH] D43518: [clangd] Allow embedders some control over when diagnostics are generated.

2018-02-22 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clangd/TUScheduler.cpp:298
+  while (shouldSkipHeadLocked())
+Requests.pop_front();
+  assert(!Requests.empty() && "skipped the whole queue");

sammccall wrote:
> ilya-biryukov wrote:
> > Instead of skipping requests here we could try removing them from back of 
> > the queue in `startTask` (or rewriting the last request instead of adding a 
> > new one).
> > It feels the code could be simpler, as we will only ever have to remove a 
> > single request from the queue. And it could also keep the queue smaller in 
> > case of many subsequent `Auto` requests.
> > WDYT?
> Having startTask look ahead to find things to cancel was the thing I found 
> most confusing/limiting in the previous code, so I'd rather not go back there 
> :-)
> That said, I did try this first, trying to limit the scope of this patch, but 
> it got hard.
> 
> The main problems are:
> - you're not just looking ahead one task, or even to a fixed one. After [auto 
> no], no cancels no, auto cancels both, read cancels neither. The states and 
> the state machine are hard to reason about. (unless you just loop over the 
> whole queue, which seems just as complex)
> - the decision of "should task X run" is distributed over time via mutating 
> state, rather than happening at one point via reads
>  - when looking at startTask time, you have to reason about the (possibly) 
> concurrently running task. In run(), no task is running and nothing can be 
> enqueued, so there's no concurrency issues.
> 
> >And it could also keep the queue smaller in case of many subsequent Auto 
> >requests.
> This is true, but it doesn't seem like a practical concern.
Thanks for clarifying. The first bullet point shouldn't be a big a problem. 
Yes, the new task can remove multiple items from the back of the queue, but the 
implementation still looks more natural as it only needs to inspect the 
**last**  item on the queue on each of the outer loop iterations. (While the 
current implementation has to do an inner loop through multiple items on the 
queue in addition to the outer loop).

The second point makes it hard, though. I would probably go with calling 
`pop_front()` when removing the request and signalling empty queue separately.

> This is true, but it doesn't seem like a practical concern.
It isn't, but I still think it's a nice-to-have.



Comment at: clangd/TUScheduler.cpp:339
+// Used unless followed by an update that generates diagnostics.
+for (; Next != Requests.end(); ++Next)
+  if (Next->UpdateType == WantDiagnostics::Yes ||

sammccall wrote:
> ilya-biryukov wrote:
> > Maybe skip updates directly in this function and make it return void?
> > Calling a function in a loop that loops through elements itself is a little 
> > confusing.
> Returning bool constrains the contract of this class to choosing to run one 
> item or not, and the type system forces a specific decision.
> Returning void leaves the option of purging one or no or multiple items. The 
> only void function with a clear contract would be "drop all dead requests at 
> the start", which is too complex to get right in one go. (happy to pull the 
> loop out of run into such a function if you think it would help, though.)
Another alternative is to return an iterator to the first non-dead request from 
this function use it to remove the dead requests in the clients of this 
function.
This would get rid of the outer loop. WDYT?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43518



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


[PATCH] D43621: [Driver] Allow using a canonical form of '-fuse-ld=' when cross-compiling on Windows.

2018-02-22 Thread Igor Kudrin via Phabricator via cfe-commits
ikudrin added inline comments.



Comment at: lib/Driver/ToolChain.cpp:415
 // second-guess that.
-if (llvm::sys::fs::exists(UseLinker))
+if (llvm::sys::fs::can_execute(UseLinker))
   return UseLinker;

Hahnfeld wrote:
> I don't think we should do this for absolute paths?
Why not? You can omit ".exe" suffix on Windows when calling an application, 
right?


Repository:
  rC Clang

https://reviews.llvm.org/D43621



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


[PATCH] D42840: [docs] Fix duplicate arguments for JoinedAndSeparate

2018-02-22 Thread Jonas Hahnfeld via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL325805: [docs] Fix duplicate arguments for JoinedAndSeparate 
(authored by Hahnfeld, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D42840?vs=132559=135438#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D42840

Files:
  cfe/trunk/utils/TableGen/ClangOptionDocEmitter.cpp


Index: cfe/trunk/utils/TableGen/ClangOptionDocEmitter.cpp
===
--- cfe/trunk/utils/TableGen/ClangOptionDocEmitter.cpp
+++ cfe/trunk/utils/TableGen/ClangOptionDocEmitter.cpp
@@ -245,19 +245,27 @@
 void emitOptionName(StringRef Prefix, const Record *Option, raw_ostream ) {
   // Find the arguments to list after the option.
   unsigned NumArgs = getNumArgsForKind(Option->getValueAsDef("Kind"), Option);
+  bool HasMetaVarName = !Option->isValueUnset("MetaVarName");
 
   std::vector Args;
-  if (!Option->isValueUnset("MetaVarName"))
+  if (HasMetaVarName)
 Args.push_back(Option->getValueAsString("MetaVarName"));
   else if (NumArgs == 1)
 Args.push_back("");
 
-  while (Args.size() < NumArgs) {
-Args.push_back(("").str());
-// Use '--args  ...' if any number of args are allowed.
-if (Args.size() == 2 && NumArgs == UnlimitedArgs) {
-  Args.back() += "...";
-  break;
+  // Fill up arguments if this option didn't provide a meta var name or it
+  // supports an unlimited number of arguments. We can't see how many arguments
+  // already are in a meta var name, so assume it has right number. This is
+  // needed for JoinedAndSeparate options so that there arent't too many
+  // arguments.
+  if (!HasMetaVarName || NumArgs == UnlimitedArgs) {
+while (Args.size() < NumArgs) {
+  Args.push_back(("").str());
+  // Use '--args  ...' if any number of args are allowed.
+  if (Args.size() == 2 && NumArgs == UnlimitedArgs) {
+Args.back() += "...";
+break;
+  }
 }
   }
 


Index: cfe/trunk/utils/TableGen/ClangOptionDocEmitter.cpp
===
--- cfe/trunk/utils/TableGen/ClangOptionDocEmitter.cpp
+++ cfe/trunk/utils/TableGen/ClangOptionDocEmitter.cpp
@@ -245,19 +245,27 @@
 void emitOptionName(StringRef Prefix, const Record *Option, raw_ostream ) {
   // Find the arguments to list after the option.
   unsigned NumArgs = getNumArgsForKind(Option->getValueAsDef("Kind"), Option);
+  bool HasMetaVarName = !Option->isValueUnset("MetaVarName");
 
   std::vector Args;
-  if (!Option->isValueUnset("MetaVarName"))
+  if (HasMetaVarName)
 Args.push_back(Option->getValueAsString("MetaVarName"));
   else if (NumArgs == 1)
 Args.push_back("");
 
-  while (Args.size() < NumArgs) {
-Args.push_back(("").str());
-// Use '--args  ...' if any number of args are allowed.
-if (Args.size() == 2 && NumArgs == UnlimitedArgs) {
-  Args.back() += "...";
-  break;
+  // Fill up arguments if this option didn't provide a meta var name or it
+  // supports an unlimited number of arguments. We can't see how many arguments
+  // already are in a meta var name, so assume it has right number. This is
+  // needed for JoinedAndSeparate options so that there arent't too many
+  // arguments.
+  if (!HasMetaVarName || NumArgs == UnlimitedArgs) {
+while (Args.size() < NumArgs) {
+  Args.push_back(("").str());
+  // Use '--args  ...' if any number of args are allowed.
+  if (Args.size() == 2 && NumArgs == UnlimitedArgs) {
+Args.back() += "...";
+break;
+  }
 }
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42841: [docs] Improve help for OpenMP options

2018-02-22 Thread Jonas Hahnfeld via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL325806: [docs] Improve help for OpenMP options, NFC. 
(authored by Hahnfeld, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D42841?vs=132571=135439#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D42841

Files:
  cfe/trunk/include/clang/Driver/Options.td


Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -466,7 +466,8 @@
 def Xopenmp_target : Separate<["-"], "Xopenmp-target">,
   HelpText<"Pass  to the target offloading toolchain.">, 
MetaVarName<"">;
 def Xopenmp_target_EQ : JoinedAndSeparate<["-"], "Xopenmp-target=">,
-  HelpText<"Pass  to the specified target offloading toolchain. The 
triple that identifies the toolchain must be provided after the equals sign.">, 
MetaVarName<"">;
+  HelpText<"Pass  to the target offloading toolchain identified by 
.">,
+  MetaVarName<" ">;
 def z : Separate<["-"], "z">, Flags<[LinkerInput, RenderAsInput]>,
   HelpText<"Pass -z  to the linker">, MetaVarName<"">,
   Group;
@@ -1397,24 +1398,26 @@
 
 def fobjc_sender_dependent_dispatch : Flag<["-"], 
"fobjc-sender-dependent-dispatch">, Group;
 def fomit_frame_pointer : Flag<["-"], "fomit-frame-pointer">, Group;
-def fopenmp : Flag<["-"], "fopenmp">, Group, Flags<[CC1Option, 
NoArgumentUnused]>;
+def fopenmp : Flag<["-"], "fopenmp">, Group, Flags<[CC1Option, 
NoArgumentUnused]>,
+  HelpText<"Parse OpenMP pragmas and generate parallel code.">;
 def fno_openmp : Flag<["-"], "fno-openmp">, Group, 
Flags<[NoArgumentUnused]>;
 def fopenmp_version_EQ : Joined<["-"], "fopenmp-version=">, Group, 
Flags<[CC1Option, NoArgumentUnused]>;
 def fopenmp_EQ : Joined<["-"], "fopenmp=">, Group;
-def fopenmp_use_tls : Flag<["-"], "fopenmp-use-tls">, Group, 
Flags<[NoArgumentUnused]>;
-def fnoopenmp_use_tls : Flag<["-"], "fnoopenmp-use-tls">, Group, 
Flags<[CC1Option, NoArgumentUnused]>;
+def fopenmp_use_tls : Flag<["-"], "fopenmp-use-tls">, Group,
+  Flags<[NoArgumentUnused, HelpHidden]>;
+def fnoopenmp_use_tls : Flag<["-"], "fnoopenmp-use-tls">, Group,
+  Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
 def fopenmp_targets_EQ : CommaJoined<["-"], "fopenmp-targets=">, 
Flags<[DriverOption, CC1Option]>,
   HelpText<"Specify comma-separated list of triples OpenMP offloading targets 
to be supported">;
-def fopenmp_dump_offload_linker_script : Flag<["-"], 
"fopenmp-dump-offload-linker-script">, Group,
-  Flags<[NoArgumentUnused]>;
-def fopenmp_relocatable_target : Flag<["-"], "fopenmp-relocatable-target">, 
Group, Flags<[CC1Option, NoArgumentUnused]>,
-  HelpText<"OpenMP target code is compiled as relocatable using the -c flag. 
For OpenMP targets the code is relocatable by default.">;
-def fnoopenmp_relocatable_target : Flag<["-"], 
"fnoopenmp-relocatable-target">, Group, Flags<[CC1Option, 
NoArgumentUnused]>,
-  HelpText<"Do not compile OpenMP target code as relocatable.">;
+def fopenmp_dump_offload_linker_script : Flag<["-"], 
"fopenmp-dump-offload-linker-script">,
+  Group, Flags<[NoArgumentUnused, HelpHidden]>;
+def fopenmp_relocatable_target : Flag<["-"], "fopenmp-relocatable-target">,
+  Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
+def fnoopenmp_relocatable_target : Flag<["-"], "fnoopenmp-relocatable-target">,
+  Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
 def fopenmp_simd : Flag<["-"], "fopenmp-simd">, Group, 
Flags<[CC1Option, NoArgumentUnused]>,
   HelpText<"Emit OpenMP code only for SIMD-based constructs.">;
-def fno_openmp_simd : Flag<["-"], "fno-openmp-simd">, Group, 
Flags<[CC1Option, NoArgumentUnused]>,
-  HelpText<"Disable OpenMP code for SIMD-based constructs.">;
+def fno_openmp_simd : Flag<["-"], "fno-openmp-simd">, Group, 
Flags<[CC1Option, NoArgumentUnused]>;
 def fno_optimize_sibling_calls : Flag<["-"], "fno-optimize-sibling-calls">, 
Group;
 def foptimize_sibling_calls : Flag<["-"], "foptimize-sibling-calls">, 
Group;
 def force__cpusubtype__ALL : Flag<["-"], "force_cpusubtype_ALL">;


Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -466,7 +466,8 @@
 def Xopenmp_target : Separate<["-"], "Xopenmp-target">,
   HelpText<"Pass  to the target offloading toolchain.">, MetaVarName<"">;
 def Xopenmp_target_EQ : JoinedAndSeparate<["-"], "Xopenmp-target=">,
-  HelpText<"Pass  to the specified target offloading toolchain. The triple that identifies the toolchain must be provided after the equals sign.">, MetaVarName<"">;
+  HelpText<"Pass  to the target offloading toolchain identified by .">,
+  MetaVarName<" ">;
 def z : Separate<["-"], "z">, Flags<[LinkerInput, RenderAsInput]>,
   HelpText<"Pass -z  to the linker">, 

[PATCH] D43634: [clangd] Extend textDocument/didChange to specify whether diagnostics should be generated.

2018-02-22 Thread Eric Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE325813: [clangd] Extend textDocument/didChange to specify 
whether diagnostics should be… (authored by ioeric, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D43634?vs=135463=135465#toc

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43634

Files:
  clangd/ClangdLSPServer.cpp
  clangd/Protocol.cpp
  clangd/Protocol.h


Index: clangd/Protocol.h
===
--- clangd/Protocol.h
+++ clangd/Protocol.h
@@ -297,6 +297,12 @@
 
   /// The actual content changes.
   std::vector contentChanges;
+
+  /// Forces diagnostics to be generated, or to not be generated, for this
+  /// version of the file. If not set, diagnostics are eventually consistent:
+  /// either they will be provided for this version or some subsequent one.
+  /// This is a clangd extension.
+  llvm::Optional wantDiagnostics;
 };
 bool fromJSON(const json::Expr &, DidChangeTextDocumentParams &);
 
Index: clangd/ClangdLSPServer.cpp
===
--- clangd/ClangdLSPServer.cpp
+++ clangd/ClangdLSPServer.cpp
@@ -149,9 +149,13 @@
   if (Params.contentChanges.size() != 1)
 return replyError(ErrorCode::InvalidParams,
   "can only apply one change at a time");
+  auto WantDiags = WantDiagnostics::Auto;
+  if (Params.wantDiagnostics.hasValue())
+WantDiags = Params.wantDiagnostics.getValue() ? WantDiagnostics::Yes
+  : WantDiagnostics::No;
   // We only support full syncing right now.
   Server.addDocument(Params.textDocument.uri.file(),
- Params.contentChanges[0].text, WantDiagnostics::Auto);
+ Params.contentChanges[0].text, WantDiags);
 }
 
 void ClangdLSPServer::onFileEvent(DidChangeWatchedFilesParams ) {
Index: clangd/Protocol.cpp
===
--- clangd/Protocol.cpp
+++ clangd/Protocol.cpp
@@ -221,7 +221,8 @@
 bool fromJSON(const json::Expr , DidChangeTextDocumentParams ) {
   json::ObjectMapper O(Params);
   return O && O.map("textDocument", R.textDocument) &&
- O.map("contentChanges", R.contentChanges);
+ O.map("contentChanges", R.contentChanges) &&
+ O.map("wantDiagnostics", R.wantDiagnostics);
 }
 
 bool fromJSON(const json::Expr , FileChangeType ) {


Index: clangd/Protocol.h
===
--- clangd/Protocol.h
+++ clangd/Protocol.h
@@ -297,6 +297,12 @@
 
   /// The actual content changes.
   std::vector contentChanges;
+
+  /// Forces diagnostics to be generated, or to not be generated, for this
+  /// version of the file. If not set, diagnostics are eventually consistent:
+  /// either they will be provided for this version or some subsequent one.
+  /// This is a clangd extension.
+  llvm::Optional wantDiagnostics;
 };
 bool fromJSON(const json::Expr &, DidChangeTextDocumentParams &);
 
Index: clangd/ClangdLSPServer.cpp
===
--- clangd/ClangdLSPServer.cpp
+++ clangd/ClangdLSPServer.cpp
@@ -149,9 +149,13 @@
   if (Params.contentChanges.size() != 1)
 return replyError(ErrorCode::InvalidParams,
   "can only apply one change at a time");
+  auto WantDiags = WantDiagnostics::Auto;
+  if (Params.wantDiagnostics.hasValue())
+WantDiags = Params.wantDiagnostics.getValue() ? WantDiagnostics::Yes
+  : WantDiagnostics::No;
   // We only support full syncing right now.
   Server.addDocument(Params.textDocument.uri.file(),
- Params.contentChanges[0].text, WantDiagnostics::Auto);
+ Params.contentChanges[0].text, WantDiags);
 }
 
 void ClangdLSPServer::onFileEvent(DidChangeWatchedFilesParams ) {
Index: clangd/Protocol.cpp
===
--- clangd/Protocol.cpp
+++ clangd/Protocol.cpp
@@ -221,7 +221,8 @@
 bool fromJSON(const json::Expr , DidChangeTextDocumentParams ) {
   json::ObjectMapper O(Params);
   return O && O.map("textDocument", R.textDocument) &&
- O.map("contentChanges", R.contentChanges);
+ O.map("contentChanges", R.contentChanges) &&
+ O.map("wantDiagnostics", R.wantDiagnostics);
 }
 
 bool fromJSON(const json::Expr , FileChangeType ) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42644: [asan] Intercept std::rethrow_exception indirectly.

2018-02-22 Thread Robert Schneider via Phabricator via cfe-commits
robot marked an inline comment as done.
robot added a comment.

Have you had the time to review the second revision?


Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D42644



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


[PATCH] D43621: [Driver] Allow using a canonical form of '-fuse-ld=' when cross-compiling on Windows.

2018-02-22 Thread Igor Kudrin via Phabricator via cfe-commits
ikudrin created this revision.
ikudrin added reviewers: phosek, Hahnfeld, logan, rnk.
ikudrin added a project: clang.

Right now, we have to add an `.exe` suffix when using this switch, like 
`-fuse-ld=lld.exe`.
If the suffix is omitted, `llvm::sys::fs::exists()` cannot find the file on 
Windows,
while `llvm::sys::fs::can_Execute()` automatically tries both variants.


Repository:
  rC Clang

https://reviews.llvm.org/D43621

Files:
  lib/Driver/ToolChain.cpp


Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -412,7 +412,7 @@
   if (llvm::sys::path::is_absolute(UseLinker)) {
 // If we're passed what looks like an absolute path, don't attempt to
 // second-guess that.
-if (llvm::sys::fs::exists(UseLinker))
+if (llvm::sys::fs::can_execute(UseLinker))
   return UseLinker;
   } else if (UseLinker.empty() || UseLinker == "ld") {
 // If we're passed -fuse-ld= with no argument, or with the argument ld,
@@ -427,7 +427,7 @@
 LinkerName.append(UseLinker);
 
 std::string LinkerPath(GetProgramPath(LinkerName.c_str()));
-if (llvm::sys::fs::exists(LinkerPath))
+if (llvm::sys::fs::can_execute(LinkerPath))
   return LinkerPath;
   }
 


Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -412,7 +412,7 @@
   if (llvm::sys::path::is_absolute(UseLinker)) {
 // If we're passed what looks like an absolute path, don't attempt to
 // second-guess that.
-if (llvm::sys::fs::exists(UseLinker))
+if (llvm::sys::fs::can_execute(UseLinker))
   return UseLinker;
   } else if (UseLinker.empty() || UseLinker == "ld") {
 // If we're passed -fuse-ld= with no argument, or with the argument ld,
@@ -427,7 +427,7 @@
 LinkerName.append(UseLinker);
 
 std::string LinkerPath(GetProgramPath(LinkerName.c_str()));
-if (llvm::sys::fs::exists(LinkerPath))
+if (llvm::sys::fs::can_execute(LinkerPath))
   return LinkerPath;
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [libcxx] r323971 - Remove ; use instead. See https://libcxx.llvm.org/TS_deprecation.html

2018-02-22 Thread Nico Weber via cfe-commits
I have a small personal project where I used to use this. I tried switching
to  instead, but that apparently requires -std=c++17. With that,
things build fine with my locally-built clang, but latest Xcode clang
doesn't accept that flag yet. So I tried -std=c++1z, but latest Xcode (9.2)
doesn't event include the  header yet. So now I have no way of
being able to build my project with both trunk clang and Xcode clang. Maybe
a one-year deprecation period is too short?

(It's not a huge deal, I have a optional<> implementation in my project for
platforms that don't ship it yet, but things used to be fine on mac until
this change at least. It's also not an important project, I just thought
I'd point out that this makes life more complicated than it would be if the
deletion period was longer.)

On Thu, Feb 1, 2018 at 9:54 AM, Marshall Clow via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: marshall
> Date: Thu Feb  1 06:54:25 2018
> New Revision: 323971
>
> URL: http://llvm.org/viewvc/llvm-project?rev=323971=rev
> Log:
> Remove ; use  instead. See
> https://libcxx.llvm.org/TS_deprecation.html
>
> Removed:
> libcxx/trunk/test/libcxx/experimental/optional/
> libcxx/trunk/test/std/experimental/optional/
> Modified:
> libcxx/trunk/include/experimental/optional
> libcxx/trunk/include/module.modulemap
> libcxx/trunk/src/optional.cpp
> libcxx/trunk/test/libcxx/double_include.sh.cpp
> libcxx/trunk/test/libcxx/min_max_macros.sh.cpp
>
> Modified: libcxx/trunk/include/experimental/optional
> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/
> experimental/optional?rev=323971=323970=323971=diff
> 
> ==
> --- libcxx/trunk/include/experimental/optional (original)
> +++ libcxx/trunk/include/experimental/optional Thu Feb  1 06:54:25 2018
> @@ -8,915 +8,4 @@
>  //
>  //===---
> ---===//
>
> -#ifndef _LIBCPP_EXPERIMENTAL_OPTIONAL
> -#define _LIBCPP_EXPERIMENTAL_OPTIONAL
> -
> -/*
> -optional synopsis
> -
> -// C++1y
> -
> -namespace std { namespace experimental { inline namespace fundamentals_v1
> {
> -
> -// 5.3, optional for object types
> -template  class optional;
> -
> -// 5.4, In-place construction
> -struct in_place_t{};
> -constexpr in_place_t in_place{};
> -
> -// 5.5, No-value state indicator
> -struct nullopt_t{see below};
> -constexpr nullopt_t nullopt(unspecified);
> -
> -// 5.6, Class bad_optional_access
> -class bad_optional_access;
> -
> -// 5.7, Relational operators
> -template 
> -  constexpr bool operator==(const optional&, const optional&);
> -template 
> -  constexpr bool operator!=(const optional&, const optional&);
> -template 
> -  constexpr bool operator<(const optional&, const optional&);
> -template 
> -  constexpr bool operator>(const optional&, const optional&);
> -template 
> -  constexpr bool operator<=(const optional&, const optional&);
> -template 
> -  constexpr bool operator>=(const optional&, const optional&);
> -
> -// 5.8, Comparison with nullopt
> -template  constexpr bool operator==(const optional&,
> nullopt_t) noexcept;
> -template  constexpr bool operator==(nullopt_t, const
> optional&) noexcept;
> -template  constexpr bool operator!=(const optional&,
> nullopt_t) noexcept;
> -template  constexpr bool operator!=(nullopt_t, const
> optional&) noexcept;
> -template  constexpr bool operator<(const optional&,
> nullopt_t) noexcept;
> -template  constexpr bool operator<(nullopt_t, const
> optional&) noexcept;
> -template  constexpr bool operator<=(const optional&,
> nullopt_t) noexcept;
> -template  constexpr bool operator<=(nullopt_t, const
> optional&) noexcept;
> -template  constexpr bool operator>(const optional&,
> nullopt_t) noexcept;
> -template  constexpr bool operator>(nullopt_t, const
> optional&) noexcept;
> -template  constexpr bool operator>=(const optional&,
> nullopt_t) noexcept;
> -template  constexpr bool operator>=(nullopt_t, const
> optional&) noexcept;
> -
> -// 5.9, Comparison with T
> -template  constexpr bool operator==(const optional&,
> const T&);
> -template  constexpr bool operator==(const T&, const
> optional&);
> -template  constexpr bool operator!=(const optional&,
> const T&);
> -template  constexpr bool operator!=(const T&, const
> optional&);
> -template  constexpr bool operator<(const optional&, const
> T&);
> -template  constexpr bool operator<(const T&, const
> optional&);
> -template  constexpr bool operator<=(const optional&,
> const T&);
> -template  constexpr bool operator<=(const T&, const
> optional&);
> -template  constexpr bool operator>(const optional&, const
> T&);
> -template  constexpr bool operator>(const T&, const
> optional&);
> -template  constexpr bool 

[PATCH] D43625: [OpenMP] Remove implicit data sharing code gen that aims to use device shared memory

2018-02-22 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:564
+llvm::Value *FnArgs[] = {ZeroAddr.getPointer(), ZeroAddr.getPointer()};
+emitCall(CGF, Fn, FnArgs);
 

Pass non-null `SourceLocation` here as the last argument


Repository:
  rC Clang

https://reviews.llvm.org/D43625



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


[PATCH] D43630: [Driver] Fix search paths on x32

2018-02-22 Thread James Clarke via Phabricator via cfe-commits
jrtc27 created this revision.
Herald added a subscriber: cfe-commits.

When targeting x32, the x32 libraries and headers should be used, not
the x86_64 ones (which may not even be available), so prioritise those
and use the right multiarch triple.


Repository:
  rC Clang

https://reviews.llvm.org/D43630

Files:
  lib/Driver/ToolChains/Gnu.cpp
  lib/Driver/ToolChains/Linux.cpp


Index: lib/Driver/ToolChains/Linux.cpp
===
--- lib/Driver/ToolChains/Linux.cpp
+++ lib/Driver/ToolChains/Linux.cpp
@@ -78,10 +78,13 @@
   return "i386-linux-gnu";
 break;
   case llvm::Triple::x86_64:
-// We don't want this for x32, otherwise it will match x86_64 libs
-if (TargetEnvironment != llvm::Triple::GNUX32 &&
-D.getVFS().exists(SysRoot + "/lib/x86_64-linux-gnu"))
-  return "x86_64-linux-gnu";
+if (TargetEnvironment == llvm::Triple::GNUX32) {
+  if (D.getVFS().exists(SysRoot + "/lib/x86_64-linux-gnux32"))
+return "x86_64-linux-gnux32";
+} else {
+  if (D.getVFS().exists(SysRoot + "/lib/x86_64-linux-gnu"))
+return "x86_64-linux-gnu";
+}
 break;
   case llvm::Triple::aarch64:
 if (D.getVFS().exists(SysRoot + "/lib/aarch64-linux-gnu"))
@@ -620,6 +623,8 @@
   // in use in any released version of Debian, so we should consider
   // removing them.
   "/usr/include/i686-linux-gnu/64", "/usr/include/i486-linux-gnu/64"};
+  const StringRef X32MultiarchIncludeDirs[] = {
+  "/usr/include/x86_64-linux-gnux32"};
   const StringRef X86MultiarchIncludeDirs[] = {
   "/usr/include/i386-linux-gnu",
 
@@ -661,7 +666,10 @@
   ArrayRef MultiarchIncludeDirs;
   switch (getTriple().getArch()) {
   case llvm::Triple::x86_64:
-MultiarchIncludeDirs = X86_64MultiarchIncludeDirs;
+if (getTriple().getEnvironment() == llvm::Triple::GNUX32)
+  MultiarchIncludeDirs = X32MultiarchIncludeDirs;
+else
+  MultiarchIncludeDirs = X86_64MultiarchIncludeDirs;
 break;
   case llvm::Triple::x86:
 MultiarchIncludeDirs = X86MultiarchIncludeDirs;
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -1848,7 +1848,10 @@
   "x86_64-manbo-linux-gnu", "x86_64-linux-gnu",
   "x86_64-slackware-linux", "x86_64-linux-android",
   "x86_64-unknown-linux"};
-  static const char *const X32LibDirs[] = {"/libx32"};
+  static const char *const X32LibDirs[] = {"/libx32", "/lib"};
+  static const char *const X32Triples[] = {
+  "x86_64-linux-gnux32","x86_64-unknown-linux-gnux32",
+  "x86_64-pc-linux-gnux32"};
   static const char *const X86LibDirs[] = {"/lib32", "/lib"};
   static const char *const X86Triples[] = {
   "i686-linux-gnu",   "i686-pc-linux-gnu", "i486-linux-gnu",
@@ -1989,14 +1992,16 @@
 }
 break;
   case llvm::Triple::x86_64:
-LibDirs.append(begin(X86_64LibDirs), end(X86_64LibDirs));
-TripleAliases.append(begin(X86_64Triples), end(X86_64Triples));
 // x32 is always available when x86_64 is available, so adding it as
 // secondary arch with x86_64 triples
 if (TargetTriple.getEnvironment() == llvm::Triple::GNUX32) {
-  BiarchLibDirs.append(begin(X32LibDirs), end(X32LibDirs));
+  LibDirs.append(begin(X32LibDirs), end(X32LibDirs));
+  TripleAliases.append(begin(X32Triples), end(X32Triples));
+  BiarchLibDirs.append(begin(X86_64LibDirs), end(X86_64LibDirs));
   BiarchTripleAliases.append(begin(X86_64Triples), end(X86_64Triples));
 } else {
+  LibDirs.append(begin(X86_64LibDirs), end(X86_64LibDirs));
+  TripleAliases.append(begin(X86_64Triples), end(X86_64Triples));
   BiarchLibDirs.append(begin(X86LibDirs), end(X86LibDirs));
   BiarchTripleAliases.append(begin(X86Triples), end(X86Triples));
 }


Index: lib/Driver/ToolChains/Linux.cpp
===
--- lib/Driver/ToolChains/Linux.cpp
+++ lib/Driver/ToolChains/Linux.cpp
@@ -78,10 +78,13 @@
   return "i386-linux-gnu";
 break;
   case llvm::Triple::x86_64:
-// We don't want this for x32, otherwise it will match x86_64 libs
-if (TargetEnvironment != llvm::Triple::GNUX32 &&
-D.getVFS().exists(SysRoot + "/lib/x86_64-linux-gnu"))
-  return "x86_64-linux-gnu";
+if (TargetEnvironment == llvm::Triple::GNUX32) {
+  if (D.getVFS().exists(SysRoot + "/lib/x86_64-linux-gnux32"))
+return "x86_64-linux-gnux32";
+} else {
+  if (D.getVFS().exists(SysRoot + "/lib/x86_64-linux-gnu"))
+return "x86_64-linux-gnu";
+}
 break;
   case llvm::Triple::aarch64:
 if (D.getVFS().exists(SysRoot + "/lib/aarch64-linux-gnu"))
@@ -620,6 +623,8 @@
   // in use in any released version of Debian, so we should consider
   // removing them.
   "/usr/include/i686-linux-gnu/64", "/usr/include/i486-linux-gnu/64"};
+  const 

[PATCH] D43500: [clang-tidy]: modernize-use-default-member-init: Remove trailing comma and colon.

2018-02-22 Thread Eric Liu via Phabricator via cfe-commits
ioeric added a comment.

In https://reviews.llvm.org/D43500#1015208, @jdemeule wrote:

> In https://reviews.llvm.org/D43500#1013558, @malcolm.parsons wrote:
>
> > In https://reviews.llvm.org/D43500#1013497, @aaron.ballman wrote:
> >
> > > Is there a way to make clang-apply-replacements smarter rather than 
> > > forcing every check to jump through hoops? I'm worried that if we have to 
> > > fix individual checks we'll just run into the same bug later.
> >
> >
> > See 
> > http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20161017/174238.html
>
>
> I was not aware of //cleanupAroundReplacements//. It should be a better 
> option than fixing every check one by one. I am working on adding it on 
> clang-apply-replacement for now and another review will be propose soon.


That would be awesome Jeremy! Thanks!

I think it might be easier if you convert all replacements to 
`tooling::AtomicChange` and use `applyAtomicChanges` 
(https://github.com/llvm-mirror/clang/blob/master/include/clang/Tooling/Refactoring/AtomicChange.h#L172)
 in clang-apply-replacements.

Let me know if you have any question, and I'm happy to review the patch when 
it's ready!


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43500



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


[PATCH] D43634: [clangd] Extend textDocument/didChange to specify whether diagnostics should be generated.

2018-02-22 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Nice,  this will be useful for at least a couple of editor integrations.




Comment at: clangd/Protocol.h:301
+
+  /// If this is not set, diagnostics will be generated for the current version
+  /// or a subsequent one.

Nit: a little weird to lead with the missing case. Suggest rephrase as:

Forces diagnostics to be generated, or to not be generated. for this version of 
the file.
If not set, diagnostics are eventually consistent: either they will be provided 
for this version
or some subsequent one.



Comment at: test/clangd/want-diagnostics.test:5
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///main.cpp","languageId":"cpp","version":1,"text":"void
 main() {}"}}}
+#  CHECK:  "method": "textDocument/publishDiagnostics",
+---

I think this test doesn't test anything useful because the check lines are not 
sequenced with respect to the input.

I'm not sure a lit test is that useful here, the actual logic is already unit 
tested. If we really want to test the ClangdLSPServer change, a unit test might 
be easier to get right, but personally I'd be happy enough leaving the logic 
untested (and maybe throwing a wantDiagnostics into one of the updates in 
protocol.test)


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43634



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


[clang-tools-extra] r325801 - [clangd] fix test use-after-free from r325774

2018-02-22 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Thu Feb 22 07:33:33 2018
New Revision: 325801

URL: http://llvm.org/viewvc/llvm-project?rev=325801=rev
Log:
[clangd] fix test use-after-free from r325774

Modified:
clang-tools-extra/trunk/unittests/clangd/TUSchedulerTests.cpp

Modified: clang-tools-extra/trunk/unittests/clangd/TUSchedulerTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/TUSchedulerTests.cpp?rev=325801=325800=325801=diff
==
--- clang-tools-extra/trunk/unittests/clangd/TUSchedulerTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/TUSchedulerTests.cpp Thu Feb 22 
07:33:33 2018
@@ -91,14 +91,13 @@ TEST_F(TUSchedulerTests, MissingFiles) {
 TEST_F(TUSchedulerTests, WantDiagnostics) {
   std::atomic CallbackCount(0);
   {
+// To avoid a racy test, don't allow tasks to actualy run on the worker
+// thread until we've scheduled them all.
+Notification Ready;
 TUScheduler S(getDefaultAsyncThreadsCount(),
   /*StorePreamblesInMemory=*/true,
   /*ASTParsedCallback=*/nullptr);
 auto Path = testPath("foo.cpp");
-
-// To avoid a racy test, don't allow tasks to actualy run on the worker
-// thread until we've scheduled them all.
-Notification Ready;
 S.update(Path, getInputs(Path, ""), WantDiagnostics::Yes,
  [&](std::vector) { Ready.wait(); });
 


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


[PATCH] D43621: [Driver] Allow using a canonical form of '-fuse-ld=' when cross-compiling on Windows.

2018-02-22 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added inline comments.



Comment at: lib/Driver/ToolChain.cpp:415
 // second-guess that.
-if (llvm::sys::fs::exists(UseLinker))
+if (llvm::sys::fs::can_execute(UseLinker))
   return UseLinker;

I don't think we should do this for absolute paths?


Repository:
  rC Clang

https://reviews.llvm.org/D43621



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


r325805 - [docs] Fix duplicate arguments for JoinedAndSeparate

2018-02-22 Thread Jonas Hahnfeld via cfe-commits
Author: hahnfeld
Date: Thu Feb 22 09:06:27 2018
New Revision: 325805

URL: http://llvm.org/viewvc/llvm-project?rev=325805=rev
Log:
[docs] Fix duplicate arguments for JoinedAndSeparate

We can't see how many arguments are in the meta var name, so just
assume that it is the right number.

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

Modified:
cfe/trunk/utils/TableGen/ClangOptionDocEmitter.cpp

Modified: cfe/trunk/utils/TableGen/ClangOptionDocEmitter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangOptionDocEmitter.cpp?rev=325805=325804=325805=diff
==
--- cfe/trunk/utils/TableGen/ClangOptionDocEmitter.cpp (original)
+++ cfe/trunk/utils/TableGen/ClangOptionDocEmitter.cpp Thu Feb 22 09:06:27 2018
@@ -245,19 +245,27 @@ void emitOptionWithArgs(StringRef Prefix
 void emitOptionName(StringRef Prefix, const Record *Option, raw_ostream ) {
   // Find the arguments to list after the option.
   unsigned NumArgs = getNumArgsForKind(Option->getValueAsDef("Kind"), Option);
+  bool HasMetaVarName = !Option->isValueUnset("MetaVarName");
 
   std::vector Args;
-  if (!Option->isValueUnset("MetaVarName"))
+  if (HasMetaVarName)
 Args.push_back(Option->getValueAsString("MetaVarName"));
   else if (NumArgs == 1)
 Args.push_back("");
 
-  while (Args.size() < NumArgs) {
-Args.push_back(("").str());
-// Use '--args  ...' if any number of args are allowed.
-if (Args.size() == 2 && NumArgs == UnlimitedArgs) {
-  Args.back() += "...";
-  break;
+  // Fill up arguments if this option didn't provide a meta var name or it
+  // supports an unlimited number of arguments. We can't see how many arguments
+  // already are in a meta var name, so assume it has right number. This is
+  // needed for JoinedAndSeparate options so that there arent't too many
+  // arguments.
+  if (!HasMetaVarName || NumArgs == UnlimitedArgs) {
+while (Args.size() < NumArgs) {
+  Args.push_back(("").str());
+  // Use '--args  ...' if any number of args are allowed.
+  if (Args.size() == 2 && NumArgs == UnlimitedArgs) {
+Args.back() += "...";
+break;
+  }
 }
   }
 


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


r325806 - [docs] Improve help for OpenMP options, NFC.

2018-02-22 Thread Jonas Hahnfeld via cfe-commits
Author: hahnfeld
Date: Thu Feb 22 09:06:35 2018
New Revision: 325806

URL: http://llvm.org/viewvc/llvm-project?rev=325806=rev
Log:
[docs] Improve help for OpenMP options, NFC.

 * Add HelpText for -fopenmp so that it appears in clang --help.
 * Hide -fno-openmp-simd, only list the positive option.
 * Hide -fopenmp-relocatable-target and -fopenmp-use-tls from
   clang --help and from ClangCommandLineReference.
 * Improve MetaVarName for -Xopenmp-target=<...>.

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

Modified:
cfe/trunk/include/clang/Driver/Options.td

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=325806=325805=325806=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Thu Feb 22 09:06:35 2018
@@ -466,7 +466,8 @@ def Xcuda_ptxas : Separate<["-"], "Xcuda
 def Xopenmp_target : Separate<["-"], "Xopenmp-target">,
   HelpText<"Pass  to the target offloading toolchain.">, 
MetaVarName<"">;
 def Xopenmp_target_EQ : JoinedAndSeparate<["-"], "Xopenmp-target=">,
-  HelpText<"Pass  to the specified target offloading toolchain. The 
triple that identifies the toolchain must be provided after the equals sign.">, 
MetaVarName<"">;
+  HelpText<"Pass  to the target offloading toolchain identified by 
.">,
+  MetaVarName<" ">;
 def z : Separate<["-"], "z">, Flags<[LinkerInput, RenderAsInput]>,
   HelpText<"Pass -z  to the linker">, MetaVarName<"">,
   Group;
@@ -1397,24 +1398,26 @@ def fno_objc_nonfragile_abi : Flag<["-"]
 
 def fobjc_sender_dependent_dispatch : Flag<["-"], 
"fobjc-sender-dependent-dispatch">, Group;
 def fomit_frame_pointer : Flag<["-"], "fomit-frame-pointer">, Group;
-def fopenmp : Flag<["-"], "fopenmp">, Group, Flags<[CC1Option, 
NoArgumentUnused]>;
+def fopenmp : Flag<["-"], "fopenmp">, Group, Flags<[CC1Option, 
NoArgumentUnused]>,
+  HelpText<"Parse OpenMP pragmas and generate parallel code.">;
 def fno_openmp : Flag<["-"], "fno-openmp">, Group, 
Flags<[NoArgumentUnused]>;
 def fopenmp_version_EQ : Joined<["-"], "fopenmp-version=">, Group, 
Flags<[CC1Option, NoArgumentUnused]>;
 def fopenmp_EQ : Joined<["-"], "fopenmp=">, Group;
-def fopenmp_use_tls : Flag<["-"], "fopenmp-use-tls">, Group, 
Flags<[NoArgumentUnused]>;
-def fnoopenmp_use_tls : Flag<["-"], "fnoopenmp-use-tls">, Group, 
Flags<[CC1Option, NoArgumentUnused]>;
+def fopenmp_use_tls : Flag<["-"], "fopenmp-use-tls">, Group,
+  Flags<[NoArgumentUnused, HelpHidden]>;
+def fnoopenmp_use_tls : Flag<["-"], "fnoopenmp-use-tls">, Group,
+  Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
 def fopenmp_targets_EQ : CommaJoined<["-"], "fopenmp-targets=">, 
Flags<[DriverOption, CC1Option]>,
   HelpText<"Specify comma-separated list of triples OpenMP offloading targets 
to be supported">;
-def fopenmp_dump_offload_linker_script : Flag<["-"], 
"fopenmp-dump-offload-linker-script">, Group,
-  Flags<[NoArgumentUnused]>;
-def fopenmp_relocatable_target : Flag<["-"], "fopenmp-relocatable-target">, 
Group, Flags<[CC1Option, NoArgumentUnused]>,
-  HelpText<"OpenMP target code is compiled as relocatable using the -c flag. 
For OpenMP targets the code is relocatable by default.">;
-def fnoopenmp_relocatable_target : Flag<["-"], 
"fnoopenmp-relocatable-target">, Group, Flags<[CC1Option, 
NoArgumentUnused]>,
-  HelpText<"Do not compile OpenMP target code as relocatable.">;
+def fopenmp_dump_offload_linker_script : Flag<["-"], 
"fopenmp-dump-offload-linker-script">,
+  Group, Flags<[NoArgumentUnused, HelpHidden]>;
+def fopenmp_relocatable_target : Flag<["-"], "fopenmp-relocatable-target">,
+  Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
+def fnoopenmp_relocatable_target : Flag<["-"], "fnoopenmp-relocatable-target">,
+  Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
 def fopenmp_simd : Flag<["-"], "fopenmp-simd">, Group, 
Flags<[CC1Option, NoArgumentUnused]>,
   HelpText<"Emit OpenMP code only for SIMD-based constructs.">;
-def fno_openmp_simd : Flag<["-"], "fno-openmp-simd">, Group, 
Flags<[CC1Option, NoArgumentUnused]>,
-  HelpText<"Disable OpenMP code for SIMD-based constructs.">;
+def fno_openmp_simd : Flag<["-"], "fno-openmp-simd">, Group, 
Flags<[CC1Option, NoArgumentUnused]>;
 def fno_optimize_sibling_calls : Flag<["-"], "fno-optimize-sibling-calls">, 
Group;
 def foptimize_sibling_calls : Flag<["-"], "foptimize-sibling-calls">, 
Group;
 def force__cpusubtype__ALL : Flag<["-"], "force_cpusubtype_ALL">;


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


[PATCH] D43590: [clang-format] Fix regression when getStyle() called with empty filename

2018-02-22 Thread Bjorn Pettersson via Phabricator via cfe-commits
bjope added inline comments.



Comment at: unittests/Format/FormatTest.cpp:11727
+TEST(FormatStyle, GetStyleWithEmptyFileName) {
+  auto Style1 = getStyle("file", "", "Google");
+  ASSERT_TRUE((bool)Style1);

Do you really want to try to find a ".clang-format" file here, with fallback to 
"Google" if no such file is found?

When I'm building I usually end up having my build directory inside the llvm 
repo. And since there is a .clang-format file checked in to llvm that file is 
found, as it searches for a .clang-format file somewhere in the directory 
structure above the current dir when running the test (if I remember 
correctly?). We have had such problem before.

Can't you just as well do
  auto Style1 = getStyle("Google", "", "Google");
or is that not triggering the original bug?

Right now our build bots ends up like this (I guess it has found the 
.clang-format in my llvm/clang repo and decided to use "LLVM" as format for 
"Style1"):

```
FAIL: Clang-Unit :: Format/./FormatTests/FormatStyle.GetStyleWithEmptyFileName 
(14009 of 36611)
 TEST 'Clang-Unit :: 
Format/./FormatTests/FormatStyle.GetStyleWithEmptyFileName' FAILED 

Note: Google Test filter = FormatStyle.GetStyleWithEmptyFileName
[==] Running 1 test from 1 test case.
[--] Global test environment set-up.
[--] 1 test from FormatStyle
[ RUN  ] FormatStyle.GetStyleWithEmptyFileName
../tools/clang/unittests/Format/FormatTest.cpp:11729: Failure
  Expected: *Style1
  Which is: 456-byte object 
To be equal to: getGoogleStyle()
  Which is: 456-byte object 
[  FAILED  ] FormatStyle.GetStyleWithEmptyFileName (1 ms)
[--] 1 test from FormatStyle (1 ms total)

[--] Global test environment tear-down
[==] 1 test from 1 test case ran. (1 ms total)
[  PASSED  ] 0 tests.
[  FAILED  ] 1 test, listed below:
[  FAILED  ] FormatStyle.GetStyleWithEmptyFileName

```



Repository:
  rC Clang

https://reviews.llvm.org/D43590



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


[PATCH] D42366: [CodeGen] Fix generation of TBAA tags for may-alias accesses

2018-02-22 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added a comment.

In https://reviews.llvm.org/D42366#1014546, @rjmccall wrote:

> In https://reviews.llvm.org/D42366#1014157, @kosarev wrote:
>
> > I think zero would serve better as the unknown-size value. People who are 
> > not aware of TBAA internals would guess that since zero-sized accesses make 
> > no sense, they are likely to have some special meaning. Similarly, for code 
> > that is supposed to process the size fields of access descriptors zero 
> > would be an obvious "illegal size value". In contrast, UINT64_MAX is just a 
> > very large number that doesn't hint anything on its special purpose.
>
>
> My thoughts exactly.
>
> John.


SGTM. Let's do that.


Repository:
  rC Clang

https://reviews.llvm.org/D42366



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


r325812 - [OPENMP] Require valid SourceLocation in function call, NFC.

2018-02-22 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Feb 22 10:33:31 2018
New Revision: 325812

URL: http://llvm.org/viewvc/llvm-project?rev=325812=rev
Log:
[OPENMP] Require valid SourceLocation in function call, NFC.

Removed default empty SourceLocation argument from `emitCall` function
and require valid location.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=325812=325811=325812=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Thu Feb 22 10:33:31 2018
@@ -8057,9 +8057,10 @@ void CGOpenMPRuntime::emitDoacrossOrdere
   CGF.EmitRuntimeCall(RTLFn, Args);
 }
 
-void CGOpenMPRuntime::emitCall(CodeGenFunction , llvm::Value *Callee,
-   ArrayRef Args,
-   SourceLocation Loc) const {
+void CGOpenMPRuntime::emitCall(CodeGenFunction , SourceLocation Loc,
+   llvm::Value *Callee,
+   ArrayRef Args) const {
+  assert(Loc.isValid() && "Outlined function call location must be valid.");
   auto DL = ApplyDebugLocation::CreateDefaultArtificial(CGF, Loc);
 
   if (auto *Fn = dyn_cast(Callee)) {
@@ -8074,8 +8075,7 @@ void CGOpenMPRuntime::emitCall(CodeGenFu
 void CGOpenMPRuntime::emitOutlinedFunctionCall(
 CodeGenFunction , SourceLocation Loc, llvm::Value *OutlinedFn,
 ArrayRef Args) const {
-  assert(Loc.isValid() && "Outlined function call location must be valid.");
-  emitCall(CGF, OutlinedFn, Args, Loc);
+  emitCall(CGF, Loc, OutlinedFn, Args);
 }
 
 Address CGOpenMPRuntime::getParameterAddress(CodeGenFunction ,

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h?rev=325812=325811=325812=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h Thu Feb 22 10:33:31 2018
@@ -251,9 +251,8 @@ protected:
   virtual StringRef getOutlinedHelperName() const { return ".omp_outlined."; }
 
   /// Emits \p Callee function call with arguments \p Args with location \p 
Loc.
-  void emitCall(CodeGenFunction , llvm::Value *Callee,
-ArrayRef Args = llvm::None,
-SourceLocation Loc = SourceLocation()) const;
+  void emitCall(CodeGenFunction , SourceLocation Loc, llvm::Value *Callee,
+ArrayRef Args = llvm::None) const;
 
 private:
   /// \brief Default const ident_t object used for initialization of all other


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


[PATCH] D43621: [Driver] Allow using a canonical form of '-fuse-ld=' when cross-compiling on Windows.

2018-02-22 Thread Adrian McCarthy via Phabricator via cfe-commits
amccarth added a comment.

> Right now, we have to add an .exe suffix when using this switch, like 
> -fuse-ld=lld.exe.

That's weird, because lots of lldb tests compile and link test binaries on 
Windows with `-fuse-ld=lld` (without the `.exe`).  What makes you say the 
`.exe` is necessary?


Repository:
  rC Clang

https://reviews.llvm.org/D43621



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


[PATCH] D41228: [ObjC] Enable __strong pointers in structs under ARC

2018-02-22 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added inline comments.



Comment at: include/clang/AST/Type.h:1121
+  /// after it is moved, as opposed to a truely destructive move in which the
+  /// source object is placed in an uninitialized state.
+  PrimitiveCopyKind isNonTrivialToPrimitiveDestructiveMove() const;

rjmccall wrote:
> "truly"
> 
> Hmm.  Now that I'm thinking more about it, I'm not sure there's any point in 
> tracking non-triviality of a C++-style destructive move separately from the 
> non-triviality of a copy.  It's hard to imagine that there would ever be a 
> non-C++ type that primitively has non-trivial copies but trivial C++-style 
> moves or vice-versa.  Type-based destructors imply that the type represents 
> some kind of resource, and a C++-style move will always be non-trivial for 
> resource types because ownership of the resource needs to be given up by the 
> old location.  Otherwise, a type might be non-trivial to copy but not destroy 
> because there's something special about how it's stored (like volatility), 
> but it's hard to imagine what could possibly cause it to be non-trivial to 
> destroy but not copy.
> 
> If we were tracking non-triviality of an *unsafe* destructive move, one that 
> leaves the source in an uninitialized state, that's quite different.
> 
> I think there are three reasonable options here:
> 
> - Ignore the argument I just made about the types that we're *likely* to care 
> about modeling and generalize your tracking to also distinguish construction 
> from assignment.  In such an environment, I think you can absolutely make an 
> argument that it's still interesting to track C++-style moves separately from 
> copies.
> 
> - Drop the tracking of destructive moves completely.  If you want to keep the 
> method around, find, but it can just call `isNonTrivialToPrimitiveCopy()`.
> 
> - Change the tracking of *destructive* moves to instead track 
> *deinitializing* moves.  The implementation would stop considering `__strong` 
> types to be non-trivial to move.
> 
> But as things stand today, I do not see any point in separately tracking 
> triviality of C++-style destructive moves.
The second option seems most reasonable to me. We can always make changes if 
someone comes up with a type that requires tracking destructive moves 
separately.



Comment at: lib/CodeGen/CGNonTrivialStruct.cpp:193
+
+TrivialFieldIsVolatile |= FT.isVolatileQualified();
+if (Start == End)

rjmccall wrote:
> ahatanak wrote:
> > rjmccall wrote:
> > > I feel like maybe volatile fields should be individually copied instead 
> > > of being aggregated into a multi-field memcpy.  This is a more natural 
> > > interpretation of the C volatile rules than we currently do.  In fact, 
> > > arguably we should really add a PrimitiveCopyKind enumerator for volatile 
> > > fields (that are otherwise trivially-copyable) and force all copies of 
> > > structs with volatile fields into this path precisely so that we can make 
> > > a point of copying the volatile fields this way.  (Obviously that part is 
> > > not something that's your responsibility to do.)
> > > 
> > > To get that right with bit-fields, you'll need to propagate the actual 
> > > FieldDecl down.  On the plus side, that should let you use 
> > > EmitLValueForField to do the field projection in the common case.
> > I added method visitVolatileTrivial that copies volatile fields 
> > individually. Please see test case test_copy_constructor_Bitfield1 in 
> > test/CodeGenObjC/strong-in-c-struct.m.
> Okay, great!  I like the name.
> 
> Does this mean we're now copying all structs that contain volatile fields 
> with one of these helper functions?  If so, please add a C test case testing 
> just that.  Also, you should retitle this review and stress that we're 
> changing how *all* non-trivial types are copied, and that that includes both 
> volatile and ARC-qualified fields.
No, the current patch doesn't copy volatile fields of a struct individually 
unless the struct is a non-trivial type (which means its primitive copy kind is 
PCK_Struct). I'll look into today how I can force structs with volatile fields 
that are not non-trivial to be copied using the helper functions.

It seems like we would need a boolean flag in RecordDecl that tracks the 
presence of volatile fields in the struct or one of its subobjects. I assume we 
want to copy volatile fields individually in C++ too, in which case the flag 
needs to be set in both C and C++ mode. Is that right?


https://reviews.llvm.org/D41228



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


[PATCH] D43513: [OpenMP] Limit reduction support for pragma 'distribute' when combined with pragma 'simd'

2018-02-22 Thread Carlo Bertolli via Phabricator via cfe-commits
carlo.bertolli updated this revision to Diff 135429.
carlo.bertolli added a comment.

[OpenMP] Add regression test: this verifies that only one call to the runtime 
for reduction is done in a combined construct with distribute, without simd, 
and with at least one pragma accepting reduction as a clause.


Repository:
  rC Clang

https://reviews.llvm.org/D43513

Files:
  lib/CodeGen/CGStmtOpenMP.cpp
  test/OpenMP/distribute_parallel_for_reduction_codegen.cpp

Index: test/OpenMP/distribute_parallel_for_reduction_codegen.cpp
===
--- /dev/null
+++ test/OpenMP/distribute_parallel_for_reduction_codegen.cpp
@@ -0,0 +1,84 @@
+// Test host code gen
+
+// RUN: %clang_cc1  -verify -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1  -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1  -fopenmp -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1  -verify -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32
+// RUN: %clang_cc1  -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1  -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32
+
+// RUN: %clang_cc1  -verify -fopenmp-simd -fopenmp-version=45 -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY1 %s
+// RUN: %clang_cc1  -fopenmp-simd -fopenmp-version=45 -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1  -fopenmp-simd -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY1 %s
+// RUN: %clang_cc1  -verify -fopenmp-simd -fopenmp-version=45 -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY1 %s
+// RUN: %clang_cc1  -fopenmp-simd -fopenmp-version=45 -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1  -fopenmp-simd -fopenmp-version=45 -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY1 %s
+// SIMD-ONLY1-NOT: {{__kmpc|__tgt}}
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+
+template 
+T tmain(T ) {
+  int n = 1000;  
+  // schedule: dynamic chunk
+  #pragma omp target map(tofrom:r)
+  #pragma omp teams
+  #pragma omp distribute parallel for reduction(+:r)
+  for (int i = 0; i < n; ++i)
+r += (T)i;  
+
+  return r;
+}
+
+int main() {
+  int n = 1000;
+  int r = 0;
+  #pragma omp target map(tofrom:r)
+  #pragma omp teams
+  #pragma omp distribute parallel for reduction(+:r)
+  for (int i = 0; i < n; ++i)
+r += i;
+
+  return tmain(r);
+}
+
+// CHECK-LABEL: main
+// CHECK: call{{.+}} @__tgt_target_teams(
+// CHECK: call void [[OFFL:@.+]](
+// CHECK: call{{.+}} [[TMAIN:@.+]](i{{32|64}}
+// CHECK: ret
+
+// CHECK: define{{.+}} [[OFFL]](
+// CHECK: call{{.+}} @__kmpc_fork_teams({{.+}}, {{.+}}, {{.+}} [[TEOUTL:@.+]] to{{.+}}
+// CHECK: ret void
+
+// CHECK: define{{.+}} [[TEOUTL]](
+// CHECK: call{{.+}} @__kmpc_fork_call({{.+}}, {{.+}}, {{.+}} [[PAROUTL:@.+]] to{{.+}}
+// CHECK: ret void
+
+// CHECK: define{{.+}} [[PAROUTL]](
+// CHECK: call{{.+}} @__kmpc_reduce_nowait(
+// CHECK: call{{.+}} @__kmpc_end_reduce_nowait(
+// CHECK: ret void
+
+// CHECK: define{{.+}} [[TMAIN]](i{{32|64}}
+// CHECK: call{{.+}} @__tgt_target_teams(
+// CHECK: call void [[TOFFL:@.+]](
+// CHECK: ret
+
+// CHECK: define{{.+}} [[TOFFL]](
+// CHECK: call{{.+}} @__kmpc_fork_teams({{.+}}, {{.+}}, {{.+}} [[TEMPLTEOUTL:@.+]] to{{.+}}
+// CHECK: ret void
+
+// CHECK: define{{.+}} [[TEMPLTEOUTL]](
+// CHECK: call{{.+}} @__kmpc_fork_call({{.+}}, {{.+}}, {{.+}} [[TPAROUTL:@.+]] to{{.+}}
+// CHECK: ret void
+
+// CHECK: define{{.+}} [[TPAROUTL]](
+// CHECK: call{{.+}} @__kmpc_reduce_nowait(
+// CHECK: call{{.+}} @__kmpc_end_reduce_nowait(
+// CHECK: ret void
+
+#endif 

[PATCH] D43634: [clangd] Extend textDocument/didChange to specify whether diagnostics should be generated.

2018-02-22 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 135463.
ioeric marked 2 inline comments as done.
ioeric added a comment.

Addressed review comments. Removed test.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43634

Files:
  clangd/ClangdLSPServer.cpp
  clangd/Protocol.cpp
  clangd/Protocol.h


Index: clangd/Protocol.h
===
--- clangd/Protocol.h
+++ clangd/Protocol.h
@@ -297,6 +297,12 @@
 
   /// The actual content changes.
   std::vector contentChanges;
+
+  /// Forces diagnostics to be generated, or to not be generated, for this
+  /// version of the file. If not set, diagnostics are eventually consistent:
+  /// either they will be provided for this version or some subsequent one.
+  /// This is a clangd extension.
+  llvm::Optional wantDiagnostics;
 };
 bool fromJSON(const json::Expr &, DidChangeTextDocumentParams &);
 
Index: clangd/Protocol.cpp
===
--- clangd/Protocol.cpp
+++ clangd/Protocol.cpp
@@ -221,7 +221,8 @@
 bool fromJSON(const json::Expr , DidChangeTextDocumentParams ) {
   json::ObjectMapper O(Params);
   return O && O.map("textDocument", R.textDocument) &&
- O.map("contentChanges", R.contentChanges);
+ O.map("contentChanges", R.contentChanges) &&
+ O.map("wantDiagnostics", R.wantDiagnostics);
 }
 
 bool fromJSON(const json::Expr , FileChangeType ) {
Index: clangd/ClangdLSPServer.cpp
===
--- clangd/ClangdLSPServer.cpp
+++ clangd/ClangdLSPServer.cpp
@@ -149,9 +149,13 @@
   if (Params.contentChanges.size() != 1)
 return replyError(ErrorCode::InvalidParams,
   "can only apply one change at a time");
+  auto WantDiags = WantDiagnostics::Auto;
+  if (Params.wantDiagnostics.hasValue())
+WantDiags = Params.wantDiagnostics.getValue() ? WantDiagnostics::Yes
+  : WantDiagnostics::No;
   // We only support full syncing right now.
   Server.addDocument(Params.textDocument.uri.file(),
- Params.contentChanges[0].text, WantDiagnostics::Auto);
+ Params.contentChanges[0].text, WantDiags);
 }
 
 void ClangdLSPServer::onFileEvent(DidChangeWatchedFilesParams ) {


Index: clangd/Protocol.h
===
--- clangd/Protocol.h
+++ clangd/Protocol.h
@@ -297,6 +297,12 @@
 
   /// The actual content changes.
   std::vector contentChanges;
+
+  /// Forces diagnostics to be generated, or to not be generated, for this
+  /// version of the file. If not set, diagnostics are eventually consistent:
+  /// either they will be provided for this version or some subsequent one.
+  /// This is a clangd extension.
+  llvm::Optional wantDiagnostics;
 };
 bool fromJSON(const json::Expr &, DidChangeTextDocumentParams &);
 
Index: clangd/Protocol.cpp
===
--- clangd/Protocol.cpp
+++ clangd/Protocol.cpp
@@ -221,7 +221,8 @@
 bool fromJSON(const json::Expr , DidChangeTextDocumentParams ) {
   json::ObjectMapper O(Params);
   return O && O.map("textDocument", R.textDocument) &&
- O.map("contentChanges", R.contentChanges);
+ O.map("contentChanges", R.contentChanges) &&
+ O.map("wantDiagnostics", R.wantDiagnostics);
 }
 
 bool fromJSON(const json::Expr , FileChangeType ) {
Index: clangd/ClangdLSPServer.cpp
===
--- clangd/ClangdLSPServer.cpp
+++ clangd/ClangdLSPServer.cpp
@@ -149,9 +149,13 @@
   if (Params.contentChanges.size() != 1)
 return replyError(ErrorCode::InvalidParams,
   "can only apply one change at a time");
+  auto WantDiags = WantDiagnostics::Auto;
+  if (Params.wantDiagnostics.hasValue())
+WantDiags = Params.wantDiagnostics.getValue() ? WantDiagnostics::Yes
+  : WantDiagnostics::No;
   // We only support full syncing right now.
   Server.addDocument(Params.textDocument.uri.file(),
- Params.contentChanges[0].text, WantDiagnostics::Auto);
+ Params.contentChanges[0].text, WantDiags);
 }
 
 void ClangdLSPServer::onFileEvent(DidChangeWatchedFilesParams ) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r325813 - [clangd] Extend textDocument/didChange to specify whether diagnostics should be generated.

2018-02-22 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Thu Feb 22 10:40:39 2018
New Revision: 325813

URL: http://llvm.org/viewvc/llvm-project?rev=325813=rev
Log:
[clangd] Extend textDocument/didChange to specify whether diagnostics should be 
generated.

Summary:
This would allow us to disable diagnostics when didChange is called but
diagnostics are not wanted (e.g. code completion).

Reviewers: sammccall

Subscribers: klimek, ilya-biryukov, jkorous-apple, cfe-commits

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

Modified:
clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
clang-tools-extra/trunk/clangd/Protocol.cpp
clang-tools-extra/trunk/clangd/Protocol.h

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=325813=325812=325813=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Thu Feb 22 10:40:39 2018
@@ -149,9 +149,13 @@ void ClangdLSPServer::onDocumentDidChang
   if (Params.contentChanges.size() != 1)
 return replyError(ErrorCode::InvalidParams,
   "can only apply one change at a time");
+  auto WantDiags = WantDiagnostics::Auto;
+  if (Params.wantDiagnostics.hasValue())
+WantDiags = Params.wantDiagnostics.getValue() ? WantDiagnostics::Yes
+  : WantDiagnostics::No;
   // We only support full syncing right now.
   Server.addDocument(Params.textDocument.uri.file(),
- Params.contentChanges[0].text, WantDiagnostics::Auto);
+ Params.contentChanges[0].text, WantDiags);
 }
 
 void ClangdLSPServer::onFileEvent(DidChangeWatchedFilesParams ) {

Modified: clang-tools-extra/trunk/clangd/Protocol.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Protocol.cpp?rev=325813=325812=325813=diff
==
--- clang-tools-extra/trunk/clangd/Protocol.cpp (original)
+++ clang-tools-extra/trunk/clangd/Protocol.cpp Thu Feb 22 10:40:39 2018
@@ -221,7 +221,8 @@ bool fromJSON(const json::Expr ,
 bool fromJSON(const json::Expr , DidChangeTextDocumentParams ) {
   json::ObjectMapper O(Params);
   return O && O.map("textDocument", R.textDocument) &&
- O.map("contentChanges", R.contentChanges);
+ O.map("contentChanges", R.contentChanges) &&
+ O.map("wantDiagnostics", R.wantDiagnostics);
 }
 
 bool fromJSON(const json::Expr , FileChangeType ) {

Modified: clang-tools-extra/trunk/clangd/Protocol.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Protocol.h?rev=325813=325812=325813=diff
==
--- clang-tools-extra/trunk/clangd/Protocol.h (original)
+++ clang-tools-extra/trunk/clangd/Protocol.h Thu Feb 22 10:40:39 2018
@@ -297,6 +297,12 @@ struct DidChangeTextDocumentParams {
 
   /// The actual content changes.
   std::vector contentChanges;
+
+  /// Forces diagnostics to be generated, or to not be generated, for this
+  /// version of the file. If not set, diagnostics are eventually consistent:
+  /// either they will be provided for this version or some subsequent one.
+  /// This is a clangd extension.
+  llvm::Optional wantDiagnostics;
 };
 bool fromJSON(const json::Expr &, DidChangeTextDocumentParams &);
 


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


r325814 - [CUDA] Added missing functions.

2018-02-22 Thread Artem Belevich via cfe-commits
Author: tra
Date: Thu Feb 22 10:40:52 2018
New Revision: 325814

URL: http://llvm.org/viewvc/llvm-project?rev=325814=rev
Log:
[CUDA] Added missing functions.

Initial commit missed sincos(float), llabs() and few atomics that we
used to pull in from device_functions.hpp, which we no longer include.

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

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

Modified: cfe/trunk/lib/Headers/__clang_cuda_device_functions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__clang_cuda_device_functions.h?rev=325814=325813=325814=diff
==
--- cfe/trunk/lib/Headers/__clang_cuda_device_functions.h (original)
+++ cfe/trunk/lib/Headers/__clang_cuda_device_functions.h Thu Feb 22 10:40:52 
2018
@@ -687,6 +687,10 @@ __DEVICE__ float __ull2float_ru(unsigned
 __DEVICE__ float __ull2float_rz(unsigned long long __a) {
   return __nv_ull2float_rz(__a);
 }
+__DEVICE__ unsigned long long __ullAtomicAdd(unsigned long long *__p,
+ unsigned long long __v) {
+  return __nvvm_atom_add_gen_ll((long long *)__p, __v);
+}
 __DEVICE__ unsigned long long __ullAtomicAdd_block(unsigned long long *__p,
unsigned long long __v) {
   return __nvvm_atom_cta_add_gen_ll((long long *)__p, __v);
@@ -707,6 +711,11 @@ __DEVICE__ unsigned long long __ullAtomi
 unsigned long long __v) {
   return __nvvm_atom_sys_and_gen_ll((long long *)__p, __v);
 }
+__DEVICE__ unsigned long long __ullAtomicCAS(unsigned long long *__p,
+ unsigned long long __cmp,
+ unsigned long long __v) {
+  return __nvvm_atom_cas_gen_ll((long long *)__p, __cmp, __v);
+}
 __DEVICE__ unsigned long long __ullAtomicCAS_block(unsigned long long *__p,
unsigned long long __cmp,
unsigned long long __v) {
@@ -717,6 +726,10 @@ __DEVICE__ unsigned long long __ullAtomi
 unsigned long long __v) {
   return __nvvm_atom_sys_cas_gen_ll((long long *)__p, __cmp, __v);
 }
+__DEVICE__ unsigned long long __ullAtomicExch(unsigned long long *__p,
+  unsigned long long __v) {
+  return __nvvm_atom_xchg_gen_ll((long long *)__p, __v);
+}
 __DEVICE__ unsigned long long __ullAtomicExch_block(unsigned long long *__p,
 unsigned long long __v) {
   return __nvvm_atom_cta_xchg_gen_ll((long long *)__p, __v);
@@ -1123,10 +1136,16 @@ __DEVICE__ double j1(double __a) { retur
 __DEVICE__ float j1f(float __a) { return __nv_j1f(__a); }
 __DEVICE__ double jn(int __n, double __a) { return __nv_jn(__n, __a); }
 __DEVICE__ float jnf(int __n, float __a) { return __nv_jnf(__n, __a); }
+#if defined(__LP64__)
+__DEVICE__ long labs(long __a) { return llabs(__a); };
+#else
+__DEVICE__ long labs(long __a) { return __nv_abs(__a); };
+#endif
 __DEVICE__ double ldexp(double __a, int __b) { return __nv_ldexp(__a, __b); }
 __DEVICE__ float ldexpf(float __a, int __b) { return __nv_ldexpf(__a, __b); }
 __DEVICE__ double lgamma(double __a) { return __nv_lgamma(__a); }
 __DEVICE__ float lgammaf(float __a) { return __nv_lgammaf(__a); }
+__DEVICE__ long long llabs(long long __a) { return __nv_llabs(__a); }
 __DEVICE__ long long llmax(long long __a, long long __b) {
   return __nv_llmax(__a, __b);
 }
@@ -1267,6 +1286,9 @@ __DEVICE__ float scalblnf(float __a, lon
   return scalbnf(__a, (int)__b);
 }
 __DEVICE__ double sin(double __a) { return __nv_sin(__a); }
+__DEVICE__ void sincos(double __a, double *__sptr, double *__cptr) {
+  return __nv_sincos(__a, __sptr, __cptr);
+}
 __DEVICE__ void sincosf(float __a, float *__sptr, float *__cptr) {
   return __FAST_OR_SLOW(__nv_fast_sincosf, __nv_sincosf)(__a, __sptr, __cptr);
 }


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


[PATCH] D43621: [Driver] Allow using a canonical form of '-fuse-ld=' when cross-compiling on Windows.

2018-02-22 Thread Adrian McCarthy via Phabricator via cfe-commits
amccarth added a comment.

This must be new-ish code, since I've routinely used `-fuse-ld=lld` (without 
`.exe`) on Windows.


Repository:
  rC Clang

https://reviews.llvm.org/D43621



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


[clang-tools-extra] r325802 - Fix "not all control paths return a value" MSVC warning. NFCI.

2018-02-22 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Thu Feb 22 08:12:27 2018
New Revision: 325802

URL: http://llvm.org/viewvc/llvm-project?rev=325802=rev
Log:
Fix "not all control paths return a value" MSVC warning. NFCI.

Modified:
clang-tools-extra/trunk/clangd/TUScheduler.cpp

Modified: clang-tools-extra/trunk/clangd/TUScheduler.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/TUScheduler.cpp?rev=325802=325801=325802=diff
==
--- clang-tools-extra/trunk/clangd/TUScheduler.cpp (original)
+++ clang-tools-extra/trunk/clangd/TUScheduler.cpp Thu Feb 22 08:12:27 2018
@@ -342,6 +342,7 @@ bool ASTWorker::shouldSkipHeadLocked() c
 return true; // Prefer later diagnostics.
 return false;
   }
+  llvm_unreachable("Unknown WantDiagnostics");
 }
 
 bool ASTWorker::blockUntilIdle(Deadline Timeout) const {


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


[PATCH] D43625: [OpenMP] Remove implicit data sharing code gen that aims to use device shared memory

2018-02-22 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea created this revision.
gtbercea added reviewers: ABataev, carlo.bertolli, caomhin.
Herald added subscribers: cfe-commits, guansong, jholewinski.

Remove this scheme for now since it will be covered by another more generic 
scheme using global memory. This code will be worked into an optimization for 
the generic data sharing scheme. Removing this completely and then adding it 
via future patches will make all future data sharing patches cleaner.


Repository:
  rC Clang

https://reviews.llvm.org/D43625

Files:
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  lib/CodeGen/CGOpenMPRuntimeNVPTX.h
  test/OpenMP/nvptx_data_sharing.cpp
  test/OpenMP/nvptx_parallel_codegen.cpp
  test/OpenMP/nvptx_target_teams_codegen.cpp

Index: test/OpenMP/nvptx_target_teams_codegen.cpp
===
--- test/OpenMP/nvptx_target_teams_codegen.cpp
+++ test/OpenMP/nvptx_target_teams_codegen.cpp
@@ -60,7 +60,7 @@
   //
   // CHECK: [[AWAIT_WORK]]
   // CHECK: call void @llvm.nvvm.barrier0()
-  // CHECK: [[KPR:%.+]] = call i1 @__kmpc_kernel_parallel(i8** [[OMP_WORK_FN]], i8*** %shared_args, i16 1)
+  // CHECK: [[KPR:%.+]] = call i1 @__kmpc_kernel_parallel(i8** [[OMP_WORK_FN]], i16 1)
   // CHECK: [[KPRB:%.+]] = zext i1 [[KPR]] to i8
   // store i8 [[KPRB]], i8* [[OMP_EXEC_STATUS]], align 1
   // CHECK: [[WORK:%.+]] = load i8*, i8** [[OMP_WORK_FN]],
@@ -148,7 +148,7 @@
   //
   // CHECK: [[AWAIT_WORK]]
   // CHECK: call void @llvm.nvvm.barrier0()
-  // CHECK: [[KPR:%.+]] = call i1 @__kmpc_kernel_parallel(i8** [[OMP_WORK_FN]], i8*** %shared_args, i16 1)
+  // CHECK: [[KPR:%.+]] = call i1 @__kmpc_kernel_parallel(i8** [[OMP_WORK_FN]], i16 1)
   // CHECK: [[KPRB:%.+]] = zext i1 [[KPR]] to i8
   // store i8 [[KPRB]], i8* [[OMP_EXEC_STATUS]], align 1
   // CHECK: [[WORK:%.+]] = load i8*, i8** [[OMP_WORK_FN]],
Index: test/OpenMP/nvptx_parallel_codegen.cpp
===
--- test/OpenMP/nvptx_parallel_codegen.cpp
+++ test/OpenMP/nvptx_parallel_codegen.cpp
@@ -78,7 +78,7 @@
   //
   // CHECK: [[AWAIT_WORK]]
   // CHECK: call void @llvm.nvvm.barrier0()
-  // CHECK: [[KPR:%.+]] = call i1 @__kmpc_kernel_parallel(i8** [[OMP_WORK_FN]],
+  // CHECK: [[KPR:%.+]] = call i1 @__kmpc_kernel_parallel(i8** [[OMP_WORK_FN]]
   // CHECK: [[KPRB:%.+]] = zext i1 [[KPR]] to i8
   // store i8 [[KPRB]], i8* [[OMP_EXEC_STATUS]], align 1
   // CHECK: [[WORK:%.+]] = load i8*, i8** [[OMP_WORK_FN]],
@@ -92,20 +92,20 @@
   //
   // CHECK: [[EXEC_PARALLEL]]
   // CHECK: [[WF1:%.+]] = load i8*, i8** [[OMP_WORK_FN]],
-  // CHECK: [[WM1:%.+]] = icmp eq i8* [[WF1]], bitcast (void (i16, i32, i8**)* [[PARALLEL_FN1:@.+]]_wrapper to i8*)
+  // CHECK: [[WM1:%.+]] = icmp eq i8* [[WF1]], bitcast (void (i32*, i32*)* [[PARALLEL_FN1:@.+]] to i8*)
   // CHECK: br i1 [[WM1]], label {{%?}}[[EXEC_PFN1:.+]], label {{%?}}[[CHECK_NEXT1:.+]]
   //
   // CHECK: [[EXEC_PFN1]]
-  // CHECK: call void [[PARALLEL_FN1]]_wrapper(
+  // CHECK: call void [[PARALLEL_FN1]](
   // CHECK: br label {{%?}}[[TERM_PARALLEL:.+]]
   //
   // CHECK: [[CHECK_NEXT1]]
   // CHECK: [[WF2:%.+]] = load i8*, i8** [[OMP_WORK_FN]],
-  // CHECK: [[WM2:%.+]] = icmp eq i8* [[WF2]], bitcast (void (i16, i32, i8**)* [[PARALLEL_FN2:@.+]]_wrapper to i8*)
+  // CHECK: [[WM2:%.+]] = icmp eq i8* [[WF2]], bitcast (void (i32*, i32*)* [[PARALLEL_FN2:@.+]] to i8*)
   // CHECK: br i1 [[WM2]], label {{%?}}[[EXEC_PFN2:.+]], label {{%?}}[[CHECK_NEXT2:.+]]
   //
   // CHECK: [[EXEC_PFN2]]
-  // CHECK: call void [[PARALLEL_FN2]]_wrapper(
+  // CHECK: call void [[PARALLEL_FN2]](
   // CHECK: br label {{%?}}[[TERM_PARALLEL:.+]]
   //
   // CHECK: [[CHECK_NEXT2]]
@@ -152,13 +152,13 @@
   // CHECK-DAG: [[MWS:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.warpsize()
   // CHECK: [[MTMP1:%.+]] = sub i32 [[MNTH]], [[MWS]]
   // CHECK: call void @__kmpc_kernel_init(i32 [[MTMP1]]
-  // CHECK: call void @__kmpc_kernel_prepare_parallel(i8* bitcast (void (i16, i32, i8**)* [[PARALLEL_FN1]]_wrapper to i8*),
+  // CHECK: call void @__kmpc_kernel_prepare_parallel(i8* bitcast (void (i32*, i32*)* [[PARALLEL_FN1]] to i8*),
   // CHECK: call void @llvm.nvvm.barrier0()
   // CHECK: call void @llvm.nvvm.barrier0()
   // CHECK: call void @__kmpc_serialized_parallel(
   // CHECK: {{call|invoke}} void [[PARALLEL_FN3:@.+]](
   // CHECK: call void @__kmpc_end_serialized_parallel(
-  // CHECK: call void @__kmpc_kernel_prepare_parallel(i8* bitcast (void (i16, i32, i8**)* [[PARALLEL_FN2]]_wrapper to i8*),
+  // CHECK: call void @__kmpc_kernel_prepare_parallel(i8* bitcast (void (i32*, i32*)* [[PARALLEL_FN2]] to i8*),
   // CHECK: call void @llvm.nvvm.barrier0()
   // CHECK: call void @llvm.nvvm.barrier0()
   // CHECK-64-DAG: load i32, i32* [[REF_A]]
@@ -203,7 +203,7 @@
   //
   // CHECK: [[AWAIT_WORK]]
   // CHECK: call void @llvm.nvvm.barrier0()
-  // CHECK: [[KPR:%.+]] = call i1 @__kmpc_kernel_parallel(i8** [[OMP_WORK_FN]],
+  // CHECK: [[KPR:%.+]] = call i1 

r325807 - [docs] Regenerate command line reference

2018-02-22 Thread Jonas Hahnfeld via cfe-commits
Author: hahnfeld
Date: Thu Feb 22 09:10:28 2018
New Revision: 325807

URL: http://llvm.org/viewvc/llvm-project?rev=325807=rev
Log:
[docs] Regenerate command line reference

Modified:
cfe/trunk/docs/ClangCommandLineReference.rst

Modified: cfe/trunk/docs/ClangCommandLineReference.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangCommandLineReference.rst?rev=325807=325806=325807=diff
==
--- cfe/trunk/docs/ClangCommandLineReference.rst (original)
+++ cfe/trunk/docs/ClangCommandLineReference.rst Thu Feb 22 09:10:28 2018
@@ -61,10 +61,10 @@ Pass  to the ptxas assembler
 Pass  to the target offloading toolchain.
 
 .. program:: clang1
-.. option:: -Xopenmp-target= 
+.. option:: -Xopenmp-target= 
 .. program:: clang
 
-Pass  to the specified target offloading toolchain. The triple that 
identifies the toolchain must be provided after the equals sign.
+Pass  to the target offloading toolchain identified by .
 
 .. option:: -Z
 
@@ -710,6 +710,14 @@ Print source range spans in numeric form
 
 .. option:: -fdiagnostics-show-category=
 
+.. option:: -fdiscard-value-names, -fno-discard-value-names
+
+Discard value names in LLVM IR
+
+.. option:: -fexperimental-isel, -fno-experimental-isel
+
+Enables the experimental global instruction selector
+
 .. option:: -fexperimental-new-pass-manager, -fno-experimental-new-pass-manager
 
 Enables an experimental new pass manager in LLVM.
@@ -744,6 +752,10 @@ Level of field padding for AddressSaniti
 
 Enable linker dead stripping of globals in AddressSanitizer
 
+.. option:: -fsanitize-address-poison-class-member-array-new-cookie, 
-fno-sanitize-address-poison-class-member-array-new-cookie
+
+Enable poisoning array cookies when using class member operator new\[\] in 
AddressSanitizer
+
 .. option:: -fsanitize-address-use-after-scope, 
-fno-sanitize-address-use-after-scope
 
 Enable use-after-scope detection in AddressSanitizer
@@ -876,6 +888,10 @@ Add directory to include search path
 
 Restrict all prior -I flags to double-quoted inclusion and remove current 
directory from include path
 
+.. option:: --cuda-path-ignore-env
+
+Ignore environment variables to detect CUDA installation
+
 .. option:: --cuda-path=
 
 CUDA installation path
@@ -1507,12 +1523,6 @@ Do not treat C++ operator name keywords
 
 .. option:: -fno-working-directory
 
-.. option:: -fnoopenmp-relocatable-target
-
-Do not compile OpenMP target code as relocatable.
-
-.. option:: -fnoopenmp-use-tls
-
 .. option:: -fobjc-abi-version=
 
 .. option:: -fobjc-arc, -fno-objc-arc
@@ -1551,18 +1561,12 @@ Enable ARC-style weak references in Obje
 
 .. option:: -fopenmp, -fno-openmp
 
-.. option:: -fopenmp-dump-offload-linker-script
-
-.. option:: -fopenmp-relocatable-target
-
-OpenMP target code is compiled as relocatable using the -c flag. For OpenMP 
targets the code is relocatable by default.
+Parse OpenMP pragmas and generate parallel code.
 
 .. option:: -fopenmp-simd, -fno-openmp-simd
 
 Emit OpenMP code only for SIMD-based constructs.
 
-.. option:: -fopenmp-use-tls
-
 .. option:: -fopenmp-version=
 
 .. program:: clang1
@@ -1748,7 +1752,7 @@ Enable the superword-level parallelism v
 
 .. option:: -fsplit-dwarf-inlining, -fno-split-dwarf-inlining
 
-Place debug types in their own section (ELF Only)
+Provide minimal debug info in the object/executable to facilitate online 
symbolication/stack traces in the absence of .dwo/.dwp files when using Split 
DWARF
 
 .. option:: -fsplit-stack
 
@@ -1974,6 +1978,10 @@ OpenCL language standard to compile for.
 
 OpenCL only. This option is added for compatibility with OpenCL 1.0.
 
+.. option:: -cl-uniform-work-group-size
+
+OpenCL only. Defines that the global work-size be a multiple of the work-group 
size specified to clEnqueueNDRangeKernel
+
 .. option:: -cl-unsafe-math-optimizations
 
 OpenCL only. Allow unsafe floating-point optimizations.  Also implies 
-cl-no-signed-zeros and -cl-mad-enable.
@@ -2086,6 +2094,10 @@ Use Intel MCU ABI
 
 (integrated-as) Emit an object file which can be used with an incremental 
linker
 
+.. option:: -mindirect-jump=
+
+Change indirect jump instructions to inhibit speculation
+
 .. option:: -miphoneos-version-min=, -mios-version-min=
 
 .. option:: -mips16
@@ -2436,6 +2448,8 @@ X86
 
 .. option:: -mrtm, -mno-rtm
 
+.. option:: -msahf, -mno-sahf
+
 .. option:: -msgx, -mno-sgx
 
 .. option:: -msha, -mno-sha


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


[PATCH] D41102: Setup clang-doc frontend framework

2018-02-22 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett updated this revision to Diff 135453.
juliehockett marked 13 inline comments as done.
juliehockett added a comment.

Cleaning up bitcode writer


https://reviews.llvm.org/D41102

Files:
  CMakeLists.txt
  clang-doc/BitcodeWriter.cpp
  clang-doc/BitcodeWriter.h
  clang-doc/CMakeLists.txt
  clang-doc/ClangDoc.h
  clang-doc/Mapper.cpp
  clang-doc/Mapper.h
  clang-doc/Representation.h
  clang-doc/tool/CMakeLists.txt
  clang-doc/tool/ClangDocMain.cpp
  docs/clang-doc.rst
  test/CMakeLists.txt
  test/clang-doc/mapper-class.cpp
  test/clang-doc/mapper-enum.cpp
  test/clang-doc/mapper-function.cpp
  test/clang-doc/mapper-method.cpp
  test/clang-doc/mapper-namespace.cpp
  test/clang-doc/mapper-struct.cpp
  test/clang-doc/mapper-union.cpp

Index: test/clang-doc/mapper-union.cpp
===
--- /dev/null
+++ test/clang-doc/mapper-union.cpp
@@ -0,0 +1,29 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: llvm-bcanalyzer %t/docs/c:@u...@d.bc --dump | FileCheck %s
+
+union D { int X; int Y; };
+// CHECK: 
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'D'
+  // CHECK: 
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'int'
+// CHECK:  blob data = 'D::X'
+// CHECK: 
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'int'
+// CHECK:  blob data = 'D::Y'
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+
+
Index: test/clang-doc/mapper-struct.cpp
===
--- /dev/null
+++ test/clang-doc/mapper-struct.cpp
@@ -0,0 +1,23 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: llvm-bcanalyzer %t/docs/c:@s...@c.bc --dump | FileCheck %s
+
+struct C { int i; };
+// CHECK: 
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'C'
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'int'
+// CHECK:  blob data = 'C::i'
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+
+
Index: test/clang-doc/mapper-namespace.cpp
===
--- /dev/null
+++ test/clang-doc/mapper-namespace.cpp
@@ -0,0 +1,17 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: llvm-bcanalyzer %t/docs/c:@n...@a.bc --dump | FileCheck %s
+
+namespace A {}
+// CHECK: 
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'A'
+// CHECK: 
+
+
Index: test/clang-doc/mapper-method.cpp
===
--- /dev/null
+++ test/clang-doc/mapper-method.cpp
@@ -0,0 +1,31 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: llvm-bcanalyzer %t/docs/c:@S@G@F@Method#I#.bc --dump | FileCheck %s
+
+class G {
+public: 
+	int Method(int param) { return param; }
+};
+// CHECK: 
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'Method'
+  // CHECK: 
+  // CHECK:  blob data = 'c:@S@G'
+  // CHECK: 
+// CHECK:  blob data = 'int'
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'int'
+// CHECK:  blob data = 'param'
+  // CHECK: 
+// CHECK: 
+
+
+
+
Index: test/clang-doc/mapper-function.cpp
===
--- /dev/null
+++ test/clang-doc/mapper-function.cpp
@@ -0,0 +1,24 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: llvm-bcanalyzer %t/docs/c:@F@F#I#.bc --dump | FileCheck %s
+
+int F(int param) { return param; }
+// CHECK: 
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'F'
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'int'
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'int'
+// CHECK:  blob data = 'param'
+  // CHECK: 
+// CHECK: 
+
Index: test/clang-doc/mapper-enum.cpp
===
--- /dev/null
+++ test/clang-doc/mapper-enum.cpp
@@ -0,0 +1,25 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: llvm-bcanalyzer %t/docs/c:@e...@b.bc --dump | FileCheck %s
+
+enum B { X, Y };
+// CHECK: 
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'B'
+  

[PATCH] D41102: Setup clang-doc frontend framework

2018-02-22 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett added inline comments.



Comment at: clang-doc/BitcodeWriter.cpp:219
+
+void ClangDocBitcodeWriter::emitIntRecord(int Value, RecordId ID) {
+  if (!Value) return;

lebedev.ri wrote:
> Now, all these three `emit*Record` functions now have the 'same signature':
> ```
> template 
> void ClangDocBitcodeWriter::emitRecord(const T& Record, RecordId ID);
> 
> template <>
> void ClangDocBitcodeWriter::emitRecord(StringRef Str, RecordId ID) {
> ...
> ```
> 
> **Assuming there are no implicit conversions going on**, i'd make that change.
> It, again, may open the road for further generalizations.
I overloaded the functions -- cleaner, and deals with any implicit conversions 
nicely.



Comment at: clang-doc/BitcodeWriter.h:178
+  void emitTypeBlock(const std::unique_ptr );
+  void emitMemberTypeBlock(const std::unique_ptr );
+  void emitFieldTypeBlock(const std::unique_ptr );

lebedev.ri wrote:
> Let's continue cracking down on duplication.
> I think these four functions need the same template treatment as 
> `writeBitstreamForInfo()`
> 
> (please feel free to use better names)
> ```
> template
> void emitBlock(const std::unique_ptr );
> 
> template
> void emitTypedBlock(const std::unique_ptr ) {
>   StreamSubBlockGuard Block(Stream, MapFromInfoToBlockId::ID);
>   emitBlock(B);
> }
> 
> template<>
> void ClangDocBitcodeWriter::emitBlock(const std::unique_ptr ) {
>   emitStringRecord(T->TypeUSR, FIELD_TYPE_TYPE);
>   for (const auto  : T->Description) emitCommentBlock(CI);
> }
> ```
> 
> I agree that it seems strange, and seem to actually increase the code size so 
> far,
> but i believe by exposing similar functionality under one function,
> later, it will open the road for more opportunities of further consolidation.
Since it actually ended up duplicating the `writeBitstreamForInfo()` code, I 
rolled all of this into one `emitBlock()` entry point.


https://reviews.llvm.org/D41102



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


[PATCH] D43513: [OpenMP] Limit reduction support for pragma 'distribute' when combined with pragma 'simd'

2018-02-22 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

LG


Repository:
  rC Clang

https://reviews.llvm.org/D43513



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


[PATCH] D43621: [Driver] Allow using a canonical form of '-fuse-ld=' when cross-compiling on Windows.

2018-02-22 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added a comment.

In https://reviews.llvm.org/D43621#1015888, @amccarth wrote:

> This must be new-ish code, since I've routinely used `-fuse-ld=lld` (without 
> `.exe`) on Windows.


Well, since 12/2016: https://reviews.llvm.org/rC289668


Repository:
  rC Clang

https://reviews.llvm.org/D43621



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


[PATCH] D43628: [Sema][NFC] Split Function MultiVersioning decl semantic analysis into its own .cpp file.

2018-02-22 Thread Erich Keane via Phabricator via cfe-commits
erichkeane created this revision.
erichkeane added reviewers: rnk, echristo, aaron.ballman, rsmith.
Herald added subscribers: mgrang, mgorny.

I'm currently working on the cpu_dispatch and cpu_specific multiversion
support, which is making this functionality require a significant amount
of functions.  It seems that it would be easier to refactor this and add
additional mechanisms if unencumbered by the rest of SemaDecl (which itself
is getting quite large).


Repository:
  rC Clang

https://reviews.llvm.org/D43628

Files:
  include/clang/Sema/Sema.h
  lib/Sema/CMakeLists.txt
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclMultiVersion.cpp

Index: lib/Sema/SemaDeclMultiVersion.cpp
===
--- lib/Sema/SemaDeclMultiVersion.cpp
+++ lib/Sema/SemaDeclMultiVersion.cpp
@@ -0,0 +1,353 @@
+//==SemaDeclMultiVersion.cpp - Semantic Analysis for MultiVersion Functions===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+//  This file implements semantic analysis for MultiVersion Function
+//  Declarations.
+//
+//===--===//
+
+#include "clang/Sema/SemaInternal.h"
+
+using namespace clang;
+using namespace sema;
+
+/// \brief Check the target attribute of the function for MultiVersion
+/// validity.
+///
+/// Returns true if there was an error, false otherwise.
+static bool CheckMultiVersionValue(Sema , const FunctionDecl *FD) {
+  const auto *TA = FD->getAttr();
+  assert(TA && "MultiVersion Candidate requires a target attribute");
+  TargetAttr::ParsedTargetAttr ParseInfo = TA->parse();
+  const TargetInfo  = S.Context.getTargetInfo();
+  enum ErrType { Feature = 0, Architecture = 1 };
+
+  if (!ParseInfo.Architecture.empty() &&
+  !TargetInfo.validateCpuIs(ParseInfo.Architecture)) {
+S.Diag(FD->getLocation(), diag::err_bad_multiversion_option)
+<< Architecture << ParseInfo.Architecture;
+return true;
+  }
+
+  for (const auto  : ParseInfo.Features) {
+auto BareFeat = StringRef{Feat}.substr(1);
+if (Feat[0] == '-') {
+  S.Diag(FD->getLocation(), diag::err_bad_multiversion_option)
+  << Feature << ("no-" + BareFeat).str();
+  return true;
+}
+
+if (!TargetInfo.validateCpuSupports(BareFeat) ||
+!TargetInfo.isValidFeatureName(BareFeat)) {
+  S.Diag(FD->getLocation(), diag::err_bad_multiversion_option)
+  << Feature << BareFeat;
+  return true;
+}
+  }
+  return false;
+}
+
+static bool CheckMultiVersionAdditionalRules(Sema , const FunctionDecl *OldFD,
+ const FunctionDecl *NewFD,
+ bool CausesMV) {
+  enum DoesntSupport {
+FuncTemplates = 0,
+VirtFuncs = 1,
+DeducedReturn = 2,
+Constructors = 3,
+Destructors = 4,
+DeletedFuncs = 5,
+DefaultedFuncs = 6
+  };
+  enum Different {
+CallingConv = 0,
+ReturnType = 1,
+ConstexprSpec = 2,
+InlineSpec = 3,
+StorageClass = 4,
+Linkage = 5
+  };
+
+  // For now, disallow all other attributes.  These should be opt-in, but
+  // an analysis of all of them is a future FIXME.
+  if (CausesMV && OldFD &&
+  std::distance(OldFD->attr_begin(), OldFD->attr_end()) != 1) {
+S.Diag(OldFD->getLocation(), diag::err_multiversion_no_other_attrs);
+S.Diag(NewFD->getLocation(), diag::note_multiversioning_caused_here);
+return true;
+  }
+
+  if (std::distance(NewFD->attr_begin(), NewFD->attr_end()) != 1)
+return S.Diag(NewFD->getLocation(), diag::err_multiversion_no_other_attrs);
+
+  if (NewFD->getTemplatedKind() == FunctionDecl::TK_FunctionTemplate)
+return S.Diag(NewFD->getLocation(), diag::err_multiversion_doesnt_support)
+   << FuncTemplates;
+
+  if (const auto *NewCXXFD = dyn_cast(NewFD)) {
+if (NewCXXFD->isVirtual())
+  return S.Diag(NewCXXFD->getLocation(),
+diag::err_multiversion_doesnt_support)
+ << VirtFuncs;
+
+if (const auto *NewCXXCtor = dyn_cast(NewFD))
+  return S.Diag(NewCXXCtor->getLocation(),
+diag::err_multiversion_doesnt_support)
+ << Constructors;
+
+if (const auto *NewCXXDtor = dyn_cast(NewFD))
+  return S.Diag(NewCXXDtor->getLocation(),
+diag::err_multiversion_doesnt_support)
+ << Destructors;
+  }
+
+  if (NewFD->isDeleted())
+return S.Diag(NewFD->getLocation(), diag::err_multiversion_doesnt_support)
+   << DeletedFuncs;
+
+  if (NewFD->isDefaulted())
+return S.Diag(NewFD->getLocation(), diag::err_multiversion_doesnt_support)
+   << DefaultedFuncs;
+
+  QualType NewQType = S.getASTContext().getCanonicalType(NewFD->getType());
+  const auto 

[PATCH] D43634: [clangd] Extend textDocument/didChange to specify whether diagnostics should be generated.

2018-02-22 Thread Eric Liu via Phabricator via cfe-commits
ioeric created this revision.
ioeric added a reviewer: sammccall.
Herald added subscribers: cfe-commits, jkorous-apple, ilya-biryukov, klimek.

This would allow us to disable diagnostics when didChange is called but
diagnostics are not wanted (e.g. code completion).


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43634

Files:
  clangd/ClangdLSPServer.cpp
  clangd/Protocol.cpp
  clangd/Protocol.h
  test/clangd/want-diagnostics.test


Index: test/clangd/want-diagnostics.test
===
--- /dev/null
+++ test/clangd/want-diagnostics.test
@@ -0,0 +1,19 @@
+# RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+---
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///main.cpp","languageId":"cpp","version":1,"text":"void
 main() {}"}}}
+#  CHECK:  "method": "textDocument/publishDiagnostics",
+---
+{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"test:///main.cpp","version":2},"contentChanges":[{"text":"void
 main() {}"}]}}
+---
+#  CHECK:  "method": "textDocument/publishDiagnostics",
+{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"test:///main.cpp","version":3},"contentChanges":[{"text":"void
 main() {}"}],"wantDiagnostics":true}}
+---
+#  CHECK:  "method": "textDocument/publishDiagnostics",
+{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"test:///main.cpp","version":4},"contentChanges":[{"text":"void
 main() {}"}],"wantDiagnostics":false}}
+---
+#  CHECK-NOT:  "method": "textDocument/publishDiagnostics",
+{"jsonrpc":"2.0","id":2,"method":"shutdown"}
+#  CHECK:  "method": "textDocument/publishDiagnostics",
+---
+{"jsonrpc":"2.0","method":"exit"}
Index: clangd/Protocol.h
===
--- clangd/Protocol.h
+++ clangd/Protocol.h
@@ -297,6 +297,15 @@
 
   /// The actual content changes.
   std::vector contentChanges;
+
+  /// If this is not set, diagnostics will be generated for the current version
+  /// or a subsequent one.
+  /// If this is set to true, dianostics are guaranteed to be generated for the
+  /// current version.
+  /// If this is set to false, dianostics will not be generated for this
+  /// request.
+  /// This is a clangd extension.
+  llvm::Optional wantDiagnostics;
 };
 bool fromJSON(const json::Expr &, DidChangeTextDocumentParams &);
 
Index: clangd/Protocol.cpp
===
--- clangd/Protocol.cpp
+++ clangd/Protocol.cpp
@@ -221,7 +221,8 @@
 bool fromJSON(const json::Expr , DidChangeTextDocumentParams ) {
   json::ObjectMapper O(Params);
   return O && O.map("textDocument", R.textDocument) &&
- O.map("contentChanges", R.contentChanges);
+ O.map("contentChanges", R.contentChanges) &&
+ O.map("wantDiagnostics", R.wantDiagnostics);
 }
 
 bool fromJSON(const json::Expr , FileChangeType ) {
Index: clangd/ClangdLSPServer.cpp
===
--- clangd/ClangdLSPServer.cpp
+++ clangd/ClangdLSPServer.cpp
@@ -149,9 +149,13 @@
   if (Params.contentChanges.size() != 1)
 return replyError(ErrorCode::InvalidParams,
   "can only apply one change at a time");
+  auto WantDiags = WantDiagnostics::Auto;
+  if (Params.wantDiagnostics.hasValue())
+WantDiags = Params.wantDiagnostics.getValue() ? WantDiagnostics::Yes
+  : WantDiagnostics::No;
   // We only support full syncing right now.
   Server.addDocument(Params.textDocument.uri.file(),
- Params.contentChanges[0].text, WantDiagnostics::Auto);
+ Params.contentChanges[0].text, WantDiags);
 }
 
 void ClangdLSPServer::onFileEvent(DidChangeWatchedFilesParams ) {


Index: test/clangd/want-diagnostics.test
===
--- /dev/null
+++ test/clangd/want-diagnostics.test
@@ -0,0 +1,19 @@
+# RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+---
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///main.cpp","languageId":"cpp","version":1,"text":"void main() {}"}}}
+#  CHECK:  "method": "textDocument/publishDiagnostics",
+---
+{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"test:///main.cpp","version":2},"contentChanges":[{"text":"void main() {}"}]}}
+---
+#  CHECK:  "method": "textDocument/publishDiagnostics",

[PATCH] D43581: [clang-tidy/google] Fix the Objective-C global variable declaration check 

2018-02-22 Thread Yan Zhang via Phabricator via cfe-commits
Wizard requested changes to this revision.
Wizard added a comment.
This revision now requires changes to proceed.

Please update the warning info to indicate that prefix 'k' is not the only 
option for constants. Something like:
"const global variable '%0' must have an appropriate prefix or a name which 
starts with 'k[A-Z]'"


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43581



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


[PATCH] D43576: Solution to fix PR27066 - Redefinition with same mangled name as another definition (dllexport and uuid)

2018-02-22 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

It seems to me that the test here is very much lacking.  It doesn't seem to 
include the example you've mentioned, and has no validation to ensure that 
there is a single instantiation happening.  I'd like to see what happens when a 
UUID is passed as a pack, how SFINAE works on it, etc.




Comment at: include/clang/AST/RecursiveASTVisitor.h:846
 
+  case TemplateArgument::UuidExpression: {
+return getDerived().TraverseStmt(Arg.getAsUuidExpr());

No need for curly brackets.



Comment at: include/clang/AST/RecursiveASTVisitor.h:891
 
+  case TemplateArgument::UuidExpression: {
+return getDerived().TraverseStmt(ArgLoc.getSourceUuidExpression());

Curly brackets likely not necessary here.



Comment at: include/clang/AST/TemplateBase.h:214
   }
+  TemplateArgument(CXXUuidofExpr *E);
 

This function overload should be documented.



Comment at: lib/AST/ASTContext.cpp:5066
 
+case TemplateArgument::UuidExpression:
+  return Arg;

Not only for you here, but is there any reason why this cannot just be a 
fallthrough for the ones above?  I suspect we'd prefer to get those 3 all 
combined.



Comment at: lib/AST/MicrosoftMangle.cpp:1426
 break;
+  case TemplateArgument::UuidExpression: {
+const Expr *e = TA.getAsUuidExpr();

If you combine the getAsUuidExpr line and the mangleExpession line, you can get 
rid of curlies, and be more consistent with the surrounding code.



Comment at: lib/AST/TemplateBase.cpp:581
+PrintingPolicy Policy(LangOpts);
+Arg.getAsUuidExpr()->printPretty(OS, nullptr, Policy);
+return DB << OS.str();

Why is much of this required?  Wouldn't just calling printPretty with the 
current policy work?  Why use a separate stream rather than the 'DB' stream?



Comment at: lib/Sema/SemaTemplate.cpp:4629
+  ExprResult Res =
+CheckTemplateArgument(NTTP, NTTPType, 
Arg.getArgument().getAsUuidExpr(),
+  Result, CTAK);

Is this section clang-formatted?  It seems a little oddly newlined.


https://reviews.llvm.org/D43576



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


[PATCH] D42776: [Sema] Fix an assertion failure in constant expression evaluation of calls to functions with default arguments

2018-02-22 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

ping


https://reviews.llvm.org/D42776



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


[PATCH] D41228: [ObjC] Enable __strong pointers in structs under ARC

2018-02-22 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: include/clang/AST/Type.h:1121
+  /// after it is moved, as opposed to a truely destructive move in which the
+  /// source object is placed in an uninitialized state.
+  PrimitiveCopyKind isNonTrivialToPrimitiveDestructiveMove() const;

ahatanak wrote:
> rjmccall wrote:
> > "truly"
> > 
> > Hmm.  Now that I'm thinking more about it, I'm not sure there's any point 
> > in tracking non-triviality of a C++-style destructive move separately from 
> > the non-triviality of a copy.  It's hard to imagine that there would ever 
> > be a non-C++ type that primitively has non-trivial copies but trivial 
> > C++-style moves or vice-versa.  Type-based destructors imply that the type 
> > represents some kind of resource, and a C++-style move will always be 
> > non-trivial for resource types because ownership of the resource needs to 
> > be given up by the old location.  Otherwise, a type might be non-trivial to 
> > copy but not destroy because there's something special about how it's 
> > stored (like volatility), but it's hard to imagine what could possibly 
> > cause it to be non-trivial to destroy but not copy.
> > 
> > If we were tracking non-triviality of an *unsafe* destructive move, one 
> > that leaves the source in an uninitialized state, that's quite different.
> > 
> > I think there are three reasonable options here:
> > 
> > - Ignore the argument I just made about the types that we're *likely* to 
> > care about modeling and generalize your tracking to also distinguish 
> > construction from assignment.  In such an environment, I think you can 
> > absolutely make an argument that it's still interesting to track C++-style 
> > moves separately from copies.
> > 
> > - Drop the tracking of destructive moves completely.  If you want to keep 
> > the method around, find, but it can just call 
> > `isNonTrivialToPrimitiveCopy()`.
> > 
> > - Change the tracking of *destructive* moves to instead track 
> > *deinitializing* moves.  The implementation would stop considering 
> > `__strong` types to be non-trivial to move.
> > 
> > But as things stand today, I do not see any point in separately tracking 
> > triviality of C++-style destructive moves.
> The second option seems most reasonable to me. We can always make changes if 
> someone comes up with a type that requires tracking destructive moves 
> separately.
Well, we already have a type that would have a trivial deinitializing move: ARC 
`__strong` pointers.  What we don't have is anything in IRGen that currently 
would take advantage of that fact.  Anyway, I agree that we can wait to start 
tracking this until we add such code to the compiler.



Comment at: lib/CodeGen/CGNonTrivialStruct.cpp:193
+
+TrivialFieldIsVolatile |= FT.isVolatileQualified();
+if (Start == End)

ahatanak wrote:
> rjmccall wrote:
> > ahatanak wrote:
> > > rjmccall wrote:
> > > > I feel like maybe volatile fields should be individually copied instead 
> > > > of being aggregated into a multi-field memcpy.  This is a more natural 
> > > > interpretation of the C volatile rules than we currently do.  In fact, 
> > > > arguably we should really add a PrimitiveCopyKind enumerator for 
> > > > volatile fields (that are otherwise trivially-copyable) and force all 
> > > > copies of structs with volatile fields into this path precisely so that 
> > > > we can make a point of copying the volatile fields this way.  
> > > > (Obviously that part is not something that's your responsibility to do.)
> > > > 
> > > > To get that right with bit-fields, you'll need to propagate the actual 
> > > > FieldDecl down.  On the plus side, that should let you use 
> > > > EmitLValueForField to do the field projection in the common case.
> > > I added method visitVolatileTrivial that copies volatile fields 
> > > individually. Please see test case test_copy_constructor_Bitfield1 in 
> > > test/CodeGenObjC/strong-in-c-struct.m.
> > Okay, great!  I like the name.
> > 
> > Does this mean we're now copying all structs that contain volatile fields 
> > with one of these helper functions?  If so, please add a C test case 
> > testing just that.  Also, you should retitle this review and stress that 
> > we're changing how *all* non-trivial types are copied, and that that 
> > includes both volatile and ARC-qualified fields.
> No, the current patch doesn't copy volatile fields of a struct individually 
> unless the struct is a non-trivial type (which means its primitive copy kind 
> is PCK_Struct). I'll look into today how I can force structs with volatile 
> fields that are not non-trivial to be copied using the helper functions.
> 
> It seems like we would need a boolean flag in RecordDecl that tracks the 
> presence of volatile fields in the struct or one of its subobjects. I assume 
> we want to copy volatile fields individually in C++ too, in which case the 
> flag needs to be set in both C 

[PATCH] D43576: Solution to fix PR27066 - Redefinition with same mangled name as another definition (dllexport and uuid)

2018-02-22 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam added a comment.

In https://reviews.llvm.org/D43576#1016295, @majnemer wrote:

> We should really, really avoid making this sort of change without first 
> trying to desugar uuidof into a reference to a variable. That would solve a 
> ton of problems, problems like this one.


Not sure I fully understand what you are proposing?

Are you proposing that generated symbols like this:
??4?$A@$E?_GUID_ddb47a6a_0f23_11d5_9109_00e0296b75d3@@3U__s_GUID@@B@@QEAAAEAV0@AEBV0@@Z
 
Be de-sugared? Wouldn't that be different that what MS is doing? 
Can you please give me more details about what you are thinking of?
Thanks.


https://reviews.llvm.org/D43576



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


[PATCH] D43640: add support for constants with appropriate prefix. Start with 'k' is not the only option. This is according to http://google.github.io/styleguide/objcguide.html#constants

2018-02-22 Thread Yan Zhang via Phabricator via cfe-commits
Wizard created this revision.
Herald added subscribers: cfe-commits, klimek.

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43640

Files:
  clang-tidy/google/GlobalVariableDeclarationCheck.cpp
  test/clang-tidy/google-objc-global-variable-declaration.m


Index: test/clang-tidy/google-objc-global-variable-declaration.m
===
--- test/clang-tidy/google-objc-global-variable-declaration.m
+++ test/clang-tidy/google-objc-global-variable-declaration.m
@@ -2,7 +2,7 @@
 
 @class NSString;
 static NSString* const myConstString = @"hello";
-// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 
'myConstString' must have a name which starts with 'k[A-Z]' 
[google-objc-global-variable-declaration]
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 
'myConstString' must have an appropriate prefix or a name which starts with 
'k[A-Z]' [google-objc-global-variable-declaration]
 // CHECK-FIXES: static NSString* const kMyConstString = @"hello";
 
 static NSString* MyString = @"hi";
@@ -22,14 +22,15 @@
 // CHECK-FIXES: static NSString* gNoDef;
 
 static NSString* const _notAlpha = @"NotBeginWithAlpha";
-// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable '_notAlpha' 
must have a name which starts with 'k[A-Z]' 
[google-objc-global-variable-declaration]
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable '_notAlpha' 
must have an appropriate prefix or a name which starts with 'k[A-Z]' 
[google-objc-global-variable-declaration]
 // CHECK-FIXES: static NSString* const _notAlpha = @"NotBeginWithAlpha";
 
 static NSString* const k_Alpha = @"SecondNotAlpha";
-// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 'k_Alpha' 
must have a name which starts with 'k[A-Z]' 
[google-objc-global-variable-declaration]
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 'k_Alpha' 
must have an appropriate prefix or a name which starts with 'k[A-Z]' 
[google-objc-global-variable-declaration]
 // CHECK-FIXES: static NSString* const k_Alpha = @"SecondNotAlpha";
 
 static NSString* const kGood = @"hello";
+static NSString* const ABCGood = @"I have a prefix";
 static NSString* gMyIntGood = 0;
 
 @implementation Foo
Index: clang-tidy/google/GlobalVariableDeclarationCheck.cpp
===
--- clang-tidy/google/GlobalVariableDeclarationCheck.cpp
+++ clang-tidy/google/GlobalVariableDeclarationCheck.cpp
@@ -24,15 +24,13 @@
 
 namespace {
 
-AST_MATCHER(VarDecl, isLocalVariable) {
-  return Node.isLocalVarDecl();
-}
+AST_MATCHER(VarDecl, isLocalVariable) { return Node.isLocalVarDecl(); }
 
 FixItHint generateFixItHint(const VarDecl *Decl, bool IsConst) {
   char FC = Decl->getName()[0];
   if (!llvm::isAlpha(FC) || Decl->getName().size() == 1) {
 // No fix available if first character is not alphabetical character, or it
-// is a single-character variable, since it is difficult to determine the 
+// is a single-character variable, since it is difficult to determine the
 // proper fix in this case. Users should create a proper variable name by
 // their own.
 return FixItHint();
@@ -72,7 +70,7 @@
   this);
   Finder->addMatcher(varDecl(hasGlobalStorage(), hasType(isConstQualified()),
  unless(isLocalVariable()),
- unless(matchesName("::k[A-Z]")))
+ unless(matchesName("::(k|[A-Z]{2,})[A-Z]")))
  .bind("global_const"),
  this);
 }
@@ -87,8 +85,8 @@
   }
   if (const auto *Decl = Result.Nodes.getNodeAs("global_const")) {
 diag(Decl->getLocation(),
- "const global variable '%0' must have a name which starts with "
- "'k[A-Z]'")
+ "const global variable '%0' must have an appropriate prefix or a name 
"
+ "which starts with 'k[A-Z]'")
 << Decl->getName() << generateFixItHint(Decl, true);
   }
 }


Index: test/clang-tidy/google-objc-global-variable-declaration.m
===
--- test/clang-tidy/google-objc-global-variable-declaration.m
+++ test/clang-tidy/google-objc-global-variable-declaration.m
@@ -2,7 +2,7 @@
 
 @class NSString;
 static NSString* const myConstString = @"hello";
-// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 'myConstString' must have a name which starts with 'k[A-Z]' [google-objc-global-variable-declaration]
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 'myConstString' must have an appropriate prefix or a name which starts with 'k[A-Z]' [google-objc-global-variable-declaration]
 // CHECK-FIXES: static NSString* const kMyConstString = @"hello";
 
 static NSString* MyString = @"hi";
@@ -22,14 +22,15 @@
 // CHECK-FIXES: static NSString* gNoDef;
 
 static NSString* const _notAlpha = @"NotBeginWithAlpha";
-// CHECK-MESSAGES: 

r325822 - [OpenMP] Limit reduction support for pragma 'distribute' when combined with pragma 'simd'

2018-02-22 Thread Carlo Bertolli via cfe-commits
Author: cbertol
Date: Thu Feb 22 11:38:14 2018
New Revision: 325822

URL: http://llvm.org/viewvc/llvm-project?rev=325822=rev
Log:
[OpenMP] Limit reduction support for pragma 'distribute' when combined with 
pragma 'simd'

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

This is a bug fix that removes the emission of reduction support for pragma 
'distribute' when found alone or in combinations without simd.
Pragma 'distribute' does not have a reduction clause, but when combined with 
pragma 'simd' we need to emit the support for simd's reduction clause as part 
of code generation for distribute. This guard is similar to the one used for 
reduction support earlier in the same code gen function.



Added:
cfe/trunk/test/OpenMP/distribute_parallel_for_reduction_codegen.cpp
Modified:
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp

Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=325822=325821=325822=diff
==
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Thu Feb 22 11:38:14 2018
@@ -3358,26 +3358,30 @@ void CodeGenFunction::EmitOMPDistributeL
   CGF.EmitLoadOfScalar(IL, S.getLocStart()));
 });
   }
-  OpenMPDirectiveKind ReductionKind = OMPD_unknown;
-  if (isOpenMPParallelDirective(S.getDirectiveKind()) &&
-  isOpenMPSimdDirective(S.getDirectiveKind())) {
-ReductionKind = OMPD_parallel_for_simd;
-  } else if (isOpenMPParallelDirective(S.getDirectiveKind())) {
-ReductionKind = OMPD_parallel_for;
-  } else if (isOpenMPSimdDirective(S.getDirectiveKind())) {
-ReductionKind = OMPD_simd;
-  } else if (!isOpenMPTeamsDirective(S.getDirectiveKind()) &&
- S.hasClausesOfKind()) {
-llvm_unreachable(
-"No reduction clauses is allowed in distribute directive.");
+  if (isOpenMPSimdDirective(S.getDirectiveKind()) &&
+  !isOpenMPParallelDirective(S.getDirectiveKind()) &&
+  !isOpenMPTeamsDirective(S.getDirectiveKind())) {
+OpenMPDirectiveKind ReductionKind = OMPD_unknown;
+if (isOpenMPParallelDirective(S.getDirectiveKind()) &&
+isOpenMPSimdDirective(S.getDirectiveKind())) {
+  ReductionKind = OMPD_parallel_for_simd;
+} else if (isOpenMPParallelDirective(S.getDirectiveKind())) {
+  ReductionKind = OMPD_parallel_for;
+} else if (isOpenMPSimdDirective(S.getDirectiveKind())) {
+  ReductionKind = OMPD_simd;
+} else if (!isOpenMPTeamsDirective(S.getDirectiveKind()) &&
+   S.hasClausesOfKind()) {
+  llvm_unreachable(
+  "No reduction clauses is allowed in distribute directive.");
+}
+EmitOMPReductionClauseFinal(S, ReductionKind);
+// Emit post-update of the reduction variables if IsLastIter != 0.
+emitPostUpdateForReductionClause(
+*this, S, [&](CodeGenFunction ) -> llvm::Value * {
+  return CGF.Builder.CreateIsNotNull(
+  CGF.EmitLoadOfScalar(IL, S.getLocStart()));
+});
   }
-  EmitOMPReductionClauseFinal(S, ReductionKind);
-  // Emit post-update of the reduction variables if IsLastIter != 0.
-  emitPostUpdateForReductionClause(
-  *this, S, [&](CodeGenFunction ) -> llvm::Value * {
-return CGF.Builder.CreateIsNotNull(
-CGF.EmitLoadOfScalar(IL, S.getLocStart()));
-  });
   // Emit final copy of the lastprivate variables if IsLastIter != 0.
   if (HasLastprivateClause) {
 EmitOMPLastprivateClauseFinal(

Added: cfe/trunk/test/OpenMP/distribute_parallel_for_reduction_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/distribute_parallel_for_reduction_codegen.cpp?rev=325822=auto
==
--- cfe/trunk/test/OpenMP/distribute_parallel_for_reduction_codegen.cpp (added)
+++ cfe/trunk/test/OpenMP/distribute_parallel_for_reduction_codegen.cpp Thu Feb 
22 11:38:14 2018
@@ -0,0 +1,84 @@
+// Test host code gen
+
+// RUN: %clang_cc1  -verify -fopenmp -fopenmp-version=45 -x c++ -std=c++11 
-triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-llvm %s -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1  -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-pch -o %t %s
+// RUN: %clang_cc1  -fopenmp -fopenmp-version=45 -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s 
--check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1  -verify -fopenmp -fopenmp-version=45 -x c++ -std=c++11 
-triple 

Re: r324308 - Fix crash on invalid.

2018-02-22 Thread Richard Trieu via cfe-commits
Thanks, Hans!

On Thu, Feb 22, 2018 at 3:27 AM, Hans Wennborg  wrote:

> Seems safe. Merged in r325766.
>
> On Thu, Feb 22, 2018 at 1:15 AM, Richard Trieu  wrote:
> > Hi Hans,
> >
> > If there's still time for rc3, I'd like to get this crash fix in.  This
> adds
> > a null check to prevent a crash on invalid.
> >
> > Richard
> >
> > On Mon, Feb 5, 2018 at 6:58 PM, Richard Trieu via cfe-commits
> >  wrote:
> >>
> >> Author: rtrieu
> >> Date: Mon Feb  5 18:58:21 2018
> >> New Revision: 324308
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=324308=rev
> >> Log:
> >> Fix crash on invalid.
> >>
> >> Don't call a method when the pointer is null.
> >>
> >> Modified:
> >> cfe/trunk/lib/Sema/SemaExpr.cpp
> >> cfe/trunk/test/SemaCXX/lambda-expressions.cpp
> >>
> >> Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
> >> URL:
> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/
> SemaExpr.cpp?rev=324308=324307=324308=diff
> >>
> >> 
> ==
> >> --- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
> >> +++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Feb  5 18:58:21 2018
> >> @@ -14958,7 +14958,8 @@ static void DoMarkVarDeclReferenced(Sema
> >>  if (RefersToEnclosingScope) {
> >>LambdaScopeInfo *const LSI =
> >>SemaRef.getCurLambda(/*IgnoreNonLambdaCapturingScope=
> */true);
> >> -  if (LSI && !LSI->CallOperator->Encloses(Var->getDeclContext()))
> {
> >> +  if (LSI && (!LSI->CallOperator ||
> >> +  !LSI->CallOperator->Encloses(Var->getDeclContext(
> {
> >>  // If a variable could potentially be odr-used, defer marking
> it
> >> so
> >>  // until we finish analyzing the full expression for any
> >>  // lvalue-to-rvalue
> >>
> >> Modified: cfe/trunk/test/SemaCXX/lambda-expressions.cpp
> >> URL:
> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
> SemaCXX/lambda-expressions.cpp?rev=324308=324307=324308=diff
> >>
> >> 
> ==
> >> --- cfe/trunk/test/SemaCXX/lambda-expressions.cpp (original)
> >> +++ cfe/trunk/test/SemaCXX/lambda-expressions.cpp Mon Feb  5 18:58:21
> 2018
> >> @@ -608,3 +608,18 @@ namespace ConversionOperatorDoesNotHaveD
> >>// This used to crash in return type deduction for the conversion
> >> opreator.
> >>struct A { int n; void f() { +[](decltype(n)) {}; } };
> >>  }
> >> +
> >> +namespace TypoCorrection {
> >> +template  struct X {};
> >> +// expected-note@-1 {{template parameter is declared here}}
> >> +
> >> +template 
> >> +void Run(const int& points) {
> >> +// expected-note@-1 {{'points' declared here}}
> >> +  auto outer_lambda = []() {
> >> +auto inner_lambda = [](const X&) {};
> >> +// expected-error@-1 {{use of undeclared identifier 'Points'; did
> you
> >> mean 'points'?}}
> >> +// expected-error@-2 {{template argument for template type
> parameter
> >> must be a type}}
> >> +  };
> >> +}
> >> +}
> >>
> >>
> >> ___
> >> cfe-commits mailing list
> >> cfe-commits@lists.llvm.org
> >> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
> >
> >
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43533: [CFG] [analyzer] NFC: Refactor ConstructionContext into a finite set of cases.

2018-02-22 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 135480.
NoQ added a comment.

Address comments.


https://reviews.llvm.org/D43533

Files:
  include/clang/Analysis/CFG.h
  include/clang/Analysis/ConstructionContext.h
  lib/Analysis/CFG.cpp
  lib/Analysis/CMakeLists.txt
  lib/Analysis/ConstructionContext.cpp
  lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp

Index: lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
+++ lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
@@ -16,6 +16,7 @@
 #include "clang/AST/CXXInheritance.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/Analysis/Analyses/LiveVariables.h"
+#include "clang/Analysis/ConstructionContext.h"
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
 #include "llvm/ADT/SmallSet.h"
@@ -635,10 +636,11 @@
 
 const CXXConstructExpr *CtorExpr = Ctor.getOriginExpr();
 
-auto CC = getCurrentCFGElement().getAs();
-const Stmt *ParentExpr = CC ? CC->getTriggerStmt() : nullptr;
+auto CCE = getCurrentCFGElement().getAs();
+const ConstructionContext *CC = CCE ? CCE->getConstructionContext()
+: nullptr;
 
-if (ParentExpr && isa(ParentExpr) &&
+if (CC && isa(CC) &&
 !Opts.mayInlineCXXAllocator())
   return CIP_DisallowedOnce;
 
Index: lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
+++ lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
@@ -12,6 +12,7 @@
 //===--===//
 
 #include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
+#include "clang/Analysis/ConstructionContext.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/StmtCXX.h"
 #include "clang/AST/ParentMap.h"
@@ -111,47 +112,20 @@
   // See if we're constructing an existing region by looking at the
   // current construction context.
   if (CC) {
-if (const Stmt *TriggerStmt = CC->getTriggerStmt()) {
-  if (const CXXNewExpr *CNE = dyn_cast(TriggerStmt)) {
-if (AMgr.getAnalyzerOptions().mayInlineCXXAllocator()) {
-  // TODO: Detect when the allocator returns a null pointer.
-  // Constructor shall not be called in this case.
-  if (const SubRegion *MR = dyn_cast_or_null(
-  getCXXNewAllocatorValue(State, CNE, LCtx).getAsRegion())) {
-if (CNE->isArray()) {
-  // TODO: In fact, we need to call the constructor for every
-  // allocated element, not just the first one!
-  CallOpts.IsArrayCtorOrDtor = true;
-  return getStoreManager().GetElementZeroRegion(
-  MR, CNE->getType()->getPointeeType());
-}
-return MR;
-  }
-}
-  } else if (auto *DS = dyn_cast(TriggerStmt)) {
-const auto *Var = cast(DS->getSingleDecl());
-SVal LValue = State->getLValue(Var, LCtx);
-QualType Ty = Var->getType();
-LValue = makeZeroElementRegion(State, LValue, Ty,
-   CallOpts.IsArrayCtorOrDtor);
-return LValue.getAsRegion();
-  } else if (isa(TriggerStmt)) {
-// TODO: We should construct into a CXXBindTemporaryExpr or a
-// MaterializeTemporaryExpr around the call-expression on the previous
-// stack frame. Currently we re-bind the temporary to the correct region
-// later, but that's not semantically correct. This of course does not
-// apply when we're in the top frame. But if we are in an inlined
-// function, we should be able to take the call-site CFG element,
-// and it should contain (but right now it wouldn't) some sort of
-// construction context that'd give us the right temporary expression.
-CallOpts.IsTemporaryCtorOrDtor = true;
-return MRMgr.getCXXTempObjectRegion(CE, LCtx);
-  } else if (isa(TriggerStmt)) {
-CallOpts.IsTemporaryCtorOrDtor = true;
-return MRMgr.getCXXTempObjectRegion(CE, LCtx);
-  }
-  // TODO: Consider other directly initialized elements.
-} else if (const CXXCtorInitializer *Init = CC->getTriggerInit()) {
+switch (CC->getKind()) {
+case ConstructionContext::SimpleVariableKind: {
+  const auto *DSCC = cast(CC);
+  const auto *DS = DSCC->getDeclStmt();
+  const auto *Var = cast(DS->getSingleDecl());
+  SVal LValue = State->getLValue(Var, LCtx);
+  QualType Ty = Var->getType();
+  LValue =
+  makeZeroElementRegion(State, LValue, Ty, CallOpts.IsArrayCtorOrDtor);
+  return LValue.getAsRegion();
+}
+case ConstructionContext::ConstructorInitializerKind: {
+  const auto *ICC = cast(CC);
+  const auto *Init = 

[PATCH] D34367: CodeGen: Fix address space of indirect function argument

2018-02-22 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 135474.
yaxunl added a comment.

Revised by John's comments.


https://reviews.llvm.org/D34367

Files:
  lib/CodeGen/CGAtomic.cpp
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGCall.h
  lib/CodeGen/CGClass.cpp
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CGExprCXX.cpp
  lib/CodeGen/CGGPUBuiltin.cpp
  lib/CodeGen/CGObjCGNU.cpp
  lib/CodeGen/CGObjCMac.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/CodeGen/MicrosoftCXXABI.cpp
  test/CodeGenCXX/amdgcn-func-arg.cpp
  test/CodeGenOpenCL/addr-space-struct-arg.cl
  test/CodeGenOpenCL/byval.cl

Index: test/CodeGenOpenCL/byval.cl
===
--- test/CodeGenOpenCL/byval.cl
+++ test/CodeGenOpenCL/byval.cl
@@ -1,5 +1,4 @@
 // RUN: %clang_cc1 -emit-llvm -o - -triple amdgcn %s | FileCheck %s
-// RUN: %clang_cc1 -emit-llvm -o - -triple amdgcn---opencl %s | FileCheck %s
 
 struct A {
   int x[100];
Index: test/CodeGenOpenCL/addr-space-struct-arg.cl
===
--- test/CodeGenOpenCL/addr-space-struct-arg.cl
+++ test/CodeGenOpenCL/addr-space-struct-arg.cl
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 %s -emit-llvm -o - -O0 -finclude-default-header -ffake-address-space-map -triple i686-pc-darwin | FileCheck -enable-var-scope -check-prefixes=COM,X86 %s
-// RUN: %clang_cc1 %s -emit-llvm -o - -O0 -finclude-default-header -triple amdgcn-amdhsa-amd-amdgizcl | FileCheck -enable-var-scope -check-prefixes=COM,AMD %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -O0 -finclude-default-header -triple amdgcn-amdhsa-amd | FileCheck -enable-var-scope -check-prefixes=COM,AMDGCN %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -cl-std=CL2.0 -O0 -finclude-default-header -triple amdgcn-amdhsa-amd | FileCheck -enable-var-scope -check-prefixes=COM,AMDGCN,AMDGCN20 %s
 
 typedef struct {
   int cells[9];
@@ -35,9 +36,12 @@
   int2 y[20];
 };
 
+#if __OPENCL_C_VERSION__ >= 200
+struct LargeStructOneMember g_s;
+#endif
 
 // X86-LABEL: define void @foo(%struct.Mat4X4* noalias sret %agg.result, %struct.Mat3X3* byval align 4 %in)
-// AMD-LABEL: define %struct.Mat4X4 @foo([9 x i32] %in.coerce)
+// AMDGCN-LABEL: define %struct.Mat4X4 @foo([9 x i32] %in.coerce)
 Mat4X4 __attribute__((noinline)) foo(Mat3X3 in) {
   Mat4X4 out;
   return out;
@@ -49,15 +53,15 @@
 // X86: call void @llvm.memcpy.p0i8.p1i8.i32(i8*
 // X86: call void @llvm.memcpy.p1i8.p0i8.i32(i8 addrspace(1)*
 
-// AMD: load [9 x i32], [9 x i32] addrspace(1)*
-// AMD: call %struct.Mat4X4 @foo([9 x i32]
-// AMD: call void @llvm.memcpy.p1i8.p5i8.i64(i8 addrspace(1)*
+// AMDGCN: load [9 x i32], [9 x i32] addrspace(1)*
+// AMDGCN: call %struct.Mat4X4 @foo([9 x i32]
+// AMDGCN: call void @llvm.memcpy.p1i8.p5i8.i64(i8 addrspace(1)*
 kernel void ker(global Mat3X3 *in, global Mat4X4 *out) {
   out[0] = foo(in[1]);
 }
 
 // X86-LABEL: define void @foo_large(%struct.Mat64X64* noalias sret %agg.result, %struct.Mat32X32* byval align 4 %in)
-// AMD-LABEL: define void @foo_large(%struct.Mat64X64 addrspace(5)* noalias sret %agg.result, %struct.Mat32X32 addrspace(5)* byval align 4 %in)
+// AMDGCN-LABEL: define void @foo_large(%struct.Mat64X64 addrspace(5)* noalias sret %agg.result, %struct.Mat32X32 addrspace(5)* byval align 4 %in)
 Mat64X64 __attribute__((noinline)) foo_large(Mat32X32 in) {
   Mat64X64 out;
   return out;
@@ -68,66 +72,97 @@
 // the return value.
 // X86: call void @llvm.memcpy.p0i8.p1i8.i32(i8*
 // X86: call void @llvm.memcpy.p1i8.p0i8.i32(i8 addrspace(1)*
-// AMD: call void @llvm.memcpy.p5i8.p1i8.i64(i8 addrspace(5)*
-// AMD: call void @llvm.memcpy.p1i8.p5i8.i64(i8 addrspace(1)*
+// AMDGCN: call void @llvm.memcpy.p5i8.p1i8.i64(i8 addrspace(5)*
+// AMDGCN: call void @llvm.memcpy.p1i8.p5i8.i64(i8 addrspace(1)*
 kernel void ker_large(global Mat32X32 *in, global Mat64X64 *out) {
   out[0] = foo_large(in[1]);
 }
 
-// AMD-LABEL: define void @FuncOneMember(<2 x i32> %u.coerce)
+// AMDGCN-LABEL: define void @FuncOneMember(<2 x i32> %u.coerce)
 void FuncOneMember(struct StructOneMember u) {
   u.x = (int2)(0, 0);
 }
 
-// AMD-LABEL: define void @FuncOneLargeMember(%struct.LargeStructOneMember addrspace(5)* byval align 8 %u)
+// AMDGCN-LABEL: define void @FuncOneLargeMember(%struct.LargeStructOneMember addrspace(5)* byval align 8 %u)
+// AMDGCN-NOT: addrspacecast
+// AMDGCN:   store <2 x i32> %{{.*}}, <2 x i32> addrspace(5)*
 void FuncOneLargeMember(struct LargeStructOneMember u) {
   u.x[0] = (int2)(0, 0);
 }
 
-// AMD-LABEL: define amdgpu_kernel void @KernelOneMember
-// AMD-SAME:  (<2 x i32> %[[u_coerce:.*]])
-// AMD:  %[[u:.*]] = alloca %struct.StructOneMember, align 8, addrspace(5)
-// AMD:  %[[coerce_dive:.*]] = getelementptr inbounds %struct.StructOneMember, %struct.StructOneMember addrspace(5)* %[[u]], i32 0, i32 0
-// AMD:  store <2 x i32> %[[u_coerce]], <2 x i32> addrspace(5)* %[[coerce_dive]]
-// AMD:  call void @FuncOneMember(<2 x i32>
+// AMDGCN20-LABEL: define void @test_indirect_arg_globl()
+// AMDGCN20:  %[[byval_temp:.*]] 

[PATCH] D43513: [OpenMP] Limit reduction support for pragma 'distribute' when combined with pragma 'simd'

2018-02-22 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL325822: [OpenMP] Limit reduction support for pragma 
distribute when combined with… (authored by cbertol, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D43513?vs=135429=135491#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D43513

Files:
  cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
  cfe/trunk/test/OpenMP/distribute_parallel_for_reduction_codegen.cpp

Index: cfe/trunk/test/OpenMP/distribute_parallel_for_reduction_codegen.cpp
===
--- cfe/trunk/test/OpenMP/distribute_parallel_for_reduction_codegen.cpp
+++ cfe/trunk/test/OpenMP/distribute_parallel_for_reduction_codegen.cpp
@@ -0,0 +1,84 @@
+// Test host code gen
+
+// RUN: %clang_cc1  -verify -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1  -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1  -fopenmp -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1  -verify -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32
+// RUN: %clang_cc1  -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1  -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32
+
+// RUN: %clang_cc1  -verify -fopenmp-simd -fopenmp-version=45 -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY1 %s
+// RUN: %clang_cc1  -fopenmp-simd -fopenmp-version=45 -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1  -fopenmp-simd -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY1 %s
+// RUN: %clang_cc1  -verify -fopenmp-simd -fopenmp-version=45 -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY1 %s
+// RUN: %clang_cc1  -fopenmp-simd -fopenmp-version=45 -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1  -fopenmp-simd -fopenmp-version=45 -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY1 %s
+// SIMD-ONLY1-NOT: {{__kmpc|__tgt}}
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+
+template 
+T tmain(T ) {
+  int n = 1000;  
+  // schedule: dynamic chunk
+  #pragma omp target map(tofrom:r)
+  #pragma omp teams
+  #pragma omp distribute parallel for reduction(+:r)
+  for (int i = 0; i < n; ++i)
+r += (T)i;  
+
+  return r;
+}
+
+int main() {
+  int n = 1000;
+  int r = 0;
+  #pragma omp target map(tofrom:r)
+  #pragma omp teams
+  #pragma omp distribute parallel for reduction(+:r)
+  for (int i = 0; i < n; ++i)
+r += i;
+
+  return tmain(r);
+}
+
+// CHECK-LABEL: main
+// CHECK: call{{.+}} @__tgt_target_teams(
+// CHECK: call void [[OFFL:@.+]](
+// CHECK: call{{.+}} [[TMAIN:@.+]](i{{32|64}}
+// CHECK: ret
+
+// CHECK: define{{.+}} [[OFFL]](
+// CHECK: call{{.+}} @__kmpc_fork_teams({{.+}}, {{.+}}, {{.+}} [[TEOUTL:@.+]] to{{.+}}
+// CHECK: ret void
+
+// CHECK: define{{.+}} [[TEOUTL]](
+// CHECK: call{{.+}} @__kmpc_fork_call({{.+}}, {{.+}}, {{.+}} [[PAROUTL:@.+]] to{{.+}}
+// CHECK: ret void
+
+// CHECK: define{{.+}} [[PAROUTL]](
+// CHECK: call{{.+}} @__kmpc_reduce_nowait(
+// CHECK: call{{.+}} @__kmpc_end_reduce_nowait(
+// CHECK: ret void
+
+// CHECK: define{{.+}} [[TMAIN]](i{{32|64}}
+// CHECK: call{{.+}} @__tgt_target_teams(
+// CHECK: call void [[TOFFL:@.+]](
+// CHECK: ret
+
+// CHECK: define{{.+}} [[TOFFL]](
+// CHECK: call{{.+}} @__kmpc_fork_teams({{.+}}, {{.+}}, {{.+}} [[TEMPLTEOUTL:@.+]] to{{.+}}
+// CHECK: ret void
+
+// CHECK: define{{.+}} [[TEMPLTEOUTL]](
+// CHECK: call{{.+}} @__kmpc_fork_call({{.+}}, {{.+}}, {{.+}} [[TPAROUTL:@.+]] to{{.+}}
+// CHECK: ret void
+
+// CHECK: define{{.+}} 

[PATCH] D43581: [clang-tidy/google] Fix the Objective-C global variable declaration check 

2018-02-22 Thread Yan Zhang via Phabricator via cfe-commits
Wizard accepted this revision.
Wizard added a comment.
This revision is now accepted and ready to land.

In https://reviews.llvm.org/D43581#1016318, @stephanemoore wrote:

> In https://reviews.llvm.org/D43581#1016300, @Wizard wrote:
>
> > Please update the warning info to indicate that prefix 'k' is not the only 
> > option for constants. Something like:
> >  "const global variable '%0' must have an appropriate prefix or a name 
> > which starts with 'k[A-Z]'"
>
>
> Is the latest warning info satisfactory? I believe I updated it after adding 
> you as a reviewer.


Hmm I feel it is a bit unfriendly to show users a rather complicated regex in 
the info, but I will leave it to you. Not a big problem.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43581



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


[PATCH] D43581: [clang-tidy/google] Fix the Objective-C global variable declaration check 

2018-02-22 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/google/GlobalVariableDeclarationCheck.cpp:92
+ "an appropriate prefix (see "
+ "http://google.github.io/styleguide/objcguide#constants).")
 << Decl->getName() << generateFixItHint(Decl, true);

We don't usually put hyperlinks in the diagnostic messages, so please remove 
this.

My suggestion about describing what constitutes an appropriate prefix was with 
regards to the style guide wording itself. For instance, that document doesn't 
mention that two capital letters is good. That's not on you to fix before this 
patch goes in, of course.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43581



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


[PATCH] D43581: [clang-tidy/google] Fix the Objective-C global variable declaration check 

2018-02-22 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore added a comment.

In https://reviews.llvm.org/D43581#1016327, @Wizard wrote:

> In https://reviews.llvm.org/D43581#1016318, @stephanemoore wrote:
>
> > In https://reviews.llvm.org/D43581#1016300, @Wizard wrote:
> >
> > > Please update the warning info to indicate that prefix 'k' is not the 
> > > only option for constants. Something like:
> > >  "const global variable '%0' must have an appropriate prefix or a name 
> > > which starts with 'k[A-Z]'"
> >
> >
> > Is the latest warning info satisfactory? I believe I updated it after 
> > adding you as a reviewer.
>
>
> Hmm I feel it is a bit unfriendly to show users a rather complicated regex in 
> the info, but I will leave it to you. Not a big problem.


At a glance this seems unconventional but could we have the warning link to the 
Google Objective-C style guide for guidance on an appropriate prefix? Is that 
allowed for diagnostic messages? I can revert if that is considered 
inappropriate.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43581



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


[PATCH] D43576: Solution to fix PR27066 - Redefinition with same mangled name as another definition (dllexport and uuid)

2018-02-22 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam updated this revision to Diff 135502.

https://reviews.llvm.org/D43576

Files:
  test/CodeGenCXX/instantiate-uuid.cpp
  test/Sema/member-reference-dll.cpp


Index: test/Sema/member-reference-dll.cpp
===
--- test/Sema/member-reference-dll.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-windows-msvc -fsyntax-only -verify 
-fms-extensions -fms-compatibility %s
-// expected-no-diagnostics
-
-namespace test1 {
-class __declspec(dllimport) Edge;
-
-template 
-class __declspec(dllimport) Range {
-  void insert(T *obj) { obj->loc(); }
-};
-
-template void Range::insert(Edge *);
-} // namespace test1
-
-namespace test2 {
-class __declspec(dllexport) Edge;
-
-template 
-class __declspec(dllimport) Range {
-  void insert(T *obj) { obj->loc(); }
-};
-
-template void Range::insert(Edge *);
-} // namespace test2
Index: test/CodeGenCXX/instantiate-uuid.cpp
===
--- /dev/null
+++ test/CodeGenCXX/instantiate-uuid.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -std=c++14 -fms-extensions 
-fms-compatibility -emit-llvm -o - %s | Filecheck %s
+
+// expected-no-diagnostics
+
+// M32-DAG: 
$"\01??4?$A@$E?_GUID_ddb47a6a_0f23_11d5_9109_00e0296b75d3@@3U__s_GUID@@B@@QEAAAEAV0@AEBV0@@Z"
 = comdat any
+
+typedef struct _GUID {
+  int i;
+} IID;
+template 
+class A {};
+
+struct
+__declspec(uuid("{DDB47A6A-0F23-11D5-9109-00E0296B75D3}"))
+S1 {};
+
+struct
+__declspec(uuid("{DDB47A6A-0F23-11D5-9109-00E0296B75D3}"))
+S2 {};
+
+struct __declspec(dllexport)
+C1 : public A<&__uuidof(S1)> {};
+
+struct __declspec(dllexport)
+C2 : public A<&__uuidof(S2)> {};
+
+// CHECK-LABEL: define weak_odr dllexport dereferenceable(1) %class.A* 
@"\01??4?$A@$E?_GUID_ddb47a6a_0f23_11d5_9109_00e0296b75d3@@3U__s_GUID@@B@@QEAAAEAV0@AEBV0@@Z"
+
+


Index: test/Sema/member-reference-dll.cpp
===
--- test/Sema/member-reference-dll.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-windows-msvc -fsyntax-only -verify -fms-extensions -fms-compatibility %s
-// expected-no-diagnostics
-
-namespace test1 {
-class __declspec(dllimport) Edge;
-
-template 
-class __declspec(dllimport) Range {
-  void insert(T *obj) { obj->loc(); }
-};
-
-template void Range::insert(Edge *);
-} // namespace test1
-
-namespace test2 {
-class __declspec(dllexport) Edge;
-
-template 
-class __declspec(dllimport) Range {
-  void insert(T *obj) { obj->loc(); }
-};
-
-template void Range::insert(Edge *);
-} // namespace test2
Index: test/CodeGenCXX/instantiate-uuid.cpp
===
--- /dev/null
+++ test/CodeGenCXX/instantiate-uuid.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -std=c++14 -fms-extensions -fms-compatibility -emit-llvm -o - %s | Filecheck %s
+
+// expected-no-diagnostics
+
+// M32-DAG: $"\01??4?$A@$E?_GUID_ddb47a6a_0f23_11d5_9109_00e0296b75d3@@3U__s_GUID@@B@@QEAAAEAV0@AEBV0@@Z" = comdat any
+
+typedef struct _GUID {
+  int i;
+} IID;
+template 
+class A {};
+
+struct
+__declspec(uuid("{DDB47A6A-0F23-11D5-9109-00E0296B75D3}"))
+S1 {};
+
+struct
+__declspec(uuid("{DDB47A6A-0F23-11D5-9109-00E0296B75D3}"))
+S2 {};
+
+struct __declspec(dllexport)
+C1 : public A<&__uuidof(S1)> {};
+
+struct __declspec(dllexport)
+C2 : public A<&__uuidof(S2)> {};
+
+// CHECK-LABEL: define weak_odr dllexport dereferenceable(1) %class.A* @"\01??4?$A@$E?_GUID_ddb47a6a_0f23_11d5_9109_00e0296b75d3@@3U__s_GUID@@B@@QEAAAEAV0@AEBV0@@Z"
+
+
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43576: Solution to fix PR27066 - Redefinition with same mangled name as another definition (dllexport and uuid)

2018-02-22 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam added a comment.

Adding test case.


https://reviews.llvm.org/D43576



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


[PATCH] D43640: add support for constants with appropriate prefix. Start with 'k' is not the only option. This is according to http://google.github.io/styleguide/objcguide.html#constants

2018-02-22 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore added a comment.

I have this change out for review as well:
https://reviews.llvm.org/D43581


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43640



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


[PATCH] D43581: [clang-tidy/google] Fix the Objective-C global variable declaration check 

2018-02-22 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore updated this revision to Diff 135489.
stephanemoore added a comment.

I forgot to update the diagnostic message per the change.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43581

Files:
  clang-tidy/google/GlobalVariableDeclarationCheck.cpp
  test/clang-tidy/google-objc-global-variable-declaration.m


Index: test/clang-tidy/google-objc-global-variable-declaration.m
===
--- test/clang-tidy/google-objc-global-variable-declaration.m
+++ test/clang-tidy/google-objc-global-variable-declaration.m
@@ -30,8 +30,16 @@
 // CHECK-FIXES: static NSString* const k_Alpha = @"SecondNotAlpha";
 
 static NSString* const kGood = @"hello";
+static NSString* const XYGood = @"hello";
 static NSString* gMyIntGood = 0;
 
+extern NSString* const GTLServiceErrorDomain;
+
+typedef NS_ENUM(NSInteger, GTLServiceError) {
+  GTLServiceErrorQueryResultMissing = -3000,
+  GTLServiceErrorWaitTimedOut   = -3001,
+};
+
 @implementation Foo
 - (void)f {
 int x = 0;
Index: clang-tidy/google/GlobalVariableDeclarationCheck.cpp
===
--- clang-tidy/google/GlobalVariableDeclarationCheck.cpp
+++ clang-tidy/google/GlobalVariableDeclarationCheck.cpp
@@ -72,7 +72,7 @@
   this);
   Finder->addMatcher(varDecl(hasGlobalStorage(), hasType(isConstQualified()),
  unless(isLocalVariable()),
- unless(matchesName("::k[A-Z]")))
+ unless(matchesName("::(k[A-Z]|[A-Z]{2,})")))
  .bind("global_const"),
  this);
 }
@@ -88,7 +88,7 @@
   if (const auto *Decl = Result.Nodes.getNodeAs("global_const")) {
 diag(Decl->getLocation(),
  "const global variable '%0' must have a name which starts with "
- "'k[A-Z]'")
+ "an appropriate prefix matching '(k[A-Z]|[A-Z]{2,})'.")
 << Decl->getName() << generateFixItHint(Decl, true);
   }
 }


Index: test/clang-tidy/google-objc-global-variable-declaration.m
===
--- test/clang-tidy/google-objc-global-variable-declaration.m
+++ test/clang-tidy/google-objc-global-variable-declaration.m
@@ -30,8 +30,16 @@
 // CHECK-FIXES: static NSString* const k_Alpha = @"SecondNotAlpha";
 
 static NSString* const kGood = @"hello";
+static NSString* const XYGood = @"hello";
 static NSString* gMyIntGood = 0;
 
+extern NSString* const GTLServiceErrorDomain;
+
+typedef NS_ENUM(NSInteger, GTLServiceError) {
+  GTLServiceErrorQueryResultMissing = -3000,
+  GTLServiceErrorWaitTimedOut   = -3001,
+};
+
 @implementation Foo
 - (void)f {
 int x = 0;
Index: clang-tidy/google/GlobalVariableDeclarationCheck.cpp
===
--- clang-tidy/google/GlobalVariableDeclarationCheck.cpp
+++ clang-tidy/google/GlobalVariableDeclarationCheck.cpp
@@ -72,7 +72,7 @@
   this);
   Finder->addMatcher(varDecl(hasGlobalStorage(), hasType(isConstQualified()),
  unless(isLocalVariable()),
- unless(matchesName("::k[A-Z]")))
+ unless(matchesName("::(k[A-Z]|[A-Z]{2,})")))
  .bind("global_const"),
  this);
 }
@@ -88,7 +88,7 @@
   if (const auto *Decl = Result.Nodes.getNodeAs("global_const")) {
 diag(Decl->getLocation(),
  "const global variable '%0' must have a name which starts with "
- "'k[A-Z]'")
+ "an appropriate prefix matching '(k[A-Z]|[A-Z]{2,})'.")
 << Decl->getName() << generateFixItHint(Decl, true);
   }
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43640: add support for constants with appropriate prefix. Start with 'k' is not the only option. This is according to http://google.github.io/styleguide/objcguide.html#constants

2018-02-22 Thread Yan Zhang via Phabricator via cfe-commits
Wizard added a comment.

In https://reviews.llvm.org/D43640#1016287, @stephanemoore wrote:

> I have this change out for review as well:
>  https://reviews.llvm.org/D43581


Ah cool. Your change looks good. Technically the same as mine. I will discard 
this diff.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43640



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


[PATCH] D43576: Solution to fix PR27066 - Redefinition with same mangled name as another definition (dllexport and uuid)

2018-02-22 Thread David Majnemer via Phabricator via cfe-commits
majnemer added a comment.

We should really, really avoid making this sort of change without first trying 
to desugar uuidof into a reference to a variable. That would solve a ton of 
problems, problems like this one.


https://reviews.llvm.org/D43576



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


[PATCH] D43581: [clang-tidy/google] Fix the Objective-C global variable declaration check 

2018-02-22 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore updated this revision to Diff 135497.
stephanemoore added a comment.

Update the diagnostic information to link to the Google Objective-C style guide 
for guidance on an appropriate prefix.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43581

Files:
  clang-tidy/google/GlobalVariableDeclarationCheck.cpp
  test/clang-tidy/google-objc-global-variable-declaration.m


Index: test/clang-tidy/google-objc-global-variable-declaration.m
===
--- test/clang-tidy/google-objc-global-variable-declaration.m
+++ test/clang-tidy/google-objc-global-variable-declaration.m
@@ -30,8 +30,16 @@
 // CHECK-FIXES: static NSString* const k_Alpha = @"SecondNotAlpha";
 
 static NSString* const kGood = @"hello";
+static NSString* const XYGood = @"hello";
 static NSString* gMyIntGood = 0;
 
+extern NSString* const GTLServiceErrorDomain;
+
+typedef NS_ENUM(NSInteger, GTLServiceError) {
+  GTLServiceErrorQueryResultMissing = -3000,
+  GTLServiceErrorWaitTimedOut   = -3001,
+};
+
 @implementation Foo
 - (void)f {
 int x = 0;
Index: clang-tidy/google/GlobalVariableDeclarationCheck.cpp
===
--- clang-tidy/google/GlobalVariableDeclarationCheck.cpp
+++ clang-tidy/google/GlobalVariableDeclarationCheck.cpp
@@ -72,7 +72,7 @@
   this);
   Finder->addMatcher(varDecl(hasGlobalStorage(), hasType(isConstQualified()),
  unless(isLocalVariable()),
- unless(matchesName("::k[A-Z]")))
+ unless(matchesName("::(k[A-Z]|[A-Z]{2,})")))
  .bind("global_const"),
  this);
 }
@@ -88,7 +88,8 @@
   if (const auto *Decl = Result.Nodes.getNodeAs("global_const")) {
 diag(Decl->getLocation(),
  "const global variable '%0' must have a name which starts with "
- "'k[A-Z]'")
+ "an appropriate prefix (see "
+ "http://google.github.io/styleguide/objcguide#constants).")
 << Decl->getName() << generateFixItHint(Decl, true);
   }
 }


Index: test/clang-tidy/google-objc-global-variable-declaration.m
===
--- test/clang-tidy/google-objc-global-variable-declaration.m
+++ test/clang-tidy/google-objc-global-variable-declaration.m
@@ -30,8 +30,16 @@
 // CHECK-FIXES: static NSString* const k_Alpha = @"SecondNotAlpha";
 
 static NSString* const kGood = @"hello";
+static NSString* const XYGood = @"hello";
 static NSString* gMyIntGood = 0;
 
+extern NSString* const GTLServiceErrorDomain;
+
+typedef NS_ENUM(NSInteger, GTLServiceError) {
+  GTLServiceErrorQueryResultMissing = -3000,
+  GTLServiceErrorWaitTimedOut   = -3001,
+};
+
 @implementation Foo
 - (void)f {
 int x = 0;
Index: clang-tidy/google/GlobalVariableDeclarationCheck.cpp
===
--- clang-tidy/google/GlobalVariableDeclarationCheck.cpp
+++ clang-tidy/google/GlobalVariableDeclarationCheck.cpp
@@ -72,7 +72,7 @@
   this);
   Finder->addMatcher(varDecl(hasGlobalStorage(), hasType(isConstQualified()),
  unless(isLocalVariable()),
- unless(matchesName("::k[A-Z]")))
+ unless(matchesName("::(k[A-Z]|[A-Z]{2,})")))
  .bind("global_const"),
  this);
 }
@@ -88,7 +88,8 @@
   if (const auto *Decl = Result.Nodes.getNodeAs("global_const")) {
 diag(Decl->getLocation(),
  "const global variable '%0' must have a name which starts with "
- "'k[A-Z]'")
+ "an appropriate prefix (see "
+ "http://google.github.io/styleguide/objcguide#constants).")
 << Decl->getName() << generateFixItHint(Decl, true);
   }
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43581: [clang-tidy/google] Fix the Objective-C global variable declaration check 

2018-02-22 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore updated this revision to Diff 135510.
stephanemoore added a comment.

Revert the inclusion of the link to the Google Objective-C style guide in the 
diagnostic message.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43581

Files:
  clang-tidy/google/GlobalVariableDeclarationCheck.cpp
  test/clang-tidy/google-objc-global-variable-declaration.m


Index: test/clang-tidy/google-objc-global-variable-declaration.m
===
--- test/clang-tidy/google-objc-global-variable-declaration.m
+++ test/clang-tidy/google-objc-global-variable-declaration.m
@@ -30,8 +30,16 @@
 // CHECK-FIXES: static NSString* const k_Alpha = @"SecondNotAlpha";
 
 static NSString* const kGood = @"hello";
+static NSString* const XYGood = @"hello";
 static NSString* gMyIntGood = 0;
 
+extern NSString* const GTLServiceErrorDomain;
+
+typedef NS_ENUM(NSInteger, GTLServiceError) {
+  GTLServiceErrorQueryResultMissing = -3000,
+  GTLServiceErrorWaitTimedOut   = -3001,
+};
+
 @implementation Foo
 - (void)f {
 int x = 0;
Index: clang-tidy/google/GlobalVariableDeclarationCheck.cpp
===
--- clang-tidy/google/GlobalVariableDeclarationCheck.cpp
+++ clang-tidy/google/GlobalVariableDeclarationCheck.cpp
@@ -72,7 +72,7 @@
   this);
   Finder->addMatcher(varDecl(hasGlobalStorage(), hasType(isConstQualified()),
  unless(isLocalVariable()),
- unless(matchesName("::k[A-Z]")))
+ unless(matchesName("::(k[A-Z]|[A-Z]{2,})")))
  .bind("global_const"),
  this);
 }
@@ -88,7 +88,7 @@
   if (const auto *Decl = Result.Nodes.getNodeAs("global_const")) {
 diag(Decl->getLocation(),
  "const global variable '%0' must have a name which starts with "
- "'k[A-Z]'")
+ "an appropriate prefix matching '(k[A-Z]|[A-Z]{2,})'.")
 << Decl->getName() << generateFixItHint(Decl, true);
   }
 }


Index: test/clang-tidy/google-objc-global-variable-declaration.m
===
--- test/clang-tidy/google-objc-global-variable-declaration.m
+++ test/clang-tidy/google-objc-global-variable-declaration.m
@@ -30,8 +30,16 @@
 // CHECK-FIXES: static NSString* const k_Alpha = @"SecondNotAlpha";
 
 static NSString* const kGood = @"hello";
+static NSString* const XYGood = @"hello";
 static NSString* gMyIntGood = 0;
 
+extern NSString* const GTLServiceErrorDomain;
+
+typedef NS_ENUM(NSInteger, GTLServiceError) {
+  GTLServiceErrorQueryResultMissing = -3000,
+  GTLServiceErrorWaitTimedOut   = -3001,
+};
+
 @implementation Foo
 - (void)f {
 int x = 0;
Index: clang-tidy/google/GlobalVariableDeclarationCheck.cpp
===
--- clang-tidy/google/GlobalVariableDeclarationCheck.cpp
+++ clang-tidy/google/GlobalVariableDeclarationCheck.cpp
@@ -72,7 +72,7 @@
   this);
   Finder->addMatcher(varDecl(hasGlobalStorage(), hasType(isConstQualified()),
  unless(isLocalVariable()),
- unless(matchesName("::k[A-Z]")))
+ unless(matchesName("::(k[A-Z]|[A-Z]{2,})")))
  .bind("global_const"),
  this);
 }
@@ -88,7 +88,7 @@
   if (const auto *Decl = Result.Nodes.getNodeAs("global_const")) {
 diag(Decl->getLocation(),
  "const global variable '%0' must have a name which starts with "
- "'k[A-Z]'")
+ "an appropriate prefix matching '(k[A-Z]|[A-Z]{2,})'.")
 << Decl->getName() << generateFixItHint(Decl, true);
   }
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43640: add support for constants with appropriate prefix. Start with 'k' is not the only option. This is according to http://google.github.io/styleguide/objcguide.html#constants

2018-02-22 Thread Yan Zhang via Phabricator via cfe-commits
Wizard updated this revision to Diff 135485.
Wizard added a comment.

fix format


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43640

Files:
  clang-tidy/google/GlobalVariableDeclarationCheck.cpp
  test/clang-tidy/google-objc-global-variable-declaration.m


Index: test/clang-tidy/google-objc-global-variable-declaration.m
===
--- test/clang-tidy/google-objc-global-variable-declaration.m
+++ test/clang-tidy/google-objc-global-variable-declaration.m
@@ -2,7 +2,7 @@
 
 @class NSString;
 static NSString* const myConstString = @"hello";
-// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 
'myConstString' must have a name which starts with 'k[A-Z]' 
[google-objc-global-variable-declaration]
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 
'myConstString' must have an appropriate prefix or a name which starts with 
'k[A-Z]' [google-objc-global-variable-declaration]
 // CHECK-FIXES: static NSString* const kMyConstString = @"hello";
 
 static NSString* MyString = @"hi";
@@ -22,14 +22,15 @@
 // CHECK-FIXES: static NSString* gNoDef;
 
 static NSString* const _notAlpha = @"NotBeginWithAlpha";
-// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable '_notAlpha' 
must have a name which starts with 'k[A-Z]' 
[google-objc-global-variable-declaration]
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable '_notAlpha' 
must have an appropriate prefix or a name which starts with 'k[A-Z]' 
[google-objc-global-variable-declaration]
 // CHECK-FIXES: static NSString* const _notAlpha = @"NotBeginWithAlpha";
 
 static NSString* const k_Alpha = @"SecondNotAlpha";
-// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 'k_Alpha' 
must have a name which starts with 'k[A-Z]' 
[google-objc-global-variable-declaration]
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 'k_Alpha' 
must have an appropriate prefix or a name which starts with 'k[A-Z]' 
[google-objc-global-variable-declaration]
 // CHECK-FIXES: static NSString* const k_Alpha = @"SecondNotAlpha";
 
 static NSString* const kGood = @"hello";
+static NSString* const ABCGood = @"I have a prefix";
 static NSString* gMyIntGood = 0;
 
 @implementation Foo
Index: clang-tidy/google/GlobalVariableDeclarationCheck.cpp
===
--- clang-tidy/google/GlobalVariableDeclarationCheck.cpp
+++ clang-tidy/google/GlobalVariableDeclarationCheck.cpp
@@ -24,15 +24,15 @@
 
 namespace {
 
-AST_MATCHER(VarDecl, isLocalVariable) {
-  return Node.isLocalVarDecl();
+AST_MATCHER(VarDecl, isLocalVariable) { 
+  return Node.isLocalVarDecl(); 
 }
 
 FixItHint generateFixItHint(const VarDecl *Decl, bool IsConst) {
   char FC = Decl->getName()[0];
   if (!llvm::isAlpha(FC) || Decl->getName().size() == 1) {
 // No fix available if first character is not alphabetical character, or it
-// is a single-character variable, since it is difficult to determine the 
+// is a single-character variable, since it is difficult to determine the
 // proper fix in this case. Users should create a proper variable name by
 // their own.
 return FixItHint();
@@ -72,7 +72,7 @@
   this);
   Finder->addMatcher(varDecl(hasGlobalStorage(), hasType(isConstQualified()),
  unless(isLocalVariable()),
- unless(matchesName("::k[A-Z]")))
+ unless(matchesName("::(k|[A-Z]{2,})[A-Z]")))
  .bind("global_const"),
  this);
 }
@@ -87,8 +87,8 @@
   }
   if (const auto *Decl = Result.Nodes.getNodeAs("global_const")) {
 diag(Decl->getLocation(),
- "const global variable '%0' must have a name which starts with "
- "'k[A-Z]'")
+ "const global variable '%0' must have an appropriate prefix or a name 
"
+ "which starts with 'k[A-Z]'")
 << Decl->getName() << generateFixItHint(Decl, true);
   }
 }


Index: test/clang-tidy/google-objc-global-variable-declaration.m
===
--- test/clang-tidy/google-objc-global-variable-declaration.m
+++ test/clang-tidy/google-objc-global-variable-declaration.m
@@ -2,7 +2,7 @@
 
 @class NSString;
 static NSString* const myConstString = @"hello";
-// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 'myConstString' must have a name which starts with 'k[A-Z]' [google-objc-global-variable-declaration]
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 'myConstString' must have an appropriate prefix or a name which starts with 'k[A-Z]' [google-objc-global-variable-declaration]
 // CHECK-FIXES: static NSString* const kMyConstString = @"hello";
 
 static NSString* MyString = @"hi";
@@ -22,14 +22,15 @@
 // CHECK-FIXES: static NSString* gNoDef;
 
 static NSString* const _notAlpha = @"NotBeginWithAlpha";
-// 

[PATCH] D43581: [clang-tidy/google] Fix the Objective-C global variable declaration check 

2018-02-22 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore added a comment.

In https://reviews.llvm.org/D43581#1016300, @Wizard wrote:

> Please update the warning info to indicate that prefix 'k' is not the only 
> option for constants. Something like:
>  "const global variable '%0' must have an appropriate prefix or a name which 
> starts with 'k[A-Z]'"


Is the latest warning info satisfactory? I believe I updated it after adding 
you as a reviewer.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43581



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


[PATCH] D43602: [CUDA] Added missing functions.

2018-02-22 Thread Artem Belevich via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC325814: [CUDA] Added missing functions. (authored by tra, 
committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D43602?vs=135348=135466#toc

Repository:
  rC Clang

https://reviews.llvm.org/D43602

Files:
  lib/Headers/__clang_cuda_device_functions.h


Index: lib/Headers/__clang_cuda_device_functions.h
===
--- lib/Headers/__clang_cuda_device_functions.h
+++ lib/Headers/__clang_cuda_device_functions.h
@@ -687,6 +687,10 @@
 __DEVICE__ float __ull2float_rz(unsigned long long __a) {
   return __nv_ull2float_rz(__a);
 }
+__DEVICE__ unsigned long long __ullAtomicAdd(unsigned long long *__p,
+ unsigned long long __v) {
+  return __nvvm_atom_add_gen_ll((long long *)__p, __v);
+}
 __DEVICE__ unsigned long long __ullAtomicAdd_block(unsigned long long *__p,
unsigned long long __v) {
   return __nvvm_atom_cta_add_gen_ll((long long *)__p, __v);
@@ -707,6 +711,11 @@
 unsigned long long __v) {
   return __nvvm_atom_sys_and_gen_ll((long long *)__p, __v);
 }
+__DEVICE__ unsigned long long __ullAtomicCAS(unsigned long long *__p,
+ unsigned long long __cmp,
+ unsigned long long __v) {
+  return __nvvm_atom_cas_gen_ll((long long *)__p, __cmp, __v);
+}
 __DEVICE__ unsigned long long __ullAtomicCAS_block(unsigned long long *__p,
unsigned long long __cmp,
unsigned long long __v) {
@@ -717,6 +726,10 @@
 unsigned long long __v) {
   return __nvvm_atom_sys_cas_gen_ll((long long *)__p, __cmp, __v);
 }
+__DEVICE__ unsigned long long __ullAtomicExch(unsigned long long *__p,
+  unsigned long long __v) {
+  return __nvvm_atom_xchg_gen_ll((long long *)__p, __v);
+}
 __DEVICE__ unsigned long long __ullAtomicExch_block(unsigned long long *__p,
 unsigned long long __v) {
   return __nvvm_atom_cta_xchg_gen_ll((long long *)__p, __v);
@@ -1123,10 +1136,16 @@
 __DEVICE__ float j1f(float __a) { return __nv_j1f(__a); }
 __DEVICE__ double jn(int __n, double __a) { return __nv_jn(__n, __a); }
 __DEVICE__ float jnf(int __n, float __a) { return __nv_jnf(__n, __a); }
+#if defined(__LP64__)
+__DEVICE__ long labs(long __a) { return llabs(__a); };
+#else
+__DEVICE__ long labs(long __a) { return __nv_abs(__a); };
+#endif
 __DEVICE__ double ldexp(double __a, int __b) { return __nv_ldexp(__a, __b); }
 __DEVICE__ float ldexpf(float __a, int __b) { return __nv_ldexpf(__a, __b); }
 __DEVICE__ double lgamma(double __a) { return __nv_lgamma(__a); }
 __DEVICE__ float lgammaf(float __a) { return __nv_lgammaf(__a); }
+__DEVICE__ long long llabs(long long __a) { return __nv_llabs(__a); }
 __DEVICE__ long long llmax(long long __a, long long __b) {
   return __nv_llmax(__a, __b);
 }
@@ -1267,6 +1286,9 @@
   return scalbnf(__a, (int)__b);
 }
 __DEVICE__ double sin(double __a) { return __nv_sin(__a); }
+__DEVICE__ void sincos(double __a, double *__sptr, double *__cptr) {
+  return __nv_sincos(__a, __sptr, __cptr);
+}
 __DEVICE__ void sincosf(float __a, float *__sptr, float *__cptr) {
   return __FAST_OR_SLOW(__nv_fast_sincosf, __nv_sincosf)(__a, __sptr, __cptr);
 }


Index: lib/Headers/__clang_cuda_device_functions.h
===
--- lib/Headers/__clang_cuda_device_functions.h
+++ lib/Headers/__clang_cuda_device_functions.h
@@ -687,6 +687,10 @@
 __DEVICE__ float __ull2float_rz(unsigned long long __a) {
   return __nv_ull2float_rz(__a);
 }
+__DEVICE__ unsigned long long __ullAtomicAdd(unsigned long long *__p,
+ unsigned long long __v) {
+  return __nvvm_atom_add_gen_ll((long long *)__p, __v);
+}
 __DEVICE__ unsigned long long __ullAtomicAdd_block(unsigned long long *__p,
unsigned long long __v) {
   return __nvvm_atom_cta_add_gen_ll((long long *)__p, __v);
@@ -707,6 +711,11 @@
 unsigned long long __v) {
   return __nvvm_atom_sys_and_gen_ll((long long *)__p, __v);
 }
+__DEVICE__ unsigned long long __ullAtomicCAS(unsigned long long *__p,
+ unsigned long long __cmp,
+ unsigned long long __v) {
+  return __nvvm_atom_cas_gen_ll((long long *)__p, __cmp, __v);
+}
 __DEVICE__ unsigned long long __ullAtomicCAS_block(unsigned long long *__p,
unsigned long long __cmp,
 

[PATCH] D43533: [CFG] [analyzer] NFC: Refactor ConstructionContext into a finite set of cases.

2018-02-22 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: include/clang/Analysis/ConstructionContext.h:119
+  static const ConstructionContext *
+  finalize(BumpVectorContext , const ConstructionContextLayer *TopLayer);
+

a.sidorin wrote:
> Maybe just `build()`? For me, `finalize()` strongly associates with Java's 
> broken clean-up mechanism.
Renamed into `createFromLayers()`.



Comment at: lib/Analysis/CFG.cpp:4737
+}
+case ConstructionContext::SimpleVariableKind: {
+  const auto *DSCC = cast(CC);

dcoughlin wrote:
> Eventually (not now) I think it would be great to include the construction 
> context kind in the printed CFG. This would make it easier to understand at a 
> glance the context.
Yeah, the only reason i don't do verbose printing is because changes in tests 
are massive.



Comment at: lib/Analysis/ConstructionContext.cpp:49
+  // patterns.
+  if (const Stmt *S = TopLayer->getTriggerStmt()) {
+if (const auto *DS = dyn_cast(S)) {

dcoughlin wrote:
> I like how this puts all the messy pattern matching in one place. The follows 
> the general LLVM guidelines of "if it has to be messy, put it all in one 
> place and hide the messiness from everything else".
Actually two places, the other one being `findConstructionContext()`.


https://reviews.llvm.org/D43533



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


[PATCH] D43105: [RISCV] Enable __int128_t and __uint128_t through clang flag

2018-02-22 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang updated this revision to Diff 135493.
mgrang retitled this revision from "[RISCV] Enable __int128_t and uint128_t 
through clang flag" to "[RISCV] Enable __int128_t and __uint128_t through clang 
flag".
mgrang edited the summary of this revision.

Repository:
  rC Clang

https://reviews.llvm.org/D43105

Files:
  include/clang/Basic/TargetInfo.h
  include/clang/Basic/TargetOptions.h
  include/clang/Driver/Options.td
  lib/Basic/Targets/Mips.h
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/riscv32-abi.c
  test/Driver/types.c
  test/Preprocessor/init.c

Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -10210,6 +10210,11 @@
 // RISCV32-LINUX: #define linux 1
 // RISCV32-LINUX: #define unix 1
 
+// RUN: %clang_cc1 -E -dM -ffreestanding \
+// RUN: -triple=riscv32 -fforce-enable-int128 < /dev/null \
+// RUN:   | FileCheck -match-full-lines -check-prefix=RISCV32-INT128 %s
+// RISCV32-INT128: #define __SIZEOF_INT128__ 16
+
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=riscv64 < /dev/null \
 // RUN:   | FileCheck -match-full-lines -check-prefix=RISCV64 %s
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=riscv64-unknown-linux < /dev/null \
Index: test/Driver/types.c
===
--- /dev/null
+++ test/Driver/types.c
@@ -0,0 +1,18 @@
+// Check whether __int128_t and __uint128_t are supported.
+
+// RUN: not %clang -c --target=riscv32-unknown-linux-gnu -fsyntax-only %s \
+// RUN: 2>&1 | FileCheck %s
+
+// RUN: %clang -c --target=riscv32-unknown-linux-gnu -fsyntax-only %s \
+// RUN: -fno-force-enable-int128 -fforce-enable-int128
+
+// RUN: not %clang -c --target=riscv32-unknown-linux-gnu -fsyntax-only %s \
+// RUN: -fforce-enable-int128 -fno-force-enable-int128
+
+void a() {
+  __int128_t s;
+  __uint128_t t;
+}
+
+// CHECK: error: use of undeclared identifier '__int128_t'
+// CHECK: error: use of undeclared identifier '__uint128_t'
Index: test/CodeGen/riscv32-abi.c
===
--- test/CodeGen/riscv32-abi.c
+++ test/CodeGen/riscv32-abi.c
@@ -421,3 +421,10 @@
 
   return ret;
 }
+
+// RUN: %clang_cc1 -triple riscv32 -fforce-enable-int128 \
+// RUN: -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK-FORCEINT128-LABEL
+#ifdef __SIZEOF_INT128__
+// CHECK-FORCEINT128-LABEL: define i128 @f_scalar_5(i128 %x)
+__int128_t f_scalar_5(__int128_t x) { return x; }
+#endif
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -2765,6 +2765,7 @@
   if (Opts.Triple.empty())
 Opts.Triple = llvm::sys::getDefaultTargetTriple();
   Opts.OpenCLExtensionsAsWritten = Args.getAllArgValues(OPT_cl_ext_EQ);
+  Opts.ForceEnableInt128 = Args.hasArg(OPT_fforce_enable_int128);
 }
 
 bool CompilerInvocation::CreateFromArgs(CompilerInvocation ,
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -4725,6 +4725,12 @@
 }
   }
 
+  if (Arg *A = Args.getLastArg(options::OPT_fforce_enable_int128,
+   options::OPT_fno_force_enable_int128)) {
+if (A->getOption().matches(options::OPT_fforce_enable_int128))
+  CmdArgs.push_back("-fforce-enable-int128");
+  }
+
   // Finally add the compile command to the compilation.
   if (Args.hasArg(options::OPT__SLASH_fallback) &&
   Output.getType() == types::TY_Object &&
Index: lib/Basic/Targets/Mips.h
===
--- lib/Basic/Targets/Mips.h
+++ lib/Basic/Targets/Mips.h
@@ -387,7 +387,9 @@
 return llvm::makeArrayRef(NewABIRegAliases);
   }
 
-  bool hasInt128Type() const override { return ABI == "n32" || ABI == "n64"; }
+  bool hasInt128Type() const override {
+return (ABI == "n32" || ABI == "n64") || getTargetOpts().ForceEnableInt128;
+  }
 
   bool validateTarget(DiagnosticsEngine ) const override;
 };
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -839,6 +839,12 @@
 def fjump_tables : Flag<["-"], "fjump-tables">, Group;
 def fno_jump_tables : Flag<["-"], "fno-jump-tables">, Group, Flags<[CC1Option]>,
   HelpText<"Do not use jump tables for lowering switches">;
+def fforce_enable_int128 : Flag<["-"], "fforce-enable-int128">,
+  Group, Flags<[CC1Option]>,
+  HelpText<"Enable support for int128_t type">;
+def fno_force_enable_int128 : Flag<["-"], "fno-force-enable-int128">,
+  Group, Flags<[CC1Option]>,
+  HelpText<"Disable support for int128_t type">;
 
 // Begin sanitizer flags. These should all be core options exposed in all driver
 // 

[PATCH] D43322: Diagnose cases of "return x" that should be "return std::move(x)" for efficiency

2018-02-22 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone updated this revision to Diff 135484.
Quuxplusone added a reviewer: rsmith.
Quuxplusone added a subscriber: Rakete.
Quuxplusone added a comment.

Eliminate a couple of `auto` per comment by @Rakete.


Repository:
  rC Clang

https://reviews.llvm.org/D43322

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaStmt.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  test/SemaCXX/warn-return-std-move.cpp

Index: test/SemaCXX/warn-return-std-move.cpp
===
--- /dev/null
+++ test/SemaCXX/warn-return-std-move.cpp
@@ -0,0 +1,334 @@
+// RUN: %clang_cc1 -fsyntax-only -Wreturn-std-move -Wreturn-std-move-in-cxx11 -std=c++11 -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wreturn-std-move -Wreturn-std-move-in-cxx11 -std=c++11 -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+
+// definitions for std::move
+namespace std {
+inline namespace foo {
+template  struct remove_reference { typedef T type; };
+template  struct remove_reference { typedef T type; };
+template  struct remove_reference { typedef T type; };
+
+template  typename remove_reference::type &(T &);
+} // namespace foo
+} // namespace std
+
+struct Instrument {
+Instrument() {}
+Instrument(Instrument&&) { /* MOVE */ }
+Instrument(const Instrument&) { /* COPY */ }
+};
+struct ConvertFromBase { Instrument i; };
+struct ConvertFromDerived { Instrument i; };
+struct Base {
+Instrument i;
+operator ConvertFromBase() const& { return ConvertFromBase{i}; }
+operator ConvertFromBase() && { return ConvertFromBase{std::move(i)}; }
+};
+struct Derived : public Base {
+operator ConvertFromDerived() const& { return ConvertFromDerived{i}; }
+operator ConvertFromDerived() && { return ConvertFromDerived{std::move(i)}; }
+};
+struct ConstructFromBase {
+Instrument i;
+ConstructFromBase(const Base& b): i(b.i) {}
+ConstructFromBase(Base&& b): i(std::move(b.i)) {}
+};
+struct ConstructFromDerived {
+Instrument i;
+ConstructFromDerived(const Derived& d): i(d.i) {}
+ConstructFromDerived(Derived&& d): i(std::move(d.i)) {}
+};
+
+struct TrivialInstrument {
+int i = 42;
+};
+struct ConvertFromTrivialBase { TrivialInstrument i; };
+struct ConvertFromTrivialDerived { TrivialInstrument i; };
+struct TrivialBase {
+TrivialInstrument i;
+operator ConvertFromTrivialBase() const& { return ConvertFromTrivialBase{i}; }
+operator ConvertFromTrivialBase() && { return ConvertFromTrivialBase{std::move(i)}; }
+};
+struct TrivialDerived : public TrivialBase {
+operator ConvertFromTrivialDerived() const& { return ConvertFromTrivialDerived{i}; }
+operator ConvertFromTrivialDerived() && { return ConvertFromTrivialDerived{std::move(i)}; }
+};
+struct ConstructFromTrivialBase {
+TrivialInstrument i;
+ConstructFromTrivialBase(const TrivialBase& b): i(b.i) {}
+ConstructFromTrivialBase(TrivialBase&& b): i(std::move(b.i)) {}
+};
+struct ConstructFromTrivialDerived {
+TrivialInstrument i;
+ConstructFromTrivialDerived(const TrivialDerived& d): i(d.i) {}
+ConstructFromTrivialDerived(TrivialDerived&& d): i(std::move(d.i)) {}
+};
+
+Derived test1() {
+Derived d1;
+return d1;  // ok
+}
+Base test2() {
+Derived d2;
+return d2;  // e1
+// expected-warning@-1{{will be copied despite being returned by name}}
+// expected-note@-2{{to avoid copying}}
+// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:12-[[@LINE-3]]:14}:"std::move(d2)"
+}
+ConstructFromDerived test3() {
+Derived d3;
+return d3;  // e2-cxx11
+// expected-warning@-1{{would have been copied despite being returned by name}}
+// expected-note@-2{{to avoid copying on older compilers}}
+// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:12-[[@LINE-3]]:14}:"std::move(d3)"
+}
+ConstructFromBase test4() {
+Derived d4;
+return d4;  // e3
+// expected-warning@-1{{will be copied despite being returned by name}}
+// expected-note@-2{{to avoid copying}}
+// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:12-[[@LINE-3]]:14}:"std::move(d4)"
+}
+ConvertFromDerived test5() {
+Derived d5;
+return d5;  // e4
+// expected-warning@-1{{will be copied despite being returned by name}}
+// expected-note@-2{{to avoid copying}}
+// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:12-[[@LINE-3]]:14}:"std::move(d5)"
+}
+ConvertFromBase test6() {
+Derived d6;
+return d6;  // e5
+// expected-warning@-1{{will be copied despite being returned by name}}
+// expected-note@-2{{to avoid copying}}
+// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:12-[[@LINE-3]]:14}:"std::move(d6)"
+}
+
+// These test cases should not produce the warning.
+Derived ok1() { Derived d; return d; }
+Base ok2() { Derived d; return static_cast(d); }
+ConstructFromDerived ok3() { Derived d; return static_cast(d); }
+ConstructFromBase ok4() { 

[PATCH] D34367: CodeGen: Fix address space of indirect function argument

2018-02-22 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 135499.
yaxunl added a comment.

sync to ToT.


https://reviews.llvm.org/D34367

Files:
  lib/CodeGen/CGAtomic.cpp
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGCall.h
  lib/CodeGen/CGClass.cpp
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CGExprCXX.cpp
  lib/CodeGen/CGGPUBuiltin.cpp
  lib/CodeGen/CGObjCGNU.cpp
  lib/CodeGen/CGObjCMac.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/CodeGen/MicrosoftCXXABI.cpp
  test/CodeGenCXX/amdgcn-func-arg.cpp
  test/CodeGenOpenCL/addr-space-struct-arg.cl
  test/CodeGenOpenCL/byval.cl

Index: test/CodeGenOpenCL/byval.cl
===
--- test/CodeGenOpenCL/byval.cl
+++ test/CodeGenOpenCL/byval.cl
@@ -1,5 +1,4 @@
 // RUN: %clang_cc1 -emit-llvm -o - -triple amdgcn %s | FileCheck %s
-// RUN: %clang_cc1 -emit-llvm -o - -triple amdgcn---opencl %s | FileCheck %s
 
 struct A {
   int x[100];
Index: test/CodeGenOpenCL/addr-space-struct-arg.cl
===
--- test/CodeGenOpenCL/addr-space-struct-arg.cl
+++ test/CodeGenOpenCL/addr-space-struct-arg.cl
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 %s -emit-llvm -o - -O0 -finclude-default-header -ffake-address-space-map -triple i686-pc-darwin | FileCheck -enable-var-scope -check-prefixes=COM,X86 %s
 // RUN: %clang_cc1 %s -emit-llvm -o - -O0 -finclude-default-header -triple amdgcn-amdhsa-amd | FileCheck -enable-var-scope -check-prefixes=COM,AMDGCN %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -cl-std=CL2.0 -O0 -finclude-default-header -triple amdgcn-amdhsa-amd | FileCheck -enable-var-scope -check-prefixes=COM,AMDGCN,AMDGCN20 %s
 
 typedef struct {
   int cells[9];
@@ -35,6 +36,9 @@
   int2 y[20];
 };
 
+#if __OPENCL_C_VERSION__ >= 200
+struct LargeStructOneMember g_s;
+#endif
 
 // X86-LABEL: define void @foo(%struct.Mat4X4* noalias sret %agg.result, %struct.Mat3X3* byval align 4 %in)
 // AMDGCN-LABEL: define %struct.Mat4X4 @foo([9 x i32] %in.coerce)
@@ -80,10 +84,42 @@
 }
 
 // AMDGCN-LABEL: define void @FuncOneLargeMember(%struct.LargeStructOneMember addrspace(5)* byval align 8 %u)
+// AMDGCN-NOT: addrspacecast
+// AMDGCN:   store <2 x i32> %{{.*}}, <2 x i32> addrspace(5)*
 void FuncOneLargeMember(struct LargeStructOneMember u) {
   u.x[0] = (int2)(0, 0);
 }
 
+// AMDGCN20-LABEL: define void @test_indirect_arg_globl()
+// AMDGCN20:  %[[byval_temp:.*]] = alloca %struct.LargeStructOneMember, align 8, addrspace(5)
+// AMDGCN20:  %[[r0:.*]] = bitcast %struct.LargeStructOneMember addrspace(5)* %[[byval_temp]] to i8 addrspace(5)*
+// AMDGCN20:  call void @llvm.memcpy.p5i8.p1i8.i64(i8 addrspace(5)* align 8 %[[r0]], i8 addrspace(1)* align 8 bitcast (%struct.LargeStructOneMember addrspace(1)* @g_s to i8 addrspace(1)*), i64 800, i1 false)
+// AMDGCN20:  call void @FuncOneLargeMember(%struct.LargeStructOneMember addrspace(5)* byval align 8 %[[byval_temp]])
+#if __OPENCL_C_VERSION__ >= 200
+void test_indirect_arg_globl(void) {
+  FuncOneLargeMember(g_s);
+}
+#endif
+
+// AMDGCN-LABEL: define amdgpu_kernel void @test_indirect_arg_local()
+// AMDGCN: %[[byval_temp:.*]] = alloca %struct.LargeStructOneMember, align 8, addrspace(5)
+// AMDGCN: %[[r0:.*]] = bitcast %struct.LargeStructOneMember addrspace(5)* %[[byval_temp]] to i8 addrspace(5)*
+// AMDGCN: call void @llvm.memcpy.p5i8.p3i8.i64(i8 addrspace(5)* align 8 %[[r0]], i8 addrspace(3)* align 8 bitcast (%struct.LargeStructOneMember addrspace(3)* @test_indirect_arg_local.l_s to i8 addrspace(3)*), i64 800, i1 false)
+// AMDGCN: call void @FuncOneLargeMember(%struct.LargeStructOneMember addrspace(5)* byval align 8 %[[byval_temp]])
+kernel void test_indirect_arg_local(void) {
+  local struct LargeStructOneMember l_s;
+  FuncOneLargeMember(l_s);
+}
+
+// AMDGCN-LABEL: define void @test_indirect_arg_private()
+// AMDGCN: %[[p_s:.*]] = alloca %struct.LargeStructOneMember, align 8, addrspace(5)
+// AMDGCN-NOT: @llvm.memcpy
+// AMDGCN-NEXT: call void @FuncOneLargeMember(%struct.LargeStructOneMember addrspace(5)* byval align 8 %[[p_s]])
+void test_indirect_arg_private(void) {
+  struct LargeStructOneMember p_s;
+  FuncOneLargeMember(p_s);
+}
+
 // AMDGCN-LABEL: define amdgpu_kernel void @KernelOneMember
 // AMDGCN-SAME:  (<2 x i32> %[[u_coerce:.*]])
 // AMDGCN:  %[[u:.*]] = alloca %struct.StructOneMember, align 8, addrspace(5)
@@ -112,7 +148,6 @@
   u.y[0] = (int2)(0, 0);
 }
 
-
 // AMDGCN-LABEL: define amdgpu_kernel void @KernelTwoMember
 // AMDGCN-SAME:  (%struct.StructTwoMember %[[u_coerce:.*]])
 // AMDGCN:  %[[u:.*]] = alloca %struct.StructTwoMember, align 8, addrspace(5)
Index: test/CodeGenCXX/amdgcn-func-arg.cpp
===
--- /dev/null
+++ test/CodeGenCXX/amdgcn-func-arg.cpp
@@ -0,0 +1,94 @@
+// RUN: %clang_cc1 -O0 -triple amdgcn---amdgiz -emit-llvm %s -o - | FileCheck %s
+
+class A {
+public:
+  int x;
+  A():x(0) {}
+  ~A() {}
+};
+
+class B {
+int x[100];
+};
+
+A g_a;
+B g_b;
+
+void func_with_ref_arg(A );
+void 

[PATCH] D34367: CodeGen: Fix address space of indirect function argument

2018-02-22 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/CodeGen/CGCall.cpp:3446
+  return LV.asAggregateRValue();
+}
+

No, I don't think this is right.  This method should always return an 
independent RValue; if the CallArg is storing an LValue, it should copy from it 
into a temporary.  That means it needs to take a CGF, and it also means you 
can't call it eagerly.



Comment at: lib/CodeGen/CGCall.cpp:3779
+  RV = I->getRValue();
+}
 

For example, all of this is eagerly forcing an RValue, and it needs to be 
delayed so that you can take advantage of having an LValue in the right cases 
below.



Comment at: lib/CodeGen/CGCall.cpp:3814
 EmitInitStoreOfNonAggregate(*this, RV, argLV);
   }
   break;

I think most of this could be replaced with a copyInto(CGF&, Address) method on 
CallArg that just stores/copies the RValue into the destination.  But you might 
need to handle the aggregate-RValue case specially before calling the method, 
because I think what that's expressing is that we're trying to evaluate 
aggregate-RValue arguments directly into the right place in the inalloca 
allocation.


https://reviews.llvm.org/D34367



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


[PATCH] D43581: [clang-tidy/google] Fix the Objective-C global variable declaration check 

2018-02-22 Thread Yan Zhang via Phabricator via cfe-commits
Wizard added inline comments.



Comment at: clang-tidy/google/GlobalVariableDeclarationCheck.cpp:92
+ "an appropriate prefix (see "
+ "http://google.github.io/styleguide/objcguide#constants).")
 << Decl->getName() << generateFixItHint(Decl, true);

aaron.ballman wrote:
> We don't usually put hyperlinks in the diagnostic messages, so please remove 
> this.
> 
> My suggestion about describing what constitutes an appropriate prefix was 
> with regards to the style guide wording itself. For instance, that document 
> doesn't mention that two capital letters is good. That's not on you to fix 
> before this patch goes in, of course.
Btw it is actually "2 or more" characters for prefix. I think it makes sense 
because we need at least 2 or more characters to call it a "prefix" :-)


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43581



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


[PATCH] D42776: [Sema] Fix an assertion failure in constant expression evaluation of calls to functions with default arguments

2018-02-22 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

Thank you, this looks like a great direction.

As noted, there are a bunch of other cases that we should cover with this 
approach. I'm really happy about the number of related bugs we get to fix with 
this change.




Comment at: lib/AST/ExprConstant.cpp:3186-3187
   // object under construction.
-  if (Info.isEvaluatingConstructor(LVal.getLValueBase(), LVal.CallIndex)) {
+  if (Info.isEvaluatingConstructor(LVal.getLValueBase(),
+   LVal.getLValueCallIndex())) {
 BaseType = Info.Ctx.getCanonicalType(BaseType);

This should take the version into account.



Comment at: lib/AST/ExprConstant.cpp:5236
 if (Frame) {
-  Result.set(VD, Frame->Index);
+  Result.set({VD, Frame->Index});
   return true;

Hmm. We should be versioning local variables as well. Currently we'll accept 
invalid code such as:

```
constexpr int f() {
  int *p = nullptr;
  for (int k = 0; k != 2; ++k) {
int local_var = 0;
if (k == 0)
  p = _var;
else
  return *p;
  }
}
static_assert(f() == 0);
```



Comment at: lib/AST/ExprConstant.cpp:5275-5278
+unsigned Version = Info.CurrentCall->getMTEVersion();
 Value = >
-createTemporary(E, E->getStorageDuration() == SD_Automatic);
-Result.set(E, Info.CurrentCall->Index);
+createTemporary(E, E->getStorageDuration() == SD_Automatic, Version);
+Result.set({E, Info.CurrentCall->Index, Version});

Can you combine these, so we have a single function to create a temporary and 
produce both an `LValue` denoting it and an `APValue*` to hold its evaluated 
value?



Comment at: lib/AST/ExprConstant.cpp:5772
 } else {
-  Result.set(SubExpr, Info.CurrentCall->Index);
+  Result.set({SubExpr, Info.CurrentCall->Index});
   if (!EvaluateInPlace(Info.CurrentCall->createTemporary(SubExpr, false),

This should create a versioned temporary object.



Comment at: lib/AST/ExprConstant.cpp:6540
   bool VisitConstructExpr(const Expr *E) {
-Result.set(E, Info.CurrentCall->Index);
+Result.set({E, Info.CurrentCall->Index});
 return EvaluateInPlace(Info.CurrentCall->createTemporary(E, false),

This should create a versioned temporary object.



Comment at: lib/AST/ExprConstant.cpp:8031
+ (A.getLValueCallIndex() == B.getLValueCallIndex() &&
+  A.getLValueVersion() == B.getLValueVersion());
 }

You already checked this above. It'd make sense to check the call index and 
version in the same place here, but we should only need one check for each :)



Comment at: lib/AST/ExprConstant.cpp:9974-9997
+LV.set({E, Info.CurrentCall->Index});
 APValue  = Info.CurrentCall->createTemporary(E, false);
 if (!EvaluateArray(E, LV, Value, Info))
   return false;
 Result = Value;
   } else if (T->isRecordType()) {
 LValue LV;

These temporaries should all be versioned.


https://reviews.llvm.org/D42776



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


[PATCH] D43105: [RISCV] Enable __int128_t and __uint128_t through clang flag

2018-02-22 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang added a comment.

Added tests for ABI lowering and preprocessor defines as per comments.


Repository:
  rC Clang

https://reviews.llvm.org/D43105



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


[PATCH] D43362: Simplify setting dso_local. NFC.

2018-02-22 Thread Eric Christopher via Phabricator via cfe-commits
echristo accepted this revision.
echristo added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks for the cleanup.


https://reviews.llvm.org/D43362



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


[PATCH] D43657: [analyzer] dump() dynamic type info and taint into state dumps.

2018-02-22 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision.
NoQ added reviewers: dcoughlin, xazax.hun, a.sidorin, george.karpenkov, szepet.
Herald added subscribers: cfe-commits, rnkovacs.

More dumps!

Eg.:

  Dynamic types of regions:
  x : class PR13569_virtual::Child

Taint dumps were already implemented, so i added them because they seemed to 
have been accidentally left out.


Repository:
  rC Clang

https://reviews.llvm.org/D43657

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeMap.h
  lib/StaticAnalyzer/Core/DynamicTypeMap.cpp
  lib/StaticAnalyzer/Core/ProgramState.cpp


Index: lib/StaticAnalyzer/Core/ProgramState.cpp
===
--- lib/StaticAnalyzer/Core/ProgramState.cpp
+++ lib/StaticAnalyzer/Core/ProgramState.cpp
@@ -17,6 +17,7 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/SubEngine.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/TaintManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeMap.h"
 #include "llvm/Support/raw_ostream.h"
 
 using namespace clang;
@@ -449,6 +450,12 @@
   // Print out the constraints.
   Mgr.getConstraintManager().print(this, Out, NL, Sep);
 
+  // Print out the tracked dynamic types.
+  printDynamicTypeInfo(this, Out, NL, Sep);
+
+  // Print out tainted symbols.
+  printTaint(Out, NL, Sep);
+
   // Print checker-specific data.
   Mgr.getOwningEngine()->printState(Out, this, NL, Sep, LC);
 }
@@ -466,7 +473,7 @@
   TaintMapImpl TM = get();
 
   if (!TM.isEmpty())
-Out <<"Tainted Symbols:" << NL;
+Out <<"Tainted symbols:" << NL;
 
   for (TaintMapImpl::iterator I = TM.begin(), E = TM.end(); I != E; ++I) {
 Out << I->first << " : " << I->second << NL;
Index: lib/StaticAnalyzer/Core/DynamicTypeMap.cpp
===
--- lib/StaticAnalyzer/Core/DynamicTypeMap.cpp
+++ lib/StaticAnalyzer/Core/DynamicTypeMap.cpp
@@ -47,5 +47,28 @@
   return NewState;
 }
 
+void printDynamicTypeInfo(ProgramStateRef State, raw_ostream ,
+  const char *NL, const char *Sep) {
+  bool First = true;
+  for (const auto  : State->get()) {
+if (First) {
+  Out << NL << "Dynamic types of regions:" << NL;
+  First = false;
+}
+const MemRegion *MR = I.first;
+const DynamicTypeInfo  = I.second;
+Out << MR << " : ";
+if (DTI.isValid()) {
+  Out << DTI.getType()->getPointeeType().getAsString();
+  if (DTI.canBeASubClass()) {
+Out << " (or its subclass)";
+  }
+} else {
+  Out << "Invalid type info";
+}
+Out << NL;
+  }
+}
+
 } // namespace ento
 } // namespace clang
Index: include/clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeMap.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeMap.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeMap.h
@@ -51,6 +51,9 @@
 DynamicTypeInfo(NewTy, CanBeSubClassed));
 }
 
+void printDynamicTypeInfo(ProgramStateRef State, raw_ostream ,
+  const char *NL, const char *Sep);
+
 } // ento
 } // clang
 


Index: lib/StaticAnalyzer/Core/ProgramState.cpp
===
--- lib/StaticAnalyzer/Core/ProgramState.cpp
+++ lib/StaticAnalyzer/Core/ProgramState.cpp
@@ -17,6 +17,7 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/SubEngine.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/TaintManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeMap.h"
 #include "llvm/Support/raw_ostream.h"
 
 using namespace clang;
@@ -449,6 +450,12 @@
   // Print out the constraints.
   Mgr.getConstraintManager().print(this, Out, NL, Sep);
 
+  // Print out the tracked dynamic types.
+  printDynamicTypeInfo(this, Out, NL, Sep);
+
+  // Print out tainted symbols.
+  printTaint(Out, NL, Sep);
+
   // Print checker-specific data.
   Mgr.getOwningEngine()->printState(Out, this, NL, Sep, LC);
 }
@@ -466,7 +473,7 @@
   TaintMapImpl TM = get();
 
   if (!TM.isEmpty())
-Out <<"Tainted Symbols:" << NL;
+Out <<"Tainted symbols:" << NL;
 
   for (TaintMapImpl::iterator I = TM.begin(), E = TM.end(); I != E; ++I) {
 Out << I->first << " : " << I->second << NL;
Index: lib/StaticAnalyzer/Core/DynamicTypeMap.cpp
===
--- lib/StaticAnalyzer/Core/DynamicTypeMap.cpp
+++ lib/StaticAnalyzer/Core/DynamicTypeMap.cpp
@@ -47,5 +47,28 @@
   return NewState;
 }
 
+void printDynamicTypeInfo(ProgramStateRef State, raw_ostream ,
+  const char *NL, const char *Sep) {
+  bool First = true;
+  for (const auto  : State->get()) {
+if (First) {
+  Out << NL << "Dynamic types of regions:" << NL;
+  First = false;
+}
+const 

Re: [PATCH] D43514: Start settinng dso_local for COFF

2018-02-22 Thread Rafael Avila de Espindola via cfe-commits
Eric Christopher via Phabricator  writes:

> echristo added inline comments.
>
>
> 
> Comment at: lib/CodeGen/CodeGenModule.h:728
> +  /// This must be called after dllimport/dllexport is set.
> +  /// FIXME: should this set dllimport/dllexport instead?
>void setGVProperties(llvm::GlobalValue *GV, const NamedDecl *D) const;
> 
> Agreed? Maybe? Should the rest of the properties from above each call be set 
> in this function?
>
> Since you've got the decl it might be best to get as many of them in one 
> place as possible?

Very likely yes.

One think I have locally is a very ugly patch that sets dso_local all
over the place in clang until every GV in coff is dso_local or
dllimport.

My idea is to cleanup it bit by bit once the initial patch (this one) is
in.

I can try moving dllimport/dllexport setting to setGVProperties as the
first followup patch if you agree.

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


[PATCH] D43576: Solution to fix PR27066 - Redefinition with same mangled name as another definition (dllexport and uuid)

2018-02-22 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In https://reviews.llvm.org/D43576#1016561, @majnemer wrote:

> Here's my thinking: the `__uuidof` expression literally declares a variable 
> called `_GUID_ddb47a6a_0f23_11d5_9109_00e0296b75d3` of type `__s_GUID` which 
> is why it behaves the way it does: https://godbolt.org/g/74FY7U


This is an implementation detail leaking, though. no? Note that that is a 
reserved name.

> I don't think it is reasonable to invent new semantics which are different 
> from the MSVC ones because we find the MSVC ones inelegant.

I mostly agree, but my point is that this is *not* the MSVC semantics, it's 
merely an implementation detail that non-conforming code happens to be able to 
observe. Suppose that `type_info` objects were similarly accessible in MSVC by 
guessing their mangled names. Would you be arguing that we should inject 
variables for those too? (And note that it is *nearly* true that `type_info` 
objects work that way: https://godbolt.org/g/zByFFg -- but the parser gets 
confused somehow when you reference them.) The only difference I can see 
between these cases is that the reserved name used for the GUID case happens to 
not contain any ?s and @s, so happens to be utterable as an identifier.

We should not attempt to be compatible with the cases where MSVC's 
implementation details happen to leak into user-visible semantics.

> What is the relative upside to a new kind of Decl? Better AST fidelity?

Yes, exactly. The same reason we don't desguar other things any more than we 
have to.


https://reviews.llvm.org/D43576



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


[PATCH] D43105: [RISCV] Enable __int128_t and __uint128_t through clang flag

2018-02-22 Thread Alex Bradbury via Phabricator via cfe-commits
asb added inline comments.



Comment at: test/CodeGen/riscv32-abi.c:2-3
 // RUN: %clang_cc1 -triple riscv32 -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple riscv32 -emit-llvm -fforce-enable-int128 %s -o - \
+// RUN: | FileCheck %s -check-prefix=CHECK-FORCEINT128
 

Nit: this is slightly different to what I suggested. 
`-check-prefixes=CHECK,CHECK-FORCEINT128` would mean that all the other 
lowerings are rechecked with -fforce-eanble-int128 and are seen to remain 
unchanged.


Repository:
  rC Clang

https://reviews.llvm.org/D43105



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


[PATCH] D43105: [RISCV] Enable __int128_t and __uint128_t through clang flag

2018-02-22 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang updated this revision to Diff 135553.

Repository:
  rC Clang

https://reviews.llvm.org/D43105

Files:
  include/clang/Basic/TargetInfo.h
  include/clang/Basic/TargetOptions.h
  include/clang/Driver/Options.td
  lib/Basic/Targets/Mips.h
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/riscv32-abi.c
  test/Driver/types.c
  test/Preprocessor/init.c

Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -10007,6 +10007,9 @@
 // RUN:   | FileCheck -match-full-lines -check-prefix=RISCV32 %s
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=riscv32-unknown-linux < /dev/null \
 // RUN:   | FileCheck -match-full-lines -check-prefixes=RISCV32,RISCV32-LINUX %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=riscv32 \
+// RUN: -fforce-enable-int128 < /dev/null | FileCheck -match-full-lines \
+// RUN: -check-prefixes=RISCV32,RISCV32-INT128 %s
 // RISCV32: #define _ILP32 1
 // RISCV32: #define __ATOMIC_ACQUIRE 2
 // RISCV32: #define __ATOMIC_ACQ_REL 4
@@ -10136,6 +10139,7 @@
 // RISCV32: #define __SIG_ATOMIC_WIDTH__ 32
 // RISCV32: #define __SIZEOF_DOUBLE__ 8
 // RISCV32: #define __SIZEOF_FLOAT__ 4
+// RISCV32-INT128: #define __SIZEOF_INT128__ 16
 // RISCV32: #define __SIZEOF_INT__ 4
 // RISCV32: #define __SIZEOF_LONG_DOUBLE__ 16
 // RISCV32: #define __SIZEOF_LONG_LONG__ 8
Index: test/Driver/types.c
===
--- /dev/null
+++ test/Driver/types.c
@@ -0,0 +1,18 @@
+// Check whether __int128_t and __uint128_t are supported.
+
+// RUN: not %clang -c --target=riscv32-unknown-linux-gnu -fsyntax-only %s \
+// RUN: 2>&1 | FileCheck %s
+
+// RUN: %clang -c --target=riscv32-unknown-linux-gnu -fsyntax-only %s \
+// RUN: -fno-force-enable-int128 -fforce-enable-int128
+
+// RUN: not %clang -c --target=riscv32-unknown-linux-gnu -fsyntax-only %s \
+// RUN: -fforce-enable-int128 -fno-force-enable-int128
+
+void a() {
+  __int128_t s;
+  __uint128_t t;
+}
+
+// CHECK: error: use of undeclared identifier '__int128_t'
+// CHECK: error: use of undeclared identifier '__uint128_t'
Index: test/CodeGen/riscv32-abi.c
===
--- test/CodeGen/riscv32-abi.c
+++ test/CodeGen/riscv32-abi.c
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -triple riscv32 -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple riscv32 -emit-llvm -fforce-enable-int128 %s -o - \
+// RUN: | FileCheck %s -check-prefixes=CHECK,CHECK-FORCEINT128
 
 #include 
 #include 
@@ -24,6 +26,11 @@
 // CHECK-LABEL: define i64 @f_scalar_4(i64 %x)
 int64_t f_scalar_4(int64_t x) { return x; }
 
+#ifdef __SIZEOF_INT128__
+// CHECK-FORCEINT128-LABEL: define i128 @f_scalar_5(i128 %x)
+__int128_t f_scalar_5(__int128_t x) { return x; }
+#endif
+
 // CHECK-LABEL: define float @f_fp_scalar_1(float %x)
 float f_fp_scalar_1(float x) { return x; }
 
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -2765,6 +2765,7 @@
   if (Opts.Triple.empty())
 Opts.Triple = llvm::sys::getDefaultTargetTriple();
   Opts.OpenCLExtensionsAsWritten = Args.getAllArgValues(OPT_cl_ext_EQ);
+  Opts.ForceEnableInt128 = Args.hasArg(OPT_fforce_enable_int128);
 }
 
 bool CompilerInvocation::CreateFromArgs(CompilerInvocation ,
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -4725,6 +4725,12 @@
 }
   }
 
+  if (Arg *A = Args.getLastArg(options::OPT_fforce_enable_int128,
+   options::OPT_fno_force_enable_int128)) {
+if (A->getOption().matches(options::OPT_fforce_enable_int128))
+  CmdArgs.push_back("-fforce-enable-int128");
+  }
+
   // Finally add the compile command to the compilation.
   if (Args.hasArg(options::OPT__SLASH_fallback) &&
   Output.getType() == types::TY_Object &&
Index: lib/Basic/Targets/Mips.h
===
--- lib/Basic/Targets/Mips.h
+++ lib/Basic/Targets/Mips.h
@@ -387,7 +387,9 @@
 return llvm::makeArrayRef(NewABIRegAliases);
   }
 
-  bool hasInt128Type() const override { return ABI == "n32" || ABI == "n64"; }
+  bool hasInt128Type() const override {
+return (ABI == "n32" || ABI == "n64") || getTargetOpts().ForceEnableInt128;
+  }
 
   bool validateTarget(DiagnosticsEngine ) const override;
 };
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -839,6 +839,12 @@
 def fjump_tables : Flag<["-"], "fjump-tables">, Group;
 def fno_jump_tables : Flag<["-"], "fno-jump-tables">, Group, Flags<[CC1Option]>,
   HelpText<"Do not use jump tables 

[PATCH] D41102: Setup clang-doc frontend framework

2018-02-22 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett updated this revision to Diff 135559.
juliehockett marked 10 inline comments as done.
juliehockett added a comment.

Refactoring bitcode writer


https://reviews.llvm.org/D41102

Files:
  CMakeLists.txt
  clang-doc/BitcodeWriter.cpp
  clang-doc/BitcodeWriter.h
  clang-doc/CMakeLists.txt
  clang-doc/ClangDoc.h
  clang-doc/Mapper.cpp
  clang-doc/Mapper.h
  clang-doc/Representation.h
  clang-doc/tool/CMakeLists.txt
  clang-doc/tool/ClangDocMain.cpp
  docs/clang-doc.rst
  test/CMakeLists.txt
  test/clang-doc/mapper-class.cpp
  test/clang-doc/mapper-enum.cpp
  test/clang-doc/mapper-function.cpp
  test/clang-doc/mapper-method.cpp
  test/clang-doc/mapper-namespace.cpp
  test/clang-doc/mapper-struct.cpp
  test/clang-doc/mapper-union.cpp

Index: test/clang-doc/mapper-union.cpp
===
--- /dev/null
+++ test/clang-doc/mapper-union.cpp
@@ -0,0 +1,29 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: llvm-bcanalyzer %t/docs/c:@u...@d.bc --dump | FileCheck %s
+
+union D { int X; int Y; };
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'D'
+  // CHECK: 
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'int'
+// CHECK:  blob data = 'D::X'
+// CHECK: 
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'int'
+// CHECK:  blob data = 'D::Y'
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+
+
+
Index: test/clang-doc/mapper-struct.cpp
===
--- /dev/null
+++ test/clang-doc/mapper-struct.cpp
@@ -0,0 +1,24 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: llvm-bcanalyzer %t/docs/c:@s...@c.bc --dump | FileCheck %s
+
+struct C { int i; };
+// CHECK: 
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'C'
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'int'
+// CHECK:  blob data = 'C::i'
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+
+
+
Index: test/clang-doc/mapper-namespace.cpp
===
--- /dev/null
+++ test/clang-doc/mapper-namespace.cpp
@@ -0,0 +1,17 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: llvm-bcanalyzer %t/docs/c:@n...@a.bc --dump | FileCheck %s
+
+namespace A {}
+// CHECK: 
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'A'
+// CHECK: 
+
+
Index: test/clang-doc/mapper-method.cpp
===
--- /dev/null
+++ test/clang-doc/mapper-method.cpp
@@ -0,0 +1,31 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: llvm-bcanalyzer %t/docs/c:@S@G@F@Method#I#.bc --dump | FileCheck %s
+
+class G {
+public: 
+	int Method(int param) { return param; }
+};
+// CHECK: 
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'Method'
+  // CHECK: 
+  // CHECK:  blob data = 'c:@S@G'
+  // CHECK: 
+// CHECK:  blob data = 'int'
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'int'
+// CHECK:  blob data = 'param'
+  // CHECK: 
+// CHECK: 
+
+
+
+
Index: test/clang-doc/mapper-function.cpp
===
--- /dev/null
+++ test/clang-doc/mapper-function.cpp
@@ -0,0 +1,25 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: llvm-bcanalyzer %t/docs/c:@F@F#I#.bc --dump | FileCheck %s
+
+int F(int param) { return param; }
+// CHECK: 
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'F'
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'int'
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'int'
+// CHECK:  blob data = 'param'
+  // CHECK: 
+// CHECK: 
+
+
Index: test/clang-doc/mapper-enum.cpp
===
--- /dev/null
+++ test/clang-doc/mapper-enum.cpp
@@ -0,0 +1,26 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: llvm-bcanalyzer %t/docs/c:@e...@b.bc --dump | FileCheck %s
+
+enum B { X, Y };
+// CHECK: 
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'B'
+  // 

  1   2   >