Re: [PATCH] D59376: [LibTooling] Add Transformer, a library for source-to-source transformations.

2019-04-03 Thread Yitzhak Mandelbaum via cfe-commits
https://reviews.llvm.org/D60213 for the record

On Wed, Apr 3, 2019 at 12:55 PM Yitzhak Mandelbaum 
wrote:

> Thanks.  Do you have build command I can run before/after to verify my fix
> before I submit?
>
> On Wed, Apr 3, 2019 at 12:43 PM Alexey Bataev via Phabricator <
> revi...@reviews.llvm.org> wrote:
>
>> ABataev added a comment.
>>
>> Patch breaks the build with the shared libraries, for example,
>> http://lab.llvm.org:8011/builders/clang-ppc64le-linux-multistage/builds/9498.
>> Seems to me, you need to add an extra dependency on clangTooling.
>> clangToolingCore is not enough.
>>
>>
>> Repository:
>>   rC Clang
>>
>> CHANGES SINCE LAST ACTION
>>   https://reviews.llvm.org/D59376/new/
>>
>> https://reviews.llvm.org/D59376
>>
>>
>>
>>


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


[PATCH] D60213: Add clangTooling dependency to fix the build.

2019-04-03 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added a comment.

In D60213#1453516 , @ABataev wrote:

> Nope, it won't work. There is a cyclic dependency, unfortunately. 
> clangTooling depends on clangToolingRefactor already. You need to revert your 
> commit and refactor it to remove the cyclic dependency.


I see. I've never reverted before and I can't seem to find any instructions for 
doing so (only some offhand mentions). If there's a doc on this, can you please 
link me to it?

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60213



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


Re: [PATCH] D60213: Add clangTooling dependency to fix the build.

2019-04-03 Thread Yitzhak Mandelbaum via cfe-commits
That would be great, thank you.

On Wed, Apr 3, 2019 at 1:28 PM Alexey Bataev via Phabricator <
revi...@reviews.llvm.org> wrote:

> ABataev added a comment.
>
> I can revert it for you, if you want
>
>
> Repository:
>   rG LLVM Github Monorepo
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D60213/new/
>
> https://reviews.llvm.org/D60213
>
>
>
>


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


[PATCH] D60151: [clang-tidy] Add using SmallSet to LLVM.h to fix bug in typedef in llvm checkers.

2019-04-03 Thread Don Hinton via Phabricator via cfe-commits
hintonda marked an inline comment as done.
hintonda added inline comments.



Comment at: clang-tools-extra/clang-tidy/utils/HeaderFileExtensionsUtils.h:21
 
-typedef llvm::SmallSet HeaderFileExtensionsSet;
+using HeaderFileExtensionsSet = SmallSet;
 

aaron.ballman wrote:
> alexfh wrote:
> > hintonda wrote:
> > > aaron.ballman wrote:
> > > > hintonda wrote:
> > > > > aaron.ballman wrote:
> > > > > > I do not like that we're removing the namespace qualifier here. I 
> > > > > > would prefer to leave it as `::llvm::SmallSet<::llvm::StringRef, 
> > > > > > 5>` if there is a namespace clash.
> > > > > Other than aesthetics, the reason I don't like the idea of fully 
> > > > > scoping these types, at least without a comment, is that the error is 
> > > > > triggered by some other code gets included first, and has nothing to 
> > > > > do with this code -- there's nothing actually wrong with the original 
> > > > > code.  So it could/would be confusing for a reader later on wondering 
> > > > > why you needed to fully scope these types, and not others.
> > > > I would argue that the original code is wrong to not use 
> > > > fully-qualified namespace specifiers. The issue is that we have two 
> > > > different namespaces named `llvm` and have gotten away with poor 
> > > > namespace hygiene by accident. Either we should rename the clang-tidy 
> > > > `llvm` namespace to something that does not conflict, or we should 
> > > > consistently use fully-qualified namespace specifiers when in 
> > > > clang-tidy and needing to refer to an `llvm` namespace explicitly.
> > > > 
> > > > I think this patch goes in the wrong direction by making it easier to 
> > > > limp along with poor namespace hygiene.
> > > By fully qualified, do you mean appending the global namespace, `::` to 
> > > everything?   I actually like using `llvm::`, but `::llvm::` is odd and 
> > > needs explanation.
> > > 
> > > I'd be happy to abandon this change and instead rename the 
> > > `clang::tidy::llvm` to `clang::tidy::something_else`, if that's what the 
> > > community would prefer.
> > > 
> > Aaron, you have  a very good point. We also have a more recent example of a 
> > good namespace hygiene in clang-tidy code: the `abseil` module is not 
> > called `absl` mainly to "avoid collisions with a well-known top-level 
> > namespace" 
> > (https://google.github.io/styleguide/cppguide.html#Namespace_Names).
> > 
> > If we can rename the llvm module to something reasonable ("llvm_project"?) 
> > without breaking the naming invariants (used by the add_new_check.py 
> > script, for example), it would be a much better solution.
> > By fully qualified, do you mean appending the global namespace, :: to 
> > everything? I actually like using llvm::, but ::llvm:: is odd and needs 
> > explanation.
> 
> I mean that within clang-tidy, anywhere we write `llvm::` today, we write 
> `::llvm::` instead when we're talking about the global `llvm` namespace as 
> opposed to the clang-tidy `llvm` namespace.
> 
> > I'd be happy to abandon this change and instead rename the 
> > clang::tidy::llvm to clang::tidy::something_else, if that's what the 
> > community would prefer.
> 
> That's my personal preference. I'm fine with the suggestion from @alexfh of 
> using `llvm_project` instead, but we could also go with `llvm_proj`, 
> `llvm_code`, `llvm_tidy`, etc.
Looks like a consensus.  I'll work up a patch and get back to you.  Thanks 
again.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60151



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


r357617 - [OPENMP]Add codegen for firstprivate vars with allocate clause.

2019-04-03 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Apr  3 10:57:06 2019
New Revision: 357617

URL: http://llvm.org/viewvc/llvm-project?rev=357617=rev
Log:
[OPENMP]Add codegen for firstprivate vars with allocate clause.

Added codegen/test for the firstprivatized variables with the allocate
clause.

Modified:
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/test/OpenMP/parallel_firstprivate_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=357617=357616=357617=diff
==
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Wed Apr  3 10:57:06 2019
@@ -1457,7 +1457,13 @@ CodeGenFunction::EmitAutoVarAlloca(const
 
   Address address = Address::invalid();
   Address AllocaAddr = Address::invalid();
-  if (Ty->isConstantSizeType()) {
+  Address OpenMPLocalAddr =
+  getLangOpts().OpenMP
+  ? CGM.getOpenMPRuntime().getAddressOfLocalVariable(*this, )
+  : Address::invalid();
+  if (getLangOpts().OpenMP && OpenMPLocalAddr.isValid()) {
+address = OpenMPLocalAddr;
+  } else if (Ty->isConstantSizeType()) {
 bool NRVO = getLangOpts().ElideConstructors &&
   D.isNRVOVariable();
 
@@ -1500,14 +1506,7 @@ CodeGenFunction::EmitAutoVarAlloca(const
 // unless:
 // - it's an NRVO variable.
 // - we are compiling OpenMP and it's an OpenMP local variable.
-
-Address OpenMPLocalAddr =
-getLangOpts().OpenMP
-? CGM.getOpenMPRuntime().getAddressOfLocalVariable(*this, )
-: Address::invalid();
-if (getLangOpts().OpenMP && OpenMPLocalAddr.isValid()) {
-  address = OpenMPLocalAddr;
-} else if (NRVO) {
+if (NRVO) {
   // The named return value optimization: allocate this variable in the
   // return slot, so that we can elide the copy when returning this
   // variable (C++0x [class.copy]p34).

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=357617=357616=357617=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Wed Apr  3 10:57:06 2019
@@ -9768,10 +9768,13 @@ Address CGOpenMPRuntime::getAddressOfLoc
   CharUnits Align = CGM.getContext().getDeclAlign(CVD);
   if (CVD->getType()->isVariablyModifiedType()) {
 Size = CGF.getTypeSize(CVD->getType());
-Align = CGM.getContext().getTypeAlignInChars(CVD->getType());
+// Align the size: ((size + align - 1) / align) * align
+Size = CGF.Builder.CreateNUWAdd(
+Size, CGM.getSize(Align - CharUnits::fromQuantity(1)));
+Size = CGF.Builder.CreateUDiv(Size, CGM.getSize(Align));
+Size = CGF.Builder.CreateNUWMul(Size, CGM.getSize(Align));
   } else {
 CharUnits Sz = CGM.getContext().getTypeSizeInChars(CVD->getType());
-Align = CGM.getContext().getDeclAlign(CVD);
 Size = CGM.getSize(Sz.alignTo(Align));
   }
   llvm::Value *ThreadID = getThreadID(CGF, CVD->getBeginLoc());

Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=357617=357616=357617=diff
==
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Wed Apr  3 10:57:06 2019
@@ -750,8 +750,10 @@ bool CodeGenFunction::EmitOMPFirstprivat
   bool ThisFirstprivateIsLastprivate =
   Lastprivates.count(OrigVD->getCanonicalDecl()) > 0;
   const FieldDecl *FD = CapturedStmtInfo->lookup(OrigVD);
+  const auto *VD = cast(cast(IInit)->getDecl());
   if (!MustEmitFirstprivateCopy && !ThisFirstprivateIsLastprivate && FD &&
-  !FD->getType()->isReferenceType()) {
+  !FD->getType()->isReferenceType() &&
+  (!VD || !VD->hasAttr())) {
 EmittedAsFirstprivate.insert(OrigVD->getCanonicalDecl());
 ++IRef;
 ++InitsRef;
@@ -760,7 +762,8 @@ bool CodeGenFunction::EmitOMPFirstprivat
   // Do not emit copy for firstprivate constant variables in target 
regions,
   // captured by reference.
   if (DeviceConstTarget && OrigVD->getType().isConstant(getContext()) &&
-  FD && FD->getType()->isReferenceType()) {
+  FD && FD->getType()->isReferenceType() &&
+  (!VD || !VD->hasAttr())) {
 (void)CGM.getOpenMPRuntime().registerTargetFirstprivateCopy(*this,
 OrigVD);
 ++IRef;
@@ -770,7 +773,6 @@ bool CodeGenFunction::EmitOMPFirstprivat
   FirstprivateIsLastprivate =
   FirstprivateIsLastprivate || ThisFirstprivateIsLastprivate;
   if 

Re: [PATCH] D59376: [LibTooling] Add Transformer, a library for source-to-source transformations.

2019-04-03 Thread Yitzhak Mandelbaum via cfe-commits
Thanks.  Any idea why AtomicChange.cpp's inclusion of
clang/Tooling/ReplacementsYaml.h
doesn't cause the same problem?
https://github.com/llvm/llvm-project/blob/master/clang/lib/Tooling/Refactoring/AtomicChange.cpp

On Wed, Apr 3, 2019 at 2:11 PM Alexey Bataev  wrote:

> The problem is that libToolingRefactor is a part of libTooling. And you
> have the dependency from the Tooling/Refactor subdirectory to the outer one
> Tooling/ directory. And it means that libToolingRefactor is a part of
> libTooling, but it must depend on libTooling itself.
>
> -
> Best regards,
> Alexey Bataev
>
> 03.04.2019 14:08, Yitzhak Mandelbaum пишет:
>
> Alexey, thanks for reverting the change. Can you expand on why a
> dependency from libToolingRefactor to libTooling causes a cycle in the dep
> graph? In particular, I can't find the reverse dependency libTooling ->
> libToolingRefactor. If you can expand on that (I presume its a chain rather
> than a direct dependency?) that would be really helpful.
>
> thanks!
>
> On Wed, Apr 3, 2019 at 1:29 PM Yitzhak Mandelbaum 
> wrote:
>
>> I'll revert the change.
>>
>> On Wed, Apr 3, 2019 at 1:00 PM Yitzhak Mandelbaum 
>> wrote:
>>
>>> https://reviews.llvm.org/D60213 for the record
>>>
>>> On Wed, Apr 3, 2019 at 12:55 PM Yitzhak Mandelbaum 
>>> wrote:
>>>
 Thanks.  Do you have build command I can run before/after to verify my
 fix before I submit?

 On Wed, Apr 3, 2019 at 12:43 PM Alexey Bataev via Phabricator <
 revi...@reviews.llvm.org> wrote:

> ABataev added a comment.
>
> Patch breaks the build with the shared libraries, for example,
> http://lab.llvm.org:8011/builders/clang-ppc64le-linux-multistage/builds/9498.
> Seems to me, you need to add an extra dependency on clangTooling.
> clangToolingCore is not enough.
>
>
> Repository:
>   rC Clang
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D59376/new/
>
> https://reviews.llvm.org/D59376
>
>
>
>


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


[PATCH] D60235: [CMake] Disable libc++ and libc++abi new/delete definitions when built with ASan

2019-04-03 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a subscriber: ldionne.
phosek added a comment.

In D60235#1454152 , @mcgrathr wrote:

> IMHO the library code should use `#if !__has_feature(...)` to avoid the 
> definitions entirely when built with a sanitizer whose runtime provides them.
>  But this is a fine way to achieve that while we wait for those libraries to 
> be fixed for sanitized builds.


I agree, D60176  implements that but @ldionne 
thinks that we should go with the CMake option.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60235



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


[PATCH] D60237: [MS] Add metadata for __declspec(allocator)

2019-04-03 Thread Amy Huang via Phabricator via cfe-commits
akhuang created this revision.
akhuang added a reviewer: rnk.
Herald added subscribers: cfe-commits, jfb.
Herald added a project: clang.

Emit !heapallocsite in the metadata for calls to functions marked with
__declspec(allocator). Eventually this will be emitted as S_HEAPALLOCSITE debug
info in codeview.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D60237

Files:
  clang/lib/CodeGen/CGAtomic.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/test/CodeGen/debug-info-codeview-heapallocsite.c

Index: clang/test/CodeGen/debug-info-codeview-heapallocsite.c
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-codeview-heapallocsite.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -debug-info-kind=limited -gcodeview -fdeclspec -S -emit-llvm < %s | FileCheck %s
+
+char buf[1024];
+__declspec(allocator) void *myalloc(int s) {
+  void *p = [0];
+  return p;
+}
+
+void call_alloc() {
+  char *p = (char*)myalloc(sizeof(char));
+}
+
+// CHECK: !heapallocsite [[DBG_F1:!.*]]
+// CHECK: [[DBG_F1:!.*]] = !{}
Index: clang/lib/CodeGen/CGDebugInfo.h
===
--- clang/lib/CodeGen/CGDebugInfo.h
+++ clang/lib/CodeGen/CGDebugInfo.h
@@ -476,6 +476,9 @@
   /// Emit standalone debug info for a type.
   llvm::DIType *getOrCreateStandaloneType(QualType Ty, SourceLocation Loc);
 
+  /// Get debug info for MSAllocator metadata.
+  llvm::MDNode *getMSAllocatorMetadata(QualType Ty, SourceLocation Loc);
+
   void completeType(const EnumDecl *ED);
   void completeType(const RecordDecl *RD);
   void completeRequiredType(const RecordDecl *RD);
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1959,6 +1959,20 @@
   return T;
 }
 
+llvm::MDNode *CGDebugInfo::getMSAllocatorMetadata(QualType D,
+  SourceLocation Loc) {
+  // FIXME: return the type that return value is cast to
+  llvm::MDNode *node;
+  if (D.getTypePtr()->isVoidPointerType()) {
+node = llvm::MDNode::get(CGM.getLLVMContext(), None);
+  } else {
+QualType PointeeTy = D.getTypePtr()->getPointeeType();
+node = getOrCreateType(PointeeTy, getOrCreateFile(Loc));
+  }
+  return node;
+}
+
+
 void CGDebugInfo::completeType(const EnumDecl *ED) {
   if (DebugKind <= codegenoptions::DebugLineTablesOnly)
 return;
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -3800,6 +3800,8 @@
 
   llvm::FunctionType *IRFuncTy = getTypes().GetFunctionType(CallInfo);
 
+  const Decl *TargetDecl = Callee.getAbstractInfo().getCalleeDecl().getDecl();
+
 #ifndef NDEBUG
   if (!(CallInfo.isVariadic() && CallInfo.getArgStruct())) {
 // For an inalloca varargs function, we don't expect CallInfo to match the
@@ -4288,11 +4290,7 @@
   // Apply always_inline to all calls within flatten functions.
   // FIXME: should this really take priority over __try, below?
   if (CurCodeDecl && CurCodeDecl->hasAttr() &&
-  !(Callee.getAbstractInfo().getCalleeDecl().getDecl() &&
-Callee.getAbstractInfo()
-.getCalleeDecl()
-.getDecl()
-->hasAttr())) {
+  !(TargetDecl && TargetDecl->hasAttr())) {
 Attrs =
 Attrs.addAttribute(getLLVMContext(), llvm::AttributeList::FunctionIndex,
llvm::Attribute::AlwaysInline);
@@ -4376,11 +4374,17 @@
 
   // Suppress tail calls if requested.
   if (llvm::CallInst *Call = dyn_cast(CI)) {
-const Decl *TargetDecl = Callee.getAbstractInfo().getCalleeDecl().getDecl();
 if (TargetDecl && TargetDecl->hasAttr())
   Call->setTailCallKind(llvm::CallInst::TCK_NoTail);
   }
 
+  // Add metadata for calls to MSAllocator functions
+  if (!DisableDebugInfo) {
+if (TargetDecl && TargetDecl->hasAttr())
+  CI->setMetadata("heapallocsite", getDebugInfo()->
+   getMSAllocatorMetadata(RetTy, Loc));
+  }
+
   // 4. Finish the call.
 
   // If the call doesn't return, finish the basic block and clear the
@@ -4537,7 +4541,6 @@
   } ();
 
   // Emit the assume_aligned check on the return value.
-  const Decl *TargetDecl = Callee.getAbstractInfo().getCalleeDecl().getDecl();
   if (Ret.isScalar() && TargetDecl) {
 if (const auto *AA = TargetDecl->getAttr()) {
   llvm::Value *OffsetValue = nullptr;
Index: clang/lib/CodeGen/CGAtomic.cpp
===
--- clang/lib/CodeGen/CGAtomic.cpp
+++ clang/lib/CodeGen/CGAtomic.cpp
@@ -1688,7 +1688,7 @@
 UpRVal = OldRVal;
 DesiredLVal = CGF.MakeAddrLValue(DesiredAddr, AtomicLVal.getType());
   } else {
-// Build new lvalue for temp address
+

[clang-tools-extra] r357654 - Make clangd-fuzzer use the normal add_llvm_fuzzer() machinery

2019-04-03 Thread Nico Weber via cfe-commits
Author: nico
Date: Wed Apr  3 17:05:53 2019
New Revision: 357654

URL: http://llvm.org/viewvc/llvm-project?rev=357654=rev
Log:
Make clangd-fuzzer use the normal add_llvm_fuzzer() machinery

This allows building it even if no fuzzer is enabled. (Sadly, it only
builds on Linux at the moment.)

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

Added:
clang-tools-extra/trunk/clangd/fuzzer/DummyClangdMain.cpp
clang-tools-extra/trunk/clangd/fuzzer/clangd-fuzzer.cpp
Removed:
clang-tools-extra/trunk/clangd/fuzzer/ClangdFuzzer.cpp
Modified:
clang-tools-extra/trunk/clangd/CMakeLists.txt
clang-tools-extra/trunk/clangd/fuzzer/CMakeLists.txt

Modified: clang-tools-extra/trunk/clangd/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CMakeLists.txt?rev=357654=357653=357654=diff
==
--- clang-tools-extra/trunk/clangd/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clangd/CMakeLists.txt Wed Apr  3 17:05:53 2019
@@ -116,7 +116,8 @@ add_clang_library(clangDaemon
   )
 
 add_subdirectory(refactor/tweaks)
-if( LLVM_LIB_FUZZING_ENGINE OR LLVM_USE_SANITIZE_COVERAGE )
+if (LINUX)
+  # FIXME: Make fuzzer not use linux-specific APIs, build it everywhere.
   add_subdirectory(fuzzer)
 endif()
 add_subdirectory(tool)

Modified: clang-tools-extra/trunk/clangd/fuzzer/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/fuzzer/CMakeLists.txt?rev=357654=357653=357654=diff
==
--- clang-tools-extra/trunk/clangd/fuzzer/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clangd/fuzzer/CMakeLists.txt Wed Apr  3 17:05:53 
2019
@@ -2,13 +2,10 @@ include_directories(${CMAKE_CURRENT_SOUR
 
 set(LLVM_LINK_COMPONENTS support)
 
-if(LLVM_USE_SANITIZE_COVERAGE)
-  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=fuzzer")
-endif()
-
-add_clang_executable(clangd-fuzzer
-  EXCLUDE_FROM_ALL
-  ClangdFuzzer.cpp
+# This fuzzer runs on oss-fuzz, so keep it around even if it looks 
unreferenced.
+add_llvm_fuzzer(clangd-fuzzer
+  clangd-fuzzer.cpp
+  DUMMY_MAIN DummyClangdMain.cpp
   )
 
 target_link_libraries(clangd-fuzzer
@@ -20,5 +17,4 @@ target_link_libraries(clangd-fuzzer
   clangSema
   clangTooling
   clangToolingCore
-  ${LLVM_LIB_FUZZING_ENGINE}
   )

Removed: clang-tools-extra/trunk/clangd/fuzzer/ClangdFuzzer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/fuzzer/ClangdFuzzer.cpp?rev=357653=auto
==
--- clang-tools-extra/trunk/clangd/fuzzer/ClangdFuzzer.cpp (original)
+++ clang-tools-extra/trunk/clangd/fuzzer/ClangdFuzzer.cpp (removed)
@@ -1,42 +0,0 @@
-//===-- ClangdFuzzer.cpp - Fuzz clangd 
===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===--===//
-///
-/// \file
-/// \brief This file implements a function that runs clangd on a single input.
-/// This function is then linked into the Fuzzer library.
-///
-//===--===//
-
-#include "ClangdLSPServer.h"
-#include "ClangdServer.h"
-#include "CodeComplete.h"
-#include "FSProvider.h"
-#include 
-#include 
-
-using namespace clang::clangd;
-
-extern "C" int LLVMFuzzerTestOneInput(uint8_t *data, size_t size) {
-  if (size == 0)
-return 0;
-
-  // fmemopen isn't portable, but I think we only run the fuzzer on Linux.
-  std::FILE *In = fmemopen(data, size, "r");
-  auto Transport = newJSONTransport(In, llvm::nulls(),
-/*InMirror=*/nullptr, /*Pretty=*/false,
-/*Style=*/JSONStreamStyle::Delimited);
-  RealFileSystemProvider FS;
-  CodeCompleteOptions CCOpts;
-  CCOpts.EnableSnippets = false;
-  ClangdServer::Options Opts;
-
-  // Initialize and run ClangdLSPServer.
-  ClangdLSPServer LSPServer(*Transport, FS, CCOpts, llvm::None, false, Opts);
-  LSPServer.run();
-  return 0;
-}

Added: clang-tools-extra/trunk/clangd/fuzzer/DummyClangdMain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/fuzzer/DummyClangdMain.cpp?rev=357654=auto
==
--- clang-tools-extra/trunk/clangd/fuzzer/DummyClangdMain.cpp (added)
+++ clang-tools-extra/trunk/clangd/fuzzer/DummyClangdMain.cpp Wed Apr  3 
17:05:53 2019
@@ -0,0 +1,18 @@
+//=== DummyClangdMain.cpp - Entry point to sanity check the fuzzer 
===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// 

[PATCH] D59923: [Driver] Simplify -g level computation and its interaction with -gsplit-dwarf

2019-04-03 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

Ping :)


Repository:
  rC Clang

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

https://reviews.llvm.org/D59923



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


[PATCH] D59744: Fix i386 ABI "__m64" type bug

2019-04-03 Thread Wei Xiao via Phabricator via cfe-commits
wxiao3 added a comment.

Dear reviewers, any comments?


Repository:
  rC Clang

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

https://reviews.llvm.org/D59744



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


[PATCH] D59802: [clang-tidy] Add new checker: llvm-prefer-isa-or-dyn-cast-in-conditionals

2019-04-03 Thread Don Hinton via Phabricator via cfe-commits
hintonda marked an inline comment as done.
hintonda added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/llvm/AvoidCastInConditionalCheck.cpp:145
+
+diag(MatchedDecl->getBeginLoc(), "use dyn_cast_or_null")
+<< FixItHint::CreateReplacement(SourceRange(MatchedDecl->getBeginLoc(),

aaron.ballman wrote:
> hintonda wrote:
> > aaron.ballman wrote:
> > > hintonda wrote:
> > > > aaron.ballman wrote:
> > > > > This diagnostic doesn't tell the user what they've done wrong with 
> > > > > the code or why this is a better choice.
> > > > Yes, but I'm not yet sure what it should say.  Was sorta hoping for a 
> > > > suggestion.  
> > > Do you have any evidence that this situation happens in practice? I kind 
> > > of feel like this entire branch could be eliminated from this patch 
> > > unless it actually catches problems that happen.
> > Yes, here are a few from clang/lib -- let me know if you think it's worth 
> > it or not to keep this:
> > 
> > - DiagnosticName: llvm-avoid-cast-in-conditional
> >   FileOffset: 305293
> >   FilePath: 
> > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/Sema/SemaTemplate.cpp
> >   Message: method 'getAsTemplateDecl' is called twice and could be expensive
> >   Replacements:
> >   - FilePath: 
> > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/Sema/SemaTemplate.cpp
> > Length: 93
> > Offset: 305293
> > ReplacementText: 
> > dyn_cast_or_null(Name.getAsTemplateDecl())
> > - DiagnosticName: llvm-avoid-cast-in-conditional
> >   FileOffset: 153442
> >   FilePath: 
> > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/AST/ASTContext.cpp
> >   Message: method 'getAsTemplateDecl' is called twice and could be expensive
> >   Replacements:
> >   - FilePath: 
> > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/AST/ASTContext.cpp
> > Length: 92
> > Offset: 153442
> > ReplacementText: 
> > dyn_cast_or_null(Template.getAsTemplateDecl())
> > - DiagnosticName: llvm-avoid-cast-in-conditional
> >   FileOffset: 97556
> >   FilePath: 
> > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/AST/Expr.cpp
> >   Message: method 'getMethodDecl' is called twice and could be expensive
> >   Replacements:
> >   - FilePath: 
> > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/AST/Expr.cpp
> > Length: 68
> > Offset: 97556
> > ReplacementText: 
> > dyn_cast_or_null(MCE->getMethodDecl())
> > - DiagnosticName: llvm-avoid-cast-in-conditional
> >   FileOffset: 301950
> >   FilePath: 
> > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/Sema/SemaInit.cpp
> >   Message: method 'get' is called twice and could be expensive
> >   Replacements:
> >   - FilePath: 
> > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/Sema/SemaInit.cpp
> > Length: 49
> > Offset: 301950
> > ReplacementText: dyn_cast_or_null(CurInit.get())
> > - DiagnosticName: llvm-avoid-cast-in-conditional
> >   FileOffset: 14335
> >   FilePath: 
> > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/Sema/AnalysisBasedWarnings.cpp
> >   Message: method 'operator bool' is called twice and could be expensive
> >   Replacements:
> >   - FilePath: 
> > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/Sema/AnalysisBasedWarnings.cpp
> > Length: 57
> > Offset: 14335
> > ReplacementText: dyn_cast_or_null(B->getTerminator())
> > - DiagnosticName: llvm-avoid-cast-in-conditional
> >   FileOffset: 15997
> >   FilePath: 
> > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/Sema/AnalysisBasedWarnings.cpp
> >   Message: method 'operator bool' is called twice and could be expensive
> >   Replacements:
> >   - FilePath: 
> > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/Sema/AnalysisBasedWarnings.cpp
> > Length: 55
> > Offset: 15997
> > ReplacementText: dyn_cast_or_null(B.getTerminator())
> > - DiagnosticName: llvm-avoid-cast-in-conditional
> >   FileOffset: 9492
> >   FilePath: 
> > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h
> >   Message: method 'sexpr' is called twice and could be expensive
> >   Replacements:
> >   - FilePath: 
> > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h
> > Length: 39
> > Offset: 9492
> > ReplacementText: dyn_cast_or_null(sexpr())
> > - DiagnosticName: llvm-avoid-cast-in-conditional
> >   FileOffset: 9572
> >   FilePath: 
> > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h
> >   Message: method 'sexpr' is called twice and could be expensive
> >   Replacements:
> >   - FilePath: 
> > 

[PATCH] D59802: [clang-tidy] Add new checker: llvm-prefer-isa-or-dyn-cast-in-conditionals

2019-04-03 Thread Don Hinton via Phabricator via cfe-commits
hintonda marked an inline comment as done.
hintonda added inline comments.



Comment at: clang-tools-extra/clang-tidy/llvm/AvoidCastInConditionalCheck.cpp:18
+
+AST_MATCHER(Expr, isMacroID) { return Node.getExprLoc().isMacroID(); }
+} // namespace ast_matchers

aaron.ballman wrote:
> hintonda wrote:
> > @aaron.ballman:  This matcher seems genuinely useful.  What do you think 
> > about moving it to ASTMatchers.h? 
> I think that adding something like this might be a good idea. We don't have 
> any notion of source locations in the AST matching syntax currently, and I'm 
> not certain whether that's a good thing or not here. I'm mildly uncomfortable 
> that this matcher operates on an `Expr` but then internally uses a source 
> location from that expression and I wonder if we would rather introduce 
> source location matching. For instance, what if the user cares about the 
> difference between `getExprLoc()` and `getBeginLoc()` for some reason?
Well, you can attach it to whatever you want, so I'm not sure that's a problem. 
 Alternatively, you have to check each location yourself.  In my case, that was 
multiple places, so putting it in the matcher cleaned up the code.

I need to verify it, but it seems that it triggered when any macros were in the 
range, but I need to look closer into that to understand the behavior.   I'll 
check it out and get back to you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59802



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


[PATCH] D60235: [CMake] Disable libc++ and libc++abi new/delete definitions when built with ASan

2019-04-03 Thread Roland McGrath via Phabricator via cfe-commits
mcgrathr accepted this revision.
mcgrathr added a comment.
This revision is now accepted and ready to land.

IMHO the library code should use `#if !__has_feature(...)` to avoid the 
definitions entirely when built with a sanitizer whose runtime provides them.
But this is a fine way to achieve that while we wait for those libraries to be 
fixed for sanitized builds.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60235



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


r357643 - add periods

2019-04-03 Thread Amy Huang via cfe-commits
Author: akhuang
Date: Wed Apr  3 15:19:07 2019
New Revision: 357643

URL: http://llvm.org/viewvc/llvm-project?rev=357643=rev
Log:
add periods

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

Modified: cfe/trunk/lib/CodeGen/CGAtomic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGAtomic.cpp?rev=357643=357642=357643=diff
==
--- cfe/trunk/lib/CodeGen/CGAtomic.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGAtomic.cpp Wed Apr  3 15:19:07 2019
@@ -1688,7 +1688,7 @@ EmitAtomicUpdateValue(CodeGenFunction 
 UpRVal = OldRVal;
 DesiredLVal = CGF.MakeAddrLValue(DesiredAddr, AtomicLVal.getType());
   } else {
-// Build new lvalue for temp address
+// Build new lvalue for temp address.
 Address Ptr = Atomics.materializeRValue(OldRVal);
 LValue UpdateLVal;
 if (AtomicLVal.isBitField()) {
@@ -1721,7 +1721,7 @@ EmitAtomicUpdateValue(CodeGenFunction 
 }
 UpRVal = CGF.EmitLoadOfLValue(UpdateLVal, SourceLocation());
   }
-  // Store new value in the corresponding memory area
+  // Store new value in the corresponding memory area.
   RValue NewRVal = UpdateOp(UpRVal);
   if (NewRVal.isScalar()) {
 CGF.EmitStoreThroughLValue(NewRVal, DesiredLVal);
@@ -1786,7 +1786,7 @@ void AtomicInfo::EmitAtomicUpdateOp(
SourceLocation(), 
/*AsValue=*/false);
   EmitAtomicUpdateValue(CGF, *this, OldRVal, UpdateOp, NewAtomicAddr);
   auto *DesiredVal = CGF.Builder.CreateLoad(NewAtomicIntAddr);
-  // Try to write new value using cmpxchg operation
+  // Try to write new value using cmpxchg operation.
   auto Res = EmitAtomicCompareExchangeOp(PHI, DesiredVal, AO, Failure);
   PHI->addIncoming(Res.first, CGF.Builder.GetInsertBlock());
   CGF.Builder.CreateCondBr(Res.second, ExitBB, ContBB);
@@ -1797,7 +1797,7 @@ static void EmitAtomicUpdateValue(CodeGe
   RValue UpdateRVal, Address DesiredAddr) {
   LValue AtomicLVal = Atomics.getAtomicLValue();
   LValue DesiredLVal;
-  // Build new lvalue for temp address
+  // Build new lvalue for temp address.
   if (AtomicLVal.isBitField()) {
 DesiredLVal =
 LValue::MakeBitfield(DesiredAddr, AtomicLVal.getBitFieldInfo(),
@@ -1814,7 +1814,7 @@ static void EmitAtomicUpdateValue(CodeGe
 DesiredAddr, AtomicLVal.getExtVectorElts(), AtomicLVal.getType(),
 AtomicLVal.getBaseInfo(), AtomicLVal.getTBAAInfo());
   }
-  // Store new value in the corresponding memory area
+  // Store new value in the corresponding memory area.
   assert(UpdateRVal.isScalar());
   CGF.EmitStoreThroughLValue(UpdateRVal, DesiredLVal);
 }
@@ -1866,7 +1866,7 @@ void AtomicInfo::EmitAtomicUpdateOp(llvm
   }
   EmitAtomicUpdateValue(CGF, *this, UpdateRVal, NewAtomicAddr);
   auto *DesiredVal = CGF.Builder.CreateLoad(NewAtomicIntAddr);
-  // Try to write new value using cmpxchg operation
+  // Try to write new value using cmpxchg operation.
   auto Res = EmitAtomicCompareExchangeOp(PHI, DesiredVal, AO, Failure);
   PHI->addIncoming(Res.first, CGF.Builder.GetInsertBlock());
   CGF.Builder.CreateCondBr(Res.second, ExitBB, ContBB);


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


[PATCH] D60238: Verify that Android targets generate DWARF 4 by default.

2019-04-03 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added inline comments.



Comment at: clang/test/Driver/debug-options.c:280
 // G_STANDALONE: "-debug-info-kind=standalone"
+// G_DWARF2: "-dwarf-version=2"
 // G_DWARF4: "-dwarf-version=4"

What's that for?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60238



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


[PATCH] D60238: Verify that Android targets generate DWARF 4 by default.

2019-04-03 Thread Stephen Hines via Phabricator via cfe-commits
srhines marked an inline comment as done.
srhines added inline comments.



Comment at: clang/test/Driver/debug-options.c:280
 // G_STANDALONE: "-debug-info-kind=standalone"
+// G_DWARF2: "-dwarf-version=2"
 // G_DWARF4: "-dwarf-version=4"

aprantl wrote:
> What's that for?
Look at Line 30. You added references to it from a while ago, but it didn't 
exist.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60238



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


[PATCH] D60201: Make clangd-fuzzer use the normal add_llvm_fuzzer() machinery

2019-04-03 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE357654: Make clangd-fuzzer use the normal 
add_llvm_fuzzer() machinery (authored by nico, committed by ).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D60201?vs=193492=193630#toc

Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D60201

Files:
  clangd/CMakeLists.txt
  clangd/fuzzer/CMakeLists.txt
  clangd/fuzzer/ClangdFuzzer.cpp
  clangd/fuzzer/DummyClangdMain.cpp
  clangd/fuzzer/clangd-fuzzer.cpp

Index: clangd/CMakeLists.txt
===
--- clangd/CMakeLists.txt
+++ clangd/CMakeLists.txt
@@ -116,7 +116,8 @@
   )
 
 add_subdirectory(refactor/tweaks)
-if( LLVM_LIB_FUZZING_ENGINE OR LLVM_USE_SANITIZE_COVERAGE )
+if (LINUX)
+  # FIXME: Make fuzzer not use linux-specific APIs, build it everywhere.
   add_subdirectory(fuzzer)
 endif()
 add_subdirectory(tool)
Index: clangd/fuzzer/CMakeLists.txt
===
--- clangd/fuzzer/CMakeLists.txt
+++ clangd/fuzzer/CMakeLists.txt
@@ -2,13 +2,10 @@
 
 set(LLVM_LINK_COMPONENTS support)
 
-if(LLVM_USE_SANITIZE_COVERAGE)
-  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=fuzzer")
-endif()
-
-add_clang_executable(clangd-fuzzer
-  EXCLUDE_FROM_ALL
-  ClangdFuzzer.cpp
+# This fuzzer runs on oss-fuzz, so keep it around even if it looks unreferenced.
+add_llvm_fuzzer(clangd-fuzzer
+  clangd-fuzzer.cpp
+  DUMMY_MAIN DummyClangdMain.cpp
   )
 
 target_link_libraries(clangd-fuzzer
@@ -20,5 +17,4 @@
   clangSema
   clangTooling
   clangToolingCore
-  ${LLVM_LIB_FUZZING_ENGINE}
   )
Index: clangd/fuzzer/clangd-fuzzer.cpp
===
--- clangd/fuzzer/clangd-fuzzer.cpp
+++ clangd/fuzzer/clangd-fuzzer.cpp
@@ -0,0 +1,42 @@
+//===-- ClangdFuzzer.cpp - Fuzz clangd ===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+///
+/// \file
+/// \brief This file implements a function that runs clangd on a single input.
+/// This function is then linked into the Fuzzer library.
+///
+//===--===//
+
+#include "ClangdLSPServer.h"
+#include "ClangdServer.h"
+#include "CodeComplete.h"
+#include "FSProvider.h"
+#include 
+#include 
+
+using namespace clang::clangd;
+
+extern "C" int LLVMFuzzerTestOneInput(uint8_t *data, size_t size) {
+  if (size == 0)
+return 0;
+
+  // fmemopen isn't portable, but I think we only run the fuzzer on Linux.
+  std::FILE *In = fmemopen(data, size, "r");
+  auto Transport = newJSONTransport(In, llvm::nulls(),
+/*InMirror=*/nullptr, /*Pretty=*/false,
+/*Style=*/JSONStreamStyle::Delimited);
+  RealFileSystemProvider FS;
+  CodeCompleteOptions CCOpts;
+  CCOpts.EnableSnippets = false;
+  ClangdServer::Options Opts;
+
+  // Initialize and run ClangdLSPServer.
+  ClangdLSPServer LSPServer(*Transport, FS, CCOpts, llvm::None, false, Opts);
+  LSPServer.run();
+  return 0;
+}
Index: clangd/fuzzer/DummyClangdMain.cpp
===
--- clangd/fuzzer/DummyClangdMain.cpp
+++ clangd/fuzzer/DummyClangdMain.cpp
@@ -0,0 +1,18 @@
+//=== DummyClangdMain.cpp - Entry point to sanity check the fuzzer ===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// Implementation of main so we can build and test without linking libFuzzer.
+//
+//===--===//
+
+#include "llvm/FuzzMutate/FuzzerCLI.h"
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size);
+int main(int argc, char *argv[]) {
+  return llvm::runFuzzerOnInputs(argc, argv, LLVMFuzzerTestOneInput);
+}
Index: clangd/fuzzer/ClangdFuzzer.cpp
===
--- clangd/fuzzer/ClangdFuzzer.cpp
+++ clangd/fuzzer/ClangdFuzzer.cpp
@@ -1,42 +0,0 @@
-//===-- ClangdFuzzer.cpp - Fuzz clangd ===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//

[PATCH] D60120: check-clang-tools: Actually build and run XPC test

2019-04-03 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

ping?


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

https://reviews.llvm.org/D60120



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


[PATCH] D60237: [MS] Add metadata for __declspec(allocator)

2019-04-03 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: clang/lib/CodeGen/CGAtomic.cpp:1691
   } else {
-// Build new lvalue for temp address
+// Build new lvalue for temp address.
 Address Ptr = Atomics.materializeRValue(OldRVal);

I don't have an issue with these changes if you want to make them, but they 
should be committed separately.



Comment at: clang/lib/CodeGen/CGCall.cpp:4384-4385
+if (TargetDecl && TargetDecl->hasAttr())
+  CI->setMetadata("heapallocsite", getDebugInfo()->
+   getMSAllocatorMetadata(RetTy, Loc));
+  }

I think we should make CGDebugInfo responsible for calling setMetadata. In some 
sense, "heapallocsite" metadata is debug info, so it makes sense that it would 
be documented there. Also, if there are other places where we need to add this 
metadata, we won't have to duplicate this string literal.

So, CGDebugInfo should have some new method 
`addHeapAllocSiteMetadata(Instruction *CallSite, QualType Ty)`, and that can 
call the private getOrCreateType method. Sound good?



Comment at: clang/test/CodeGen/debug-info-codeview-heapallocsite.c:13
+
+// CHECK: !heapallocsite [[DBG_F1:!.*]]
+// CHECK: [[DBG_F1:!.*]] = !{}

We should expect this test case to grow, so it would be good to add more 
context around here. Something like:
  CHECK-LABEL: define{{.*}} @call_alloc
  CHECK: call i8* @myalloc(i64 1) {{.*}} !heapallocsite ...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60237



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


[PATCH] D60018: [codeview] Remove Type member from CVRecord

2019-04-03 Thread Reid Kleckner via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLD357658: [codeview] Remove Type member from CVRecord 
(authored by rnk, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D60018?vs=193526=193633#toc

Repository:
  rLLD LLVM Linker

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

https://reviews.llvm.org/D60018

Files:
  COFF/PDB.cpp


Index: COFF/PDB.cpp
===
--- COFF/PDB.cpp
+++ COFF/PDB.cpp
@@ -759,7 +759,7 @@
   if (Kind == SymbolKind::S_GPROC32_ID || Kind == SymbolKind::S_LPROC32_ID) {
 SmallVector Refs;
 auto Content = RecordData.drop_front(sizeof(RecordPrefix));
-CVSymbol Sym(Kind, RecordData);
+CVSymbol Sym(RecordData);
 discoverTypeIndicesInSymbol(Sym, Refs);
 assert(Refs.size() == 1);
 assert(Refs.front().Count == 1);
@@ -959,7 +959,7 @@
 MutableArrayRef RecordBytes;
 if (NeedsRealignment) {
   RecordBytes = copyAndAlignSymbol(Sym, AlignedSymbolMem);
-  Sym = CVSymbol(Sym.kind(), RecordBytes);
+  Sym = CVSymbol(RecordBytes);
 } else {
   // Otherwise, we can actually mutate the symbol directly, since we
   // copied it to apply relocations.
@@ -983,7 +983,7 @@
 // An object file may have S_xxx_ID symbols, but these get converted to
 // "real" symbols in a PDB.
 translateIdSymbols(RecordBytes, TMerger.getIDTable());
-Sym = CVSymbol(symbolKind(RecordBytes), RecordBytes);
+Sym = CVSymbol(RecordBytes);
 
 // If this record refers to an offset in the object file's string 
table,
 // add that item to the global PDB string table and re-write the index.


Index: COFF/PDB.cpp
===
--- COFF/PDB.cpp
+++ COFF/PDB.cpp
@@ -759,7 +759,7 @@
   if (Kind == SymbolKind::S_GPROC32_ID || Kind == SymbolKind::S_LPROC32_ID) {
 SmallVector Refs;
 auto Content = RecordData.drop_front(sizeof(RecordPrefix));
-CVSymbol Sym(Kind, RecordData);
+CVSymbol Sym(RecordData);
 discoverTypeIndicesInSymbol(Sym, Refs);
 assert(Refs.size() == 1);
 assert(Refs.front().Count == 1);
@@ -959,7 +959,7 @@
 MutableArrayRef RecordBytes;
 if (NeedsRealignment) {
   RecordBytes = copyAndAlignSymbol(Sym, AlignedSymbolMem);
-  Sym = CVSymbol(Sym.kind(), RecordBytes);
+  Sym = CVSymbol(RecordBytes);
 } else {
   // Otherwise, we can actually mutate the symbol directly, since we
   // copied it to apply relocations.
@@ -983,7 +983,7 @@
 // An object file may have S_xxx_ID symbols, but these get converted to
 // "real" symbols in a PDB.
 translateIdSymbols(RecordBytes, TMerger.getIDTable());
-Sym = CVSymbol(symbolKind(RecordBytes), RecordBytes);
+Sym = CVSymbol(RecordBytes);
 
 // If this record refers to an offset in the object file's string table,
 // add that item to the global PDB string table and re-write the index.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r357667 - Revert r357452 - 'SimplifyCFG SinkCommonCodeFromPredecessors: Also sink function calls without used results (PR41259)'

2019-04-03 Thread David L. Jones via cfe-commits
Author: dlj
Date: Wed Apr  3 19:27:57 2019
New Revision: 357667

URL: http://llvm.org/viewvc/llvm-project?rev=357667=rev
Log:
Revert r357452 - 'SimplifyCFG SinkCommonCodeFromPredecessors: Also sink 
function calls without used results (PR41259)'

This revision causes tests to fail under ASAN. Since the cause of the failures
is not clear (could be ASAN, could be a Clang bug, could be a bug in this
revision), the safest course of action seems to be to revert while 
investigating.


Modified:
cfe/trunk/test/CodeGenCXX/nrvo.cpp
cfe/trunk/test/CodeGenCXX/stack-reuse-exceptions.cpp
cfe/trunk/test/CodeGenObjC/exceptions.m

Modified: cfe/trunk/test/CodeGenCXX/nrvo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/nrvo.cpp?rev=357667=357666=357667=diff
==
--- cfe/trunk/test/CodeGenCXX/nrvo.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/nrvo.cpp Wed Apr  3 19:27:57 2019
@@ -60,6 +60,7 @@ X test2(bool B) {
   // CHECK-NEXT: call void @llvm.lifetime.start
   // CHECK-NEXT: call {{.*}} @_ZN1XC1Ev
   // CHECK: call {{.*}} @_ZN1XC1ERKS_
+  // CHECK: call {{.*}} @_ZN1XC1ERKS_
   // CHECK: call {{.*}} @_ZN1XD1Ev
   // CHECK-NEXT: call void @llvm.lifetime.end
   // CHECK: call {{.*}} @_ZN1XD1Ev

Modified: cfe/trunk/test/CodeGenCXX/stack-reuse-exceptions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/stack-reuse-exceptions.cpp?rev=357667=357666=357667=diff
==
--- cfe/trunk/test/CodeGenCXX/stack-reuse-exceptions.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/stack-reuse-exceptions.cpp Wed Apr  3 19:27:57 
2019
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu %s -o - -emit-llvm -O1 \
-// RUN: -fexceptions -fcxx-exceptions -mllvm 
-simplifycfg-sink-common=false | FileCheck %s
+// RUN: -fexceptions -fcxx-exceptions | FileCheck %s
 //
 // We should emit lifetime.ends for these temporaries in both the 'exception'
 // and 'normal' paths in functions.

Modified: cfe/trunk/test/CodeGenObjC/exceptions.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/exceptions.m?rev=357667=357666=357667=diff
==
--- cfe/trunk/test/CodeGenObjC/exceptions.m (original)
+++ cfe/trunk/test/CodeGenObjC/exceptions.m Wed Apr  3 19:27:57 2019
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 
-fobjc-runtime=macosx-fragile-10.5 -emit-llvm -fobjc-exceptions -mllvm 
-simplifycfg-sink-common=false -O2 -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 
-fobjc-runtime=macosx-fragile-10.5 -emit-llvm -fobjc-exceptions -O2 -o - %s | 
FileCheck %s
 //
 //  [irgen] [eh] Exception code built with clang 
(x86_64) crashes
 


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


[PATCH] D59802: [clang-tidy] Add new checker: llvm-prefer-isa-or-dyn-cast-in-conditionals

2019-04-03 Thread Don Hinton via Phabricator via cfe-commits
hintonda marked an inline comment as done.
hintonda added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/llvm/AvoidCastInConditionalCheck.cpp:145
+
+diag(MatchedDecl->getBeginLoc(), "use dyn_cast_or_null")
+<< FixItHint::CreateReplacement(SourceRange(MatchedDecl->getBeginLoc(),

hintonda wrote:
> aaron.ballman wrote:
> > hintonda wrote:
> > > aaron.ballman wrote:
> > > > hintonda wrote:
> > > > > aaron.ballman wrote:
> > > > > > This diagnostic doesn't tell the user what they've done wrong with 
> > > > > > the code or why this is a better choice.
> > > > > Yes, but I'm not yet sure what it should say.  Was sorta hoping for a 
> > > > > suggestion.  
> > > > Do you have any evidence that this situation happens in practice? I 
> > > > kind of feel like this entire branch could be eliminated from this 
> > > > patch unless it actually catches problems that happen.
> > > Yes, here are a few from clang/lib -- let me know if you think it's worth 
> > > it or not to keep this:
> > > 
> > > - DiagnosticName: llvm-avoid-cast-in-conditional
> > >   FileOffset: 305293
> > >   FilePath: 
> > > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/Sema/SemaTemplate.cpp
> > >   Message: method 'getAsTemplateDecl' is called twice and could be 
> > > expensive
> > >   Replacements:
> > >   - FilePath: 
> > > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/Sema/SemaTemplate.cpp
> > > Length: 93
> > > Offset: 305293
> > > ReplacementText: 
> > > dyn_cast_or_null(Name.getAsTemplateDecl())
> > > - DiagnosticName: llvm-avoid-cast-in-conditional
> > >   FileOffset: 153442
> > >   FilePath: 
> > > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/AST/ASTContext.cpp
> > >   Message: method 'getAsTemplateDecl' is called twice and could be 
> > > expensive
> > >   Replacements:
> > >   - FilePath: 
> > > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/AST/ASTContext.cpp
> > > Length: 92
> > > Offset: 153442
> > > ReplacementText: 
> > > dyn_cast_or_null(Template.getAsTemplateDecl())
> > > - DiagnosticName: llvm-avoid-cast-in-conditional
> > >   FileOffset: 97556
> > >   FilePath: 
> > > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/AST/Expr.cpp
> > >   Message: method 'getMethodDecl' is called twice and could be expensive
> > >   Replacements:
> > >   - FilePath: 
> > > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/AST/Expr.cpp
> > > Length: 68
> > > Offset: 97556
> > > ReplacementText: 
> > > dyn_cast_or_null(MCE->getMethodDecl())
> > > - DiagnosticName: llvm-avoid-cast-in-conditional
> > >   FileOffset: 301950
> > >   FilePath: 
> > > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/Sema/SemaInit.cpp
> > >   Message: method 'get' is called twice and could be expensive
> > >   Replacements:
> > >   - FilePath: 
> > > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/Sema/SemaInit.cpp
> > > Length: 49
> > > Offset: 301950
> > > ReplacementText: dyn_cast_or_null(CurInit.get())
> > > - DiagnosticName: llvm-avoid-cast-in-conditional
> > >   FileOffset: 14335
> > >   FilePath: 
> > > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/Sema/AnalysisBasedWarnings.cpp
> > >   Message: method 'operator bool' is called twice and could be expensive
> > >   Replacements:
> > >   - FilePath: 
> > > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/Sema/AnalysisBasedWarnings.cpp
> > > Length: 57
> > > Offset: 14335
> > > ReplacementText: dyn_cast_or_null(B->getTerminator())
> > > - DiagnosticName: llvm-avoid-cast-in-conditional
> > >   FileOffset: 15997
> > >   FilePath: 
> > > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/Sema/AnalysisBasedWarnings.cpp
> > >   Message: method 'operator bool' is called twice and could be expensive
> > >   Replacements:
> > >   - FilePath: 
> > > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/Sema/AnalysisBasedWarnings.cpp
> > > Length: 55
> > > Offset: 15997
> > > ReplacementText: dyn_cast_or_null(B.getTerminator())
> > > - DiagnosticName: llvm-avoid-cast-in-conditional
> > >   FileOffset: 9492
> > >   FilePath: 
> > > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h
> > >   Message: method 'sexpr' is called twice and could be expensive
> > >   Replacements:
> > >   - FilePath: 
> > > /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h
> > > Length: 39
> > > Offset: 9492
> > > ReplacementText: dyn_cast_or_null(sexpr())
> > > - DiagnosticName: llvm-avoid-cast-in-conditional
> > >   FileOffset: 9572
> > >   FilePath: 
> > > 

[PATCH] D60238: Verify that Android targets generate DWARF 4 by default.

2019-04-03 Thread Stephen Hines via Phabricator via cfe-commits
srhines created this revision.
srhines added a reviewer: aprantl.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
srhines added subscribers: pirama, chh.

In the future, Android releases will support DWARF 5, but we need to
ensure that older targets only have DWARF 4 generated for them. This
patch inserts that verification for all Android releases now. The patch
also fixes 2 minor mistakes (a mistakenly moved RUN line, and the
missing G_DWARF2 check label).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D60238

Files:
  clang/test/Driver/debug-options.c


Index: clang/test/Driver/debug-options.c
===
--- clang/test/Driver/debug-options.c
+++ clang/test/Driver/debug-options.c
@@ -17,9 +17,14 @@
 // RUN: %clang -### -c -glldb %s -target x86_64-linux-gnu 2>&1 \
 // RUN: | FileCheck -check-prefix=G -check-prefix=G_LLDB %s
 // RUN: %clang -### -c -gsce %s -target x86_64-linux-gnu 2>&1 \
+// RUN: | FileCheck -check-prefix=G -check-prefix=G_SCE %s
+
+// Android.
+// Android should always generate DWARF4.
+// RUN: %clang -### -c -g %s -target arm-linux-androideabi 2>&1 \
+// RUN: | FileCheck -check-prefix=G -check-prefix=G_DWARF4 %s
 
 // Darwin.
-// RUN: | FileCheck -check-prefix=G -check-prefix=G_SCE %s
 // RUN: %clang -### -c -g %s -target x86_64-apple-darwin 2>&1 \
 // RUN: | FileCheck -check-prefix=G_STANDALONE \
 // RUN: -check-prefix=G_DWARF2 \
@@ -272,6 +277,7 @@
 //
 // G_STANDALONE: "-cc1"
 // G_STANDALONE: "-debug-info-kind=standalone"
+// G_DWARF2: "-dwarf-version=2"
 // G_DWARF4: "-dwarf-version=4"
 //
 // G_GDB:  "-debugger-tuning=gdb"


Index: clang/test/Driver/debug-options.c
===
--- clang/test/Driver/debug-options.c
+++ clang/test/Driver/debug-options.c
@@ -17,9 +17,14 @@
 // RUN: %clang -### -c -glldb %s -target x86_64-linux-gnu 2>&1 \
 // RUN: | FileCheck -check-prefix=G -check-prefix=G_LLDB %s
 // RUN: %clang -### -c -gsce %s -target x86_64-linux-gnu 2>&1 \
+// RUN: | FileCheck -check-prefix=G -check-prefix=G_SCE %s
+
+// Android.
+// Android should always generate DWARF4.
+// RUN: %clang -### -c -g %s -target arm-linux-androideabi 2>&1 \
+// RUN: | FileCheck -check-prefix=G -check-prefix=G_DWARF4 %s
 
 // Darwin.
-// RUN: | FileCheck -check-prefix=G -check-prefix=G_SCE %s
 // RUN: %clang -### -c -g %s -target x86_64-apple-darwin 2>&1 \
 // RUN: | FileCheck -check-prefix=G_STANDALONE \
 // RUN: -check-prefix=G_DWARF2 \
@@ -272,6 +277,7 @@
 //
 // G_STANDALONE: "-cc1"
 // G_STANDALONE: "-debug-info-kind=standalone"
+// G_DWARF2: "-dwarf-version=2"
 // G_DWARF4: "-dwarf-version=4"
 //
 // G_GDB:  "-debugger-tuning=gdb"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D60238: Verify that Android targets generate DWARF 4 by default.

2019-04-03 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl accepted this revision.
aprantl added a comment.
This revision is now accepted and ready to land.

Good catch!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60238



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


[libunwind] r357671 - [libunwind] Export the weak alias in Mach-O

2019-04-03 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Wed Apr  3 20:36:35 2019
New Revision: 357671

URL: http://llvm.org/viewvc/llvm-project?rev=357671=rev
Log:
[libunwind] Export the weak alias in Mach-O

This is not necessary for ELF since .globl and .weak are mutually
exclusive, but is necessary for Mach-O otherwise the symbol isn't
visible externally.

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

Modified:
libunwind/trunk/src/assembly.h

Modified: libunwind/trunk/src/assembly.h
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/assembly.h?rev=357671=357670=357671=diff
==
--- libunwind/trunk/src/assembly.h (original)
+++ libunwind/trunk/src/assembly.h Wed Apr  3 20:36:35 2019
@@ -47,6 +47,7 @@
 #define HIDDEN_SYMBOL(name) .private_extern name
 #define WEAK_SYMBOL(name) .weak_reference name
 #define WEAK_ALIAS(name, aliasname)
\
+  .globl SYMBOL_NAME(aliasname) SEPARATOR  
\
   WEAK_SYMBOL(aliasname) SEPARATOR 
\
   SYMBOL_NAME(aliasname) = SYMBOL_NAME(name)
 


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


[PATCH] D60236: add periods

2019-04-03 Thread Amy Huang via Phabricator via cfe-commits
akhuang created this revision.
Herald added subscribers: cfe-commits, jfb.
Herald added a project: clang.

emit metadata for __declspec(allocator)

add tests for heapallocsite metadata


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D60236

Files:
  clang/lib/CodeGen/CGAtomic.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/test/CodeGen/debug-info-codeview-heapallocsite.c

Index: clang/test/CodeGen/debug-info-codeview-heapallocsite.c
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-codeview-heapallocsite.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -debug-info-kind=limited -gcodeview -fdeclspec -S -emit-llvm < %s | FileCheck %s
+
+char buf[1024];
+__declspec(allocator) void *myalloc(int s) {
+  void *p = [0];
+  return p;
+}
+
+void call_alloc() {
+  char *p = (char*)myalloc(sizeof(char));
+}
+
+// CHECK: !heapallocsite [[DBG_F1:!.*]]
+// CHECK: [[DBG_F1:!.*]] = !{}
Index: clang/lib/CodeGen/CGDebugInfo.h
===
--- clang/lib/CodeGen/CGDebugInfo.h
+++ clang/lib/CodeGen/CGDebugInfo.h
@@ -476,6 +476,9 @@
   /// Emit standalone debug info for a type.
   llvm::DIType *getOrCreateStandaloneType(QualType Ty, SourceLocation Loc);
 
+  /// Get debug info for MSAllocator metadata.
+  llvm::MDNode *getMSAllocatorMetadata(QualType Ty, SourceLocation Loc);
+
   void completeType(const EnumDecl *ED);
   void completeType(const RecordDecl *RD);
   void completeRequiredType(const RecordDecl *RD);
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1959,6 +1959,20 @@
   return T;
 }
 
+llvm::MDNode *CGDebugInfo::getMSAllocatorMetadata(QualType D,
+  SourceLocation Loc) {
+  // FIXME: return the type that return value is cast to
+  llvm::MDNode *node;
+  if (D.getTypePtr()->isVoidPointerType()) {
+node = llvm::MDNode::get(CGM.getLLVMContext(), None);
+  } else {
+QualType PointeeTy = D.getTypePtr()->getPointeeType();
+node = getOrCreateType(PointeeTy, getOrCreateFile(Loc));
+  }
+  return node;
+}
+
+
 void CGDebugInfo::completeType(const EnumDecl *ED) {
   if (DebugKind <= codegenoptions::DebugLineTablesOnly)
 return;
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -3800,6 +3800,8 @@
 
   llvm::FunctionType *IRFuncTy = getTypes().GetFunctionType(CallInfo);
 
+  const Decl *TargetDecl = Callee.getAbstractInfo().getCalleeDecl().getDecl();
+
 #ifndef NDEBUG
   if (!(CallInfo.isVariadic() && CallInfo.getArgStruct())) {
 // For an inalloca varargs function, we don't expect CallInfo to match the
@@ -4288,11 +4290,7 @@
   // Apply always_inline to all calls within flatten functions.
   // FIXME: should this really take priority over __try, below?
   if (CurCodeDecl && CurCodeDecl->hasAttr() &&
-  !(Callee.getAbstractInfo().getCalleeDecl().getDecl() &&
-Callee.getAbstractInfo()
-.getCalleeDecl()
-.getDecl()
-->hasAttr())) {
+  !(TargetDecl && TargetDecl->hasAttr())) {
 Attrs =
 Attrs.addAttribute(getLLVMContext(), llvm::AttributeList::FunctionIndex,
llvm::Attribute::AlwaysInline);
@@ -4376,11 +4374,17 @@
 
   // Suppress tail calls if requested.
   if (llvm::CallInst *Call = dyn_cast(CI)) {
-const Decl *TargetDecl = Callee.getAbstractInfo().getCalleeDecl().getDecl();
 if (TargetDecl && TargetDecl->hasAttr())
   Call->setTailCallKind(llvm::CallInst::TCK_NoTail);
   }
 
+  // Add metadata for calls to MSAllocator functions
+  if (!DisableDebugInfo) {
+if (TargetDecl && TargetDecl->hasAttr())
+  CI->setMetadata("heapallocsite", getDebugInfo()->
+   getMSAllocatorMetadata(RetTy, Loc));
+  }
+
   // 4. Finish the call.
 
   // If the call doesn't return, finish the basic block and clear the
@@ -4537,7 +4541,6 @@
   } ();
 
   // Emit the assume_aligned check on the return value.
-  const Decl *TargetDecl = Callee.getAbstractInfo().getCalleeDecl().getDecl();
   if (Ret.isScalar() && TargetDecl) {
 if (const auto *AA = TargetDecl->getAttr()) {
   llvm::Value *OffsetValue = nullptr;
Index: clang/lib/CodeGen/CGAtomic.cpp
===
--- clang/lib/CodeGen/CGAtomic.cpp
+++ clang/lib/CodeGen/CGAtomic.cpp
@@ -1688,7 +1688,7 @@
 UpRVal = OldRVal;
 DesiredLVal = CGF.MakeAddrLValue(DesiredAddr, AtomicLVal.getType());
   } else {
-// Build new lvalue for temp address
+// Build new lvalue for temp address.
 Address Ptr = Atomics.materializeRValue(OldRVal);
 LValue UpdateLVal;
 

[PATCH] D60247: Make SourceManager::createFileID(UnownedTag, ...) take a const llvm::MemoryBuffer*

2019-04-03 Thread Nico Weber via Phabricator via cfe-commits
thakis created this revision.
thakis added a reviewer: rnk.
Herald added subscribers: llvm-commits, arphaman.
Herald added a project: LLVM.

Requires making the llvm::MemoryBuffer* stored by SourceManager const, which in 
turn requires making the accessors for that return const llvm::MemoryBuffer*s 
and updating all call sites.

The original motivation for this was to use it and fix the TODO in 
CodeGenAction.cpp's ConvertBackendLocation() by using the UnownedTag version of 
createFileID, and since llvm::SourceMgr* hands out a const llvm::MemoryBuffer* 
this is required. I'm not sure if fixing the TODO this way actually works, but 
this seems like a good change on its own anyways.

No intended behavior change.


https://reviews.llvm.org/D60247

Files:
  clang-tools-extra/clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp
  clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp
  clang/include/clang/Basic/SourceManager.h
  clang/include/clang/Frontend/FrontendOptions.h
  clang/lib/Basic/SourceManager.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/Frontend/PrecompiledPreamble.cpp
  clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
  clang/lib/StaticAnalyzer/Core/IssueHash.cpp
  clang/tools/clang-import-test/clang-import-test.cpp
  clang/tools/libclang/CIndex.cpp
  llvm/include/llvm/Support/MemoryBuffer.h

Index: llvm/include/llvm/Support/MemoryBuffer.h
===
--- llvm/include/llvm/Support/MemoryBuffer.h
+++ llvm/include/llvm/Support/MemoryBuffer.h
@@ -264,7 +264,7 @@
 
 public:
   MemoryBufferRef() = default;
-  MemoryBufferRef(MemoryBuffer& Buffer)
+  MemoryBufferRef(const MemoryBuffer& Buffer)
   : Buffer(Buffer.getBuffer()), Identifier(Buffer.getBufferIdentifier()) {}
   MemoryBufferRef(StringRef Buffer, StringRef Identifier)
   : Buffer(Buffer), Identifier(Identifier) {}
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -4228,7 +4228,7 @@
   const SourceManager  = cxtu::getASTUnit(TU)->getSourceManager();
   FileID fid = SM.translateFile(static_cast(file));
   bool Invalid = true;
-  llvm::MemoryBuffer *buf = SM.getBuffer(fid, );
+  const llvm::MemoryBuffer *buf = SM.getBuffer(fid, );
   if (Invalid) {
 if (size)
   *size = 0;
Index: clang/tools/clang-import-test/clang-import-test.cpp
===
--- clang/tools/clang-import-test/clang-import-test.cpp
+++ clang/tools/clang-import-test/clang-import-test.cpp
@@ -102,7 +102,8 @@
 unsigned LocColumn =
 SM.getSpellingColumnNumber(Loc, /*Invalid=*/nullptr) - 1;
 FileID FID = SM.getFileID(Loc);
-llvm::MemoryBuffer *Buffer = SM.getBuffer(FID, Loc, /*Invalid=*/nullptr);
+const llvm::MemoryBuffer *Buffer =
+SM.getBuffer(FID, Loc, /*Invalid=*/nullptr);
 
 assert(LocData >= Buffer->getBufferStart() &&
LocData < Buffer->getBufferEnd());
Index: clang/lib/StaticAnalyzer/Core/IssueHash.cpp
===
--- clang/lib/StaticAnalyzer/Core/IssueHash.cpp
+++ clang/lib/StaticAnalyzer/Core/IssueHash.cpp
@@ -120,7 +120,7 @@
   return "";
 }
 
-static StringRef GetNthLineOfFile(llvm::MemoryBuffer *Buffer, int Line) {
+static StringRef GetNthLineOfFile(const llvm::MemoryBuffer *Buffer, int Line) {
   if (!Buffer)
 return "";
 
@@ -144,7 +144,7 @@
 col++;
   SourceLocation StartOfLine =
   SM.translateLineCol(SM.getFileID(L), L.getExpansionLineNumber(), col);
-  llvm::MemoryBuffer *Buffer =
+  const llvm::MemoryBuffer *Buffer =
   SM.getBuffer(SM.getFileID(StartOfLine), StartOfLine);
   if (!Buffer)
 return {};
Index: clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
@@ -1140,7 +1140,7 @@
   }
 
   bool Invalid = false;
-  llvm::MemoryBuffer *BF =
+  const llvm::MemoryBuffer *BF =
   Mgr.getSourceManager().getBuffer(SLInfo.first, SL, );
   if (Invalid)
 return;
Index: clang/lib/Frontend/PrecompiledPreamble.cpp
===
--- clang/lib/Frontend/PrecompiledPreamble.cpp
+++ clang/lib/Frontend/PrecompiledPreamble.cpp
@@ -377,7 +377,7 @@
   PrecompiledPreamble::PreambleFileHash::createForFile(File->getSize(),
ModTime);
 } else {
-  llvm::MemoryBuffer *Buffer = SourceMgr.getMemoryBufferForFile(File);
+  const llvm::MemoryBuffer *Buffer = SourceMgr.getMemoryBufferForFile(File);
   FilesInPreamble[File->getName()] =
   PrecompiledPreamble::PreambleFileHash::createForMemoryBuffer(Buffer);
 }
Index: 

[PATCH] D59987: Add support for detection of devtoolset-8

2019-04-03 Thread Tom Stellard via Phabricator via cfe-commits
tstellar added a comment.

Do you have commit access?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59987



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


[PATCH] D60151: [clang-tidy] Add using SmallSet to LLVM.h to fix bug in typedef in llvm checkers.

2019-04-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman requested changes to this revision.
aaron.ballman added inline comments.
This revision now requires changes to proceed.



Comment at: clang-tools-extra/clang-tidy/utils/HeaderFileExtensionsUtils.h:21
 
-typedef llvm::SmallSet HeaderFileExtensionsSet;
+using HeaderFileExtensionsSet = SmallSet;
 

I do not like that we're removing the namespace qualifier here. I would prefer 
to leave it as `::llvm::SmallSet<::llvm::StringRef, 5>` if there is a namespace 
clash.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60151



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


r357579 - Fixing a typo; NFC.

2019-04-03 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Wed Apr  3 06:37:56 2019
New Revision: 357579

URL: http://llvm.org/viewvc/llvm-project?rev=357579=rev
Log:
Fixing a typo; NFC.

Modified:
cfe/trunk/docs/LibASTMatchersReference.html
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h

Modified: cfe/trunk/docs/LibASTMatchersReference.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=357579=357578=357579=diff
==
--- cfe/trunk/docs/LibASTMatchersReference.html (original)
+++ cfe/trunk/docs/LibASTMatchersReference.html Wed Apr  3 06:37:56 2019
@@ -2773,7 +2773,7 @@ Decl has pointer identity in the AST.
 Given
   __attribute__((device)) void f() { ... }
 decl(hasAttr(clang::attr::CUDADevice)) matches the function declaration of
-f. If the matcher is use from clang-query, attr::Kind parameter should be
+f. If the matcher is used from clang-query, attr::Kind parameter should be
 passed as a quoted string. e.g., hasAttr("attr::CUDADevice").
 
 

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=357579=357578=357579=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Wed Apr  3 06:37:56 2019
@@ -6187,7 +6187,7 @@ AST_MATCHER_P(CaseStmt, hasCaseConstant,
 ///   __attribute__((device)) void f() { ... }
 /// \endcode
 /// decl(hasAttr(clang::attr::CUDADevice)) matches the function declaration of
-/// f. If the matcher is use from clang-query, attr::Kind parameter should be
+/// f. If the matcher is used from clang-query, attr::Kind parameter should be
 /// passed as a quoted string. e.g., hasAttr("attr::CUDADevice").
 AST_MATCHER_P(Decl, hasAttr, attr::Kind, AttrKind) {
   for (const auto *Attr : Node.attrs()) {


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


[PATCH] D59646: [PR40778][PR41157][OpenCL] Prevent implicit initialization of local address space objects

2019-04-03 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

LGTM.


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

https://reviews.llvm.org/D59646



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


[PATCH] D59988: [PR41276] Generate address space cast of 'this' for objects attributed by an address space in C++

2019-04-03 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

LGTM.


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

https://reviews.llvm.org/D59988



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


[PATCH] D60199: [clang-format] Do not emit replacements while regrouping if Cpp includes are OK

2019-04-03 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
krasimir added a reviewer: ioeric.

Currently clang-format would always emit a replacement for multi-block #include
sections if `IBS_Regroup`, even if the sections are correct:

  % cat ~/test.h
  #include 
  
  #include "b.h"
  % bin/clang-format --output-replacements-xml -style=google ~/test.h
  
  
  #include a.h>#include 
"b.h"
  
  %

This change makes clang-format not emit replacements in this case.
The logic is similar to the one implemented for Java in r354452.


Repository:
  rC Clang

https://reviews.llvm.org/D60199

Files:
  lib/Format/Format.cpp
  unittests/Format/SortIncludesTest.cpp

Index: unittests/Format/SortIncludesTest.cpp
===
--- unittests/Format/SortIncludesTest.cpp
+++ unittests/Format/SortIncludesTest.cpp
@@ -8,6 +8,7 @@
 
 #include "FormatTestUtils.h"
 #include "clang/Format/Format.h"
+#include "llvm/ADT/None.h"
 #include "llvm/Support/Debug.h"
 #include "gtest/gtest.h"
 
@@ -24,9 +25,13 @@
   }
 
   std::string sort(StringRef Code, std::vector Ranges,
+   llvm::Optional ExpectedNumRanges = llvm::None,
StringRef FileName = "input.cc") {
 auto Replaces = sortIncludes(FmtStyle, Code, Ranges, FileName);
 Ranges = tooling::calculateRangesAfterReplacements(Replaces, Ranges);
+if (ExpectedNumRanges) {
+  EXPECT_EQ(*ExpectedNumRanges, Replaces.size());
+}
 auto Sorted = applyAllReplacements(Code, Replaces);
 EXPECT_TRUE(static_cast(Sorted));
 auto Result = applyAllReplacements(
@@ -35,8 +40,10 @@
 return *Result;
   }
 
-  std::string sort(StringRef Code, StringRef FileName = "input.cpp") {
-return sort(Code, GetCodeRange(Code), FileName);
+  std::string sort(StringRef Code,
+   llvm::Optional ExpectedNumRanges = llvm::None,
+   StringRef FileName = "input.cpp") {
+return sort(Code, GetCodeRange(Code), ExpectedNumRanges, FileName);
   }
 
   unsigned newCursor(llvm::StringRef Code, unsigned Cursor) {
@@ -321,6 +328,7 @@
 sort("#include \"llvm/a.h\"\n"
  "#include \"c.h\"\n"
  "#include \"b.h\"\n",
+ 1,
  "a.cc"));
   EXPECT_EQ("#include \"llvm/a.h\"\n"
 "#include \"b.h\"\n"
@@ -328,6 +336,7 @@
 sort("#include \"llvm/a.h\"\n"
  "#include \"c.h\"\n"
  "#include \"b.h\"\n",
+ 1,
  "a_test.cc"));
   EXPECT_EQ("#include \"llvm/input.h\"\n"
 "#include \"b.h\"\n"
@@ -335,6 +344,7 @@
 sort("#include \"llvm/input.h\"\n"
  "#include \"c.h\"\n"
  "#include \"b.h\"\n",
+ 1,
  "input.mm"));
 
   // Don't allow prefixes.
@@ -344,6 +354,7 @@
 sort("#include \"llvm/not_a.h\"\n"
  "#include \"c.h\"\n"
  "#include \"b.h\"\n",
+ 1,
  "a.cc"));
 
   // Don't do this for _main and other suffixes.
@@ -353,6 +364,7 @@
 sort("#include \"llvm/a.h\"\n"
  "#include \"c.h\"\n"
  "#include \"b.h\"\n",
+ 1,
  "a_main.cc"));
 
   // Don't do this in headers.
@@ -362,6 +374,7 @@
 sort("#include \"llvm/a.h\"\n"
  "#include \"c.h\"\n"
  "#include \"b.h\"\n",
+ 1,
  "a.h"));
 
   // Only do this in the first #include block.
@@ -375,6 +388,7 @@
  "#include \"llvm/a.h\"\n"
  "#include \"c.h\"\n"
  "#include \"b.h\"\n",
+ 1,
  "a.cc"));
 
   // Only recognize the first #include with a matching basename as main include.
@@ -386,6 +400,7 @@
  "#include \"a.h\"\n"
  "#include \"c.h\"\n"
  "#include \"llvm/a.h\"\n",
+ 1,
  "a.cc"));
 }
 
@@ -400,6 +415,7 @@
  "\n"
  "#include \"a.h\"\n"
  "#include \"c.h\"\n",
+ 1,
  "c.cc"));
 }
 
@@ -415,6 +431,7 @@
  "\n"
  "#include \"a.h\"\n"
  "#include \"c.h\"\n",
+ 1,
  "a.cc"));
 }
 
@@ -438,6 +455,7 @@
  "#include \"gmock/gmock.h\"\n"
  "#include \"llvm/X.h\"\n"
  "#include \"LLVM/z.h\"\n",
+ 1,
  "a_TEST.cc"));
 }
 
@@ -449,6 +467,7 @@
 sort("#include \"c_main.h\"\n"
  "#include \"a_other.h\"\n"
  "#include \"important_os_header.h\"\n",
+ 1,
  "c_main.cc"));
 
   // check stable when re-run
@@ -458,6 +477,7 @@
 sort("#include \"important_os_header.h\"\n"
 

[clang-tools-extra] r357582 - [clang-tidy] Remove the old ClangTidyCheck::registerPPCallbacks method

2019-04-03 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Wed Apr  3 07:03:43 2019
New Revision: 357582

URL: http://llvm.org/viewvc/llvm-project?rev=357582=rev
Log:
[clang-tidy] Remove the old ClangTidyCheck::registerPPCallbacks method

Summary:
All in-tree clang-tidy checks have been migrated to the new
ClangTidyCheck::registerPPCallbacks method. Time to drop the old one.

Reviewers: sammccall, hokein

Reviewed By: hokein

Subscribers: xazax.hun, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

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

Modified:
clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
clang-tools-extra/trunk/clang-tidy/ClangTidyCheck.h
clang-tools-extra/trunk/clangd/ClangdUnit.cpp
clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyTest.h

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp?rev=357582=357581=357582=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Wed Apr  3 07:03:43 2019
@@ -393,7 +393,6 @@ ClangTidyASTConsumerFactory::CreateASTCo
 
   for (auto  : Checks) {
 Check->registerMatchers(&*Finder);
-Check->registerPPCallbacks(Compiler);
 Check->registerPPCallbacks(*SM, PP, ModuleExpanderPP);
   }
 

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyCheck.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyCheck.h?rev=357582=357581=357582=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidyCheck.h (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyCheck.h Wed Apr  3 07:03:43 2019
@@ -53,9 +53,6 @@ public:
   /// constructor using the Options.get() methods below.
   ClangTidyCheck(StringRef CheckName, ClangTidyContext *Context);
 
-  /// DEPRECATED: Use the other overload.
-  virtual void registerPPCallbacks(CompilerInstance ) {}
-
   /// \brief Override this to register ``PPCallbacks`` in the preprocessor.
   ///
   /// This should be used for clang-tidy checks that analyze preprocessor-

Modified: clang-tools-extra/trunk/clangd/ClangdUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdUnit.cpp?rev=357582=357581=357582=diff
==
--- clang-tools-extra/trunk/clangd/ClangdUnit.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp Wed Apr  3 07:03:43 2019
@@ -299,7 +299,6 @@ ParsedAST::build(std::unique_ptrregisterPPCallbacks(*Clang);
   Check->registerPPCallbacks(Clang->getSourceManager(), PP, PP);
   Check->registerMatchers();
 }

Modified: clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyTest.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyTest.h?rev=357582=357581=357582=diff
==
--- clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyTest.h (original)
+++ clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyTest.h Wed Apr  3 
07:03:43 2019
@@ -42,7 +42,6 @@ private:
 Preprocessor *PP = ();
 for (auto  : Checks) {
   Check->registerMatchers();
-  Check->registerPPCallbacks(Compiler);
   Check->registerPPCallbacks(Compiler.getSourceManager(), PP, PP);
 }
 return Finder.newASTConsumer();


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


[PATCH] D60197: [clang-tidy] Remove the old ClangTidyCheck::registerPPCallbacks method

2019-04-03 Thread Alexander Kornienko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE357582: [clang-tidy] Remove the old 
ClangTidyCheck::registerPPCallbacks method (authored by alexfh, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D60197?vs=193481=193486#toc

Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D60197

Files:
  clang-tidy/ClangTidy.cpp
  clang-tidy/ClangTidyCheck.h
  clangd/ClangdUnit.cpp
  unittests/clang-tidy/ClangTidyTest.h


Index: unittests/clang-tidy/ClangTidyTest.h
===
--- unittests/clang-tidy/ClangTidyTest.h
+++ unittests/clang-tidy/ClangTidyTest.h
@@ -42,7 +42,6 @@
 Preprocessor *PP = ();
 for (auto  : Checks) {
   Check->registerMatchers();
-  Check->registerPPCallbacks(Compiler);
   Check->registerPPCallbacks(Compiler.getSourceManager(), PP, PP);
 }
 return Finder.newASTConsumer();
Index: clang-tidy/ClangTidyCheck.h
===
--- clang-tidy/ClangTidyCheck.h
+++ clang-tidy/ClangTidyCheck.h
@@ -53,9 +53,6 @@
   /// constructor using the Options.get() methods below.
   ClangTidyCheck(StringRef CheckName, ClangTidyContext *Context);
 
-  /// DEPRECATED: Use the other overload.
-  virtual void registerPPCallbacks(CompilerInstance ) {}
-
   /// \brief Override this to register ``PPCallbacks`` in the preprocessor.
   ///
   /// This should be used for clang-tidy checks that analyze preprocessor-
Index: clang-tidy/ClangTidy.cpp
===
--- clang-tidy/ClangTidy.cpp
+++ clang-tidy/ClangTidy.cpp
@@ -393,7 +393,6 @@
 
   for (auto  : Checks) {
 Check->registerMatchers(&*Finder);
-Check->registerPPCallbacks(Compiler);
 Check->registerPPCallbacks(*SM, PP, ModuleExpanderPP);
   }
 
Index: clangd/ClangdUnit.cpp
===
--- clangd/ClangdUnit.cpp
+++ clangd/ClangdUnit.cpp
@@ -299,7 +299,6 @@
 for (const auto  : CTChecks) {
   // FIXME: the PP callbacks skip the entire preamble.
   // Checks that want to see #includes in the main file do not see them.
-  Check->registerPPCallbacks(*Clang);
   Check->registerPPCallbacks(Clang->getSourceManager(), PP, PP);
   Check->registerMatchers();
 }


Index: unittests/clang-tidy/ClangTidyTest.h
===
--- unittests/clang-tidy/ClangTidyTest.h
+++ unittests/clang-tidy/ClangTidyTest.h
@@ -42,7 +42,6 @@
 Preprocessor *PP = ();
 for (auto  : Checks) {
   Check->registerMatchers();
-  Check->registerPPCallbacks(Compiler);
   Check->registerPPCallbacks(Compiler.getSourceManager(), PP, PP);
 }
 return Finder.newASTConsumer();
Index: clang-tidy/ClangTidyCheck.h
===
--- clang-tidy/ClangTidyCheck.h
+++ clang-tidy/ClangTidyCheck.h
@@ -53,9 +53,6 @@
   /// constructor using the Options.get() methods below.
   ClangTidyCheck(StringRef CheckName, ClangTidyContext *Context);
 
-  /// DEPRECATED: Use the other overload.
-  virtual void registerPPCallbacks(CompilerInstance ) {}
-
   /// \brief Override this to register ``PPCallbacks`` in the preprocessor.
   ///
   /// This should be used for clang-tidy checks that analyze preprocessor-
Index: clang-tidy/ClangTidy.cpp
===
--- clang-tidy/ClangTidy.cpp
+++ clang-tidy/ClangTidy.cpp
@@ -393,7 +393,6 @@
 
   for (auto  : Checks) {
 Check->registerMatchers(&*Finder);
-Check->registerPPCallbacks(Compiler);
 Check->registerPPCallbacks(*SM, PP, ModuleExpanderPP);
   }
 
Index: clangd/ClangdUnit.cpp
===
--- clangd/ClangdUnit.cpp
+++ clangd/ClangdUnit.cpp
@@ -299,7 +299,6 @@
 for (const auto  : CTChecks) {
   // FIXME: the PP callbacks skip the entire preamble.
   // Checks that want to see #includes in the main file do not see them.
-  Check->registerPPCallbacks(*Clang);
   Check->registerPPCallbacks(Clang->getSourceManager(), PP, PP);
   Check->registerMatchers();
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D60139: [clang-tidy] Add misc-placement-new-target-size check

2019-04-03 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: docs/clang-tidy/checks/misc-placement-new-target-size.rst:5
+==
+
+

Eugene.Zelenko wrote:
> Unnecessary empty line.
Somehow empty line is still there.


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

https://reviews.llvm.org/D60139



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


[clang-tools-extra] r357574 - gn build: Add build files for clangd xpc framework code

2019-04-03 Thread Nico Weber via cfe-commits
Author: nico
Date: Wed Apr  3 05:33:19 2019
New Revision: 357574

URL: http://llvm.org/viewvc/llvm-project?rev=357574=rev
Log:
gn build: Add build files for clangd xpc framework code

This is a bit of a larger change since this is the first (and as far as
I can tell only) place where the LLVM build produces macOS framework
bundles.

GN has some built-in support for this, so use that.
`gn help create_bundle` has a terse description (but it's a bit
outdated: `deps` must be `public_deps` and the conditionals in the
example in the help aren't quite right on non-iOS).

We need a new 'copy_bundle_data' tool, and since we copy the clangd.xpc
bundle as bundle_data into ClangdXPC.framework it needs to be able to
handle directories in addition to files.

GN also insists we have a compile_xcassets tool even though it's not
used. I just made that run `false`.

Despite GN's support for bundles, we still need to manually create the
expected symlink structure in the .framework bundle. Since this code
never runs on Windows, it's safe to create the symlinks before the
symlink targets exist, so we can just make the bundle depend on the
steps that create the symlinks. For this to work, change the symlink
script to create the symlink's containing directory if it doesn't yet
exist.

I locally verified that CMake and GN build create the same bundle
structure. (I noticed that both builds set LC_ID_DYLIB to the pre-copy
libClangdXPCLib.dylib name, but that seems to not cause any issues and
it happens in the CMake build too.)

(Also add an error message to clangd-xpc-test-client for when loading
the dylib fails – this was useful while locally debugging this.)

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

Modified:
clang-tools-extra/trunk/clangd/xpc/framework/CMakeLists.txt
clang-tools-extra/trunk/clangd/xpc/test-client/ClangdXPCTestClient.cpp

Modified: clang-tools-extra/trunk/clangd/xpc/framework/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/xpc/framework/CMakeLists.txt?rev=357574=357573=357574=diff
==
--- clang-tools-extra/trunk/clangd/xpc/framework/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clangd/xpc/framework/CMakeLists.txt Wed Apr  3 
05:33:19 2019
@@ -1,6 +1,7 @@
 
 set(SOURCES
-ClangdXPC.cpp)
+  ClangdXPC.cpp
+)
 add_clang_library(ClangdXPCLib SHARED
   ${SOURCES}
   DEPENDS

Modified: clang-tools-extra/trunk/clangd/xpc/test-client/ClangdXPCTestClient.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/xpc/test-client/ClangdXPCTestClient.cpp?rev=357574=357573=357574=diff
==
--- clang-tools-extra/trunk/clangd/xpc/test-client/ClangdXPCTestClient.cpp 
(original)
+++ clang-tools-extra/trunk/clangd/xpc/test-client/ClangdXPCTestClient.cpp Wed 
Apr  3 05:33:19 2019
@@ -49,8 +49,10 @@ int main(int argc, char *argv[]) {
   // Open the ClangdXPC dylib in the framework.
   std::string LibPath = getLibraryPath();
   void *dlHandle = dlopen(LibPath.c_str(), RTLD_LOCAL | RTLD_FIRST);
-  if (!dlHandle)
+  if (!dlHandle) {
+llvm::errs() << "Failed to load framework from \'" << LibPath << "\'\n";
 return 1;
+  }
 
   // Lookup the XPC service bundle name, and launch it.
   clangd_xpc_get_bundle_identifier_t clangd_xpc_get_bundle_identifier =


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


[PATCH] D59802: [clang-tidy] Add new checker: llvm-prefer-isa-or-dyn-cast-in-conditionals

2019-04-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/llvm/AvoidCastInConditionalCheck.cpp:145
+
+diag(MatchedDecl->getBeginLoc(), "use dyn_cast_or_null")
+<< FixItHint::CreateReplacement(SourceRange(MatchedDecl->getBeginLoc(),

hintonda wrote:
> aaron.ballman wrote:
> > hintonda wrote:
> > > aaron.ballman wrote:
> > > > This diagnostic doesn't tell the user what they've done wrong with the 
> > > > code or why this is a better choice.
> > > Yes, but I'm not yet sure what it should say.  Was sorta hoping for a 
> > > suggestion.  
> > Do you have any evidence that this situation happens in practice? I kind of 
> > feel like this entire branch could be eliminated from this patch unless it 
> > actually catches problems that happen.
> Yes, here are a few from clang/lib -- let me know if you think it's worth it 
> or not to keep this:
> 
> - DiagnosticName: llvm-avoid-cast-in-conditional
>   FileOffset: 305293
>   FilePath: 
> /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/Sema/SemaTemplate.cpp
>   Message: method 'getAsTemplateDecl' is called twice and could be expensive
>   Replacements:
>   - FilePath: 
> /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/Sema/SemaTemplate.cpp
> Length: 93
> Offset: 305293
> ReplacementText: 
> dyn_cast_or_null(Name.getAsTemplateDecl())
> - DiagnosticName: llvm-avoid-cast-in-conditional
>   FileOffset: 153442
>   FilePath: 
> /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/AST/ASTContext.cpp
>   Message: method 'getAsTemplateDecl' is called twice and could be expensive
>   Replacements:
>   - FilePath: 
> /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/AST/ASTContext.cpp
> Length: 92
> Offset: 153442
> ReplacementText: 
> dyn_cast_or_null(Template.getAsTemplateDecl())
> - DiagnosticName: llvm-avoid-cast-in-conditional
>   FileOffset: 97556
>   FilePath: 
> /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/AST/Expr.cpp
>   Message: method 'getMethodDecl' is called twice and could be expensive
>   Replacements:
>   - FilePath: 
> /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/AST/Expr.cpp
> Length: 68
> Offset: 97556
> ReplacementText: dyn_cast_or_null(MCE->getMethodDecl())
> - DiagnosticName: llvm-avoid-cast-in-conditional
>   FileOffset: 301950
>   FilePath: 
> /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/Sema/SemaInit.cpp
>   Message: method 'get' is called twice and could be expensive
>   Replacements:
>   - FilePath: 
> /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/Sema/SemaInit.cpp
> Length: 49
> Offset: 301950
> ReplacementText: dyn_cast_or_null(CurInit.get())
> - DiagnosticName: llvm-avoid-cast-in-conditional
>   FileOffset: 14335
>   FilePath: 
> /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/Sema/AnalysisBasedWarnings.cpp
>   Message: method 'operator bool' is called twice and could be expensive
>   Replacements:
>   - FilePath: 
> /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/Sema/AnalysisBasedWarnings.cpp
> Length: 57
> Offset: 14335
> ReplacementText: dyn_cast_or_null(B->getTerminator())
> - DiagnosticName: llvm-avoid-cast-in-conditional
>   FileOffset: 15997
>   FilePath: 
> /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/Sema/AnalysisBasedWarnings.cpp
>   Message: method 'operator bool' is called twice and could be expensive
>   Replacements:
>   - FilePath: 
> /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/lib/Sema/AnalysisBasedWarnings.cpp
> Length: 55
> Offset: 15997
> ReplacementText: dyn_cast_or_null(B.getTerminator())
> - DiagnosticName: llvm-avoid-cast-in-conditional
>   FileOffset: 9492
>   FilePath: 
> /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h
>   Message: method 'sexpr' is called twice and could be expensive
>   Replacements:
>   - FilePath: 
> /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h
> Length: 39
> Offset: 9492
> ReplacementText: dyn_cast_or_null(sexpr())
> - DiagnosticName: llvm-avoid-cast-in-conditional
>   FileOffset: 9572
>   FilePath: 
> /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h
>   Message: method 'sexpr' is called twice and could be expensive
>   Replacements:
>   - FilePath: 
> /Users/dhinton/projects/llvm_project/monorepo/llvm-project/clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h
> Length: 38
> Offset: 9572
> ReplacementText: dyn_cast_or_null(sexpr())
> - DiagnosticName: llvm-avoid-cast-in-conditional
>   FileOffset: 9492
>   FilePath: 
> 

[PATCH] D59376: [LibTooling] Add Transformer, a library for source-to-source transformations.

2019-04-03 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC357576: [LibTooling] Add Transformer, a library for 
source-to-source transformations. (authored by ymandel, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D59376?vs=193306=193480#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D59376

Files:
  include/clang/Tooling/Refactoring/Transformer.h
  lib/Tooling/Refactoring/CMakeLists.txt
  lib/Tooling/Refactoring/Transformer.cpp
  unittests/Tooling/CMakeLists.txt
  unittests/Tooling/TransformerTest.cpp

Index: lib/Tooling/Refactoring/Transformer.cpp
===
--- lib/Tooling/Refactoring/Transformer.cpp
+++ lib/Tooling/Refactoring/Transformer.cpp
@@ -0,0 +1,204 @@
+//===--- Transformer.cpp - Transformer library implementation ---*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/Tooling/Refactoring/Transformer.h"
+#include "clang/AST/Expr.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Rewrite/Core/Rewriter.h"
+#include "clang/Tooling/FixIt.h"
+#include "clang/Tooling/Refactoring.h"
+#include "clang/Tooling/Refactoring/AtomicChange.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Errc.h"
+#include "llvm/Support/Error.h"
+#include 
+#include 
+#include 
+#include 
+
+using namespace clang;
+using namespace tooling;
+
+using ast_matchers::MatchFinder;
+using ast_type_traits::ASTNodeKind;
+using ast_type_traits::DynTypedNode;
+using llvm::Error;
+using llvm::Expected;
+using llvm::Optional;
+using llvm::StringError;
+using llvm::StringRef;
+using llvm::Twine;
+
+using MatchResult = MatchFinder::MatchResult;
+
+// Did the text at this location originate in a macro definition (aka. body)?
+// For example,
+//
+//   #define NESTED(x) x
+//   #define MACRO(y) { int y  = NESTED(3); }
+//   if (true) MACRO(foo)
+//
+// The if statement expands to
+//
+//   if (true) { int foo = 3; }
+//   ^ ^
+//   Loc1  Loc2
+//
+// For SourceManager SM, SM.isMacroArgExpansion(Loc1) and
+// SM.isMacroArgExpansion(Loc2) are both true, but isOriginMacroBody(sm, Loc1)
+// is false, because "foo" originated in the source file (as an argument to a
+// macro), whereas isOriginMacroBody(SM, Loc2) is true, because "3" originated
+// in the definition of MACRO.
+static bool isOriginMacroBody(const clang::SourceManager ,
+  clang::SourceLocation Loc) {
+  while (Loc.isMacroID()) {
+if (SM.isMacroBodyExpansion(Loc))
+  return true;
+// Otherwise, it must be in an argument, so we continue searching up the
+// invocation stack. getImmediateMacroCallerLoc() gives the location of the
+// argument text, inside the call text.
+Loc = SM.getImmediateMacroCallerLoc(Loc);
+  }
+  return false;
+}
+
+static llvm::Error invalidArgumentError(Twine Message) {
+  return llvm::make_error(llvm::errc::invalid_argument, Message);
+}
+
+static llvm::Error typeError(StringRef Id, const ASTNodeKind ,
+ Twine Message) {
+  return invalidArgumentError(
+  Message + " (node id=" + Id + " kind=" + Kind.asStringRef() + ")");
+}
+
+static llvm::Error missingPropertyError(StringRef Id, Twine Description,
+StringRef Property) {
+  return invalidArgumentError(Description + " requires property '" + Property +
+  "' (node id=" + Id + ")");
+}
+
+static Expected
+getTargetRange(StringRef Target, const DynTypedNode , ASTNodeKind Kind,
+   NodePart TargetPart, ASTContext ) {
+  switch (TargetPart) {
+  case NodePart::Node: {
+// For non-expression statements, associate any trailing semicolon with the
+// statement text.  However, if the target was intended as an expression (as
+// indicated by its kind) then we do not associate any trailing semicolon
+// with it.  We only associate the exact expression text.
+if (Node.get() != nullptr) {
+  auto ExprKind = ASTNodeKind::getFromNodeKind();
+  if (!ExprKind.isBaseOf(Kind))
+return fixit::getExtendedRange(Node, tok::TokenKind::semi, Context);
+}
+return CharSourceRange::getTokenRange(Node.getSourceRange());
+  }
+  case NodePart::Member:
+if (auto *M = Node.get())
+  return CharSourceRange::getTokenRange(
+  M->getMemberNameInfo().getSourceRange());
+return typeError(Target, Node.getNodeKind(),
+ "NodePart::Member 

[PATCH] D60151: [clang-tidy] Add using SmallSet to LLVM.h to fix bug in typedef in llvm checkers.

2019-04-03 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

The change looks fine, but I don't understand the description of this revision. 
Could you clarify which checkers you're talking about and which bug you observe?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60151



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


[PATCH] D59963: [clang-tidy] Add a module for the Linux kernel.

2019-04-03 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

Can you verify that the add_new_check.py script works fine with this new module?
Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59963



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


[PATCH] D59806: [clang-tidy] Add a check for [super self] in initializers 

2019-04-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tools-extra/clang-tidy/objc/SuperSelfCheck.cpp:112
+  << Message->getMethodDecl()
+  << FixItHint::CreateReplacement(Message->getSourceRange(),
+  StringRef("[super init]"));

stephanemoore wrote:
> aaron.ballman wrote:
> > stephanemoore wrote:
> > > stephanemoore wrote:
> > > > aaron.ballman wrote:
> > > > > This could be dangerous if the `[super self]` construct is in a 
> > > > > macro, couldn't it? e.g.,
> > > > > ```
> > > > > #define DERP self
> > > > > 
> > > > > [super DERP];
> > > > > ```
> > > > Good point. Let me add some test cases and make sure this is handled 
> > > > properly.
> > > Added some test cases where `[super self]` is expanded from macros.
> > You missed the test case I was worried about -- where the macro is mixed 
> > into the expression. I don't think we want to try to add a fix-it in that 
> > case.
> Added a test case though at the moment it generates a fixit.
> 
> Before I investigate modifying the check to avoid generating a fixit in this 
> case, I think it would be helpful for me to understand your concerns in that 
> scenario better. Is your concern that a proper fix might involve fixing the 
> macro itself rather than the message expression?
> 
> ```
> #if FLAG
> #define INVOCATION self
> #else
> #define INVOCATION init
> #endif
> 
> - (instancetype)init {
>   return [super INVOCATION];
> }
> ```
> Before I investigate modifying the check to avoid generating a fixit in this 
> case, I think it would be helpful for me to understand your concerns in that 
> scenario better. Is your concern that a proper fix might involve fixing the 
> macro itself rather than the message expression?

Essentially, yes. Macros can get arbitrarily complex and so our rule of thumb 
is to not apply fix-its when the code being fixed is within a macro. Another 
example that can be tricky is adding another layer of macros:
```
#define FOO super
#define BAR self
#define BAZ FOO BAR

- (instancetype)init {
  return [BAZ];
}
```



Comment at: clang-tools-extra/test/clang-tidy/objc-super-self.m:41
+  INITIALIZER_IMPL();
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: suspicious invocation of 'self' in 
initializer; did you mean to invoke a superclass initializer? [objc-super-self]
+}

stephanemoore wrote:
> aaron.ballman wrote:
> > Are you missing a `CHECK-FIXES` here?
> > 
> > Personally, I don't think we should try to generate a fixit for this case, 
> > so I would expect a CHECK-FIXES that ensures this doesn't get modified.
> No fix is currently generated for this case which is why there is no 
> `CHECK-FIXES`. I also agree that no fix should be generated for this case.
> 
> I must confess that I have yet to fully understand why the fix for this case 
> is discarded (though I am grateful for the behavior). Let me dig around to 
> try to better understand why no fixit is generated for this case and assess 
> adding a condition for emitting the fixit.
Our typical way to check that a fix is not applied is to use `// CHECK-FIXES: 
` to test that the fix was not applied.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59806



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


[PATCH] D60130: gn build: Add build files for clangd xpc framework code

2019-04-03 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE357574: gn build: Add build files for clangd xpc framework 
code (authored by nico, committed by ).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D60130?vs=193313=193476#toc

Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D60130

Files:
  clangd/xpc/framework/CMakeLists.txt
  clangd/xpc/test-client/ClangdXPCTestClient.cpp


Index: clangd/xpc/framework/CMakeLists.txt
===
--- clangd/xpc/framework/CMakeLists.txt
+++ clangd/xpc/framework/CMakeLists.txt
@@ -1,6 +1,7 @@
 
 set(SOURCES
-ClangdXPC.cpp)
+  ClangdXPC.cpp
+)
 add_clang_library(ClangdXPCLib SHARED
   ${SOURCES}
   DEPENDS
Index: clangd/xpc/test-client/ClangdXPCTestClient.cpp
===
--- clangd/xpc/test-client/ClangdXPCTestClient.cpp
+++ clangd/xpc/test-client/ClangdXPCTestClient.cpp
@@ -49,8 +49,10 @@
   // Open the ClangdXPC dylib in the framework.
   std::string LibPath = getLibraryPath();
   void *dlHandle = dlopen(LibPath.c_str(), RTLD_LOCAL | RTLD_FIRST);
-  if (!dlHandle)
+  if (!dlHandle) {
+llvm::errs() << "Failed to load framework from \'" << LibPath << "\'\n";
 return 1;
+  }
 
   // Lookup the XPC service bundle name, and launch it.
   clangd_xpc_get_bundle_identifier_t clangd_xpc_get_bundle_identifier =


Index: clangd/xpc/framework/CMakeLists.txt
===
--- clangd/xpc/framework/CMakeLists.txt
+++ clangd/xpc/framework/CMakeLists.txt
@@ -1,6 +1,7 @@
 
 set(SOURCES
-ClangdXPC.cpp)
+  ClangdXPC.cpp
+)
 add_clang_library(ClangdXPCLib SHARED
   ${SOURCES}
   DEPENDS
Index: clangd/xpc/test-client/ClangdXPCTestClient.cpp
===
--- clangd/xpc/test-client/ClangdXPCTestClient.cpp
+++ clangd/xpc/test-client/ClangdXPCTestClient.cpp
@@ -49,8 +49,10 @@
   // Open the ClangdXPC dylib in the framework.
   std::string LibPath = getLibraryPath();
   void *dlHandle = dlopen(LibPath.c_str(), RTLD_LOCAL | RTLD_FIRST);
-  if (!dlHandle)
+  if (!dlHandle) {
+llvm::errs() << "Failed to load framework from \'" << LibPath << "\'\n";
 return 1;
+  }
 
   // Lookup the XPC service bundle name, and launch it.
   clangd_xpc_get_bundle_identifier_t clangd_xpc_get_bundle_identifier =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59802: [clang-tidy] Add new checker: llvm-prefer-isa-or-dyn-cast-in-conditionals

2019-04-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tools-extra/clang-tidy/llvm/AvoidCastInConditionalCheck.cpp:18
+
+AST_MATCHER(Expr, isMacroID) { return Node.getExprLoc().isMacroID(); }
+} // namespace ast_matchers

hintonda wrote:
> @aaron.ballman:  This matcher seems genuinely useful.  What do you think 
> about moving it to ASTMatchers.h? 
I think that adding something like this might be a good idea. We don't have any 
notion of source locations in the AST matching syntax currently, and I'm not 
certain whether that's a good thing or not here. I'm mildly uncomfortable that 
this matcher operates on an `Expr` but then internally uses a source location 
from that expression and I wonder if we would rather introduce source location 
matching. For instance, what if the user cares about the difference between 
`getExprLoc()` and `getBeginLoc()` for some reason?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59802



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


[PATCH] D59646: [PR40778][PR41157][OpenCL] Prevent implicit initialization of local address space objects

2019-04-03 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia updated this revision to Diff 193474.
Anastasia added a comment.

Improved comment about initializers in __local addr space.


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

https://reviews.llvm.org/D59646

Files:
  lib/Sema/SemaDecl.cpp
  test/CodeGenOpenCLCXX/addrspace-of-this.cl
  test/CodeGenOpenCLCXX/local_addrspace_init.cl


Index: test/CodeGenOpenCLCXX/local_addrspace_init.cl
===
--- /dev/null
+++ test/CodeGenOpenCLCXX/local_addrspace_init.cl
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 %s -triple spir -cl-std=c++ -emit-llvm -O0 -o - | FileCheck 
%s
+
+// Test that we don't initialize local address space objects.
+//CHECK: @_ZZ4testvE1i = internal addrspace(3) global i32 undef
+//CHECK: @_ZZ4testvE2ii = internal addrspace(3) global %class.C undef
+class C {
+  int i;
+};
+
+kernel void test() {
+  __local int i;
+  __local C ii;
+  // FIXME: In OpenCL C we don't accept initializers for local
+  // address space variables. User defined initialization could
+  // make sense, but would it mean that all work items need to
+  // execute it? Potentially disallowing any initialization would
+  // make things easier and assingments can be used to set specific
+  // values. This rules should make it consistent with OpenCL C.
+  //__local C c();
+}
Index: test/CodeGenOpenCLCXX/addrspace-of-this.cl
===
--- test/CodeGenOpenCLCXX/addrspace-of-this.cl
+++ test/CodeGenOpenCLCXX/addrspace-of-this.cl
@@ -150,15 +150,13 @@
 TEST(__local)
 
 // COMMON-LABEL: _Z11test__localv
-// EXPL: @__cxa_guard_acquire
 
-// Test the address space of 'this' when invoking a constructor for an object 
in non-default address space
-// EXPL: call void @_ZNU3AS41CC1Ev(%class.C addrspace(4)* addrspacecast 
(%class.C addrspace(3)* @_ZZ11test__localvE1c to %class.C addrspace(4)*))
+// Test that we don't initialize an object in local address space.
+// EXPL-NOT: call void @_ZNU3AS41CC1Ev(%class.C addrspace(4)* addrspacecast 
(%class.C addrspace(3)* @_ZZ11test__localvE1c to %class.C addrspace(4)*))
 
 // Test the address space of 'this' when invoking a method.
 // COMMON: %call = call i32 @_ZNU3AS41C3getEv(%class.C addrspace(4)* 
addrspacecast (%class.C addrspace(3)* @_ZZ11test__localvE1c to %class.C 
addrspace(4)*))
 
-
 // Test the address space of 'this' when invoking copy-constructor.
 // COMMON: [[C1GEN:%[0-9]+]] = addrspacecast %class.C* %c1 to %class.C 
addrspace(4)*
 // EXPL: call void @_ZNU3AS41CC1ERU3AS4KS_(%class.C addrspace(4)* [[C1GEN]], 
%class.C addrspace(4)* dereferenceable(4) addrspacecast (%class.C addrspace(3)* 
@_ZZ11test__localvE1c to %class.C addrspace(4)*))
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -11645,7 +11645,11 @@
   setFunctionHasBranchProtectedScope();
   }
 }
-
+// In OpenCL, we can't initialize objects in the __local address space,
+// even implicitly, so don't synthesize an implicit initializer.
+if (getLangOpts().OpenCL &&
+Var->getType().getAddressSpace() == LangAS::opencl_local)
+  return;
 // C++03 [dcl.init]p9:
 //   If no initializer is specified for an object, and the
 //   object is of (possibly cv-qualified) non-POD class type (or


Index: test/CodeGenOpenCLCXX/local_addrspace_init.cl
===
--- /dev/null
+++ test/CodeGenOpenCLCXX/local_addrspace_init.cl
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 %s -triple spir -cl-std=c++ -emit-llvm -O0 -o - | FileCheck %s
+
+// Test that we don't initialize local address space objects.
+//CHECK: @_ZZ4testvE1i = internal addrspace(3) global i32 undef
+//CHECK: @_ZZ4testvE2ii = internal addrspace(3) global %class.C undef
+class C {
+  int i;
+};
+
+kernel void test() {
+  __local int i;
+  __local C ii;
+  // FIXME: In OpenCL C we don't accept initializers for local
+  // address space variables. User defined initialization could
+  // make sense, but would it mean that all work items need to
+  // execute it? Potentially disallowing any initialization would
+  // make things easier and assingments can be used to set specific
+  // values. This rules should make it consistent with OpenCL C.
+  //__local C c();
+}
Index: test/CodeGenOpenCLCXX/addrspace-of-this.cl
===
--- test/CodeGenOpenCLCXX/addrspace-of-this.cl
+++ test/CodeGenOpenCLCXX/addrspace-of-this.cl
@@ -150,15 +150,13 @@
 TEST(__local)
 
 // COMMON-LABEL: _Z11test__localv
-// EXPL: @__cxa_guard_acquire
 
-// Test the address space of 'this' when invoking a constructor for an object in non-default address space
-// EXPL: call void @_ZNU3AS41CC1Ev(%class.C addrspace(4)* addrspacecast (%class.C addrspace(3)* @_ZZ11test__localvE1c to %class.C addrspace(4)*))
+// Test that we don't 

[PATCH] D59628: Add support for __attribute__((objc_class_stub))

2019-04-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: include/clang/Basic/Attr.td:293
   bit Negated = negated;
+  string CustomCode = customCode;
 }

I think the type here should be `code` instead of `string` since the user is 
passing in code snippets, no?



Comment at: lib/Sema/SemaDeclObjC.cpp:4129-4130
+
+if (IntfDecl->hasAttr()) {
+  if (!IntfDecl->hasAttr())
+Diag(IntfDecl->getLocation(), 
diag::err_class_stub_subclassing_mismatch);

Combine these `if` statements?


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

https://reviews.llvm.org/D59628



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


r357576 - [LibTooling] Add Transformer, a library for source-to-source transformations.

2019-04-03 Thread Yitzhak Mandelbaum via cfe-commits
Author: ymandel
Date: Wed Apr  3 06:05:19 2019
New Revision: 357576

URL: http://llvm.org/viewvc/llvm-project?rev=357576=rev
Log:
[LibTooling] Add Transformer, a library for source-to-source transformations.

Summary: Adds a basic version of Transformer, a library supporting the concise 
specification of clang-based source-to-source transformations.  A full 
discussion of the end goal can be found on the cfe-dev list with subject "[RFC] 
Easier source-to-source transformations with clang tooling".

Reviewers: ilya-biryukov

Reviewed By: ilya-biryukov

Subscribers: mgorny, jfb, jdoerfert, cfe-commits

Tags: #clang

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

Added:
cfe/trunk/include/clang/Tooling/Refactoring/Transformer.h
cfe/trunk/lib/Tooling/Refactoring/Transformer.cpp
cfe/trunk/unittests/Tooling/TransformerTest.cpp
Modified:
cfe/trunk/lib/Tooling/Refactoring/CMakeLists.txt
cfe/trunk/unittests/Tooling/CMakeLists.txt

Added: cfe/trunk/include/clang/Tooling/Refactoring/Transformer.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Refactoring/Transformer.h?rev=357576=auto
==
--- cfe/trunk/include/clang/Tooling/Refactoring/Transformer.h (added)
+++ cfe/trunk/include/clang/Tooling/Refactoring/Transformer.h Wed Apr  3 
06:05:19 2019
@@ -0,0 +1,210 @@
+//===--- Transformer.h - Clang source-rewriting library -*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+///
+///  \file
+///  Defines a library supporting the concise specification of clang-based
+///  source-to-source transformations.
+///
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLING_REFACTOR_TRANSFORMER_H_
+#define LLVM_CLANG_TOOLING_REFACTOR_TRANSFORMER_H_
+
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/ASTMatchers/ASTMatchersInternal.h"
+#include "clang/Tooling/Refactoring/AtomicChange.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/Support/Error.h"
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+namespace clang {
+namespace tooling {
+/// Determines the part of the AST node to replace.  We support this to work
+/// around the fact that the AST does not differentiate various syntactic
+/// elements into their own nodes, so users can specify them relative to a 
node,
+/// instead.
+enum class NodePart {
+  /// The node itself.
+  Node,
+  /// Given a \c MemberExpr, selects the member's token.
+  Member,
+  /// Given a \c NamedDecl or \c CxxCtorInitializer, selects that token of the
+  /// relevant name, not including qualifiers.
+  Name,
+};
+
+using TextGenerator =
+std::function;
+
+/// Description of a source-code transformation.
+//
+// A *rewrite rule* describes a transformation of source code. It has the
+// following components:
+//
+// * Matcher: the pattern term, expressed as clang matchers (with Transformer
+//   extensions).
+//
+// * Target: the source code impacted by the rule. This identifies an AST node,
+//   or part thereof (\c TargetPart), whose source range indicates the extent 
of
+//   the replacement applied by the replacement term.  By default, the extent 
is
+//   the node matched by the pattern term (\c NodePart::Node). Target's are
+//   typed (\c TargetKind), which guides the determination of the node extent
+//   and might, in the future, statically constrain the set of eligible
+//   NodeParts for a given node.
+//
+// * Replacement: a function that produces a replacement string for the target,
+//   based on the match result.
+//
+// * Explanation: explanation of the rewrite.  This will be displayed to the
+//   user, where possible (for example, in clang-tidy fix descriptions).
+//
+// Rules have an additional, implicit, component: the parameters. These are
+// portions of the pattern which are left unspecified, yet named so that we can
+// reference them in the replacement term.  The structure of parameters can be
+// partially or even fully specified, in which case they serve just to identify
+// matched nodes for later reference rather than abstract over portions of the
+// AST.  However, in all cases, we refer to named portions of the pattern as
+// parameters.
+//
+// RewriteRule is constructed in a "fluent" style, by creating a builder and
+// chaining setters of individual components.
+// \code
+//   RewriteRule MyRule = buildRule(functionDecl(...)).replaceWith(...);
+// \endcode
+//
+// The \c Transformer class should then be used to apply the rewrite rule and
+// obtain the corresponding replacements.
+struct RewriteRule {
+  // `Matcher` describes the context of 

[PATCH] D59985: Re-fix invalid address space generation for clk_event_t arguments of enqueue_kernel builtin function

2019-04-03 Thread Alexey Sotkin via Phabricator via cfe-commits
AlexeySotkin marked an inline comment as done.
AlexeySotkin added inline comments.



Comment at: lib/CodeGen/CGBuiltin.cpp:3711
+  EventList = EventList->getType()->isIntegerTy()
+  ? Builder.CreateIntToPtr(EventList, EventPtrTy)
+  : Builder.CreatePointerCast(EventList, EventPtrTy);

Anastasia wrote:
> AlexeySotkin wrote:
> > Anastasia wrote:
> > > It seems we are not testing the casts?
> > Do you mean that when we run LIT tests, this code is not executed? If so, 
> > in the modified test below, literal zeros are making clang to execute 
> > CreateIntToPtr call indeed.
> > Or, do you mean that we need some extra check(to make sure the cast will be 
> > successful for example) in the source code itself ?
> I mean since you are generating extra IR nodes we should check in the tests 
> that they appear correctly. I don't see these casts checked in the tests 
> currently.
Since we are casting null constants they are folded to null values, like this 
`%opencl.clk_event_t{{.*}}* addrspace(4)* null`.


Repository:
  rC Clang

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

https://reviews.llvm.org/D59985



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


[PATCH] D60183: Fix typos in tests. NFC.

2019-04-03 Thread Xing via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL357577: Fix typos in tests. NFC. (authored by Higuoxing, 
committed by ).
Herald added a subscriber: delcypher.

Changed prior to commit:
  https://reviews.llvm.org/D60183?vs=193439=193482#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D60183

Files:
  cfe/trunk/test/Analysis/analyzer-list-configs.c
  compiler-rt/trunk/test/tsan/race_on_heap.cc


Index: compiler-rt/trunk/test/tsan/race_on_heap.cc
===
--- compiler-rt/trunk/test/tsan/race_on_heap.cc
+++ compiler-rt/trunk/test/tsan/race_on_heap.cc
@@ -39,7 +39,7 @@
 // CHECK: WARNING: ThreadSanitizer: data race
 // ...
 // CHECK: Location is heap block of size 99 at [[ADDR]] allocated by thread T1:
-// CHCEK: #0 malloc
+// CHECK: #0 malloc
 // CHECK: #{{1|2}} alloc
 // CHECK: #{{2|3}} AllocThread
 // ...
Index: cfe/trunk/test/Analysis/analyzer-list-configs.c
===
--- cfe/trunk/test/Analysis/analyzer-list-configs.c
+++ cfe/trunk/test/Analysis/analyzer-list-configs.c
@@ -3,7 +3,7 @@
 //
 // CHECK: USAGE: clang -cc1 [CLANG_OPTIONS] -analyzer-config 

 //
-// CHCEK:  clang -cc1 [CLANG_OPTIONS] -analyzer-config OPTION1=VALUE, 
-analyzer-config OPTION2=VALUE, ...
+// CHECK:  clang -cc1 [CLANG_OPTIONS] -analyzer-config OPTION1=VALUE, 
-analyzer-config OPTION2=VALUE, ...
 //
 // CHECK:  clang [CLANG_OPTIONS] -Xclang -analyzer-config 
-Xclang
 //


Index: compiler-rt/trunk/test/tsan/race_on_heap.cc
===
--- compiler-rt/trunk/test/tsan/race_on_heap.cc
+++ compiler-rt/trunk/test/tsan/race_on_heap.cc
@@ -39,7 +39,7 @@
 // CHECK: WARNING: ThreadSanitizer: data race
 // ...
 // CHECK: Location is heap block of size 99 at [[ADDR]] allocated by thread T1:
-// CHCEK: #0 malloc
+// CHECK: #0 malloc
 // CHECK: #{{1|2}} alloc
 // CHECK: #{{2|3}} AllocThread
 // ...
Index: cfe/trunk/test/Analysis/analyzer-list-configs.c
===
--- cfe/trunk/test/Analysis/analyzer-list-configs.c
+++ cfe/trunk/test/Analysis/analyzer-list-configs.c
@@ -3,7 +3,7 @@
 //
 // CHECK: USAGE: clang -cc1 [CLANG_OPTIONS] -analyzer-config 
 //
-// CHCEK:  clang -cc1 [CLANG_OPTIONS] -analyzer-config OPTION1=VALUE, -analyzer-config OPTION2=VALUE, ...
+// CHECK:  clang -cc1 [CLANG_OPTIONS] -analyzer-config OPTION1=VALUE, -analyzer-config OPTION2=VALUE, ...
 //
 // CHECK:  clang [CLANG_OPTIONS] -Xclang -analyzer-config -Xclang
 //
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D60197: [clang-tidy] Remove the old ClangTidyCheck::registerPPCallbacks method

2019-04-03 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh created this revision.
alexfh added reviewers: sammccall, hokein.
Herald added subscribers: kadircet, arphaman, jkorous, xazax.hun.
Herald added a project: clang.

All in-tree clang-tidy checks have been migrated to the new
ClangTidyCheck::registerPPCallbacks method. Time to drop the old one.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D60197

Files:
  clang-tools-extra/clang-tidy/ClangTidy.cpp
  clang-tools-extra/clang-tidy/ClangTidyCheck.h
  clang-tools-extra/clangd/ClangdUnit.cpp
  clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h


Index: clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h
===
--- clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h
+++ clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h
@@ -42,7 +42,6 @@
 Preprocessor *PP = ();
 for (auto  : Checks) {
   Check->registerMatchers();
-  Check->registerPPCallbacks(Compiler);
   Check->registerPPCallbacks(Compiler.getSourceManager(), PP, PP);
 }
 return Finder.newASTConsumer();
Index: clang-tools-extra/clangd/ClangdUnit.cpp
===
--- clang-tools-extra/clangd/ClangdUnit.cpp
+++ clang-tools-extra/clangd/ClangdUnit.cpp
@@ -299,7 +299,6 @@
 for (const auto  : CTChecks) {
   // FIXME: the PP callbacks skip the entire preamble.
   // Checks that want to see #includes in the main file do not see them.
-  Check->registerPPCallbacks(*Clang);
   Check->registerPPCallbacks(Clang->getSourceManager(), PP, PP);
   Check->registerMatchers();
 }
Index: clang-tools-extra/clang-tidy/ClangTidyCheck.h
===
--- clang-tools-extra/clang-tidy/ClangTidyCheck.h
+++ clang-tools-extra/clang-tidy/ClangTidyCheck.h
@@ -53,9 +53,6 @@
   /// constructor using the Options.get() methods below.
   ClangTidyCheck(StringRef CheckName, ClangTidyContext *Context);
 
-  /// DEPRECATED: Use the other overload.
-  virtual void registerPPCallbacks(CompilerInstance ) {}
-
   /// \brief Override this to register ``PPCallbacks`` in the preprocessor.
   ///
   /// This should be used for clang-tidy checks that analyze preprocessor-
Index: clang-tools-extra/clang-tidy/ClangTidy.cpp
===
--- clang-tools-extra/clang-tidy/ClangTidy.cpp
+++ clang-tools-extra/clang-tidy/ClangTidy.cpp
@@ -393,7 +393,6 @@
 
   for (auto  : Checks) {
 Check->registerMatchers(&*Finder);
-Check->registerPPCallbacks(Compiler);
 Check->registerPPCallbacks(*SM, PP, ModuleExpanderPP);
   }
 


Index: clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h
===
--- clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h
+++ clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h
@@ -42,7 +42,6 @@
 Preprocessor *PP = ();
 for (auto  : Checks) {
   Check->registerMatchers();
-  Check->registerPPCallbacks(Compiler);
   Check->registerPPCallbacks(Compiler.getSourceManager(), PP, PP);
 }
 return Finder.newASTConsumer();
Index: clang-tools-extra/clangd/ClangdUnit.cpp
===
--- clang-tools-extra/clangd/ClangdUnit.cpp
+++ clang-tools-extra/clangd/ClangdUnit.cpp
@@ -299,7 +299,6 @@
 for (const auto  : CTChecks) {
   // FIXME: the PP callbacks skip the entire preamble.
   // Checks that want to see #includes in the main file do not see them.
-  Check->registerPPCallbacks(*Clang);
   Check->registerPPCallbacks(Clang->getSourceManager(), PP, PP);
   Check->registerMatchers();
 }
Index: clang-tools-extra/clang-tidy/ClangTidyCheck.h
===
--- clang-tools-extra/clang-tidy/ClangTidyCheck.h
+++ clang-tools-extra/clang-tidy/ClangTidyCheck.h
@@ -53,9 +53,6 @@
   /// constructor using the Options.get() methods below.
   ClangTidyCheck(StringRef CheckName, ClangTidyContext *Context);
 
-  /// DEPRECATED: Use the other overload.
-  virtual void registerPPCallbacks(CompilerInstance ) {}
-
   /// \brief Override this to register ``PPCallbacks`` in the preprocessor.
   ///
   /// This should be used for clang-tidy checks that analyze preprocessor-
Index: clang-tools-extra/clang-tidy/ClangTidy.cpp
===
--- clang-tools-extra/clang-tidy/ClangTidy.cpp
+++ clang-tools-extra/clang-tidy/ClangTidy.cpp
@@ -393,7 +393,6 @@
 
   for (auto  : Checks) {
 Check->registerMatchers(&*Finder);
-Check->registerPPCallbacks(Compiler);
 Check->registerPPCallbacks(*SM, PP, ModuleExpanderPP);
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59985: Re-fix invalid address space generation for clk_event_t arguments of enqueue_kernel builtin function

2019-04-03 Thread Alexey Sotkin via Phabricator via cfe-commits
AlexeySotkin marked an inline comment as done.
AlexeySotkin added inline comments.



Comment at: lib/CodeGen/CGBuiltin.cpp:3711
+  EventList = EventList->getType()->isIntegerTy()
+  ? Builder.CreateIntToPtr(EventList, EventPtrTy)
+  : Builder.CreatePointerCast(EventList, EventPtrTy);

AlexeySotkin wrote:
> Anastasia wrote:
> > AlexeySotkin wrote:
> > > Anastasia wrote:
> > > > It seems we are not testing the casts?
> > > Do you mean that when we run LIT tests, this code is not executed? If so, 
> > > in the modified test below, literal zeros are making clang to execute 
> > > CreateIntToPtr call indeed.
> > > Or, do you mean that we need some extra check(to make sure the cast will 
> > > be successful for example) in the source code itself ?
> > I mean since you are generating extra IR nodes we should check in the tests 
> > that they appear correctly. I don't see these casts checked in the tests 
> > currently.
> Since we are casting null constants they are folded to null values, like this 
> `%opencl.clk_event_t{{.*}}* addrspace(4)* null`.
I think `0` is the only possible integral literal, which can be given as the 
events arguments.


Repository:
  rC Clang

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

https://reviews.llvm.org/D59985



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


r357577 - Fix typos in tests. NFC.

2019-04-03 Thread Xing GUO via cfe-commits
Author: higuoxing
Date: Wed Apr  3 06:15:09 2019
New Revision: 357577

URL: http://llvm.org/viewvc/llvm-project?rev=357577=rev
Log:
Fix typos in tests. NFC.

Reviewers: Higuoxing

Reviewed By: Higuoxing

Subscribers: kubamracek, cfe-commits, #sanitizers, llvm-commits

Tags: #clang, #sanitizers, #llvm

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

Modified:
cfe/trunk/test/Analysis/analyzer-list-configs.c

Modified: cfe/trunk/test/Analysis/analyzer-list-configs.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/analyzer-list-configs.c?rev=357577=357576=357577=diff
==
--- cfe/trunk/test/Analysis/analyzer-list-configs.c (original)
+++ cfe/trunk/test/Analysis/analyzer-list-configs.c Wed Apr  3 06:15:09 2019
@@ -3,7 +3,7 @@
 //
 // CHECK: USAGE: clang -cc1 [CLANG_OPTIONS] -analyzer-config 

 //
-// CHCEK:  clang -cc1 [CLANG_OPTIONS] -analyzer-config OPTION1=VALUE, 
-analyzer-config OPTION2=VALUE, ...
+// CHECK:  clang -cc1 [CLANG_OPTIONS] -analyzer-config OPTION1=VALUE, 
-analyzer-config OPTION2=VALUE, ...
 //
 // CHECK:  clang [CLANG_OPTIONS] -Xclang -analyzer-config 
-Xclang
 //


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


<    1   2