[PATCH] D51554: [CUDA][OPENMP][NVPTX]Improve logic of the debug info support.

2018-12-05 Thread Eric Christopher via Phabricator via cfe-commits
echristo added inline comments.



Comment at: lib/Driver/ToolChains/Cuda.cpp:282-285
 enum DebugInfoKind {
-  NoDebug,   /// No debug info.
-  LineTableOnly, /// Line tables only.
-  FullDebug  /// Full debug info.
+  NoDebug, /// No debug info.
+  DebugDirectivesOnly, /// Line tables only.
+  FullDebug,   /// Full debug info.

This enum doesn't appear to be complete? Either way can you make it match the 
other and document what each thing means a bit more?



Comment at: lib/Driver/ToolChains/Cuda.cpp:289
 
 static DebugInfoKind mustEmitDebugInfo(const ArgList &Args) {
+  const Arg *A = Args.getLastArg(options::OPT_O_Group);

Please document this routine in prose.



Comment at: lib/Driver/ToolChains/Cuda.cpp:292
+  bool IsDebugEnabled = !A || A->getOption().matches(options::OPT_O0) ||
+Args.hasFlag(options::OPT_cuda_noopt_device_debug,
+ options::OPT_no_cuda_noopt_device_debug,

ABataev wrote:
> echristo wrote:
> > Is this an nvcc compatibility flag?
> No, nvcc uses different set of flags. It uses `-g` for the debug info for the 
> host code and `-G` for the device code. I'm not the original author of this 
> option. clang uses it to control emission of the debug info for the device.
> The bad thing about nvcc that it disables optimizations when `-G` is used. 
> Using this option we can use LLVM optimizations and disable the optimizations 
> only when we call `ptxas` tool.
OK.



Comment at: lib/Driver/ToolChains/Cuda.cpp:706-708
+void CudaToolChain::adjustDebugInfoKind(
+codegenoptions::DebugInfoKind &DebugInfoKind, const ArgList &Args) const {
+  switch (mustEmitDebugInfo(Args)) {

Is this really doing anything?


Repository:
  rC Clang

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

https://reviews.llvm.org/D51554



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


r348459 - Remove unnecessary include.

2018-12-05 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Wed Dec  5 22:32:40 2018
New Revision: 348459

URL: http://llvm.org/viewvc/llvm-project?rev=348459&view=rev
Log:
Remove unnecessary include.

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

Modified: cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp?rev=348459&r1=348458&r2=348459&view=diff
==
--- cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp (original)
+++ cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp Wed Dec  5 
22:32:40 2018
@@ -21,7 +21,6 @@
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Lex/HeaderSearch.h"
 #include "clang/Lex/Preprocessor.h"
-#include "clang/Serialization/ASTWriter.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Bitcode/BitstreamReader.h"
 #include "llvm/DebugInfo/DWARF/DWARFContext.h"


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


r348458 - Remove CodeGen dependencies on Sema.

2018-12-05 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Wed Dec  5 22:12:20 2018
New Revision: 348458

URL: http://llvm.org/viewvc/llvm-project?rev=348458&view=rev
Log:
Remove CodeGen dependencies on Sema.

Move diagnostics from Sema to Frontend (or Common) so that CodeGen no longer
needs to include the Sema diagnostic IDs.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/CodeGen/CGAtomic.cpp
cfe/trunk/lib/CodeGen/CGStmt.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td?rev=348458&r1=348457&r2=348458&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td Wed Dec  5 22:12:20 
2018
@@ -189,6 +189,12 @@ def err_seh___finally_block : Error<
 def note_invalid_subexpr_in_const_expr : Note<
   "subexpression not valid in a constant expression">;
 
+// Sema && Frontend
+let CategoryName = "Inline Assembly Issue" in {
+  def err_asm_invalid_type_in_input : Error<
+"invalid type %0 in asm input for constraint '%1'">;
+}
+
 // Targets
 
 def err_target_unknown_triple : Error<

Modified: cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td?rev=348458&r1=348457&r2=348458&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td Wed Dec  5 
22:12:20 2018
@@ -245,4 +245,49 @@ def warn_stdlibcxx_not_found : Warning<
   "include path for stdlibc++ headers not found; pass '-stdlib=libc++' on the "
   "command line to use the libc++ standard library instead">,
   InGroup>;
+
+def err_builtin_needs_feature : Error<"%0 needs target feature %1">;
+def err_function_needs_feature : Error<
+  "always_inline function %1 requires target feature '%2', but would "
+  "be inlined into function %0 that is compiled without support for '%2'">;
+
+def err_alias_to_undefined : Error<
+  "%select{alias|ifunc}0 must point to a defined "
+  "%select{variable or |}1function">;
+def warn_alias_to_weak_alias : Warning<
+  "%select{alias|ifunc}2 will always resolve to %0 even if weak definition of "
+  "%1 is overridden">,
+  InGroup;
+def err_duplicate_mangled_name : Error<
+  "definition with same mangled name '%0' as another definition">;
+def err_cyclic_alias : Error<
+  "%select{alias|ifunc}0 definition is part of a cycle">;
+def err_ifunc_resolver_return : Error<
+  "ifunc resolver function must return a pointer">;
+
+def warn_atomic_op_misaligned : Warning<
+  "%select{large|misaligned}0 atomic operation may incur "
+  "significant performance penalty">, InGroup>;
+
+def warn_alias_with_section : Warning<
+  "%select{alias|ifunc}1 will not be in section '%0' but in the same section "
+  "as the %select{aliasee|resolver}2">,
+  InGroup;
+
+let CategoryName = "Instrumentation Issue" in {
+def warn_profile_data_out_of_date : Warning<
+  "profile data may be out of date: of %0 function%s0, %1 
%plural{1:has|:have}1"
+  " mismatched data that will be ignored">,
+  InGroup;
+def warn_profile_data_missing : Warning<
+  "profile data may be incomplete: of %0 function%s0, %1 %plural{1:has|:have}1"
+  " no data">,
+  InGroup,
+  DefaultIgnore;
+def warn_profile_data_unprofiled : Warning<
+  "no profile data available for file \"%0\"">,
+  InGroup;
+
+} // end of instrumentation issue category
+
 }

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=348458&r1=348457&r2=348458&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Dec  5 22:12:20 
2018
@@ -622,11 +622,6 @@ def err_invalid_cpu_supports : Error<"in
 def err_invalid_cpu_is : Error<"invalid cpu name for builtin">;
 def err_invalid_cpu_specific_dispatch_value : Error<
 "invalid option '%0' for %select{cpu_specific|cpu_dispatch}1">;
-def err_builtin_needs_feature : Error<"%0 needs target feature %1">;
-def err_function_needs_feature
-: Error<"always_inline function %1 requires target feature '%2', but would 
"
-"be inlined into function %0 that is compiled without support for "
-"'%2'">;
 def warn_builtin_unknown : Warning<"use of unknown builtin %0">,
   InGroup, DefaultError;
 def warn_cstruct_memaccess : Warning<
@@ -2880,20 +2875,6 @@ def 

[PATCH] D55349: Convert some ObjC alloc msgSends to runtime calls

2018-12-05 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: include/clang/Basic/ObjCRuntime.h:189
+  /// When this method returns true, Clang will turn non-super message sends of
+  /// certain selectors into calls to the correspond entrypoint:
+  ///   alloc => objc_alloc

"corresponding"



Comment at: include/clang/Basic/ObjCRuntime.h:190
+  /// certain selectors into calls to the correspond entrypoint:
+  ///   alloc => objc_alloc
+  bool shouldUseRuntimeFunctionsForAlloc() const {

The actual code also rewrites `allocWithZone:` (which is why it's reasonable to 
pluralize "functions" in the method name).



Comment at: include/clang/Basic/ObjCRuntime.h:200
+case WatchOS:
+  return true;
+

Did we really add this so long ago?  Wow.



Comment at: lib/CodeGen/CGObjC.cpp:383
+// prefix are identified as OMF_alloc but we only want to call the
+// runtime for this version.
+if (Runtime.shouldUseRuntimeFunctionsForAlloc() &&

Using the word "selector" instead of "name" is both more technically accurate 
and nicely side-steps the difference between "alloc" (which you want to 
include) and "alloc:" (which you don't).  You have this correct in the code.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55349



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


[PATCH] D54862: [OpenCL] Add generic AS to 'this' pointer

2018-12-05 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/AST/ItaniumMangle.cpp:1507
+Qualifiers MethodQuals = Qualifiers::fromCVRUMask(
+Method->getTypeQualifiers().getCVRUQualifiers());
 // We do not consider restrict a distinguishing attribute for overloading

mikael wrote:
> rjmccall wrote:
> > Anastasia wrote:
> > > rjmccall wrote:
> > > > You can overload based on the address space, right?  I think it needs 
> > > > to be mangled.
> > > Does this refer to our earlier discussion 
> > > https://reviews.llvm.org/D54862#inline-484509
> > > 
> > > We don't have a way to qualify methods with an address space yet? I was 
> > > going to send an RFC to `cfe-dev` for this but if you think it would be 
> > > ok to go ahead with an implementation, I am happy with it. Either way 
> > > would it be better to do this in a separate patch?
> > I'm fine with delaying implementation on these two issues until a later 
> > patch since, as you say, they can't be tested well until we support 
> > arbitrary address-space qualifiers.  Please at least leave FIXMEs for them.
> I actually did update this, since we can test the mangling of __generic in 
> the test.
Great, thanks.  Looks good.



Comment at: lib/AST/Type.cpp:2950
+   FunctionTypeBits.HasExtQuals = 0;
+  }
 }

The indentation here is messed up.

You seem to be mixing up "fast qualifiers" with "CVR qualifiers" in a few 
places.  That's currently correct, in the sense that the fast qualifiers are 
currently defined to be the CVR qualifiers, but the point of the distinction is 
that we might want to change that (and we have in fact explored that in the 
past).  I think you should make `FunctionTypeBits` only claim to store the fast 
qualifiers, which mostly just means updating a few field / accessor names and 
changing things like the `getCVRQualifiers()` call right above this to be 
`getFastQualifiers()`.

If there are places where it's convenient to assume that the CVR qualifiers are 
exactly the fast qualifiers, it's okay to static_assert that, but you should 
make sure to static_assert it in each place you assume it.



Comment at: lib/CodeGen/CGDebugInfo.cpp:2593
+  getOrCreateInstanceMethodType(
+  CXXMethodDecl::getThisType(FPT, Ty->getMostRecentCXXRecordDecl()),
+  FPT, U),

Why is this `getMostRecentCXXRecordDecl` instead of `getClass`?



Comment at: lib/CodeGen/CGDeclCXX.cpp:32
+   (D.hasLocalStorage() && 
CGF.getContext().getLangOpts().OpenCLCPlusPlus)) &&
+  "VarDecl must have global or local (in the case of OpenCL) storage!");
   assert(!D.getType()->isReferenceType() &&

What causes OpenCL C++ declarations to go down this path?



Comment at: lib/Index/USRGeneration.cpp:274
+if (unsigned quals = MD->getTypeQualifiers().getCVRUQualifiers())
   Out << (char)('0' + quals);
 switch (MD->getRefQualifier()) {

akyrtzi wrote:
> rjmccall wrote:
> > Paging @akyrtzi here.  The address-space qualifier should be part of the 
> > USR but I don't think if there's a defined schema for that.
> If I understand correctly from other comments you can't add special mangling 
> and USR generation yet and intend to add FIXME for doing mangling support 
> later ? If yes, could you also add FIXME here and re-visit ?
While you're here, can you described the right way for us to extend USR 
generation here to potentially add an address space?



Comment at: lib/Parse/ParseDecl.cpp:6166
+
+  Qualifiers Q = Qualifiers::fromOpaqueValue(DS.getTypeQualifiers());
+  if (D.getDeclSpec().isConstexprSpecified() && !getLangOpts().CPlusPlus14)

I think `fromCVRUQualifiers` is probably the right function, and if that 
doesn't exist you should add it.



Comment at: lib/Sema/SemaExprCXX.cpp:1112
+  QualType T = S.Context.getRecordType(Record).withCVRQualifiers(Quals);
+  T = S.getASTContext().getAddrSpaceQualType(T, 
CXXThisTypeQuals.getAddressSpace());
+

I don't think there's a good reason for this to be dropping non-CVR qualifiers. 
 If there is, it really needs a comment.



Comment at: lib/Sema/TreeTransform.h:5276
+  Sema::CXXThisScopeRAII ThisScope(
+  SemaRef, ThisContext, Qualifiers::fromOpaqueValue(ThisTypeQuals));
 

I think you need to turn `ThisTypeQuals` into a `Qualifiers` here.


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

https://reviews.llvm.org/D54862



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


[PATCH] D53738: [Fixed Point Arithmetic] Fixed Point Addition

2018-12-05 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Okay, thanks, that makes sense to me.

I'll ask around to find a way to contact the C committee.


Repository:
  rC Clang

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

https://reviews.llvm.org/D53738



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


r348454 - ARM, AArch64: support `__attribute__((__swiftcall__))`

2018-12-05 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Wed Dec  5 19:28:37 2018
New Revision: 348454

URL: http://llvm.org/viewvc/llvm-project?rev=348454&view=rev
Log:
ARM, AArch64: support `__attribute__((__swiftcall__))`

Support the Swift calling convention on Windows ARM and AArch64.  Both
of these conform to the AAPCS, AAPCS64 calling convention, and LLVM has
been adjusted to account for the register usage.  Ensure that the
frontend passes this into the backend.  This allows the swift runtime to
be built for Windows.

Added:
cfe/trunk/test/CodeGen/swift-call-conv.c
cfe/trunk/test/Sema/swift-call-conv.c
Modified:
cfe/trunk/lib/Basic/Targets/AArch64.cpp
cfe/trunk/lib/Basic/Targets/ARM.cpp

Modified: cfe/trunk/lib/Basic/Targets/AArch64.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/AArch64.cpp?rev=348454&r1=348453&r2=348454&view=diff
==
--- cfe/trunk/lib/Basic/Targets/AArch64.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/AArch64.cpp Wed Dec  5 19:28:37 2018
@@ -514,6 +514,7 @@ WindowsARM64TargetInfo::checkCallingConv
   case CC_OpenCLKernel:
   case CC_PreserveMost:
   case CC_PreserveAll:
+  case CC_Swift:
   case CC_Win64:
 return CCCR_OK;
   default:

Modified: cfe/trunk/lib/Basic/Targets/ARM.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/ARM.cpp?rev=348454&r1=348453&r2=348454&view=diff
==
--- cfe/trunk/lib/Basic/Targets/ARM.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/ARM.cpp Wed Dec  5 19:28:37 2018
@@ -996,6 +996,7 @@ WindowsARMTargetInfo::checkCallingConven
   case CC_OpenCLKernel:
   case CC_PreserveMost:
   case CC_PreserveAll:
+  case CC_Swift:
 return CCCR_OK;
   default:
 return CCCR_Warning;

Added: cfe/trunk/test/CodeGen/swift-call-conv.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/swift-call-conv.c?rev=348454&view=auto
==
--- cfe/trunk/test/CodeGen/swift-call-conv.c (added)
+++ cfe/trunk/test/CodeGen/swift-call-conv.c Wed Dec  5 19:28:37 2018
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple aarch64-unknown-windows-msvc -emit-llvm %s -o - | 
FileCheck %s
+// RUN: %clang_cc1 -triple thumbv7-unknown-windows-msvc -emit-llvm %s -o - | 
FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-windows-msvc -emit-llvm %s -o - | 
FileCheck %s
+
+// REQUIRES: 
aarch64-registered-target,arm-registered-target,x86-registered-target
+
+void __attribute__((__swiftcall__)) f(void) {}
+// CHECK-LABEL: define dso_local swiftcc void @f()
+

Added: cfe/trunk/test/Sema/swift-call-conv.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/swift-call-conv.c?rev=348454&view=auto
==
--- cfe/trunk/test/Sema/swift-call-conv.c (added)
+++ cfe/trunk/test/Sema/swift-call-conv.c Wed Dec  5 19:28:37 2018
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -triple aarch64-unknown-windows-msvc -fsyntax-only %s 
-verify
+// RUN: %clang_cc1 -triple thumbv7-unknown-windows-msvc -fsyntax-only %s 
-verify
+// RUN: %clang_cc1 -triple x86_64-unknown-windows-msvc -fsyntax-only %s -verify
+
+// expected-no-diagnostics
+
+void __attribute__((__swiftcall__)) f(void) {}


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


[PATCH] D55067: [HIP] Fix offset of kernel argument for AMDGPU target

2018-12-05 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D55067#1320691 , @arsenm wrote:

> I think if we can just declare something simple to follow that doesn't depend 
> on the IR type alignment, we could pack any basic type and align any 
> aggregates to 4


From the user point of view, I don't think it is a good idea to let the user 
calculate the offset and pass it to hipSetupArgument, especially if we want to 
have some specific alignment rules for amdgpu backend. We should just drop the 
offset parameter from hipSetupArgument and let the runtime figure out the 
offset based on device code metadata. This will always work no matter how 
backend changes the way to layout the kernel arguments.


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

https://reviews.llvm.org/D55067



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


[PATCH] D55346: [clang-tidy] check for using declaration scope and qualification

2018-12-05 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: docs/clang-tidy/checks/abseil-anonymous-enclosed-aliases.rst:20
+
+  } // foo

Are there guidelines?



Comment at: docs/clang-tidy/checks/abseil-qualified-aliases.rst:22
+
+See https://abseil.io/tips/119 for an in depth justification for this
+check. 

Please make text consistent across all these checks.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D55346



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


[PATCH] D55269: [CUDA] Fix nvidia-cuda-toolkit detection on Ubuntu

2018-12-05 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny updated this revision to Diff 176916.
jdenny retitled this revision from "[CUDA][OpenMP] Fix nvidia-cuda-toolkit 
detection on Debian/Ubuntu" to "[CUDA] Fix nvidia-cuda-toolkit detection on 
Ubuntu".
jdenny edited the summary of this revision.
jdenny added a comment.

Apply reviewer suggestion.


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

https://reviews.llvm.org/D55269

Files:
  clang/lib/Driver/ToolChains/Cuda.cpp


Index: clang/lib/Driver/ToolChains/Cuda.cpp
===
--- clang/lib/Driver/ToolChains/Cuda.cpp
+++ clang/lib/Driver/ToolChains/Cuda.cpp
@@ -114,7 +114,7 @@
 for (const char *Ver : Versions)
   Candidates.emplace_back(D.SysRoot + "/usr/local/cuda-" + Ver);
 
-if (Distro(D.getVFS()).IsDebian())
+if (Distro(D.getVFS()).IsDebian() || Distro(D.getVFS()).IsUbuntu())
   // Special case for Debian to have nvidia-cuda-toolkit work
   // out of the box. More info on http://bugs.debian.org/882505
   Candidates.emplace_back(D.SysRoot + "/usr/lib/cuda");


Index: clang/lib/Driver/ToolChains/Cuda.cpp
===
--- clang/lib/Driver/ToolChains/Cuda.cpp
+++ clang/lib/Driver/ToolChains/Cuda.cpp
@@ -114,7 +114,7 @@
 for (const char *Ver : Versions)
   Candidates.emplace_back(D.SysRoot + "/usr/local/cuda-" + Ver);
 
-if (Distro(D.getVFS()).IsDebian())
+if (Distro(D.getVFS()).IsDebian() || Distro(D.getVFS()).IsUbuntu())
   // Special case for Debian to have nvidia-cuda-toolkit work
   // out of the box. More info on http://bugs.debian.org/882505
   Candidates.emplace_back(D.SysRoot + "/usr/lib/cuda");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r348448 - [darwin] remove version number check when enabling -fobjc-subscripting-legacy-runtime

2018-12-05 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Wed Dec  5 18:44:23 2018
New Revision: 348448

URL: http://llvm.org/viewvc/llvm-project?rev=348448&view=rev
Log:
[darwin] remove version number check when enabling 
-fobjc-subscripting-legacy-runtime

This subscripting feature actually works on older OS versions anyway.

rdar://36287065

Modified:
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/test/Driver/rewrite-legacy-objc.m

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=348448&r1=348447&r2=348448&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Wed Dec  5 18:44:23 2018
@@ -2828,7 +2828,6 @@ static void RenderObjCOptions(const Tool
   // When ObjectiveC legacy runtime is in effect on MacOSX, turn on the option
   // to do Array/Dictionary subscripting by default.
   if (Arch == llvm::Triple::x86 && T.isMacOSX() &&
-  !T.isMacOSXVersionLT(10, 7) &&
   Runtime.getKind() == ObjCRuntime::FragileMacOSX && 
Runtime.isNeXTFamily())
 CmdArgs.push_back("-fobjc-subscripting-legacy-runtime");
 

Modified: cfe/trunk/test/Driver/rewrite-legacy-objc.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/rewrite-legacy-objc.m?rev=348448&r1=348447&r2=348448&view=diff
==
--- cfe/trunk/test/Driver/rewrite-legacy-objc.m (original)
+++ cfe/trunk/test/Driver/rewrite-legacy-objc.m Wed Dec  5 18:44:23 2018
@@ -10,4 +10,4 @@
 // RUN: %clang -no-canonical-prefixes -target i386-apple-macosx10.6.0 
-rewrite-legacy-objc %s -o - -### 2>&1 | \
 // RUN:   FileCheck -check-prefix=TEST2 %s
 // TEST1: "-fmessage-length" "0" "-stack-protector" "1" "-fblocks" 
"-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" 
"-fobjc-runtime=macosx-fragile" "-fobjc-subscripting-legacy-runtime" 
"-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fmax-type-align=16" 
"-fdiagnostics-show-option"
-// TEST2: "-fmessage-length" "0" "-stack-protector" "1" "-fblocks" 
"-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" 
"-fobjc-runtime=macosx-fragile" "-fno-objc-infer-related-result-type" 
"-fobjc-exceptions" "-fmax-type-align=16" "-fdiagnostics-show-option"
+// TEST2: "-fmessage-length" "0" "-stack-protector" "1" "-fblocks" 
"-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" 
"-fobjc-runtime=macosx-fragile" "-fobjc-subscripting-legacy-runtime" 
"-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fmax-type-align=16" 
"-fdiagnostics-show-option"


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


[PATCH] D55346: [clang-tidy] check for using declaration scope and qualification

2018-12-05 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tidy/abseil/AnonymousEnclosedAliasesCheck.cpp:31
+
+
+void AnonymousEnclosedAliasesCheck::check(const MatchFinder::MatchResult 
&Result) {

Please remove unnecessary empty line.



Comment at: clang-tidy/abseil/AnonymousEnclosedAliasesCheck.cpp:33
+void AnonymousEnclosedAliasesCheck::check(const MatchFinder::MatchResult 
&Result) {
+  
+  const UsingDecl *MatchedUsingDecl = 

Please remove unnecessary empty line.



Comment at: clang-tidy/abseil/AnonymousEnclosedAliasesCheck.cpp:34
+  
+  const UsingDecl *MatchedUsingDecl = 
+   Result.Nodes.getNodeAs("using_decl");

const auto *



Comment at: clang-tidy/abseil/QualifiedAliasesCheck.cpp:13
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+#include 

Please remove unnecessary empty line.



Comment at: clang-tidy/abseil/SafelyScopedCheck.cpp:27
+usingDecl(hasParent(namespaceDecl(forEach(namespaceDecl() )
+).bind("use"), this);
+}

Please run Clang-format over patch.



Comment at: docs/ReleaseNotes.rst:73
+
+  Flags using declarations in header files, and suggests that 
+  these aliases be removed.

Please enclose using in ``. Same in other places, including documentation.



Comment at: docs/clang-tidy/checks/abseil-alias-free-headers.rst:10
+accept the specified alias. This is bad practice, which is why the check 
suggests
+such declarations be removed. 

Are there guidelines?



Comment at: docs/clang-tidy/checks/abseil-qualified-aliases.rst:24
+check. 
+ 

Please remove unnecessary empty line.



Comment at: docs/clang-tidy/checks/abseil-safely-scoped.rst:28
+See https://abseil.io/tips/119 for more explanation. 
+

Please remove unnecessary empty line.



Comment at: test/clang-tidy/abseil-qualified-aliases.cpp:27
+} // namespace example
+

Please remove unnecessary empty line.



Comment at: test/clang-tidy/abseil-safely-scoped.cpp:27
+}  // namespace foo
+

Please remove unnecessary empty line.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D55346



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


r348447 - Reapply fix from r348062 to fix test on Windows.

2018-12-05 Thread Douglas Yung via cfe-commits
Author: dyung
Date: Wed Dec  5 18:13:09 2018
New Revision: 348447

URL: http://llvm.org/viewvc/llvm-project?rev=348447&view=rev
Log:
Reapply fix from r348062 to fix test on Windows.


Modified:
cfe/trunk/test/CodeGenCXX/debug-prefix-map-lambda.cpp

Modified: cfe/trunk/test/CodeGenCXX/debug-prefix-map-lambda.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-prefix-map-lambda.cpp?rev=348447&r1=348446&r2=348447&view=diff
==
--- cfe/trunk/test/CodeGenCXX/debug-prefix-map-lambda.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/debug-prefix-map-lambda.cpp Wed Dec  5 18:13:09 
2018
@@ -4,7 +4,7 @@
 template  void b(T) {}
 void c() {
   // CHECK: !DISubprogram(name: "b<(lambda at
-  // CHECK-SAME:  /SOURCE_ROOT/debug-prefix-map-lambda.cpp
+  // CHECK-SAME:  SOURCE_ROOT
   // CHECK-SAME:  [[@LINE+1]]:{{[0-9]+}})>"
   b([]{});
 }


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


[PATCH] D55349: Convert some ObjC alloc msgSends to runtime calls

2018-12-05 Thread Pete Cooper via Phabricator via cfe-commits
pete created this revision.
pete added reviewers: ahatanak, rjmccall, erik.pilkington.
Herald added a subscriber: cfe-commits.

It is faster to directly call the ObjC runtime for methods such as 
alloc/allocWithZone instead of sending a message to those functions.

This patch adds support for converting messages to alloc/allocWithZone to their 
equivalent runtime calls.

Tests included for the positive case of applying this transformation, negative 
tests that we ensure we only convert "alloc" to objc_alloc, not "alloc2", and 
also a driver test to ensure we enable this only for supported runtime versions.


Repository:
  rC Clang

https://reviews.llvm.org/D55349

Files:
  include/clang/Basic/ObjCRuntime.h
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CGObjC.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/CodeGenModule.h
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGenObjC/convert-messages-to-runtime-calls.m
  test/Driver/objc-convert-messages-to-runtime-calls.m

Index: test/Driver/objc-convert-messages-to-runtime-calls.m
===
--- /dev/null
+++ test/Driver/objc-convert-messages-to-runtime-calls.m
@@ -0,0 +1,7 @@
+// RUN: %clang %s -### -o %t.o 2>&1 -fsyntax-only -fobjc-convert-messages-to-runtime-calls -fno-objc-convert-messages-to-runtime-calls -target x86_64-apple-macosx10.10.0 | FileCheck  %s --check-prefix=DISABLE
+// RUN: %clang %s -### -o %t.o 2>&1 -fsyntax-only -fno-objc-convert-messages-to-runtime-calls -fobjc-convert-messages-to-runtime-calls -target x86_64-apple-macosx10.10.0 | FileCheck  %s --check-prefix=ENABLE
+
+// Check that we pass fobjc-convert-messages-to-runtime-calls only when supported, and not explicitly disabled.
+
+// DISABLE: "-fno-objc-convert-messages-to-runtime-calls"
+// ENABLE-NOT: "-fno-objc-convert-messages-to-runtime-calls"
Index: test/CodeGenObjC/convert-messages-to-runtime-calls.m
===
--- /dev/null
+++ test/CodeGenObjC/convert-messages-to-runtime-calls.m
@@ -0,0 +1,66 @@
+// RUN: %clang_cc1 -fobjc-runtime=macosx-10.10.0 -emit-llvm -o - %s -fno-objc-convert-messages-to-runtime-calls | FileCheck %s --check-prefix=MSGS
+// RUN: %clang_cc1 -fobjc-runtime=macosx-10.10.0 -emit-llvm -o - %s | FileCheck %s --check-prefix=CALLS
+// RUN: %clang_cc1 -fobjc-runtime=macosx-10.9.0 -emit-llvm -o - %s | FileCheck %s --check-prefix=MSGS
+// RUN: %clang_cc1 -fobjc-runtime=macosx-fragile-10.10.0 -emit-llvm -o - %s | FileCheck %s --check-prefix=MSGS
+// RUN: %clang_cc1 -fobjc-runtime=ios-8.0 -emit-llvm -o - %s | FileCheck %s --check-prefix=CALLS
+// RUN: %clang_cc1 -fobjc-runtime=ios-7.0 -emit-llvm -o - %s | FileCheck %s --check-prefix=MSGS
+// Note: This line below is for tvos for which the driver passes through to use the ios9.0 runtime.
+// RUN: %clang_cc1 -fobjc-runtime=ios-9.0 -emit-llvm -o - %s | FileCheck %s --check-prefix=CALLS
+// RUN: %clang_cc1 -fobjc-runtime=watchos-2.0 -emit-llvm -o - %s | FileCheck %s --check-prefix=CALLS
+
+#define nil (id)0
+
+@interface NSObject
++ (id)alloc;
++ (id)allocWithZone:(void*)zone;
++ (id)alloc2;
+@end
+
+// CHECK-LABEL: define {{.*}}void @test1
+void test1(id x) {
+  // MSGS: {{call.*@objc_msgSend}}
+  // CALLS: {{call.*@objc_alloc}}
+  [NSObject alloc];
+  [NSObject allocWithZone:nil];
+}
+
+// CHECK-LABEL: define {{.*}}void @test2
+void test2(void* x) {
+  // MSGS: {{call.*@objc_msgSend}}
+  // MSGS: {{call.*@objc_msgSend}}
+  // MSGS: {{call.*@objc_msgSend}}
+  // CALLS: {{call.*@objc_msgSend}}
+  // CALLS: {{call.*@objc_msgSend}}
+  // CALLS: {{call.*@objc_msgSend}}
+  [NSObject alloc2];
+  [NSObject allocWithZone:(void*)-1];
+  [NSObject allocWithZone:x];
+}
+
+@class A;
+@interface B
++ (A*) alloc;
++ (A*)allocWithZone:(void*)zone;
+@end
+
+// Make sure we get a bitcast on the return type as the
+// call will return i8* which we have to cast to A*
+// CHECK-LABEL: define {{.*}}void @test_alloc_class_ptr
+A* test_alloc_class_ptr() {
+  // CALLS: {{call.*@objc_alloc}}
+  // CALLS-NEXT: bitcast i8*
+  // CALLS-NEXT: ret
+  return [B alloc];
+}
+
+// Make sure we get a bitcast on the return type as the
+// call will return i8* which we have to cast to A*
+// CHECK-LABEL: define {{.*}}void @test_alloc_class_ptr
+A* test_allocWithZone_class_ptr() {
+  // CALLS: {{call.*@objc_alloc}}
+  // CALLS-NEXT: bitcast i8*
+  // CALLS-NEXT: ret
+  return [B allocWithZone:nil];
+}
+
+
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -1155,6 +1155,10 @@
 }
   }
 
+
+  if (Args.hasArg(OPT_fno_objc_convert_messages_to_runtime_calls))
+Opts.ObjCConvertMessagesToRuntimeCalls = 0;
+
   if (Args.getLastArg(OPT_femulated_tls) ||
   Args.getLastArg(OPT_fno_emulated_tls)) {
 Opts.ExplicitEmulatedTLS =

r348443 - [attributes] Add more tests for os_returns_retained

2018-12-05 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Wed Dec  5 17:21:38 2018
New Revision: 348443

URL: http://llvm.org/viewvc/llvm-project?rev=348443&view=rev
Log:
[attributes] Add more tests for os_returns_retained

Modified:
cfe/trunk/test/Sema/attr-osobject.mm

Modified: cfe/trunk/test/Sema/attr-osobject.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-osobject.mm?rev=348443&r1=348442&r2=348443&view=diff
==
--- cfe/trunk/test/Sema/attr-osobject.mm (original)
+++ cfe/trunk/test/Sema/attr-osobject.mm Wed Dec  5 17:21:38 2018
@@ -1,6 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
-
-// expected-no-diagnostics
+// RUN: %clang_cc1 -fsyntax-only -verify -fblocks %s
 
 struct S {};
 
@@ -9,3 +7,9 @@ struct S {};
   - (S*) generateS __attribute__((os_returns_retained));
   - (void) takeS:(S*) __attribute__((os_consumed)) s;
 @end
+
+typedef __attribute__((os_returns_retained)) id (^blockType)(); // 
expected-warning{{'os_returns_retained' attribute only applies to functions, 
Objective-C methods, and Objective-C properties}}
+
+__auto_type b = ^ id (id filter)  __attribute__((os_returns_retained))  { // 
expected-warning{{'os_returns_retained' attribute only applies to functions, 
Objective-C methods, and Objective-C properties}}
+  return filter;
+};


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


[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-12-05 Thread Leonard Chan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC348442: [Sema/Attribute] Check for noderef attribute 
(authored by leonardchan, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D49511?vs=176907&id=176908#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D49511

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/AST/TypePrinter.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprMember.cpp
  lib/Sema/SemaInit.cpp
  lib/Sema/SemaType.cpp
  test/Frontend/noderef.c
  test/Frontend/noderef.cpp
  test/Frontend/noderef_on_non_pointers.m
  test/Frontend/noderef_templates.cpp

Index: lib/AST/TypePrinter.cpp
===
--- lib/AST/TypePrinter.cpp
+++ lib/AST/TypePrinter.cpp
@@ -1508,6 +1508,9 @@
   case attr::PreserveAll:
 OS << "preserve_all";
 break;
+  case attr::NoDeref:
+OS << "noderef";
+break;
   }
   OS << "))";
 }
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -183,11 +183,15 @@
 SmallVector AttrsForTypes;
 bool AttrsForTypesSorted = true;
 
+/// Flag to indicate we parsed a noderef attribute. This is used for
+/// validating that noderef was used on a pointer or array.
+bool parsedNoDeref;
+
   public:
 TypeProcessingState(Sema &sema, Declarator &declarator)
-  : sema(sema), declarator(declarator),
-chunkIndex(declarator.getNumTypeObjects()),
-trivial(true), hasSavedAttrs(false) {}
+: sema(sema), declarator(declarator),
+  chunkIndex(declarator.getNumTypeObjects()), trivial(true),
+  hasSavedAttrs(false), parsedNoDeref(false) {}
 
 Sema &getSema() const {
   return sema;
@@ -278,6 +282,10 @@
   llvm_unreachable("no Attr* for AttributedType*");
 }
 
+void setParsedNoDeref(bool parsed) { parsedNoDeref = parsed; }
+
+bool didParseNoDeref() const { return parsedNoDeref; }
+
 ~TypeProcessingState() {
   if (trivial) return;
 
@@ -3887,6 +3895,11 @@
   return false;
 }
 
+static bool IsNoDerefableChunk(DeclaratorChunk Chunk) {
+  return (Chunk.Kind == DeclaratorChunk::Pointer ||
+  Chunk.Kind == DeclaratorChunk::Array);
+}
+
 template
 static AttrT *createSimpleAttr(ASTContext &Ctx, ParsedAttr &Attr) {
   Attr.setUsedAsTypeAttr();
@@ -4280,6 +4293,9 @@
 }
   }
 
+  bool ExpectNoDerefChunk =
+  state.getCurrentAttributes().hasAttribute(ParsedAttr::AT_NoDeref);
+
   // Walk the DeclTypeInfo, building the recursive type as we go.
   // DeclTypeInfos are ordered from the identifier out, which is
   // opposite of what we want :).
@@ -4889,8 +4905,22 @@
 
 // See if there are any attributes on this declarator chunk.
 processTypeAttrs(state, T, TAL_DeclChunk, DeclType.getAttrs());
+
+if (DeclType.Kind != DeclaratorChunk::Paren) {
+  if (ExpectNoDerefChunk) {
+if (!IsNoDerefableChunk(DeclType))
+  S.Diag(DeclType.Loc, diag::warn_noderef_on_non_pointer_or_array);
+ExpectNoDerefChunk = false;
+  }
+
+  ExpectNoDerefChunk = state.didParseNoDeref();
+}
   }
 
+  if (ExpectNoDerefChunk)
+S.Diag(state.getDeclarator().getBeginLoc(),
+   diag::warn_noderef_on_non_pointer_or_array);
+
   // GNU warning -Wstrict-prototypes
   //   Warn if a function declaration is without a prototype.
   //   This warning is issued for all kinds of unprototyped function
@@ -7271,6 +7301,9 @@
   // sure we visit every element once. Copy the attributes list, and iterate
   // over that.
   ParsedAttributesView AttrsCopy{attrs};
+
+  state.setParsedNoDeref(false);
+
   for (ParsedAttr &attr : AttrsCopy) {
 
 // Skip attributes that were marked to be invalid.
@@ -7368,6 +7401,15 @@
 HandleLifetimeBoundAttr(state, type, attr);
   break;
 
+case ParsedAttr::AT_NoDeref: {
+  ASTContext &Ctx = state.getSema().Context;
+  type = state.getAttributedType(createSimpleAttr(Ctx, attr),
+ type, type);
+  attr.setUsedAsTypeAttr();
+  state.setParsedNoDeref(true);
+  break;
+}
+
 MS_TYPE_ATTRS_CASELIST:
   if (!handleMSPointerTypeQualifierAttr(state, attr, type))
 attr.setUsedAsTypeAttr();
Index: lib/Sema/SemaInit.cpp
===
--- lib/Sema/SemaInit.cpp
+++ lib/Sema/SemaInit.cpp
@@ -7687,6 +7687,18 @@
 
 case SK_ConversionSequence:
 case SK_ConversionSequenceNoNarrowing: {
+  if (const auto *FromPtrType =
+  CurInit.get()->getType()->getAs()) {
+if (const auto *ToPtrType = Step->Type->getAs()) {
+  if (FromPtrType->getPointeeType()->hasAttr(attr::NoDeref)

r348442 - [Sema/Attribute] Check for noderef attribute

2018-12-05 Thread Leonard Chan via cfe-commits
Author: leonardchan
Date: Wed Dec  5 17:05:54 2018
New Revision: 348442

URL: http://llvm.org/viewvc/llvm-project?rev=348442&view=rev
Log:
[Sema/Attribute] Check for noderef attribute

This patch adds the noderef attribute in clang and checks for dereferences of
types that have this attribute. This attribute is currently used by sparse and
would like to be ported to clang.

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

Added:
cfe/trunk/test/Frontend/noderef.c
cfe/trunk/test/Frontend/noderef.cpp
cfe/trunk/test/Frontend/noderef_on_non_pointers.m
cfe/trunk/test/Frontend/noderef_templates.cpp
Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/AttrDocs.td
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/TypePrinter.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaExprMember.cpp
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/lib/Sema/SemaType.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=348442&r1=348441&r2=348442&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Wed Dec  5 17:05:54 2018
@@ -1822,6 +1822,11 @@ def Regparm : TypeAttr {
   let ASTNode = 0;
 }
 
+def NoDeref : TypeAttr {
+  let Spellings = [Clang<"noderef">];
+  let Documentation = [NoDerefDocs];
+}
+
 def ReqdWorkGroupSize : InheritableAttr {
   // Does not have a [[]] spelling because it is an OpenCL-related attribute.
   let Spellings = [GNU<"reqd_work_group_size">];

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=348442&r1=348441&r2=348442&view=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Wed Dec  5 17:05:54 2018
@@ -3593,6 +3593,63 @@ corresponding line within the inlined ca
   }];
 }
 
+def NoDerefDocs : Documentation {
+  let Category = DocCatType;
+  let Content = [{
+The ``noderef`` attribute causes clang to diagnose dereferences of annotated 
pointer types.
+This is ideally used with pointers that point to special memory which cannot 
be read
+from or written to, but allowing for the pointer to be used in pointer 
arithmetic.
+The following are examples of valid expressions where dereferences are 
diagnosed:
+
+.. code-block:: c
+
+  int __attribute__((noderef)) *p;
+  int x = *p;  // warning
+
+  int __attribute__((noderef)) **p2;
+  x = **p2;  // warning
+
+  int * __attribute__((noderef)) *p3;
+  p = *p3;  // warning
+
+  struct S {
+int a;
+  };
+  struct S __attribute__((noderef)) *s;
+  x = s->a;// warning
+  x = (*s).a;  // warning
+
+Not all dereferences may diagnose a warning if the value directed by the 
pointer may not be
+accessed. The following are examples of valid expressions where may not be 
diagnosed:
+
+.. code-block:: c
+
+  int *q;
+  int __attribute__((noderef)) *p;
+  q = &*p;
+  q = *&p;
+
+  struct S {
+int a;
+  };
+  struct S __attribute__((noderef)) *s;
+  p = &s->a;
+  p = &(*s).a;
+
+``noderef`` is currently only supported for pointers and arrays and not usable 
for
+references or Objective-C object pointers.
+
+.. code-block: c++
+
+  int x = 2;
+  int __attribute__((noderef)) &y = x;  // warning: 'noderef' can only be used 
on an array or pointer type
+
+.. code-block: objc
+
+  id __attribute__((noderef)) obj = [NSObject new]; // warning: 'noderef' can 
only be used on an array or pointer type
+}];
+}
+
 def ReinitializesDocs : Documentation {
   let Category = DocCatFunction;
   let Content = [{

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=348442&r1=348441&r2=348442&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Wed Dec  5 17:05:54 2018
@@ -1039,3 +1039,5 @@ def ExperimentalISel : DiagGroup<"experi
 // A warning group specifically for warnings related to function
 // multiversioning.
 def FunctionMultiVersioning : DiagGroup<"function-multiversion">;
+
+def NoDeref : DiagGroup<"noderef">;

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=348442&r1=348441&r2=348442&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticS

[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-12-05 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 176907.
leonardchan marked an inline comment as done.

Repository:
  rC Clang

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

https://reviews.llvm.org/D49511

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/TypePrinter.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprMember.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/Frontend/noderef.c
  clang/test/Frontend/noderef.cpp
  clang/test/Frontend/noderef_on_non_pointers.m
  clang/test/Frontend/noderef_templates.cpp

Index: clang/test/Frontend/noderef_templates.cpp
===
--- /dev/null
+++ clang/test/Frontend/noderef_templates.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -verify %s
+
+#define NODEREF __attribute__((noderef))
+
+template 
+int func(T NODEREF *a) { // expected-note 2 {{a declared here}}
+  return *a + 1; // expected-warning 2 {{dereferencing a; was declared with a 'noderef' type}}
+}
+
+void func() {
+  float NODEREF *f;
+  int NODEREF *i;
+  func(f); // expected-note{{in instantiation of function template specialization 'func' requested here}}
+  func(i); // expected-note{{in instantiation of function template specialization 'func' requested here}}
+}
Index: clang/test/Frontend/noderef_on_non_pointers.m
===
--- /dev/null
+++ clang/test/Frontend/noderef_on_non_pointers.m
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -verify %s
+
+#define NODEREF __attribute__((noderef))
+
+@interface NSObject
++ (id)new;
+@end
+
+void func() {
+  id NODEREF obj = [NSObject new]; // expected-warning{{'noderef' can only be used on an array or pointer type}}
+}
Index: clang/test/Frontend/noderef.cpp
===
--- /dev/null
+++ clang/test/Frontend/noderef.cpp
@@ -0,0 +1,102 @@
+// RUN: %clang_cc1 -fblocks -verify %s
+
+/**
+ * Test 'noderef' attribute with c++ constructs.
+ */
+
+#define NODEREF __attribute__((noderef))
+
+void Normal() {
+  int NODEREF i;// expected-warning{{'noderef' can only be used on an array or pointer type}}
+  int NODEREF *i_ptr;   // expected-note 2 {{i_ptr declared here}}
+  int NODEREF **i_ptr2; // ok
+  int *NODEREF i_ptr3;  // expected-warning{{'noderef' can only be used on an array or pointer type}}
+  int *NODEREF *i_ptr4; // ok
+
+  auto NODEREF *auto_i_ptr = i_ptr;
+  auto NODEREF auto_i = i; // expected-warning{{'noderef' can only be used on an array or pointer type}}
+
+  struct {
+int x;
+int y;
+  } NODEREF *s;
+
+  int __attribute__((noderef(10))) * no_args; // expected-error{{'noderef' attribute takes no arguments}}
+
+  int i2 = *i_ptr; // expected-warning{{dereferencing i_ptr; was declared with a 'noderef' type}}
+  int &i3 = *i_ptr;// expected-warning{{dereferencing i_ptr; was declared with a 'noderef' type}}
+  int *i_ptr5 = i_ptr; // expected-warning{{casting to dereferenceable pointer removes 'noderef' attribute}}
+  int *i_ptr6(i_ptr);  // expected-warning{{casting to dereferenceable pointer removes 'noderef' attribute}}
+}
+
+const int NODEREF *const_i_ptr;
+static int NODEREF *static_i_ptr;
+
+void ParenTypes() {
+  int NODEREF(*i_ptr);// ok (same as `int NODEREF *`)
+  int NODEREF *(*i_ptr2); // ok (same as `int NODEREF **`)
+}
+
+// Function declarations
+int NODEREF func();   // expected-warning{{'noderef' can only be used on an array or pointer type}}
+int NODEREF *func2(); // ok (returning pointer)
+
+typedef int NODEREF (*func3)(int); // expected-warning{{'noderef' can only be used on an array or pointer type}}
+typedef int NODEREF *(*func4)(int);
+
+void Arrays() {
+  int NODEREF i_arr[10];  // ok
+  int NODEREF i_arr2[10][10]; // ok
+  int NODEREF *i_arr3[10];// ok
+  int NODEREF i_arr4[] = {1, 2};
+}
+
+void ParenArrays() {
+  int NODEREF(i_ptr[10]);
+  int NODEREF(i_ptr2[10])[10];
+}
+
+typedef int NODEREF *(*func5[10])(int);
+
+// Arguments
+void func6(int NODEREF x); // expected-warning{{'noderef' can only be used on an array or pointer type}}
+void func7(int NODEREF *x);
+void func8() NODEREF;
+
+void References() {
+  int x = 2;
+  int NODEREF &y = x; // expected-warning{{'noderef' can only be used on an array or pointer type}}
+  int *xp = &x;
+  int NODEREF *&a = xp; // ok (reference to a NODEREF *)
+  int *NODEREF &b = xp; // expected-warning{{'noderef' can only be used on an array or pointer type}}
+}
+
+void BlockPointers() {
+  typedef int NODEREF (^IntBlock)(); // expected-warning{{'noderef' can only be used on an array or pointer type}}
+}
+
+class A {
+public:
+  int member;
+  int NODEREF *member2;
+  int NODEREF member3; // expected-warning{{'noderef' can only be used on an array or pointer type}}
+};
+

[PATCH] D55346: [clang-tidy] check for using declaration scope and qualification

2018-12-05 Thread Shyan Akmal via Phabricator via cfe-commits
Naysh created this revision.
Naysh added reviewers: EricWF, JonasToth.
Herald added subscribers: cfe-commits, xazax.hun, mgorny.

This patch adds four new, small checks corresponding to the guidelines in 
https://abseil.io/tips/119.

The checks are:

- Alias Free Headers: makes sure header files do not use convenience aliases
- Anonymous Enclosed Aliases: suggests that using declarations be moved to 
existing anonymous namespaces
- Qualified Aliases: suggests using declarations be fully qualified
- Safely Scoped: suggests using declarations be moved to innermost namespaces


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D55346

Files:
  .gitignore
  clang-tidy/abseil/AbseilTidyModule.cpp
  clang-tidy/abseil/AliasFreeHeadersCheck.cpp
  clang-tidy/abseil/AliasFreeHeadersCheck.h
  clang-tidy/abseil/AnonymousEnclosedAliasesCheck.cpp
  clang-tidy/abseil/AnonymousEnclosedAliasesCheck.h
  clang-tidy/abseil/CMakeLists.txt
  clang-tidy/abseil/QualifiedAliasesCheck.cpp
  clang-tidy/abseil/QualifiedAliasesCheck.h
  clang-tidy/abseil/SafelyScopedCheck.cpp
  clang-tidy/abseil/SafelyScopedCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/abseil-alias-free-headers.rst
  docs/clang-tidy/checks/abseil-anonymous-enclosed-aliases.rst
  docs/clang-tidy/checks/abseil-qualified-aliases.rst
  docs/clang-tidy/checks/abseil-safely-scoped.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/abseil-alias-free-headers.hpp
  test/clang-tidy/abseil-anonymous-enclosed-aliases.cpp
  test/clang-tidy/abseil-qualified-aliases.cpp
  test/clang-tidy/abseil-safely-scoped.cpp
  test/clang-tidy/temporaries.cpp

Index: test/clang-tidy/temporaries.cpp
===
--- test/clang-tidy/temporaries.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-// REQUIRES: static-analyzer
-// RUN: clang-tidy -checks='-*,clang-analyzer-core.NullDereference' %s -- | FileCheck %s
-
-struct NoReturnDtor {
-  ~NoReturnDtor() __attribute__((noreturn));
-};
-
-extern bool check(const NoReturnDtor &);
-
-// CHECK-NOT: warning
-void testNullPointerDereferencePositive() {
-  int *value = 0;
-  // CHECK: [[@LINE+1]]:10: warning: Dereference of null pointer (loaded from variable 'value') [clang-analyzer-core.NullDereference]
-  *value = 1;
-}
-
-// CHECK-NOT: warning
-void testNullPointerDereference() {
-  int *value = 0;
-  if (check(NoReturnDtor())) {
-// This unreachable code causes a warning if analysis of temporary
-// destructors is not enabled.
-*value = 1;
-  }
-}
Index: test/clang-tidy/abseil-safely-scoped.cpp
===
--- /dev/null
+++ test/clang-tidy/abseil-safely-scoped.cpp
@@ -0,0 +1,27 @@
+// RUN: %check_clang_tidy %s abseil-safely-scoped %t
+namespace bar {
+
+class something {
+
+};
+}
+
+namespace foo {
+
+using bar::something;
+
+namespace {
+
+}  // anonymous namespace
+}  // namespace foo
+// CHECK-MESSAGES: :[[@LINE-6]]:12: warning: UsingDecl 'something' should be in the innermost scope. See: https://abseil.io/tips/119 [abseil-safely-scoped]
+
+namespace foo {
+
+namespace {
+
+using ::bar::something;
+
+}  // anonymous namespace
+}  // namespace foo
+
Index: test/clang-tidy/abseil-qualified-aliases.cpp
===
--- /dev/null
+++ test/clang-tidy/abseil-qualified-aliases.cpp
@@ -0,0 +1,27 @@
+// RUN: %check_clang_tidy %s abseil-qualified-aliases %t
+
+namespace foo {
+  void f();
+  void correct();
+}
+
+namespace bar {
+  using foo::f;
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: using declaration is not fully qualified: see https://abseil.io/tips/119 [abseil-qualified-aliases]
+  using ::foo::correct;
+}
+
+namespace outermost {
+  namespace middle {
+namespace innermost {
+
+  enum Color {Red, Blue, Yellow};
+
+} // namespace innermost
+
+using innermost::Color;
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: using declaration is not fully qualified: see https://abseil.io/tips/119 [abseil-qualified-aliases]
+
+  } // namespace middle
+} // namespace example
+
Index: test/clang-tidy/abseil-anonymous-enclosed-aliases.cpp
===
--- /dev/null
+++ test/clang-tidy/abseil-anonymous-enclosed-aliases.cpp
@@ -0,0 +1,27 @@
+// RUN: %check_clang_tidy %s abseil-anonymous-enclosed-aliases %t
+namespace bar {
+
+class something {
+
+};
+}
+
+namespace foo {
+
+using bar::something;
+
+namespace {
+
+}  // anonymous namespace
+}  // namespace foo
+// CHECK-MESSAGES: :[[@LINE-6]]:12: warning: UsingDecl 'something' should be in the anonymous namespace. See: https://abseil.io/tips/119 [abseil-anonymous-enclosed-aliases]
+
+
+namespace foo {
+
+namespace {
+
+using ::bar::something;
+
+}  // anonymous namespace
+}  // namespace foo
Index: test/clang-tidy/abseil-alias-free-headers.hpp
===
--- /dev/null
+++ test/clang-tidy/abseil-alias-free-h

[PATCH] D54401: [analyzer] Prefer returns values to out-params in CheckerRegistry.cpp

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

In D54401#1318282 , @alexfh wrote:

> In D54401#1315354 , @NoQ wrote:
>
> > The code looks good, but i vaguely remember that we might accidentally 
> > break clang-tidy integration that uses this API to enable/disable specific 
> > checkers via `-checks=-analyzer-...`.
> >
> > *summons @alexfh*
>
>
> It's hard to tell without trying. Could you build and test clang-tools-extra 
> with this patch? There should be a test for the relevant functionality in 
> clang-tidy.


It compiles without problem, and `check-all` doesn't produce a single 
`clang-tools-extra` failure. Yay!


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

https://reviews.llvm.org/D54401



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


r348434 - [Sema] Push and Pop Expression Evaluation Context Records at the start and end of function definitions

2018-12-05 Thread Leonard Chan via cfe-commits
Author: leonardchan
Date: Wed Dec  5 16:10:36 2018
New Revision: 348434

URL: http://llvm.org/viewvc/llvm-project?rev=348434&view=rev
Log:
[Sema] Push and Pop Expression Evaluation Context Records at the start and end 
of function definitions

This patch creates a new context for every function definition we enter.
Currently we do not push and pop on these, usually working off of the global
context record added in the Sema constructor, which never gets popped.

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

Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=348434&r1=348433&r2=348434&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Dec  5 16:10:36 2018
@@ -12828,6 +12828,7 @@ Decl *Sema::ActOnStartOfFunctionDef(Scop
 // Parsing the function declaration failed in some way. Push on a fake 
scope
 // anyway so we can try to parse the function body.
 PushFunctionScope();
+PushExpressionEvaluationContext(ExprEvalContexts.back().Context);
 return D;
   }
 
@@ -12838,6 +12839,11 @@ Decl *Sema::ActOnStartOfFunctionDef(Scop
   else
 FD = cast(D);
 
+  // Do not push if it is a lambda because one is already pushed when building
+  // the lambda in ActOnStartOfLambdaDefinition().
+  if (!isLambdaCallOperator(FD))
+PushExpressionEvaluationContext(ExprEvalContexts.back().Context);
+
   // Check for defining attributes before the check for redefinition.
   if (const auto *Attr = FD->getAttr()) {
 Diag(Attr->getLocation(), diag::err_alias_is_definition) << FD << 0;
@@ -13046,6 +13052,21 @@ Decl *Sema::ActOnFinishFunctionBody(Decl
   return ActOnFinishFunctionBody(D, BodyArg, false);
 }
 
+/// RAII object that pops an ExpressionEvaluationContext when exiting a 
function
+/// body.
+class ExitFunctionBodyRAII {
+public:
+  ExitFunctionBodyRAII(Sema &S, bool IsLambda) : S(S), IsLambda(IsLambda) {}
+  ~ExitFunctionBodyRAII() {
+if (!IsLambda)
+  S.PopExpressionEvaluationContext();
+  }
+
+private:
+  Sema &S;
+  bool IsLambda = false;
+};
+
 Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt *Body,
 bool IsInstantiation) {
   FunctionDecl *FD = dcl ? dcl->getAsFunction() : nullptr;
@@ -13056,6 +13077,11 @@ Decl *Sema::ActOnFinishFunctionBody(Decl
   if (getLangOpts().CoroutinesTS && getCurFunction()->isCoroutine())
 CheckCompletedCoroutineBody(FD, Body);
 
+  // Do not call PopExpressionEvaluationContext() if it is a lambda because one
+  // is already popped when finishing the lambda in BuildLambdaExpr(). This is
+  // meant to pop the context added in ActOnStartOfFunctionDef().
+  ExitFunctionBodyRAII ExitRAII(*this, isLambdaCallOperator(FD));
+
   if (FD) {
 FD->setBody(Body);
 FD->setWillHaveBody(false);

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=348434&r1=348433&r2=348434&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Wed Dec  5 16:10:36 2018
@@ -363,6 +363,8 @@ void Sema::ActOnStartOfObjCMethodDef(Sco
   assert((getCurMethodDecl() == nullptr) && "Methodparsing confused");
   ObjCMethodDecl *MDecl = dyn_cast_or_null(D);
 
+  PushExpressionEvaluationContext(ExprEvalContexts.back().Context);
+
   // If we don't have a valid method decl, simply return.
   if (!MDecl)
 return;

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=348434&r1=348433&r2=348434&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Dec  5 16:10:36 2018
@@ -14414,11 +14414,8 @@ void Sema::PopExpressionEvaluationContex
   // Pop the current expression evaluation context off the stack.
   ExprEvalContexts.pop_back();
 
-  if (!ExprEvalContexts.empty())
-ExprEvalContexts.back().NumTypos += NumTypos;
-  else
-assert(NumTypos == 0 && "There are outstanding typos after popping the "
-"last ExpressionEvaluationContextRecord");
+  // The global expression evaluation context record is never popped.
+  ExprEvalContexts.back().NumTypos += NumTypos;
 }
 
 void Sema::DiscardCleanupsInEvaluationContext() {


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


[PATCH] D54014: [Sema] Push and Pop Expression Evaluation Context Records at the start and end of function definitions

2018-12-05 Thread Leonard Chan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC348434: [Sema] Push and Pop Expression Evaluation Context 
Records at the start and end… (authored by leonardchan, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D54014?vs=176893&id=176894#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D54014

Files:
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclObjC.cpp
  lib/Sema/SemaExpr.cpp


Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -12828,6 +12828,7 @@
 // Parsing the function declaration failed in some way. Push on a fake 
scope
 // anyway so we can try to parse the function body.
 PushFunctionScope();
+PushExpressionEvaluationContext(ExprEvalContexts.back().Context);
 return D;
   }
 
@@ -12838,6 +12839,11 @@
   else
 FD = cast(D);
 
+  // Do not push if it is a lambda because one is already pushed when building
+  // the lambda in ActOnStartOfLambdaDefinition().
+  if (!isLambdaCallOperator(FD))
+PushExpressionEvaluationContext(ExprEvalContexts.back().Context);
+
   // Check for defining attributes before the check for redefinition.
   if (const auto *Attr = FD->getAttr()) {
 Diag(Attr->getLocation(), diag::err_alias_is_definition) << FD << 0;
@@ -13046,6 +13052,21 @@
   return ActOnFinishFunctionBody(D, BodyArg, false);
 }
 
+/// RAII object that pops an ExpressionEvaluationContext when exiting a 
function
+/// body.
+class ExitFunctionBodyRAII {
+public:
+  ExitFunctionBodyRAII(Sema &S, bool IsLambda) : S(S), IsLambda(IsLambda) {}
+  ~ExitFunctionBodyRAII() {
+if (!IsLambda)
+  S.PopExpressionEvaluationContext();
+  }
+
+private:
+  Sema &S;
+  bool IsLambda = false;
+};
+
 Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt *Body,
 bool IsInstantiation) {
   FunctionDecl *FD = dcl ? dcl->getAsFunction() : nullptr;
@@ -13056,6 +13077,11 @@
   if (getLangOpts().CoroutinesTS && getCurFunction()->isCoroutine())
 CheckCompletedCoroutineBody(FD, Body);
 
+  // Do not call PopExpressionEvaluationContext() if it is a lambda because one
+  // is already popped when finishing the lambda in BuildLambdaExpr(). This is
+  // meant to pop the context added in ActOnStartOfFunctionDef().
+  ExitFunctionBodyRAII ExitRAII(*this, isLambdaCallOperator(FD));
+
   if (FD) {
 FD->setBody(Body);
 FD->setWillHaveBody(false);
Index: lib/Sema/SemaDeclObjC.cpp
===
--- lib/Sema/SemaDeclObjC.cpp
+++ lib/Sema/SemaDeclObjC.cpp
@@ -363,6 +363,8 @@
   assert((getCurMethodDecl() == nullptr) && "Methodparsing confused");
   ObjCMethodDecl *MDecl = dyn_cast_or_null(D);
 
+  PushExpressionEvaluationContext(ExprEvalContexts.back().Context);
+
   // If we don't have a valid method decl, simply return.
   if (!MDecl)
 return;
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -14414,11 +14414,8 @@
   // Pop the current expression evaluation context off the stack.
   ExprEvalContexts.pop_back();
 
-  if (!ExprEvalContexts.empty())
-ExprEvalContexts.back().NumTypos += NumTypos;
-  else
-assert(NumTypos == 0 && "There are outstanding typos after popping the "
-"last ExpressionEvaluationContextRecord");
+  // The global expression evaluation context record is never popped.
+  ExprEvalContexts.back().NumTypos += NumTypos;
 }
 
 void Sema::DiscardCleanupsInEvaluationContext() {


Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -12828,6 +12828,7 @@
 // Parsing the function declaration failed in some way. Push on a fake scope
 // anyway so we can try to parse the function body.
 PushFunctionScope();
+PushExpressionEvaluationContext(ExprEvalContexts.back().Context);
 return D;
   }
 
@@ -12838,6 +12839,11 @@
   else
 FD = cast(D);
 
+  // Do not push if it is a lambda because one is already pushed when building
+  // the lambda in ActOnStartOfLambdaDefinition().
+  if (!isLambdaCallOperator(FD))
+PushExpressionEvaluationContext(ExprEvalContexts.back().Context);
+
   // Check for defining attributes before the check for redefinition.
   if (const auto *Attr = FD->getAttr()) {
 Diag(Attr->getLocation(), diag::err_alias_is_definition) << FD << 0;
@@ -13046,6 +13052,21 @@
   return ActOnFinishFunctionBody(D, BodyArg, false);
 }
 
+/// RAII object that pops an ExpressionEvaluationContext when exiting a function
+/// body.
+class ExitFunctionBodyRAII {
+public:
+  ExitFunctionBodyRAII(Sema &S, bool IsLambda) : S(S), IsLambda(IsLambda) {}
+  ~ExitFunctionBodyRAII() {
+if (!IsLambda)
+  S.PopExpressi

[PATCH] D54014: [Sema] Push and Pop Expression Evaluation Context Records at the start and end of function definitions

2018-12-05 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 176893.
leonardchan marked an inline comment as done.

Repository:
  rC Clang

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

https://reviews.llvm.org/D54014

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclObjC.cpp
  clang/lib/Sema/SemaExpr.cpp


Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -14414,11 +14414,8 @@
   // Pop the current expression evaluation context off the stack.
   ExprEvalContexts.pop_back();
 
-  if (!ExprEvalContexts.empty())
-ExprEvalContexts.back().NumTypos += NumTypos;
-  else
-assert(NumTypos == 0 && "There are outstanding typos after popping the "
-"last ExpressionEvaluationContextRecord");
+  // The global expression evaluation context record is never popped.
+  ExprEvalContexts.back().NumTypos += NumTypos;
 }
 
 void Sema::DiscardCleanupsInEvaluationContext() {
Index: clang/lib/Sema/SemaDeclObjC.cpp
===
--- clang/lib/Sema/SemaDeclObjC.cpp
+++ clang/lib/Sema/SemaDeclObjC.cpp
@@ -363,6 +363,8 @@
   assert((getCurMethodDecl() == nullptr) && "Methodparsing confused");
   ObjCMethodDecl *MDecl = dyn_cast_or_null(D);
 
+  PushExpressionEvaluationContext(ExprEvalContexts.back().Context);
+
   // If we don't have a valid method decl, simply return.
   if (!MDecl)
 return;
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -12828,6 +12828,7 @@
 // Parsing the function declaration failed in some way. Push on a fake 
scope
 // anyway so we can try to parse the function body.
 PushFunctionScope();
+PushExpressionEvaluationContext(ExprEvalContexts.back().Context);
 return D;
   }
 
@@ -12838,6 +12839,11 @@
   else
 FD = cast(D);
 
+  // Do not push if it is a lambda because one is already pushed when building
+  // the lambda in ActOnStartOfLambdaDefinition().
+  if (!isLambdaCallOperator(FD))
+PushExpressionEvaluationContext(ExprEvalContexts.back().Context);
+
   // Check for defining attributes before the check for redefinition.
   if (const auto *Attr = FD->getAttr()) {
 Diag(Attr->getLocation(), diag::err_alias_is_definition) << FD << 0;
@@ -13046,6 +13052,21 @@
   return ActOnFinishFunctionBody(D, BodyArg, false);
 }
 
+/// RAII object that pops an ExpressionEvaluationContext when exiting a 
function
+/// body.
+class ExitFunctionBodyRAII {
+public:
+  ExitFunctionBodyRAII(Sema &S, bool IsLambda) : S(S), IsLambda(IsLambda) {}
+  ~ExitFunctionBodyRAII() {
+if (!IsLambda)
+  S.PopExpressionEvaluationContext();
+  }
+
+private:
+  Sema &S;
+  bool IsLambda = false;
+};
+
 Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt *Body,
 bool IsInstantiation) {
   FunctionDecl *FD = dcl ? dcl->getAsFunction() : nullptr;
@@ -13056,6 +13077,11 @@
   if (getLangOpts().CoroutinesTS && getCurFunction()->isCoroutine())
 CheckCompletedCoroutineBody(FD, Body);
 
+  // Do not call PopExpressionEvaluationContext() if it is a lambda because one
+  // is already popped when finishing the lambda in BuildLambdaExpr(). This is
+  // meant to pop the context added in ActOnStartOfFunctionDef().
+  ExitFunctionBodyRAII ExitRAII(*this, isLambdaCallOperator(FD));
+
   if (FD) {
 FD->setBody(Body);
 FD->setWillHaveBody(false);


Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -14414,11 +14414,8 @@
   // Pop the current expression evaluation context off the stack.
   ExprEvalContexts.pop_back();
 
-  if (!ExprEvalContexts.empty())
-ExprEvalContexts.back().NumTypos += NumTypos;
-  else
-assert(NumTypos == 0 && "There are outstanding typos after popping the "
-"last ExpressionEvaluationContextRecord");
+  // The global expression evaluation context record is never popped.
+  ExprEvalContexts.back().NumTypos += NumTypos;
 }
 
 void Sema::DiscardCleanupsInEvaluationContext() {
Index: clang/lib/Sema/SemaDeclObjC.cpp
===
--- clang/lib/Sema/SemaDeclObjC.cpp
+++ clang/lib/Sema/SemaDeclObjC.cpp
@@ -363,6 +363,8 @@
   assert((getCurMethodDecl() == nullptr) && "Methodparsing confused");
   ObjCMethodDecl *MDecl = dyn_cast_or_null(D);
 
+  PushExpressionEvaluationContext(ExprEvalContexts.back().Context);
+
   // If we don't have a valid method decl, simply return.
   if (!MDecl)
 return;
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -12828,6 +12828,7 @@
 // Parsing the function decl

r348431 - Fix title underlines being too short after r348429

2018-12-05 Thread Pete Cooper via cfe-commits
Author: pete
Date: Wed Dec  5 16:01:44 2018
New Revision: 348431

URL: http://llvm.org/viewvc/llvm-project?rev=348431&view=rev
Log:
Fix title underlines being too short after r348429

Modified:
cfe/trunk/docs/AutomaticReferenceCounting.rst

Modified: cfe/trunk/docs/AutomaticReferenceCounting.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/AutomaticReferenceCounting.rst?rev=348431&r1=348430&r2=348431&view=diff
==
--- cfe/trunk/docs/AutomaticReferenceCounting.rst (original)
+++ cfe/trunk/docs/AutomaticReferenceCounting.rst Wed Dec  5 16:01:44 2018
@@ -2285,7 +2285,7 @@ block exactly as if it had been sent the
 .. _arc.runtime.objc_storeStrong:
 
 ``void objc_storeStrong(id *object, id value);``
---
+
 
 *Precondition:* ``object`` is a valid pointer to a ``__strong`` object which is
 adequately aligned for a pointer.  ``value`` is null or a pointer to a valid


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


r348429 - Update ARC docs as objc_storeStrong returns void not id

2018-12-05 Thread Pete Cooper via cfe-commits
Author: pete
Date: Wed Dec  5 15:49:52 2018
New Revision: 348429

URL: http://llvm.org/viewvc/llvm-project?rev=348429&view=rev
Log:
Update ARC docs as objc_storeStrong returns void not id

Modified:
cfe/trunk/docs/AutomaticReferenceCounting.rst

Modified: cfe/trunk/docs/AutomaticReferenceCounting.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/AutomaticReferenceCounting.rst?rev=348429&r1=348428&r2=348429&view=diff
==
--- cfe/trunk/docs/AutomaticReferenceCounting.rst (original)
+++ cfe/trunk/docs/AutomaticReferenceCounting.rst Wed Dec  5 15:49:52 2018
@@ -2284,7 +2284,7 @@ block exactly as if it had been sent the
 
 .. _arc.runtime.objc_storeStrong:
 
-``id objc_storeStrong(id *object, id value);``
+``void objc_storeStrong(id *object, id value);``
 --
 
 *Precondition:* ``object`` is a valid pointer to a ``__strong`` object which is


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


r348425 - Fix test change from r348365 to deal with Windows paths correctly.

2018-12-05 Thread Douglas Yung via cfe-commits
Author: dyung
Date: Wed Dec  5 15:10:14 2018
New Revision: 348425

URL: http://llvm.org/viewvc/llvm-project?rev=348425&view=rev
Log:
Fix test change from r348365 to deal with Windows paths correctly.


Modified:
cfe/trunk/test/Driver/darwin-stdlib.cpp

Modified: cfe/trunk/test/Driver/darwin-stdlib.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/darwin-stdlib.cpp?rev=348425&r1=348424&r2=348425&view=diff
==
--- cfe/trunk/test/Driver/darwin-stdlib.cpp (original)
+++ cfe/trunk/test/Driver/darwin-stdlib.cpp Wed Dec  5 15:10:14 2018
@@ -14,7 +14,7 @@
 // optional absolute include for libc++ from InitHeaderSearch.cpp also fires.
 
 // CHECK-LIBCXX: "-stdlib=libc++"
-// CHECK-LIBCXX: "-internal-isystem" 
"{{[^"]*}}{{[/\\]}}Inputs{{[/\\]}}darwin_toolchain_tree{{[/\\]}}bin{{[/\\]}}include{{[/\\]}}c++{{[/\\]}}v1"
+// CHECK-LIBCXX: "-internal-isystem" 
"{{[^"]*}}{{/|}}Inputs{{/|}}darwin_toolchain_tree{{/|}}bin{{/|}}include{{/|}}c++{{/|}}v1"
 
 // CHECK-LIBSTDCXX-NOT: -stdlib=libc++
 // CHECK-LIBSTDCXX-NOT: -stdlib=libstdc++


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


[PATCH] D55067: [HIP] Fix offset of kernel argument for AMDGPU target

2018-12-05 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

I think if we can just declare something simple to follow that doesn't depend 
on the IR type alignment, we could pack any basic type and align any aggregates 
to 4


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

https://reviews.llvm.org/D55067



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


[PATCH] D55289: [analyzer] MoveChecker Pt.5: Improve invalidation policies.

2018-12-05 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ marked an inline comment as done.
NoQ added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/MoveChecker.cpp:540-542
+// Explicit regions are the regions passed into the call directly, but
+// not all of them end up being invalidated. The ones that do appear in
+// the Regions array as well.

NoQ wrote:
> Szelethus wrote:
> > Really? Then I guess this needs to be updated in `CheckerDocumentation.cpp`:
> > 
> > ```
> >   /// \param ExplicitRegions The regions explicitly requested for 
> > invalidation.
> >   ///For a function call, this would be the arguments. For a bind, 
> > this
> >   ///would be the region being bound to.
> > ```
> > 
> > To me, this clearly indicates that the elements of `ExplicitRegions` will 
> > be invalidated. Does "requested for" really just mean "requested for 
> > potential"? Since this happens //before// any invalidation, it could easily 
> > be interpreted as "invalidated after the end of the callback".
> The callback fires after invalidation - cf. 
> `ProgramState::invalidateRegionsImpl`. Note that the `if (Eng)` condition is 
> always true, because how the heck were we supposed to run path-sensitive 
> analysis without `ExprEngine`.
> 
> The terminology is really weird here because we the word "invalidation" has 
> too many meanings. Essentially, `ExplicitRegions` are regions that were 
> specifically requested for invalidation, but it is up to the `CallEvent` / 
> `ProgramState` / `StoreManager` (depending on which `invalidateRegions()` was 
> called) to decide what invalidation means in this case by filling in the 
> `RegionAndSymbolInvalidationTraits` map.
> 
> For regions that represent values of const pointers/references directly 
> passed into the function, `CallEvent` decides to set the 
> `TK_PreserveContents` trait, which says "invalidate the region but keep its 
> contents intact". It would still perform other forms of invalidation on that 
> region, say, pointer escape: if there are pointer values written down 
> somewhere within that region, checkers need to stop tracking them.
> 
> Now, the callback never said that it has something to do with "invalidation". 
> Instead, it is about "region changes", which means changes of the region's 
> contents in the Store. This doesn't necessarily happen due to invalidation; 
> it may also happen while evaluating a simple assignment in the program, as we 
> see in the newly added `testUpdateField()` test. And, as we've seen above, 
> not every "invalidation" changes contents of the region.
> 
> Similarly, `TK_SuppressEscape` would suppress the `checkPointerEscape()` 
> callback for the region, but will not suppress `checkRegionChanges()` for 
> that (non-explicit) region.
> 
> Therefore we end up in a weird situation when some regions were requested to 
> be invalidated but never were actually invalidated in terms of the Store. It 
> kinda  makes sense, but i hate it anyway.  The `checkRegionChanges()` 
> callback is hard to understand and hard to use and too general and has too 
> much stuff stuffed into it. `checkPointerEscape` is an easier-to-use fork of 
> it, but it doesn't cover the use case of checkers that track objects via 
> regions. I suspect that the right solution here is to start tracking objects 
> as "symbols", i.e., assign a unique opaque ID to every state through which 
> every object in the program goes (regardless of which object it is) and use 
> that as keys in the map. That should remove the stress of dealing with 
> invalidation from C++ checkers that need to track objects opaquely. The 
> problem won't magically disappear, as we still need to identify when exactly 
> does the state change, but an additional level of indirection (Region -> ID 
> -> CheckerState instead of just Region -> CheckerState) allows us to 
> decompose it into smaller parts and de-duplicate some of this work.
> 
> But regardless of that, it is still weird that `ExplicitRegions` is not a 
> sub-set of `Regions`. We need to either document it or fix it, and for some 
> reason i prefer the latter. In particular, the only checker that actually 
> actively acts upon `ExplicitRegions` when they're const is 
> `RetainCountChecker`, but in fact people don't ever use `const` in stuff that 
> it checks, it just isn't idiomatic.
Another funny thing about `RegionAndSymbolInvalidationTraits`  is that it races 
when the same region is passed both via const pointer and a non-const pointer. 
The region will be invalidated or not depending on which one goes in first. We 
really need to fix it.


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

https://reviews.llvm.org/D55289



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


[PATCH] D55289: [analyzer] MoveChecker Pt.5: Improve invalidation policies.

2018-12-05 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/MoveChecker.cpp:528
 ArrayRef ExplicitRegions,
 ArrayRef Regions, const LocationContext *LCtx,
 const CallEvent *Call) const {

Szelethus wrote:
> This isn't specific to this revision, but I find the parameter name `Regions` 
> way too vague. Maybe `ImplicitRegions`?
How about these?



Comment at: lib/StaticAnalyzer/Checkers/MoveChecker.cpp:545
+  if (ThisRegion != Region)
+if (std::find(Regions.begin(), Regions.end(), Region) != Regions.end())
+  State = removeFromState(State, Region);

a_sidorin wrote:
> NoQ wrote:
> > This is clumsy. I think we shouldn't include non-invalidated regions in the 
> > `ExplicitRegions` array in the first place.
> Just a reminder: we have `llvm::find` and a bunch of nice related range 
> wrappers.
Thx!


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

https://reviews.llvm.org/D55289



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


[PATCH] D55289: [analyzer] MoveChecker Pt.5: Improve invalidation policies.

2018-12-05 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 176877.
NoQ marked 5 inline comments as done.
NoQ added a comment.

Address comments :)


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

https://reviews.llvm.org/D55289

Files:
  lib/StaticAnalyzer/Checkers/MoveChecker.cpp
  test/Analysis/use-after-move.cpp

Index: test/Analysis/use-after-move.cpp
===
--- test/Analysis/use-after-move.cpp
+++ test/Analysis/use-after-move.cpp
@@ -116,6 +116,19 @@
   bool empty() const;
   bool isEmpty() const;
   operator bool() const;
+
+  void testUpdateField() {
+A a;
+A b = std::move(a);
+a.i = 1;
+a.foo(); // no-warning
+  }
+  void testUpdateFieldDouble() {
+A a;
+A b = std::move(a);
+a.d = 1.0;
+a.foo(); // no-warning
+  }
 };
 
 int bignum();
@@ -594,24 +607,50 @@
   foobar(a.getI(), std::move(a)); //no-warning
 }
 
-void not_known(A &a);
-void not_known(A *a);
+void not_known_pass_by_ref(A &a);
+void not_known_pass_by_const_ref(const A &a);
+void not_known_pass_by_rvalue_ref(A &&a);
+void not_known_pass_by_ptr(A *a);
+void not_known_pass_by_const_ptr(const A *a);
 
 void regionAndPointerEscapeTest() {
   {
 A a;
 A b;
 b = std::move(a);
-not_known(a);
-a.foo(); //no-warning
+not_known_pass_by_ref(a);
+a.foo(); // no-warning
+  }
+  {
+A a;
+A b;
+b = std::move(a); // expected-note{{Object 'a' is moved}}
+not_known_pass_by_const_ref(a);
+a.foo(); // expected-warning{{Method called on moved-from object 'a'}}
+ // expected-note@-1{{Method called on moved-from object 'a'}}
+  }
+  {
+A a;
+A b;
+b = std::move(a);
+not_known_pass_by_rvalue_ref(std::move(a));
+a.foo(); // no-warning
   }
   {
 A a;
 A b;
 b = std::move(a);
-not_known(&a);
+not_known_pass_by_ptr(&a);
 a.foo(); // no-warning
   }
+  {
+A a;
+A b;
+b = std::move(a); // expected-note{{Object 'a' is moved}}
+not_known_pass_by_const_ptr(&a);
+a.foo(); // expected-warning{{Method called on moved-from object 'a'}}
+ // expected-note@-1{{Method called on moved-from object 'a'}}
+  }
 }
 
 // A declaration statement containing multiple declarations sequences the
Index: lib/StaticAnalyzer/Checkers/MoveChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/MoveChecker.cpp
+++ lib/StaticAnalyzer/Checkers/MoveChecker.cpp
@@ -524,19 +524,35 @@
 
 ProgramStateRef MoveChecker::checkRegionChanges(
 ProgramStateRef State, const InvalidatedSymbols *Invalidated,
-ArrayRef ExplicitRegions,
-ArrayRef Regions, const LocationContext *LCtx,
-const CallEvent *Call) const {
-  // In case of an InstanceCall don't remove the ThisRegion from the GDM since
-  // it is handled in checkPreCall and checkPostCall.
-  const MemRegion *ThisRegion = nullptr;
-  if (const auto *IC = dyn_cast_or_null(Call)) {
-ThisRegion = IC->getCXXThisVal().getAsRegion();
-  }
-
-  for (const auto *Region : ExplicitRegions) {
-if (ThisRegion != Region)
-  State = removeFromState(State, Region);
+ArrayRef RequestedRegions,
+ArrayRef InvalidatedRegions,
+const LocationContext *LCtx, const CallEvent *Call) const {
+  if (Call) {
+// Relax invalidation upon function calls: only invalidate parameters
+// that are passed directly via non-const pointers or non-const references
+// or rvalue references.
+// In case of an InstanceCall don't invalidate the this-region since
+// it is fully handled in checkPreCall and checkPostCall.
+const MemRegion *ThisRegion = nullptr;
+if (const auto *IC = dyn_cast(Call))
+  ThisRegion = IC->getCXXThisVal().getAsRegion();
+
+// Requested ("explicit") regions are the regions passed into the call
+// directly, but not all of them end up being invalidated.
+// But when they do, they appear in the InvalidatedRegions array as well.
+for (const auto *Region : RequestedRegions) {
+  if (ThisRegion != Region) {
+if (llvm::find(InvalidatedRegions, Region) !=
+std::end(InvalidatedRegions)) {
+  State = removeFromState(State, Region);
+}
+  }
+}
+  } else {
+// For invalidations that aren't caused by calls, assume nothing. In
+// particular, direct write into an object's field invalidates the status.
+for (const auto *Region : InvalidatedRegions)
+  State = removeFromState(State, Region->getBaseRegion());
   }
 
   return State;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-12-05 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.

Thanks for your patience.




Comment at: clang/lib/Sema/SemaInit.cpp:7838-7854
+  if (const auto *FromPtrType = SourceType->getAs()) {
+if (const auto *ToPtrType = Step->Type->getAs()) {
+  if (FromPtrType->getPointeeType()->hasAttr(attr::NoDeref) &&
+  !ToPtrType->getPointeeType()->hasAttr(attr::NoDeref)) {
+S.Diag(CurInit.get()->getExprLoc(),
+   diag::warn_noderef_to_dereferenceable_pointer)
+<< CurInit.get()->getSourceRange();

`CheckSingleAssignmentConstraints` also warns in this case; is the explicit 
warning emission above necessary?


Repository:
  rC Clang

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

https://reviews.llvm.org/D49511



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


[PATCH] D55133: [CTU] Add statistics

2018-12-05 Thread Aleksei Sidorin via Phabricator via cfe-commits
a_sidorin accepted this revision.
a_sidorin added a comment.

LGTM with a nit.




Comment at: lib/CrossTU/CrossTranslationUnit.cpp:171
   loadExternalAST(LookupFnName, CrossTUDir, IndexName);
-  if (!ASTUnitOrError)
+  if (!ASTUnitOrError) {
 return ASTUnitOrError.takeError();

We can omit braces here.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55133



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


[PATCH] D54014: [Sema] Push and Pop Expression Evaluation Context Records at the start and end of function definitions

2018-12-05 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

Thanks!




Comment at: clang/lib/Sema/SemaDecl.cpp:13181-13182
+if (!IFace) {
+  if (!IsLambda)
+PopExpressionEvaluationContext();
   return false;

Adding this pop before each return seems error-prone. Can you do this with an 
RAII object instead?


Repository:
  rC Clang

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

https://reviews.llvm.org/D54014



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


r348415 - [Hexagon] Add support for Hexagon V66

2018-12-05 Thread Krzysztof Parzyszek via cfe-commits
Author: kparzysz
Date: Wed Dec  5 13:38:35 2018
New Revision: 348415

URL: http://llvm.org/viewvc/llvm-project?rev=348415&view=rev
Log:
[Hexagon] Add support for Hexagon V66

Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Basic/Targets/Hexagon.cpp
cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp
cfe/trunk/test/Driver/hexagon-hvx.c
cfe/trunk/test/Driver/hexagon-toolchain-elf.c
cfe/trunk/test/Preprocessor/hexagon-predefines.c

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=348415&r1=348414&r2=348415&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Wed Dec  5 13:38:35 2018
@@ -2708,6 +2708,8 @@ def mv62 : Flag<["-"], "mv62">, Group, AliasArgs<["hexagonv62"]>;
 def mv65 : Flag<["-"], "mv65">, Group,
   Alias, AliasArgs<["hexagonv65"]>;
+def mv66 : Flag<["-"], "mv66">, Group,
+  Alias, AliasArgs<["hexagonv66"]>;
 def mhexagon_hvx : Flag<["-"], "mhvx">, Group,
   HelpText<"Enable Hexagon Vector eXtensions">;
 def mhexagon_hvx_EQ : Joined<["-"], "mhvx=">,

Modified: cfe/trunk/lib/Basic/Targets/Hexagon.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/Hexagon.cpp?rev=348415&r1=348414&r2=348415&view=diff
==
--- cfe/trunk/lib/Basic/Targets/Hexagon.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/Hexagon.cpp Wed Dec  5 13:38:35 2018
@@ -48,6 +48,9 @@ void HexagonTargetInfo::getTargetDefines
   } else if (CPU == "hexagonv65") {
 Builder.defineMacro("__HEXAGON_V65__");
 Builder.defineMacro("__HEXAGON_ARCH__", "65");
+  } else if (CPU == "hexagonv66") {
+Builder.defineMacro("__HEXAGON_V66__");
+Builder.defineMacro("__HEXAGON_ARCH__", "66");
   }
 
   if (hasFeature("hvx-length64b")) {
@@ -145,7 +148,7 @@ struct CPUSuffix {
 static constexpr CPUSuffix Suffixes[] = {
 {{"hexagonv5"},  {"5"}},  {{"hexagonv55"}, {"55"}},
 {{"hexagonv60"}, {"60"}}, {{"hexagonv62"}, {"62"}},
-{{"hexagonv65"}, {"65"}},
+{{"hexagonv65"}, {"65"}}, {{"hexagonv66"}, {"66"}},
 };
 
 const char *HexagonTargetInfo::getHexagonCPUSuffix(StringRef Name) {

Modified: cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp?rev=348415&r1=348414&r2=348415&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp Wed Dec  5 13:38:35 2018
@@ -32,6 +32,7 @@ static StringRef getDefaultHvxLength(Str
   .Case("v60", "64b")
   .Case("v62", "64b")
   .Case("v65", "64b")
+  .Case("v66", "128b")
   .Default("128b");
 }
 

Modified: cfe/trunk/test/Driver/hexagon-hvx.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/hexagon-hvx.c?rev=348415&r1=348414&r2=348415&view=diff
==
--- cfe/trunk/test/Driver/hexagon-hvx.c (original)
+++ cfe/trunk/test/Driver/hexagon-hvx.c Wed Dec  5 13:38:35 2018
@@ -2,6 +2,10 @@
 // Tests for the hvx features and warnings.
 // 
-
 
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv66 -mhvx \
+// RUN:  2>&1 | FileCheck -check-prefix=CHECKHVX166 %s
+// CHECKHVX166: "-target-feature" "+hvxv66"
+
 // RUN: %clang -c %s -### -target hexagon-unknown-elf -mv65 -mhvx \
 // RUN:  2>&1 | FileCheck -check-prefix=CHECKHVX165 %s
 // CHECKHVX165: "-target-feature" "+hvxv65"
@@ -69,6 +73,9 @@
 // RUN: %clang -c %s -### -target hexagon-unknown-elf -mv60 -mhvx \
 // RUN:  -mhvx-length=64B 2>&1 | FileCheck -check-prefix=CHECK-HVXLENGTH-64B %s
 // CHECK-HVXLENGTH-64B: "-target-feature" "+hvx{{.*}}" "-target-feature" 
"+hvx-length64b"
+// The default mode on v66 and future archs is 128B.
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv66 -mhvx \
+// RUN:  2>&1 | FileCheck -check-prefix=CHECK-HVXLENGTH-128B %s
 // RUN: %clang -c %s -### -target hexagon-unknown-elf -mv62 -mhvx 
-mhvx-length=128B\
 // RUN:  2>&1 | FileCheck -check-prefix=CHECK-HVXLENGTH-128B %s
 // CHECK-HVXLENGTH-128B: "-target-feature" "+hvx{{.*}}" "-target-feature" 
"+hvx-length128b"

Modified: cfe/trunk/test/Driver/hexagon-toolchain-elf.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/hexagon-toolchain-elf.c?rev=348415&r1=348414&r2=348415&view=diff
==
--- cfe/trunk/test/Driver/hexagon-toolchain-elf.c (original)
+++ cfe/trunk/test/Driver/hexagon-toolchain-elf.c Wed Dec  5 13:38:35 2018
@@ -99,20 +99,28 @@
 
 // RUN: %clang -### -target hexagon-unknown-elf \
 // RUN:   -ccc-install-dir %S/Inputs/hexago

[PATCH] D54309: [AST] Allow limiting the scope of common AST traversals (getParents, RAV).

2018-12-05 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

Hi Sam,

this patch "broke" `ExprMutAnalyzer`, at least it creates an assertion failure 
that seems harmless. Your thought on it would be great!

The assertion in: `ASTMatchFinder.cpp +680` is triggered in the Analysis to 
figure out if something is mutated, because `Parents` is empty and the 
traversal scope is the TU itself, but the node is a `CXXConstructoDecl`. This 
does not happen for alle cases though, please take a look at this reproducer: 
https://godbolt.org/z/0yOq2I

Only for the Lambda-Case problems occur. If I `#if 0` the assertion out the 
issue goes away, and the real world code that triggered this behaviour is not 
bothered, too.

I am really puzzled why this issue occurs, but as you implemented the 
restrictions it would like to hear your opinion on the issue. If you want to 
reproduce yourself I am of course happy to help, but 
https://github.com/JonasToth/clang/blob/fix_crash/unittests/Analysis/ExprMutationAnalyzerTest.cpp#L1134
   is probably the easiest way to do so (just add this to trunk and run 
`check-clang-unit`).

Thank you for the time!


Repository:
  rC Clang

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

https://reviews.llvm.org/D54309



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


Re: r348408 - Add dump tests for inherited default template parameters

2018-12-05 Thread Aaron Ballman via cfe-commits
On Wed, Dec 5, 2018 at 4:01 PM Stephen Kelly  wrote:
>
> Surely all of the tests specifically about template decls should be moved?

If you want to move all of them, feel free.

~Aaron

>
> On 05/12/2018 20:31, Aaron Ballman wrote:
> > On Wed, Dec 5, 2018 at 3:24 PM Stephen Kelly via cfe-commits
> >  wrote:
> >> Author: steveire
> >> Date: Wed Dec  5 12:21:13 2018
> >> New Revision: 348408
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=348408&view=rev
> >> Log:
> >> Add dump tests for inherited default template parameters
> >>
> >> Modified:
> >>  cfe/trunk/test/AST/ast-dump-decl.cpp
> > Can you move these tests into ast-dump-template-decls.cpp?
> >
> > ~Aaron
> >
> >> Modified: cfe/trunk/test/AST/ast-dump-decl.cpp
> >> URL: 
> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/ast-dump-decl.cpp?rev=348408&r1=348407&r2=348408&view=diff
> >> ==
> >> --- cfe/trunk/test/AST/ast-dump-decl.cpp (original)
> >> +++ cfe/trunk/test/AST/ast-dump-decl.cpp Wed Dec  5 12:21:13 2018
> >> @@ -263,6 +263,15 @@ namespace testClassTemplateDecl {
> >> template class TestClassTemplatePartial {
> >>   int j;
> >> };
> >> +
> >> +  template struct TestTemplateDefaultType;
> >> +  template struct TestTemplateDefaultType { };
> >> +
> >> +  template struct TestTemplateDefaultNonType;
> >> +  template struct TestTemplateDefaultNonType { };
> >> +
> >> +  template class TT = TestClassTemplate> struct 
> >> TestTemplateTemplateDefaultType;
> >> +  template class TT> struct 
> >> TestTemplateTemplateDefaultType { };
> >>   }
> >>   // CHECK:  ClassTemplateDecl{{.*}} TestClassTemplate
> >>   // CHECK-NEXT:   TemplateTypeParmDecl
> >> @@ -316,6 +325,24 @@ namespace testClassTemplateDecl {
> >>   // CHECK-NEXT:   CXXRecordDecl{{.*}} class TestClassTemplatePartial
> >>   // CHECK-NEXT:   FieldDecl{{.*}} j
> >>
> >> +// CHECK:  ClassTemplateDecl 0x{{[^ ]*}} prev 0x{{[^ ]*}} {{.*}} 
> >> TestTemplateDefaultType
> >> +// CHECK-NEXT:   TemplateTypeParmDecl
> >> +// CHECK-NEXT: TemplateArgument type 'int'
> >> +// CHECK-NEXT: inherited from TemplateTypeParm 0x{{[^ ]*}} 'T'
> >> +
> >> +// CHECK:  ClassTemplateDecl 0x{{[^ ]*}} prev 0x{{[^ ]*}} {{.*}} 
> >> TestTemplateDefaultNonType
> >> +// CHECK-NEXT:   NonTypeTemplateParmDecl
> >> +// CHECK-NEXT: TemplateArgument expr
> >> +// CHECK-NEXT:   ConstantExpr
> >> +// CHECK-NEXT: IntegerLiteral
> >> +// CHECK-NEXT: inherited from NonTypeTemplateParm 0x{{[^ ]*}} 'I' 
> >> 'int'
> >> +
> >> +// CHECK:  ClassTemplateDecl 0x{{[^ ]*}} prev 0x{{[^ ]*}} {{.*}} 
> >> TestTemplateTemplateDefaultType
> >> +// CHECK-NEXT:   TemplateTemplateParmDecl
> >> +// CHECK-NEXT: TemplateTypeParmDecl
> >> +// CHECK-NEXT: TemplateArgument
> >> +// CHECK-NEXT: inherited from TemplateTemplateParm 0x{{[^ ]*}} 'TT'
> >> +
> >>   // PR15220 dump instantiation only once
> >>   namespace testCanonicalTemplate {
> >> class A {};
> >>
> >>
> >> ___
> >> 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] D55280: [CTU] Make loadExternalAST return with non nullptr on success

2018-12-05 Thread Aleksei Sidorin via Phabricator via cfe-commits
a_sidorin requested changes to this revision.
a_sidorin added a comment.
This revision now requires changes to proceed.

Hi Gabor,
There is a code in getExternalAST:

  std::unique_ptr LoadedUnit(ASTUnit::LoadFromASTFile(
  ASTFileName, CI.getPCHContainerOperations()->getRawReader(),
  ASTUnit::LoadEverything, Diags, CI.getFileSystemOpts()));
  Unit = LoadedUnit.get();
  FileASTUnitMap[ASTFileName] = std::move(LoadedUnit);

And `ASTUnit::LoadFromASTFile()`can return nullptr. Actually, there is a 
problem in `loadExternalAST()` - it ignores this fact.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55280



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


r348412 - NFC: Extract TextNodeDumper class

2018-12-05 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Wed Dec  5 13:12:39 2018
New Revision: 348412

URL: http://llvm.org/viewvc/llvm-project?rev=348412&view=rev
Log:
NFC: Extract TextNodeDumper class

Summary:
Start by moving some utilities to it. It will eventually house dumping
of individual nodes (after indentation etc has already been accounted
for).

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

Added:
cfe/trunk/include/clang/AST/TextNodeDumper.h
cfe/trunk/lib/AST/TextNodeDumper.cpp
Modified:
cfe/trunk/lib/AST/ASTDumper.cpp
cfe/trunk/lib/AST/CMakeLists.txt

Added: cfe/trunk/include/clang/AST/TextNodeDumper.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TextNodeDumper.h?rev=348412&view=auto
==
--- cfe/trunk/include/clang/AST/TextNodeDumper.h (added)
+++ cfe/trunk/include/clang/AST/TextNodeDumper.h Wed Dec  5 13:12:39 2018
@@ -0,0 +1,54 @@
+//===--- TextNodeDumper.h - Printing of AST nodes 
-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This file implements AST dumping of components of individual AST nodes.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_AST_TEXTNODEDUMPER_H
+#define LLVM_CLANG_AST_TEXTNODEDUMPER_H
+
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/ASTDumperUtils.h"
+#include "clang/AST/ExprCXX.h"
+
+namespace clang {
+
+class TextNodeDumper {
+  raw_ostream &OS;
+  const bool ShowColors;
+
+  /// Keep track of the last location we print out so that we can
+  /// print out deltas from then on out.
+  const char *LastLocFilename = "";
+  unsigned LastLocLine = ~0U;
+
+  const SourceManager *SM;
+
+  /// The policy to use for printing; can be defaulted.
+  PrintingPolicy PrintPolicy;
+
+public:
+  TextNodeDumper(raw_ostream &OS, bool ShowColors, const SourceManager *SM,
+ const PrintingPolicy &PrintPolicy);
+
+  void dumpPointer(const void *Ptr);
+  void dumpLocation(SourceLocation Loc);
+  void dumpSourceRange(SourceRange R);
+  void dumpBareType(QualType T, bool Desugar = true);
+  void dumpType(QualType T);
+  void dumpBareDeclRef(const Decl *D);
+  void dumpName(const NamedDecl *ND);
+  void dumpAccessSpecifier(AccessSpecifier AS);
+  void dumpCXXTemporary(const CXXTemporary *Temporary);
+};
+
+} // namespace clang
+
+#endif // LLVM_CLANG_AST_TEXTNODEDUMPER_H

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=348412&r1=348411&r2=348412&view=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Wed Dec  5 13:12:39 2018
@@ -23,6 +23,7 @@
 #include "clang/AST/DeclVisitor.h"
 #include "clang/AST/LocInfoType.h"
 #include "clang/AST/StmtVisitor.h"
+#include "clang/AST/TextNodeDumper.h"
 #include "clang/AST/TypeVisitor.h"
 #include "clang/Basic/Builtins.h"
 #include "clang/Basic/Module.h"
@@ -44,10 +45,10 @@ namespace  {
 public TypeVisitor {
 
 TextTreeStructure TreeStructure;
+TextNodeDumper NodeDumper;
 
 raw_ostream &OS;
 const CommandTraits *Traits;
-const SourceManager *SM;
 
 /// The policy to use for printing; can be defaulted.
 PrintingPolicy PrintPolicy;
@@ -56,11 +57,6 @@ namespace  {
 /// not already been loaded.
 bool Deserialize = false;
 
-/// Keep track of the last location we print out so that we can
-/// print out deltas from then on out.
-const char *LastLocFilename = "";
-unsigned LastLocLine = ~0U;
-
 const bool ShowColors;
 
 /// Dump a child of the current node.
@@ -80,7 +76,8 @@ namespace  {
 ASTDumper(raw_ostream &OS, const CommandTraits *Traits,
   const SourceManager *SM, bool ShowColors,
   const PrintingPolicy &PrintPolicy)
-: TreeStructure(OS, ShowColors), OS(OS), Traits(Traits), SM(SM),
+: TreeStructure(OS, ShowColors),
+  NodeDumper(OS, ShowColors, SM, PrintPolicy), OS(OS), Traits(Traits),
   PrintPolicy(PrintPolicy), ShowColors(ShowColors) {}
 
 void setDeserialize(bool D) { Deserialize = D; }
@@ -90,23 +87,17 @@ namespace  {
 void dumpFullComment(const FullComment *C);
 
 // Utilities
-void dumpPointer(const void *Ptr);
-void dumpSourceRange(SourceRange R);
-void dumpLocation(SourceLocation Loc);
-void dumpBareType(QualType T, bool Desugar = true);
-void dumpType(QualType T);
+void dumpType(QualType T) { NodeDumper.dumpType(T); }
 void dumpTypeAsChild(QualType T);
 void dumpTypeAsChild(const Type *T);
-void dumpBareDeclRef(c

[PATCH] D55189: Extract TextNodeDumper class

2018-12-05 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC348412: NFC: Extract TextNodeDumper class (authored by 
steveire, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D55189?vs=176478&id=176872#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D55189

Files:
  include/clang/AST/TextNodeDumper.h
  lib/AST/ASTDumper.cpp
  lib/AST/CMakeLists.txt
  lib/AST/TextNodeDumper.cpp

Index: include/clang/AST/TextNodeDumper.h
===
--- include/clang/AST/TextNodeDumper.h
+++ include/clang/AST/TextNodeDumper.h
@@ -0,0 +1,54 @@
+//===--- TextNodeDumper.h - Printing of AST nodes -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This file implements AST dumping of components of individual AST nodes.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_AST_TEXTNODEDUMPER_H
+#define LLVM_CLANG_AST_TEXTNODEDUMPER_H
+
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/ASTDumperUtils.h"
+#include "clang/AST/ExprCXX.h"
+
+namespace clang {
+
+class TextNodeDumper {
+  raw_ostream &OS;
+  const bool ShowColors;
+
+  /// Keep track of the last location we print out so that we can
+  /// print out deltas from then on out.
+  const char *LastLocFilename = "";
+  unsigned LastLocLine = ~0U;
+
+  const SourceManager *SM;
+
+  /// The policy to use for printing; can be defaulted.
+  PrintingPolicy PrintPolicy;
+
+public:
+  TextNodeDumper(raw_ostream &OS, bool ShowColors, const SourceManager *SM,
+ const PrintingPolicy &PrintPolicy);
+
+  void dumpPointer(const void *Ptr);
+  void dumpLocation(SourceLocation Loc);
+  void dumpSourceRange(SourceRange R);
+  void dumpBareType(QualType T, bool Desugar = true);
+  void dumpType(QualType T);
+  void dumpBareDeclRef(const Decl *D);
+  void dumpName(const NamedDecl *ND);
+  void dumpAccessSpecifier(AccessSpecifier AS);
+  void dumpCXXTemporary(const CXXTemporary *Temporary);
+};
+
+} // namespace clang
+
+#endif // LLVM_CLANG_AST_TEXTNODEDUMPER_H
Index: lib/AST/CMakeLists.txt
===
--- lib/AST/CMakeLists.txt
+++ lib/AST/CMakeLists.txt
@@ -69,6 +69,7 @@
   StmtViz.cpp
   TemplateBase.cpp
   TemplateName.cpp
+  TextNodeDumper.cpp
   Type.cpp
   TypeLoc.cpp
   TypePrinter.cpp
Index: lib/AST/TextNodeDumper.cpp
===
--- lib/AST/TextNodeDumper.cpp
+++ lib/AST/TextNodeDumper.cpp
@@ -0,0 +1,141 @@
+//===--- TextNodeDumper.cpp - Printing of AST nodes ---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This file implements AST dumping of components of individual AST nodes.
+//
+//===--===//
+
+#include "clang/AST/TextNodeDumper.h"
+
+using namespace clang;
+
+TextNodeDumper::TextNodeDumper(raw_ostream &OS, bool ShowColors,
+   const SourceManager *SM,
+   const PrintingPolicy &PrintPolicy)
+: OS(OS), ShowColors(ShowColors), SM(SM), PrintPolicy(PrintPolicy) {}
+
+void TextNodeDumper::dumpPointer(const void *Ptr) {
+  ColorScope Color(OS, ShowColors, AddressColor);
+  OS << ' ' << Ptr;
+}
+
+void TextNodeDumper::dumpLocation(SourceLocation Loc) {
+  if (!SM)
+return;
+
+  ColorScope Color(OS, ShowColors, LocationColor);
+  SourceLocation SpellingLoc = SM->getSpellingLoc(Loc);
+
+  // The general format we print out is filename:line:col, but we drop pieces
+  // that haven't changed since the last loc printed.
+  PresumedLoc PLoc = SM->getPresumedLoc(SpellingLoc);
+
+  if (PLoc.isInvalid()) {
+OS << "";
+return;
+  }
+
+  if (strcmp(PLoc.getFilename(), LastLocFilename) != 0) {
+OS << PLoc.getFilename() << ':' << PLoc.getLine() << ':'
+   << PLoc.getColumn();
+LastLocFilename = PLoc.getFilename();
+LastLocLine = PLoc.getLine();
+  } else if (PLoc.getLine() != LastLocLine) {
+OS << "line" << ':' << PLoc.getLine() << ':' << PLoc.getColumn();
+LastLocLine = PLoc.getLine();
+  } else {
+OS << "col" << ':' << PLoc.getColumn();
+  }
+}
+
+void TextNodeDumper::dumpSourceRange(SourceRange R) {
+  // Can't translate locations if a SourceManager isn't available.
+  if (!SM)
+return;
+
+  OS << " <";
+  dumpLocation(R.getBegin());
+  if (R.getBegin() != R.getEnd())

[PATCH] D55262: [OpenCL] Fix for TBAA information of pointer after addresspacecast

2018-12-05 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Oh, sorry, that wasn't a good example because that's still the natural 
alignment for `A`.  It should be `static_cast<__generic int &>(GPtr->X)`.


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

https://reviews.llvm.org/D55262



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


[PATCH] D55245: [clang-tidy] Add the abseil-duration-subtraction check

2018-12-05 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

In D55245#1320546 , @hwright wrote:

> Ping.
>
> I assume I've got the right reviewers here, but I've also been sending a 
> bunch of stuff your way lately, so if I'm overwhelming review capacity, 
> please let me know.


Hi hyrum, you have the right reviews. I do not have review capacity today, but 
at the end of the week. We usually ping after a few days (~1 week), e.g. for me 
its a hobby and I need to work :)
If you have more patches in the pipeline, you can already work on them/push 
them to review. It is easier to review a bit more in one piece and generates 
higher throughput too.

If other reviewers have time, go for it :)


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

https://reviews.llvm.org/D55245



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


[PATCH] D55340: NFC: Move dump of individual Stmts to TextNodeDumper

2018-12-05 Thread Stephen Kelly via Phabricator via cfe-commits
steveire created this revision.
steveire added a reviewer: aaron.ballman.
Herald added a subscriber: cfe-commits.

Repository:
  rC Clang

https://reviews.llvm.org/D55340

Files:
  include/clang/AST/TextNodeDumper.h
  lib/AST/ASTDumper.cpp
  lib/AST/TextNodeDumper.cpp

Index: lib/AST/TextNodeDumper.cpp
===
--- lib/AST/TextNodeDumper.cpp
+++ lib/AST/TextNodeDumper.cpp
@@ -42,6 +42,60 @@
   const comments::FullComment *>::visit(C, FC);
 }
 
+void TextNodeDumper::Visit(const Stmt *Node) {
+  if (!Node) {
+ColorScope Color(OS, ShowColors, NullColor);
+OS << "<<>>";
+return;
+  }
+  {
+ColorScope Color(OS, ShowColors, StmtColor);
+OS << Node->getStmtClassName();
+  }
+  dumpPointer(Node);
+  dumpSourceRange(Node->getSourceRange());
+
+  if (auto E = dyn_cast(Node)) {
+dumpType(E->getType());
+
+{
+  ColorScope Color(OS, ShowColors, ValueKindColor);
+  switch (E->getValueKind()) {
+  case VK_RValue:
+break;
+  case VK_LValue:
+OS << " lvalue";
+break;
+  case VK_XValue:
+OS << " xvalue";
+break;
+  }
+}
+
+{
+  ColorScope Color(OS, ShowColors, ObjectKindColor);
+  switch (E->getObjectKind()) {
+  case OK_Ordinary:
+break;
+  case OK_BitField:
+OS << " bitfield";
+break;
+  case OK_ObjCProperty:
+OS << " objcproperty";
+break;
+  case OK_ObjCSubscript:
+OS << " objcsubscript";
+break;
+  case OK_VectorComponent:
+OS << " vectorcomponent";
+break;
+  }
+}
+  }
+
+  ConstStmtVisitor::Visit(Node);
+}
+
 void TextNodeDumper::dumpPointer(const void *Ptr) {
   ColorScope Color(OS, ShowColors, AddressColor);
   OS << ' ' << Ptr;
@@ -295,3 +349,408 @@
 const comments::VerbatimLineComment *C, const comments::FullComment *) {
   OS << " Text=\"" << C->getText() << "\"";
 }
+
+void TextNodeDumper::VisitIfStmt(const IfStmt *Node) {
+  if (Node->hasInitStorage())
+OS << " has_init";
+  if (Node->hasVarStorage())
+OS << " has_var";
+  if (Node->hasElseStorage())
+OS << " has_else";
+}
+
+void TextNodeDumper::VisitSwitchStmt(const SwitchStmt *Node) {
+  if (Node->hasInitStorage())
+OS << " has_init";
+  if (Node->hasVarStorage())
+OS << " has_var";
+}
+
+void TextNodeDumper::VisitWhileStmt(const WhileStmt *Node) {
+  if (Node->hasVarStorage())
+OS << " has_var";
+}
+
+void TextNodeDumper::VisitLabelStmt(const LabelStmt *Node) {
+  OS << " '" << Node->getName() << "'";
+}
+
+void TextNodeDumper::VisitGotoStmt(const GotoStmt *Node) {
+  OS << " '" << Node->getLabel()->getName() << "'";
+  dumpPointer(Node->getLabel());
+}
+
+void TextNodeDumper::VisitCaseStmt(const CaseStmt *Node) {
+  if (Node->caseStmtIsGNURange())
+OS << " gnu_range";
+}
+
+static void dumpBasePath(raw_ostream &OS, const CastExpr *Node) {
+  if (Node->path_empty())
+return;
+
+  OS << " (";
+  bool First = true;
+  for (CastExpr::path_const_iterator I = Node->path_begin(),
+ E = Node->path_end();
+   I != E; ++I) {
+const CXXBaseSpecifier *Base = *I;
+if (!First)
+  OS << " -> ";
+
+const CXXRecordDecl *RD =
+cast(Base->getType()->getAs()->getDecl());
+
+if (Base->isVirtual())
+  OS << "virtual ";
+OS << RD->getName();
+First = false;
+  }
+
+  OS << ')';
+}
+
+void TextNodeDumper::VisitCastExpr(const CastExpr *Node) {
+  OS << " <";
+  {
+ColorScope Color(OS, ShowColors, CastColor);
+OS << Node->getCastKindName();
+  }
+  dumpBasePath(OS, Node);
+  OS << ">";
+}
+
+void TextNodeDumper::VisitImplicitCastExpr(const ImplicitCastExpr *Node) {
+  VisitCastExpr(Node);
+  if (Node->isPartOfExplicitCast())
+OS << " part_of_explicit_cast";
+}
+
+void TextNodeDumper::VisitDeclRefExpr(const DeclRefExpr *Node) {
+
+  OS << " ";
+  dumpBareDeclRef(Node->getDecl());
+  if (Node->getDecl() != Node->getFoundDecl()) {
+OS << " (";
+dumpBareDeclRef(Node->getFoundDecl());
+OS << ")";
+  }
+}
+
+void TextNodeDumper::VisitUnresolvedLookupExpr(
+const UnresolvedLookupExpr *Node) {
+  OS << " (";
+  if (!Node->requiresADL())
+OS << "no ";
+  OS << "ADL) = '" << Node->getName() << '\'';
+
+  UnresolvedLookupExpr::decls_iterator I = Node->decls_begin(),
+   E = Node->decls_end();
+  if (I == E)
+OS << " empty";
+  for (; I != E; ++I)
+dumpPointer(*I);
+}
+
+void TextNodeDumper::VisitObjCIvarRefExpr(const ObjCIvarRefExpr *Node) {
+
+  {
+ColorScope Color(OS, ShowColors, DeclKindNameColor);
+OS << " " << Node->getDecl()->getDeclKindName() << "Decl";
+  }
+  OS << "='" << *Node->getDecl() << "'";
+  dumpPointer(Node->getDecl());
+  if (Node->isFreeIvar())
+OS << " isFreeIvar";
+}
+
+void TextNodeDumper::VisitPredefinedExpr(const PredefinedExpr *Node) {
+  OS << " " << PredefinedExpr::getIdentKindName

[PATCH] D55339: NFC: Move VisitExpr code to dumpStmt

2018-12-05 Thread Stephen Kelly via Phabricator via cfe-commits
steveire created this revision.
steveire added a reviewer: aaron.ballman.
Herald added a subscriber: cfe-commits.

The call is duplicated in the handlers of all Expr subclasses.

This change makes it easy to split statement handling out to
TextNodeDumper.


Repository:
  rC Clang

https://reviews.llvm.org/D55339

Files:
  lib/AST/ASTDumper.cpp

Index: lib/AST/ASTDumper.cpp
===
--- lib/AST/ASTDumper.cpp
+++ lib/AST/ASTDumper.cpp
@@ -379,7 +379,6 @@
 void VisitOMPExecutableDirective(const OMPExecutableDirective *Node);
 
 // Exprs
-void VisitExpr(const Expr *Node);
 void VisitCastExpr(const CastExpr *Node);
 void VisitImplicitCastExpr(const ImplicitCastExpr *Node);
 void VisitDeclRefExpr(const DeclRefExpr *Node);
@@ -415,7 +414,6 @@
 void VisitExprWithCleanups(const ExprWithCleanups *Node);
 void VisitUnresolvedLookupExpr(const UnresolvedLookupExpr *Node);
 void VisitLambdaExpr(const LambdaExpr *Node) {
-  VisitExpr(Node);
   dumpDecl(Node->getLambdaClass());
 }
 void VisitSizeOfPackExpr(const SizeOfPackExpr *Node);
@@ -1697,6 +1695,44 @@
 NodeDumper.dumpPointer(S);
 NodeDumper.dumpSourceRange(S->getSourceRange());
 
+if (auto *E = dyn_cast(S)) {
+  NodeDumper.dumpType(E->getType());
+
+  {
+ColorScope Color(OS, ShowColors, ValueKindColor);
+switch (E->getValueKind()) {
+case VK_RValue:
+  break;
+case VK_LValue:
+  OS << " lvalue";
+  break;
+case VK_XValue:
+  OS << " xvalue";
+  break;
+}
+  }
+
+  {
+ColorScope Color(OS, ShowColors, ObjectKindColor);
+switch (E->getObjectKind()) {
+case OK_Ordinary:
+  break;
+case OK_BitField:
+  OS << " bitfield";
+  break;
+case OK_ObjCProperty:
+  OS << " objcproperty";
+  break;
+case OK_ObjCSubscript:
+  OS << " objcsubscript";
+  break;
+case OK_VectorComponent:
+  OS << " vectorcomponent";
+  break;
+}
+  }
+}
+
 ConstStmtVisitor::Visit(S);
 
 // Some statements have custom mechanisms for dumping their children.
@@ -1799,44 +1835,6 @@
 //  Expr dumping methods.
 //===--===//
 
-void ASTDumper::VisitExpr(const Expr *Node) {
-  NodeDumper.dumpType(Node->getType());
-
-  {
-ColorScope Color(OS, ShowColors, ValueKindColor);
-switch (Node->getValueKind()) {
-case VK_RValue:
-  break;
-case VK_LValue:
-  OS << " lvalue";
-  break;
-case VK_XValue:
-  OS << " xvalue";
-  break;
-}
-  }
-
-  {
-ColorScope Color(OS, ShowColors, ObjectKindColor);
-switch (Node->getObjectKind()) {
-case OK_Ordinary:
-  break;
-case OK_BitField:
-  OS << " bitfield";
-  break;
-case OK_ObjCProperty:
-  OS << " objcproperty";
-  break;
-case OK_ObjCSubscript:
-  OS << " objcsubscript";
-  break;
-case OK_VectorComponent:
-  OS << " vectorcomponent";
-  break;
-}
-  }
-}
-
 static void dumpBasePath(raw_ostream &OS, const CastExpr *Node) {
   if (Node->path_empty())
 return;
@@ -1863,7 +1861,6 @@
 }
 
 void ASTDumper::VisitCastExpr(const CastExpr *Node) {
-  VisitExpr(Node);
   OS << " <";
   {
 ColorScope Color(OS, ShowColors, CastColor);
@@ -1880,8 +1877,6 @@
 }
 
 void ASTDumper::VisitDeclRefExpr(const DeclRefExpr *Node) {
-  VisitExpr(Node);
-
   OS << " ";
   NodeDumper.dumpBareDeclRef(Node->getDecl());
   if (Node->getDecl() != Node->getFoundDecl()) {
@@ -1892,7 +1887,6 @@
 }
 
 void ASTDumper::VisitUnresolvedLookupExpr(const UnresolvedLookupExpr *Node) {
-  VisitExpr(Node);
   OS << " (";
   if (!Node->requiresADL())
 OS << "no ";
@@ -1907,8 +1901,6 @@
 }
 
 void ASTDumper::VisitObjCIvarRefExpr(const ObjCIvarRefExpr *Node) {
-  VisitExpr(Node);
-
   {
 ColorScope Color(OS, ShowColors, DeclKindNameColor);
 OS << " " << Node->getDecl()->getDeclKindName() << "Decl";
@@ -1920,46 +1912,37 @@
 }
 
 void ASTDumper::VisitPredefinedExpr(const PredefinedExpr *Node) {
-  VisitExpr(Node);
   OS << " " << PredefinedExpr::getIdentKindName(Node->getIdentKind());
 }
 
 void ASTDumper::VisitCharacterLiteral(const CharacterLiteral *Node) {
-  VisitExpr(Node);
   ColorScope Color(OS, ShowColors, ValueColor);
   OS << " " << Node->getValue();
 }
 
 void ASTDumper::VisitIntegerLiteral(const IntegerLiteral *Node) {
-  VisitExpr(Node);
-
   bool isSigned = Node->getType()->isSignedIntegerType();
   ColorScope Color(OS, ShowColors, ValueColor);
   OS << " " << Node->getValue().toString(10, isSigned);
 }
 
 void ASTDumper::VisitFixedPointLiteral(const FixedPointLiteral *Node) {
-  VisitExpr(Node);
-
   ColorScope Color(OS, ShowColors, ValueColor);
   OS << " " << Node->getValueAsString(/*Radix=*/10);
 }
 
 void ASTDumper::VisitFloatingLite

[PATCH] D55338: NFC: Move VisitStmt code to dumpStmt

2018-12-05 Thread Stephen Kelly via Phabricator via cfe-commits
steveire created this revision.
steveire added a reviewer: aaron.ballman.
Herald added a subscriber: cfe-commits.

This call is duplicated in Visits of all direct subclasses of Stmt.


Repository:
  rC Clang

https://reviews.llvm.org/D55338

Files:
  lib/AST/ASTDumper.cpp

Index: lib/AST/ASTDumper.cpp
===
--- lib/AST/ASTDumper.cpp
+++ lib/AST/ASTDumper.cpp
@@ -364,7 +364,6 @@
 void VisitBlockDecl(const BlockDecl *D);
 
 // Stmts.
-void VisitStmt(const Stmt *Node);
 void VisitDeclStmt(const DeclStmt *Node);
 void VisitAttributedStmt(const AttributedStmt *Node);
 void VisitIfStmt(const IfStmt *Node);
@@ -1691,6 +1690,12 @@
   OS << "<<>>";
   return;
 }
+{
+  ColorScope Color(OS, ShowColors, StmtColor);
+  OS << S->getStmtClassName();
+}
+NodeDumper.dumpPointer(S);
+NodeDumper.dumpSourceRange(S->getSourceRange());
 
 ConstStmtVisitor::Visit(S);
 
@@ -1704,17 +1709,7 @@
   });
 }
 
-void ASTDumper::VisitStmt(const Stmt *Node) {
-  {
-ColorScope Color(OS, ShowColors, StmtColor);
-OS << Node->getStmtClassName();
-  }
-  NodeDumper.dumpPointer(Node);
-  NodeDumper.dumpSourceRange(Node->getSourceRange());
-}
-
 void ASTDumper::VisitDeclStmt(const DeclStmt *Node) {
-  VisitStmt(Node);
   for (DeclStmt::const_decl_iterator I = Node->decl_begin(),
  E = Node->decl_end();
I != E; ++I)
@@ -1722,7 +1717,6 @@
 }
 
 void ASTDumper::VisitAttributedStmt(const AttributedStmt *Node) {
-  VisitStmt(Node);
   for (ArrayRef::iterator I = Node->getAttrs().begin(),
 E = Node->getAttrs().end();
I != E; ++I)
@@ -1730,7 +1724,6 @@
 }
 
 void ASTDumper::VisitIfStmt(const IfStmt *Node) {
-  VisitStmt(Node);
   if (Node->hasInitStorage())
 OS << " has_init";
   if (Node->hasVarStorage())
@@ -1740,7 +1733,6 @@
 }
 
 void ASTDumper::VisitSwitchStmt(const SwitchStmt *Node) {
-  VisitStmt(Node);
   if (Node->hasInitStorage())
 OS << " has_init";
   if (Node->hasVarStorage())
@@ -1748,35 +1740,29 @@
 }
 
 void ASTDumper::VisitWhileStmt(const WhileStmt *Node) {
-  VisitStmt(Node);
   if (Node->hasVarStorage())
 OS << " has_var";
 }
 
 void ASTDumper::VisitLabelStmt(const LabelStmt *Node) {
-  VisitStmt(Node);
   OS << " '" << Node->getName() << "'";
 }
 
 void ASTDumper::VisitGotoStmt(const GotoStmt *Node) {
-  VisitStmt(Node);
   OS << " '" << Node->getLabel()->getName() << "'";
   NodeDumper.dumpPointer(Node->getLabel());
 }
 
 void ASTDumper::VisitCXXCatchStmt(const CXXCatchStmt *Node) {
-  VisitStmt(Node);
   dumpDecl(Node->getExceptionDecl());
 }
 
 void ASTDumper::VisitCaseStmt(const CaseStmt *Node) {
-  VisitStmt(Node);
   if (Node->caseStmtIsGNURange())
 OS << " gnu_range";
 }
 
 void ASTDumper::VisitCapturedStmt(const CapturedStmt *Node) {
-  VisitStmt(Node);
   dumpDecl(Node->getCapturedDecl());
 }
 
@@ -1786,7 +1772,6 @@
 
 void ASTDumper::VisitOMPExecutableDirective(
 const OMPExecutableDirective *Node) {
-  VisitStmt(Node);
   for (auto *C : Node->clauses()) {
 dumpChild([=] {
   if (!C) {
@@ -1815,7 +1800,6 @@
 //===--===//
 
 void ASTDumper::VisitExpr(const Expr *Node) {
-  VisitStmt(Node);
   NodeDumper.dumpType(Node->getType());
 
   {
@@ -2241,7 +2225,6 @@
 }
 
 void ASTDumper::VisitObjCAtCatchStmt(const ObjCAtCatchStmt *Node) {
-  VisitStmt(Node);
   if (const VarDecl *CatchParam = Node->getCatchParamDecl())
 dumpDecl(CatchParam);
   else
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D55337: NFC: Move dumpDeclRef to NodeDumper

2018-12-05 Thread Stephen Kelly via Phabricator via cfe-commits
steveire created this revision.
steveire added a reviewer: aaron.ballman.
Herald added a subscriber: cfe-commits.

Repository:
  rC Clang

https://reviews.llvm.org/D55337

Files:
  include/clang/AST/TextNodeDumper.h
  lib/AST/ASTDumper.cpp
  lib/AST/TextNodeDumper.cpp

Index: lib/AST/TextNodeDumper.cpp
===
--- lib/AST/TextNodeDumper.cpp
+++ lib/AST/TextNodeDumper.cpp
@@ -15,12 +15,13 @@
 
 using namespace clang;
 
-TextNodeDumper::TextNodeDumper(raw_ostream &OS, bool ShowColors,
+TextNodeDumper::TextNodeDumper(TextTreeStructure &TreeStructure,
+   raw_ostream &OS, bool ShowColors,
const SourceManager *SM,
const PrintingPolicy &PrintPolicy,
const comments::CommandTraits *Traits)
-: OS(OS), ShowColors(ShowColors), SM(SM), PrintPolicy(PrintPolicy),
-  Traits(Traits) {}
+: TreeStructure(TreeStructure), OS(OS), ShowColors(ShowColors), SM(SM),
+  PrintPolicy(PrintPolicy), Traits(Traits) {}
 
 void TextNodeDumper::visit(const comments::Comment *C,
const comments::FullComment *FC) {
@@ -161,6 +162,17 @@
   OS << ")";
 }
 
+void TextNodeDumper::dumpDeclRef(const Decl *D, const char *Label) {
+  if (!D)
+return;
+
+  TreeStructure.addChild([=] {
+if (Label)
+  OS << Label << ' ';
+dumpBareDeclRef(D);
+  });
+}
+
 const char *TextNodeDumper::getCommandName(unsigned CommandID) {
   if (Traits)
 return Traits->getCommandInfo(CommandID)->Name;
Index: lib/AST/ASTDumper.cpp
===
--- lib/AST/ASTDumper.cpp
+++ lib/AST/ASTDumper.cpp
@@ -76,8 +76,8 @@
   const SourceManager *SM, bool ShowColors,
   const PrintingPolicy &PrintPolicy)
 : TreeStructure(OS, ShowColors),
-  NodeDumper(OS, ShowColors, SM, PrintPolicy, Traits), OS(OS),
-  PrintPolicy(PrintPolicy), ShowColors(ShowColors) {}
+  NodeDumper(TreeStructure, OS, ShowColors, SM, PrintPolicy, Traits),
+  OS(OS), PrintPolicy(PrintPolicy), ShowColors(ShowColors) {}
 
 void setDeserialize(bool D) { Deserialize = D; }
 
@@ -89,7 +89,6 @@
 void dumpType(QualType T) { NodeDumper.dumpType(T); }
 void dumpTypeAsChild(QualType T);
 void dumpTypeAsChild(const Type *T);
-void dumpDeclRef(const Decl *Node, const char *Label = nullptr);
 void dumpBareDeclRef(const Decl *Node) { NodeDumper.dumpBareDeclRef(Node); }
 bool hasNodes(const DeclContext *DC);
 void dumpDeclContext(const DeclContext *DC);
@@ -208,10 +207,10 @@
 dumpChild([=] { OS << "..."; });
 }
 void VisitUnresolvedUsingType(const UnresolvedUsingType *T) {
-  dumpDeclRef(T->getDecl());
+  NodeDumper.dumpDeclRef(T->getDecl());
 }
 void VisitTypedefType(const TypedefType *T) {
-  dumpDeclRef(T->getDecl());
+  NodeDumper.dumpDeclRef(T->getDecl());
 }
 void VisitTypeOfExprType(const TypeOfExprType *T) {
   dumpStmt(T->getUnderlyingExpr());
@@ -228,7 +227,7 @@
   dumpTypeAsChild(T->getBaseType());
 }
 void VisitTagType(const TagType *T) {
-  dumpDeclRef(T->getDecl());
+  NodeDumper.dumpDeclRef(T->getDecl());
 }
 void VisitAttributedType(const AttributedType *T) {
   // FIXME: AttrKind
@@ -237,7 +236,7 @@
 void VisitTemplateTypeParmType(const TemplateTypeParmType *T) {
   OS << " depth " << T->getDepth() << " index " << T->getIndex();
   if (T->isParameterPack()) OS << " pack";
-  dumpDeclRef(T->getDecl());
+  NodeDumper.dumpDeclRef(T->getDecl());
 }
 void VisitSubstTemplateTypeParmType(const SubstTemplateTypeParmType *T) {
   dumpTypeAsChild(T->getReplacedParameter());
@@ -261,10 +260,10 @@
 dumpTypeAsChild(T->getAliasedType());
 }
 void VisitInjectedClassNameType(const InjectedClassNameType *T) {
-  dumpDeclRef(T->getDecl());
+  NodeDumper.dumpDeclRef(T->getDecl());
 }
 void VisitObjCInterfaceType(const ObjCInterfaceType *T) {
-  dumpDeclRef(T->getDecl());
+  NodeDumper.dumpDeclRef(T->getDecl());
 }
 void VisitObjCObjectPointerType(const ObjCObjectPointerType *T) {
   dumpTypeAsChild(T->getPointeeType());
@@ -508,17 +507,6 @@
   });
 }
 
-void ASTDumper::dumpDeclRef(const Decl *D, const char *Label) {
-  if (!D)
-return;
-
-  dumpChild([=]{
-if (Label)
-  OS << Label << ' ';
-dumpBareDeclRef(D);
-  });
-}
-
 bool ASTDumper::hasNodes(const DeclContext *DC) {
   if (!DC)
 return false;
@@ -713,7 +701,7 @@
   break;
 case TemplateArgument::Declaration:
   OS << " decl";
-  dumpDeclRef(A.getAsDecl());
+  NodeDumper.dumpDeclRef(A.getAsDecl());
   break;
 case TemplateArgument::NullPtr:
   OS << " nullptr";
@@ -864,7 +852,7 @@
   NodeDumper.dumpType(D->getType());
 
   for (auto *Child : D->chain())
-dumpDeclRef(Ch

Re: [cfe-dev] r347339 - [clang][Parse] Diagnose useless null statements / empty init-statements

2018-12-05 Thread James Y Knight via cfe-commits
Nobody should be using "-Weverything" in their default build flags! It
should only be used as a way to find the names of interesting warning
flags. I'd note that "-Weverything" even has warnings that _conflict_ with
each-other...

It's unworkable for clang to have a policy which prevents the addition of
new warning options just because someone enables -Weverything... If people
feel like that is what's happening now, we need to fix that. If that's what
it comes to, even deleting the -Weverything flag would be better.

The question I'd ask for new warnings is a different one: is this warning
something which people could feasibly decide to *opt into*, with -Werror,
for their entire project? This does appear to meet that criteria -- the
cases where it warns do appear to be indicating potential issues, and the
code fix which silences the warning will improve the code, not make it
worse.

On Wed, Dec 5, 2018 at 2:51 PM Aaron Ballman via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> On Wed, Dec 5, 2018 at 2:14 PM Alex L via cfe-commits
>  wrote:
> >
> > We have about 100k unique occurrences of this warning across a slice of
> our software stack. It's simply not feasible to us to adopt it, so we would
> prefer for it to be reverted to avoid downstream divergence in Apple's
> clang. Granted, these occur in projects that use -Weverything but those
> projects are typically understanding of warnings that they can turn off
> when they see that they provide useful value in terms of warnings about
> unintended behavior that's sometimes caught. This warning doesn't seem to
> catch unintended bugs and it would be a heroic battle to adopt it for us in
> a way where projects are somewhat satisfied. It seems to be a better fit
> for a clang-tidy check that could suggest automatic fixits and that the
> users could run on their codebase to "modernize" if they want to.
>
> I'm not certain I agree that this does not catch unintended bugs.
> After all, it started a discussion that pointed out design issues with
> two different macros which were provided as examples of
> false-positives. I think this diagnostic points out bad code smells
> and is no more stylistic than some of the other diagnostics in
> -Weverything, like not having a previous prototype before defining a
> function. I am not sold on the idea that this diagnostic should be
> moved into clang-tidy simply because it's showing up in a lot of
> -Weverything builds.
>
> ~Aaron
>
> >
> > Cheers,
> > Alex
> >
> > On Wed, 5 Dec 2018 at 10:43, Richard Smith via cfe-dev <
> cfe-...@lists.llvm.org> wrote:
> >>
> >> On Wed, 5 Dec 2018, 10:01 George Karpenkov via cfe-commits <
> cfe-commits@lists.llvm.org wrote:
> >>>
> >>> These are the cases I get:
> >>>
> >>> #define unexpected(a) { kprintf("unexpected %s:%d\n", __FILE__,
> __LINE__); a; }
> >>>
> >>> and
> >>>
> >>> #if 0
> >>> #define DEBG(fmt, args...)  { IOLog(fmt, ## args); kprintf(fmt, ##
> args); }
> >>> #else
> >>> #define DEBG(fmt, args...)  {}
> >>> #endif
> >>>
> >>> Now calls
> >>>
> >>> `DEBG(‘x’);` and `unexpected(‘msg’);`
> >>>
> >>> cause the warning to be fired.
> >>> Of course, semicolon could be omitted, but the fact that the macro has
> braces is sort of an implementation detail.
> >>>
> >>> Greg Parker has pointed out it’s possible to rewrite the macros using
> the “do { … } while (0)”,
> >>> but that is a lot of macros to change, and the resulting code would be
> arguably less readable.
> >>
> >>
> >> That suggestion is the (or at least an) idiomatic way to write a
> "statement-like" macro that expects a semicolon. The approach taken by the
> above macros is often considered to be a macro antipattern (try putting it
> in an unbraced if and adding an else clause, for example).
> >>>
> >>> On Dec 5, 2018, at 5:10 AM, Aaron Ballman 
> wrote:
> >>>
> >>> On Wed, Dec 5, 2018 at 1:40 AM Roman Lebedev 
> wrote:
> >>>
> >>>
> >>> It is a problem in practice for us since we have projects which enable
> all available warnings and also enable “-Werror”.
> >>>
> >>> Hm, they have asked for -Weverything and they got it. Seems to be
> >>> working as intended.
> >>> When in previous discussions elsewhere i have talked about
> >>> -Weverything, i was always
> >>> been told that it isn't supposed to be used like that (admittedly, i
> >>> *do* use it like that :)).
> >>>
> >>> Could you explain how is this different from any other warning that is
> >>> considered pointless by the project?
> >>> Why not simply disable it?
> >>>
> >>>
> >>> You are right, it could be disabled. It’s just for this warning the
> noise vs. usefulness ratio seemed pretty low.
> >>>
> >>>
> >>> Would you be okay with the warning if it was only diagnosed when the
> >>> source location of the semi-colon is not immediately preceded by a
> >>> macro expansion location? e.g.,
> >>>
> >>> EMPTY_EXPANSION(12); // Not diagnosed
> >>> EMPTY_EXPANSION; // Not diagnosed
> >>> ; // Diagnosed
> >>>
> >>> This could work provided that all empty s

Re: r348408 - Add dump tests for inherited default template parameters

2018-12-05 Thread Stephen Kelly via cfe-commits

Surely all of the tests specifically about template decls should be moved?

On 05/12/2018 20:31, Aaron Ballman wrote:

On Wed, Dec 5, 2018 at 3:24 PM Stephen Kelly via cfe-commits
 wrote:

Author: steveire
Date: Wed Dec  5 12:21:13 2018
New Revision: 348408

URL: http://llvm.org/viewvc/llvm-project?rev=348408&view=rev
Log:
Add dump tests for inherited default template parameters

Modified:
 cfe/trunk/test/AST/ast-dump-decl.cpp

Can you move these tests into ast-dump-template-decls.cpp?

~Aaron


Modified: cfe/trunk/test/AST/ast-dump-decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/ast-dump-decl.cpp?rev=348408&r1=348407&r2=348408&view=diff
==
--- cfe/trunk/test/AST/ast-dump-decl.cpp (original)
+++ cfe/trunk/test/AST/ast-dump-decl.cpp Wed Dec  5 12:21:13 2018
@@ -263,6 +263,15 @@ namespace testClassTemplateDecl {
template class TestClassTemplatePartial {
  int j;
};
+
+  template struct TestTemplateDefaultType;
+  template struct TestTemplateDefaultType { };
+
+  template struct TestTemplateDefaultNonType;
+  template struct TestTemplateDefaultNonType { };
+
+  template class TT = TestClassTemplate> struct 
TestTemplateTemplateDefaultType;
+  template class TT> struct TestTemplateTemplateDefaultType 
{ };
  }
  // CHECK:  ClassTemplateDecl{{.*}} TestClassTemplate
  // CHECK-NEXT:   TemplateTypeParmDecl
@@ -316,6 +325,24 @@ namespace testClassTemplateDecl {
  // CHECK-NEXT:   CXXRecordDecl{{.*}} class TestClassTemplatePartial
  // CHECK-NEXT:   FieldDecl{{.*}} j

+// CHECK:  ClassTemplateDecl 0x{{[^ ]*}} prev 0x{{[^ ]*}} {{.*}} 
TestTemplateDefaultType
+// CHECK-NEXT:   TemplateTypeParmDecl
+// CHECK-NEXT: TemplateArgument type 'int'
+// CHECK-NEXT: inherited from TemplateTypeParm 0x{{[^ ]*}} 'T'
+
+// CHECK:  ClassTemplateDecl 0x{{[^ ]*}} prev 0x{{[^ ]*}} {{.*}} 
TestTemplateDefaultNonType
+// CHECK-NEXT:   NonTypeTemplateParmDecl
+// CHECK-NEXT: TemplateArgument expr
+// CHECK-NEXT:   ConstantExpr
+// CHECK-NEXT: IntegerLiteral
+// CHECK-NEXT: inherited from NonTypeTemplateParm 0x{{[^ ]*}} 'I' 'int'
+
+// CHECK:  ClassTemplateDecl 0x{{[^ ]*}} prev 0x{{[^ ]*}} {{.*}} 
TestTemplateTemplateDefaultType
+// CHECK-NEXT:   TemplateTemplateParmDecl
+// CHECK-NEXT: TemplateTypeParmDecl
+// CHECK-NEXT: TemplateArgument
+// CHECK-NEXT: inherited from TemplateTemplateParm 0x{{[^ ]*}} 'TT'
+
  // PR15220 dump instantiation only once
  namespace testCanonicalTemplate {
class A {};


___
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] D55188: Extract TextChildDumper class

2018-12-05 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL348410: NFC: Extract TextTreeStructure class (authored by 
steveire, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D55188?vs=176467&id=176867#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D55188

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

Index: cfe/trunk/lib/AST/ASTDumper.cpp
===
--- cfe/trunk/lib/AST/ASTDumper.cpp
+++ cfe/trunk/lib/AST/ASTDumper.cpp
@@ -13,6 +13,7 @@
 //===--===//
 
 #include "clang/AST/ASTContext.h"
+#include "clang/AST/ASTDumperUtils.h"
 #include "clang/AST/Attr.h"
 #include "clang/AST/CommentVisitor.h"
 #include "clang/AST/DeclCXX.h"
@@ -35,78 +36,6 @@
 //===--===//
 
 namespace  {
-  // Colors used for various parts of the AST dump
-  // Do not use bold yellow for any text.  It is hard to read on white screens.
-
-  struct TerminalColor {
-raw_ostream::Colors Color;
-bool Bold;
-  };
-
-  // Red   - CastColor
-  // Green - TypeColor
-  // Bold Green- DeclKindNameColor, UndeserializedColor
-  // Yellow- AddressColor, LocationColor
-  // Blue  - CommentColor, NullColor, IndentColor
-  // Bold Blue - AttrColor
-  // Bold Magenta  - StmtColor
-  // Cyan  - ValueKindColor, ObjectKindColor
-  // Bold Cyan - ValueColor, DeclNameColor
-
-  // Decl kind names (VarDecl, FunctionDecl, etc)
-  static const TerminalColor DeclKindNameColor = { raw_ostream::GREEN, true };
-  // Attr names (CleanupAttr, GuardedByAttr, etc)
-  static const TerminalColor AttrColor = { raw_ostream::BLUE, true };
-  // Statement names (DeclStmt, ImplicitCastExpr, etc)
-  static const TerminalColor StmtColor = { raw_ostream::MAGENTA, true };
-  // Comment names (FullComment, ParagraphComment, TextComment, etc)
-  static const TerminalColor CommentColor = { raw_ostream::BLUE, false };
-
-  // Type names (int, float, etc, plus user defined types)
-  static const TerminalColor TypeColor = { raw_ostream::GREEN, false };
-
-  // Pointer address
-  static const TerminalColor AddressColor = { raw_ostream::YELLOW, false };
-  // Source locations
-  static const TerminalColor LocationColor = { raw_ostream::YELLOW, false };
-
-  // lvalue/xvalue
-  static const TerminalColor ValueKindColor = { raw_ostream::CYAN, false };
-  // bitfield/objcproperty/objcsubscript/vectorcomponent
-  static const TerminalColor ObjectKindColor = { raw_ostream::CYAN, false };
-
-  // Null statements
-  static const TerminalColor NullColor = { raw_ostream::BLUE, false };
-
-  // Undeserialized entities
-  static const TerminalColor UndeserializedColor = { raw_ostream::GREEN, true };
-
-  // CastKind from CastExpr's
-  static const TerminalColor CastColor = { raw_ostream::RED, false };
-
-  // Value of the statement
-  static const TerminalColor ValueColor = { raw_ostream::CYAN, true };
-  // Decl names
-  static const TerminalColor DeclNameColor = { raw_ostream::CYAN, true };
-
-  // Indents ( `, -. | )
-  static const TerminalColor IndentColor = { raw_ostream::BLUE, false };
-
-  class ColorScope {
-raw_ostream &OS;
-const bool ShowColors;
-
-  public:
-ColorScope(raw_ostream &OS, bool ShowColors, TerminalColor Color)
-: OS(OS), ShowColors(ShowColors) {
-  if (ShowColors)
-OS.changeColor(Color.Color, Color.Bold);
-}
-~ColorScope() {
-  if (ShowColors)
-OS.resetColor();
-}
-  };
 
   class ASTDumper
   : public ConstDeclVisitor,
@@ -114,6 +43,8 @@
 public ConstCommentVisitor,
 public TypeVisitor {
 
+TextTreeStructure TreeStructure;
+
 raw_ostream &OS;
 const CommandTraits *Traits;
 const SourceManager *SM;
@@ -121,22 +52,10 @@
 /// The policy to use for printing; can be defaulted.
 PrintingPolicy PrintPolicy;
 
-/// Pending[i] is an action to dump an entity at level i.
-llvm::SmallVector, 32> Pending;
-
 /// Indicates whether we should trigger deserialization of nodes that had
 /// not already been loaded.
 bool Deserialize = false;
 
-/// Indicates whether we're at the top level.
-bool TopLevel = true;
-
-/// Indicates if we're handling the first child after entering a new depth.
-bool FirstChild = true;
-
-/// Prefix for currently-being-dumped entity.
-std::string Prefix;
-
 /// Keep track of the last location we print out so that we can
 /// print out deltas from then on out.
 const char *LastLocFilename = "";
@@ -146,65 +65,7 @@
 
 /// Dump a child of the current node.
 template void dumpChild(Fn doDumpChild) {
-  // If we're at the top level, there's nothin

r348410 - NFC: Extract TextTreeStructure class

2018-12-05 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Wed Dec  5 12:53:14 2018
New Revision: 348410

URL: http://llvm.org/viewvc/llvm-project?rev=348410&view=rev
Log:
NFC: Extract TextTreeStructure class

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

Added:
cfe/trunk/include/clang/AST/ASTDumperUtils.h
Modified:
cfe/trunk/lib/AST/ASTDumper.cpp

Added: cfe/trunk/include/clang/AST/ASTDumperUtils.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTDumperUtils.h?rev=348410&view=auto
==
--- cfe/trunk/include/clang/AST/ASTDumperUtils.h (added)
+++ cfe/trunk/include/clang/AST/ASTDumperUtils.h Wed Dec  5 12:53:14 2018
@@ -0,0 +1,181 @@
+//===--- ASTDumperUtils.h - Printing of AST nodes 
-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This file implements AST utilities for traversal down the tree.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_AST_ASTDUMPERUTILS_H
+#define LLVM_CLANG_AST_ASTDUMPERUTILS_H
+
+#include "clang/AST/ASTContext.h"
+#include "llvm/Support/raw_ostream.h"
+
+namespace clang {
+
+// Colors used for various parts of the AST dump
+// Do not use bold yellow for any text.  It is hard to read on white screens.
+
+struct TerminalColor {
+  raw_ostream::Colors Color;
+  bool Bold;
+};
+
+// Red   - CastColor
+// Green - TypeColor
+// Bold Green- DeclKindNameColor, UndeserializedColor
+// Yellow- AddressColor, LocationColor
+// Blue  - CommentColor, NullColor, IndentColor
+// Bold Blue - AttrColor
+// Bold Magenta  - StmtColor
+// Cyan  - ValueKindColor, ObjectKindColor
+// Bold Cyan - ValueColor, DeclNameColor
+
+// Decl kind names (VarDecl, FunctionDecl, etc)
+static const TerminalColor DeclKindNameColor = {raw_ostream::GREEN, true};
+// Attr names (CleanupAttr, GuardedByAttr, etc)
+static const TerminalColor AttrColor = {raw_ostream::BLUE, true};
+// Statement names (DeclStmt, ImplicitCastExpr, etc)
+static const TerminalColor StmtColor = {raw_ostream::MAGENTA, true};
+// Comment names (FullComment, ParagraphComment, TextComment, etc)
+static const TerminalColor CommentColor = {raw_ostream::BLUE, false};
+
+// Type names (int, float, etc, plus user defined types)
+static const TerminalColor TypeColor = {raw_ostream::GREEN, false};
+
+// Pointer address
+static const TerminalColor AddressColor = {raw_ostream::YELLOW, false};
+// Source locations
+static const TerminalColor LocationColor = {raw_ostream::YELLOW, false};
+
+// lvalue/xvalue
+static const TerminalColor ValueKindColor = {raw_ostream::CYAN, false};
+// bitfield/objcproperty/objcsubscript/vectorcomponent
+static const TerminalColor ObjectKindColor = {raw_ostream::CYAN, false};
+
+// Null statements
+static const TerminalColor NullColor = {raw_ostream::BLUE, false};
+
+// Undeserialized entities
+static const TerminalColor UndeserializedColor = {raw_ostream::GREEN, true};
+
+// CastKind from CastExpr's
+static const TerminalColor CastColor = {raw_ostream::RED, false};
+
+// Value of the statement
+static const TerminalColor ValueColor = {raw_ostream::CYAN, true};
+// Decl names
+static const TerminalColor DeclNameColor = {raw_ostream::CYAN, true};
+
+// Indents ( `, -. | )
+static const TerminalColor IndentColor = {raw_ostream::BLUE, false};
+
+class ColorScope {
+  raw_ostream &OS;
+  const bool ShowColors;
+
+public:
+  ColorScope(raw_ostream &OS, bool ShowColors, TerminalColor Color)
+  : OS(OS), ShowColors(ShowColors) {
+if (ShowColors)
+  OS.changeColor(Color.Color, Color.Bold);
+  }
+  ~ColorScope() {
+if (ShowColors)
+  OS.resetColor();
+  }
+};
+
+class TextTreeStructure {
+  raw_ostream &OS;
+  const bool ShowColors;
+
+  /// Pending[i] is an action to dump an entity at level i.
+  llvm::SmallVector, 32> Pending;
+
+  /// Indicates whether we're at the top level.
+  bool TopLevel = true;
+
+  /// Indicates if we're handling the first child after entering a new depth.
+  bool FirstChild = true;
+
+  /// Prefix for currently-being-dumped entity.
+  std::string Prefix;
+
+public:
+  /// Add a child of the current node.  Calls doAddChild without arguments
+  template  void addChild(Fn doAddChild) {
+// If we're at the top level, there's nothing interesting to do; just
+// run the dumper.
+if (TopLevel) {
+  TopLevel = false;
+  doAddChild();
+  while (!Pending.empty()) {
+Pending.back()(true);
+Pending.pop_back();
+  }
+  Prefix.clear();
+  OS << "\n";
+  TopLevel = true;
+  return;
+}
+
+auto dumpWithIndent = [this, doAddChild](bool isLastChild) {
+

[PATCH] D55289: [analyzer] MoveChecker Pt.5: Improve invalidation policies.

2018-12-05 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/MoveChecker.cpp:540-542
+// Explicit regions are the regions passed into the call directly, but
+// not all of them end up being invalidated. The ones that do appear in
+// the Regions array as well.

Szelethus wrote:
> Really? Then I guess this needs to be updated in `CheckerDocumentation.cpp`:
> 
> ```
>   /// \param ExplicitRegions The regions explicitly requested for 
> invalidation.
>   ///For a function call, this would be the arguments. For a bind, 
> this
>   ///would be the region being bound to.
> ```
> 
> To me, this clearly indicates that the elements of `ExplicitRegions` will be 
> invalidated. Does "requested for" really just mean "requested for potential"? 
> Since this happens //before// any invalidation, it could easily be 
> interpreted as "invalidated after the end of the callback".
The callback fires after invalidation - cf. 
`ProgramState::invalidateRegionsImpl`. Note that the `if (Eng)` condition is 
always true, because how the heck were we supposed to run path-sensitive 
analysis without `ExprEngine`.

The terminology is really weird here because we the word "invalidation" has too 
many meanings. Essentially, `ExplicitRegions` are regions that were 
specifically requested for invalidation, but it is up to the `CallEvent` / 
`ProgramState` / `StoreManager` (depending on which `invalidateRegions()` was 
called) to decide what invalidation means in this case by filling in the 
`RegionAndSymbolInvalidationTraits` map.

For regions that represent values of const pointers/references directly passed 
into the function, `CallEvent` decides to set the `TK_PreserveContents` trait, 
which says "invalidate the region but keep its contents intact". It would still 
perform other forms of invalidation on that region, say, pointer escape: if 
there are pointer values written down somewhere within that region, checkers 
need to stop tracking them.

Now, the callback never said that it has something to do with "invalidation". 
Instead, it is about "region changes", which means changes of the region's 
contents in the Store. This doesn't necessarily happen due to invalidation; it 
may also happen while evaluating a simple assignment in the program, as we see 
in the newly added `testUpdateField()` test. And, as we've seen above, not 
every "invalidation" changes contents of the region.

Similarly, `TK_SuppressEscape` would suppress the `checkPointerEscape()` 
callback for the region, but will not suppress `checkRegionChanges()` for that 
(non-explicit) region.

Therefore we end up in a weird situation when some regions were requested to be 
invalidated but never were actually invalidated in terms of the Store. It kinda 
 makes sense, but i hate it anyway.  The `checkRegionChanges()` callback is 
hard to understand and hard to use and too general and has too much stuff 
stuffed into it. `checkPointerEscape` is an easier-to-use fork of it, but it 
doesn't cover the use case of checkers that track objects via regions. I 
suspect that the right solution here is to start tracking objects as "symbols", 
i.e., assign a unique opaque ID to every state through which every object in 
the program goes (regardless of which object it is) and use that as keys in the 
map. That should remove the stress of dealing with invalidation from C++ 
checkers that need to track objects opaquely. The problem won't magically 
disappear, as we still need to identify when exactly does the state change, but 
an additional level of indirection (Region -> ID -> CheckerState instead of 
just Region -> CheckerState) allows us to decompose it into smaller parts and 
de-duplicate some of this work.

But regardless of that, it is still weird that `ExplicitRegions` is not a 
sub-set of `Regions`. We need to either document it or fix it, and for some 
reason i prefer the latter. In particular, the only checker that actually 
actively acts upon `ExplicitRegions` when they're const is 
`RetainCountChecker`, but in fact people don't ever use `const` in stuff that 
it checks, it just isn't idiomatic.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55289



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


[PATCH] D55307: [analyzer] MoveChecker Pt.6: Suppress the warning for the few move-safe STL classes.

2018-12-05 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added inline comments.



Comment at: test/Analysis/diagnostics/explicit-suppression.cpp:22
 #ifndef SUPPRESSED
-  // expected-warning@../Inputs/system-header-simulator-cxx.h:670 {{Called C++ 
object pointer is null}}
+  // expected-warning@../Inputs/system-header-simulator-cxx.h:677 {{Called C++ 
object pointer is null}}
 #endif

Szelethus wrote:
> NoQ wrote:
> > Szelethus wrote:
> > > Can't we just change this to `// expected-warning{{Called C++ object 
> > > pointer is null}}`? This file is so tiny, I think it wouldn't cause much 
> > > confusion, and  reduces unnecessary maintenance work.
> > I don't think it'll work. The warning is not on this line, it is in 
> > `system-header-simulator-cxx.h`, so we need to specify it somehow, and 
> > it'll appear only in this test, not in other tests that include that 
> > header, so we can't put it directly into the header.
> Ah, okay.
But since this is the only warning in the file, we could get away with it 
of we use `FileCheck`! But I leave it up to you.

I had a lot of bots breaking on me because I forgot `git add` on this file 
once, so I might end up fixing it myself.


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

https://reviews.llvm.org/D55307



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


r348409 - NFC: Inline handling of DependentSizedArrayType

2018-12-05 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Wed Dec  5 12:34:07 2018
New Revision: 348409

URL: http://llvm.org/viewvc/llvm-project?rev=348409&view=rev
Log:
NFC: Inline handling of DependentSizedArrayType

Summary:
Re-order handling of getElementType and getBracketsRange. It is
necessary to perform all printing before any traversal to child nodes.

This causes no change in the output of ast-dump-array.cpp due to the way
child nodes are printed with a delay.  This new order of the code is
also the order that produces the expected output anyway.

Subscribers: cfe-commits

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

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

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=348409&r1=348408&r2=348409&view=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Wed Dec  5 12:34:07 2018
@@ -299,9 +299,15 @@ namespace  {
   dumpStmt(T->getSizeExpr());
 }
 void VisitDependentSizedArrayType(const DependentSizedArrayType *T) {
-  VisitArrayType(T);
+  switch (T->getSizeModifier()) {
+case ArrayType::Normal: break;
+case ArrayType::Static: OS << " static"; break;
+case ArrayType::Star: OS << " *"; break;
+  }
+  OS << " " << T->getIndexTypeQualifiers().getAsString();
   OS << " ";
   dumpSourceRange(T->getBracketsRange());
+  dumpTypeAsChild(T->getElementType());
   dumpStmt(T->getSizeExpr());
 }
 void VisitDependentSizedExtVectorType(


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


[PATCH] D55257: Inline handling of DependentSizedArrayType

2018-12-05 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL348409: NFC: Inline handling of DependentSizedArrayType 
(authored by steveire, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D55257

Files:
  cfe/trunk/lib/AST/ASTDumper.cpp


Index: cfe/trunk/lib/AST/ASTDumper.cpp
===
--- cfe/trunk/lib/AST/ASTDumper.cpp
+++ cfe/trunk/lib/AST/ASTDumper.cpp
@@ -299,9 +299,15 @@
   dumpStmt(T->getSizeExpr());
 }
 void VisitDependentSizedArrayType(const DependentSizedArrayType *T) {
-  VisitArrayType(T);
+  switch (T->getSizeModifier()) {
+case ArrayType::Normal: break;
+case ArrayType::Static: OS << " static"; break;
+case ArrayType::Star: OS << " *"; break;
+  }
+  OS << " " << T->getIndexTypeQualifiers().getAsString();
   OS << " ";
   dumpSourceRange(T->getBracketsRange());
+  dumpTypeAsChild(T->getElementType());
   dumpStmt(T->getSizeExpr());
 }
 void VisitDependentSizedExtVectorType(


Index: cfe/trunk/lib/AST/ASTDumper.cpp
===
--- cfe/trunk/lib/AST/ASTDumper.cpp
+++ cfe/trunk/lib/AST/ASTDumper.cpp
@@ -299,9 +299,15 @@
   dumpStmt(T->getSizeExpr());
 }
 void VisitDependentSizedArrayType(const DependentSizedArrayType *T) {
-  VisitArrayType(T);
+  switch (T->getSizeModifier()) {
+case ArrayType::Normal: break;
+case ArrayType::Static: OS << " static"; break;
+case ArrayType::Star: OS << " *"; break;
+  }
+  OS << " " << T->getIndexTypeQualifiers().getAsString();
   OS << " ";
   dumpSourceRange(T->getBracketsRange());
+  dumpTypeAsChild(T->getElementType());
   dumpStmt(T->getSizeExpr());
 }
 void VisitDependentSizedExtVectorType(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r348408 - Add dump tests for inherited default template parameters

2018-12-05 Thread Aaron Ballman via cfe-commits
On Wed, Dec 5, 2018 at 3:24 PM Stephen Kelly via cfe-commits
 wrote:
>
> Author: steveire
> Date: Wed Dec  5 12:21:13 2018
> New Revision: 348408
>
> URL: http://llvm.org/viewvc/llvm-project?rev=348408&view=rev
> Log:
> Add dump tests for inherited default template parameters
>
> Modified:
> cfe/trunk/test/AST/ast-dump-decl.cpp

Can you move these tests into ast-dump-template-decls.cpp?

~Aaron

>
> Modified: cfe/trunk/test/AST/ast-dump-decl.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/ast-dump-decl.cpp?rev=348408&r1=348407&r2=348408&view=diff
> ==
> --- cfe/trunk/test/AST/ast-dump-decl.cpp (original)
> +++ cfe/trunk/test/AST/ast-dump-decl.cpp Wed Dec  5 12:21:13 2018
> @@ -263,6 +263,15 @@ namespace testClassTemplateDecl {
>template class TestClassTemplatePartial {
>  int j;
>};
> +
> +  template struct TestTemplateDefaultType;
> +  template struct TestTemplateDefaultType { };
> +
> +  template struct TestTemplateDefaultNonType;
> +  template struct TestTemplateDefaultNonType { };
> +
> +  template class TT = TestClassTemplate> struct 
> TestTemplateTemplateDefaultType;
> +  template class TT> struct 
> TestTemplateTemplateDefaultType { };
>  }
>  // CHECK:  ClassTemplateDecl{{.*}} TestClassTemplate
>  // CHECK-NEXT:   TemplateTypeParmDecl
> @@ -316,6 +325,24 @@ namespace testClassTemplateDecl {
>  // CHECK-NEXT:   CXXRecordDecl{{.*}} class TestClassTemplatePartial
>  // CHECK-NEXT:   FieldDecl{{.*}} j
>
> +// CHECK:  ClassTemplateDecl 0x{{[^ ]*}} prev 0x{{[^ ]*}} {{.*}} 
> TestTemplateDefaultType
> +// CHECK-NEXT:   TemplateTypeParmDecl
> +// CHECK-NEXT: TemplateArgument type 'int'
> +// CHECK-NEXT: inherited from TemplateTypeParm 0x{{[^ ]*}} 'T'
> +
> +// CHECK:  ClassTemplateDecl 0x{{[^ ]*}} prev 0x{{[^ ]*}} {{.*}} 
> TestTemplateDefaultNonType
> +// CHECK-NEXT:   NonTypeTemplateParmDecl
> +// CHECK-NEXT: TemplateArgument expr
> +// CHECK-NEXT:   ConstantExpr
> +// CHECK-NEXT: IntegerLiteral
> +// CHECK-NEXT: inherited from NonTypeTemplateParm 0x{{[^ ]*}} 'I' 'int'
> +
> +// CHECK:  ClassTemplateDecl 0x{{[^ ]*}} prev 0x{{[^ ]*}} {{.*}} 
> TestTemplateTemplateDefaultType
> +// CHECK-NEXT:   TemplateTemplateParmDecl
> +// CHECK-NEXT: TemplateTypeParmDecl
> +// CHECK-NEXT: TemplateArgument
> +// CHECK-NEXT: inherited from TemplateTemplateParm 0x{{[^ ]*}} 'TT'
> +
>  // PR15220 dump instantiation only once
>  namespace testCanonicalTemplate {
>class A {};
>
>
> ___
> 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


r348408 - Add dump tests for inherited default template parameters

2018-12-05 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Wed Dec  5 12:21:13 2018
New Revision: 348408

URL: http://llvm.org/viewvc/llvm-project?rev=348408&view=rev
Log:
Add dump tests for inherited default template parameters

Modified:
cfe/trunk/test/AST/ast-dump-decl.cpp

Modified: cfe/trunk/test/AST/ast-dump-decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/ast-dump-decl.cpp?rev=348408&r1=348407&r2=348408&view=diff
==
--- cfe/trunk/test/AST/ast-dump-decl.cpp (original)
+++ cfe/trunk/test/AST/ast-dump-decl.cpp Wed Dec  5 12:21:13 2018
@@ -263,6 +263,15 @@ namespace testClassTemplateDecl {
   template class TestClassTemplatePartial {
 int j;
   };
+
+  template struct TestTemplateDefaultType;
+  template struct TestTemplateDefaultType { };
+
+  template struct TestTemplateDefaultNonType;
+  template struct TestTemplateDefaultNonType { };
+
+  template class TT = TestClassTemplate> struct 
TestTemplateTemplateDefaultType;
+  template class TT> struct TestTemplateTemplateDefaultType 
{ };
 }
 // CHECK:  ClassTemplateDecl{{.*}} TestClassTemplate
 // CHECK-NEXT:   TemplateTypeParmDecl
@@ -316,6 +325,24 @@ namespace testClassTemplateDecl {
 // CHECK-NEXT:   CXXRecordDecl{{.*}} class TestClassTemplatePartial
 // CHECK-NEXT:   FieldDecl{{.*}} j
 
+// CHECK:  ClassTemplateDecl 0x{{[^ ]*}} prev 0x{{[^ ]*}} {{.*}} 
TestTemplateDefaultType
+// CHECK-NEXT:   TemplateTypeParmDecl
+// CHECK-NEXT: TemplateArgument type 'int'
+// CHECK-NEXT: inherited from TemplateTypeParm 0x{{[^ ]*}} 'T'
+
+// CHECK:  ClassTemplateDecl 0x{{[^ ]*}} prev 0x{{[^ ]*}} {{.*}} 
TestTemplateDefaultNonType
+// CHECK-NEXT:   NonTypeTemplateParmDecl
+// CHECK-NEXT: TemplateArgument expr
+// CHECK-NEXT:   ConstantExpr
+// CHECK-NEXT: IntegerLiteral
+// CHECK-NEXT: inherited from NonTypeTemplateParm 0x{{[^ ]*}} 'I' 'int'
+
+// CHECK:  ClassTemplateDecl 0x{{[^ ]*}} prev 0x{{[^ ]*}} {{.*}} 
TestTemplateTemplateDefaultType
+// CHECK-NEXT:   TemplateTemplateParmDecl
+// CHECK-NEXT: TemplateTypeParmDecl
+// CHECK-NEXT: TemplateArgument
+// CHECK-NEXT: inherited from TemplateTemplateParm 0x{{[^ ]*}} 'TT'
+
 // PR15220 dump instantiation only once
 namespace testCanonicalTemplate {
   class A {};


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


[PATCH] D55189: Extract TextNodeDumper class

2018-12-05 Thread Stephen Kelly via Phabricator via cfe-commits
steveire marked an inline comment as done.
steveire added inline comments.



Comment at: lib/AST/ASTDumper.cpp:90
 // Utilities
-void dumpPointer(const void *Ptr);
-void dumpSourceRange(SourceRange R);
-void dumpLocation(SourceLocation Loc);
-void dumpBareType(QualType T, bool Desugar = true);
-void dumpType(QualType T);
+void dumpType(QualType T) { NodeDumper.dumpType(T); }
 void dumpTypeAsChild(QualType T);

aaron.ballman wrote:
> Another nice cleanup for later would be to replace these call sites with the 
> `NodeDumper.foo()` version. Same for `dumpBareDeclRef()` below.
These methods are called from `AttrDump.inc`. They'll be removed when the 
commit to port the Attr dumping goes in.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55189



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


[PATCH] D55245: [clang-tidy] Add the abseil-duration-subtraction check

2018-12-05 Thread Hyrum Wright via Phabricator via cfe-commits
hwright added a comment.

Ping.

I assume I've got the right reviewers here, but I've also been sending a bunch 
of stuff your way lately, so if I'm overwhelming review capacity, please let me 
know.


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

https://reviews.llvm.org/D55245



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


[PATCH] D55150: Emit warnings from the driver for use of -mllvm or -Xclang options.

2018-12-05 Thread James Y Knight via Phabricator via cfe-commits
jyknight added a comment.

In D55150#1318082 , @chandlerc wrote:

> I think this should be `internal-driver-option` and the text updated? I don't 
> think these are necessarily experimental, they're internals of the compiler 
> implementation, and not a supported interface for users. Unsure how to best 
> explain this.


Yea, I was trying to figure out a good name. I thought "unsupported" at first, 
but that is a tricky word, since it has the connotation of "doesn't work in 
this version", which is not what I mean to imply -- the thing someone wants to 
do likely does work, but we need to indicate no guarantees about the future. 
Which is where "experimental" came from -- the options are useful for 
experimenting with compiler features that are not fully baked.

Perhaps "internal" is okay too...


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

https://reviews.llvm.org/D55150



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


[PATCH] D52790: [analyzer][PlistMacroExpansion] New flag to convert macro expansions to events

2018-12-05 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus planned changes to this revision.
Szelethus added a comment.
Herald added subscribers: gamesh411, baloghadamsoftware.

Since the way how these macro events are created as a whole changed in part 1, 
this path will need a big overhaul.


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

https://reviews.llvm.org/D52790



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


Re: [cfe-dev] r347339 - [clang][Parse] Diagnose useless null statements / empty init-statements

2018-12-05 Thread Aaron Ballman via cfe-commits
On Wed, Dec 5, 2018 at 2:14 PM Alex L via cfe-commits
 wrote:
>
> We have about 100k unique occurrences of this warning across a slice of our 
> software stack. It's simply not feasible to us to adopt it, so we would 
> prefer for it to be reverted to avoid downstream divergence in Apple's clang. 
> Granted, these occur in projects that use -Weverything but those projects are 
> typically understanding of warnings that they can turn off when they see that 
> they provide useful value in terms of warnings about unintended behavior 
> that's sometimes caught. This warning doesn't seem to catch unintended bugs 
> and it would be a heroic battle to adopt it for us in a way where projects 
> are somewhat satisfied. It seems to be a better fit for a clang-tidy check 
> that could suggest automatic fixits and that the users could run on their 
> codebase to "modernize" if they want to.

I'm not certain I agree that this does not catch unintended bugs.
After all, it started a discussion that pointed out design issues with
two different macros which were provided as examples of
false-positives. I think this diagnostic points out bad code smells
and is no more stylistic than some of the other diagnostics in
-Weverything, like not having a previous prototype before defining a
function. I am not sold on the idea that this diagnostic should be
moved into clang-tidy simply because it's showing up in a lot of
-Weverything builds.

~Aaron

>
> Cheers,
> Alex
>
> On Wed, 5 Dec 2018 at 10:43, Richard Smith via cfe-dev 
>  wrote:
>>
>> On Wed, 5 Dec 2018, 10:01 George Karpenkov via cfe-commits 
>> >>
>>> These are the cases I get:
>>>
>>> #define unexpected(a) { kprintf("unexpected %s:%d\n", __FILE__, __LINE__); 
>>> a; }
>>>
>>> and
>>>
>>> #if 0
>>> #define DEBG(fmt, args...)  { IOLog(fmt, ## args); kprintf(fmt, ## 
>>> args); }
>>> #else
>>> #define DEBG(fmt, args...)  {}
>>> #endif
>>>
>>> Now calls
>>>
>>> `DEBG(‘x’);` and `unexpected(‘msg’);`
>>>
>>> cause the warning to be fired.
>>> Of course, semicolon could be omitted, but the fact that the macro has 
>>> braces is sort of an implementation detail.
>>>
>>> Greg Parker has pointed out it’s possible to rewrite the macros using the 
>>> “do { … } while (0)”,
>>> but that is a lot of macros to change, and the resulting code would be 
>>> arguably less readable.
>>
>>
>> That suggestion is the (or at least an) idiomatic way to write a 
>> "statement-like" macro that expects a semicolon. The approach taken by the 
>> above macros is often considered to be a macro antipattern (try putting it 
>> in an unbraced if and adding an else clause, for example).
>>>
>>> On Dec 5, 2018, at 5:10 AM, Aaron Ballman  wrote:
>>>
>>> On Wed, Dec 5, 2018 at 1:40 AM Roman Lebedev  wrote:
>>>
>>>
>>> It is a problem in practice for us since we have projects which enable all 
>>> available warnings and also enable “-Werror”.
>>>
>>> Hm, they have asked for -Weverything and they got it. Seems to be
>>> working as intended.
>>> When in previous discussions elsewhere i have talked about
>>> -Weverything, i was always
>>> been told that it isn't supposed to be used like that (admittedly, i
>>> *do* use it like that :)).
>>>
>>> Could you explain how is this different from any other warning that is
>>> considered pointless by the project?
>>> Why not simply disable it?
>>>
>>>
>>> You are right, it could be disabled. It’s just for this warning the noise 
>>> vs. usefulness ratio seemed pretty low.
>>>
>>>
>>> Would you be okay with the warning if it was only diagnosed when the
>>> source location of the semi-colon is not immediately preceded by a
>>> macro expansion location? e.g.,
>>>
>>> EMPTY_EXPANSION(12); // Not diagnosed
>>> EMPTY_EXPANSION; // Not diagnosed
>>> ; // Diagnosed
>>>
>>> This could work provided that all empty space preceding the semicolon is 
>>> ignored (as the macro could be separated by space(s) or newline(s).
>>> I’m not sure the complexity would be worth it, as I haven’t seen bugs 
>>> arising from extra semicolons and empty statements,
>>> but it would take care of my use case.
>>>
>>>
>>> Or rather when the *previous* semicolon is coming from a macro.
>>>
>>> I don't like this. clang is already wa-a-ay too forgiving about
>>> macros, it almost ignores almost every warning in macros.
>>> It was an *intentional* decision to still warn on useless ';' after
>>> non-empty macros.
>>>
>>>
>>> I think I'm confused now. This is a test case:
>>>
>>> NULLMACRO(v7); // OK. This could be either GOODMACRO() or
>>> BETTERMACRO() situation, so we can't know we can drop it.
>>>
>>> So empty macro expansions should be ignored as I expected... so what
>>> is being diagnosed? George, can you provide a more clear example that
>>> demonstrates the issue?
>>>
>>> To be clear, I do *not* think this is a situation we should spend
>>> effort supporting (assuming "all available warnings" really means
>>> -Weverything and not something else):
>>>
>>> It is a problem in practice for us si

[PATCH] D53738: [Fixed Point Arithmetic] Fixed Point Addition

2018-12-05 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:1304
+RHSTy = ResultTy;
+  }
+

ebevhan wrote:
> rjmccall wrote:
> > ebevhan wrote:
> > > rjmccall wrote:
> > > > leonardchan wrote:
> > > > > rjmccall wrote:
> > > > > > leonardchan wrote:
> > > > > > > rjmccall wrote:
> > > > > > > > leonardchan wrote:
> > > > > > > > > rjmccall wrote:
> > > > > > > > > > ebevhan wrote:
> > > > > > > > > > > rjmccall wrote:
> > > > > > > > > > > > leonardchan wrote:
> > > > > > > > > > > > > rjmccall wrote:
> > > > > > > > > > > > > > ebevhan wrote:
> > > > > > > > > > > > > > > rjmccall wrote:
> > > > > > > > > > > > > > > > Hmm.  So adding a signed integer to an unsigned 
> > > > > > > > > > > > > > > > fixed-point type always converts the integer to 
> > > > > > > > > > > > > > > > unsigned?  That's a little weird, but only 
> > > > > > > > > > > > > > > > because the fixed-point rule seems to be the 
> > > > > > > > > > > > > > > > other way.  Anyway, I assume it's not a bug in 
> > > > > > > > > > > > > > > > the spec.
> > > > > > > > > > > > > > > `handleFixedPointConversion` only calculates the 
> > > > > > > > > > > > > > > result type of the expression, not the 
> > > > > > > > > > > > > > > calculation type. The final result type of the 
> > > > > > > > > > > > > > > operation will be the unsigned fixed-point type, 
> > > > > > > > > > > > > > > but the calculation itself will be done in a 
> > > > > > > > > > > > > > > signed type with enough precision to represent 
> > > > > > > > > > > > > > > both the signed integer and the unsigned 
> > > > > > > > > > > > > > > fixed-point type. 
> > > > > > > > > > > > > > > 
> > > > > > > > > > > > > > > Though, if the result ends up being negative, the 
> > > > > > > > > > > > > > > final result is undefined unless the type is 
> > > > > > > > > > > > > > > saturating. I don't think there is a test for the 
> > > > > > > > > > > > > > > saturating case (signed integer + unsigned 
> > > > > > > > > > > > > > > saturating fixed-point) in the SaturatedAddition 
> > > > > > > > > > > > > > > tests.
> > > > > > > > > > > > > > > `handleFixedPointConversion` only calculates the 
> > > > > > > > > > > > > > > result type of the expression, not the 
> > > > > > > > > > > > > > > calculation type.
> > > > > > > > > > > > > > 
> > > > > > > > > > > > > > Right, I understand that, but the result type of 
> > > > > > > > > > > > > > the expression obviously impacts the expressive 
> > > > > > > > > > > > > > range of the result, since you can end up with a 
> > > > > > > > > > > > > > negative value.
> > > > > > > > > > > > > > 
> > > > > > > > > > > > > > Hmm.  With that said, if the general principle is 
> > > > > > > > > > > > > > to perform the operation with full precision on the 
> > > > > > > > > > > > > > original operand values, why are unsigned 
> > > > > > > > > > > > > > fixed-point operands coerced to their corresponding 
> > > > > > > > > > > > > > signed types *before* the operation?  This is 
> > > > > > > > > > > > > > precision-limiting if the unsigned representation 
> > > > > > > > > > > > > > doesn't use a padding bit.  That seems like a bug 
> > > > > > > > > > > > > > in the spec.
> > > > > > > > > > > > > > Hmm. With that said, if the general principle is to 
> > > > > > > > > > > > > > perform the operation with full precision on the 
> > > > > > > > > > > > > > original operand values, why are unsigned 
> > > > > > > > > > > > > > fixed-point operands coerced to their corresponding 
> > > > > > > > > > > > > > signed types *before* the operation? This is 
> > > > > > > > > > > > > > precision-limiting if the unsigned representation 
> > > > > > > > > > > > > > doesn't use a padding bit. That seems like a bug in 
> > > > > > > > > > > > > > the spec.
> > > > > > > > > > > > > 
> > > > > > > > > > > > > Possibly. When the standard mentions converting from 
> > > > > > > > > > > > > signed to unsigned fixed point, the only requirement 
> > > > > > > > > > > > > involved is conservation of magnitude (the number of 
> > > > > > > > > > > > > integral bits excluding the sign)
> > > > > > > > > > > > > 
> > > > > > > > > > > > > ```
> > > > > > > > > > > > > when signed and unsigned fixed-point types are mixed, 
> > > > > > > > > > > > > the unsigned type is converted to the corresponding 
> > > > > > > > > > > > > signed type, and this should go without loss of 
> > > > > > > > > > > > > magnitude
> > > > > > > > > > > > > ```
> > > > > > > > > > > > > 
> > > > > > > > > > > > > This is just speculation, but I'm under the 
> > > > > > > > > > > > > impression that not as much "attention" was given for 
> > > > > > > > > > > > > unsigned types as for signed types since "`In the 
> > > > > > > > > > > > > embedded processor world, support for unsigned 
> > > > > > > > > > > > > fixed-point data types is rare; normally only signed 
> > > > > > > > > > > > > fixed-point data types are supported`", but w

[PATCH] D53738: [Fixed Point Arithmetic] Fixed Point Addition

2018-12-05 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 176862.
leonardchan marked an inline comment as done.

Repository:
  rC Clang

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

https://reviews.llvm.org/D53738

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/FixedPoint.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/Basic/FixedPoint.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Frontend/fixed_point_add.c
  clang/test/Frontend/fixed_point_conversions.c

Index: clang/test/Frontend/fixed_point_conversions.c
===
--- clang/test/Frontend/fixed_point_conversions.c
+++ clang/test/Frontend/fixed_point_conversions.c
@@ -214,19 +214,17 @@
   // Only get overflow checking if signed fract to unsigned accum
   sat_ua = sat_sf;
   // DEFAULT:  [[FRACT:%[0-9a-z]+]] = load i8, i8* %sat_sf, align 1
-  // DEFAULT-NEXT: [[FRACT_EXT:%[0-9a-z]+]] = sext i8 [[FRACT]] to i17
-  // DEFAULT-NEXT: [[ACCUM:%[0-9a-z]+]] = shl i17 [[FRACT_EXT]], 9
-  // DEFAULT-NEXT: [[IS_NEG:%[0-9a-z]+]] = icmp slt i17 [[ACCUM]], 0
-  // DEFAULT-NEXT: [[RESULT:%[0-9a-z]+]] = select i1 [[IS_NEG]], i17 0, i17 [[ACCUM]]
-  // DEFAULT-NEXT: [[RESULT_EXT:%[0-9a-z]+]] = sext i17 [[RESULT]] to i32
-  // DEFAULT-NEXT: store i32 [[RESULT_EXT]], i32* %sat_ua, align 4
+  // DEFAULT-NEXT: [[FRACT_EXT:%[0-9a-z]+]] = sext i8 [[FRACT]] to i32
+  // DEFAULT-NEXT: [[ACCUM:%[0-9a-z]+]] = shl i32 [[FRACT_EXT]], 9
+  // DEFAULT-NEXT: [[IS_NEG:%[0-9a-z]+]] = icmp slt i32 [[ACCUM]], 0
+  // DEFAULT-NEXT: [[RESULT:%[0-9a-z]+]] = select i1 [[IS_NEG]], i32 0, i32 [[ACCUM]]
+  // DEFAULT-NEXT: store i32 [[RESULT]], i32* %sat_ua, align 4
   // SAME:  [[FRACT:%[0-9a-z]+]] = load i8, i8* %sat_sf, align 1
-  // SAME-NEXT: [[FRACT_EXT:%[0-9a-z]+]] = sext i8 [[FRACT]] to i16
-  // SAME-NEXT: [[ACCUM:%[0-9a-z]+]] = shl i16 [[FRACT_EXT]], 8
-  // SAME-NEXT: [[IS_NEG:%[0-9a-z]+]] = icmp slt i16 [[ACCUM]], 0
-  // SAME-NEXT: [[RESULT:%[0-9a-z]+]] = select i1 [[IS_NEG]], i16 0, i16 [[ACCUM]]
-  // SAME-NEXT: [[RESULT_EXT:%[0-9a-z]+]] = sext i16 [[RESULT]] to i32
-  // SAME-NEXT: store i32 [[RESULT_EXT]], i32* %sat_ua, align 4
+  // SAME-NEXT: [[FRACT_EXT:%[0-9a-z]+]] = sext i8 [[FRACT]] to i32
+  // SAME-NEXT: [[ACCUM:%[0-9a-z]+]] = shl i32 [[FRACT_EXT]], 8
+  // SAME-NEXT: [[IS_NEG:%[0-9a-z]+]] = icmp slt i32 [[ACCUM]], 0
+  // SAME-NEXT: [[RESULT:%[0-9a-z]+]] = select i1 [[IS_NEG]], i32 0, i32 [[ACCUM]]
+  // SAME-NEXT: store i32 [[RESULT]], i32* %sat_ua, align 4
 }
 
 void TestFixedPointCastBetFractAccum() {
Index: clang/test/Frontend/fixed_point_add.c
===
--- /dev/null
+++ clang/test/Frontend/fixed_point_add.c
@@ -0,0 +1,390 @@
+// RUN: %clang_cc1 -ffixed-point -S -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,SIGNED
+// RUN: %clang_cc1 -ffixed-point -fpadding-on-unsigned-fixed-point -S -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,UNSIGNED
+
+void SignedAddition() {
+  // CHECK-LABEL: SignedAddition
+  short _Accum sa;
+  _Accum a, b, c, d;
+  long _Accum la;
+  unsigned short _Accum usa;
+  unsigned _Accum ua;
+  unsigned long _Accum ula;
+
+  short _Fract sf;
+  _Fract f;
+  long _Fract lf;
+  unsigned short _Fract usf;
+  unsigned _Fract uf;
+  unsigned long _Fract ulf;
+
+  // Same type
+  // CHECK:  [[SA:%[0-9]+]] = load i16, i16* %sa, align 2
+  // CHECK-NEXT: [[SA2:%[0-9]+]] = load i16, i16* %sa, align 2
+  // CHECK-NEXT: [[SUM:%[0-9]+]] = add i16 [[SA]], [[SA2]]
+  // CHECK-NEXT: store i16 [[SUM]], i16* %sa, align 2
+  sa = sa + sa;
+
+  // To larger scale and larger width
+  // CHECK:  [[SA:%[0-9]+]] = load i16, i16* %sa, align 2
+  // CHECK-NEXT: [[A:%[0-9]+]] = load i32, i32* %a, align 4
+  // CHECK-NEXT: [[EXT_SA:%[a-z0-9]+]] = sext i16 [[SA]] to i32
+  // CHECK-NEXT: [[SA:%[a-z0-9]+]] = shl i32 [[EXT_SA]], 8
+  // CHECK-NEXT: [[SUM:%[0-9]+]] = add i32 [[SA]], [[A]]
+  // CHECK-NEXT: store i32 [[SUM]], i32* %a, align 4
+  a = sa + a;
+
+  // To same scale and smaller width
+  // CHECK:  [[SA:%[0-9]+]] = load i16, i16* %sa, align 2
+  // CHECK-NEXT: [[SF:%[0-9]+]] = load i8, i8* %sf, align 1
+  // CHECK-NEXT: [[EXT_SF:%[a-z0-9]+]] = sext i8 [[SF]] to i16
+  // CHECK-NEXT: [[SUM:%[0-9]+]] = add i16 [[SA]], [[EXT_SF]]
+  // CHECK-NEXT: store i16 [[SUM]], i16* %sa, align 2
+  sa = sa + sf;
+
+  // To smaller scale and same width.
+  // CHECK:  [[SA:%[0-9]+]] = load i16, i16* %sa, align 2
+  // CHECK-NEXT: [[F:%[0-9]+]] = load i16, i16* %f, align 2
+  // CHECK-NEXT: [[EXT_SA:%[a-z0-9]+]] = sext i16 [[SA]] to i24
+  // CHECK-NEXT: [[SA:%[a-z0-9]+]] = shl i24 [[EXT_SA]], 8
+  // CHECK-NEXT: [[EXT_F:%[a-z0-9]+]] = sext i16 [[F]] to i24
+  // CHECK-NEXT: [[SUM:%[0-9]+]] = add i24 [[SA]], [[EXT_F]]
+  // CHECK-NEXT: [[RES:%[a-z0-9]+]] = ashr i24 [[SUM]], 8
+  // CHECK-NEXT: [[TRUNC_RES:%[a-z0-9]+]] = trunc i24

[PATCH] D21508: Diagnose friend function template redefinitions

2018-12-05 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith marked an inline comment as done.
rsmith added a comment.
This revision is now accepted and ready to land.

Thanks (and sorry for dropping the ball on this review).


Repository:
  rC Clang

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

https://reviews.llvm.org/D21508



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


Re: r347720 - [RISCV] Mark unit tests as "requires: riscv-registered-target"

2018-12-05 Thread Grang, Mandeep Singh via cfe-commits

Hi Alex,

Sorry, I missed this thread. I guess I was too quick to commit my patch. 
The actual problem seems to be something else due to which 
riscv32-toolchain.c fails on Windows. The fact that upstream bots seem 
to be fine could point to a bug in our internal code. Basically it is 
not able to find riscv32-unknown-elf-ld and ends up invoking ld.exe. I 
will look into this in more detail. Meanwhile I have reverted this patch 
in r348402.


--Mandeep

On 12/5/2018 12:28 AM, Alex Bradbury wrote:

On Thu, 29 Nov 2018 at 09:44, Alex Bradbury  wrote:

On Tue, 27 Nov 2018 at 22:56, Mandeep Singh Grang via cfe-commits
 wrote:

Author: mgrang
Date: Tue Nov 27 14:53:57 2018
New Revision: 347720

URL: http://llvm.org/viewvc/llvm-project?rev=347720&view=rev
Log:
[RISCV] Mark unit tests as "requires: riscv-registered-target"

Some of these tests break if the RISCV backend has not been built.

Reland D54816.

Modified:
 cfe/trunk/test/Driver/riscv-abi.c
 cfe/trunk/test/Driver/riscv-arch.c
 cfe/trunk/test/Driver/riscv-features.c
 cfe/trunk/test/Driver/riscv-gnutools.c
 cfe/trunk/test/Driver/riscv32-toolchain.c
 cfe/trunk/test/Driver/riscv64-toolchain.c

Hi Mandeep,

Maybe I'm missing something obvious but I'm a bit confused - what in
these tests requires that lib/Target/RISCV was built?

These tests obviously don't fail on the standard builders for instance.

Hi Mandeep, any thoughts on the question above?

Thanks,

Alex


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


r348402 - Revert "[RISCV] Mark unit tests as "requires: riscv-registered-target""

2018-12-05 Thread Mandeep Singh Grang via cfe-commits
Author: mgrang
Date: Wed Dec  5 11:19:38 2018
New Revision: 348402

URL: http://llvm.org/viewvc/llvm-project?rev=348402&view=rev
Log:
Revert "[RISCV] Mark unit tests as "requires: riscv-registered-target""

This reverts commit 8908dd12e7bbfc74e264233e900206ad31e285f0.

Modified:
cfe/trunk/test/Driver/riscv-abi.c
cfe/trunk/test/Driver/riscv-arch.c
cfe/trunk/test/Driver/riscv-features.c
cfe/trunk/test/Driver/riscv-gnutools.c
cfe/trunk/test/Driver/riscv32-toolchain.c
cfe/trunk/test/Driver/riscv64-toolchain.c

Modified: cfe/trunk/test/Driver/riscv-abi.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/riscv-abi.c?rev=348402&r1=348401&r2=348402&view=diff
==
--- cfe/trunk/test/Driver/riscv-abi.c (original)
+++ cfe/trunk/test/Driver/riscv-abi.c Wed Dec  5 11:19:38 2018
@@ -1,5 +1,3 @@
-// REQUIRES: riscv-registered-target
-
 // RUN: %clang -target riscv32-unknown-elf %s -### -o %t.o 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-ILP32 %s
 // RUN: %clang -target riscv32-unknown-elf %s -### -o %t.o -mabi=ilp32 2>&1 \

Modified: cfe/trunk/test/Driver/riscv-arch.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/riscv-arch.c?rev=348402&r1=348401&r2=348402&view=diff
==
--- cfe/trunk/test/Driver/riscv-arch.c (original)
+++ cfe/trunk/test/Driver/riscv-arch.c Wed Dec  5 11:19:38 2018
@@ -1,5 +1,3 @@
-// REQUIRES: riscv-registered-target
-
 // RUN: %clang -target riscv32-unknown-elf -march=rv32i -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck %s
 // RUN: %clang -target riscv32-unknown-elf -march=rv32im -### %s \

Modified: cfe/trunk/test/Driver/riscv-features.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/riscv-features.c?rev=348402&r1=348401&r2=348402&view=diff
==
--- cfe/trunk/test/Driver/riscv-features.c (original)
+++ cfe/trunk/test/Driver/riscv-features.c Wed Dec  5 11:19:38 2018
@@ -1,5 +1,3 @@
-// REQUIRES: riscv-registered-target
-
 // RUN: %clang -target riscv32-unknown-elf -### %s -fsyntax-only 2>&1 | 
FileCheck %s
 // RUN: %clang -target riscv64-unknown-elf -### %s -fsyntax-only 2>&1 | 
FileCheck %s
 

Modified: cfe/trunk/test/Driver/riscv-gnutools.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/riscv-gnutools.c?rev=348402&r1=348401&r2=348402&view=diff
==
--- cfe/trunk/test/Driver/riscv-gnutools.c (original)
+++ cfe/trunk/test/Driver/riscv-gnutools.c Wed Dec  5 11:19:38 2018
@@ -1,5 +1,3 @@
-// REQUIRES: riscv-registered-target
-
 // Check gnutools are invoked with propagated values for -mabi and -march.
 
 // RUN: %clang -target riscv32 -fno-integrated-as %s -###  -c \

Modified: cfe/trunk/test/Driver/riscv32-toolchain.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/riscv32-toolchain.c?rev=348402&r1=348401&r2=348402&view=diff
==
--- cfe/trunk/test/Driver/riscv32-toolchain.c (original)
+++ cfe/trunk/test/Driver/riscv32-toolchain.c Wed Dec  5 11:19:38 2018
@@ -1,5 +1,3 @@
-// REQUIRES: riscv-registered-target
-
 // A basic clang -cc1 command-line, and simple environment check.
 
 // RUN: %clang %s -### -no-canonical-prefixes -target riscv32 2>&1 | FileCheck 
-check-prefix=CC1 %s

Modified: cfe/trunk/test/Driver/riscv64-toolchain.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/riscv64-toolchain.c?rev=348402&r1=348401&r2=348402&view=diff
==
--- cfe/trunk/test/Driver/riscv64-toolchain.c (original)
+++ cfe/trunk/test/Driver/riscv64-toolchain.c Wed Dec  5 11:19:38 2018
@@ -1,5 +1,3 @@
-// REQUIRES: riscv-registered-target
-
 // A basic clang -cc1 command-line, and simple environment check.
 
 // RUN: %clang %s -### -no-canonical-prefixes -target riscv64 2>&1 | FileCheck 
-check-prefix=CC1 %s


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


Re: [cfe-dev] r347339 - [clang][Parse] Diagnose useless null statements / empty init-statements

2018-12-05 Thread Alex L via cfe-commits
We have about 100k unique occurrences of this warning across a slice of our
software stack. It's simply not feasible to us to adopt it, so we would
prefer for it to be reverted to avoid downstream divergence in Apple's
clang. Granted, these occur in projects that use -Weverything but those
projects are typically understanding of warnings that they can turn off
when they see that they provide useful value in terms of warnings about
unintended behavior that's sometimes caught. This warning doesn't seem to
catch unintended bugs and it would be a heroic battle to adopt it for us in
a way where projects are somewhat satisfied. It seems to be a better fit
for a clang-tidy check that could suggest automatic fixits and that the
users could run on their codebase to "modernize" if they want to.

Cheers,
Alex

On Wed, 5 Dec 2018 at 10:43, Richard Smith via cfe-dev <
cfe-...@lists.llvm.org> wrote:

> On Wed, 5 Dec 2018, 10:01 George Karpenkov via cfe-commits <
> cfe-commits@lists.llvm.org wrote:
>
>> These are the cases I get:
>>
>> #define unexpected(a) { kprintf("unexpected %s:%d\n", __FILE__,
>> __LINE__); a; }
>>
>> and
>>
>> #if 0
>> #define DEBG(fmt, args...)  { IOLog(fmt, ## args); kprintf(fmt, ##
>> args); }
>> #else
>> #define DEBG(fmt, args...)  {}
>> #endif
>>
>> Now calls
>>
>> `DEBG(‘x’);` and `unexpected(‘msg’);`
>>
>> cause the warning to be fired.
>> Of course, semicolon could be omitted, but the fact that the macro has
>> braces is sort of an implementation detail.
>>
>> Greg Parker has pointed out it’s possible to rewrite the macros using the
>> “do { … } while (0)”,
>> but that is a lot of macros to change, and the resulting code would be
>> arguably less readable.
>>
>
> That suggestion is the (or at least an) idiomatic way to write a
> "statement-like" macro that expects a semicolon. The approach taken by the
> above macros is often considered to be a macro antipattern (try putting it
> in an unbraced if and adding an else clause, for example).
>
>> On Dec 5, 2018, at 5:10 AM, Aaron Ballman  wrote:
>>
>> On Wed, Dec 5, 2018 at 1:40 AM Roman Lebedev 
>> wrote:
>>
>>
>> It is a problem in practice for us since we have projects which enable
>> all available warnings and also enable “-Werror”.
>>
>> Hm, they have asked for -Weverything and they got it. Seems to be
>> working as intended.
>> When in previous discussions elsewhere i have talked about
>> -Weverything, i was always
>> been told that it isn't supposed to be used like that (admittedly, i
>> *do* use it like that :)).
>>
>> Could you explain how is this different from any other warning that is
>> considered pointless by the project?
>> Why not simply disable it?
>>
>>
>> You are right, it could be disabled. It’s just for this warning the noise
>> vs. usefulness ratio seemed pretty low.
>>
>>
>> Would you be okay with the warning if it was only diagnosed when the
>> source location of the semi-colon is not immediately preceded by a
>> macro expansion location? e.g.,
>>
>> EMPTY_EXPANSION(12); // Not diagnosed
>> EMPTY_EXPANSION; // Not diagnosed
>> ; // Diagnosed
>>
>> This could work provided that all empty space preceding the semicolon is
>> ignored (as the macro could be separated by space(s) or newline(s).
>> I’m not sure the complexity would be worth it, as I haven’t seen bugs
>> arising from extra semicolons and empty statements,
>> but it would take care of my use case.
>>
>>
>> Or rather when the *previous* semicolon is coming from a macro.
>>
>> I don't like this. clang is already wa-a-ay too forgiving about
>> macros, it almost ignores almost every warning in macros.
>> It was an *intentional* decision to still warn on useless ';' after
>> non-empty macros.
>>
>>
>> I think I'm confused now. This is a test case:
>>
>> NULLMACRO(v7); // OK. This could be either GOODMACRO() or
>> BETTERMACRO() situation, so we can't know we can drop it.
>>
>> So empty macro expansions should be ignored as I expected... so what
>> is being diagnosed? George, can you provide a more clear example that
>> demonstrates the issue?
>>
>> To be clear, I do *not* think this is a situation we should spend
>> effort supporting (assuming "all available warnings" really means
>> -Weverything and not something else):
>>
>> It is a problem in practice for us since we have projects which enable
>> all available warnings and also enable “-Werror”.
>>
>>
>> However, if we are diagnosing *empty* macro expansions followed by a
>> semi-colon, I think that would be unacceptably chatty and is worth
>> fixing on its own merits.
>>
>> ~Aaron
>>
>>
>> ~Aaron
>>
>> Regards,
>> George
>>
>> Roman.
>>
>> On Nov 20, 2018, at 10:59 AM, Roman Lebedev via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>> Author: lebedevri
>> Date: Tue Nov 20 10:59:05 2018
>> New Revision: 347339
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=347339&view=rev
>> Log:
>> [clang][Parse] Diagnose useless null statements / empty init-statements
>>
>> Summary:
>> clang has `-Wextra-semi`

[PATCH] D55085: Avoid emitting redundant or unusable directories in DIFile metadata entries

2018-12-05 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Ah, sorry, I incorrectly checked that the old revision landed without problems. 
Have no data on whether the new revision breaks anything, will have to wait for 
the input from the US timezone buildcop


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

https://reviews.llvm.org/D55085



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


[PATCH] D55315: [clangd] Only reduce priority of a thread for indexing.

2018-12-05 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clangd/Threading.h:124
 };
-void setThreadPriority(std::thread &T, ThreadPriority Priority);
+// Sets scheduling priority for the calling thread.
+void setCurrentThreadPriority(ThreadPriority Priority);

The comment looks redundant now. Maybe remove it?



Comment at: clangd/index/Background.cpp:202
 std::lock_guard Lock(QueueMu);
-Queue.push_back(std::move(T));
+if (Priority == ThreadPriority::Low) {
+  Queue.push_back(Bind(

Since we might be interested in scheduling higher-priority tasks first anyway 
(not in this patch, but still), maybe store a pair of `(Task, Priority)` in the 
queue and call `setCurrentThreadPriority` when actually running the task?


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D55315



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


[PATCH] D55321: Do not check for parameters shadowing fields in function declarations

2018-12-05 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

Committed in r348400.


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

https://reviews.llvm.org/D55321



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


r348400 - Do not check for parameters shadowing fields in function declarations.

2018-12-05 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Wed Dec  5 10:56:57 2018
New Revision: 348400

URL: http://llvm.org/viewvc/llvm-project?rev=348400&view=rev
Log:
Do not check for parameters shadowing fields in function declarations.

We would issue a false-positive diagnostic for parameters in function 
declarations shadowing fields; we now only issue the diagnostic on a function 
definition instead.

Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaCXX/warn-shadow.cpp

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=348400&r1=348399&r2=348400&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Wed Dec  5 10:56:57 2018
@@ -12141,6 +12141,18 @@ bool Sema::CheckParmsForFunctionDef(Arra
   if (!Param->getType().isConstQualified())
 Diag(Param->getLocation(), diag::err_attribute_pointers_only)
 << Attr->getSpelling() << 1;
+
+// Check for parameter names shadowing fields from the class.
+if (LangOpts.CPlusPlus && !Param->isInvalidDecl()) {
+  // The owning context for the parameter should be the function, but we
+  // want to see if this function's declaration context is a record.
+  DeclContext *DC = Param->getDeclContext();
+  if (DC && DC->isFunctionOrMethod()) {
+if (auto *RD = dyn_cast(DC->getParent()))
+  CheckShadowInheritedFields(Param->getLocation(), 
Param->getDeclName(),
+ RD, /*DeclIsField*/ false);
+  }
+}
   }
 
   return HasInvalidParm;

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=348400&r1=348399&r2=348400&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Dec  5 10:56:57 2018
@@ -12427,13 +12427,6 @@ Decl *Sema::ActOnParamDeclarator(Scope *
 D.setInvalidType(true);
   }
 }
-
-if (LangOpts.CPlusPlus) {
-  DeclarationNameInfo DNI = GetNameForDeclarator(D);
-  if (auto *RD = dyn_cast(CurContext))
-CheckShadowInheritedFields(DNI.getLoc(), DNI.getName(), RD,
-   /*DeclIsField*/ false);
-}
   }
 
   // Temporarily put parameter variables in the translation unit, not

Modified: cfe/trunk/test/SemaCXX/warn-shadow.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-shadow.cpp?rev=348400&r1=348399&r2=348400&view=diff
==
--- cfe/trunk/test/SemaCXX/warn-shadow.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-shadow.cpp Wed Dec  5 10:56:57 2018
@@ -201,7 +201,7 @@ void avoidWarningWhenRedefining(int b) {
   typedef char l; // no warning or error.
  
   typedef char n; // no warning or error. 
-  typedef char n; // no warning or error.
+  typedef char n; // no warning or error.
   using n=char; // no warning or error.
 }
 
@@ -225,7 +225,7 @@ void f(int a) {
 
 namespace PR34120 {
 struct A {
-  int B; // expected-note {{declared here}}
+  int B; // expected-note 2 {{declared here}}
 };
 
 class C : public A {
@@ -233,8 +233,13 @@ class C : public A {
   void E() {
 extern void f(int B); // Ok
   }
+  void F(int B); // Ok, declaration; not definition.
+  void G(int B);
 };
 
+void C::G(int B) { // expected-warning {{parameter 'B' shadows member 
inherited from type 'A'}}
+}
+
 class Private {
   int B;
 };


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


[PATCH] D55307: [analyzer] MoveChecker Pt.6: Suppress the warning for the few move-safe STL classes.

2018-12-05 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus accepted this revision.
Szelethus added a comment.
This revision is now accepted and ready to land.

AFAIK `constexpr` arrays can be `std::sort`-ed, but it probably isn't worth the 
effort, I tried it myself when I was working with non-checker configs, and it's 
a big hassle for ultimately very little gain.




Comment at: test/Analysis/diagnostics/explicit-suppression.cpp:22
 #ifndef SUPPRESSED
-  // expected-warning@../Inputs/system-header-simulator-cxx.h:670 {{Called C++ 
object pointer is null}}
+  // expected-warning@../Inputs/system-header-simulator-cxx.h:677 {{Called C++ 
object pointer is null}}
 #endif

NoQ wrote:
> Szelethus wrote:
> > Can't we just change this to `// expected-warning{{Called C++ object 
> > pointer is null}}`? This file is so tiny, I think it wouldn't cause much 
> > confusion, and  reduces unnecessary maintenance work.
> I don't think it'll work. The warning is not on this line, it is in 
> `system-header-simulator-cxx.h`, so we need to specify it somehow, and it'll 
> appear only in this test, not in other tests that include that header, so we 
> can't put it directly into the header.
Ah, okay.


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

https://reviews.llvm.org/D55307



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


r348399 - Adding tests for -ast-dump; NFC.

2018-12-05 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Wed Dec  5 10:53:57 2018
New Revision: 348399

URL: http://llvm.org/viewvc/llvm-project?rev=348399&view=rev
Log:
Adding tests for -ast-dump; NFC.

This adds tests for various function and class template declarations.

Added:
cfe/trunk/test/AST/ast-dump-template-decls.cpp

Added: cfe/trunk/test/AST/ast-dump-template-decls.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/ast-dump-template-decls.cpp?rev=348399&view=auto
==
--- cfe/trunk/test/AST/ast-dump-template-decls.cpp (added)
+++ cfe/trunk/test/AST/ast-dump-template-decls.cpp Wed Dec  5 10:53:57 2018
@@ -0,0 +1,102 @@
+// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown -ast-dump %s | 
FileCheck -strict-whitespace %s
+
+template 
+// CHECK: FunctionTemplateDecl 0x{{[^ ]*}} <{{.*}}:1, line:[[@LINE+2]]:10> 
col:6 a
+// CHECK-NEXT: TemplateTypeParmDecl 0x{{[^ ]*}}  
col:20 referenced typename depth 0 index 0 Ty
+void a(Ty);
+
+template 
+// CHECK: FunctionTemplateDecl 0x{{[^ ]*}}  col:6 b
+// CHECK-NEXT: TemplateTypeParmDecl 0x{{[^ ]*}}  
col:23 referenced typename depth 0 index 0 ... Ty
+void b(Ty...);
+
+template 
+// CHECK: FunctionTemplateDecl 0x{{[^ ]*}}  col:6 c
+// CHECK-NEXT: TemplateTypeParmDecl 0x{{[^ ]*}}  
col:20 referenced typename depth 0 index 0 Ty
+// CHECK-NEXT: TemplateTypeParmDecl 0x{{[^ ]*}}  col:33 
referenced typename depth 0 index 1 Uy
+void c(Ty, Uy);
+
+template <>
+void c(float, int);
+// CHECK: FunctionDecl 0x{{[^ ]*}} prev 0x{{[^ ]*}}  col:6 c 'void (float, int)'
+// CHECK: TemplateArgument type 'float'
+// CHECK: TemplateArgument type 'int'
+
+template  typename Uy>
+// CHECK: FunctionTemplateDecl 0x{{[^ ]*}}  col:6 d
+// CHECK-NEXT: TemplateTypeParmDecl 0x{{[^ ]*}}  
col:20 referenced typename depth 0 index 0 Ty
+// CHECK-NEXT: TemplateTemplateParmDecl 0x{{[^ ]*}}  col:52 
depth 0 index 1 Uy
+// CHECK-NEXT: TemplateTypeParmDecl 0x{{[^ ]*}}  col:33 typename depth 
1 index 0
+void d(Ty, Uy);
+
+template 
+// CHECK: FunctionTemplateDecl 0x{{[^ ]*}}  col:6 e
+// CHECK-NEXT: TemplateTypeParmDecl 0x{{[^ ]*}}  
col:17 referenced class depth 0 index 0 Ty
+void e(Ty);
+
+template 
+// CHECK: FunctionTemplateDecl 0x{{[^ ]*}}  col:6 f
+// CHECK-NEXT: NonTypeTemplateParmDecl 0x{{[^ ]*}}  col:15 referenced 'int' depth 0 index 0 N
+void f(int i = N);
+
+template 
+// CHECK: FunctionTemplateDecl 0x{{[^ ]*}}  col:6 g
+// CHECK-NEXT: TemplateTypeParmDecl 0x{{[^ ]*}}  
col:20 referenced typename depth 0 index 0 Ty
+// CHECK-NEXT: TemplateArgument type 'int'
+void g(Ty);
+
+template 
+// CHECK: FunctionTemplateDecl 0x{{[^ ]*}}  col:6 h
+// CHECK-NEXT: TemplateTypeParmDecl 0x{{[^ ]*}}  
col:11 typename depth 0 index 0
+// CHECK-NEXT: TemplateArgument type 'void'
+void h();
+
+template 
+// CHECK: ClassTemplateDecl 0x{{[^ ]*}}  col:8 R
+// CHECK-NEXT: TemplateTypeParmDecl 0x{{[^ ]*}}  
col:20 typename depth 0 index 0 Ty
+// CHECK: ClassTemplateSpecialization 0x{{[^ ]*}} 'R'
+struct R {};
+
+template <>
+// CHECK: ClassTemplateSpecializationDecl 0x{{[^ ]*}}  col:8 struct R definition
+// CHECK: TemplateArgument type 'int'
+struct R {};
+
+template 
+// CHECK: ClassTemplateDecl 0x{{[^ ]*}}  col:8 S
+// CHECK-NEXT: TemplateTypeParmDecl 0x{{[^ ]*}}  
col:20 typename depth 0 index 0 Ty
+// CHECK-NEXT: TemplateTypeParmDecl 0x{{[^ ]*}}  col:30 class 
depth 0 index 1 Uy
+struct S {};
+
+template 
+// CHECK: ClassTemplatePartialSpecializationDecl 0x{{[^ ]*}} 
 col:8 struct S definition
+// CHECK: TemplateArgument type 'type-parameter-0-0'
+// CHECK-NEXT: TemplateArgument type 'int'
+// CHECK-NEXT: TemplateTypeParmDecl 0x{{[^ ]*}}  
col:20 referenced typename depth 0 index 0 Ty
+struct S {};
+
+template 
+// CHECK: ClassTemplateDecl 0x{{[^ ]*}}  col:8 T
+// CHECK-NEXT: NonTypeTemplateParmDecl 0x{{[^ ]*}}  
col:15 'auto' depth 0 index 0
+struct T {};
+
+template 
+// CHECK: ClassTemplateDecl 0x{{[^ ]*}}  col:8 U
+// CHECK-NEXT: NonTypeTemplateParmDecl 0x{{[^ ]*}}  
col:25 'decltype(auto)' depth 0 index 0
+struct U {};
+
+template 
+// CHECK: ClassTemplateDecl 0x{{[^ ]*}}  line:[[@LINE+2]]:8 V
+// CHECK-NEXT: TemplateTypeParmDecl 0x{{[^ ]*}}  
col:20 typename depth 0 index 0 Ty
+struct V {
+  template 
+  // CHECK: FunctionTemplateDecl 0x{{[^ ]*}}  col:8 f
+  // CHECK-NEXT: TemplateTypeParmDecl 0x{{[^ ]*}}  col:22 typename depth 1 index 0 Uy
+  void f();
+};
+
+template 
+template 
+// CHECK: FunctionTemplateDecl 0x{{[^ ]*}} parent 0x{{[^ ]*}} prev 0x{{[^ ]*}} 
 col:13 f
+// CHECK-NEXT: TemplateTypeParmDecl 0x{{[^ ]*}}  
col:20 typename depth 1 index 0 Uy
+void V::f() {}


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


[PATCH] D53866: [Preamble] Stop generating preamble for circular #includes

2018-12-05 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: include/clang/Lex/Preprocessor.h:391
   } PreambleConditionalStack;
+  bool PreambleGenerationFailed = false;
 

nik wrote:
> ilya-biryukov wrote:
> > There's a mechanism to handle preamble with errors, see 
> > `PreprocessorOpts::AllowPCHWithCompilerErrors`.
> > Maybe rely on it and avoid adding a different one?
> I'm not sure how to make use of AllowPCHWithCompilerErrors. It's clearly 
> meant as an input/readonly option - do you suggest setting that one to 
> "false" in case we detect the cyclic include (and later checking for it...)? 
> That feels a bit hacky. Have you meant something else?
We emit an error, so the preamble will **not** be emitted. 
Unless the users specify `AllowPCHWithCompilerErrors`, in which case they've 
signed up for this anyway.

I propose to **not** add the new flag at all. Would that work?



Comment at: lib/Lex/PPDirectives.cpp:1945
+// Generate a fatal error to skip further processing.
+Diag(FilenameTok.getLocation(), diag::err_pp_error_opening_file) << ""
+ << "";

nik wrote:
> ilya-biryukov wrote:
> > Maybe add a new error or find a more appropriate existing one to reuse?
> > "Error opening file", especially without any arguments does not provide 
> > enough context to figure out what went wrong.
> > Maybe add a new error or find a more appropriate existing one to reuse?
> 
> As stated above, introducing a new diagnostic that the user will never face 
> feels wrong, but that's just a preference. If you prefer a dedicated 
> diagnostics, that's fine for me.
> 
> Checking the existing ones, there are not many fatal errors to choose from:
> 
>   err_pp_file_not_found
>   err_pp_through_header_not_found
>   err_pp_through_header_not_seen
>   err_pp_pragma_hdrstop_not_seen
>   err_pp_error_opening_file
> 
> The last one looks the best for me.
> 
> > "Error opening file", especially without any arguments does not provide 
> > enough context to figure out what went wrong.
> 
> I've added some arguments which might be useful for debugging.
Could we create a new error for this case?



Comment at: lib/Lex/PPDirectives.cpp:1946
+Diag(FilenameTok.getLocation(), diag::err_pp_error_opening_file)
+<< Filename << "Main file can't include itself for preamble.";
+return;

I thought the convention is to **not** capitalize the first word of a message, 
otherwise it would be a bit inconsistent with other errors:
```
cannot open file 'foo.cpp:  Main file can't include itself for preamble
```

also a small nit: maybe rephrase to `main file cannot be included recursively 
for preamble`
and another small nit: we probably want to remove the full stop at the end.


Repository:
  rC Clang

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

https://reviews.llvm.org/D53866



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


[PATCH] D55307: [analyzer] MoveChecker Pt.6: Suppress the warning for the few move-safe STL classes.

2018-12-05 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 176856.
NoQ marked an inline comment as done.
NoQ added a comment.

Convert the pointer to a reference.

In D55307#1320434 , @Szelethus wrote:

> > Had to pass the checker into the visitor and make some methods non-static 
> > because globals with constructors are discouraged.
>
> How about making the set `constexpr`?


Mmm, i don't think it works this way, even `std::set` can't be made `constexpr` 
yet as of C++17, let alone an LLVM custom collection. It should be possible to 
make a `constexpr` array, but we'll lose the presumably-faster lookup this way, 
so not really worth it; the cost is minimal anyway.


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

https://reviews.llvm.org/D55307

Files:
  lib/StaticAnalyzer/Checkers/MoveChecker.cpp
  test/Analysis/Inputs/system-header-simulator-cxx.h
  test/Analysis/diagnostics/explicit-suppression.cpp
  test/Analysis/use-after-move.cpp

Index: test/Analysis/use-after-move.cpp
===
--- test/Analysis/use-after-move.cpp
+++ test/Analysis/use-after-move.cpp
@@ -13,47 +13,7 @@
 // RUN:  -analyzer-config exploration_strategy=dfs -DDFS=1\
 // RUN:  -analyzer-config alpha.cplusplus.Move:Aggressive=true -DAGGRESSIVE
 
-namespace std {
-
-typedef __typeof(sizeof(int)) size_t;
-
-template 
-struct remove_reference;
-
-template 
-struct remove_reference { typedef _Tp type; };
-
-template 
-struct remove_reference<_Tp &> { typedef _Tp type; };
-
-template 
-struct remove_reference<_Tp &&> { typedef _Tp type; };
-
-template 
-typename remove_reference<_Tp>::type &&move(_Tp &&__t) {
-  return static_cast::type &&>(__t);
-}
-
-template 
-_Tp &&forward(typename remove_reference<_Tp>::type &__t) noexcept {
-  return static_cast<_Tp &&>(__t);
-}
-
-template 
-void swap(T &a, T &b) {
-  T c(std::move(a));
-  a = std::move(b);
-  b = std::move(c);
-}
-
-template 
-class vector {
-public:
-  vector();
-  void push_back(const T &t);
-};
-
-} // namespace std
+#include "Inputs/system-header-simulator-cxx.h"
 
 class B {
 public:
@@ -832,13 +792,26 @@
 
 class HasSTLField {
   std::vector V;
-  void foo() {
+  void testVector() {
 // Warn even in non-aggressive mode when it comes to STL, because
 // in STL the object is left in "valid but unspecified state" after move.
 std::vector W = std::move(V); // expected-note{{Object 'V' of type 'std::vector' is left in a valid but unspecified state after move}}
 V.push_back(123); // expected-warning{{Method called on moved-from object 'V'}}
   // expected-note@-1{{Method called on moved-from object 'V'}}
   }
+
+  std::unique_ptr P;
+  void testUniquePtr() {
+// unique_ptr remains in a well-defined state after move.
+std::unique_ptr Q = std::move(P);
+P.get();
+#ifdef AGGRESSIVE
+// expected-warning@-2{{Method called on moved-from object 'P'}}
+// expected-note@-4{{Object 'P' is moved}}
+// expected-note@-4{{Method called on moved-from object 'P'}}
+#endif
+*P += 1; // FIXME: Should warn that the pointer is null.
+  }
 };
 
 void localRValueMove(A &&a) {
@@ -846,3 +819,11 @@
   a.foo(); // expected-warning{{Method called on moved-from object 'a'}}
// expected-note@-1{{Method called on moved-from object 'a'}}
 }
+
+void localUniquePtr(std::unique_ptr P) {
+  // Even though unique_ptr is safe to use after move,
+  // reusing a local variable this way usually indicates a bug.
+  std::unique_ptr Q = std::move(P); // expected-note{{Object 'P' is moved}}
+  P.get(); // expected-warning{{Method called on moved-from object 'P'}}
+   // expected-note@-1{{Method called on moved-from object 'P'}}
+}
Index: test/Analysis/diagnostics/explicit-suppression.cpp
===
--- test/Analysis/diagnostics/explicit-suppression.cpp
+++ test/Analysis/diagnostics/explicit-suppression.cpp
@@ -19,6 +19,6 @@
 void testCopyNull(C *I, C *E) {
   std::copy(I, E, (C *)0);
 #ifndef SUPPRESSED
-  // expected-warning@../Inputs/system-header-simulator-cxx.h:670 {{Called C++ object pointer is null}}
+  // expected-warning@../Inputs/system-header-simulator-cxx.h:677 {{Called C++ object pointer is null}}
 #endif
 }
Index: test/Analysis/Inputs/system-header-simulator-cxx.h
===
--- test/Analysis/Inputs/system-header-simulator-cxx.h
+++ test/Analysis/Inputs/system-header-simulator-cxx.h
@@ -237,6 +237,13 @@
 return static_cast(a);
   }
 
+  template 
+  void swap(T &a, T &b) {
+T c(std::move(a));
+a = std::move(b);
+b = std::move(c);
+  }
+
   template
   class vector {
 typedef T value_type;
@@ -770,6 +777,22 @@
 
 }
 
+#if __cplusplus >= 201103L
+namespace std {
+  template // TODO: Implement the stub for deleter.
+  class unique_ptr {
+  public:
+unique_ptr(const unique_ptr &) = delete;
+unique_ptr(un

Re: [cfe-dev] r347339 - [clang][Parse] Diagnose useless null statements / empty init-statements

2018-12-05 Thread Richard Smith via cfe-commits
On Wed, 5 Dec 2018, 10:01 George Karpenkov via cfe-commits <
cfe-commits@lists.llvm.org wrote:

> These are the cases I get:
>
> #define unexpected(a) { kprintf("unexpected %s:%d\n", __FILE__, __LINE__);
> a; }
>
> and
>
> #if 0
> #define DEBG(fmt, args...)  { IOLog(fmt, ## args); kprintf(fmt, ##
> args); }
> #else
> #define DEBG(fmt, args...)  {}
> #endif
>
> Now calls
>
> `DEBG(‘x’);` and `unexpected(‘msg’);`
>
> cause the warning to be fired.
> Of course, semicolon could be omitted, but the fact that the macro has
> braces is sort of an implementation detail.
>
> Greg Parker has pointed out it’s possible to rewrite the macros using the
> “do { … } while (0)”,
> but that is a lot of macros to change, and the resulting code would be
> arguably less readable.
>

That suggestion is the (or at least an) idiomatic way to write a
"statement-like" macro that expects a semicolon. The approach taken by the
above macros is often considered to be a macro antipattern (try putting it
in an unbraced if and adding an else clause, for example).

> On Dec 5, 2018, at 5:10 AM, Aaron Ballman  wrote:
>
> On Wed, Dec 5, 2018 at 1:40 AM Roman Lebedev  wrote:
>
>
> It is a problem in practice for us since we have projects which enable all
> available warnings and also enable “-Werror”.
>
> Hm, they have asked for -Weverything and they got it. Seems to be
> working as intended.
> When in previous discussions elsewhere i have talked about
> -Weverything, i was always
> been told that it isn't supposed to be used like that (admittedly, i
> *do* use it like that :)).
>
> Could you explain how is this different from any other warning that is
> considered pointless by the project?
> Why not simply disable it?
>
>
> You are right, it could be disabled. It’s just for this warning the noise
> vs. usefulness ratio seemed pretty low.
>
>
> Would you be okay with the warning if it was only diagnosed when the
> source location of the semi-colon is not immediately preceded by a
> macro expansion location? e.g.,
>
> EMPTY_EXPANSION(12); // Not diagnosed
> EMPTY_EXPANSION; // Not diagnosed
> ; // Diagnosed
>
> This could work provided that all empty space preceding the semicolon is
> ignored (as the macro could be separated by space(s) or newline(s).
> I’m not sure the complexity would be worth it, as I haven’t seen bugs
> arising from extra semicolons and empty statements,
> but it would take care of my use case.
>
>
> Or rather when the *previous* semicolon is coming from a macro.
>
> I don't like this. clang is already wa-a-ay too forgiving about
> macros, it almost ignores almost every warning in macros.
> It was an *intentional* decision to still warn on useless ';' after
> non-empty macros.
>
>
> I think I'm confused now. This is a test case:
>
> NULLMACRO(v7); // OK. This could be either GOODMACRO() or
> BETTERMACRO() situation, so we can't know we can drop it.
>
> So empty macro expansions should be ignored as I expected... so what
> is being diagnosed? George, can you provide a more clear example that
> demonstrates the issue?
>
> To be clear, I do *not* think this is a situation we should spend
> effort supporting (assuming "all available warnings" really means
> -Weverything and not something else):
>
> It is a problem in practice for us since we have projects which enable all
> available warnings and also enable “-Werror”.
>
>
> However, if we are diagnosing *empty* macro expansions followed by a
> semi-colon, I think that would be unacceptably chatty and is worth
> fixing on its own merits.
>
> ~Aaron
>
>
> ~Aaron
>
> Regards,
> George
>
> Roman.
>
> On Nov 20, 2018, at 10:59 AM, Roman Lebedev via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> Author: lebedevri
> Date: Tue Nov 20 10:59:05 2018
> New Revision: 347339
>
> URL: http://llvm.org/viewvc/llvm-project?rev=347339&view=rev
> Log:
> [clang][Parse] Diagnose useless null statements / empty init-statements
>
> Summary:
> clang has `-Wextra-semi` (D43162), which is not dictated by the currently
> selected standard.
> While that is great, there is at least one more source of need-less semis
> - 'null statements'.
> Sometimes, they are needed:
> ```
> for(int x = 0; continueToDoWork(x); x++)
> ; // Ugly code, but the semi is needed here.
> ```
>
> But sometimes they are just there for no reason:
> ```
> switch(X) {
> case 0:
> return -2345;
> case 5:
> return 0;
> default:
> return 42;
> }; // <- oops
>
> ;;; <- PS, still not diagnosed. Clearly this is junk.
> ```
>
> Additionally:
> ```
> if(; // <- empty init-statement
>  true)
> ;
>
> switch (; // empty init-statement
>   x) {
> ...
> }
>
> for (; // <- empty init-statement
>int y : S())
> ;
> }
>
> As usual, things may or may not go sideways in the presence of macros.
> While evaluating this diag on my codebase of interest, it was
> unsurprisingly
> discovered that Google Test macros are *very* prone to this.
> And it seems many issues are deep within the GTest itself, not
> in the snippets

[PATCH] D55307: [analyzer] MoveChecker Pt.6: Suppress the warning for the few move-safe STL classes.

2018-12-05 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: test/Analysis/diagnostics/explicit-suppression.cpp:22
 #ifndef SUPPRESSED
-  // expected-warning@../Inputs/system-header-simulator-cxx.h:670 {{Called C++ 
object pointer is null}}
+  // expected-warning@../Inputs/system-header-simulator-cxx.h:677 {{Called C++ 
object pointer is null}}
 #endif

Szelethus wrote:
> Can't we just change this to `// expected-warning{{Called C++ object pointer 
> is null}}`? This file is so tiny, I think it wouldn't cause much confusion, 
> and  reduces unnecessary maintenance work.
I don't think it'll work. The warning is not on this line, it is in 
`system-header-simulator-cxx.h`, so we need to specify it somehow, and it'll 
appear only in this test, not in other tests that include that header, so we 
can't put it directly into the header.


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

https://reviews.llvm.org/D55307



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


r348397 - Honor -fdebug-prefix-map when creating function names for the debug info.

2018-12-05 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Wed Dec  5 10:37:44 2018
New Revision: 348397

URL: http://llvm.org/viewvc/llvm-project?rev=348397&view=rev
Log:
Honor -fdebug-prefix-map when creating function names for the debug info.

This adds a callback to PrintingPolicy to allow CGDebugInfo to remap
file paths according to -fdebug-prefix-map. Otherwise the debug info
(particularly function names for C++ lambdas) may contain paths that
should have been remapped in the debug info.



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

Added:
cfe/trunk/test/CodeGenCXX/debug-prefix-map-lambda.cpp
Modified:
cfe/trunk/include/clang/AST/PrettyPrinter.h
cfe/trunk/lib/AST/TypePrinter.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h

Modified: cfe/trunk/include/clang/AST/PrettyPrinter.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/PrettyPrinter.h?rev=348397&r1=348396&r2=348397&view=diff
==
--- cfe/trunk/include/clang/AST/PrettyPrinter.h (original)
+++ cfe/trunk/include/clang/AST/PrettyPrinter.h Wed Dec  5 10:37:44 2018
@@ -50,7 +50,8 @@ struct PrintingPolicy {
 PolishForDeclaration(false), Half(LO.Half),
 MSWChar(LO.MicrosoftExt && !LO.WChar), IncludeNewlines(true),
 MSVCFormatting(false), ConstantsAsWritten(false),
-SuppressImplicitBase(false), FullyQualifiedName(false) {}
+SuppressImplicitBase(false), FullyQualifiedName(false),
+RemapFilePaths(false) {}
 
   /// Adjust this printing policy for cases where it's known that we're
   /// printing C++ code (for instance, if AST dumping reaches a C++-only
@@ -223,6 +224,12 @@ struct PrintingPolicy {
   /// When true, print the fully qualified name of function declarations.
   /// This is the opposite of SuppressScope and thus overrules it.
   unsigned FullyQualifiedName : 1;
+
+  /// Whether to apply -fdebug-prefix-map to any file paths.
+  unsigned RemapFilePaths : 1;
+
+  /// When RemapFilePaths is true, this function performs the action.
+  std::function remapPath;
 };
 
 } // end namespace clang

Modified: cfe/trunk/lib/AST/TypePrinter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TypePrinter.cpp?rev=348397&r1=348396&r2=348397&view=diff
==
--- cfe/trunk/lib/AST/TypePrinter.cpp (original)
+++ cfe/trunk/lib/AST/TypePrinter.cpp Wed Dec  5 10:37:44 2018
@@ -1157,9 +1157,13 @@ void TypePrinter::printTag(TagDecl *D, r
   PresumedLoc PLoc = D->getASTContext().getSourceManager().getPresumedLoc(
   D->getLocation());
   if (PLoc.isValid()) {
-OS << " at " << PLoc.getFilename()
-   << ':' << PLoc.getLine()
-   << ':' << PLoc.getColumn();
+OS << " at ";
+StringRef File = PLoc.getFilename();
+if (Policy.RemapFilePaths)
+  OS << Policy.remapPath(File);
+else
+  OS << File;
+OS << ':' << PLoc.getLine() << ':' << PLoc.getColumn();
   }
 }
 

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=348397&r1=348396&r2=348397&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Wed Dec  5 10:37:44 2018
@@ -235,6 +235,9 @@ PrintingPolicy CGDebugInfo::getPrintingP
   if (CGM.getCodeGenOpts().EmitCodeView)
 PP.MSVCFormatting = true;
 
+  // Apply -fdebug-prefix-map.
+  PP.RemapFilePaths = true;
+  PP.remapPath = [this](StringRef Path) { return remapDIPath(Path); };
   return PP;
 }
 

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=348397&r1=348396&r2=348397&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Wed Dec  5 10:37:44 2018
@@ -341,6 +341,9 @@ public:
 
   void finalize();
 
+  /// Remap a given path with the current debug prefix map
+  std::string remapDIPath(StringRef) const;
+
   /// Register VLA size expression debug node with the qualified type.
   void registerVLASizeExpression(QualType Ty, llvm::Metadata *SizeExpr) {
 SizeExprCache[Ty] = SizeExpr;
@@ -528,9 +531,6 @@ private:
   /// Create new compile unit.
   void CreateCompileUnit();
 
-  /// Remap a given path with the current debug prefix map
-  std::string remapDIPath(StringRef) const;
-
   /// Compute the file checksum debug info for input file ID.
   Optional
   computeChecksum(FileID FID, SmallString<32> &Checksum) const;

Added: cfe/trunk/test/CodeGenCXX/debug-prefix-map-lambda.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-prefix-map-lambda.cpp?rev=348397&view=auto
==

[PATCH] D55250: [clangd] Enhance macro hover to see full definition

2018-12-05 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clangd/XRefs.cpp:578
+bool Invalid;
+StringRef Buffer = SM.getBufferData(SM.getFileID(StartLoc), &Invalid);
+if (!Invalid) {

Unfortunately we can't get the buffer here, because for the preamble macros the 
files might change on disk after we build the preamble and we can end up 
reading a different version of the file. Which can in turn lead to crashes as 
the offsets obtained from the source locations can point outside the buffer for 
the corresponding file.

This is really annoying and generally the solution is to try find a different 
way to obtain the same information, e.g. by looking at what `MacroInfo` has 
available.
However, I don't know of a good workaround for this. Happy to look into ways of 
providing something close to a macro definition from `MacroInfo` or other 
sources, can scout for this tomorrow.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D55250



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


r348396 - [analyzer] Attribute for RetainCountChecker for OSObject should propagate with inheritance

2018-12-05 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Wed Dec  5 10:34:54 2018
New Revision: 348396

URL: http://llvm.org/viewvc/llvm-project?rev=348396&view=rev
Log:
[analyzer] Attribute for RetainCountChecker for OSObject should propagate with 
inheritance

rdar://46388388

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp
cfe/trunk/test/Analysis/osobject-retain-release.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp?rev=348396&r1=348395&r2=348396&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp Wed Dec  5 
10:34:54 2018
@@ -686,9 +686,59 @@ RetainSummaryManager::getRetEffectFromAn
 return RetEffect::MakeNotOwned(RetEffect::Generalized);
   }
 
+  if (const auto *MD = dyn_cast(D))
+for (const auto *PD : MD->overridden_methods())
+  if (auto RE = getRetEffectFromAnnotations(RetTy, PD))
+return RE;
+
   return None;
 }
 
+/// Apply the annotation of {@code pd} in function {@code FD}
+/// to the resulting summary stored in out-parameter {@code Template}.
+/// Return whether an annotation was applied.
+bool applyFunctionParamAnnotationEffect(const ParmVarDecl *pd,
+unsigned parm_idx,
+const FunctionDecl *FD,
+ArgEffects::Factory &AF,
+RetainSummaryTemplate &Template) {
+  if (pd->hasAttr()) {
+Template->addArg(AF, parm_idx, DecRefMsg);
+return true;
+  } else if (pd->hasAttr() || pd->hasAttr() ||
+ hasRCAnnotation(pd, "rc_ownership_consumed")) {
+Template->addArg(AF, parm_idx, DecRef);
+return true;
+  } else if (pd->hasAttr() ||
+ hasRCAnnotation(pd, "rc_ownership_returns_retained")) {
+QualType PointeeTy = pd->getType()->getPointeeType();
+if (!PointeeTy.isNull()) {
+  if (coreFoundation::isCFObjectRef(PointeeTy)) {
+Template->addArg(AF, parm_idx, RetainedOutParameter);
+return true;
+  }
+}
+  } else if (pd->hasAttr()) {
+QualType PointeeTy = pd->getType()->getPointeeType();
+if (!PointeeTy.isNull()) {
+  if (coreFoundation::isCFObjectRef(PointeeTy)) {
+Template->addArg(AF, parm_idx, UnretainedOutParameter);
+return true;
+  }
+}
+  } else {
+if (const auto *MD = dyn_cast(FD)) {
+  for (const auto *OD : MD->overridden_methods()) {
+const ParmVarDecl *OP = OD->parameters()[parm_idx];
+if (applyFunctionParamAnnotationEffect(OP, parm_idx, MD, AF, Template))
+  return true;
+  }
+}
+  }
+
+  return false;
+}
+
 void
 RetainSummaryManager::updateSummaryFromAnnotations(const RetainSummary *&Summ,
const FunctionDecl *FD) {
@@ -703,24 +753,7 @@ RetainSummaryManager::updateSummaryFromA
   for (auto pi = FD->param_begin(),
  pe = FD->param_end(); pi != pe; ++pi, ++parm_idx) {
 const ParmVarDecl *pd = *pi;
-if (pd->hasAttr()) {
-  Template->addArg(AF, parm_idx, DecRefMsg);
-} else if (pd->hasAttr() ||
- pd->hasAttr() ||
- hasRCAnnotation(pd, "rc_ownership_consumed")) {
-  Template->addArg(AF, parm_idx, DecRef);
-} else if (pd->hasAttr() ||
- hasRCAnnotation(pd, "rc_ownership_returns_retained")) {
-  QualType PointeeTy = pd->getType()->getPointeeType();
-  if (!PointeeTy.isNull())
-if (coreFoundation::isCFObjectRef(PointeeTy))
-  Template->addArg(AF, parm_idx, RetainedOutParameter);
-} else if (pd->hasAttr()) {
-  QualType PointeeTy = pd->getType()->getPointeeType();
-  if (!PointeeTy.isNull())
-if (coreFoundation::isCFObjectRef(PointeeTy))
-  Template->addArg(AF, parm_idx, UnretainedOutParameter);
-}
+applyFunctionParamAnnotationEffect(pd, parm_idx, FD, AF, Template);
   }
 
   QualType RetTy = FD->getReturnType();

Modified: cfe/trunk/test/Analysis/osobject-retain-release.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/osobject-retain-release.cpp?rev=348396&r1=348395&r2=348396&view=diff
==
--- cfe/trunk/test/Analysis/osobject-retain-release.cpp (original)
+++ cfe/trunk/test/Analysis/osobject-retain-release.cpp Wed Dec  5 10:34:54 2018
@@ -21,12 +21,13 @@ struct OSObject {
 
   unsigned int foo() { return 42; }
 
+  virtual OS_RETURNS_NOT_RETAINED OSObject *identity();
+
   static OSObject *generateObject(int);
 
   static OSObject *getObject();
   static OSObject *GetObject();
 
-
   static void * operator new(size_t size);
 
   static const OSMetaClass * cons

[PATCH] D55226: [Fix][StaticAnalyzer] Bug 39792 - False positive on strcpy targeting struct member

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

I like what I'm seeing.

In D55226#1320281 , @Pierre-vh wrote:

> Hi again!
>
> As I'm quite new to this, I don't know what the next step is. Do we need to 
> wait for more people to review this diff?
>  What happens when it's considered "ready"? How is it committed? (I don't 
> have commit access)


Welcome! :) Always great to see new people around.

Once the revision is accepted (and, preferably accepted by someone 
knowledgeable in the analyzer) you may commit. When you start contributing to 
the project, and you don't have commit access just yet, you should ask someone 
who does to commit the patch on your behalf. Once you have "enough" patches 
under your belt, you may ask for a commit access.

Here are some links with more info on patch reviews, commiting, and the like:

https://llvm.org/docs/Contributing.html
https://llvm.org/docs/DeveloperPolicy.html ("Making and Submitting a Patch" 
seems outdated, but the following sections are worth a read: "Code Reviews", 
"Obtaining Commit Access" (and the rest, if you have the time))
https://llvm.org/docs/Phabricator.html

Sadly, I won't be around my working PC for a while, so I can't commit on your 
behalf just yet. If you asked for someone to commit but no one did, it's 
perfectly fine to ping it once a week.


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

https://reviews.llvm.org/D55226



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


[PATCH] D55322: Mention changes to libc++ include dir lookup in release notes.

2018-12-05 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC348394: Mention changes to libc++ include dir lookup in 
release notes. (authored by ibiryukov, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D55322?vs=176809&id=176854#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D55322

Files:
  docs/ReleaseNotes.rst


Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -120,6 +120,13 @@
   entirely from Clang. The feature did not properly work with about 1/3 of the
   possible tokens available and was unmaintained.
 
+- The internals of libc++ include directory detection on MacOS have changed.
+  Instead of running a search based on the ``-resource-dir`` flag, the search
+  is now based on the path of the compiler in the filesystem. The default
+  behaviour should not change. However, if you override ``-resource-dir``
+  manually and rely on the old behaviour you will need to add appropriate
+  compiler flags for finding the corresponding libc++ include directory.
+
 New Compiler Flags
 --
 


Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -120,6 +120,13 @@
   entirely from Clang. The feature did not properly work with about 1/3 of the
   possible tokens available and was unmaintained.
 
+- The internals of libc++ include directory detection on MacOS have changed.
+  Instead of running a search based on the ``-resource-dir`` flag, the search
+  is now based on the path of the compiler in the filesystem. The default
+  behaviour should not change. However, if you override ``-resource-dir``
+  manually and rely on the old behaviour you will need to add appropriate
+  compiler flags for finding the corresponding libc++ include directory.
+
 New Compiler Flags
 --
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r348394 - Mention changes to libc++ include dir lookup in release notes.

2018-12-05 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Wed Dec  5 10:32:05 2018
New Revision: 348394

URL: http://llvm.org/viewvc/llvm-project?rev=348394&view=rev
Log:
Mention changes to libc++ include dir lookup in release notes.

Summary: The change itself landed as r348365, see the comment for more details.

Reviewers: arphaman, EricWF

Reviewed By: arphaman

Subscribers: cfe-commits

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

Modified:
cfe/trunk/docs/ReleaseNotes.rst

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=348394&r1=348393&r2=348394&view=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Wed Dec  5 10:32:05 2018
@@ -120,6 +120,13 @@ Non-comprehensive list of changes in thi
   entirely from Clang. The feature did not properly work with about 1/3 of the
   possible tokens available and was unmaintained.
 
+- The internals of libc++ include directory detection on MacOS have changed.
+  Instead of running a search based on the ``-resource-dir`` flag, the search
+  is now based on the path of the compiler in the filesystem. The default
+  behaviour should not change. However, if you override ``-resource-dir``
+  manually and rely on the old behaviour you will need to add appropriate
+  compiler flags for finding the corresponding libc++ include directory.
+
 New Compiler Flags
 --
 


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


[PATCH] D55085: Avoid emitting redundant or unusable directories in DIFile metadata entries

2018-12-05 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

It looks like the integrate went smoothly with the new change, thanks for 
fixing it!


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

https://reviews.llvm.org/D55085



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


[PATCH] D55307: [analyzer] MoveChecker Pt.6: Suppress the warning for the few move-safe STL classes.

2018-12-05 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus marked an inline comment as done.
Szelethus added a comment.

This looks great!

> Had to pass the checker into the visitor and make some methods non-static 
> because globals with constructors are discouraged.

How about making the set `constexpr`?




Comment at: lib/StaticAnalyzer/Checkers/MoveChecker.cpp:122
   private:
+const MoveChecker *Chk;
 // The tracked region.

Why not const reference?



Comment at: test/Analysis/diagnostics/explicit-suppression.cpp:22
 #ifndef SUPPRESSED
-  // expected-warning@../Inputs/system-header-simulator-cxx.h:670 {{Called C++ 
object pointer is null}}
+  // expected-warning@../Inputs/system-header-simulator-cxx.h:677 {{Called C++ 
object pointer is null}}
 #endif

Can't we just change this to `// expected-warning{{Called C++ object pointer is 
null}}`? This file is so tiny, I think it wouldn't cause much confusion, and  
reduces unnecessary maintenance work.



Comment at: test/Analysis/use-after-move.cpp:16
 
-namespace std {
-
-typedef __typeof(sizeof(int)) size_t;
-
-template 
-struct remove_reference;
-
-template 
-struct remove_reference { typedef _Tp type; };
-
-template 
-struct remove_reference<_Tp &> { typedef _Tp type; };
-
-template 
-struct remove_reference<_Tp &&> { typedef _Tp type; };
-
-template 
-typename remove_reference<_Tp>::type &&move(_Tp &&__t) {
-  return static_cast::type &&>(__t);
-}
-
-template 
-_Tp &&forward(typename remove_reference<_Tp>::type &__t) noexcept {
-  return static_cast<_Tp &&>(__t);
-}
-
-template 
-void swap(T &a, T &b) {
-  T c(std::move(a));
-  a = std::move(b);
-  b = std::move(c);
-}
-
-template 
-class vector {
-public:
-  vector();
-  void push_back(const T &t);
-};
-
-} // namespace std
+#include "Inputs/system-header-simulator-cxx.h"
 

This is cool, thanks!


Repository:
  rC Clang

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

https://reviews.llvm.org/D55307



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


[PATCH] D54796: [clangd] C++ API for emitting file status

2018-12-05 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, still have a few NITs and suggestions (see the comment about emitting 
"queued" on waiting for diagnostics and **not** emitting queued if the lock was 
acquired from the first try), but they don't look like something that should 
block this change.




Comment at: clangd/TUScheduler.cpp:268
+  /// Status of the TU.
+  TUStatus Status; /* GUARDED_BY(DiagMu) */
 };

hokein wrote:
> ilya-biryukov wrote:
> > hokein wrote:
> > > ilya-biryukov wrote:
> > > > Is `Status` actually ever read from multiple threads?
> > > > I assume it's only accessed on the worker thread, right? I think we can 
> > > > leave out the locks around it and put beside other fields only accessed 
> > > > by the worker thread, i.e. `DiagsWereReported`, etc.
> > > > 
> > > > PS Sorry go going back and forth, I didn't think about it in the 
> > > > previous review iteration.
> > > Unfortunately not, most statuses are emitted via worker thread, but we 
> > > emit `Queued` status in the main thread...
> > Hm, that sounds surprising.
> > What if the rebuild is in progress on the worker thread and we emit the 
> > queued status on the main thread at the same time? We might get weird 
> > sequences of statuses, right? 
> > E.g. `Queued → BuildingPreamble → [new update on the main thread] Queued → 
> > [processing request on a worker thread] RunningAction('XRefs')`
> > 
> > The `Queued` request status between `BuildingPreamble` and `RunningAction` 
> > looks **really** weird.
> > Maybe we could avoid that by setting emitting the `Queued` status on the 
> > worker thread whenever we're about to sleep on the debounce timeout?
> This sounds fair enough, and can simplify the code.
> 
> > Maybe we could avoid that by setting emitting the Queued status on the 
> > worker thread whenever we're about to sleep on the debounce timeout?
> 
> The `Queued` state is originally designed for the state that the worker 
> thread is blocked by the max-concurrent-threads semaphore.
> Emitting it when we're about to sleep on the debounce timeout doesn't seem a 
> right place to me. I think a reasonable place is before requiring the 
> `Barrier`.
> 
Ah, good point, waiting on a barrier can definitely take some time and is a 
form of queuing that we might want to notify the clients about.
It would be nice to notify only when the Barrier couldn't be acquired right 
away though, this probably be achieved adding `try_lock()` on the semaphore and 
only emitting a `Queued` notification if it fails. That way we'll avoid 
spamming the clients with non-useful statuses.

Wrt to deciding on whether we should notify when waiting on a debounce timer or 
on acquiring a semaphore... Why not both?



Comment at: clangd/TUScheduler.cpp:422
+Details.ReuseAST = true;
+emitTUStatus({TUAction::BuildingFile, TaskName}, &Details);
 return;

Should we also emit this status if we reuse the AST, but still report the 
diagnostics?



Comment at: clangd/TUScheduler.cpp:626
 {
+  emitTUStatus({TUAction::Queued, Req.Name});
   std::lock_guard BarrierLock(Barrier);

See the other suggestion about emitting this status only when locking the 
barrier failed.
This might be a good fit for a different patch, though, maybe add a FIXME here?



Comment at: clangd/TUScheduler.h:75
+  struct BuildDetails {
+/// indicates whether clang failed to build the TU.
+bool BuildFailed = false;

NIT: start with a capital letter to be consistent with the rest of the codebase.



Comment at: clangd/TUScheduler.h:77
+bool BuildFailed = false;
+/// indicates whether we reused the prebuilt AST.
+bool ReuseAST = false;

NIT: start with a capital letter to be consistent with the rest of the codebase.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D54796



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


[PATCH] D55262: [OpenCL] Fix for TBAA information of pointer after addresspacecast

2018-12-05 Thread Romanov Vlad via Phabricator via cfe-commits
romanovvlad updated this revision to Diff 176850.
romanovvlad added a comment.

Added new test case + formatting.


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

https://reviews.llvm.org/D55262

Files:
  lib/CodeGen/CGExpr.cpp
  test/CodeGenOpenCLCXX/address-space-deduction2.cl


Index: test/CodeGenOpenCLCXX/address-space-deduction2.cl
===
--- test/CodeGenOpenCLCXX/address-space-deduction2.cl
+++ test/CodeGenOpenCLCXX/address-space-deduction2.cl
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=c++ -O0 -emit-llvm 
-o - | FileCheck %s
+
+class P {
+public:
+  P(const P &Rhs) = default;
+
+  long A;
+  long B;
+};
+
+void foo(__global P *GPtr) {
+// CHECK: call void @llvm.memcpy{{.*}}, {{.*}}, i32 16
+  P Val = GPtr[0];
+}
+
+struct __attribute__((packed)) A { int X; };
+int test(__global A *GPtr) {
+// CHECK: {{.*}} = load i32, {{.*}}, align 1
+  return static_cast<__generic A &>(*GPtr).X;
+}
Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -4270,7 +4270,8 @@
 llvm::Value *V = getTargetHooks().performAddrSpaceCast(
 *this, LV.getPointer(), E->getSubExpr()->getType().getAddressSpace(),
 DestTy.getAddressSpace(), ConvertType(DestTy));
-return MakeNaturalAlignPointeeAddrLValue(V, DestTy);
+return MakeAddrLValue(Address(V, LV.getAddress().getAlignment()),
+  E->getType(), LV.getBaseInfo(), LV.getTBAAInfo());
   }
   case CK_ObjCObjectLValueCast: {
 LValue LV = EmitLValue(E->getSubExpr());


Index: test/CodeGenOpenCLCXX/address-space-deduction2.cl
===
--- test/CodeGenOpenCLCXX/address-space-deduction2.cl
+++ test/CodeGenOpenCLCXX/address-space-deduction2.cl
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=c++ -O0 -emit-llvm -o - | FileCheck %s
+
+class P {
+public:
+  P(const P &Rhs) = default;
+
+  long A;
+  long B;
+};
+
+void foo(__global P *GPtr) {
+// CHECK: call void @llvm.memcpy{{.*}}, {{.*}}, i32 16
+  P Val = GPtr[0];
+}
+
+struct __attribute__((packed)) A { int X; };
+int test(__global A *GPtr) {
+// CHECK: {{.*}} = load i32, {{.*}}, align 1
+  return static_cast<__generic A &>(*GPtr).X;
+}
Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -4270,7 +4270,8 @@
 llvm::Value *V = getTargetHooks().performAddrSpaceCast(
 *this, LV.getPointer(), E->getSubExpr()->getType().getAddressSpace(),
 DestTy.getAddressSpace(), ConvertType(DestTy));
-return MakeNaturalAlignPointeeAddrLValue(V, DestTy);
+return MakeAddrLValue(Address(V, LV.getAddress().getAlignment()),
+  E->getType(), LV.getBaseInfo(), LV.getTBAAInfo());
   }
   case CK_ObjCObjectLValueCast: {
 LValue LV = EmitLValue(E->getSubExpr());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D55334: [AST] Pass the ASTContext to one of the ctor of DeclRefExpr

2018-12-05 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno created this revision.
riccibruno added a reviewer: aaron.ballman.
riccibruno added a project: clang.
Herald added a subscriber: cfe-commits.

Pass the `ASTContext` to one of the constructor of `DeclRefExpr` since
in most cases the appropriate `ASTContext` is readily available.

`Decl::getASTContext()` is not cheap since it must walk back the chain
of declaration contexts to reach the `TranslationUnitDecl`.

Also move the definition of the constructor out of the header since
the constructor is calling `DeclRefExpr::computeDependence` which
is not defined in the header.

This is a mechanical change which should not have any functional change.


Repository:
  rC Clang

https://reviews.llvm.org/D55334

Files:
  include/clang/AST/Expr.h
  lib/AST/ASTContext.cpp
  lib/AST/Expr.cpp
  lib/Analysis/ThreadSafety.cpp
  lib/Analysis/ThreadSafetyCommon.cpp
  lib/CodeGen/CGBlocks.cpp
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CGObjC.cpp
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/Frontend/Rewrite/RewriteModernObjC.cpp
  lib/Frontend/Rewrite/RewriteObjC.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaCUDA.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaObjCProperty.cpp
  lib/Sema/SemaOverload.cpp
  lib/Sema/TreeTransform.h

Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -3130,9 +3130,9 @@
 
 // Build a reference to the __builtin_shufflevector builtin
 FunctionDecl *Builtin = cast(Lookup.front());
-Expr *Callee = new (SemaRef.Context) DeclRefExpr(Builtin, false,
-  SemaRef.Context.BuiltinFnTy,
-  VK_RValue, BuiltinLoc);
+Expr *Callee = new (SemaRef.Context)
+DeclRefExpr(SemaRef.Context, Builtin, false,
+SemaRef.Context.BuiltinFnTy, VK_RValue, BuiltinLoc);
 QualType CalleePtrTy = SemaRef.Context.getPointerType(Builtin->getType());
 Callee = SemaRef.ImpCastExprToType(Callee, CalleePtrTy,
CK_BuiltinFnToFnPtr).get();
Index: lib/Sema/SemaOverload.cpp
===
--- lib/Sema/SemaOverload.cpp
+++ lib/Sema/SemaOverload.cpp
@@ -63,8 +63,8 @@
 return ExprError();
   if (auto *FPT = Fn->getType()->getAs())
 S.ResolveExceptionSpec(Loc, FPT);
-  DeclRefExpr *DRE = new (S.Context) DeclRefExpr(Fn, false, Fn->getType(),
- VK_LValue, Loc, LocInfo);
+  DeclRefExpr *DRE = new (S.Context)
+  DeclRefExpr(S.Context, Fn, false, Fn->getType(), VK_LValue, Loc, LocInfo);
   if (HadMultipleCandidates)
 DRE->setHadMultipleCandidates(true);
 
@@ -6968,8 +6968,8 @@
   // lvalues/rvalues and the type. Fortunately, we can allocate this
   // call on the stack and we don't need its arguments to be
   // well-formed.
-  DeclRefExpr ConversionRef(Conversion, false, Conversion->getType(), VK_LValue,
-From->getBeginLoc());
+  DeclRefExpr ConversionRef(Context, Conversion, false, Conversion->getType(),
+VK_LValue, From->getBeginLoc());
   ImplicitCastExpr ConversionFn(ImplicitCastExpr::OnStack,
 Context.getPointerType(Conversion->getType()),
 CK_FunctionToPointerDecay,
Index: lib/Sema/SemaObjCProperty.cpp
===
--- lib/Sema/SemaObjCProperty.cpp
+++ lib/Sema/SemaObjCProperty.cpp
@@ -1413,7 +1413,7 @@
   SynthesizedFunctionScope Scope(*this, getterMethod);
   ImplicitParamDecl *SelfDecl = getterMethod->getSelfDecl();
   DeclRefExpr *SelfExpr =
-new (Context) DeclRefExpr(SelfDecl, false, SelfDecl->getType(),
+new (Context) DeclRefExpr(Context, SelfDecl, false, SelfDecl->getType(),
   VK_LValue, PropertyDiagLoc);
   MarkDeclRefReferenced(SelfExpr);
   Expr *LoadSelfExpr =
@@ -1465,7 +1465,7 @@
   SynthesizedFunctionScope Scope(*this, setterMethod);
   ImplicitParamDecl *SelfDecl = setterMethod->getSelfDecl();
   DeclRefExpr *SelfExpr =
-new (Context) DeclRefExpr(SelfDecl, false, SelfDecl->getType(),
+new (Context) DeclRefExpr(Context, SelfDecl, false, SelfDecl->getType(),
   VK_LValue, PropertyDiagLoc);
   MarkDeclRefReferenced(SelfExpr);
   Expr *LoadSelfExpr =
@@ -1481,7 +1481,7 @@
   ObjCMethodDecl::param_iterator P = setterMethod->param_begin();
   ParmVarDecl *Param = (*P);
   QualType T = Param->getType().getNonReferenceType();
-  DeclRefExpr *rhs = new (Context) DeclRefExpr(Param, false, T,
+  DeclRefExpr *rhs = new (Context) DeclRefExpr(Context, Param, false, T,
VK_LValue, PropertyDiagLoc);
   MarkDeclRefReferenced(rhs);
   ExprR

Re: [cfe-dev] r347339 - [clang][Parse] Diagnose useless null statements / empty init-statements

2018-12-05 Thread George Karpenkov via cfe-commits
These are the cases I get:

#define unexpected(a) { kprintf("unexpected %s:%d\n", __FILE__, __LINE__); a; }

and

#if 0
#define DEBG(fmt, args...)  { IOLog(fmt, ## args); kprintf(fmt, ## args); }
#else
#define DEBG(fmt, args...)  {}
#endif

Now calls

`DEBG(‘x’);` and `unexpected(‘msg’);`

cause the warning to be fired.
Of course, semicolon could be omitted, but the fact that the macro has braces 
is sort of an implementation detail.

Greg Parker has pointed out it’s possible to rewrite the macros using the “do { 
… } while (0)”,
but that is a lot of macros to change, and the resulting code would be arguably 
less readable.

> On Dec 5, 2018, at 5:10 AM, Aaron Ballman  wrote:
> 
> On Wed, Dec 5, 2018 at 1:40 AM Roman Lebedev  > wrote:
>> 
>> It is a problem in practice for us since we have projects which enable 
>> all available warnings and also enable “-Werror”.
>> Hm, they have asked for -Weverything and they got it. Seems to be
>> working as intended.
>> When in previous discussions elsewhere i have talked about
>> -Weverything, i was always
>> been told that it isn't supposed to be used like that (admittedly, i
>> *do* use it like that :)).
>> 
>> Could you explain how is this different from any other warning that is
>> considered pointless by the project?
>> Why not simply disable it?

You are right, it could be disabled. It’s just for this warning the noise vs. 
usefulness ratio seemed pretty low.

>> 
> Would you be okay with the warning if it was only diagnosed when the
> source location of the semi-colon is not immediately preceded by a
> macro expansion location? e.g.,
> 
> EMPTY_EXPANSION(12); // Not diagnosed
> EMPTY_EXPANSION; // Not diagnosed
> ; // Diagnosed
 This could work provided that all empty space preceding the semicolon is 
 ignored (as the macro could be separated by space(s) or newline(s).
 I’m not sure the complexity would be worth it, as I haven’t seen bugs 
 arising from extra semicolons and empty statements,
 but it would take care of my use case.
 
>>> 
>>> Or rather when the *previous* semicolon is coming from a macro.
>> I don't like this. clang is already wa-a-ay too forgiving about
>> macros, it almost ignores almost every warning in macros.
>> It was an *intentional* decision to still warn on useless ';' after
>> non-empty macros.
> 
> I think I'm confused now. This is a test case:
> 
> NULLMACRO(v7); // OK. This could be either GOODMACRO() or
> BETTERMACRO() situation, so we can't know we can drop it.
> 
> So empty macro expansions should be ignored as I expected... so what
> is being diagnosed? George, can you provide a more clear example that
> demonstrates the issue?
> 
> To be clear, I do *not* think this is a situation we should spend
> effort supporting (assuming "all available warnings" really means
> -Weverything and not something else):
> 
>> It is a problem in practice for us since we have projects which enable all 
>> available warnings and also enable “-Werror”.
> 
> However, if we are diagnosing *empty* macro expansions followed by a
> semi-colon, I think that would be unacceptably chatty and is worth
> fixing on its own merits.
> 
> ~Aaron
> 
>> 
> ~Aaron
> 
>> Regards,
>> George
>> Roman.
>> 
>>> On Nov 20, 2018, at 10:59 AM, Roman Lebedev via cfe-commits 
>>>  wrote:
>>> 
>>> Author: lebedevri
>>> Date: Tue Nov 20 10:59:05 2018
>>> New Revision: 347339
>>> 
>>> URL: http://llvm.org/viewvc/llvm-project?rev=347339&view=rev
>>> Log:
>>> [clang][Parse] Diagnose useless null statements / empty init-statements
>>> 
>>> Summary:
>>> clang has `-Wextra-semi` (D43162), which is not dictated by the 
>>> currently selected standard.
>>> While that is great, there is at least one more source of need-less 
>>> semis - 'null statements'.
>>> Sometimes, they are needed:
>>> ```
>>> for(int x = 0; continueToDoWork(x); x++)
>>> ; // Ugly code, but the semi is needed here.
>>> ```
>>> 
>>> But sometimes they are just there for no reason:
>>> ```
>>> switch(X) {
>>> case 0:
>>> return -2345;
>>> case 5:
>>> return 0;
>>> default:
>>> return 42;
>>> }; // <- oops
>>> 
>>> ;;; <- PS, still not diagnosed. Clearly this is junk.
>>> ```
>>> 
>>> Additionally:
>>> ```
>>> if(; // <- empty init-statement
>>>  true)
>>> ;
>>> 
>>> switch (; // empty init-statement
>>>   x) {
>>> ...
>>> }
>>> 
>>> for (; // <- empty init-statement
>>>int y : S())
>>> ;
>>> }
>>> 
>>> As usual, things may or may not go sideways in the presence of macros.
>>> While evaluating this diag on my codebase of interest, it was 
>>> unsurprisingly
>>> discovered that Google Test macros are *very* prone to this.
>>> And it seems many issues are deep with

[PATCH] D55289: [analyzer] MoveChecker Pt.5: Improve invalidation policies.

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

Cool!




Comment at: lib/StaticAnalyzer/Checkers/MoveChecker.cpp:528
 ArrayRef ExplicitRegions,
 ArrayRef Regions, const LocationContext *LCtx,
 const CallEvent *Call) const {

This isn't specific to this revision, but I find the parameter name `Regions` 
way too vague. Maybe `ImplicitRegions`?



Comment at: lib/StaticAnalyzer/Checkers/MoveChecker.cpp:540-542
+// Explicit regions are the regions passed into the call directly, but
+// not all of them end up being invalidated. The ones that do appear in
+// the Regions array as well.

Really? Then I guess this needs to be updated in `CheckerDocumentation.cpp`:

```
  /// \param ExplicitRegions The regions explicitly requested for invalidation.
  ///For a function call, this would be the arguments. For a bind, this
  ///would be the region being bound to.
```

To me, this clearly indicates that the elements of `ExplicitRegions` will be 
invalidated. Does "requested for" really just mean "requested for potential"? 
Since this happens //before// any invalidation, it could easily be interpreted 
as "invalidated after the end of the callback".


Repository:
  rC Clang

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

https://reviews.llvm.org/D55289



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


[PATCH] D55321: Do not check for parameters shadowing fields in function declarations

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

Thanks!


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

https://reviews.llvm.org/D55321



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


Re: r348325 - [Sema] Remove some conditions of a failing assert

2018-12-05 Thread Erik Pilkington via cfe-commits



On 12/4/18 7:07 PM, Richard Smith wrote:
On Tue, 4 Dec 2018 at 16:46, Erik Pilkington via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:


Author: epilk
Date: Tue Dec  4 16:43:11 2018
New Revision: 348325

URL: http://llvm.org/viewvc/llvm-project?rev=348325&view=rev
Log:
[Sema] Remove some conditions of a failing assert

We should have been checking that this state is consistent, but its
possible for it to be filled later, so it isn't really sound to check
it here anyways.

Fixes llvm.org/PR39742 

Modified:
    cfe/trunk/lib/AST/DeclTemplate.cpp
    cfe/trunk/test/SemaCXX/friend-template-redecl.cpp

Modified: cfe/trunk/lib/AST/DeclTemplate.cpp
URL:

http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclTemplate.cpp?rev=348325&r1=348324&r2=348325&view=diff

==
--- cfe/trunk/lib/AST/DeclTemplate.cpp (original)
+++ cfe/trunk/lib/AST/DeclTemplate.cpp Tue Dec  4 16:43:11 2018
@@ -329,8 +329,6 @@ void FunctionTemplateDecl::mergePrevDecl

   // Ensure we don't leak any important state.
   assert(ThisCommon->Specializations.size() == 0 &&
-  !ThisCommon->InstantiatedFromMember.getPointer() &&
-         !ThisCommon->InstantiatedFromMember.getInt() &&
          "Can't merge incompatible declarations!");

   Base::Common = PrevCommon;

Modified: cfe/trunk/test/SemaCXX/friend-template-redecl.cpp
URL:

http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/friend-template-redecl.cpp?rev=348325&r1=348324&r2=348325&view=diff

==
--- cfe/trunk/test/SemaCXX/friend-template-redecl.cpp (original)
+++ cfe/trunk/test/SemaCXX/friend-template-redecl.cpp Tue Dec  4
16:43:11 2018
@@ -18,3 +18,14 @@ void f() {
   foo(x);
   bar(x);
 }
+
+namespace PR39742 {
+template
+struct wrapper {
+  template
+  friend void friend_function_template() {}
+};
+
+wrapper x;
+wrapper y;


This is ill-formed due to the redefinition of the template; we should 
at least have a FIXME to properly reject it.


Ah, good point. Added a FIXME in r348388. The fix for this is 
https://reviews.llvm.org/D21508.


Thanks!


+}


___
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


r348388 - Address a post-commit review comment on r348325.

2018-12-05 Thread Erik Pilkington via cfe-commits
Author: epilk
Date: Wed Dec  5 09:43:26 2018
New Revision: 348388

URL: http://llvm.org/viewvc/llvm-project?rev=348388&view=rev
Log:
Address a post-commit review comment on r348325.

Modified:
cfe/trunk/test/SemaCXX/friend-template-redecl.cpp

Modified: cfe/trunk/test/SemaCXX/friend-template-redecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/friend-template-redecl.cpp?rev=348388&r1=348387&r2=348388&view=diff
==
--- cfe/trunk/test/SemaCXX/friend-template-redecl.cpp (original)
+++ cfe/trunk/test/SemaCXX/friend-template-redecl.cpp Wed Dec  5 09:43:26 2018
@@ -27,5 +27,7 @@ struct wrapper {
 };
 
 wrapper x;
+// FIXME: We should really error here because of the redefinition of
+// friend_function_template.
 wrapper y;
 }


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


Re: [clang-tools-extra] r348176 - Fix compilation failure on Windows.

2018-12-05 Thread Ilya Biryukov via cfe-commits
Just noticed this. Really sorry that I submitted the broken version (made
the rename at the last minute) and many thanks for fixing this!

On Mon, Dec 3, 2018 at 9:01 PM Zachary Turner via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: zturner
> Date: Mon Dec  3 11:59:00 2018
> New Revision: 348176
>
> URL: http://llvm.org/viewvc/llvm-project?rev=348176&view=rev
> Log:
> Fix compilation failure on Windows.
>
> This was introduced earlier but apparently used an incorrect
> class name so it doesn't compile on Windows.
>
> Modified:
> clang-tools-extra/trunk/clangd/FSProvider.cpp
>
> Modified: clang-tools-extra/trunk/clangd/FSProvider.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/FSProvider.cpp?rev=348176&r1=348175&r2=348176&view=diff
>
> ==
> --- clang-tools-extra/trunk/clangd/FSProvider.cpp (original)
> +++ clang-tools-extra/trunk/clangd/FSProvider.cpp Mon Dec  3 11:59:00 2018
> @@ -76,7 +76,7 @@ clang::clangd::RealFileSystemProvider::g
>  // FIXME: Try to use a similar approach in Sema instead of relying on
>  //propagation of the 'isVolatile' flag through all layers.
>  #ifdef _WIN32
> -  return new VolatileFSProvider(vfs::getRealFileSystem());
> +  return new VolatileFileSystem(vfs::getRealFileSystem());
>  #else
>return vfs::getRealFileSystem();
>  #endif
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>


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


[PATCH] D55269: [CUDA][OpenMP] Fix nvidia-cuda-toolkit detection on Debian/Ubuntu

2018-12-05 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

In D55269#1320207 , @Hahnfeld wrote:

> I think there are some misunderstandings here, or at least I understand 
> things differently than @tra is describing them: AFAICS this change is NOT 
> about replacing `nvcc` by `clang` in any CMake project (be that the OpenMP 
> runtime or any other project outside of LLVM).


I was not talking about replacing nvcc with clang, but rather just pointed that 
CUDA support in cmake is geared towards nvcc only and may not always give the 
right answer for clang.

> The scope of the second issue is that there is a CMake project (namely 
> `openmp`) which uses `FindCuda.cmake` to detect the CUDA installation and 
> passes the resulting path to `--cuda-path`. I wrote that detection and I 
> still think it's correct because that is a way to force Clang to use a given 
> CUDA install location. If `FindCuda.cmake` returns a wrong path (`/usr` 
> instead of `/usr/lib/cuda`) or the shim package behind `/usr/lib/cuda` is 
> incomplete, then this needs to be fixed and not workarounded in Clang.

We are in agreement here.  I see no problem with explicitly specifying CUDA 
path with --cuda-path and indeed, do think that CUDA detection in Cmake 
currently provides the path that does not work for clang. It's not exactly 
invalid as it is a valid path if one were to use nvcc, but that relies on some 
additional settings debian/ubuntu sets in the environment that only work for 
nvcc.

> That said, I think it's the right way to add `isUbuntu()` to the candidate 
> detection that we already have for Debian. Simply because the compiler should 
> just get most of the simple cases right automatically.

That part I'm also fine with as Ubuntu uses exactly the same shim Debian has 
implemented and it makes sense for Clang to benefit from it on Ubuntu.

> 
> 
> In D55269#1319109 , @jdenny wrote:
> 
>> [...]
>>
>> In D55269#1318901 , @tra wrote:
>>
>> > --cuda-path=/usr was never supposed to work -- /usr is *not* the root of 
>> > the CUDA SDK.
>>
>>
>> /usr/lib/cuda/bin/nvcc doesn't exist, so that's probably why FindCUDA.cmake 
>> finds /usr/bin/nvcc (also installed by nvidia-cuda-toolkit).  Is it fair 
>> then to say that /usr/lib/cuda isn't the root either?
>>
>> [...]
>>
>> It seems that nvidia-cuda-toolkit still isn't installing a complete CUDA 
>> install in one location.  Even if it installed it all to /usr/lib/cuda, 
>> FindCUDA.cmake would probably still see /usr/bin/nvcc and assume /usr is the 
>> CUDA install root.
> 
> 
> I think this needs to be fixed then: The shim package should provide links to 
> all necessary things and CMake must be prepared to deal with it. IMO we 
> shouldn't workaround broken build system detection in the compiler.

That's exactly what I proposed to Debian folks 
https://bugs.llvm.org/show_bug.cgi?id=26966#c6 and I was under impression that 
that's what they did. It appears that they only created an empty directory 
structure with version.txt in it. At least that's what I see when I unpack 
nvidia-cuda-toolkit_9.1.85-3ubuntu1_amd64.deb. Perhaps they do something extra 
in the install script, but I didn't find anything obvious in the deb itself.

> 
> 
> In D55269#1319116 , @jdenny wrote:
> 
>> By the way, nvidia-cuda-toolkit does install the following, but there's no 
>> nvvm directory as clang currently expects:
> 
> 
> Then again the distro's packaging is broken and needs to be adjusted.

Perhaps we can build a shim package ourselves and distribute it along with the 
clang. This would decouple usability of clang from the Ubuntu/Debian release 
process and would make it possible to make clang work with CUDA on older 
debian/Ubuntu versions.

>> Let's start with fixing OpenMP's cmake files. Once it no longer insists on 
>> specifying --cuda-path=/usr, and isUbuntu is in place, what is the remaining 
>> failure that you see?
> 
> I disagree here: It's not OpenMP but CMake that's detecting the wrong path 
> here. This is the place to fix it once and for all (and possibly get the shim 
> package right in that process).

It's somewhat orthogonal, IMO. I agree that it's not OpenMP's problem. Cmake 
will fix it at some point in future, but, presumably, we want OpenMP buildable 
*now*. Adding a temporary workaround for something that Cmake can't handle now 
would make building OpenMP with clang somewhat easier which was the end goal of 
this patch. In the end it's up to OpenMP maintainers what they would want to do.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55269



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


r348387 - [CodeComplete] Fix a crash in access checks of inner classes

2018-12-05 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Wed Dec  5 09:38:39 2018
New Revision: 348387

URL: http://llvm.org/viewvc/llvm-project?rev=348387&view=rev
Log:
[CodeComplete] Fix a crash in access checks of inner classes

Summary: The crash was introduced in r348135.

Reviewers: kadircet

Reviewed By: kadircet

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/Sema/SemaAccess.cpp
cfe/trunk/lib/Sema/SemaCodeComplete.cpp
cfe/trunk/test/CodeCompletion/accessibility.cpp

Modified: cfe/trunk/lib/Sema/SemaAccess.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaAccess.cpp?rev=348387&r1=348386&r2=348387&view=diff
==
--- cfe/trunk/lib/Sema/SemaAccess.cpp (original)
+++ cfe/trunk/lib/Sema/SemaAccess.cpp Wed Dec  5 09:38:39 2018
@@ -1896,8 +1896,6 @@ bool Sema::IsSimplyAccessible(NamedDecl
   if (Target->isCXXClassMember() && NamingClass) {
 if (!getLangOpts().CPlusPlus)
   return false;
-if (Target->getAccess() == AS_public)
-  return true;
 // The unprivileged access is AS_none as we don't know how the member was
 // accessed, which is described by the access in DeclAccessPair.
 // `IsAccessible` will examine the actual access of Target (i.e.

Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=348387&r1=348386&r2=348387&view=diff
==
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Wed Dec  5 09:38:39 2018
@@ -11,6 +11,7 @@
 //
 
//===--===//
 #include "clang/AST/Decl.h"
+#include "clang/AST/DeclBase.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/ExprCXX.h"
@@ -1313,23 +1314,43 @@ public:
 
   void FoundDecl(NamedDecl *ND, NamedDecl *Hiding, DeclContext *Ctx,
  bool InBaseClass) override {
-// Naming class to use for access check. In most cases it was provided
-// explicitly (e.g. member access (lhs.foo) or qualified lookup (X::)), for
-// unqualified lookup we fallback to the \p Ctx in which we found the
-// member.
-auto *NamingClass = this->NamingClass;
-if (!NamingClass)
-  NamingClass = llvm::dyn_cast_or_null(Ctx);
-bool Accessible =
-Results.getSema().IsSimplyAccessible(ND, NamingClass, BaseType);
 ResultBuilder::Result Result(ND, Results.getBasePriority(ND), nullptr,
- false, Accessible, FixIts);
+ false, IsAccessible(ND, Ctx), FixIts);
 Results.AddResult(Result, InitialLookupCtx, Hiding, InBaseClass);
   }
 
   void EnteredContext(DeclContext *Ctx) override {
 Results.addVisitedContext(Ctx);
   }
+
+private:
+  bool IsAccessible(NamedDecl *ND, DeclContext *Ctx) {
+// Naming class to use for access check. In most cases it was provided
+// explicitly (e.g. member access (lhs.foo) or qualified lookup (X::)),
+// for unqualified lookup we fallback to the \p Ctx in which we found the
+// member.
+auto *NamingClass = this->NamingClass;
+QualType BaseType = this->BaseType;
+if (auto *Cls = llvm::dyn_cast_or_null(Ctx)) {
+  if (!NamingClass)
+NamingClass = Cls;
+  // When we emulate implicit 'this->' in an unqualified lookup, we might
+  // end up with an invalid naming class. In that case, we avoid emulating
+  // 'this->' qualifier to satisfy preconditions of the access checking.
+  if (NamingClass->getCanonicalDecl() != Cls->getCanonicalDecl() &&
+  !NamingClass->isDerivedFrom(Cls)) {
+NamingClass = Cls;
+BaseType = QualType();
+  }
+} else {
+  // The decl was found outside the C++ class, so only ObjC access checks
+  // apply. Those do not rely on NamingClass and BaseType, so we clear them
+  // out.
+  NamingClass = nullptr;
+  BaseType = QualType();
+}
+return Results.getSema().IsSimplyAccessible(ND, NamingClass, BaseType);
+  }
 };
 } // namespace
 

Modified: cfe/trunk/test/CodeCompletion/accessibility.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeCompletion/accessibility.cpp?rev=348387&r1=348386&r2=348387&view=diff
==
--- cfe/trunk/test/CodeCompletion/accessibility.cpp (original)
+++ cfe/trunk/test/CodeCompletion/accessibility.cpp Wed Dec  5 09:38:39 2018
@@ -71,3 +71,52 @@ class Y : public X {
 // RUN: | FileCheck -check-prefix=UNRELATED %s
   }
 };
+
+class Outer {
+ public:
+  static int pub;
+ protected:
+  static int prot;
+ private:
+  static int priv;
+
+  class Inner {
+int test() {
+  Outer::pub = 10;
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:85:14 %

[PATCH] D55260: [CodeComplete] Fix a crash in access checks of inner classes

2018-12-05 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC348387: [CodeComplete] Fix a crash in access checks of inner 
classes (authored by ibiryukov, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D55260?vs=176823&id=176847#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D55260

Files:
  lib/Sema/SemaAccess.cpp
  lib/Sema/SemaCodeComplete.cpp
  test/CodeCompletion/accessibility.cpp

Index: test/CodeCompletion/accessibility.cpp
===
--- test/CodeCompletion/accessibility.cpp
+++ test/CodeCompletion/accessibility.cpp
@@ -71,3 +71,52 @@
 // RUN: | FileCheck -check-prefix=UNRELATED %s
   }
 };
+
+class Outer {
+ public:
+  static int pub;
+ protected:
+  static int prot;
+ private:
+  static int priv;
+
+  class Inner {
+int test() {
+  Outer::pub = 10;
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:85:14 %s -o - \
+// RUN: | FileCheck -check-prefix=OUTER %s
+// OUTER: priv : [#int#]priv
+// OUTER: prot : [#int#]prot
+// OUTER: pub : [#int#]pub
+
+// Also check the unqualified case.
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:85:1 %s -o - \
+// RUN: | FileCheck -check-prefix=OUTER %s
+}
+  };
+};
+
+class Base {
+public:
+  int pub;
+};
+
+class Accessible : public Base {
+};
+
+class Inaccessible : private Base {
+};
+
+class Test : public Accessible, public Inaccessible {
+  int test() {
+this->Accessible::pub = 10;
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:112:23 %s -o - \
+// RUN: | FileCheck -check-prefix=ACCESSIBLE %s
+// ACCESSIBLE: pub (InBase)
+
+this->Inaccessible::pub = 10;
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:117:25 %s -o - \
+// RUN: | FileCheck -check-prefix=INACCESSIBLE %s
+// INACCESSIBLE: pub (InBase,Inaccessible)
+  }
+};
Index: lib/Sema/SemaCodeComplete.cpp
===
--- lib/Sema/SemaCodeComplete.cpp
+++ lib/Sema/SemaCodeComplete.cpp
@@ -11,6 +11,7 @@
 //
 //===--===//
 #include "clang/AST/Decl.h"
+#include "clang/AST/DeclBase.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/ExprCXX.h"
@@ -1313,23 +1314,43 @@
 
   void FoundDecl(NamedDecl *ND, NamedDecl *Hiding, DeclContext *Ctx,
  bool InBaseClass) override {
-// Naming class to use for access check. In most cases it was provided
-// explicitly (e.g. member access (lhs.foo) or qualified lookup (X::)), for
-// unqualified lookup we fallback to the \p Ctx in which we found the
-// member.
-auto *NamingClass = this->NamingClass;
-if (!NamingClass)
-  NamingClass = llvm::dyn_cast_or_null(Ctx);
-bool Accessible =
-Results.getSema().IsSimplyAccessible(ND, NamingClass, BaseType);
 ResultBuilder::Result Result(ND, Results.getBasePriority(ND), nullptr,
- false, Accessible, FixIts);
+ false, IsAccessible(ND, Ctx), FixIts);
 Results.AddResult(Result, InitialLookupCtx, Hiding, InBaseClass);
   }
 
   void EnteredContext(DeclContext *Ctx) override {
 Results.addVisitedContext(Ctx);
   }
+
+private:
+  bool IsAccessible(NamedDecl *ND, DeclContext *Ctx) {
+// Naming class to use for access check. In most cases it was provided
+// explicitly (e.g. member access (lhs.foo) or qualified lookup (X::)),
+// for unqualified lookup we fallback to the \p Ctx in which we found the
+// member.
+auto *NamingClass = this->NamingClass;
+QualType BaseType = this->BaseType;
+if (auto *Cls = llvm::dyn_cast_or_null(Ctx)) {
+  if (!NamingClass)
+NamingClass = Cls;
+  // When we emulate implicit 'this->' in an unqualified lookup, we might
+  // end up with an invalid naming class. In that case, we avoid emulating
+  // 'this->' qualifier to satisfy preconditions of the access checking.
+  if (NamingClass->getCanonicalDecl() != Cls->getCanonicalDecl() &&
+  !NamingClass->isDerivedFrom(Cls)) {
+NamingClass = Cls;
+BaseType = QualType();
+  }
+} else {
+  // The decl was found outside the C++ class, so only ObjC access checks
+  // apply. Those do not rely on NamingClass and BaseType, so we clear them
+  // out.
+  NamingClass = nullptr;
+  BaseType = QualType();
+}
+return Results.getSema().IsSimplyAccessible(ND, NamingClass, BaseType);
+  }
 };
 } // namespace
 
Index: lib/Sema/SemaAccess.cpp
===
--- lib/Sema/SemaAccess.cpp
+++ lib/Sema/SemaAccess.cpp
@@ -1896,8 +1896,6 @@
   if (Target->isCXXClassMember() && NamingClass) {
 if (!getLangOpts().CPlusPlus)
   return false;
-  

[PATCH] D55322: Mention changes to libc++ include dir lookup in release notes.

2018-12-05 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman accepted this revision.
arphaman added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55322



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


[PATCH] D54866: Cleanups in IdentifierInfo following the removal of PTH

2018-12-05 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC348384: [Basic] Cleanups in IdentifierInfo following the 
removal of PTH (authored by brunoricci, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D54866?vs=175143&id=176843#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D54866

Files:
  include/clang/Basic/IdentifierTable.h
  lib/Basic/IdentifierTable.cpp


Index: include/clang/Basic/IdentifierTable.h
===
--- include/clang/Basic/IdentifierTable.h
+++ include/clang/Basic/IdentifierTable.h
@@ -116,10 +116,19 @@
 
   llvm::StringMapEntry *Entry = nullptr;
 
+  IdentifierInfo()
+  : TokenID(tok::identifier), ObjCOrBuiltinID(0), HasMacro(false),
+HadMacro(false), IsExtension(false), IsFutureCompatKeyword(false),
+IsPoisoned(false), IsCPPOperatorKeyword(false),
+NeedsHandleIdentifier(false), IsFromAST(false), 
ChangedAfterLoad(false),
+FEChangedAfterLoad(false), RevertedTokenID(false), OutOfDate(false),
+IsModulesImport(false) {}
+
 public:
-  IdentifierInfo();
   IdentifierInfo(const IdentifierInfo &) = delete;
   IdentifierInfo &operator=(const IdentifierInfo &) = delete;
+  IdentifierInfo(IdentifierInfo &&) = delete;
+  IdentifierInfo &operator=(IdentifierInfo &&) = delete;
 
   /// Return true if this is the identifier for the specified string.
   ///
@@ -138,31 +147,10 @@
 
   /// Return the beginning of the actual null-terminated string for this
   /// identifier.
-  const char *getNameStart() const {
-if (Entry) return Entry->getKeyData();
-// FIXME: This is gross. It would be best not to embed specific details
-// of the PTH file format here.
-// The 'this' pointer really points to a
-// std::pair, where internal pointer
-// points to the external string data.
-using actualtype = std::pair;
-
-return ((const actualtype*) this)->second;
-  }
+  const char *getNameStart() const { return Entry->getKeyData(); }
 
   /// Efficiently return the length of this identifier info.
-  unsigned getLength() const {
-if (Entry) return Entry->getKeyLength();
-// FIXME: This is gross. It would be best not to embed specific details
-// of the PTH file format here.
-// The 'this' pointer really points to a
-// std::pair, where internal pointer
-// points to the external string data.
-using actualtype = std::pair;
-
-const char* p = ((const actualtype*) this)->second - 2;
-return (((unsigned) p[0]) | (((unsigned) p[1]) << 8)) - 1;
-  }
+  unsigned getLength() const { return Entry->getKeyLength(); }
 
   /// Return the actual identifier string.
   StringRef getName() const {
Index: lib/Basic/IdentifierTable.cpp
===
--- lib/Basic/IdentifierTable.cpp
+++ lib/Basic/IdentifierTable.cpp
@@ -34,28 +34,6 @@
 using namespace clang;
 
 
//===--===//
-// IdentifierInfo Implementation
-//===--===//
-
-IdentifierInfo::IdentifierInfo() {
-  TokenID = tok::identifier;
-  ObjCOrBuiltinID = 0;
-  HasMacro = false;
-  HadMacro = false;
-  IsExtension = false;
-  IsFutureCompatKeyword = false;
-  IsPoisoned = false;
-  IsCPPOperatorKeyword = false;
-  NeedsHandleIdentifier = false;
-  IsFromAST = false;
-  ChangedAfterLoad = false;
-  FEChangedAfterLoad = false;
-  RevertedTokenID = false;
-  OutOfDate = false;
-  IsModulesImport = false;
-}
-
-//===--===//
 // IdentifierTable Implementation
 
//===--===//
 


Index: include/clang/Basic/IdentifierTable.h
===
--- include/clang/Basic/IdentifierTable.h
+++ include/clang/Basic/IdentifierTable.h
@@ -116,10 +116,19 @@
 
   llvm::StringMapEntry *Entry = nullptr;
 
+  IdentifierInfo()
+  : TokenID(tok::identifier), ObjCOrBuiltinID(0), HasMacro(false),
+HadMacro(false), IsExtension(false), IsFutureCompatKeyword(false),
+IsPoisoned(false), IsCPPOperatorKeyword(false),
+NeedsHandleIdentifier(false), IsFromAST(false), ChangedAfterLoad(false),
+FEChangedAfterLoad(false), RevertedTokenID(false), OutOfDate(false),
+IsModulesImport(false) {}
+
 public:
-  IdentifierInfo();
   IdentifierInfo(const IdentifierInfo &) = delete;
   IdentifierInfo &operator=(const IdentifierInfo &) = delete;
+  IdentifierInfo(IdentifierInfo &&) = delete;
+  IdentifierInfo &operator=(IdentifierInfo &&) = delete;
 
   /// Return true if this is the identifier for the specified string.
   ///
@@ -138,31 +147,10 @@
 
   /// Return the beginning of the actual null-terminated string for this
   

[PATCH] D55131: [CTU] Add more lit tests and better error handling

2018-12-05 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added inline comments.



Comment at: test/Analysis/ctu-main.c:4
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-pch -o 
%t/ctudir2/ctu-other.c.ast %S/Inputs/ctu-other.c
+// RUN: cp %S/Inputs/externalFnMap2.txt %t/ctudir2/externalFnMap.txt
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -std=c89 -analyze 
-analyzer-checker=core,debug.ExprInspection  -analyzer-config 
experimental-enable-naive-ctu-analysis=true -analyzer-config ctu-dir=%t/ctudir2 
-verify %s

martong wrote:
> Szelethus wrote:
> > This is a question rather than anything else, why do we have both 
> > externalFnMap2.txt and externalFnMap.txt?
> `externalFnMap.txt` goes for `ctu-other.cpp`.
> `externalFnMap2.txt` goes for `ctu-other.c`.
> Perhaps we should rename them in the `Inputs` directory to include the 
> indexed file name. E.g. `ctu-other.cpp.externalFnMap.txt`. What do you think?
Sounds great! :)


Repository:
  rC Clang

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

https://reviews.llvm.org/D55131



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


r348384 - [Basic] Cleanups in IdentifierInfo following the removal of PTH

2018-12-05 Thread Bruno Ricci via cfe-commits
Author: brunoricci
Date: Wed Dec  5 09:16:55 2018
New Revision: 348384

URL: http://llvm.org/viewvc/llvm-project?rev=348384&view=rev
Log:
[Basic] Cleanups in IdentifierInfo following the removal of PTH

The Entry pointer in IdentifierInfo was only null for IdentifierInfo
created from a PTH. Now that PTH support has been removed we can remove
some PTH specific code in IdentifierInfo::getLength and
IdentifierInfo::getNameStart.

Also make the constructor of IdentifierInfo private to make sure that
they are only created by IdentifierTable, and move it to the header so
that it can be inlined in IdentifierTable::get and IdentifierTable::getOwn.

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

Reviewed By: erichkeane


Modified:
cfe/trunk/include/clang/Basic/IdentifierTable.h
cfe/trunk/lib/Basic/IdentifierTable.cpp

Modified: cfe/trunk/include/clang/Basic/IdentifierTable.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/IdentifierTable.h?rev=348384&r1=348383&r2=348384&view=diff
==
--- cfe/trunk/include/clang/Basic/IdentifierTable.h (original)
+++ cfe/trunk/include/clang/Basic/IdentifierTable.h Wed Dec  5 09:16:55 2018
@@ -116,10 +116,19 @@ class alignas(IdentifierInfoAlignment) I
 
   llvm::StringMapEntry *Entry = nullptr;
 
+  IdentifierInfo()
+  : TokenID(tok::identifier), ObjCOrBuiltinID(0), HasMacro(false),
+HadMacro(false), IsExtension(false), IsFutureCompatKeyword(false),
+IsPoisoned(false), IsCPPOperatorKeyword(false),
+NeedsHandleIdentifier(false), IsFromAST(false), 
ChangedAfterLoad(false),
+FEChangedAfterLoad(false), RevertedTokenID(false), OutOfDate(false),
+IsModulesImport(false) {}
+
 public:
-  IdentifierInfo();
   IdentifierInfo(const IdentifierInfo &) = delete;
   IdentifierInfo &operator=(const IdentifierInfo &) = delete;
+  IdentifierInfo(IdentifierInfo &&) = delete;
+  IdentifierInfo &operator=(IdentifierInfo &&) = delete;
 
   /// Return true if this is the identifier for the specified string.
   ///
@@ -138,31 +147,10 @@ public:
 
   /// Return the beginning of the actual null-terminated string for this
   /// identifier.
-  const char *getNameStart() const {
-if (Entry) return Entry->getKeyData();
-// FIXME: This is gross. It would be best not to embed specific details
-// of the PTH file format here.
-// The 'this' pointer really points to a
-// std::pair, where internal pointer
-// points to the external string data.
-using actualtype = std::pair;
-
-return ((const actualtype*) this)->second;
-  }
+  const char *getNameStart() const { return Entry->getKeyData(); }
 
   /// Efficiently return the length of this identifier info.
-  unsigned getLength() const {
-if (Entry) return Entry->getKeyLength();
-// FIXME: This is gross. It would be best not to embed specific details
-// of the PTH file format here.
-// The 'this' pointer really points to a
-// std::pair, where internal pointer
-// points to the external string data.
-using actualtype = std::pair;
-
-const char* p = ((const actualtype*) this)->second - 2;
-return (((unsigned) p[0]) | (((unsigned) p[1]) << 8)) - 1;
-  }
+  unsigned getLength() const { return Entry->getKeyLength(); }
 
   /// Return the actual identifier string.
   StringRef getName() const {

Modified: cfe/trunk/lib/Basic/IdentifierTable.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/IdentifierTable.cpp?rev=348384&r1=348383&r2=348384&view=diff
==
--- cfe/trunk/lib/Basic/IdentifierTable.cpp (original)
+++ cfe/trunk/lib/Basic/IdentifierTable.cpp Wed Dec  5 09:16:55 2018
@@ -34,28 +34,6 @@
 using namespace clang;
 
 
//===--===//
-// IdentifierInfo Implementation
-//===--===//
-
-IdentifierInfo::IdentifierInfo() {
-  TokenID = tok::identifier;
-  ObjCOrBuiltinID = 0;
-  HasMacro = false;
-  HadMacro = false;
-  IsExtension = false;
-  IsFutureCompatKeyword = false;
-  IsPoisoned = false;
-  IsCPPOperatorKeyword = false;
-  NeedsHandleIdentifier = false;
-  IsFromAST = false;
-  ChangedAfterLoad = false;
-  FEChangedAfterLoad = false;
-  RevertedTokenID = false;
-  OutOfDate = false;
-  IsModulesImport = false;
-}
-
-//===--===//
 // IdentifierTable Implementation
 
//===--===//
 


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


  1   2   >