r350696 - [X86] Make the pointer arguments to avx512 gather/scatter intrinsics 'void*' to match gcc and Intel's documentation.

2019-01-08 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Tue Jan  8 23:36:01 2019
New Revision: 350696

URL: http://llvm.org/viewvc/llvm-project?rev=350696=rev
Log:
[X86] Make the pointer arguments to avx512 gather/scatter intrinsics 'void*' to 
match gcc and Intel's documentation.

The avx2 gather intrinsics are documented to use 'int', 'long long', 'float', 
or 'double' *. So I'm leaving those. This matches gcc.

Modified:
cfe/trunk/lib/Headers/avx512fintrin.h
cfe/trunk/lib/Headers/avx512pfintrin.h
cfe/trunk/lib/Headers/avx512vlintrin.h

Modified: cfe/trunk/lib/Headers/avx512fintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=350696=350695=350696=diff
==
--- cfe/trunk/lib/Headers/avx512fintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512fintrin.h Tue Jan  8 23:36:01 2019
@@ -7630,177 +7630,177 @@ _mm512_maskz_getexp_ps (__mmask16 __U, _
 
 #define _mm512_i64gather_ps(index, addr, scale) \
   (__m256)__builtin_ia32_gatherdiv16sf((__v8sf)_mm256_undefined_ps(), \
-   (float const *)(addr), \
+   (void const *)(addr), \
(__v8di)(__m512i)(index), (__mmask8)-1, 
\
(int)(scale))
 
 #define _mm512_mask_i64gather_ps(v1_old, mask, index, addr, scale) \
   (__m256)__builtin_ia32_gatherdiv16sf((__v8sf)(__m256)(v1_old),\
-   (float const *)(addr), \
+   (void const *)(addr), \
(__v8di)(__m512i)(index), \
(__mmask8)(mask), (int)(scale))
 
 #define _mm512_i64gather_epi32(index, addr, scale) \
   (__m256i)__builtin_ia32_gatherdiv16si((__v8si)_mm256_undefined_si256(), \
-(int const *)(addr), \
+(void const *)(addr), \
 (__v8di)(__m512i)(index), \
 (__mmask8)-1, (int)(scale))
 
 #define _mm512_mask_i64gather_epi32(v1_old, mask, index, addr, scale) \
   (__m256i)__builtin_ia32_gatherdiv16si((__v8si)(__m256i)(v1_old), \
-(int const *)(addr), \
+(void const *)(addr), \
 (__v8di)(__m512i)(index), \
 (__mmask8)(mask), (int)(scale))
 
 #define _mm512_i64gather_pd(index, addr, scale) \
   (__m512d)__builtin_ia32_gatherdiv8df((__v8df)_mm512_undefined_pd(), \
-   (double const *)(addr), \
+   (void const *)(addr), \
(__v8di)(__m512i)(index), (__mmask8)-1, 
\
(int)(scale))
 
 #define _mm512_mask_i64gather_pd(v1_old, mask, index, addr, scale) \
   (__m512d)__builtin_ia32_gatherdiv8df((__v8df)(__m512d)(v1_old), \
-   (double const *)(addr), \
+   (void const *)(addr), \
(__v8di)(__m512i)(index), \
(__mmask8)(mask), (int)(scale))
 
 #define _mm512_i64gather_epi64(index, addr, scale) \
   (__m512i)__builtin_ia32_gatherdiv8di((__v8di)_mm512_undefined_epi32(), \
-   (long long const *)(addr), \
+   (void const *)(addr), \
(__v8di)(__m512i)(index), (__mmask8)-1, 
\
(int)(scale))
 
 #define _mm512_mask_i64gather_epi64(v1_old, mask, index, addr, scale) \
   (__m512i)__builtin_ia32_gatherdiv8di((__v8di)(__m512i)(v1_old), \
-   (long long const *)(addr), \
+   (void const *)(addr), \
(__v8di)(__m512i)(index), \
(__mmask8)(mask), (int)(scale))
 
 #define _mm512_i32gather_ps(index, addr, scale) \
   (__m512)__builtin_ia32_gathersiv16sf((__v16sf)_mm512_undefined_ps(), \
-   (float const *)(addr), \
+   (void const *)(addr), \
(__v16sf)(__m512)(index), \
(__mmask16)-1, (int)(scale))
 
 #define _mm512_mask_i32gather_ps(v1_old, mask, index, addr, scale) \
   (__m512)__builtin_ia32_gathersiv16sf((__v16sf)(__m512)(v1_old), \
-   (float const *)(addr), \
+   (void const *)(addr), \
(__v16sf)(__m512)(index), \
(__mmask16)(mask), (int)(scale))
 
 

[PATCH] D56466: [CodeGen] Clarify comment about COFF common symbol alignment

2019-01-08 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo accepted this revision.
mstorsjo added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rC Clang

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

https://reviews.llvm.org/D56466



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


[PATCH] D56430: Incorrect implicit data-sharing for nested tasks

2019-01-08 Thread Sergi Mateo via Phabricator via cfe-commits
smateo updated this revision to Diff 180792.
smateo added a comment.

Renaming the `isParallelRegion` function to `isImplicitTaskingRegion`.


Repository:
  rC Clang

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

https://reviews.llvm.org/D56430

Files:
  lib/Sema/SemaOpenMP.cpp
  test/OpenMP/task_messages.cpp


Index: test/OpenMP/task_messages.cpp
===
--- test/OpenMP/task_messages.cpp
+++ test/OpenMP/task_messages.cpp
@@ -8,7 +8,7 @@
 #pragma omp task // expected-error {{unexpected OpenMP directive '#pragma omp 
task'}}
 
 class S {
-  S(const S ) { a = s.a + 12; } // expected-note 14 {{implicitly declared 
private here}}
+  S(const S ) { a = s.a + 12; } // expected-note 16 {{implicitly declared 
private here}}
   int a;
 
 public:
@@ -51,6 +51,15 @@
   ++a; // expected-error {{calling a private constructor of class 'S'}}
 #pragma omp task default(shared)
 #pragma omp task
+  // expected-error@+1 {{calling a private constructor of class 'S'}}
+  ++a;
+#pragma omp parallel shared(a)
+#pragma omp task
+#pragma omp task
+  ++a;
+#pragma omp parallel shared(a)
+#pragma omp task default(shared)
+#pragma omp task
   ++a;
 #pragma omp task
 #pragma omp parallel
@@ -205,6 +214,15 @@
   ++sa; // expected-error {{calling a private constructor of class 'S'}}
 #pragma omp task default(shared)
 #pragma omp task
+  // expected-error@+1 {{calling a private constructor of class 'S'}}
+  ++sa;
+#pragma omp parallel shared(sa)
+#pragma omp task
+#pragma omp task
+  ++sa;
+#pragma omp parallel shared(sa)
+#pragma omp task default(shared)
+#pragma omp task
   ++sa;
 #pragma omp task
 #pragma omp parallel
Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -676,9 +676,13 @@
   }
 
 };
+
+bool isImplicitTaskingRegion(OpenMPDirectiveKind DKind) {
+  return isOpenMPParallelDirective(DKind) || isOpenMPTeamsDirective(DKind);
+}
+
 bool isParallelOrTaskRegion(OpenMPDirectiveKind DKind) {
-  return isOpenMPParallelDirective(DKind) || isOpenMPTaskingDirective(DKind) ||
- isOpenMPTeamsDirective(DKind) || DKind == OMPD_unknown;
+  return isImplicitTaskingRegion(DKind) || isOpenMPTaskingDirective(DKind) || 
DKind == OMPD_unknown;
 }
 
 } // namespace
@@ -819,7 +823,7 @@
   DVar.CKind = OMPC_firstprivate;
   return DVar;
 }
-  } while (I != E && !isParallelOrTaskRegion(I->Directive));
+  } while (I != E && !isImplicitTaskingRegion(I->Directive));
   DVar.CKind =
   (DVarTemp.CKind == OMPC_unknown) ? OMPC_firstprivate : OMPC_shared;
   return DVar;


Index: test/OpenMP/task_messages.cpp
===
--- test/OpenMP/task_messages.cpp
+++ test/OpenMP/task_messages.cpp
@@ -8,7 +8,7 @@
 #pragma omp task // expected-error {{unexpected OpenMP directive '#pragma omp task'}}
 
 class S {
-  S(const S ) { a = s.a + 12; } // expected-note 14 {{implicitly declared private here}}
+  S(const S ) { a = s.a + 12; } // expected-note 16 {{implicitly declared private here}}
   int a;
 
 public:
@@ -51,6 +51,15 @@
   ++a; // expected-error {{calling a private constructor of class 'S'}}
 #pragma omp task default(shared)
 #pragma omp task
+  // expected-error@+1 {{calling a private constructor of class 'S'}}
+  ++a;
+#pragma omp parallel shared(a)
+#pragma omp task
+#pragma omp task
+  ++a;
+#pragma omp parallel shared(a)
+#pragma omp task default(shared)
+#pragma omp task
   ++a;
 #pragma omp task
 #pragma omp parallel
@@ -205,6 +214,15 @@
   ++sa; // expected-error {{calling a private constructor of class 'S'}}
 #pragma omp task default(shared)
 #pragma omp task
+  // expected-error@+1 {{calling a private constructor of class 'S'}}
+  ++sa;
+#pragma omp parallel shared(sa)
+#pragma omp task
+#pragma omp task
+  ++sa;
+#pragma omp parallel shared(sa)
+#pragma omp task default(shared)
+#pragma omp task
   ++sa;
 #pragma omp task
 #pragma omp parallel
Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -676,9 +676,13 @@
   }
 
 };
+
+bool isImplicitTaskingRegion(OpenMPDirectiveKind DKind) {
+  return isOpenMPParallelDirective(DKind) || isOpenMPTeamsDirective(DKind);
+}
+
 bool isParallelOrTaskRegion(OpenMPDirectiveKind DKind) {
-  return isOpenMPParallelDirective(DKind) || isOpenMPTaskingDirective(DKind) ||
- isOpenMPTeamsDirective(DKind) || DKind == OMPD_unknown;
+  return isImplicitTaskingRegion(DKind) || isOpenMPTaskingDirective(DKind) || DKind == OMPD_unknown;
 }
 
 } // namespace
@@ -819,7 +823,7 @@
   DVar.CKind = OMPC_firstprivate;
   return DVar;
 }
-  } while (I != E && !isParallelOrTaskRegion(I->Directive));
+  } while (I != E && !isImplicitTaskingRegion(I->Directive));
   DVar.CKind =
   

Re: [PATCH] D56444: [AST] RecursiveASTVisitor visits lambda classes when implicit visitation is on.

2019-01-08 Thread Sam McCall via cfe-commits
I'll take a look at the regression, thanks.
As noted in the other review thread, the new unit test you linked is
broken: the code snippet doesn't compile (a&&), which seems to be the cause
of the crash, or at least masks it.

On Tue, Jan 8, 2019, 23:20 Jonas Toth via Phabricator <
revi...@reviews.llvm.org wrote:

> JonasToth added a comment.
>
> I still see the unit-test crashing for `ExprMutAnalyzer` (just apply these
> tests
> https://github.com/JonasToth/clang/blob/fix_crash/unittests/Analysis/ExprMutationAnalyzerTest.cpp
> and run `check-clang-unit`)
> The clang-tidy check does not crash anymore, but
> `readability-function-size` regresses. It probably doesn't properly count
> for lambdas anymore.
>
>
> Repository:
>   rC Clang
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D56444/new/
>
> https://reviews.llvm.org/D56444
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56469: [ObjC] Allow the use of implemented unavailable methods from within the @implementation context

2019-01-08 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

(This would also help with https://crbug.com/917351)


Repository:
  rC Clang

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

https://reviews.llvm.org/D56469



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


[PATCH] D56469: [ObjC] Allow the use of implemented unavailable methods from within the @implementation context

2019-01-08 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.
arphaman added a reviewer: erik.pilkington.
Herald added subscribers: cfe-commits, dexonsmith, jkorous.

In Objective-C, it's common for some frameworks to mark some methods like 
`init` as unavailable in the `@interface` to prohibit their usage.
However, these frameworks then often implemented said method and refer to it in 
another method that acts as a factory for that object. The recent change to how 
messages to `self` are type checked in clang (r349841) introduced a regression 
which started to prohibit this pattern with an `X is unavailable` error. This 
patch addresses the aforementioned regression.

rdar://47134898


Repository:
  rC Clang

https://reviews.llvm.org/D56469

Files:
  lib/Sema/SemaDeclAttr.cpp
  test/SemaObjC/call-unavailable-init-in-self.m

Index: test/SemaObjC/call-unavailable-init-in-self.m
===
--- /dev/null
+++ test/SemaObjC/call-unavailable-init-in-self.m
@@ -0,0 +1,57 @@
+// RUN: %clang_cc1 -x objective-c -verify -fobjc-arc %s
+
+@interface NSObject
+
++ (instancetype)new;
++ (instancetype)alloc;
+
+@end
+
+@interface Sub: NSObject
+
+- (instancetype)init __attribute__((unavailable)); // expected-note 4 {{'init' has been explicitly marked unavailable here}}
+
+- (void)notImplemented __attribute__((unavailable)); // expected-note {{'notImplemented' has been explicitly marked unavailable here}}
+
+@end
+
+@implementation Sub
+
++ (Sub *)create {
+  return [[self alloc] init];
+}
+
++ (Sub *)create2 {
+  return [self new];
+}
+
++ (Sub *)create3 {
+  return [Sub new];
+}
+
+- (instancetype) init {
+  return self;
+}
+
+- (void)reportUseOfUnimplemented {
+  [self notImplemented]; // expected-error {{'notImplemented' is unavailable}}
+}
+
+@end
+
+@interface SubClassContext: Sub
+@end
+
+@implementation SubClassContext
+
+- (void)subClassContext {
+  (void)[[Sub alloc] init]; // expected-error {{'init' is unavailable}}
+  (void)[Sub new]; // expected-error {{'new' is unavailable}}
+}
+
+@end
+
+void unrelatedContext() {
+  (void)[[Sub alloc] init]; // expected-error {{'init' is unavailable}}
+  (void)[Sub new]; // expected-error {{'new' is unavailable}}
+}
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -7269,9 +7269,10 @@
 /// whether we should emit a diagnostic for \c K and \c DeclVersion in
 /// the context of \c Ctx. For example, we should emit an unavailable diagnostic
 /// in a deprecated context, but not the other way around.
-static bool ShouldDiagnoseAvailabilityInContext(Sema , AvailabilityResult K,
-VersionTuple DeclVersion,
-Decl *Ctx) {
+static bool
+ShouldDiagnoseAvailabilityInContext(Sema , AvailabilityResult K,
+VersionTuple DeclVersion, Decl *Ctx,
+const NamedDecl *OffendingDecl) {
   assert(K != AR_Available && "Expected an unavailable declaration here!");
 
   // Checks if we should emit the availability diagnostic in the context of C.
@@ -7280,9 +7281,21 @@
   if (const AvailabilityAttr *AA = getAttrForPlatform(S.Context, C))
 if (AA->getIntroduced() >= DeclVersion)
   return true;
-} else if (K == AR_Deprecated)
+} else if (K == AR_Deprecated) {
   if (C->isDeprecated())
 return true;
+} else if (K == AR_Unavailable) {
+  // It is perfectly fine to refer to an 'unavailable' Objective-C method
+  // when it's actually defined and is referenced from within the
+  // @implementation itself.
+  if (const auto *MD = dyn_cast(OffendingDecl)) {
+if (const auto *Impl = dyn_cast(Ctx)) {
+  if (MD->getClassInterface() == Impl->getClassInterface() &&
+  MD->isDefined())
+return true;
+}
+  }
+}
 
 if (C->isUnavailable())
   return true;
@@ -7471,7 +7484,8 @@
   if (const AvailabilityAttr *AA = getAttrForPlatform(S.Context, OffendingDecl))
 DeclVersion = AA->getIntroduced();
 
-  if (!ShouldDiagnoseAvailabilityInContext(S, K, DeclVersion, Ctx))
+  if (!ShouldDiagnoseAvailabilityInContext(S, K, DeclVersion, Ctx,
+   OffendingDecl))
 return;
 
   SourceLocation Loc = Locs.front();
@@ -7955,7 +7969,8 @@
 
 // If the context of this function is less available than D, we should not
 // emit a diagnostic.
-if (!ShouldDiagnoseAvailabilityInContext(SemaRef, Result, Introduced, Ctx))
+if (!ShouldDiagnoseAvailabilityInContext(SemaRef, Result, Introduced, Ctx,
+ OffendingDecl))
   return;
 
 // We would like to emit the diagnostic even if -Wunguarded-availability is
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D56466: [CodeGen] Clarify comment about COFF common symbol alignment

2019-01-08 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai updated this revision to Diff 180771.
smeenai added a comment.

Refer to link.exe, and then also refer to other linkers in the second half of 
the comment to match


Repository:
  rC Clang

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

https://reviews.llvm.org/D56466

Files:
  lib/CodeGen/CodeGenModule.cpp


Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -3761,8 +3761,12 @@
   }
 }
   }
-  // COFF doesn't support alignments greater than 32, so these cannot be
-  // in common.
+
+  // Microsoft's link.exe doesn't support alignments greater than 32 for common
+  // symbols, so symbols with greater alignment requirements cannot be common.
+  // Other COFF linkers (ld.bfd and LLD) support arbitrary power-of-two
+  // alignments for common symbols via the aligncomm directive, so this
+  // restriction only applies to MSVC environments.
   if (Context.getTargetInfo().getTriple().isKnownWindowsMSVCEnvironment() &&
   Context.getTypeAlignIfKnown(D->getType()) > 32)
 return true;


Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -3761,8 +3761,12 @@
   }
 }
   }
-  // COFF doesn't support alignments greater than 32, so these cannot be
-  // in common.
+
+  // Microsoft's link.exe doesn't support alignments greater than 32 for common
+  // symbols, so symbols with greater alignment requirements cannot be common.
+  // Other COFF linkers (ld.bfd and LLD) support arbitrary power-of-two
+  // alignments for common symbols via the aligncomm directive, so this
+  // restriction only applies to MSVC environments.
   if (Context.getTargetInfo().getTriple().isKnownWindowsMSVCEnvironment() &&
   Context.getTypeAlignIfKnown(D->getType()) > 32)
 return true;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56466: [CodeGen] Clarify comment about COFF common symbol alignment

2019-01-08 Thread David Majnemer via Phabricator via cfe-commits
majnemer added inline comments.



Comment at: lib/CodeGen/CodeGenModule.cpp:3765-3766
+
+  // MSVC doesn't support alignments greater than 32 for common symbols, so
+  // symbols with greater alignment requirements cannot be common. Non-MSVC 
COFF
+  // environments support arbitrary power-of-two alignments for common symbols

I think it is most clear if this comment said "Microsoft's link.exe" instead of 
MSVC.


Repository:
  rC Clang

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

https://reviews.llvm.org/D56466



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


Re: r350643 - Limit COFF 'common' emission to <=32 alignment types.

2019-01-08 Thread Shoaib Meenai via cfe-commits
I sent out https://reviews.llvm.org/D56466 to clarify the comment accordingly.

From: David Majnemer 
Date: Tuesday, January 8, 2019 at 3:21 PM
To: Shoaib Meenai 
Cc: "Keane, Erich" , "cfe-commits@lists.llvm.org" 
, Martin Storsjo 
Subject: Re: r350643 - Limit COFF 'common' emission to <=32 alignment types.

Yes, the MinGW toolchain can handle this by specifying the alignment of a 
common symbol using the aligncomm directive. The MSVC toolchain has no such 
mechanism.

This is why the check uses isKnownWindowsMSVCEnvironment.

On Tue, Jan 8, 2019 at 1:09 PM Shoaib Meenai 
mailto:smee...@fb.com>> wrote:
It checks for both OS=Win32 and Environment=MSVC, so that wouldn't cover other 
COFF environments. wbs (Martin Storsjo) mentioned on IRC that MinGW adds an 
aligncomm directive to specify alignment for common symbols, so perhaps that's 
part of it?

From: "Keane, Erich" mailto:erich.ke...@intel.com>>
Date: Tuesday, January 8, 2019 at 1:04 PM
To: Shoaib Meenai mailto:smee...@fb.com>>, 
"cfe-commits@lists.llvm.org" 
mailto:cfe-commits@lists.llvm.org>>, David Majnemer 
mailto:david.majne...@gmail.com>>
Subject: RE: r350643 - Limit COFF 'common' emission to <=32 alignment types.

Yep, exactly.  I looked, and isKnownWindowsMSVCEnvironment checks for OS=Win32, 
which I believe would be different for other architectures.

From: Shoaib Meenai [mailto:smee...@fb.com]
Sent: Tuesday, January 8, 2019 12:41 PM
To: Keane, Erich mailto:erich.ke...@intel.com>>; 
cfe-commits@lists.llvm.org; David Majnemer 
mailto:david.majne...@gmail.com>>
Subject: Re: r350643 - Limit COFF 'common' emission to <=32 alignment types.

Ah, looks like you were originally checking for COFF, and then David suggested 
checking for MSVC instead? I'm curious about why, although I'm sure the 
suggestion is legit :)

From: cfe-commits 
mailto:cfe-commits-boun...@lists.llvm.org>> 
on behalf of Shoaib Meenai via cfe-commits 
mailto:cfe-commits@lists.llvm.org>>
Reply-To: Shoaib Meenai mailto:smee...@fb.com>>
Date: Tuesday, January 8, 2019 at 12:39 PM
To: Erich Keane mailto:erich.ke...@intel.com>>, 
"cfe-commits@lists.llvm.org" 
mailto:cfe-commits@lists.llvm.org>>
Subject: Re: r350643 - Limit COFF 'common' emission to <=32 alignment types.

Why does this check for isKnownWindowsMSVCEnvironment specifically? Wouldn't 
any COFF target (windows-cygnus, windows-gnu, windows-itanium, etc.) have the 
same limitation, since it's an object file format issue and not an ABI issue?

From: cfe-commits 
mailto:cfe-commits-boun...@lists.llvm.org>> 
on behalf of Erich Keane via cfe-commits 
mailto:cfe-commits@lists.llvm.org>>
Reply-To: Erich Keane mailto:erich.ke...@intel.com>>
Date: Tuesday, January 8, 2019 at 10:48 AM
To: "cfe-commits@lists.llvm.org" 
mailto:cfe-commits@lists.llvm.org>>
Subject: r350643 - Limit COFF 'common' emission to <=32 alignment types.

Author: erichkeane
Date: Tue Jan  8 10:44:22 2019
New Revision: 350643

URL: 
https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D350643-26view-3Drev=DwIGaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=RNVKy_b0_Wgp_PTFDpvQXETsZdWubmT5SGnGz3GigS0=Ph9GOtRaQERmqyeJeAJTFwV3sg3q8fE05FlJ3qwNx4I=
Log:
Limit COFF 'common' emission to <=32 alignment types.

As reported in PR33035, LLVM crashes if given a common object with an
alignment of greater than 32 bits. This is because the COFF file format
does not support these alignments, so emitting them is broken anyway.

This patch changes any global definitions greater than 32 bit alignment
to no longer be in 'common'.

https://urldefense.proofpoint.com/v2/url?u=https-3A__bugs.llvm.org_show-5Fbug.cgi-3Fid-3D33035=DwIGaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=RNVKy_b0_Wgp_PTFDpvQXETsZdWubmT5SGnGz3GigS0=ac1NEHuvztd6jSTCsOUJajkklfeyqdzW-xqtddJ-hvM=

Differential Revision: 
https://urldefense.proofpoint.com/v2/url?u=https-3A__reviews.llvm.org_D56391=DwIGaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=RNVKy_b0_Wgp_PTFDpvQXETsZdWubmT5SGnGz3GigS0=AucP9Sp-DYHSaOP-sPfpAOrww3xwdh8FjQkHrLZhhyo=

Change-Id: I48609289753b7f3b58c5e2bc1712756750fbd45a

Added:
cfe/trunk/test/CodeGen/microsoft-no-common-align.c
Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_lib_CodeGen_CodeGenModule.cpp-3Frev-3D350643-26r1-3D350642-26r2-3D350643-26view-3Ddiff=DwIGaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=RNVKy_b0_Wgp_PTFDpvQXETsZdWubmT5SGnGz3GigS0=gmTnEmW03ruG8LbJluf5Z4yQcxM64QP7Ce1VTnVqvPo=
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Tue Jan  8 10:44:22 2019
@@ -3761,6 +3761,11 @@ static bool 

[PATCH] D56466: [CodeGen] Clarify comment about COFF common symbol alignment

2019-01-08 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai created this revision.
smeenai added reviewers: erichkeane, majnemer, mstorsjo.

After a discussion on the commit thread, it seems the 32 byte alignment
limitation is an MSVC toolchain artifact, not an inherent COFF
restriction. Clarify the comment accordingly, since saying COFF in the
comment but using isKnownWindowsMSVCEnvironment in the conditional is
confusing. Also add a newline before the comment, which is consistent
with the local style.


Repository:
  rC Clang

https://reviews.llvm.org/D56466

Files:
  lib/CodeGen/CodeGenModule.cpp


Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -3761,8 +3761,11 @@
   }
 }
   }
-  // COFF doesn't support alignments greater than 32, so these cannot be
-  // in common.
+
+  // MSVC doesn't support alignments greater than 32 for common symbols, so
+  // symbols with greater alignment requirements cannot be common. Non-MSVC 
COFF
+  // environments support arbitrary power-of-two alignments for common symbols
+  // via the aligncomm directive, so the restriction doesn't apply there.
   if (Context.getTargetInfo().getTriple().isKnownWindowsMSVCEnvironment() &&
   Context.getTypeAlignIfKnown(D->getType()) > 32)
 return true;


Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -3761,8 +3761,11 @@
   }
 }
   }
-  // COFF doesn't support alignments greater than 32, so these cannot be
-  // in common.
+
+  // MSVC doesn't support alignments greater than 32 for common symbols, so
+  // symbols with greater alignment requirements cannot be common. Non-MSVC COFF
+  // environments support arbitrary power-of-two alignments for common symbols
+  // via the aligncomm directive, so the restriction doesn't apply there.
   if (Context.getTargetInfo().getTriple().isKnownWindowsMSVCEnvironment() &&
   Context.getTypeAlignIfKnown(D->getType()) > 32)
 return true;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56463: [SEH] Pass the frame pointer from SEH finally to finally functions

2019-01-08 Thread Sanjin Sijaric via Phabricator via cfe-commits
ssijaric created this revision.
ssijaric added reviewers: rnk, efriedma, mstorsjo, TomTan.

The following test case, compiled with -OO -target=x86_64-windows-win32, 
returns an incorrect value.  It returns 5, when it should return 9.  The 
problem is that the frame pointer that the first finally block receives is not 
passed onto the second finally block, but is regenerated using the localaddr 
intrinsic.

The test case is:

  int
  main() {
int Check = 0;
__try {
  Check = 3;
} __finally {
  __try {
Check += 2;
  } __finally {
Check += 4; 
  }
}
return Check;
  }

The code generated with "-O0 --target=x86_64-windows-win32" is:

  main:   # @main
  .seh_proc main
  # %bb.0:# %entry
subq$40, %rsp
.seh_stackalloc 40
.seh_endprologue
xorl%ecx, %ecx
  .set .Lmain$frame_escape_0, 32  < Check is at %rsp of main + 32
movl$0, 36(%rsp)
movl$0, 32(%rsp)
movl$3, 32(%rsp)
movq%rsp, %rax
movq%rax, %rdx  < main's %rsp is passed to fin$0
callq   "?fin$0@0@main@@"
movl32(%rsp), %eax
addq$40, %rsp
retq
  
  ?fin$0@0@main@@:
  subq$56, %rsp
leaq.Lmain$frame_escape_0(%rdx), %r8
movq%rdx, 48(%rsp)
movb%cl, 47(%rsp)
movl(%r8), %r9d   < Check is at %rsp of main + 32
addl$2, %r9d
movq%rsp, %rdx<  %rsp of fin$0 is passed to fin$1, should 
be %rsp of main 
movl%eax, %ecx
  callq "?fin$1@0@main@@"
  
  
  "?fin$1@0@main@@":  # @"?fin$1@0@main@@"
  # %bb.0:# %entry
subq$16, %rsp
.seh_stackalloc 16
.seh_endprologue
leaq.Lmain$frame_escape_0(%rdx), %rax
movq%rdx, 8(%rsp)
movb%cl, 7(%rsp)
movl(%rax), %r8d
addl$4, %r8d
movl%r8d, (%rax)
addq$16, %rsp
retq
.seh_handlerdata
.text

With this change, we get the following:

  "?fin$0@0@main@@":  # @"?fin$0@0@main@@"
  .seh_proc "?fin$0@0@main@@"
  # %bb.0:# %entry
subq$56, %rsp
.seh_stackalloc 56
.seh_endprologue
xorl%eax, %eax
leaq.Lmain$frame_escape_0(%rdx), %r8
movq%rdx, 48(%rsp)
movb%cl, 47(%rsp)
movl(%r8), %r9d
addl$2, %r9d
movl%r9d, (%r8)
movl%eax, %ecx
callq   "?fin$1@0@main@@"  < %rsp of main is passed in %rdx onto 
fin$1
nop
addq$56, %rsp
retq

The change assumes that no compiler generated filter function can directly 
invoke a compiler generated finally function.  I haven't been able to come up 
with a test case where this occurs.  Otherwise, the check for 
IsOutlinedSEHHelper is insufficient.   All SEH finally functions have two 
parameters, the second being the frame pointer.   This is not the case for 
filter functions, as they differ on x86 vs x86_64.


Repository:
  rC Clang

https://reviews.llvm.org/D56463

Files:
  lib/CodeGen/CGException.cpp
  test/CodeGen/exceptions-seh-nested-finally.c


Index: test/CodeGen/exceptions-seh-nested-finally.c
===
--- /dev/null
+++ test/CodeGen/exceptions-seh-nested-finally.c
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 %s -triple x86_64-pc-win32 -fms-extensions -emit-llvm -o - \
+// RUN: | FileCheck %s
+// RUN: %clang_cc1 %s -triple i686-pc-win32 -fms-extensions -emit-llvm -o - \
+// RUN: | FileCheck %s
+// RUN: %clang_cc1 %s -triple aarch64-windows -fms-extensions -emit-llvm -o - \
+// RUN: | FileCheck %s
+
+// Check that the first finally block passes the enclosing function's frame
+// pointer to the second finally block, instead of generating it via localaddr.
+
+// CHECK-LABEL: define internal void @"?fin$0@0@main@@"({{i8( zeroext)?}} 
%abnormal_termination, i8* %frame_pointer)
+// CHECK: call void @"?fin$1@0@main@@"({{i8( zeroext)?}} 0, i8* %frame_pointer)
+int
+main() {
+  int Check = 0;
+  __try {
+Check = 3;
+  } __finally {
+__try {
+  Check += 2;
+} __finally {
+  Check += 4;
+}
+  }
+  return Check;
+}
Index: lib/CodeGen/CGException.cpp
===
--- lib/CodeGen/CGException.cpp
+++ lib/CodeGen/CGException.cpp
@@ -1627,8 +1627,15 @@
 
 // Compute the two argument values.
 QualType ArgTys[2] = {Context.UnsignedCharTy, Context.VoidPtrTy};
-llvm::Value *LocalAddrFn = CGM.getIntrinsic(llvm::Intrinsic::localaddress);
-llvm::Value *FP = CGF.Builder.CreateCall(LocalAddrFn);
+llvm::Value *FP = nullptr;
+// If CFG.IsOutlinedSEHHelper is true, then we are within a finally block.
+if 

Re: [PATCH] D56215: [lld] [ELF] Include default search paths for NetBSD driver

2019-01-08 Thread Joerg Sonnenberger via cfe-commits
On Wed, Jan 09, 2019 at 12:20:06AM +, Kamil Rytarowski via Phabricator via 
llvm-commits wrote:
> krytarowski added inline comments.
> 
> 
> 
> Comment at: ELF/Driver.cpp:781
> +  }
> +}
> +
> 
> There is need to add a fallback for a native triple.

Not really. That's what the default target is.

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


[PATCH] D56215: [lld] [ELF] Include default search paths for NetBSD driver

2019-01-08 Thread Kamil Rytarowski via Phabricator via cfe-commits
krytarowski added inline comments.



Comment at: ELF/Driver.cpp:781
+  }
+}
+

There is need to add a fallback for a native triple.


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

https://reviews.llvm.org/D56215



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


[PATCH] D56438: [Modules] Allow modulemap path change for implicitly built modules

2019-01-08 Thread Yuka Takahashi via Phabricator via cfe-commits
yamaguchi added a comment.

We have both explicitly and implicitly prebuilt modules, but this patch only 
relates to implicit ones. I agree that our usecase is a bit unique where we're 
installing and distributing implicitly built pcm, but I also imagine there 
might be a usecase where you built implicit pcms in some directory and want to 
reuse them somehow from other locations. If it doesn't make sense to be 
upstream, this can stay in our fork.


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

https://reviews.llvm.org/D56438



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


[PATCH] D56438: [Modules] Allow modulemap path change for implicitly built modules

2019-01-08 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

No doubt @rsmith will have a more nuanced/accurate opinion on this than I do, 
but I would've thought the point of implicit modules is that they don't get 
moved around & it sounds like that's what this patch is suggesting/supporting, 
but maybe I haven't understood it fully?

The prebuilt PCMs you're referring to, are they built explicitly or implicitly?


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

https://reviews.llvm.org/D56438



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


Re: r336716 - Revert r336590 "[libclang] evalute compound statement cursors before trying to evaluate"

2019-01-08 Thread Alex L via cfe-commits
Fixed in r350680.

On Tue, 8 Jan 2019 at 15:24, Alex L  wrote:

> Looks like there was another leak I missed. I'm working on fixing it now.
> Cheers,
> Alex
>
> On Tue, 8 Jan 2019 at 14:38, Alex L  wrote:
>
>> Thanks for reverting the commit! Unfortunately I missed the failure back
>> then.
>> I fixed the leak and recommitted the change in r350666.
>>
>> Cheers,
>> Alex
>>
>> On Tue, 10 Jul 2018 at 12:53, Evgeniy Stepanov via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: eugenis
>>> Date: Tue Jul 10 12:49:07 2018
>>> New Revision: 336716
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=336716=rev
>>> Log:
>>> Revert r336590 "[libclang] evalute compound statement cursors before
>>> trying to evaluate"
>>>
>>> New memory leaks in
>>> LibclangParseTest_EvaluateChildExpression_Test::TestBody()
>>>
>>> Modified:
>>> cfe/trunk/tools/libclang/CIndex.cpp
>>> cfe/trunk/unittests/libclang/LibclangTest.cpp
>>>
>>> Modified: cfe/trunk/tools/libclang/CIndex.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=336716=336715=336716=diff
>>>
>>> ==
>>> --- cfe/trunk/tools/libclang/CIndex.cpp (original)
>>> +++ cfe/trunk/tools/libclang/CIndex.cpp Tue Jul 10 12:49:07 2018
>>> @@ -3890,19 +3890,6 @@ static const ExprEvalResult* evaluateExp
>>>  }
>>>
>>>  CXEvalResult clang_Cursor_Evaluate(CXCursor C) {
>>> -  if (clang_getCursorKind(C) == CXCursor_CompoundStmt) {
>>> -const CompoundStmt *compoundStmt =
>>> cast(getCursorStmt(C));
>>> -Expr *expr = nullptr;
>>> -for (auto *bodyIterator : compoundStmt->body()) {
>>> -  if ((expr = dyn_cast(bodyIterator))) {
>>> -break;
>>> -  }
>>> -}
>>> -if (expr)
>>> -  return const_cast(
>>> -  reinterpret_cast(evaluateExpr(expr, C)));
>>> -  }
>>> -
>>>const Decl *D = getCursorDecl(C);
>>>if (D) {
>>>  const Expr *expr = nullptr;
>>> @@ -3916,6 +3903,19 @@ CXEvalResult clang_Cursor_Evaluate(CXCur
>>>evaluateExpr(const_cast(expr), C)));
>>>  return nullptr;
>>>}
>>> +
>>> +  const CompoundStmt *compoundStmt =
>>> dyn_cast_or_null(getCursorStmt(C));
>>> +  if (compoundStmt) {
>>> +Expr *expr = nullptr;
>>> +for (auto *bodyIterator : compoundStmt->body()) {
>>> +  if ((expr = dyn_cast(bodyIterator))) {
>>> +break;
>>> +  }
>>> +}
>>> +if (expr)
>>> +  return const_cast(
>>> +  reinterpret_cast(evaluateExpr(expr, C)));
>>> +  }
>>>return nullptr;
>>>  }
>>>
>>>
>>> Modified: cfe/trunk/unittests/libclang/LibclangTest.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/libclang/LibclangTest.cpp?rev=336716=336715=336716=diff
>>>
>>> ==
>>> --- cfe/trunk/unittests/libclang/LibclangTest.cpp (original)
>>> +++ cfe/trunk/unittests/libclang/LibclangTest.cpp Tue Jul 10 12:49:07
>>> 2018
>>> @@ -461,47 +461,6 @@ TEST_F(LibclangParseTest, AllSkippedRang
>>>clang_disposeSourceRangeList(Ranges);
>>>  }
>>>
>>> -TEST_F(LibclangParseTest, EvaluateChildExpression) {
>>> -  std::string Main = "main.m";
>>> -  WriteFile(Main, "#define kFOO @\"foo\"\n"
>>> -  "void foobar(void) {\n"
>>> -  " {kFOO;}\n"
>>> -  "}\n");
>>> -  ClangTU = clang_parseTranslationUnit(Index, Main.c_str(), nullptr, 0,
>>> nullptr,
>>> -   0, TUFlags);
>>> -
>>> -  CXCursor C = clang_getTranslationUnitCursor(ClangTU);
>>> -  clang_visitChildren(
>>> -  C,
>>> -  [](CXCursor cursor, CXCursor parent,
>>> - CXClientData client_data) -> CXChildVisitResult {
>>> -if (clang_getCursorKind(cursor) == CXCursor_FunctionDecl) {
>>> -  int numberedStmt = 0;
>>> -  clang_visitChildren(
>>> -  cursor,
>>> -  [](CXCursor cursor, CXCursor parent,
>>> - CXClientData client_data) -> CXChildVisitResult {
>>> -int  = *((int *)client_data);
>>> -if (clang_getCursorKind(cursor) ==
>>> CXCursor_CompoundStmt) {
>>> -  if (numberedStmt) {
>>> -CXEvalResult RE = clang_Cursor_Evaluate(cursor);
>>> -EXPECT_NE(RE, nullptr);
>>> -EXPECT_EQ(clang_EvalResult_getKind(RE),
>>> -  CXEval_ObjCStrLiteral);
>>> -return CXChildVisit_Break;
>>> -  }
>>> -  numberedStmt++;
>>> -}
>>> -return CXChildVisit_Recurse;
>>> -  },
>>> -  );
>>> -  EXPECT_EQ(numberedStmt, 1);
>>> -}
>>> -return CXChildVisit_Continue;
>>> -  },
>>> -  nullptr);
>>> -}
>>> -
>>>  class LibclangReparseTest : public LibclangParseTest {
>>>  public:
>>>void DisplayDiagnostics() {
>>>
>>>
>>> 

r350680 - [libclang] Fix the mismatched delete operator for ExprEvalResult

2019-01-08 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Tue Jan  8 15:28:37 2019
New Revision: 350680

URL: http://llvm.org/viewvc/llvm-project?rev=350680=rev
Log:
[libclang] Fix the mismatched delete operator for ExprEvalResult

The '.stringVal' field in ExprEvalResult is allocated using new[],
but was freed using a regular delete. That caused memory leaks in
the test from r350666.

Modified:
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=350680=350679=350680=diff
==
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Tue Jan  8 15:28:37 2019
@@ -3694,7 +3694,7 @@ struct ExprEvalResult {
   ~ExprEvalResult() {
 if (EvalType != CXEval_UnExposed && EvalType != CXEval_Float &&
 EvalType != CXEval_Int) {
-  delete EvalData.stringVal;
+  delete[] EvalData.stringVal;
 }
   }
 };


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


[PATCH] D55488: Add utility for dumping a label with child nodes

2019-01-08 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 180754.
steveire added a comment.

Replace std::string with StringRef


Repository:
  rC Clang

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

https://reviews.llvm.org/D55488

Files:
  include/clang/AST/TextNodeDumper.h
  lib/AST/ASTDumper.cpp
  test/AST/ast-dump-stmt.cpp

Index: test/AST/ast-dump-stmt.cpp
===
--- test/AST/ast-dump-stmt.cpp
+++ test/AST/ast-dump-stmt.cpp
@@ -91,8 +91,7 @@
   U us[3] = {1};
 // CHECK: VarDecl {{.+}}  col:5 us 'U [3]' cinit
 // CHECK-NEXT: `-InitListExpr {{.+}}  'U [3]'
-// CHECK-NEXT:   |-array filler
-// CHECK-NEXT:   | `-InitListExpr {{.+}}  'U' field Field {{.+}} 'i' 'int'
+// CHECK-NEXT:   |-array_filler: InitListExpr {{.+}}  'U' field Field {{.+}} 'i' 'int'
 // CHECK-NEXT:   `-InitListExpr {{.+}}  'U' field Field {{.+}} 'i' 'int'
 // CHECK-NEXT: `-IntegerLiteral {{.+}}  'int' 1
 }
Index: lib/AST/ASTDumper.cpp
===
--- lib/AST/ASTDumper.cpp
+++ lib/AST/ASTDumper.cpp
@@ -61,6 +61,10 @@
 template void dumpChild(Fn doDumpChild) {
   NodeDumper.addChild(doDumpChild);
 }
+template 
+void dumpChild(StringRef Label, Fn doDumpChild) {
+  NodeDumper.addChild(Label, doDumpChild);
+}
 
   public:
 ASTDumper(raw_ostream , const CommandTraits *Traits,
@@ -80,7 +84,7 @@
 void setDeserialize(bool D) { Deserialize = D; }
 
 void dumpDecl(const Decl *D);
-void dumpStmt(const Stmt *S);
+void dumpStmt(const Stmt *S, StringRef Label = {});
 
 // Utilities
 void dumpType(QualType T) { NodeDumper.dumpType(T); }
@@ -1685,8 +1689,8 @@
 //  Stmt dumping methods.
 //===--===//
 
-void ASTDumper::dumpStmt(const Stmt *S) {
-  dumpChild([=] {
+void ASTDumper::dumpStmt(const Stmt *S, StringRef Label) {
+  dumpChild(Label, [=] {
 if (!S) {
   ColorScope Color(OS, ShowColors, NullColor);
   OS << "<<>>";
@@ -1957,10 +1961,7 @@
 NodeDumper.dumpBareDeclRef(Field);
   }
   if (auto *Filler = ILE->getArrayFiller()) {
-dumpChild([=] {
-  OS << "array filler";
-  dumpStmt(Filler);
-});
+dumpStmt(Filler, "array_filler");
   }
 }
 
Index: include/clang/AST/TextNodeDumper.h
===
--- include/clang/AST/TextNodeDumper.h
+++ include/clang/AST/TextNodeDumper.h
@@ -39,8 +39,16 @@
   std::string Prefix;
 
 public:
-  /// Add a child of the current node.  Calls doAddChild without arguments
-  template  void addChild(Fn doAddChild) {
+  /// Add a child of the current node.
+  /// Calls doAddChild without arguments
+  template 
+  void addChild(Fn doAddChild) {
+return addChild("", doAddChild);
+  }
+  /// Add a child of the current node with an optional label.
+  /// Calls doAddChild without arguments.
+  template 
+  void addChild(StringRef Label, Fn doAddChild) {
 // If we're at the top level, there's nothing interesting to do; just
 // run the dumper.
 if (TopLevel) {
@@ -56,7 +64,10 @@
   return;
 }
 
-auto dumpWithIndent = [this, doAddChild](bool isLastChild) {
+// We need to capture an owning-string in the lambda because the lambda 
+// is invoked in a deffered manner.
+std::string LabelStr = Label;
+auto dumpWithIndent = [this, doAddChild, LabelStr](bool isLastChild) {
   // Print out the appropriate tree structure and work out the prefix for
   // children of this node. For instance:
   //
@@ -73,6 +84,10 @@
 OS << '\n';
 ColorScope Color(OS, ShowColors, IndentColor);
 OS << Prefix << (isLastChild ? '`' : '|') << '-';
+if (!LabelStr.empty()) {
+  OS << LabelStr << ": ";
+}
+
 this->Prefix.push_back(isLastChild ? ' ' : '|');
 this->Prefix.push_back(' ');
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r336716 - Revert r336590 "[libclang] evalute compound statement cursors before trying to evaluate"

2019-01-08 Thread Alex L via cfe-commits
Looks like there was another leak I missed. I'm working on fixing it now.
Cheers,
Alex

On Tue, 8 Jan 2019 at 14:38, Alex L  wrote:

> Thanks for reverting the commit! Unfortunately I missed the failure back
> then.
> I fixed the leak and recommitted the change in r350666.
>
> Cheers,
> Alex
>
> On Tue, 10 Jul 2018 at 12:53, Evgeniy Stepanov via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: eugenis
>> Date: Tue Jul 10 12:49:07 2018
>> New Revision: 336716
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=336716=rev
>> Log:
>> Revert r336590 "[libclang] evalute compound statement cursors before
>> trying to evaluate"
>>
>> New memory leaks in
>> LibclangParseTest_EvaluateChildExpression_Test::TestBody()
>>
>> Modified:
>> cfe/trunk/tools/libclang/CIndex.cpp
>> cfe/trunk/unittests/libclang/LibclangTest.cpp
>>
>> Modified: cfe/trunk/tools/libclang/CIndex.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=336716=336715=336716=diff
>>
>> ==
>> --- cfe/trunk/tools/libclang/CIndex.cpp (original)
>> +++ cfe/trunk/tools/libclang/CIndex.cpp Tue Jul 10 12:49:07 2018
>> @@ -3890,19 +3890,6 @@ static const ExprEvalResult* evaluateExp
>>  }
>>
>>  CXEvalResult clang_Cursor_Evaluate(CXCursor C) {
>> -  if (clang_getCursorKind(C) == CXCursor_CompoundStmt) {
>> -const CompoundStmt *compoundStmt =
>> cast(getCursorStmt(C));
>> -Expr *expr = nullptr;
>> -for (auto *bodyIterator : compoundStmt->body()) {
>> -  if ((expr = dyn_cast(bodyIterator))) {
>> -break;
>> -  }
>> -}
>> -if (expr)
>> -  return const_cast(
>> -  reinterpret_cast(evaluateExpr(expr, C)));
>> -  }
>> -
>>const Decl *D = getCursorDecl(C);
>>if (D) {
>>  const Expr *expr = nullptr;
>> @@ -3916,6 +3903,19 @@ CXEvalResult clang_Cursor_Evaluate(CXCur
>>evaluateExpr(const_cast(expr), C)));
>>  return nullptr;
>>}
>> +
>> +  const CompoundStmt *compoundStmt =
>> dyn_cast_or_null(getCursorStmt(C));
>> +  if (compoundStmt) {
>> +Expr *expr = nullptr;
>> +for (auto *bodyIterator : compoundStmt->body()) {
>> +  if ((expr = dyn_cast(bodyIterator))) {
>> +break;
>> +  }
>> +}
>> +if (expr)
>> +  return const_cast(
>> +  reinterpret_cast(evaluateExpr(expr, C)));
>> +  }
>>return nullptr;
>>  }
>>
>>
>> Modified: cfe/trunk/unittests/libclang/LibclangTest.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/libclang/LibclangTest.cpp?rev=336716=336715=336716=diff
>>
>> ==
>> --- cfe/trunk/unittests/libclang/LibclangTest.cpp (original)
>> +++ cfe/trunk/unittests/libclang/LibclangTest.cpp Tue Jul 10 12:49:07 2018
>> @@ -461,47 +461,6 @@ TEST_F(LibclangParseTest, AllSkippedRang
>>clang_disposeSourceRangeList(Ranges);
>>  }
>>
>> -TEST_F(LibclangParseTest, EvaluateChildExpression) {
>> -  std::string Main = "main.m";
>> -  WriteFile(Main, "#define kFOO @\"foo\"\n"
>> -  "void foobar(void) {\n"
>> -  " {kFOO;}\n"
>> -  "}\n");
>> -  ClangTU = clang_parseTranslationUnit(Index, Main.c_str(), nullptr, 0,
>> nullptr,
>> -   0, TUFlags);
>> -
>> -  CXCursor C = clang_getTranslationUnitCursor(ClangTU);
>> -  clang_visitChildren(
>> -  C,
>> -  [](CXCursor cursor, CXCursor parent,
>> - CXClientData client_data) -> CXChildVisitResult {
>> -if (clang_getCursorKind(cursor) == CXCursor_FunctionDecl) {
>> -  int numberedStmt = 0;
>> -  clang_visitChildren(
>> -  cursor,
>> -  [](CXCursor cursor, CXCursor parent,
>> - CXClientData client_data) -> CXChildVisitResult {
>> -int  = *((int *)client_data);
>> -if (clang_getCursorKind(cursor) ==
>> CXCursor_CompoundStmt) {
>> -  if (numberedStmt) {
>> -CXEvalResult RE = clang_Cursor_Evaluate(cursor);
>> -EXPECT_NE(RE, nullptr);
>> -EXPECT_EQ(clang_EvalResult_getKind(RE),
>> -  CXEval_ObjCStrLiteral);
>> -return CXChildVisit_Break;
>> -  }
>> -  numberedStmt++;
>> -}
>> -return CXChildVisit_Recurse;
>> -  },
>> -  );
>> -  EXPECT_EQ(numberedStmt, 1);
>> -}
>> -return CXChildVisit_Continue;
>> -  },
>> -  nullptr);
>> -}
>> -
>>  class LibclangReparseTest : public LibclangParseTest {
>>  public:
>>void DisplayDiagnostics() {
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
___

Re: r350643 - Limit COFF 'common' emission to <=32 alignment types.

2019-01-08 Thread David Majnemer via cfe-commits
Yes, the MinGW toolchain can handle this by specifying the alignment of a
common symbol using the aligncomm directive. The MSVC toolchain has no such
mechanism.

This is why the check uses isKnownWindowsMSVCEnvironment.

On Tue, Jan 8, 2019 at 1:09 PM Shoaib Meenai  wrote:

> It checks for both OS=Win32 and Environment=MSVC, so that wouldn't cover
> other COFF environments. wbs (Martin Storsjo) mentioned on IRC that MinGW
> adds an aligncomm directive to specify alignment for common symbols, so
> perhaps that's part of it?
>
>
>
> *From: *"Keane, Erich" 
> *Date: *Tuesday, January 8, 2019 at 1:04 PM
> *To: *Shoaib Meenai , "cfe-commits@lists.llvm.org" <
> cfe-commits@lists.llvm.org>, David Majnemer 
> *Subject: *RE: r350643 - Limit COFF 'common' emission to <=32 alignment
> types.
>
>
>
> Yep, exactly.  I looked, and isKnownWindowsMSVCEnvironment checks for
> OS=Win32, which I believe would be different for other architectures.
>
>
>
> *From:* Shoaib Meenai [mailto:smee...@fb.com]
> *Sent:* Tuesday, January 8, 2019 12:41 PM
> *To:* Keane, Erich ; cfe-commits@lists.llvm.org;
> David Majnemer 
> *Subject:* Re: r350643 - Limit COFF 'common' emission to <=32 alignment
> types.
>
>
>
> Ah, looks like you were originally checking for COFF, and then David
> suggested checking for MSVC instead? I'm curious about why, although I'm
> sure the suggestion is legit :)
>
>
>
> *From: *cfe-commits  on behalf of
> Shoaib Meenai via cfe-commits 
> *Reply-To: *Shoaib Meenai 
> *Date: *Tuesday, January 8, 2019 at 12:39 PM
> *To: *Erich Keane , "cfe-commits@lists.llvm.org" <
> cfe-commits@lists.llvm.org>
> *Subject: *Re: r350643 - Limit COFF 'common' emission to <=32 alignment
> types.
>
>
>
> Why does this check for isKnownWindowsMSVCEnvironment specifically?
> Wouldn't any COFF target (windows-cygnus, windows-gnu, windows-itanium,
> etc.) have the same limitation, since it's an object file format issue and
> not an ABI issue?
>
>
>
> *From: *cfe-commits  on behalf of
> Erich Keane via cfe-commits 
> *Reply-To: *Erich Keane 
> *Date: *Tuesday, January 8, 2019 at 10:48 AM
> *To: *"cfe-commits@lists.llvm.org" 
> *Subject: *r350643 - Limit COFF 'common' emission to <=32 alignment types.
>
>
>
> Author: erichkeane
>
> Date: Tue Jan  8 10:44:22 2019
>
> New Revision: 350643
>
>
>
> URL:
> https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D350643-26view-3Drev=DwIGaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=RNVKy_b0_Wgp_PTFDpvQXETsZdWubmT5SGnGz3GigS0=Ph9GOtRaQERmqyeJeAJTFwV3sg3q8fE05FlJ3qwNx4I=
>
> Log:
>
> Limit COFF 'common' emission to <=32 alignment types.
>
>
>
> As reported in PR33035, LLVM crashes if given a common object with an
>
> alignment of greater than 32 bits. This is because the COFF file format
>
> does not support these alignments, so emitting them is broken anyway.
>
>
>
> This patch changes any global definitions greater than 32 bit alignment
>
> to no longer be in 'common'.
>
>
>
>
> https://urldefense.proofpoint.com/v2/url?u=https-3A__bugs.llvm.org_show-5Fbug.cgi-3Fid-3D33035=DwIGaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=RNVKy_b0_Wgp_PTFDpvQXETsZdWubmT5SGnGz3GigS0=ac1NEHuvztd6jSTCsOUJajkklfeyqdzW-xqtddJ-hvM=
>
>
>
> Differential Revision:
> https://urldefense.proofpoint.com/v2/url?u=https-3A__reviews.llvm.org_D56391=DwIGaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=RNVKy_b0_Wgp_PTFDpvQXETsZdWubmT5SGnGz3GigS0=AucP9Sp-DYHSaOP-sPfpAOrww3xwdh8FjQkHrLZhhyo=
>
>
>
> Change-Id: I48609289753b7f3b58c5e2bc1712756750fbd45a
>
>
>
> Added:
>
> cfe/trunk/test/CodeGen/microsoft-no-common-align.c
>
> Modified:
>
> cfe/trunk/lib/CodeGen/CodeGenModule.cpp
>
>
>
> Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
>
> URL:
> https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_lib_CodeGen_CodeGenModule.cpp-3Frev-3D350643-26r1-3D350642-26r2-3D350643-26view-3Ddiff=DwIGaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=RNVKy_b0_Wgp_PTFDpvQXETsZdWubmT5SGnGz3GigS0=gmTnEmW03ruG8LbJluf5Z4yQcxM64QP7Ce1VTnVqvPo=
>
>
> ==
>
> --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
>
> +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Tue Jan  8 10:44:22 2019
>
> @@ -3761,6 +3761,11 @@ static bool isVarDeclStrongDefinition(co
>
>}
>
>  }
>
>}
>
> +  // COFF doesn't support alignments greater than 32, so these cannot be
>
> +  // in common.
>
> +  if (Context.getTargetInfo().getTriple().isKnownWindowsMSVCEnvironment()
> &&
>
> +  Context.getTypeAlignIfKnown(D->getType()) > 32)
>
> +return true;
>
>return false;
>
> }
>
>
>
> Added: cfe/trunk/test/CodeGen/microsoft-no-common-align.c
>
> URL:
> 

[PATCH] D55337: NFC: Move dumpDeclRef to NodeDumper

2019-01-08 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC350677: [ASTDump] NFC: Move dumpDeclRef to NodeDumper 
(authored by steveire, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D55337?vs=177670=180752#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D55337

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

Index: lib/AST/ASTDumper.cpp
===
--- lib/AST/ASTDumper.cpp
+++ lib/AST/ASTDumper.cpp
@@ -86,7 +86,6 @@
 void dumpType(QualType T) { NodeDumper.dumpType(T); }
 void dumpTypeAsChild(QualType T);
 void dumpTypeAsChild(const Type *T);
-void dumpDeclRef(const Decl *Node, const char *Label = nullptr);
 void dumpBareDeclRef(const Decl *Node) { NodeDumper.dumpBareDeclRef(Node); }
 void dumpDeclContext(const DeclContext *DC);
 void dumpLookups(const DeclContext *DC, bool DumpDecls);
@@ -215,10 +214,10 @@
 dumpChild([=] { OS << "..."; });
 }
 void VisitUnresolvedUsingType(const UnresolvedUsingType *T) {
-  dumpDeclRef(T->getDecl());
+  NodeDumper.dumpDeclRef(T->getDecl());
 }
 void VisitTypedefType(const TypedefType *T) {
-  dumpDeclRef(T->getDecl());
+  NodeDumper.dumpDeclRef(T->getDecl());
 }
 void VisitTypeOfExprType(const TypeOfExprType *T) {
   dumpStmt(T->getUnderlyingExpr());
@@ -235,7 +234,7 @@
   dumpTypeAsChild(T->getBaseType());
 }
 void VisitTagType(const TagType *T) {
-  dumpDeclRef(T->getDecl());
+  NodeDumper.dumpDeclRef(T->getDecl());
 }
 void VisitAttributedType(const AttributedType *T) {
   // FIXME: AttrKind
@@ -244,7 +243,7 @@
 void VisitTemplateTypeParmType(const TemplateTypeParmType *T) {
   OS << " depth " << T->getDepth() << " index " << T->getIndex();
   if (T->isParameterPack()) OS << " pack";
-  dumpDeclRef(T->getDecl());
+  NodeDumper.dumpDeclRef(T->getDecl());
 }
 void VisitSubstTemplateTypeParmType(const SubstTemplateTypeParmType *T) {
   dumpTypeAsChild(T->getReplacedParameter());
@@ -268,10 +267,10 @@
 dumpTypeAsChild(T->getAliasedType());
 }
 void VisitInjectedClassNameType(const InjectedClassNameType *T) {
-  dumpDeclRef(T->getDecl());
+  NodeDumper.dumpDeclRef(T->getDecl());
 }
 void VisitObjCInterfaceType(const ObjCInterfaceType *T) {
-  dumpDeclRef(T->getDecl());
+  NodeDumper.dumpDeclRef(T->getDecl());
 }
 void VisitObjCObjectPointerType(const ObjCObjectPointerType *T) {
   dumpTypeAsChild(T->getPointeeType());
@@ -506,17 +505,6 @@
   });
 }
 
-void ASTDumper::dumpDeclRef(const Decl *D, const char *Label) {
-  if (!D)
-return;
-
-  dumpChild([=]{
-if (Label)
-  OS << Label << ' ';
-dumpBareDeclRef(D);
-  });
-}
-
 void ASTDumper::dumpDeclContext(const DeclContext *DC) {
   if (!DC)
 return;
@@ -695,7 +683,7 @@
   NodeDumper.dumpSourceRange(R);
 
 if (From)
-  dumpDeclRef(From, Label);
+  NodeDumper.dumpDeclRef(From, Label);
 
 switch (A.getKind()) {
 case TemplateArgument::Null:
@@ -707,7 +695,7 @@
   break;
 case TemplateArgument::Declaration:
   OS << " decl";
-  dumpDeclRef(A.getAsDecl());
+  NodeDumper.dumpDeclRef(A.getAsDecl());
   break;
 case TemplateArgument::NullPtr:
   OS << " nullptr";
@@ -863,7 +851,7 @@
   NodeDumper.dumpType(D->getType());
 
   for (auto *Child : D->chain())
-dumpDeclRef(Child);
+NodeDumper.dumpDeclRef(Child);
 }
 
 void ASTDumper::VisitFunctionDecl(const FunctionDecl *D) {
@@ -1105,7 +1093,7 @@
   if (D->isInline())
 OS << " inline";
   if (!D->isOriginalNamespace())
-dumpDeclRef(D->getOriginalNamespace(), "original");
+NodeDumper.dumpDeclRef(D->getOriginalNamespace(), "original");
 }
 
 void ASTDumper::VisitUsingDirectiveDecl(const UsingDirectiveDecl *D) {
@@ -1115,7 +1103,7 @@
 
 void ASTDumper::VisitNamespaceAliasDecl(const NamespaceAliasDecl *D) {
   NodeDumper.dumpName(D);
-  dumpDeclRef(D->getAliasedNamespace());
+  NodeDumper.dumpDeclRef(D->getAliasedNamespace());
 }
 
 void ASTDumper::VisitTypeAliasDecl(const TypeAliasDecl *D) {
@@ -1301,7 +1289,7 @@
 case TSK_Undeclared:
 case TSK_ImplicitInstantiation:
   if (DumpRefOnly)
-dumpDeclRef(Redecl);
+NodeDumper.dumpDeclRef(Redecl);
   else
 dumpDecl(Redecl);
   DumpedAny = true;
@@ -1313,7 +1301,7 @@
 
   // Ensure we dump at least one decl for each specialization.
   if (!DumpedAny)
-dumpDeclRef(D);
+NodeDumper.dumpDeclRef(D);
 }
 
 template 
@@ -1568,42 +1556,42 @@
 
 void ASTDumper::VisitObjCCategoryDecl(const ObjCCategoryDecl *D) {
   NodeDumper.dumpName(D);
-  dumpDeclRef(D->getClassInterface());
+  NodeDumper.dumpDeclRef(D->getClassInterface());
   dumpObjCTypeParamList(D->getTypeParamList());
-  

r350677 - [ASTDump] NFC: Move dumpDeclRef to NodeDumper

2019-01-08 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Tue Jan  8 15:11:24 2019
New Revision: 350677

URL: http://llvm.org/viewvc/llvm-project?rev=350677=rev
Log:
[ASTDump] NFC: Move dumpDeclRef to NodeDumper

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

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

Modified: cfe/trunk/include/clang/AST/TextNodeDumper.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TextNodeDumper.h?rev=350677=350676=350677=diff
==
--- cfe/trunk/include/clang/AST/TextNodeDumper.h (original)
+++ cfe/trunk/include/clang/AST/TextNodeDumper.h Tue Jan  8 15:11:24 2019
@@ -107,9 +107,9 @@ public:
 };
 
 class TextNodeDumper
-: public comments::ConstCommentVisitor,
-  public TextTreeStructure {
+: public TextTreeStructure,
+  public comments::ConstCommentVisitor {
   raw_ostream 
   const bool ShowColors;
 
@@ -144,6 +144,8 @@ public:
   void dumpAccessSpecifier(AccessSpecifier AS);
   void dumpCXXTemporary(const CXXTemporary *Temporary);
 
+  void dumpDeclRef(const Decl *D, const char *Label = nullptr);
+
   void visitTextComment(const comments::TextComment *C,
 const comments::FullComment *);
   void visitInlineCommandComment(const comments::InlineCommandComment *C,

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=350677=350676=350677=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Tue Jan  8 15:11:24 2019
@@ -86,7 +86,6 @@ namespace  {
 void dumpType(QualType T) { NodeDumper.dumpType(T); }
 void dumpTypeAsChild(QualType T);
 void dumpTypeAsChild(const Type *T);
-void dumpDeclRef(const Decl *Node, const char *Label = nullptr);
 void dumpBareDeclRef(const Decl *Node) { NodeDumper.dumpBareDeclRef(Node); 
}
 void dumpDeclContext(const DeclContext *DC);
 void dumpLookups(const DeclContext *DC, bool DumpDecls);
@@ -215,10 +214,10 @@ namespace  {
 dumpChild([=] { OS << "..."; });
 }
 void VisitUnresolvedUsingType(const UnresolvedUsingType *T) {
-  dumpDeclRef(T->getDecl());
+  NodeDumper.dumpDeclRef(T->getDecl());
 }
 void VisitTypedefType(const TypedefType *T) {
-  dumpDeclRef(T->getDecl());
+  NodeDumper.dumpDeclRef(T->getDecl());
 }
 void VisitTypeOfExprType(const TypeOfExprType *T) {
   dumpStmt(T->getUnderlyingExpr());
@@ -235,7 +234,7 @@ namespace  {
   dumpTypeAsChild(T->getBaseType());
 }
 void VisitTagType(const TagType *T) {
-  dumpDeclRef(T->getDecl());
+  NodeDumper.dumpDeclRef(T->getDecl());
 }
 void VisitAttributedType(const AttributedType *T) {
   // FIXME: AttrKind
@@ -244,7 +243,7 @@ namespace  {
 void VisitTemplateTypeParmType(const TemplateTypeParmType *T) {
   OS << " depth " << T->getDepth() << " index " << T->getIndex();
   if (T->isParameterPack()) OS << " pack";
-  dumpDeclRef(T->getDecl());
+  NodeDumper.dumpDeclRef(T->getDecl());
 }
 void VisitSubstTemplateTypeParmType(const SubstTemplateTypeParmType *T) {
   dumpTypeAsChild(T->getReplacedParameter());
@@ -268,10 +267,10 @@ namespace  {
 dumpTypeAsChild(T->getAliasedType());
 }
 void VisitInjectedClassNameType(const InjectedClassNameType *T) {
-  dumpDeclRef(T->getDecl());
+  NodeDumper.dumpDeclRef(T->getDecl());
 }
 void VisitObjCInterfaceType(const ObjCInterfaceType *T) {
-  dumpDeclRef(T->getDecl());
+  NodeDumper.dumpDeclRef(T->getDecl());
 }
 void VisitObjCObjectPointerType(const ObjCObjectPointerType *T) {
   dumpTypeAsChild(T->getPointeeType());
@@ -506,17 +505,6 @@ void ASTDumper::dumpTypeAsChild(const Ty
   });
 }
 
-void ASTDumper::dumpDeclRef(const Decl *D, const char *Label) {
-  if (!D)
-return;
-
-  dumpChild([=]{
-if (Label)
-  OS << Label << ' ';
-dumpBareDeclRef(D);
-  });
-}
-
 void ASTDumper::dumpDeclContext(const DeclContext *DC) {
   if (!DC)
 return;
@@ -695,7 +683,7 @@ void ASTDumper::dumpTemplateArgument(con
   NodeDumper.dumpSourceRange(R);
 
 if (From)
-  dumpDeclRef(From, Label);
+  NodeDumper.dumpDeclRef(From, Label);
 
 switch (A.getKind()) {
 case TemplateArgument::Null:
@@ -707,7 +695,7 @@ void ASTDumper::dumpTemplateArgument(con
   break;
 case TemplateArgument::Declaration:
   OS << " decl";
-  dumpDeclRef(A.getAsDecl());
+  NodeDumper.dumpDeclRef(A.getAsDecl());
   break;
 case TemplateArgument::NullPtr:
   OS << " nullptr";
@@ -863,7 +851,7 @@ void ASTDumper::VisitIndirectFieldDecl(c
   NodeDumper.dumpType(D->getType());
 
   for (auto *Child : D->chain())
-

Re: [PATCH] D56215: [lld] [ELF] Include default search paths for NetBSD driver

2019-01-08 Thread Joerg Sonnenberger via cfe-commits
On Tue, Jan 08, 2019 at 10:58:37PM +, Alexander Richardson via Phabricator 
via cfe-commits wrote:
> arichardson added inline comments.
> 
> 
> 
> Comment at: ELF/Driver.cpp:770
> +  // Start with a default initial triple
> +  Config->TargetTriple = llvm::Triple(getDefaultTargetTriple());
> +
> 
> If I invoke an unprefixed ld.lld on NetBSD but want to target a
> different operating system, this will cause all the NetBSD defaults to
> apply to that binary and will possibly cause it to crash at runtime.

...which no different from clang.

> I think any config changes based on a triple would need to use an
> explicit --target= flag instead. As @ruiu says, LLD's behaviour should
> not change depending on the host OS/default LLVM triple. Given the same
> input files and command line options the resulting binary should be
> identical on any host.

That boils down to either "lld is unusable out of the box" or "your
system must look similar enough to a GNU/Linux environment for lld to
work". I don't consider that useful behavior at all.

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


[PATCH] D56215: [lld] [ELF] Include default search paths for NetBSD driver

2019-01-08 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson added inline comments.



Comment at: ELF/Driver.cpp:770
+  // Start with a default initial triple
+  Config->TargetTriple = llvm::Triple(getDefaultTargetTriple());
+

If I invoke an unprefixed ld.lld on NetBSD but want to target a different 
operating system, this will cause all the NetBSD defaults to apply to that 
binary and will possibly cause it to crash at runtime.

I think any config changes based on a triple would need to use an explicit 
--target= flag instead. As @ruiu says, LLD's behaviour should not change 
depending on the host OS/default LLVM triple. Given the same input files and 
command line options the resulting binary should be identical on any host.


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

https://reviews.llvm.org/D56215



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


Re: r336716 - Revert r336590 "[libclang] evalute compound statement cursors before trying to evaluate"

2019-01-08 Thread Alex L via cfe-commits
Thanks for reverting the commit! Unfortunately I missed the failure back
then.
I fixed the leak and recommitted the change in r350666.

Cheers,
Alex

On Tue, 10 Jul 2018 at 12:53, Evgeniy Stepanov via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: eugenis
> Date: Tue Jul 10 12:49:07 2018
> New Revision: 336716
>
> URL: http://llvm.org/viewvc/llvm-project?rev=336716=rev
> Log:
> Revert r336590 "[libclang] evalute compound statement cursors before
> trying to evaluate"
>
> New memory leaks in
> LibclangParseTest_EvaluateChildExpression_Test::TestBody()
>
> Modified:
> cfe/trunk/tools/libclang/CIndex.cpp
> cfe/trunk/unittests/libclang/LibclangTest.cpp
>
> Modified: cfe/trunk/tools/libclang/CIndex.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=336716=336715=336716=diff
>
> ==
> --- cfe/trunk/tools/libclang/CIndex.cpp (original)
> +++ cfe/trunk/tools/libclang/CIndex.cpp Tue Jul 10 12:49:07 2018
> @@ -3890,19 +3890,6 @@ static const ExprEvalResult* evaluateExp
>  }
>
>  CXEvalResult clang_Cursor_Evaluate(CXCursor C) {
> -  if (clang_getCursorKind(C) == CXCursor_CompoundStmt) {
> -const CompoundStmt *compoundStmt =
> cast(getCursorStmt(C));
> -Expr *expr = nullptr;
> -for (auto *bodyIterator : compoundStmt->body()) {
> -  if ((expr = dyn_cast(bodyIterator))) {
> -break;
> -  }
> -}
> -if (expr)
> -  return const_cast(
> -  reinterpret_cast(evaluateExpr(expr, C)));
> -  }
> -
>const Decl *D = getCursorDecl(C);
>if (D) {
>  const Expr *expr = nullptr;
> @@ -3916,6 +3903,19 @@ CXEvalResult clang_Cursor_Evaluate(CXCur
>evaluateExpr(const_cast(expr), C)));
>  return nullptr;
>}
> +
> +  const CompoundStmt *compoundStmt =
> dyn_cast_or_null(getCursorStmt(C));
> +  if (compoundStmt) {
> +Expr *expr = nullptr;
> +for (auto *bodyIterator : compoundStmt->body()) {
> +  if ((expr = dyn_cast(bodyIterator))) {
> +break;
> +  }
> +}
> +if (expr)
> +  return const_cast(
> +  reinterpret_cast(evaluateExpr(expr, C)));
> +  }
>return nullptr;
>  }
>
>
> Modified: cfe/trunk/unittests/libclang/LibclangTest.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/libclang/LibclangTest.cpp?rev=336716=336715=336716=diff
>
> ==
> --- cfe/trunk/unittests/libclang/LibclangTest.cpp (original)
> +++ cfe/trunk/unittests/libclang/LibclangTest.cpp Tue Jul 10 12:49:07 2018
> @@ -461,47 +461,6 @@ TEST_F(LibclangParseTest, AllSkippedRang
>clang_disposeSourceRangeList(Ranges);
>  }
>
> -TEST_F(LibclangParseTest, EvaluateChildExpression) {
> -  std::string Main = "main.m";
> -  WriteFile(Main, "#define kFOO @\"foo\"\n"
> -  "void foobar(void) {\n"
> -  " {kFOO;}\n"
> -  "}\n");
> -  ClangTU = clang_parseTranslationUnit(Index, Main.c_str(), nullptr, 0,
> nullptr,
> -   0, TUFlags);
> -
> -  CXCursor C = clang_getTranslationUnitCursor(ClangTU);
> -  clang_visitChildren(
> -  C,
> -  [](CXCursor cursor, CXCursor parent,
> - CXClientData client_data) -> CXChildVisitResult {
> -if (clang_getCursorKind(cursor) == CXCursor_FunctionDecl) {
> -  int numberedStmt = 0;
> -  clang_visitChildren(
> -  cursor,
> -  [](CXCursor cursor, CXCursor parent,
> - CXClientData client_data) -> CXChildVisitResult {
> -int  = *((int *)client_data);
> -if (clang_getCursorKind(cursor) == CXCursor_CompoundStmt)
> {
> -  if (numberedStmt) {
> -CXEvalResult RE = clang_Cursor_Evaluate(cursor);
> -EXPECT_NE(RE, nullptr);
> -EXPECT_EQ(clang_EvalResult_getKind(RE),
> -  CXEval_ObjCStrLiteral);
> -return CXChildVisit_Break;
> -  }
> -  numberedStmt++;
> -}
> -return CXChildVisit_Recurse;
> -  },
> -  );
> -  EXPECT_EQ(numberedStmt, 1);
> -}
> -return CXChildVisit_Continue;
> -  },
> -  nullptr);
> -}
> -
>  class LibclangReparseTest : public LibclangParseTest {
>  public:
>void DisplayDiagnostics() {
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56456: [Driver] Default to -fno-addrsig on Android.

2019-01-08 Thread Dan Albert via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL350668: [Driver] Default to -fno-addrsig on Android. 
(authored by danalbert, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D56456

Files:
  cfe/trunk/lib/Driver/ToolChains/Clang.cpp
  cfe/trunk/test/Driver/addrsig.c


Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp
@@ -5292,6 +5292,7 @@
   !TC.getTriple().isPS4() &&
   !TC.getTriple().isOSNetBSD() &&
   !Distro(D.getVFS()).IsGentoo() &&
+  !TC.getTriple().isAndroid() &&
TC.useIntegratedAs()))
 CmdArgs.push_back("-faddrsig");
 
Index: cfe/trunk/test/Driver/addrsig.c
===
--- cfe/trunk/test/Driver/addrsig.c
+++ cfe/trunk/test/Driver/addrsig.c
@@ -8,6 +8,7 @@
 // RUN: %clang -### -target x86_64-unknown-linux -fno-addrsig -c %s 2>&1 | 
FileCheck -check-prefix=NO-ADDRSIG %s
 // RUN: %clang -### -target x86_64-apple-darwin -c %s 2>&1 | FileCheck 
-check-prefix=NO-ADDRSIG %s
 // RUN: %clang -### -target x86_64-scei-ps4 -c %s 2>&1 | FileCheck 
-check-prefix=NO-ADDRSIG %s
+// RUN: %clang -### -target x86_64-linux-android21 -c %s 2>&1 | FileCheck 
-check-prefix=NO-ADDRSIG %s
 
 // ADDRSIG: -faddrsig
 // NO-ADDRSIG-NOT: -faddrsig


Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp
@@ -5292,6 +5292,7 @@
   !TC.getTriple().isPS4() &&
   !TC.getTriple().isOSNetBSD() &&
   !Distro(D.getVFS()).IsGentoo() &&
+  !TC.getTriple().isAndroid() &&
TC.useIntegratedAs()))
 CmdArgs.push_back("-faddrsig");
 
Index: cfe/trunk/test/Driver/addrsig.c
===
--- cfe/trunk/test/Driver/addrsig.c
+++ cfe/trunk/test/Driver/addrsig.c
@@ -8,6 +8,7 @@
 // RUN: %clang -### -target x86_64-unknown-linux -fno-addrsig -c %s 2>&1 | FileCheck -check-prefix=NO-ADDRSIG %s
 // RUN: %clang -### -target x86_64-apple-darwin -c %s 2>&1 | FileCheck -check-prefix=NO-ADDRSIG %s
 // RUN: %clang -### -target x86_64-scei-ps4 -c %s 2>&1 | FileCheck -check-prefix=NO-ADDRSIG %s
+// RUN: %clang -### -target x86_64-linux-android21 -c %s 2>&1 | FileCheck -check-prefix=NO-ADDRSIG %s
 
 // ADDRSIG: -faddrsig
 // NO-ADDRSIG-NOT: -faddrsig
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r350668 - [Driver] Default to -fno-addrsig on Android.

2019-01-08 Thread Dan Albert via cfe-commits
Author: danalbert
Date: Tue Jan  8 14:33:59 2019
New Revision: 350668

URL: http://llvm.org/viewvc/llvm-project?rev=350668=rev
Log:
[Driver] Default to -fno-addrsig on Android.

Summary: The Android NDK still uses GNU binutils by default.

Reviewers: srhines, pirama

Reviewed By: srhines

Subscribers: cfe-commits

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

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

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=350668=350667=350668=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Tue Jan  8 14:33:59 2019
@@ -5292,6 +5292,7 @@ void Clang::ConstructJob(Compilation ,
   !TC.getTriple().isPS4() &&
   !TC.getTriple().isOSNetBSD() &&
   !Distro(D.getVFS()).IsGentoo() &&
+  !TC.getTriple().isAndroid() &&
TC.useIntegratedAs()))
 CmdArgs.push_back("-faddrsig");
 

Modified: cfe/trunk/test/Driver/addrsig.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/addrsig.c?rev=350668=350667=350668=diff
==
--- cfe/trunk/test/Driver/addrsig.c (original)
+++ cfe/trunk/test/Driver/addrsig.c Tue Jan  8 14:33:59 2019
@@ -8,6 +8,7 @@
 // RUN: %clang -### -target x86_64-unknown-linux -fno-addrsig -c %s 2>&1 | 
FileCheck -check-prefix=NO-ADDRSIG %s
 // RUN: %clang -### -target x86_64-apple-darwin -c %s 2>&1 | FileCheck 
-check-prefix=NO-ADDRSIG %s
 // RUN: %clang -### -target x86_64-scei-ps4 -c %s 2>&1 | FileCheck 
-check-prefix=NO-ADDRSIG %s
+// RUN: %clang -### -target x86_64-linux-android21 -c %s 2>&1 | FileCheck 
-check-prefix=NO-ADDRSIG %s
 
 // ADDRSIG: -faddrsig
 // NO-ADDRSIG-NOT: -faddrsig


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


r350666 - [libclang] Recommit r336590 with a fix for the memory leak in the test

2019-01-08 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Tue Jan  8 14:32:51 2019
New Revision: 350666

URL: http://llvm.org/viewvc/llvm-project?rev=350666=rev
Log:
[libclang] Recommit r336590 with a fix for the memory leak in the test

The original commit had a memory leak in the test has a leak as it doesn't
dispose of the evaluated cursor result.

This also contains the follow-up NFC refactoring commit r336591.

rdar://45893054

Original commit message:

[libclang] evalute compound statement cursors before trying to evaluate
the cursor like a declaration

This change fixes a bug in libclang in which it tries to evaluate a statement
cursor as a declaration cursor, because that statement still has a pointer to
the declaration parent.

rdar://3477

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

Modified:
cfe/trunk/tools/libclang/CIndex.cpp
cfe/trunk/unittests/libclang/LibclangTest.cpp

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=350666=350665=350666=diff
==
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Tue Jan  8 14:32:51 2019
@@ -3902,36 +3902,35 @@ static const ExprEvalResult* evaluateExp
   return nullptr;
 }
 
-CXEvalResult clang_Cursor_Evaluate(CXCursor C) {
-  const Decl *D = getCursorDecl(C);
-  if (D) {
-const Expr *expr = nullptr;
-if (auto *Var = dyn_cast(D)) {
-  expr = Var->getInit();
-} else if (auto *Field = dyn_cast(D)) {
-  expr = Field->getInClassInitializer();
-}
-if (expr)
-  return const_cast(reinterpret_cast(
-  evaluateExpr(const_cast(expr), C)));
+static const Expr *evaluateDeclExpr(const Decl *D) {
+  if (!D)
 return nullptr;
-  }
+  if (auto *Var = dyn_cast(D))
+return Var->getInit();
+  else if (auto *Field = dyn_cast(D))
+return Field->getInClassInitializer();
+  return nullptr;
+}
 
-  const CompoundStmt *compoundStmt = 
dyn_cast_or_null(getCursorStmt(C));
-  if (compoundStmt) {
-Expr *expr = nullptr;
-for (auto *bodyIterator : compoundStmt->body()) {
-  if ((expr = dyn_cast(bodyIterator))) {
-break;
-  }
-}
-if (expr)
-  return const_cast(
-  reinterpret_cast(evaluateExpr(expr, C)));
+static const Expr *evaluateCompoundStmtExpr(const CompoundStmt *CS) {
+  assert(CS && "invalid compound statement");
+  for (auto *bodyIterator : CS->body()) {
+if (const auto *E = dyn_cast(bodyIterator))
+  return E;
   }
   return nullptr;
 }
 
+CXEvalResult clang_Cursor_Evaluate(CXCursor C) {
+  if (const Expr *E =
+  clang_getCursorKind(C) == CXCursor_CompoundStmt
+  ? evaluateCompoundStmtExpr(cast(getCursorStmt(C)))
+  : evaluateDeclExpr(getCursorDecl(C)))
+return const_cast(
+reinterpret_cast(evaluateExpr(const_cast(E), 
C)));
+  return nullptr;
+}
+
 unsigned clang_Cursor_hasAttrs(CXCursor C) {
   const Decl *D = getCursorDecl(C);
   if (!D) {

Modified: cfe/trunk/unittests/libclang/LibclangTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/libclang/LibclangTest.cpp?rev=350666=350665=350666=diff
==
--- cfe/trunk/unittests/libclang/LibclangTest.cpp (original)
+++ cfe/trunk/unittests/libclang/LibclangTest.cpp Tue Jan  8 14:32:51 2019
@@ -461,6 +461,48 @@ TEST_F(LibclangParseTest, AllSkippedRang
   clang_disposeSourceRangeList(Ranges);
 }
 
+TEST_F(LibclangParseTest, EvaluateChildExpression) {
+  std::string Main = "main.m";
+  WriteFile(Main, "#define kFOO @\"foo\"\n"
+  "void foobar(void) {\n"
+  " {kFOO;}\n"
+  "}\n");
+  ClangTU = clang_parseTranslationUnit(Index, Main.c_str(), nullptr, 0, 
nullptr,
+   0, TUFlags);
+
+  CXCursor C = clang_getTranslationUnitCursor(ClangTU);
+  clang_visitChildren(
+  C,
+  [](CXCursor cursor, CXCursor parent,
+ CXClientData client_data) -> CXChildVisitResult {
+if (clang_getCursorKind(cursor) == CXCursor_FunctionDecl) {
+  int numberedStmt = 0;
+  clang_visitChildren(
+  cursor,
+  [](CXCursor cursor, CXCursor parent,
+ CXClientData client_data) -> CXChildVisitResult {
+int  = *((int *)client_data);
+if (clang_getCursorKind(cursor) == CXCursor_CompoundStmt) {
+  if (numberedStmt) {
+CXEvalResult RE = clang_Cursor_Evaluate(cursor);
+EXPECT_NE(RE, nullptr);
+EXPECT_EQ(clang_EvalResult_getKind(RE),
+  CXEval_ObjCStrLiteral);
+clang_EvalResult_dispose(RE);
+return CXChildVisit_Break;
+  }
+  numberedStmt++;
+}
+return 

[PATCH] D56407: Implement the TreeStructure interface through the TextNodeDumper

2019-01-08 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC350665: Implement the TreeStructure interface through the 
TextNodeDumper (authored by steveire, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D56407?vs=180552=180742#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D56407

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

Index: include/clang/AST/TextNodeDumper.h
===
--- include/clang/AST/TextNodeDumper.h
+++ include/clang/AST/TextNodeDumper.h
@@ -22,9 +22,94 @@
 
 namespace clang {
 
+class TextTreeStructure {
+  raw_ostream 
+  const bool ShowColors;
+
+  /// Pending[i] is an action to dump an entity at level i.
+  llvm::SmallVector, 32> Pending;
+
+  /// Indicates whether we're at the top level.
+  bool TopLevel = true;
+
+  /// Indicates if we're handling the first child after entering a new depth.
+  bool FirstChild = true;
+
+  /// Prefix for currently-being-dumped entity.
+  std::string Prefix;
+
+public:
+  /// Add a child of the current node.  Calls doAddChild without arguments
+  template  void addChild(Fn doAddChild) {
+// If we're at the top level, there's nothing interesting to do; just
+// run the dumper.
+if (TopLevel) {
+  TopLevel = false;
+  doAddChild();
+  while (!Pending.empty()) {
+Pending.back()(true);
+Pending.pop_back();
+  }
+  Prefix.clear();
+  OS << "\n";
+  TopLevel = true;
+  return;
+}
+
+auto dumpWithIndent = [this, doAddChild](bool isLastChild) {
+  // Print out the appropriate tree structure and work out the prefix for
+  // children of this node. For instance:
+  //
+  //   APrefix = ""
+  //   |-B  Prefix = "| "
+  //   | `-CPrefix = "|   "
+  //   `-D  Prefix = "  "
+  // |-EPrefix = "  | "
+  // `-FPrefix = ""
+  //   GPrefix = ""
+  //
+  // Note that the first level gets no prefix.
+  {
+OS << '\n';
+ColorScope Color(OS, ShowColors, IndentColor);
+OS << Prefix << (isLastChild ? '`' : '|') << '-';
+this->Prefix.push_back(isLastChild ? ' ' : '|');
+this->Prefix.push_back(' ');
+  }
+
+  FirstChild = true;
+  unsigned Depth = Pending.size();
+
+  doAddChild();
+
+  // If any children are left, they're the last at their nesting level.
+  // Dump those ones out now.
+  while (Depth < Pending.size()) {
+Pending.back()(true);
+this->Pending.pop_back();
+  }
+
+  // Restore the old prefix.
+  this->Prefix.resize(Prefix.size() - 2);
+};
+
+if (FirstChild) {
+  Pending.push_back(std::move(dumpWithIndent));
+} else {
+  Pending.back()(false);
+  Pending.back() = std::move(dumpWithIndent);
+}
+FirstChild = false;
+  }
+
+  TextTreeStructure(raw_ostream , bool ShowColors)
+  : OS(OS), ShowColors(ShowColors) {}
+};
+
 class TextNodeDumper
 : public comments::ConstCommentVisitor {
+   const comments::FullComment *>,
+  public TextTreeStructure {
   raw_ostream 
   const bool ShowColors;
 
Index: include/clang/AST/ASTDumperUtils.h
===
--- include/clang/AST/ASTDumperUtils.h
+++ include/clang/AST/ASTDumperUtils.h
@@ -92,90 +92,6 @@
   }
 };
 
-class TextTreeStructure {
-  raw_ostream 
-  const bool ShowColors;
-
-  /// Pending[i] is an action to dump an entity at level i.
-  llvm::SmallVector, 32> Pending;
-
-  /// Indicates whether we're at the top level.
-  bool TopLevel = true;
-
-  /// Indicates if we're handling the first child after entering a new depth.
-  bool FirstChild = true;
-
-  /// Prefix for currently-being-dumped entity.
-  std::string Prefix;
-
-public:
-  /// Add a child of the current node.  Calls doAddChild without arguments
-  template  void addChild(Fn doAddChild) {
-// If we're at the top level, there's nothing interesting to do; just
-// run the dumper.
-if (TopLevel) {
-  TopLevel = false;
-  doAddChild();
-  while (!Pending.empty()) {
-Pending.back()(true);
-Pending.pop_back();
-  }
-  Prefix.clear();
-  OS << "\n";
-  TopLevel = true;
-  return;
-}
-
-auto dumpWithIndent = [this, doAddChild](bool isLastChild) {
-  // Print out the appropriate tree structure and work out the prefix for
-  // children of this node. For instance:
-  //
-  //   APrefix = ""
-  //   |-B  Prefix = "| "
-  //   | `-CPrefix = "|   "
-  //   `-D  Prefix = "  "
-  // |-EPrefix = "  | "
-  // `-FPrefix = ""
-  //   GPrefix = ""
-  //
-  

r350665 - Implement the TreeStructure interface through the TextNodeDumper

2019-01-08 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Tue Jan  8 14:32:48 2019
New Revision: 350665

URL: http://llvm.org/viewvc/llvm-project?rev=350665=rev
Log:
Implement the TreeStructure interface through the TextNodeDumper

Summary:
This way, when the generic ASTTraverser is extracted from ASTDumper,
there can't be any problem related to ordering of class members, a
concern that was raised in https://reviews.llvm.org/D55337.

This will also preserve the property that the generic traverser does not
enforce any coupling between the NodeDumper and the TreeStructure.

 https://godbolt.org/z/PEtT1_

Reviewers: aaron.ballman, erichkeane

Subscribers: cfe-commits

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

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

Modified: cfe/trunk/include/clang/AST/ASTDumperUtils.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTDumperUtils.h?rev=350665=350664=350665=diff
==
--- cfe/trunk/include/clang/AST/ASTDumperUtils.h (original)
+++ cfe/trunk/include/clang/AST/ASTDumperUtils.h Tue Jan  8 14:32:48 2019
@@ -92,90 +92,6 @@ public:
   }
 };
 
-class TextTreeStructure {
-  raw_ostream 
-  const bool ShowColors;
-
-  /// Pending[i] is an action to dump an entity at level i.
-  llvm::SmallVector, 32> Pending;
-
-  /// Indicates whether we're at the top level.
-  bool TopLevel = true;
-
-  /// Indicates if we're handling the first child after entering a new depth.
-  bool FirstChild = true;
-
-  /// Prefix for currently-being-dumped entity.
-  std::string Prefix;
-
-public:
-  /// Add a child of the current node.  Calls doAddChild without arguments
-  template  void addChild(Fn doAddChild) {
-// If we're at the top level, there's nothing interesting to do; just
-// run the dumper.
-if (TopLevel) {
-  TopLevel = false;
-  doAddChild();
-  while (!Pending.empty()) {
-Pending.back()(true);
-Pending.pop_back();
-  }
-  Prefix.clear();
-  OS << "\n";
-  TopLevel = true;
-  return;
-}
-
-auto dumpWithIndent = [this, doAddChild](bool isLastChild) {
-  // Print out the appropriate tree structure and work out the prefix for
-  // children of this node. For instance:
-  //
-  //   APrefix = ""
-  //   |-B  Prefix = "| "
-  //   | `-CPrefix = "|   "
-  //   `-D  Prefix = "  "
-  // |-EPrefix = "  | "
-  // `-FPrefix = ""
-  //   GPrefix = ""
-  //
-  // Note that the first level gets no prefix.
-  {
-OS << '\n';
-ColorScope Color(OS, ShowColors, IndentColor);
-OS << Prefix << (isLastChild ? '`' : '|') << '-';
-this->Prefix.push_back(isLastChild ? ' ' : '|');
-this->Prefix.push_back(' ');
-  }
-
-  FirstChild = true;
-  unsigned Depth = Pending.size();
-
-  doAddChild();
-
-  // If any children are left, they're the last at their nesting level.
-  // Dump those ones out now.
-  while (Depth < Pending.size()) {
-Pending.back()(true);
-this->Pending.pop_back();
-  }
-
-  // Restore the old prefix.
-  this->Prefix.resize(Prefix.size() - 2);
-};
-
-if (FirstChild) {
-  Pending.push_back(std::move(dumpWithIndent));
-} else {
-  Pending.back()(false);
-  Pending.back() = std::move(dumpWithIndent);
-}
-FirstChild = false;
-  }
-
-  TextTreeStructure(raw_ostream , bool ShowColors)
-  : OS(OS), ShowColors(ShowColors) {}
-};
-
 } // namespace clang
 
 #endif // LLVM_CLANG_AST_ASTDUMPERUTILS_H

Modified: cfe/trunk/include/clang/AST/TextNodeDumper.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TextNodeDumper.h?rev=350665=350664=350665=diff
==
--- cfe/trunk/include/clang/AST/TextNodeDumper.h (original)
+++ cfe/trunk/include/clang/AST/TextNodeDumper.h Tue Jan  8 14:32:48 2019
@@ -22,9 +22,94 @@
 
 namespace clang {
 
+class TextTreeStructure {
+  raw_ostream 
+  const bool ShowColors;
+
+  /// Pending[i] is an action to dump an entity at level i.
+  llvm::SmallVector, 32> Pending;
+
+  /// Indicates whether we're at the top level.
+  bool TopLevel = true;
+
+  /// Indicates if we're handling the first child after entering a new depth.
+  bool FirstChild = true;
+
+  /// Prefix for currently-being-dumped entity.
+  std::string Prefix;
+
+public:
+  /// Add a child of the current node.  Calls doAddChild without arguments
+  template  void addChild(Fn doAddChild) {
+// If we're at the top level, there's nothing interesting to do; just
+// run the dumper.
+if (TopLevel) {
+  TopLevel = false;
+  doAddChild();
+  while (!Pending.empty()) {
+Pending.back()(true);
+

[PATCH] D55953: Android is not GNU, so don't claim that it is.

2019-01-08 Thread Dan Albert via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC350664: Android is not GNU, so dont claim that it is. 
(authored by danalbert, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D55953?vs=179140=180741#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D55953

Files:
  lib/Basic/Targets/OSTargets.h
  test/Preprocessor/init.c


Index: lib/Basic/Targets/OSTargets.h
===
--- lib/Basic/Targets/OSTargets.h
+++ lib/Basic/Targets/OSTargets.h
@@ -345,7 +345,6 @@
 // Linux defines; list based off of gcc output
 DefineStd(Builder, "unix", Opts);
 DefineStd(Builder, "linux", Opts);
-Builder.defineMacro("__gnu_linux__");
 Builder.defineMacro("__ELF__");
 if (Triple.isAndroid()) {
   Builder.defineMacro("__ANDROID__", "1");
@@ -355,6 +354,8 @@
   this->PlatformMinVersion = VersionTuple(Maj, Min, Rev);
   if (Maj)
 Builder.defineMacro("__ANDROID_API__", Twine(Maj));
+} else {
+Builder.defineMacro("__gnu_linux__");
 }
 if (Opts.POSIXThreads)
   Builder.defineMacro("_REENTRANT");
Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -9057,6 +9057,7 @@
 // RUN: %clang_cc1 -triple arm-linux-androideabi -E -dM < /dev/null | 
FileCheck -match-full-lines -check-prefix ANDROID %s
 // ANDROID-NOT:#define __ANDROID_API__
 // ANDROID:#define __ANDROID__ 1
+// ANDROID-NOT:#define __gnu_linux__
 //
 // RUN: %clang_cc1 -x c++ -triple i686-linux-android -E -dM < /dev/null | 
FileCheck -match-full-lines -check-prefix I386-ANDROID-CXX %s
 // I386-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 8U
@@ -9067,6 +9068,7 @@
 // RUN: %clang_cc1 -triple arm-linux-androideabi20 -E -dM < /dev/null | 
FileCheck -match-full-lines -check-prefix ANDROID20 %s
 // ANDROID20:#define __ANDROID_API__ 20
 // ANDROID20:#define __ANDROID__ 1
+// ANDROID-NOT:#define __gnu_linux__
 //
 // RUN: %clang_cc1 -triple lanai-unknown-unknown -E -dM < /dev/null | 
FileCheck -match-full-lines -check-prefix LANAI %s
 // LANAI: #define __lanai__ 1


Index: lib/Basic/Targets/OSTargets.h
===
--- lib/Basic/Targets/OSTargets.h
+++ lib/Basic/Targets/OSTargets.h
@@ -345,7 +345,6 @@
 // Linux defines; list based off of gcc output
 DefineStd(Builder, "unix", Opts);
 DefineStd(Builder, "linux", Opts);
-Builder.defineMacro("__gnu_linux__");
 Builder.defineMacro("__ELF__");
 if (Triple.isAndroid()) {
   Builder.defineMacro("__ANDROID__", "1");
@@ -355,6 +354,8 @@
   this->PlatformMinVersion = VersionTuple(Maj, Min, Rev);
   if (Maj)
 Builder.defineMacro("__ANDROID_API__", Twine(Maj));
+} else {
+Builder.defineMacro("__gnu_linux__");
 }
 if (Opts.POSIXThreads)
   Builder.defineMacro("_REENTRANT");
Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -9057,6 +9057,7 @@
 // RUN: %clang_cc1 -triple arm-linux-androideabi -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix ANDROID %s
 // ANDROID-NOT:#define __ANDROID_API__
 // ANDROID:#define __ANDROID__ 1
+// ANDROID-NOT:#define __gnu_linux__
 //
 // RUN: %clang_cc1 -x c++ -triple i686-linux-android -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix I386-ANDROID-CXX %s
 // I386-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 8U
@@ -9067,6 +9068,7 @@
 // RUN: %clang_cc1 -triple arm-linux-androideabi20 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix ANDROID20 %s
 // ANDROID20:#define __ANDROID_API__ 20
 // ANDROID20:#define __ANDROID__ 1
+// ANDROID-NOT:#define __gnu_linux__
 //
 // RUN: %clang_cc1 -triple lanai-unknown-unknown -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix LANAI %s
 // LANAI: #define __lanai__ 1
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r350664 - Android is not GNU, so don't claim that it is.

2019-01-08 Thread Dan Albert via cfe-commits
Author: danalbert
Date: Tue Jan  8 14:31:19 2019
New Revision: 350664

URL: http://llvm.org/viewvc/llvm-project?rev=350664=rev
Log:
Android is not GNU, so don't claim that it is.

Reviewers: pirama, srhines

Reviewed By: srhines

Subscribers: kristina, cfe-commits

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

Modified:
cfe/trunk/lib/Basic/Targets/OSTargets.h
cfe/trunk/test/Preprocessor/init.c

Modified: cfe/trunk/lib/Basic/Targets/OSTargets.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/OSTargets.h?rev=350664=350663=350664=diff
==
--- cfe/trunk/lib/Basic/Targets/OSTargets.h (original)
+++ cfe/trunk/lib/Basic/Targets/OSTargets.h Tue Jan  8 14:31:19 2019
@@ -345,7 +345,6 @@ protected:
 // Linux defines; list based off of gcc output
 DefineStd(Builder, "unix", Opts);
 DefineStd(Builder, "linux", Opts);
-Builder.defineMacro("__gnu_linux__");
 Builder.defineMacro("__ELF__");
 if (Triple.isAndroid()) {
   Builder.defineMacro("__ANDROID__", "1");
@@ -355,6 +354,8 @@ protected:
   this->PlatformMinVersion = VersionTuple(Maj, Min, Rev);
   if (Maj)
 Builder.defineMacro("__ANDROID_API__", Twine(Maj));
+} else {
+Builder.defineMacro("__gnu_linux__");
 }
 if (Opts.POSIXThreads)
   Builder.defineMacro("_REENTRANT");

Modified: cfe/trunk/test/Preprocessor/init.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=350664=350663=350664=diff
==
--- cfe/trunk/test/Preprocessor/init.c (original)
+++ cfe/trunk/test/Preprocessor/init.c Tue Jan  8 14:31:19 2019
@@ -9057,6 +9057,7 @@
 // RUN: %clang_cc1 -triple arm-linux-androideabi -E -dM < /dev/null | 
FileCheck -match-full-lines -check-prefix ANDROID %s
 // ANDROID-NOT:#define __ANDROID_API__
 // ANDROID:#define __ANDROID__ 1
+// ANDROID-NOT:#define __gnu_linux__
 //
 // RUN: %clang_cc1 -x c++ -triple i686-linux-android -E -dM < /dev/null | 
FileCheck -match-full-lines -check-prefix I386-ANDROID-CXX %s
 // I386-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 8U
@@ -9067,6 +9068,7 @@
 // RUN: %clang_cc1 -triple arm-linux-androideabi20 -E -dM < /dev/null | 
FileCheck -match-full-lines -check-prefix ANDROID20 %s
 // ANDROID20:#define __ANDROID_API__ 20
 // ANDROID20:#define __ANDROID__ 1
+// ANDROID-NOT:#define __gnu_linux__
 //
 // RUN: %clang_cc1 -triple lanai-unknown-unknown -E -dM < /dev/null | 
FileCheck -match-full-lines -check-prefix LANAI %s
 // LANAI: #define __lanai__ 1


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


[PATCH] D56415: NFC: Port QueryParser to StringRef

2019-01-08 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE350660: [Query] NFC: Port QueryParser to StringRef 
(authored by steveire, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D56415?vs=180626=180740#toc

Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D56415

Files:
  clang-query/QueryParser.cpp
  clang-query/QueryParser.h

Index: clang-query/QueryParser.h
===
--- clang-query/QueryParser.h
+++ clang-query/QueryParser.h
@@ -37,7 +37,7 @@
 
 private:
   QueryParser(StringRef Line, const QuerySession )
-  : Begin(Line.begin()), End(Line.end()), CompletionPos(nullptr), QS(QS) {}
+  : Line(Line), CompletionPos(nullptr), QS(QS) {}
 
   StringRef lexWord();
 
@@ -55,8 +55,7 @@
   /// \c InvalidQuery if a parse error occurs.
   QueryRef doParse();
 
-  const char *Begin;
-  const char *End;
+  StringRef Line;
 
   const char *CompletionPos;
   std::vector Completions;
Index: clang-query/QueryParser.cpp
===
--- clang-query/QueryParser.cpp
+++ clang-query/QueryParser.cpp
@@ -27,29 +27,22 @@
 // is found before End, return StringRef().  Begin is adjusted to exclude the
 // lexed region.
 StringRef QueryParser::lexWord() {
-  while (true) {
-if (Begin == End)
-  return StringRef(Begin, 0);
+  Line = Line.ltrim();
 
-if (!isWhitespace(*Begin))
-  break;
-
-++Begin;
-  }
+  if (Line.empty())
+// Even though the Line is empty, it contains a pointer and
+// a (zero) length. The pointer is used in the LexOrCompleteWord
+// code completion.
+return Line;
 
-  if (*Begin == '#') {
-End = Begin;
+  if (Line.front() == '#') {
+Line = {};
 return StringRef();
   }
 
-  const char *WordBegin = Begin;
-
-  while (true) {
-++Begin;
-
-if (Begin == End || isWhitespace(*Begin))
-  return StringRef(WordBegin, Begin - WordBegin);
-  }
+  StringRef Word = Line.take_until(isWhitespace);
+  Line = Line.drop_front(Word.size());
+  return Word;
 }
 
 // This is the StringSwitch-alike used by lexOrCompleteWord below. See that
@@ -133,10 +126,9 @@
 }
 
 QueryRef QueryParser::endQuery(QueryRef Q) {
-  const char *Extra = Begin;
+  const StringRef Extra = Line;
   if (!lexWord().empty())
-return new InvalidQuery("unexpected extra input: '" +
-StringRef(Extra, End - Extra) + "'");
+return new InvalidQuery("unexpected extra input: '" + Extra + "'");
   return Q;
 }
 
@@ -174,8 +166,7 @@
 
 QueryRef QueryParser::completeMatcherExpression() {
   std::vector Comps = Parser::completeExpression(
-  StringRef(Begin, End - Begin), CompletionPos - Begin, nullptr,
-  );
+  Line, CompletionPos - Line.begin(), nullptr, );
   for (auto I = Comps.begin(), E = Comps.end(); I != E; ++I) {
 Completions.push_back(LineEditor::Completion(I->TypedText, I->MatcherDecl));
   }
@@ -222,8 +213,8 @@
 
 Diagnostics Diag;
 ast_matchers::dynamic::VariantValue Value;
-if (!Parser::parseExpression(StringRef(Begin, End - Begin), nullptr,
- , , )) {
+if (!Parser::parseExpression(Line, nullptr, , ,
+ )) {
   return makeInvalidQueryFromDiagnostics(Diag);
 }
 
@@ -235,7 +226,7 @@
   return completeMatcherExpression();
 
 Diagnostics Diag;
-auto MatcherSource = StringRef(Begin, End - Begin).trim();
+auto MatcherSource = Line.trim();
 Optional Matcher = Parser::parseMatcherExpression(
 MatcherSource, nullptr, , );
 if (!Matcher) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r350660 - [Query] NFC: Port QueryParser to StringRef

2019-01-08 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Tue Jan  8 14:27:08 2019
New Revision: 350660

URL: http://llvm.org/viewvc/llvm-project?rev=350660=rev
Log:
[Query] NFC: Port QueryParser to StringRef

Summary:
There is no reason for it to not be a StringRef.  Making it one
simplifies existing code, and makes follow-up features easier.

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-query/QueryParser.cpp
clang-tools-extra/trunk/clang-query/QueryParser.h

Modified: clang-tools-extra/trunk/clang-query/QueryParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-query/QueryParser.cpp?rev=350660=350659=350660=diff
==
--- clang-tools-extra/trunk/clang-query/QueryParser.cpp (original)
+++ clang-tools-extra/trunk/clang-query/QueryParser.cpp Tue Jan  8 14:27:08 2019
@@ -27,29 +27,22 @@ namespace query {
 // is found before End, return StringRef().  Begin is adjusted to exclude the
 // lexed region.
 StringRef QueryParser::lexWord() {
-  while (true) {
-if (Begin == End)
-  return StringRef(Begin, 0);
+  Line = Line.ltrim();
 
-if (!isWhitespace(*Begin))
-  break;
+  if (Line.empty())
+// Even though the Line is empty, it contains a pointer and
+// a (zero) length. The pointer is used in the LexOrCompleteWord
+// code completion.
+return Line;
 
-++Begin;
-  }
-
-  if (*Begin == '#') {
-End = Begin;
+  if (Line.front() == '#') {
+Line = {};
 return StringRef();
   }
 
-  const char *WordBegin = Begin;
-
-  while (true) {
-++Begin;
-
-if (Begin == End || isWhitespace(*Begin))
-  return StringRef(WordBegin, Begin - WordBegin);
-  }
+  StringRef Word = Line.take_until(isWhitespace);
+  Line = Line.drop_front(Word.size());
+  return Word;
 }
 
 // This is the StringSwitch-alike used by lexOrCompleteWord below. See that
@@ -133,10 +126,9 @@ template  QueryRef Q
 }
 
 QueryRef QueryParser::endQuery(QueryRef Q) {
-  const char *Extra = Begin;
+  const StringRef Extra = Line;
   if (!lexWord().empty())
-return new InvalidQuery("unexpected extra input: '" +
-StringRef(Extra, End - Extra) + "'");
+return new InvalidQuery("unexpected extra input: '" + Extra + "'");
   return Q;
 }
 
@@ -174,8 +166,7 @@ QueryRef makeInvalidQueryFromDiagnostics
 
 QueryRef QueryParser::completeMatcherExpression() {
   std::vector Comps = Parser::completeExpression(
-  StringRef(Begin, End - Begin), CompletionPos - Begin, nullptr,
-  );
+  Line, CompletionPos - Line.begin(), nullptr, );
   for (auto I = Comps.begin(), E = Comps.end(); I != E; ++I) {
 Completions.push_back(LineEditor::Completion(I->TypedText, 
I->MatcherDecl));
   }
@@ -222,8 +213,8 @@ QueryRef QueryParser::doParse() {
 
 Diagnostics Diag;
 ast_matchers::dynamic::VariantValue Value;
-if (!Parser::parseExpression(StringRef(Begin, End - Begin), nullptr,
- , , )) {
+if (!Parser::parseExpression(Line, nullptr, , ,
+ )) {
   return makeInvalidQueryFromDiagnostics(Diag);
 }
 
@@ -235,7 +226,7 @@ QueryRef QueryParser::doParse() {
   return completeMatcherExpression();
 
 Diagnostics Diag;
-auto MatcherSource = StringRef(Begin, End - Begin).trim();
+auto MatcherSource = Line.trim();
 Optional Matcher = Parser::parseMatcherExpression(
 MatcherSource, nullptr, , );
 if (!Matcher) {

Modified: clang-tools-extra/trunk/clang-query/QueryParser.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-query/QueryParser.h?rev=350660=350659=350660=diff
==
--- clang-tools-extra/trunk/clang-query/QueryParser.h (original)
+++ clang-tools-extra/trunk/clang-query/QueryParser.h Tue Jan  8 14:27:08 2019
@@ -37,7 +37,7 @@ public:
 
 private:
   QueryParser(StringRef Line, const QuerySession )
-  : Begin(Line.begin()), End(Line.end()), CompletionPos(nullptr), QS(QS) {}
+  : Line(Line), CompletionPos(nullptr), QS(QS) {}
 
   StringRef lexWord();
 
@@ -55,8 +55,7 @@ private:
   /// \c InvalidQuery if a parse error occurs.
   QueryRef doParse();
 
-  const char *Begin;
-  const char *End;
+  StringRef Line;
 
   const char *CompletionPos;
   std::vector Completions;


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


[PATCH] D56456: [Driver] Default to -fno-addrsig on Android.

2019-01-08 Thread Dan Albert via Phabricator via cfe-commits
danalbert created this revision.
danalbert added reviewers: srhines, pirama.

The Android NDK still uses GNU binutils by default.


Repository:
  rC Clang

https://reviews.llvm.org/D56456

Files:
  lib/Driver/ToolChains/Clang.cpp
  test/Driver/addrsig.c


Index: test/Driver/addrsig.c
===
--- test/Driver/addrsig.c
+++ test/Driver/addrsig.c
@@ -8,6 +8,7 @@
 // RUN: %clang -### -target x86_64-unknown-linux -fno-addrsig -c %s 2>&1 | 
FileCheck -check-prefix=NO-ADDRSIG %s
 // RUN: %clang -### -target x86_64-apple-darwin -c %s 2>&1 | FileCheck 
-check-prefix=NO-ADDRSIG %s
 // RUN: %clang -### -target x86_64-scei-ps4 -c %s 2>&1 | FileCheck 
-check-prefix=NO-ADDRSIG %s
+// RUN: %clang -### -target x86_64-linux-android21 -c %s 2>&1 | FileCheck 
-check-prefix=NO-ADDRSIG %s
 
 // ADDRSIG: -faddrsig
 // NO-ADDRSIG-NOT: -faddrsig
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -5292,6 +5292,7 @@
   !TC.getTriple().isPS4() &&
   !TC.getTriple().isOSNetBSD() &&
   !Distro(D.getVFS()).IsGentoo() &&
+  !TC.getTriple().isAndroid() &&
TC.useIntegratedAs()))
 CmdArgs.push_back("-faddrsig");
 


Index: test/Driver/addrsig.c
===
--- test/Driver/addrsig.c
+++ test/Driver/addrsig.c
@@ -8,6 +8,7 @@
 // RUN: %clang -### -target x86_64-unknown-linux -fno-addrsig -c %s 2>&1 | FileCheck -check-prefix=NO-ADDRSIG %s
 // RUN: %clang -### -target x86_64-apple-darwin -c %s 2>&1 | FileCheck -check-prefix=NO-ADDRSIG %s
 // RUN: %clang -### -target x86_64-scei-ps4 -c %s 2>&1 | FileCheck -check-prefix=NO-ADDRSIG %s
+// RUN: %clang -### -target x86_64-linux-android21 -c %s 2>&1 | FileCheck -check-prefix=NO-ADDRSIG %s
 
 // ADDRSIG: -faddrsig
 // NO-ADDRSIG-NOT: -faddrsig
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -5292,6 +5292,7 @@
   !TC.getTriple().isPS4() &&
   !TC.getTriple().isOSNetBSD() &&
   !Distro(D.getVFS()).IsGentoo() &&
+  !TC.getTriple().isAndroid() &&
TC.useIntegratedAs()))
 CmdArgs.push_back("-faddrsig");
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56444: [AST] RecursiveASTVisitor visits lambda classes when implicit visitation is on.

2019-01-08 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

I still see the unit-test crashing for `ExprMutAnalyzer` (just apply these 
tests 
https://github.com/JonasToth/clang/blob/fix_crash/unittests/Analysis/ExprMutationAnalyzerTest.cpp
 and run `check-clang-unit`)
The clang-tidy check does not crash anymore, but `readability-function-size` 
regresses. It probably doesn't properly count for lambdas anymore.


Repository:
  rC Clang

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

https://reviews.llvm.org/D56444



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


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

2019-01-08 Thread Justin Lebar via Phabricator via cfe-commits
jlebar added a comment.

  __host__ void bar() {}
  __device__ int bar() { return 0; }
  __host__ __device__ void foo() { int x = bar(); }
  template  __global__ void kernel() { devF();}
  
  kernel();



> we DTRT for this case. Here __host__ bar needs to return int since foo() 
> expects that. will add a test for that.

`__host__ bar()` should not need to return int if `foo` is inline (or 
templated), because then we should never codegen `foo` for host.  I guess my 
question is, we should be sure that `kernel()` does not force an 
inline/templated `foo` to be codegen'ed for host.  (Sorry that wasn't more 
clear before.)

> I think n() should be resolved in the containing function context. n itself 
> is not template argument. the result of n() is.

Yes, that's a fair way to think about it.  It just is a bit weird that in this 
context `` refers to one function but `n()` refers to another.  Maybe that's 
unavoidable.  :shrug:

  __host__ void bar() {}
  __device__ int bar() { return 0; }
  __device__ auto baz() -> decltype(foo()) {} // which n() does it call?  
Presumably host, but:
  __device__ auto baz() -> decltype(bar()) {}  // does baz return void or int?  
Presumably...the device one, int?
  Now mix in templates and sizeof and...yeah. Rife for opportunities. :)

> I think this example is different from the issue which this patch tries to 
> address.

Agreed.

> Therefore I tend to suggest we keep things as they are, i.e., bar is 
> host/device resolved in its containing function context.

I'm not sure what is the containing function context in these examples, since 
all of the definitions don't have a containing function.

Currently `baz()` returns void, but it sort of seems to me like the decltype 
should morally be executed within a `__device__` context?

Anyway I know much of this is a distraction from your patch.  So long as we 
have `__host__ __device__` tests I'm happy here.


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

https://reviews.llvm.org/D56411



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


[PATCH] D56215: [lld] [ELF] Include default search paths for NetBSD driver

2019-01-08 Thread Rui Ueyama via Phabricator via cfe-commits
ruiu added a comment.

I want to handle NetBSD in the same way as the other operating systems. I'm 
sorry to have been saying no to a few recent patches for NetBSD, but I think 
that's for a good reason, and I don't think you presented a convincing reason 
why we had to handle only NetBSD differently.


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

https://reviews.llvm.org/D56215



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


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

2019-01-08 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D56411#1349364 , @jlebar wrote:

> Without reading the patch in detail (sorry) but looking mainly at the 
> testcase: It looks like we're not checking how overloading and `__host__ 
> __device__` functions play into this.  Maybe there are some additional 
> edge-cases to explore/check.


will add test for `__host__` `__device__`.

> Just some examples:
> 
> Will we DTRT and parse `bar` call as calling the `device` overload of `bar` in
> 
>   __host__ void bar() {}
>   __device__ int bar() { return 0; }
>   __host__ __device__ void foo() { int x = bar(); }
>   template  __global__ void kernel() { devF();}
>   
>   kernel();
> 
> 
> ?  Also will we know that we don't have to codegen `foo` for host (so `foo` 
> is actually able to do things that only device functions can)?

we DTRT for this case. Here `__host__` bar needs to return int since foo() 
expects that. will add a test for that.

> Another one: How should the following template be instantiated?
> 
>   __host__ constexpr int n() { return 0; }
>   __device__ constexpr int n() { return 1; }
>   template  __global__ void kernel() {}
>   
>   kernel
> 
> 
> Presumably the call to `n` should be the host one?  That seems correct to me, 
> but then it's pretty odd that a function pointer template argument would 
> point to a *device* function.  Maybe that's the right thing, but I bet I can 
> come up with something weird, like:

I think n() should be resolved in the containing function context. n itself is 
not template argument. the result of n() is.

> 
> 
>   __host__ void bar() {}
>   __device__ int bar() { return 0; }
>   __device__ auto baz() -> decltype(foo()) {} // which n() does it call? 
>  Presumably host, but:
>   __device__ auto baz() -> decltype(bar()) {}  // does baz return void or 
> int?  Presumably...the device one, int?
> 
> 
> Now mix in templates and sizeof and...yeah.  Rife for opportunities.  :)

I think this example is different from the issue which this patch tries to 
address. In the case of function type template parameter, it is less 
controversial about host/device resolution. The function argument is supposed 
to be called by the function template, therefore its host/device attribute 
should be consistent with the function template. Whereas in the above decltype 
example, such reqirement does not exist. Therefore I tend to suggest we keep 
things as they are, i.e., bar is host/device resolved in its containing 
function context.


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

https://reviews.llvm.org/D56411



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


[PATCH] D56215: [lld] [ELF] Include default search paths for NetBSD driver

2019-01-08 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg added inline comments.



Comment at: ELF/Driver.cpp:381
+}
+Config->SearchPaths.push_back("/usr/lib");
+  }

Those need to be sysroot-relative of course.


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

https://reviews.llvm.org/D56215



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


[PATCH] D56215: [lld] [ELF] Include default search paths for NetBSD driver

2019-01-08 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg added a comment.

@ruiu: No, it is exactly what you want, since it allows you to point lld into 
the normal sysroot. Cross-compiling is the default case for the NetBSD 
toolchain.


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

https://reviews.llvm.org/D56215



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


[PATCH] D56424: [clang-tidy] Add check for underscores in googletest names.

2019-01-08 Thread Kar Epker via Phabricator via cfe-commits
karepker marked 2 inline comments as done and an inline comment as not done.
karepker added inline comments.



Comment at: clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.cpp:27
+static bool isGoogletestTestMacro(StringRef MacroName) {
+  static const llvm::StringSet<> MacroNames = {"TEST", "TEST_F", "TEST_P",
+   "TYPED_TEST", "TYPED_TEST_P"};

MyDeveloperDay wrote:
> Is there value in making the list of macros and option?, I've worked with 
> other unit testing packages (some inhouse) that use the same format as google 
> test, but don't use TEST() itself
> 
> e.g.  (to name a few)
> 
> ```
> TEST_CASE(testclass, testname)
> BOOST_TEST(statement, floating_point_comparison_manipulation);
> BOOST_DATA_TEST_CASE(test_case_name, dataset)
> BOOST_FIXTURE_TEST_CASE( test_case2, F )
> BOOST_AUTO_TEST_CASE( test_case3 )
> 
> ```
> 
> too many for you to capture in the checker...but a nice addition for those 
> who use alternative frameworks and would like to benefit from similar  "no 
> underscore" naming conventions
> 
I'm not familiar with, e.g. the boost testing framework, so I don't know how 
closely it mirrors Googletest, but I think my preference would be to have a 
separate check for other testing frameworks.

While the testing frameworks might share some high-level similarities, there 
could be some different corner cases which would make having a separate check 
worth it as opposed to making this code more complex by trying to generalize it 
for several cases. At the very least, a different diagnostic message would be 
required. Factoring out similar functionality into some utility functions might 
reduce some of the boilerplate from implementing separate checks.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D56424



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


[PATCH] D55953: Android is not GNU, so don't claim that it is.

2019-01-08 Thread Stephen Hines via Phabricator via cfe-commits
srhines accepted this revision.
srhines added a comment.
This revision is now accepted and ready to land.

Sorry about the delay.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55953



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


[PATCH] D56215: [lld] [ELF] Include default search paths for NetBSD driver

2019-01-08 Thread Kamil Rytarowski via Phabricator via cfe-commits
krytarowski added a comment.

In D56215#1350134 , @joerg wrote:

> Thanks, this looks like a good starting point.


What's the final state you want?


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

https://reviews.llvm.org/D56215



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


[PATCH] D56424: [clang-tidy] Add check for underscores in googletest names.

2019-01-08 Thread Kar Epker via Phabricator via cfe-commits
karepker updated this revision to Diff 180727.
karepker marked 4 inline comments as done.
karepker added a comment.

Update release notes documentation to match check documentation more.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D56424

Files:
  clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.cpp
  clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.h
  clang-tidy/google/CMakeLists.txt
  clang-tidy/google/GoogleTidyModule.cpp
  docs/ReleaseNotes.rst
  
docs/clang-tidy/checks/google-readability-avoid-underscore-in-googletest-name.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/readability-avoid-underscore-in-googletest-name.cpp

Index: test/clang-tidy/readability-avoid-underscore-in-googletest-name.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-avoid-underscore-in-googletest-name.cpp
@@ -0,0 +1,108 @@
+// RUN: %check_clang_tidy %s google-readability-avoid-underscore-in-googletest-name %t
+
+#define TEST(test_case_name, test_name) void test_case_name##test_name()
+#define TEST_F(test_case_name, test_name) void test_case_name##test_name()
+#define TEST_P(test_case_name, test_name) void test_case_name##test_name()
+#define TYPED_TEST(test_case_name, test_name) void test_case_name##test_name()
+#define TYPED_TEST_P(test_case_name, test_name) void test_case_name##test_name()
+#define FRIEND_TEST(test_case_name, test_name) void test_case_name##test_name()
+
+TEST(TestCaseName, Illegal_TestName) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: avoid using "_" in test name "Illegal_TestName" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
+
+TEST(TestCaseName, DISABLED_Illegal_TestName) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: avoid using "_" in test name "Illegal_TestName" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
+TEST(TestCaseName, Illegal_Test_Name) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: avoid using "_" in test name "Illegal_Test_Name" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
+TEST(Illegal_TestCaseName, TestName) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: avoid using "_" in test case name "Illegal_TestCaseName" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
+TEST(Illegal_Test_CaseName, TestName) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: avoid using "_" in test case name "Illegal_Test_CaseName" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
+TEST(Illegal_TestCaseName, Illegal_TestName) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: avoid using "_" in test case name "Illegal_TestCaseName" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
+// CHECK-MESSAGES: :[[@LINE-2]]:28: warning: avoid using "_" in test name "Illegal_TestName" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
+
+TEST_F(TestCaseFixtureName, Illegal_TestName) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: avoid using "_" in test name "Illegal_TestName" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
+TEST_F(TestCaseFixtureName, DISABLED_Illegal_Test_Name) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: avoid using "_" in test name "Illegal_Test_Name" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
+TEST_F(TestCaseFixtureName, Illegal_Test_Name) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: avoid using "_" in test name "Illegal_Test_Name" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
+
+TEST_F(Illegal_TestCaseFixtureName, TestName) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: avoid using "_" in test case name "Illegal_TestCaseFixtureName" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
+TEST_F(Illegal_TestCaseFixtureName, Illegal_TestName) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: avoid using "_" in test case name "Illegal_TestCaseFixtureName" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
+// CHECK-MESSAGES: :[[@LINE-2]]:37: warning: avoid using "_" in test name "Illegal_TestName" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
+
+TEST_F(Illegal_Test_CaseFixtureName, TestName) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: avoid using "_" in test case name "Illegal_Test_CaseFixtureName" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
+
+TEST_P(ParameterizedTestCaseFixtureName, Illegal_TestName) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:42: warning: avoid using "_" in test name "Illegal_TestName" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]

[PATCH] D56424: [clang-tidy] Add check for underscores in googletest names.

2019-01-08 Thread Kar Epker via Phabricator via cfe-commits
karepker added inline comments.



Comment at: docs/ReleaseNotes.rst:161
+
+  Checks that Googletest test and test case names do not contain an underscore,
+  which is prohibited by the Googletest FAQ.

Eugene.Zelenko wrote:
> Please synchronize with first statement in documentation.
Done, I think. I assume by documentation you mean documentation in the check 
rst file. The first statement there isn't really a sentence, but I took as much 
of the wording from there as I could.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D56424



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


[PATCH] D56215: [lld] [ELF] Include default search paths for NetBSD driver

2019-01-08 Thread Rui Ueyama via Phabricator via cfe-commits
ruiu added a comment.

To be honest, I don't think I would lgtm a patch that changes lld's default 
behavior depending on host/target only for NetBSD, and it seems like a NetBSD's 
issue rather than an lld's issue. As I said, could you please make an effort to 
pass the flags you need from the compiler driver to the linker just like other 
systems do? That is easy to do, doesn't hurt anyone, probably a good thing to 
do  anyway as it makes options explicit rather than implicit, and solves at 
least most of the problems you have.


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

https://reviews.llvm.org/D56215



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


RE: r350643 - Limit COFF 'common' emission to <=32 alignment types.

2019-01-08 Thread Keane, Erich via cfe-commits
That seems like it would make sense to me.  COFF isn’t my expertise, so 
hopefully David/Martin/others can let me know if this is subtly broken 
elsewhere.

From: Shoaib Meenai [mailto:smee...@fb.com]
Sent: Tuesday, January 8, 2019 1:09 PM
To: Keane, Erich ; cfe-commits@lists.llvm.org; David 
Majnemer ; Martin Storsjo 
Subject: Re: r350643 - Limit COFF 'common' emission to <=32 alignment types.

It checks for both OS=Win32 and Environment=MSVC, so that wouldn't cover other 
COFF environments. wbs (Martin Storsjo) mentioned on IRC that MinGW adds an 
aligncomm directive to specify alignment for common symbols, so perhaps that's 
part of it?

From: "Keane, Erich" mailto:erich.ke...@intel.com>>
Date: Tuesday, January 8, 2019 at 1:04 PM
To: Shoaib Meenai mailto:smee...@fb.com>>, 
"cfe-commits@lists.llvm.org" 
mailto:cfe-commits@lists.llvm.org>>, David Majnemer 
mailto:david.majne...@gmail.com>>
Subject: RE: r350643 - Limit COFF 'common' emission to <=32 alignment types.

Yep, exactly.  I looked, and isKnownWindowsMSVCEnvironment checks for OS=Win32, 
which I believe would be different for other architectures.

From: Shoaib Meenai [mailto:smee...@fb.com]
Sent: Tuesday, January 8, 2019 12:41 PM
To: Keane, Erich mailto:erich.ke...@intel.com>>; 
cfe-commits@lists.llvm.org; David Majnemer 
mailto:david.majne...@gmail.com>>
Subject: Re: r350643 - Limit COFF 'common' emission to <=32 alignment types.

Ah, looks like you were originally checking for COFF, and then David suggested 
checking for MSVC instead? I'm curious about why, although I'm sure the 
suggestion is legit :)

From: cfe-commits 
mailto:cfe-commits-boun...@lists.llvm.org>> 
on behalf of Shoaib Meenai via cfe-commits 
mailto:cfe-commits@lists.llvm.org>>
Reply-To: Shoaib Meenai mailto:smee...@fb.com>>
Date: Tuesday, January 8, 2019 at 12:39 PM
To: Erich Keane mailto:erich.ke...@intel.com>>, 
"cfe-commits@lists.llvm.org" 
mailto:cfe-commits@lists.llvm.org>>
Subject: Re: r350643 - Limit COFF 'common' emission to <=32 alignment types.

Why does this check for isKnownWindowsMSVCEnvironment specifically? Wouldn't 
any COFF target (windows-cygnus, windows-gnu, windows-itanium, etc.) have the 
same limitation, since it's an object file format issue and not an ABI issue?

From: cfe-commits 
mailto:cfe-commits-boun...@lists.llvm.org>> 
on behalf of Erich Keane via cfe-commits 
mailto:cfe-commits@lists.llvm.org>>
Reply-To: Erich Keane mailto:erich.ke...@intel.com>>
Date: Tuesday, January 8, 2019 at 10:48 AM
To: "cfe-commits@lists.llvm.org" 
mailto:cfe-commits@lists.llvm.org>>
Subject: r350643 - Limit COFF 'common' emission to <=32 alignment types.

Author: erichkeane
Date: Tue Jan  8 10:44:22 2019
New Revision: 350643

URL: 
https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D350643-26view-3Drev=DwIGaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=RNVKy_b0_Wgp_PTFDpvQXETsZdWubmT5SGnGz3GigS0=Ph9GOtRaQERmqyeJeAJTFwV3sg3q8fE05FlJ3qwNx4I=
Log:
Limit COFF 'common' emission to <=32 alignment types.

As reported in PR33035, LLVM crashes if given a common object with an
alignment of greater than 32 bits. This is because the COFF file format
does not support these alignments, so emitting them is broken anyway.

This patch changes any global definitions greater than 32 bit alignment
to no longer be in 'common'.

https://urldefense.proofpoint.com/v2/url?u=https-3A__bugs.llvm.org_show-5Fbug.cgi-3Fid-3D33035=DwIGaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=RNVKy_b0_Wgp_PTFDpvQXETsZdWubmT5SGnGz3GigS0=ac1NEHuvztd6jSTCsOUJajkklfeyqdzW-xqtddJ-hvM=

Differential Revision: 
https://urldefense.proofpoint.com/v2/url?u=https-3A__reviews.llvm.org_D56391=DwIGaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=RNVKy_b0_Wgp_PTFDpvQXETsZdWubmT5SGnGz3GigS0=AucP9Sp-DYHSaOP-sPfpAOrww3xwdh8FjQkHrLZhhyo=

Change-Id: I48609289753b7f3b58c5e2bc1712756750fbd45a

Added:
cfe/trunk/test/CodeGen/microsoft-no-common-align.c
Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_lib_CodeGen_CodeGenModule.cpp-3Frev-3D350643-26r1-3D350642-26r2-3D350643-26view-3Ddiff=DwIGaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=RNVKy_b0_Wgp_PTFDpvQXETsZdWubmT5SGnGz3GigS0=gmTnEmW03ruG8LbJluf5Z4yQcxM64QP7Ce1VTnVqvPo=
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Tue Jan  8 10:44:22 2019
@@ -3761,6 +3761,11 @@ static bool isVarDeclStrongDefinition(co
   }
 }
   }
+  // COFF doesn't support alignments greater than 32, so these cannot be
+  // in common.
+  if (Context.getTargetInfo().getTriple().isKnownWindowsMSVCEnvironment() &&
+  

Re: r350643 - Limit COFF 'common' emission to <=32 alignment types.

2019-01-08 Thread Shoaib Meenai via cfe-commits
It checks for both OS=Win32 and Environment=MSVC, so that wouldn't cover other 
COFF environments. wbs (Martin Storsjo) mentioned on IRC that MinGW adds an 
aligncomm directive to specify alignment for common symbols, so perhaps that's 
part of it?

From: "Keane, Erich" 
Date: Tuesday, January 8, 2019 at 1:04 PM
To: Shoaib Meenai , "cfe-commits@lists.llvm.org" 
, David Majnemer 
Subject: RE: r350643 - Limit COFF 'common' emission to <=32 alignment types.

Yep, exactly.  I looked, and isKnownWindowsMSVCEnvironment checks for OS=Win32, 
which I believe would be different for other architectures.

From: Shoaib Meenai [mailto:smee...@fb.com]
Sent: Tuesday, January 8, 2019 12:41 PM
To: Keane, Erich ; cfe-commits@lists.llvm.org; David 
Majnemer 
Subject: Re: r350643 - Limit COFF 'common' emission to <=32 alignment types.

Ah, looks like you were originally checking for COFF, and then David suggested 
checking for MSVC instead? I'm curious about why, although I'm sure the 
suggestion is legit :)

From: cfe-commits 
mailto:cfe-commits-boun...@lists.llvm.org>> 
on behalf of Shoaib Meenai via cfe-commits 
mailto:cfe-commits@lists.llvm.org>>
Reply-To: Shoaib Meenai mailto:smee...@fb.com>>
Date: Tuesday, January 8, 2019 at 12:39 PM
To: Erich Keane mailto:erich.ke...@intel.com>>, 
"cfe-commits@lists.llvm.org" 
mailto:cfe-commits@lists.llvm.org>>
Subject: Re: r350643 - Limit COFF 'common' emission to <=32 alignment types.

Why does this check for isKnownWindowsMSVCEnvironment specifically? Wouldn't 
any COFF target (windows-cygnus, windows-gnu, windows-itanium, etc.) have the 
same limitation, since it's an object file format issue and not an ABI issue?

From: cfe-commits 
mailto:cfe-commits-boun...@lists.llvm.org>> 
on behalf of Erich Keane via cfe-commits 
mailto:cfe-commits@lists.llvm.org>>
Reply-To: Erich Keane mailto:erich.ke...@intel.com>>
Date: Tuesday, January 8, 2019 at 10:48 AM
To: "cfe-commits@lists.llvm.org" 
mailto:cfe-commits@lists.llvm.org>>
Subject: r350643 - Limit COFF 'common' emission to <=32 alignment types.

Author: erichkeane
Date: Tue Jan  8 10:44:22 2019
New Revision: 350643

URL: 
https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D350643-26view-3Drev=DwIGaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=RNVKy_b0_Wgp_PTFDpvQXETsZdWubmT5SGnGz3GigS0=Ph9GOtRaQERmqyeJeAJTFwV3sg3q8fE05FlJ3qwNx4I=
Log:
Limit COFF 'common' emission to <=32 alignment types.

As reported in PR33035, LLVM crashes if given a common object with an
alignment of greater than 32 bits. This is because the COFF file format
does not support these alignments, so emitting them is broken anyway.

This patch changes any global definitions greater than 32 bit alignment
to no longer be in 'common'.

https://urldefense.proofpoint.com/v2/url?u=https-3A__bugs.llvm.org_show-5Fbug.cgi-3Fid-3D33035=DwIGaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=RNVKy_b0_Wgp_PTFDpvQXETsZdWubmT5SGnGz3GigS0=ac1NEHuvztd6jSTCsOUJajkklfeyqdzW-xqtddJ-hvM=

Differential Revision: 
https://urldefense.proofpoint.com/v2/url?u=https-3A__reviews.llvm.org_D56391=DwIGaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=RNVKy_b0_Wgp_PTFDpvQXETsZdWubmT5SGnGz3GigS0=AucP9Sp-DYHSaOP-sPfpAOrww3xwdh8FjQkHrLZhhyo=

Change-Id: I48609289753b7f3b58c5e2bc1712756750fbd45a

Added:
cfe/trunk/test/CodeGen/microsoft-no-common-align.c
Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_lib_CodeGen_CodeGenModule.cpp-3Frev-3D350643-26r1-3D350642-26r2-3D350643-26view-3Ddiff=DwIGaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=RNVKy_b0_Wgp_PTFDpvQXETsZdWubmT5SGnGz3GigS0=gmTnEmW03ruG8LbJluf5Z4yQcxM64QP7Ce1VTnVqvPo=
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Tue Jan  8 10:44:22 2019
@@ -3761,6 +3761,11 @@ static bool isVarDeclStrongDefinition(co
   }
 }
   }
+  // COFF doesn't support alignments greater than 32, so these cannot be
+  // in common.
+  if (Context.getTargetInfo().getTriple().isKnownWindowsMSVCEnvironment() &&
+  Context.getTypeAlignIfKnown(D->getType()) > 32)
+return true;
   return false;
}

Added: cfe/trunk/test/CodeGen/microsoft-no-common-align.c
URL: 
https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_test_CodeGen_microsoft-2Dno-2Dcommon-2Dalign.c-3Frev-3D350643-26view-3Dauto=DwIGaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=RNVKy_b0_Wgp_PTFDpvQXETsZdWubmT5SGnGz3GigS0=hzPmmVFbvg4OTEVpnQ5pIfy295Ne0-xAsctZs00WZgY=
==
--- cfe/trunk/test/CodeGen/microsoft-no-common-align.c (added)
+++ cfe/trunk/test/CodeGen/microsoft-no-common-align.c Tue Jan  8 

[PATCH] D56215: [lld] [ELF] Include default search paths for NetBSD driver

2019-01-08 Thread Rui Ueyama via Phabricator via cfe-commits
ruiu added a comment.

I'm sorry to say this but I don't think this is a good approach. Just like 
changing the default behavior depending on host hurts cross-build and is 
against the policy of the lld driver, changing the default behavior depending 
on the target hurts it too. Imagine that you are doing a cross-build on 
non-NetBSD system to create a NetBSD executable. You definitely want to ignore 
/usr/lib/i386 and /usr/lib on the host system. This patch does the opposite.


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

https://reviews.llvm.org/D56215



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


[PATCH] D56215: [lld] [ELF] Include default search paths for NetBSD driver

2019-01-08 Thread Michał Górny via Phabricator via cfe-commits
mgorny marked an inline comment as done.
mgorny added inline comments.



Comment at: ELF/Driver.cpp:779
+// TODO: verify the triple somehow?
+Config->TargetTriple = llvm::Triple(Prefix);
+  }

joerg wrote:
> See ToolChain::getTargetAndModeFromProgramName in clang.
Yes, I've based this on stripped down version of that. Most notably, I wasn't 
able to verify triple against TargetRegistry since it isn't initialized here.


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

https://reviews.llvm.org/D56215



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


RE: r350643 - Limit COFF 'common' emission to <=32 alignment types.

2019-01-08 Thread Keane, Erich via cfe-commits
Yep, exactly.  I looked, and isKnownWindowsMSVCEnvironment checks for OS=Win32, 
which I believe would be different for other architectures.

From: Shoaib Meenai [mailto:smee...@fb.com]
Sent: Tuesday, January 8, 2019 12:41 PM
To: Keane, Erich ; cfe-commits@lists.llvm.org; David 
Majnemer 
Subject: Re: r350643 - Limit COFF 'common' emission to <=32 alignment types.

Ah, looks like you were originally checking for COFF, and then David suggested 
checking for MSVC instead? I'm curious about why, although I'm sure the 
suggestion is legit :)

From: cfe-commits 
mailto:cfe-commits-boun...@lists.llvm.org>> 
on behalf of Shoaib Meenai via cfe-commits 
mailto:cfe-commits@lists.llvm.org>>
Reply-To: Shoaib Meenai mailto:smee...@fb.com>>
Date: Tuesday, January 8, 2019 at 12:39 PM
To: Erich Keane mailto:erich.ke...@intel.com>>, 
"cfe-commits@lists.llvm.org" 
mailto:cfe-commits@lists.llvm.org>>
Subject: Re: r350643 - Limit COFF 'common' emission to <=32 alignment types.

Why does this check for isKnownWindowsMSVCEnvironment specifically? Wouldn't 
any COFF target (windows-cygnus, windows-gnu, windows-itanium, etc.) have the 
same limitation, since it's an object file format issue and not an ABI issue?

From: cfe-commits 
mailto:cfe-commits-boun...@lists.llvm.org>> 
on behalf of Erich Keane via cfe-commits 
mailto:cfe-commits@lists.llvm.org>>
Reply-To: Erich Keane mailto:erich.ke...@intel.com>>
Date: Tuesday, January 8, 2019 at 10:48 AM
To: "cfe-commits@lists.llvm.org" 
mailto:cfe-commits@lists.llvm.org>>
Subject: r350643 - Limit COFF 'common' emission to <=32 alignment types.

Author: erichkeane
Date: Tue Jan  8 10:44:22 2019
New Revision: 350643

URL: 
https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D350643-26view-3Drev=DwIGaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=RNVKy_b0_Wgp_PTFDpvQXETsZdWubmT5SGnGz3GigS0=Ph9GOtRaQERmqyeJeAJTFwV3sg3q8fE05FlJ3qwNx4I=
Log:
Limit COFF 'common' emission to <=32 alignment types.

As reported in PR33035, LLVM crashes if given a common object with an
alignment of greater than 32 bits. This is because the COFF file format
does not support these alignments, so emitting them is broken anyway.

This patch changes any global definitions greater than 32 bit alignment
to no longer be in 'common'.

https://urldefense.proofpoint.com/v2/url?u=https-3A__bugs.llvm.org_show-5Fbug.cgi-3Fid-3D33035=DwIGaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=RNVKy_b0_Wgp_PTFDpvQXETsZdWubmT5SGnGz3GigS0=ac1NEHuvztd6jSTCsOUJajkklfeyqdzW-xqtddJ-hvM=

Differential Revision: 
https://urldefense.proofpoint.com/v2/url?u=https-3A__reviews.llvm.org_D56391=DwIGaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=RNVKy_b0_Wgp_PTFDpvQXETsZdWubmT5SGnGz3GigS0=AucP9Sp-DYHSaOP-sPfpAOrww3xwdh8FjQkHrLZhhyo=

Change-Id: I48609289753b7f3b58c5e2bc1712756750fbd45a

Added:
cfe/trunk/test/CodeGen/microsoft-no-common-align.c
Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_lib_CodeGen_CodeGenModule.cpp-3Frev-3D350643-26r1-3D350642-26r2-3D350643-26view-3Ddiff=DwIGaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=RNVKy_b0_Wgp_PTFDpvQXETsZdWubmT5SGnGz3GigS0=gmTnEmW03ruG8LbJluf5Z4yQcxM64QP7Ce1VTnVqvPo=
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Tue Jan  8 10:44:22 2019
@@ -3761,6 +3761,11 @@ static bool isVarDeclStrongDefinition(co
   }
 }
   }
+  // COFF doesn't support alignments greater than 32, so these cannot be
+  // in common.
+  if (Context.getTargetInfo().getTriple().isKnownWindowsMSVCEnvironment() &&
+  Context.getTypeAlignIfKnown(D->getType()) > 32)
+return true;
   return false;
}

Added: cfe/trunk/test/CodeGen/microsoft-no-common-align.c
URL: 
https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_test_CodeGen_microsoft-2Dno-2Dcommon-2Dalign.c-3Frev-3D350643-26view-3Dauto=DwIGaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=RNVKy_b0_Wgp_PTFDpvQXETsZdWubmT5SGnGz3GigS0=hzPmmVFbvg4OTEVpnQ5pIfy295Ne0-xAsctZs00WZgY=
==
--- cfe/trunk/test/CodeGen/microsoft-no-common-align.c (added)
+++ cfe/trunk/test/CodeGen/microsoft-no-common-align.c Tue Jan  8 10:44:22 2019
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -emit-llvm -o - %s | FileCheck 
%s
+typedef float TooLargeAlignment __attribute__((__vector_size__(64)));
+typedef float NormalAlignment __attribute__((__vector_size__(4)));
+
+TooLargeAlignment TooBig;
+// CHECK: @TooBig = dso_local global <16 x float>  zeroinitializer, align 64
+NormalAlignment JustRight;
+// CHECK: @JustRight = common dso_local global <1 x float>  zeroinitializer, 

[PATCH] D56413: [OpenMP] Avoid remainder operations for loop index values on a collapsed loop nest.

2019-01-08 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 180722.
gtbercea added a comment.

  Fix.


Repository:
  rC Clang

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

https://reviews.llvm.org/D56413

Files:
  lib/Sema/SemaOpenMP.cpp
  test/OpenMP/for_codegen.cpp
  test/OpenMP/for_simd_codegen.cpp
  test/OpenMP/parallel_for_simd_codegen.cpp
  test/OpenMP/simd_codegen.cpp

Index: test/OpenMP/simd_codegen.cpp
===
--- test/OpenMP/simd_codegen.cpp
+++ test/OpenMP/simd_codegen.cpp
@@ -278,8 +278,11 @@
 // CHECK-NEXT: [[I_2:%.+]] = trunc i64 [[I_1_ADD0]] to i32
 // CHECK-NEXT: store i32 [[I_2]], i32* {{%.+}}{{.*}}!llvm.access.group
 // CHECK: [[IV2:%.+]] = load i64, i64* [[T1_OMP_IV]]{{.*}}!llvm.access.group
-// CHECK-NEXT: [[J_1:%.+]] = srem i64 [[IV2]], 4
-// CHECK-NEXT: [[J_2:%.+]] = mul nsw i64 [[J_1]], 2
+// CHECK: [[IV2_1:%.+]] = load i64, i64* [[T1_OMP_IV]]{{.*}}!llvm.access.group
+// CHECK-NEXT: [[J_1_DIV1:%.+]] = sdiv i64 [[IV2_1]], 4
+// CHECK-NEXT: [[J_1_MUL1:%.+]] = mul nsw i64 [[J_1_DIV1]], 4
+// CHECK-NEXT: [[J_1_SUB0:%.+]] = sub nsw i64 [[IV2]], [[J_1_MUL1]]
+// CHECK-NEXT: [[J_2:%.+]] = mul nsw i64 [[J_1_SUB0]], 2
 // CHECK-NEXT: [[J_2_ADD0:%.+]] = add nsw i64 0, [[J_2]]
 // CHECK-NEXT: store i64 [[J_2_ADD0]], i64* {{%.+}}{{.*}}!llvm.access.group
 // simd.for.inc:
@@ -393,22 +396,70 @@
 // CHECK-NEXT: [[CALC_I_1_MUL1:%.+]] = mul i32 [[CALC_I_1]], 1
 // CHECK-NEXT: [[CALC_I_2:%.+]] = add i32 1, [[CALC_I_1_MUL1]]
 // CHECK-NEXT: store i32 [[CALC_I_2]], i32* [[LC_I:.+]]
+
 // CHECK: [[IV1_2:%.+]] = load i32, i32* [[OMP_IV]]{{.+}}!llvm.access.group
-// CHECK-NEXT: [[CALC_J_1:%.+]] = udiv i32 [[IV1_2]], 20
-// CHECK-NEXT: [[CALC_J_2:%.+]] = urem i32 [[CALC_J_1]], 3
+// CHECK: [[IV1_2_1:%.+]] = load i32, i32* [[OMP_IV]]{{.+}}!llvm.access.group
+// CHECK-NEXT: [[CALC_J_1:%.+]] = udiv i32 [[IV1_2_1]], 60
+// CHECK-NEXT: [[MUL_1:%.+]] = mul i32 [[CALC_J_1]], 60
+// CHECK-NEXT: [[SUB_3:%.+]] = sub i32 [[IV1_2]], [[MUL_1]]
+// CHECK-NEXT: [[CALC_J_2:%.+]] = udiv i32 [[SUB_3]], 20
 // CHECK-NEXT: [[CALC_J_2_MUL1:%.+]] = mul i32 [[CALC_J_2]], 1
 // CHECK-NEXT: [[CALC_J_3:%.+]] = add i32 2, [[CALC_J_2_MUL1]]
 // CHECK-NEXT: store i32 [[CALC_J_3]], i32* [[LC_J:.+]]
+
 // CHECK: [[IV1_3:%.+]] = load i32, i32* [[OMP_IV]]{{.+}}!llvm.access.group
-// CHECK-NEXT: [[CALC_K_1:%.+]] = udiv i32 [[IV1_3]], 5
-// CHECK-NEXT: [[CALC_K_2:%.+]] = urem i32 [[CALC_K_1]], 4
-// CHECK-NEXT: [[CALC_K_2_MUL1:%.+]] = mul i32 [[CALC_K_2]], 1
-// CHECK-NEXT: [[CALC_K_3:%.+]] = add i32 3, [[CALC_K_2_MUL1]]
-// CHECK-NEXT: store i32 [[CALC_K_3]], i32* [[LC_K:.+]]
-// CHECK: [[IV1_4:%.+]] = load i32, i32* [[OMP_IV]]{{.+}}!llvm.access.group
-// CHECK-NEXT: [[CALC_L_1:%.+]] = urem i32 [[IV1_4]], 5
-// CHECK-NEXT: [[CALC_L_1_MUL1:%.+]] = mul i32 [[CALC_L_1]], 1
-// CHECK-NEXT: [[CALC_L_2:%.+]] = add i32 4, [[CALC_L_1_MUL1]]
+// CHECK: [[IV1_3_1:%.+]] = load i32, i32* [[OMP_IV]]{{.+}}!llvm.access.group
+// CHECK-NEXT: [[DIV_1:%.+]] = udiv i32 [[IV1_3_1]], 60
+// CHECK-NEXT: [[MUL_2:%.+]] = mul i32 [[DIV_1]], 60
+// CHECK-NEXT: [[ADD_3:%.+]] = sub i32 [[IV1_3]], [[MUL_2]]
+
+// CHECK: [[IV1_4:%.+]] = load i32, i32* [[OMP_IV]]
+// CHECK: [[IV1_4_1:%.+]] = load i32, i32* [[OMP_IV]]
+// CHECK-NEXT: [[DIV_2:%.+]] = udiv i32 [[IV1_4_1]], 60
+// CHECK-NEXT: [[MUL_3:%.+]] = mul i32 [[DIV_2]], 60
+// CHECK-NEXT: [[SUB_6:%.+]] = sub i32 [[IV1_4]], [[MUL_3]]
+// CHECK-NEXT: [[DIV_3:%.+]] = udiv i32 [[SUB_6]], 20
+// CHECK-NEXT: [[MUL_4:%.+]] = mul i32 [[DIV_3]], 20
+// CHECK-NEXT: [[ADD_5:%.+]] = sub i32 [[ADD_3]], [[MUL_4]]
+// CHECK-NEXT: [[DIV_4:%.+]] = udiv i32 [[ADD_5]], 5
+// CHECK-NEXT: [[MUL_5:%.+]] = mul i32 [[DIV_4]], 1
+// CHECK-NEXT: [[ADD_6:%.+]] = add i32 3, [[MUL_5]]
+// CHECK-NEXT: store i32 [[ADD_6]], i32* [[LC_K:.+]]
+
+// CHECK: [[IV1_5:%.+]] = load i32, i32* [[OMP_IV]]{{.+}}!llvm.access.group
+// CHECK: [[IV1_5_1:%.+]] = load i32, i32* [[OMP_IV]]{{.+}}!llvm.access.group
+// CHECK-NEXT: [[DIV_5:%.+]] = udiv i32 [[IV1_5_1]], 60
+// CHECK-NEXT: [[MUL_6:%.+]] = mul i32 [[DIV_5]], 60
+// CHECK-NEXT: [[SUB_7:%.+]] = sub i32 [[IV1_5]], [[MUL_6]]
+
+// CHECK: [[IV1_6:%.+]] = load i32, i32* [[OMP_IV]]
+// CHECK: [[IV1_6_1:%.+]] = load i32, i32* [[OMP_IV]]
+// CHECK-NEXT: [[DIV_6:%.+]] = udiv i32 [[IV1_6_1]], 60
+// CHECK-NEXT: [[MUL_7:%.+]] = mul i32 [[DIV_6]], 60
+// CHECK-NEXT: [[SUB_10:%.+]] = sub i32 [[IV1_6]], [[MUL_7]]
+// CHECK-NEXT: [[DIV_7:%.+]] = udiv i32 [[SUB_10]], 20
+// CHECK-NEXT: [[MUL_8:%.+]] = mul i32 [[DIV_7]], 20
+// CHECK-NEXT: [[SUB_11:%.+]] = sub i32 [[SUB_7]], [[MUL_8]]
+
+// CHECK: [[IV1_7:%.+]] = load i32, i32* [[OMP_IV]]
+// CHECK: [[IV1_7_1:%.+]] = load i32, i32* [[OMP_IV]]
+// CHECK-NEXT: [[DIV_8:%.+]] = udiv i32 [[IV1_7_1]], 60
+// CHECK-NEXT: [[MUL_9:%.+]] = mul i32 [[DIV_8]], 60
+// CHECK-NEXT: [[SUB_12:%.+]] = sub i32 [[IV1_7]], [[MUL_9]]
+
+// CHECK: [[IV1_8:%.+]] = load i32, i32* [[OMP_IV]]
+// CHECK: [[IV1_8_1:%.+]] = load i32, i32* 

[PATCH] D56215: [lld] [ELF] Include default search paths for NetBSD driver

2019-01-08 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg added inline comments.



Comment at: ELF/Driver.cpp:779
+// TODO: verify the triple somehow?
+Config->TargetTriple = llvm::Triple(Prefix);
+  }

See ToolChain::getTargetAndModeFromProgramName in clang.


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

https://reviews.llvm.org/D56215



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


[PATCH] D56215: [lld] [ELF] Include default search paths for NetBSD driver

2019-01-08 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg added a comment.

Thanks, this looks like a good starting point.


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

https://reviews.llvm.org/D56215



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


[PATCH] D56424: [clang-tidy] Add check for underscores in googletest names.

2019-01-08 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: docs/ReleaseNotes.rst:161
+
+  Checks that Googletest test and test case names do not contain an underscore,
+  which is prohibited by the Googletest FAQ.

Please synchronize with first statement in documentation.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D56424



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


[PATCH] D56424: [clang-tidy] Add check for underscores in googletest names.

2019-01-08 Thread Kar Epker via Phabricator via cfe-commits
karepker added a comment.

In D56424#1349336 , @lebedev.ri wrote:

> In D56424#1349218 , @karepker wrote:
>
> > Clean up comments in test file.
>
>
> For reference, what documentation sources did you read when creating the 
> review itseft?
>  I thought it was documented that an appropriate category (`[clang-tidy]`) 
> should be present in the subject.


I see now that putting the category in the commit message is recommend by 
http://llvm.org/docs/DeveloperPolicy.html#commit-messages, though if I were 
reading that for the first time, it would have been unclear to me what the 
protocol for determining the category is (e.g. should this be `[clang-tidy]` 
vs. `[clang-tools-extra]`)?

When I was preparing this for review, though, I was mostly going by example off 
this previous patch: https://reviews.llvm.org/D18408.




Comment at: clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.cpp:1
+//===--- AvoidUnderscoreInGoogletestNameCheck.cpp - 
clang-tidy-===//
+//

MyDeveloperDay wrote:
> nit: space after tidy and before ---
I think I did this. Not sure which "---" you're referring to, but I think this 
comment is now in line with other clang-tidy comments I've looked at.



Comment at: clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.cpp:62
+std::string TestCaseName = PP->getSpelling(*TestCaseNameToken);
+if (TestCaseName.find('_') != std::string::npos) {
+  Check->diag(TestCaseNameToken->getLocation(),

JonasToth wrote:
> Maybe the duplicated `diag` call can be merged, you can store the diagnostic 
> with `auto Diag = Check->diag(...)` and pass in the right location and 
> arguments.
I don't think I understand the suggestion. Don't I have to pass in the location 
immediately? `Check->diag(...)` doesn't seem to have an overload that allows 
deferring passing in the location until later.



Comment at: clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.cpp:64
+  Check->diag(TestCaseNameToken->getLocation(),
+  "avoid using \"_\" in test case name \"%0\" according to "
+  "Googletest FAQ")

JonasToth wrote:
> Duplicated message text, you can store it in a local 
> variable/StringRef/StringLiteral,
> 
> ellide braces
The message text is not quite the same. The first says "test case name" and the 
second says "test name" per the naming conventions for the two name arguments 
to the test macros in Googletest. I preferred having these as two separate 
strings instead of trying to add the word "case" conditionally to one, which I 
thought would be too complex.

Please let me know if you feel differently or have other suggestions regarding 
the message.

Braces have been removed.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D56424



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


[PATCH] D56288: [ELF] Do not enable 'new dtags' on NetBSD by default

2019-01-08 Thread Michał Górny via Phabricator via cfe-commits
mgorny updated this revision to Diff 180718.
mgorny added a comment.

Updating for completeness.


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

https://reviews.llvm.org/D56288

Files:
  ELF/Driver.cpp


Index: ELF/Driver.cpp
===
--- ELF/Driver.cpp
+++ ELF/Driver.cpp
@@ -813,7 +813,8 @@
   Config->CallGraphProfileSort = Args.hasFlag(
   OPT_call_graph_profile_sort, OPT_no_call_graph_profile_sort, true);
   Config->EnableNewDtags =
-  Args.hasFlag(OPT_enable_new_dtags, OPT_disable_new_dtags, true);
+  Args.hasFlag(OPT_enable_new_dtags, OPT_disable_new_dtags,
+   !Config->TargetTriple.isOSNetBSD());
   Config->Entry = Args.getLastArgValue(OPT_entry);
   Config->ExecuteOnly =
   Args.hasFlag(OPT_execute_only, OPT_no_execute_only, false);


Index: ELF/Driver.cpp
===
--- ELF/Driver.cpp
+++ ELF/Driver.cpp
@@ -813,7 +813,8 @@
   Config->CallGraphProfileSort = Args.hasFlag(
   OPT_call_graph_profile_sort, OPT_no_call_graph_profile_sort, true);
   Config->EnableNewDtags =
-  Args.hasFlag(OPT_enable_new_dtags, OPT_disable_new_dtags, true);
+  Args.hasFlag(OPT_enable_new_dtags, OPT_disable_new_dtags,
+   !Config->TargetTriple.isOSNetBSD());
   Config->Entry = Args.getLastArgValue(OPT_entry);
   Config->ExecuteOnly =
   Args.hasFlag(OPT_execute_only, OPT_no_execute_only, false);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r350643 - Limit COFF 'common' emission to <=32 alignment types.

2019-01-08 Thread Shoaib Meenai via cfe-commits
Ah, looks like you were originally checking for COFF, and then David suggested 
checking for MSVC instead? I'm curious about why, although I'm sure the 
suggestion is legit :)

From: cfe-commits  on behalf of Shoaib 
Meenai via cfe-commits 
Reply-To: Shoaib Meenai 
Date: Tuesday, January 8, 2019 at 12:39 PM
To: Erich Keane , "cfe-commits@lists.llvm.org" 

Subject: Re: r350643 - Limit COFF 'common' emission to <=32 alignment types.

Why does this check for isKnownWindowsMSVCEnvironment specifically? Wouldn't 
any COFF target (windows-cygnus, windows-gnu, windows-itanium, etc.) have the 
same limitation, since it's an object file format issue and not an ABI issue?

From: cfe-commits  on behalf of Erich Keane 
via cfe-commits 
Reply-To: Erich Keane 
Date: Tuesday, January 8, 2019 at 10:48 AM
To: "cfe-commits@lists.llvm.org" 
Subject: r350643 - Limit COFF 'common' emission to <=32 alignment types.

Author: erichkeane
Date: Tue Jan  8 10:44:22 2019
New Revision: 350643

URL: 
https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D350643-26view-3Drev=DwIGaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=RNVKy_b0_Wgp_PTFDpvQXETsZdWubmT5SGnGz3GigS0=Ph9GOtRaQERmqyeJeAJTFwV3sg3q8fE05FlJ3qwNx4I=
Log:
Limit COFF 'common' emission to <=32 alignment types.

As reported in PR33035, LLVM crashes if given a common object with an
alignment of greater than 32 bits. This is because the COFF file format
does not support these alignments, so emitting them is broken anyway.

This patch changes any global definitions greater than 32 bit alignment
to no longer be in 'common'.

https://urldefense.proofpoint.com/v2/url?u=https-3A__bugs.llvm.org_show-5Fbug.cgi-3Fid-3D33035=DwIGaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=RNVKy_b0_Wgp_PTFDpvQXETsZdWubmT5SGnGz3GigS0=ac1NEHuvztd6jSTCsOUJajkklfeyqdzW-xqtddJ-hvM=

Differential Revision: 
https://urldefense.proofpoint.com/v2/url?u=https-3A__reviews.llvm.org_D56391=DwIGaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=RNVKy_b0_Wgp_PTFDpvQXETsZdWubmT5SGnGz3GigS0=AucP9Sp-DYHSaOP-sPfpAOrww3xwdh8FjQkHrLZhhyo=

Change-Id: I48609289753b7f3b58c5e2bc1712756750fbd45a

Added:
cfe/trunk/test/CodeGen/microsoft-no-common-align.c
Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_lib_CodeGen_CodeGenModule.cpp-3Frev-3D350643-26r1-3D350642-26r2-3D350643-26view-3Ddiff=DwIGaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=RNVKy_b0_Wgp_PTFDpvQXETsZdWubmT5SGnGz3GigS0=gmTnEmW03ruG8LbJluf5Z4yQcxM64QP7Ce1VTnVqvPo=
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Tue Jan  8 10:44:22 2019
@@ -3761,6 +3761,11 @@ static bool isVarDeclStrongDefinition(co
   }
 }
   }
+  // COFF doesn't support alignments greater than 32, so these cannot be
+  // in common.
+  if (Context.getTargetInfo().getTriple().isKnownWindowsMSVCEnvironment() &&
+  Context.getTypeAlignIfKnown(D->getType()) > 32)
+return true;
   return false;
}

Added: cfe/trunk/test/CodeGen/microsoft-no-common-align.c
URL: 
https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_test_CodeGen_microsoft-2Dno-2Dcommon-2Dalign.c-3Frev-3D350643-26view-3Dauto=DwIGaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=RNVKy_b0_Wgp_PTFDpvQXETsZdWubmT5SGnGz3GigS0=hzPmmVFbvg4OTEVpnQ5pIfy295Ne0-xAsctZs00WZgY=
==
--- cfe/trunk/test/CodeGen/microsoft-no-common-align.c (added)
+++ cfe/trunk/test/CodeGen/microsoft-no-common-align.c Tue Jan  8 10:44:22 2019
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -emit-llvm -o - %s | FileCheck 
%s
+typedef float TooLargeAlignment __attribute__((__vector_size__(64)));
+typedef float NormalAlignment __attribute__((__vector_size__(4)));
+
+TooLargeAlignment TooBig;
+// CHECK: @TooBig = dso_local global <16 x float>  zeroinitializer, align 64
+NormalAlignment JustRight;
+// CHECK: @JustRight = common dso_local global <1 x float>  zeroinitializer, 
align 4


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.llvm.org_cgi-2Dbin_mailman_listinfo_cfe-2Dcommits=DwIGaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=RNVKy_b0_Wgp_PTFDpvQXETsZdWubmT5SGnGz3GigS0=Myn7SZhcOe32EZiKZr4ByJAZOoFl5aIfmWV9555Vh9A=

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


[PATCH] D56215: [lld] [ELF] Include default search paths for NetBSD driver

2019-01-08 Thread Michał Górny via Phabricator via cfe-commits
mgorny updated this revision to Diff 180717.
mgorny added a comment.

Next version, based on recognizing NetBSD from triple.

@joerg, is this a better approach?


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

https://reviews.llvm.org/D56215

Files:
  ELF/Config.h
  ELF/Driver.cpp
  ELF/Driver.h


Index: ELF/Driver.h
===
--- ELF/Driver.h
+++ ELF/Driver.h
@@ -31,7 +31,9 @@
   void addLibrary(StringRef Name);
 
 private:
+  void setDefaultTargetTriple(StringRef argv0);
   void readConfigs(llvm::opt::InputArgList );
+  void appendDefaultSearchPaths();
   void createFiles(llvm::opt::InputArgList );
   void inferMachineType();
   template  void link(llvm::opt::InputArgList );
Index: ELF/Driver.cpp
===
--- ELF/Driver.cpp
+++ ELF/Driver.cpp
@@ -365,6 +365,23 @@
   error("unknown -z value: " + StringRef(Arg->getValue()));
 }
 
+void LinkerDriver::appendDefaultSearchPaths() {
+  if (Config->TargetTriple.isOSNetBSD()) {
+// NetBSD driver relies on the linker knowing the default search paths.
+// Please keep this in sync with clang/lib/Driver/ToolChains/NetBSD.cpp
+// (NetBSD::NetBSD constructor)
+switch (Config->EMachine) {
+  case EM_386:
+Config->SearchPaths.push_back("/usr/lib/i386");
+break;
+  case EM_X86_64:
+break;
+  // TODO: support non-x86 architectures
+}
+Config->SearchPaths.push_back("/usr/lib");
+  }
+}
+
 void LinkerDriver::main(ArrayRef ArgsArr) {
   ELFOptTable Parser;
   opt::InputArgList Args = Parser.parse(ArgsArr.slice(1));
@@ -410,8 +427,10 @@
 }
   }
 
+  setDefaultTargetTriple(ArgsArr[0]);
   readConfigs(Args);
   checkZOptions(Args);
+  appendDefaultSearchPaths();
 
   // The behavior of -v or --version is a bit strange, but this is
   // needed for compatibility with GNU linkers.
@@ -746,6 +765,21 @@
   error(Msg + ": " + StringRef(Err).trim());
 }
 
+void LinkerDriver::setDefaultTargetTriple(StringRef argv0) {
+  // Start with a default initial triple
+  Config->TargetTriple = llvm::Triple(getDefaultTargetTriple());
+
+  // Try to override triple with program name prefix
+  std::string ProgName = llvm::sys::path::stem(argv0);
+  size_t LastComponent = ProgName.rfind('-');
+  if (LastComponent != std::string::npos) {
+std::string Prefix = ProgName.substr(0, LastComponent);
+std::string IgnoredError;
+// TODO: verify the triple somehow?
+Config->TargetTriple = llvm::Triple(Prefix);
+  }
+}
+
 // Initializes Config members by the command line options.
 void LinkerDriver::readConfigs(opt::InputArgList ) {
   errorHandler().Verbose = Args.hasArg(OPT_verbose);
Index: ELF/Config.h
===
--- ELF/Config.h
+++ ELF/Config.h
@@ -14,6 +14,7 @@
 #include "llvm/ADT/MapVector.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSet.h"
+#include "llvm/ADT/Triple.h"
 #include "llvm/BinaryFormat/ELF.h"
 #include "llvm/Support/CachePruning.h"
 #include "llvm/Support/CodeGen.h"
@@ -276,6 +277,10 @@
 
   // 4 for ELF32, 8 for ELF64.
   int Wordsize;
+
+  // Target triple, inferred from program name or defaulted to LLVM
+  // default target.
+  llvm::Triple TargetTriple;
 };
 
 // The only instance of Configuration struct.


Index: ELF/Driver.h
===
--- ELF/Driver.h
+++ ELF/Driver.h
@@ -31,7 +31,9 @@
   void addLibrary(StringRef Name);
 
 private:
+  void setDefaultTargetTriple(StringRef argv0);
   void readConfigs(llvm::opt::InputArgList );
+  void appendDefaultSearchPaths();
   void createFiles(llvm::opt::InputArgList );
   void inferMachineType();
   template  void link(llvm::opt::InputArgList );
Index: ELF/Driver.cpp
===
--- ELF/Driver.cpp
+++ ELF/Driver.cpp
@@ -365,6 +365,23 @@
   error("unknown -z value: " + StringRef(Arg->getValue()));
 }
 
+void LinkerDriver::appendDefaultSearchPaths() {
+  if (Config->TargetTriple.isOSNetBSD()) {
+// NetBSD driver relies on the linker knowing the default search paths.
+// Please keep this in sync with clang/lib/Driver/ToolChains/NetBSD.cpp
+// (NetBSD::NetBSD constructor)
+switch (Config->EMachine) {
+  case EM_386:
+Config->SearchPaths.push_back("/usr/lib/i386");
+break;
+  case EM_X86_64:
+break;
+  // TODO: support non-x86 architectures
+}
+Config->SearchPaths.push_back("/usr/lib");
+  }
+}
+
 void LinkerDriver::main(ArrayRef ArgsArr) {
   ELFOptTable Parser;
   opt::InputArgList Args = Parser.parse(ArgsArr.slice(1));
@@ -410,8 +427,10 @@
 }
   }
 
+  setDefaultTargetTriple(ArgsArr[0]);
   readConfigs(Args);
   checkZOptions(Args);
+  appendDefaultSearchPaths();
 
   // The behavior of -v or --version is a bit strange, but this is
   // needed for compatibility with GNU linkers.

Re: r350643 - Limit COFF 'common' emission to <=32 alignment types.

2019-01-08 Thread Shoaib Meenai via cfe-commits
Why does this check for isKnownWindowsMSVCEnvironment specifically? Wouldn't 
any COFF target (windows-cygnus, windows-gnu, windows-itanium, etc.) have the 
same limitation, since it's an object file format issue and not an ABI issue?

From: cfe-commits  on behalf of Erich Keane 
via cfe-commits 
Reply-To: Erich Keane 
Date: Tuesday, January 8, 2019 at 10:48 AM
To: "cfe-commits@lists.llvm.org" 
Subject: r350643 - Limit COFF 'common' emission to <=32 alignment types.

Author: erichkeane
Date: Tue Jan  8 10:44:22 2019
New Revision: 350643

URL: 
https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D350643-26view-3Drev=DwIGaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=RNVKy_b0_Wgp_PTFDpvQXETsZdWubmT5SGnGz3GigS0=Ph9GOtRaQERmqyeJeAJTFwV3sg3q8fE05FlJ3qwNx4I=
Log:
Limit COFF 'common' emission to <=32 alignment types.

As reported in PR33035, LLVM crashes if given a common object with an
alignment of greater than 32 bits. This is because the COFF file format
does not support these alignments, so emitting them is broken anyway.

This patch changes any global definitions greater than 32 bit alignment
to no longer be in 'common'.

https://urldefense.proofpoint.com/v2/url?u=https-3A__bugs.llvm.org_show-5Fbug.cgi-3Fid-3D33035=DwIGaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=RNVKy_b0_Wgp_PTFDpvQXETsZdWubmT5SGnGz3GigS0=ac1NEHuvztd6jSTCsOUJajkklfeyqdzW-xqtddJ-hvM=

Differential Revision: 
https://urldefense.proofpoint.com/v2/url?u=https-3A__reviews.llvm.org_D56391=DwIGaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=RNVKy_b0_Wgp_PTFDpvQXETsZdWubmT5SGnGz3GigS0=AucP9Sp-DYHSaOP-sPfpAOrww3xwdh8FjQkHrLZhhyo=

Change-Id: I48609289753b7f3b58c5e2bc1712756750fbd45a

Added:
cfe/trunk/test/CodeGen/microsoft-no-common-align.c
Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_lib_CodeGen_CodeGenModule.cpp-3Frev-3D350643-26r1-3D350642-26r2-3D350643-26view-3Ddiff=DwIGaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=RNVKy_b0_Wgp_PTFDpvQXETsZdWubmT5SGnGz3GigS0=gmTnEmW03ruG8LbJluf5Z4yQcxM64QP7Ce1VTnVqvPo=
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Tue Jan  8 10:44:22 2019
@@ -3761,6 +3761,11 @@ static bool isVarDeclStrongDefinition(co
   }
 }
   }
+  // COFF doesn't support alignments greater than 32, so these cannot be
+  // in common.
+  if (Context.getTargetInfo().getTriple().isKnownWindowsMSVCEnvironment() &&
+  Context.getTypeAlignIfKnown(D->getType()) > 32)
+return true;
   return false;
}

Added: cfe/trunk/test/CodeGen/microsoft-no-common-align.c
URL: 
https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_test_CodeGen_microsoft-2Dno-2Dcommon-2Dalign.c-3Frev-3D350643-26view-3Dauto=DwIGaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=RNVKy_b0_Wgp_PTFDpvQXETsZdWubmT5SGnGz3GigS0=hzPmmVFbvg4OTEVpnQ5pIfy295Ne0-xAsctZs00WZgY=
==
--- cfe/trunk/test/CodeGen/microsoft-no-common-align.c (added)
+++ cfe/trunk/test/CodeGen/microsoft-no-common-align.c Tue Jan  8 10:44:22 2019
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -emit-llvm -o - %s | FileCheck 
%s
+typedef float TooLargeAlignment __attribute__((__vector_size__(64)));
+typedef float NormalAlignment __attribute__((__vector_size__(4)));
+
+TooLargeAlignment TooBig;
+// CHECK: @TooBig = dso_local global <16 x float>  zeroinitializer, align 64
+NormalAlignment JustRight;
+// CHECK: @JustRight = common dso_local global <1 x float>  zeroinitializer, 
align 4


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.llvm.org_cgi-2Dbin_mailman_listinfo_cfe-2Dcommits=DwIGaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=RNVKy_b0_Wgp_PTFDpvQXETsZdWubmT5SGnGz3GigS0=Myn7SZhcOe32EZiKZr4ByJAZOoFl5aIfmWV9555Vh9A=

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


[PATCH] D56424: [clang-tidy] Add check for underscores in googletest names.

2019-01-08 Thread Kar Epker via Phabricator via cfe-commits
karepker updated this revision to Diff 180716.
karepker marked 15 inline comments as done.
karepker added a comment.

Address comments.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D56424

Files:
  clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.cpp
  clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.h
  clang-tidy/google/CMakeLists.txt
  clang-tidy/google/GoogleTidyModule.cpp
  docs/ReleaseNotes.rst
  
docs/clang-tidy/checks/google-readability-avoid-underscore-in-googletest-name.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/readability-avoid-underscore-in-googletest-name.cpp

Index: test/clang-tidy/readability-avoid-underscore-in-googletest-name.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-avoid-underscore-in-googletest-name.cpp
@@ -0,0 +1,108 @@
+// RUN: %check_clang_tidy %s google-readability-avoid-underscore-in-googletest-name %t
+
+#define TEST(test_case_name, test_name) void test_case_name##test_name()
+#define TEST_F(test_case_name, test_name) void test_case_name##test_name()
+#define TEST_P(test_case_name, test_name) void test_case_name##test_name()
+#define TYPED_TEST(test_case_name, test_name) void test_case_name##test_name()
+#define TYPED_TEST_P(test_case_name, test_name) void test_case_name##test_name()
+#define FRIEND_TEST(test_case_name, test_name) void test_case_name##test_name()
+
+TEST(TestCaseName, Illegal_TestName) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: avoid using "_" in test name "Illegal_TestName" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
+
+TEST(TestCaseName, DISABLED_Illegal_TestName) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: avoid using "_" in test name "Illegal_TestName" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
+TEST(TestCaseName, Illegal_Test_Name) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: avoid using "_" in test name "Illegal_Test_Name" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
+TEST(Illegal_TestCaseName, TestName) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: avoid using "_" in test case name "Illegal_TestCaseName" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
+TEST(Illegal_Test_CaseName, TestName) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: avoid using "_" in test case name "Illegal_Test_CaseName" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
+TEST(Illegal_TestCaseName, Illegal_TestName) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: avoid using "_" in test case name "Illegal_TestCaseName" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
+// CHECK-MESSAGES: :[[@LINE-2]]:28: warning: avoid using "_" in test name "Illegal_TestName" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
+
+TEST_F(TestCaseFixtureName, Illegal_TestName) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: avoid using "_" in test name "Illegal_TestName" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
+TEST_F(TestCaseFixtureName, DISABLED_Illegal_Test_Name) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: avoid using "_" in test name "Illegal_Test_Name" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
+TEST_F(TestCaseFixtureName, Illegal_Test_Name) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: avoid using "_" in test name "Illegal_Test_Name" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
+
+TEST_F(Illegal_TestCaseFixtureName, TestName) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: avoid using "_" in test case name "Illegal_TestCaseFixtureName" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
+TEST_F(Illegal_TestCaseFixtureName, Illegal_TestName) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: avoid using "_" in test case name "Illegal_TestCaseFixtureName" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
+// CHECK-MESSAGES: :[[@LINE-2]]:37: warning: avoid using "_" in test name "Illegal_TestName" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
+
+TEST_F(Illegal_Test_CaseFixtureName, TestName) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: avoid using "_" in test case name "Illegal_Test_CaseFixtureName" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
+
+TEST_P(ParameterizedTestCaseFixtureName, Illegal_TestName) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:42: warning: avoid using "_" in test name "Illegal_TestName" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
+TEST_P(ParameterizedTestCaseFixtureName, DISABLED_Illegal_TestName) {}
+// 

r350649 - [Sema] Teach Clang that aligned allocation is not supported with macosx10.13

2019-01-08 Thread Louis Dionne via cfe-commits
Author: ldionne
Date: Tue Jan  8 12:26:56 2019
New Revision: 350649

URL: http://llvm.org/viewvc/llvm-project?rev=350649=rev
Log:
[Sema] Teach Clang that aligned allocation is not supported with macosx10.13

Summary:
r306722 added diagnostics when aligned allocation is used with deployment
targets that do not support it, but the first macosx supporting aligned
allocation was incorrectly set to 10.13. In reality, the dylib shipped
with macosx10.13 does not support aligned allocation, but the dylib
shipped with macosx10.14 does.

Reviewers: ahatanak

Subscribers: christof, jkorous, dexonsmith, cfe-commits

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

Modified:
cfe/trunk/include/clang/Basic/AlignedAllocation.h
cfe/trunk/test/Driver/unavailable_aligned_allocation.cpp
cfe/trunk/test/SemaCXX/unavailable_aligned_allocation.cpp

Modified: cfe/trunk/include/clang/Basic/AlignedAllocation.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AlignedAllocation.h?rev=350649=350648=350649=diff
==
--- cfe/trunk/include/clang/Basic/AlignedAllocation.h (original)
+++ cfe/trunk/include/clang/Basic/AlignedAllocation.h Tue Jan  8 12:26:56 2019
@@ -27,8 +27,8 @@ inline llvm::VersionTuple alignedAllocMi
   default:
 break;
   case llvm::Triple::Darwin:
-  case llvm::Triple::MacOSX: // Earliest supporting version is 10.13.
-return llvm::VersionTuple(10U, 13U);
+  case llvm::Triple::MacOSX: // Earliest supporting version is 10.14.
+return llvm::VersionTuple(10U, 14U);
   case llvm::Triple::IOS:
   case llvm::Triple::TvOS: // Earliest supporting version is 11.0.0.
 return llvm::VersionTuple(11U);

Modified: cfe/trunk/test/Driver/unavailable_aligned_allocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/unavailable_aligned_allocation.cpp?rev=350649=350648=350649=diff
==
--- cfe/trunk/test/Driver/unavailable_aligned_allocation.cpp (original)
+++ cfe/trunk/test/Driver/unavailable_aligned_allocation.cpp Tue Jan  8 
12:26:56 2019
@@ -1,4 +1,4 @@
-// RUN: %clang -target x86_64-apple-macosx10.12 -c -### %s 2>&1 \
+// RUN: %clang -target x86_64-apple-macosx10.13 -c -### %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=UNAVAILABLE
 //
 // RUN: %clang -target arm64-apple-ios10 -c -### %s 2>&1 \
@@ -24,7 +24,7 @@
 //
 // UNAVAILABLE: "-faligned-alloc-unavailable"
 
-// RUN: %clang -target x86_64-apple-macosx10.13 -c -### %s 2>&1 \
+// RUN: %clang -target x86_64-apple-macosx10.14 -c -### %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=AVAILABLE
 //
 // RUN: %clang -target arm64-apple-ios11 -c -### %s 2>&1 \
@@ -54,10 +54,10 @@
 // Check that passing -faligned-allocation or -fno-aligned-allocation stops the
 // driver from passing -faligned-alloc-unavailable to cc1.
 //
-// RUN: %clang -target x86_64-apple-macosx10.12 -faligned-allocation -c -### 
%s 2>&1 \
+// RUN: %clang -target x86_64-apple-macosx10.13 -faligned-allocation -c -### 
%s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=AVAILABLE
 //
-// RUN: %clang -target x86_64-apple-macosx10.12 -fno-aligned-allocation -c 
-### %s 2>&1 \
+// RUN: %clang -target x86_64-apple-macosx10.13 -fno-aligned-allocation -c 
-### %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=AVAILABLE
 
 // AVAILABLE-NOT: "-faligned-alloc-unavailable"

Modified: cfe/trunk/test/SemaCXX/unavailable_aligned_allocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/unavailable_aligned_allocation.cpp?rev=350649=350648=350649=diff
==
--- cfe/trunk/test/SemaCXX/unavailable_aligned_allocation.cpp (original)
+++ cfe/trunk/test/SemaCXX/unavailable_aligned_allocation.cpp Tue Jan  8 
12:26:56 2019
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.12.0 -fexceptions 
-faligned-alloc-unavailable -std=c++1z -verify %s
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.12.0 -fexceptions -std=c++1z 
-verify -DNO_ERRORS %s
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.12.0 -fexceptions 
-faligned-allocation -faligned-alloc-unavailable -std=c++14 -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.0 -fexceptions 
-faligned-alloc-unavailable -std=c++1z -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.0 -fexceptions -std=c++1z 
-verify -DNO_ERRORS %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.0 -fexceptions 
-faligned-allocation -faligned-alloc-unavailable -std=c++14 -verify %s
 // RUN: %clang_cc1 -triple arm64-apple-ios10.0.0 -fexceptions 
-faligned-alloc-unavailable -std=c++1z -verify -DIOS %s
 // RUN: %clang_cc1 -triple arm64-apple-ios10.0.0 -fexceptions -std=c++1z 
-verify -DNO_ERRORS %s
 // RUN: %clang_cc1 -triple arm64-apple-tvos10.0.0 -fexceptions 
-faligned-alloc-unavailable -std=c++1z -verify -DTVOS %s
@@ -117,8 +117,8 @@ void 

[PATCH] D56445: [Sema] Teach Clang that aligned allocation is not supported with macosx10.13

2019-01-08 Thread Louis Dionne via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL350649: [Sema] Teach Clang that aligned allocation is not 
supported with macosx10.13 (authored by ldionne, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D56445?vs=180688=180715#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D56445

Files:
  cfe/trunk/include/clang/Basic/AlignedAllocation.h
  cfe/trunk/test/Driver/unavailable_aligned_allocation.cpp
  cfe/trunk/test/SemaCXX/unavailable_aligned_allocation.cpp
  
libcxx/trunk/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp
  libcxx/trunk/test/libcxx/memory/aligned_allocation_macro.pass.cpp

Index: libcxx/trunk/test/libcxx/memory/aligned_allocation_macro.pass.cpp
===
--- libcxx/trunk/test/libcxx/memory/aligned_allocation_macro.pass.cpp
+++ libcxx/trunk/test/libcxx/memory/aligned_allocation_macro.pass.cpp
@@ -9,14 +9,17 @@
 
 // UNSUPPORTED: c++98, c++03, c++11, c++14
 
-// Aligned allocation functions are not provided prior to macosx10.13, but
-// AppleClang <= 10 does not know about this restriction and always enables them.
-// XFAIL: !(apple-clang-9 || apple-clang-10) && availability=macosx10.12
-// XFAIL: !(apple-clang-9 || apple-clang-10) && availability=macosx10.11
-// XFAIL: !(apple-clang-9 || apple-clang-10) && availability=macosx10.10
-// XFAIL: !(apple-clang-9 || apple-clang-10) && availability=macosx10.9
-// XFAIL: !(apple-clang-9 || apple-clang-10) && availability=macosx10.8
-// XFAIL: !(apple-clang-9 || apple-clang-10) && availability=macosx10.7
+// AppleClang <= 10 enables aligned allocation regardless of the deployment
+// target, so this test would fail.
+// UNSUPPORTED: apple-clang-9, apple-clang-10
+
+// XFAIL: availability=macosx10.13
+// XFAIL: availability=macosx10.12
+// XFAIL: availability=macosx10.11
+// XFAIL: availability=macosx10.10
+// XFAIL: availability=macosx10.9
+// XFAIL: availability=macosx10.8
+// XFAIL: availability=macosx10.7
 
 #include 
 
Index: libcxx/trunk/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp
===
--- libcxx/trunk/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp
+++ libcxx/trunk/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp
@@ -14,9 +14,15 @@
 // definitions, which does not yet provide aligned allocation
 // XFAIL: LIBCXX-WINDOWS-FIXME
 
-// Clang 10 (and older) will trigger an availability error when the deployment
+// AppleClang 10 (and older) will trigger an availability error when the deployment
 // target does not support aligned allocation, even if we pass `-faligned-allocation`.
+// XFAIL: apple-clang-10 && availability=macosx10.13
 // XFAIL: apple-clang-10 && availability=macosx10.12
+// XFAIL: apple-clang-10 && availability=macosx10.11
+// XFAIL: apple-clang-10 && availability=macosx10.10
+// XFAIL: apple-clang-10 && availability=macosx10.9
+// XFAIL: apple-clang-10 && availability=macosx10.8
+// XFAIL: apple-clang-10 && availability=macosx10.7
 
 // The dylibs shipped before macosx10.14 do not contain the aligned allocation
 // functions, so trying to force using those with -faligned-allocation results
Index: cfe/trunk/include/clang/Basic/AlignedAllocation.h
===
--- cfe/trunk/include/clang/Basic/AlignedAllocation.h
+++ cfe/trunk/include/clang/Basic/AlignedAllocation.h
@@ -27,8 +27,8 @@
   default:
 break;
   case llvm::Triple::Darwin:
-  case llvm::Triple::MacOSX: // Earliest supporting version is 10.13.
-return llvm::VersionTuple(10U, 13U);
+  case llvm::Triple::MacOSX: // Earliest supporting version is 10.14.
+return llvm::VersionTuple(10U, 14U);
   case llvm::Triple::IOS:
   case llvm::Triple::TvOS: // Earliest supporting version is 11.0.0.
 return llvm::VersionTuple(11U);
Index: cfe/trunk/test/Driver/unavailable_aligned_allocation.cpp
===
--- cfe/trunk/test/Driver/unavailable_aligned_allocation.cpp
+++ cfe/trunk/test/Driver/unavailable_aligned_allocation.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang -target x86_64-apple-macosx10.12 -c -### %s 2>&1 \
+// RUN: %clang -target x86_64-apple-macosx10.13 -c -### %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=UNAVAILABLE
 //
 // RUN: %clang -target arm64-apple-ios10 -c -### %s 2>&1 \
@@ -24,7 +24,7 @@
 //
 // UNAVAILABLE: "-faligned-alloc-unavailable"
 
-// RUN: %clang -target x86_64-apple-macosx10.13 -c -### %s 2>&1 \
+// RUN: %clang -target x86_64-apple-macosx10.14 -c -### %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=AVAILABLE
 //
 // RUN: %clang -target arm64-apple-ios11 -c -### %s 2>&1 \
@@ -54,10 +54,10 @@
 // Check that passing -faligned-allocation or 

[PATCH] D55483: Introduce the callback attribute and emit !callback metadata

2019-01-08 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert updated this revision to Diff 180714.
jdoerfert added a comment.

Fix tests


Repository:
  rC Clang

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

https://reviews.llvm.org/D55483

Files:
  include/clang/AST/ASTContext.h
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/Builtins.def
  include/clang/Basic/Builtins.h
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/AST/ASTContext.cpp
  lib/Basic/Builtins.cpp
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/Analysis/retain-release.m
  test/CodeGen/attr-callback.c
  test/CodeGen/callback_annotated.c
  test/CodeGen/callback_openmp.c
  test/CodeGen/callback_pthread_create.c
  test/CodeGenCXX/attr-callback.cpp
  test/Misc/pragma-attribute-supported-attributes-list.test
  test/OpenMP/parallel_codegen.cpp
  test/Sema/attr-callback-broken.c
  test/Sema/attr-callback.c
  test/SemaCXX/attr-callback-broken.cpp
  test/SemaCXX/attr-callback.cpp
  utils/TableGen/ClangAttrEmitter.cpp

Index: utils/TableGen/ClangAttrEmitter.cpp
===
--- utils/TableGen/ClangAttrEmitter.cpp
+++ utils/TableGen/ClangAttrEmitter.cpp
@@ -1275,6 +1275,8 @@
 Ptr = llvm::make_unique(Arg, Attr, "unsigned");
   else if (ArgName == "VariadicUnsignedArgument")
 Ptr = llvm::make_unique(Arg, Attr, "unsigned");
+  else if (ArgName == "VariadicSignedArgument")
+Ptr = llvm::make_unique(Arg, Attr, "int");
   else if (ArgName == "VariadicStringArgument")
 Ptr = llvm::make_unique(Arg, Attr);
   else if (ArgName == "VariadicEnumArgument")
Index: test/SemaCXX/attr-callback.cpp
===
--- /dev/null
+++ test/SemaCXX/attr-callback.cpp
@@ -0,0 +1,67 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+
+// expected-no-diagnostics
+
+class C_in_class {
+#include "../Sema/attr-callback.c"
+};
+
+struct Base {
+
+  void no_args_1(void (*callback)(void));
+  __attribute__((callback(1))) void no_args_2(void (*callback)(void));
+  __attribute__((callback(1))) void no_args_3(void (*callback)(void)) {}
+
+  __attribute__((callback(1, 0))) virtual void
+  this_tr(void (*callback)(Base *));
+
+  __attribute__((callback(1, 0, -1, 0))) virtual void
+  this_unknown_this(void (*callback)(Base *, Base *, Base *));
+
+  __attribute__((callback(1))) virtual void
+  virtual_1(void (*callback)(void));
+
+  __attribute__((callback(1))) virtual void
+  virtual_2(void (*callback)(void));
+
+  __attribute__((callback(1))) virtual void
+  virtual_3(void (*callback)(void));
+};
+
+__attribute__((callback(1))) void
+Base::no_args_1(void (*callback)(void)) {
+}
+
+void Base::no_args_2(void (*callback)(void)) {
+}
+
+struct Derived_1 : public Base {
+
+  __attribute__((callback(1, 0))) virtual void
+  this_tr(void (*callback)(Base *)) override;
+
+  __attribute__((callback(1))) virtual void
+  virtual_1(void (*callback)(void)) override {}
+
+  virtual void
+  virtual_3(void (*callback)(void)) override {}
+};
+
+struct Derived_2 : public Base {
+
+  __attribute__((callback(1))) virtual void
+  virtual_1(void (*callback)(void)) override;
+
+  virtual void
+  virtual_2(void (*callback)(void)) override;
+
+  virtual void
+  virtual_3(void (*callback)(void)) override;
+};
+
+void Derived_2::virtual_1(void (*callback)(void)) {}
+
+__attribute__((callback(1))) void
+Derived_2::virtual_2(void (*callback)(void)) {}
+
+void Derived_2::virtual_3(void (*callback)(void)) {}
Index: test/SemaCXX/attr-callback-broken.cpp
===
--- /dev/null
+++ test/SemaCXX/attr-callback-broken.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+
+class C_in_class {
+#define HAS_THIS
+#include "../Sema/attr-callback-broken.c"
+#undef HAS_THIS
+};
Index: test/Sema/attr-callback.c
===
--- /dev/null
+++ test/Sema/attr-callback.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+
+// expected-no-diagnostics
+
+__attribute__((callback(1))) void no_args(void (*callback)(void));
+__attribute__((callback(1, 2, 3)))   void args_1(void (*callback)(int, double), int a, double b);
+__attribute__((callback(2, 3, 3)))   void args_2(int a, void (*callback)(double, double), double b);
+__attribute__((callback(2, -1, -1))) void args_3(int a, void (*callback)(double, double), double b);
Index: test/Sema/attr-callback-broken.c
===
--- /dev/null
+++ test/Sema/attr-callback-broken.c
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+
+__attribute__((callback())) void no_callee(void (*callback)(void)); // expected-error {{'callback' attribute takes at least 1 argument}}
+
+__attribute__((callback(1, 1)))void too_many_args_1(void   (*callback)(void)) {}   // expected-error {{'callback' 

r350648 - Fix clang for r350647: Missed a function rename

2019-01-08 Thread Philip Pfaffe via cfe-commits
Author: pfaffe
Date: Tue Jan  8 12:00:55 2019
New Revision: 350648

URL: http://llvm.org/viewvc/llvm-project?rev=350648=rev
Log:
Fix clang for r350647: Missed a function rename

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

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=350648=350647=350648=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Tue Jan  8 12:00:55 2019
@@ -53,9 +53,10 @@
 #include "llvm/Transforms/IPO/ThinLTOBitcodeWriter.h"
 #include "llvm/Transforms/InstCombine/InstCombine.h"
 #include "llvm/Transforms/Instrumentation.h"
-#include "llvm/Transforms/Instrumentation/MemorySanitizer.h"
 #include "llvm/Transforms/Instrumentation/BoundsChecking.h"
 #include "llvm/Transforms/Instrumentation/GCOVProfiler.h"
+#include "llvm/Transforms/Instrumentation/MemorySanitizer.h"
+#include "llvm/Transforms/Instrumentation/ThreadSanitizer.h"
 #include "llvm/Transforms/ObjCARC.h"
 #include "llvm/Transforms/Scalar.h"
 #include "llvm/Transforms/Scalar/GVN.h"
@@ -305,7 +306,7 @@ static void addKernelMemorySanitizerPass
 
 static void addThreadSanitizerPass(const PassManagerBuilder ,
legacy::PassManagerBase ) {
-  PM.add(createThreadSanitizerPass());
+  PM.add(createThreadSanitizerLegacyPassPass());
 }
 
 static void addDataFlowSanitizerPass(const PassManagerBuilder ,


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


[PATCH] D56413: [OpenMP] Avoid remainder operations for loop index values on a collapsed loop nest.

2019-01-08 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


Repository:
  rC Clang

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

https://reviews.llvm.org/D56413



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


[PATCH] D56413: [OpenMP] Avoid remainder operations for loop index values on a collapsed loop nest.

2019-01-08 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 180713.
gtbercea added a comment.

Remove redundant initalization.


Repository:
  rC Clang

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

https://reviews.llvm.org/D56413

Files:
  lib/Sema/SemaOpenMP.cpp
  test/OpenMP/for_codegen.cpp
  test/OpenMP/for_simd_codegen.cpp
  test/OpenMP/parallel_for_simd_codegen.cpp
  test/OpenMP/simd_codegen.cpp

Index: test/OpenMP/simd_codegen.cpp
===
--- test/OpenMP/simd_codegen.cpp
+++ test/OpenMP/simd_codegen.cpp
@@ -278,8 +278,11 @@
 // CHECK-NEXT: [[I_2:%.+]] = trunc i64 [[I_1_ADD0]] to i32
 // CHECK-NEXT: store i32 [[I_2]], i32* {{%.+}}{{.*}}!llvm.mem.parallel_loop_access ![[T1_ID]]
 // CHECK: [[IV2:%.+]] = load i64, i64* [[T1_OMP_IV]]{{.*}}!llvm.mem.parallel_loop_access ![[T1_ID]]
-// CHECK-NEXT: [[J_1:%.+]] = srem i64 [[IV2]], 4
-// CHECK-NEXT: [[J_2:%.+]] = mul nsw i64 [[J_1]], 2
+// CHECK: [[IV2_1:%.+]] = load i64, i64* [[T1_OMP_IV]]{{.*}}!llvm.mem.parallel_loop_access ![[T1_ID]]
+// CHECK-NEXT: [[I_1_DIV1:%.+]] = sdiv i64 [[IV2_1]], 4
+// CHECK-NEXT: [[I_1_MUL1:%.+]] = mul nsw i64 [[I_1_DIV1]], 4
+// CHECK-NEXT: [[I_1_SUB0:%.+]] = sub nsw i64 [[IV2]], [[I_1_MUL1]]
+// CHECK-NEXT: [[J_2:%.+]] = mul nsw i64 [[I_1_SUB0]], 2
 // CHECK-NEXT: [[J_2_ADD0:%.+]] = add nsw i64 0, [[J_2]]
 // CHECK-NEXT: store i64 [[J_2_ADD0]], i64* {{%.+}}{{.*}}!llvm.mem.parallel_loop_access ![[T1_ID]]
 // simd.for.inc:
@@ -393,22 +396,70 @@
 // CHECK-NEXT: [[CALC_I_1_MUL1:%.+]] = mul i32 [[CALC_I_1]], 1
 // CHECK-NEXT: [[CALC_I_2:%.+]] = add i32 1, [[CALC_I_1_MUL1]]
 // CHECK-NEXT: store i32 [[CALC_I_2]], i32* [[LC_I:.+]]
+
 // CHECK: [[IV1_2:%.+]] = load i32, i32* [[OMP_IV]]{{.+}}!llvm.mem.parallel_loop_access ![[COLL1_LOOP_ID]]
-// CHECK-NEXT: [[CALC_J_1:%.+]] = udiv i32 [[IV1_2]], 20
-// CHECK-NEXT: [[CALC_J_2:%.+]] = urem i32 [[CALC_J_1]], 3
+// CHECK: [[IV1_2_1:%.+]] = load i32, i32* [[OMP_IV]]{{.+}}!llvm.mem.parallel_loop_access ![[COLL1_LOOP_ID]]
+// CHECK-NEXT: [[CALC_J_1:%.+]] = udiv i32 [[IV1_2_1]], 60
+// CHECK-NEXT: [[MUL_1:%.+]] = mul i32 [[CALC_J_1]], 60
+// CHECK-NEXT: [[SUB_3:%.+]] = sub i32 [[IV1_2]], [[MUL_1]]
+// CHECK-NEXT: [[CALC_J_2:%.+]] = udiv i32 [[SUB_3]], 20
 // CHECK-NEXT: [[CALC_J_2_MUL1:%.+]] = mul i32 [[CALC_J_2]], 1
 // CHECK-NEXT: [[CALC_J_3:%.+]] = add i32 2, [[CALC_J_2_MUL1]]
 // CHECK-NEXT: store i32 [[CALC_J_3]], i32* [[LC_J:.+]]
+
 // CHECK: [[IV1_3:%.+]] = load i32, i32* [[OMP_IV]]{{.+}}!llvm.mem.parallel_loop_access ![[COLL1_LOOP_ID]]
-// CHECK-NEXT: [[CALC_K_1:%.+]] = udiv i32 [[IV1_3]], 5
-// CHECK-NEXT: [[CALC_K_2:%.+]] = urem i32 [[CALC_K_1]], 4
-// CHECK-NEXT: [[CALC_K_2_MUL1:%.+]] = mul i32 [[CALC_K_2]], 1
-// CHECK-NEXT: [[CALC_K_3:%.+]] = add i32 3, [[CALC_K_2_MUL1]]
-// CHECK-NEXT: store i32 [[CALC_K_3]], i32* [[LC_K:.+]]
-// CHECK: [[IV1_4:%.+]] = load i32, i32* [[OMP_IV]]{{.+}}!llvm.mem.parallel_loop_access ![[COLL1_LOOP_ID]]
-// CHECK-NEXT: [[CALC_L_1:%.+]] = urem i32 [[IV1_4]], 5
-// CHECK-NEXT: [[CALC_L_1_MUL1:%.+]] = mul i32 [[CALC_L_1]], 1
-// CHECK-NEXT: [[CALC_L_2:%.+]] = add i32 4, [[CALC_L_1_MUL1]]
+// CHECK: [[IV1_3_1:%.+]] = load i32, i32* [[OMP_IV]]{{.+}}!llvm.mem.parallel_loop_access ![[COLL1_LOOP_ID]]
+// CHECK-NEXT: [[DIV_1:%.+]] = udiv i32 [[IV1_3_1]], 60
+// CHECK-NEXT: [[MUL_2:%.+]] = mul i32 [[DIV_1]], 60
+// CHECK-NEXT: [[ADD_3:%.+]] = sub i32 [[IV1_3]], [[MUL_2]]
+
+// CHECK: [[IV1_4:%.+]] = load i32, i32* [[OMP_IV]]
+// CHECK: [[IV1_4_1:%.+]] = load i32, i32* [[OMP_IV]]
+// CHECK-NEXT: [[DIV_2:%.+]] = udiv i32 [[IV1_4_1]], 60
+// CHECK-NEXT: [[MUL_3:%.+]] = mul i32 [[DIV_2]], 60
+// CHECK-NEXT: [[SUB_6:%.+]] = sub i32 [[IV1_4]], [[MUL_3]]
+// CHECK-NEXT: [[DIV_3:%.+]] = udiv i32 [[SUB_6]], 20
+// CHECK-NEXT: [[MUL_4:%.+]] = mul i32 [[DIV_3]], 20
+// CHECK-NEXT: [[ADD_5:%.+]] = sub i32 [[ADD_3]], [[MUL_4]]
+// CHECK-NEXT: [[DIV_4:%.+]] = udiv i32 [[ADD_5]], 5
+// CHECK-NEXT: [[MUL_5:%.+]] = mul i32 [[DIV_4]], 1
+// CHECK-NEXT: [[ADD_6:%.+]] = add i32 3, [[MUL_5]]
+// CHECK-NEXT: store i32 [[ADD_6]], i32* [[LC_K:.+]]
+
+// CHECK: [[IV1_5:%.+]] = load i32, i32* [[OMP_IV]]{{.+}}!llvm.mem.parallel_loop_access ![[COLL1_LOOP_ID]]
+// CHECK: [[IV1_5_1:%.+]] = load i32, i32* [[OMP_IV]]{{.+}}!llvm.mem.parallel_loop_access ![[COLL1_LOOP_ID]]
+// CHECK-NEXT: [[DIV_5:%.+]] = udiv i32 [[IV1_5_1]], 60
+// CHECK-NEXT: [[MUL_6:%.+]] = mul i32 [[DIV_5]], 60
+// CHECK-NEXT: [[SUB_7:%.+]] = sub i32 [[IV1_5]], [[MUL_6]]
+
+// CHECK: [[IV1_6:%.+]] = load i32, i32* [[OMP_IV]]
+// CHECK: [[IV1_6_1:%.+]] = load i32, i32* [[OMP_IV]]
+// CHECK-NEXT: [[DIV_6:%.+]] = udiv i32 [[IV1_6_1]], 60
+// CHECK-NEXT: [[MUL_7:%.+]] = mul i32 [[DIV_6]], 60
+// CHECK-NEXT: [[SUB_10:%.+]] = sub i32 [[IV1_6]], [[MUL_7]]
+// CHECK-NEXT: [[DIV_7:%.+]] = udiv i32 [[SUB_10]], 20
+// CHECK-NEXT: [[MUL_8:%.+]] = mul i32 [[DIV_7]], 20
+// CHECK-NEXT: [[SUB_11:%.+]] = sub i32 [[SUB_7]], [[MUL_8]]
+
+// CHECK: [[IV1_7:%.+]] = load i32, i32* 

[PATCH] D56413: [OpenMP] Avoid remainder operations for loop index values on a collapsed loop nest.

2019-01-08 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: lib/Sema/SemaOpenMP.cpp:5523
   SourceLocation UpdLoc = IS.IncSrcRange.getBegin();
-  // Build: Iter = (IV / Div) % IS.NumIters
-  // where Div is product of previous iterations' IS.NumIters.
-  ExprResult Iter;
-  if (Div.isUsable()) {
-Iter =
-SemaRef.BuildBinOp(CurScope, UpdLoc, BO_Div, IV.get(), Div.get());
-  } else {
-Iter = IV;
-assert((Cnt == (int)NestedLoopCount - 1) &&
-   "unusable div expected on first iteration only");
-  }
-
-  if (Cnt != 0 && Iter.isUsable())
-Iter = SemaRef.BuildBinOp(CurScope, UpdLoc, BO_Rem, Iter.get(),
-  IS.NumIterations);
+  ExprResult Iter = IV;
+

Do you need to initialize `Iter` here?


Repository:
  rC Clang

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

https://reviews.llvm.org/D56413



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


[PATCH] D56413: [OpenMP] Avoid remainder operations for loop index values on a collapsed loop nest.

2019-01-08 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 180711.
gtbercea added a comment.

Fix update.


Repository:
  rC Clang

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

https://reviews.llvm.org/D56413

Files:
  lib/Sema/SemaOpenMP.cpp
  test/OpenMP/for_codegen.cpp
  test/OpenMP/for_simd_codegen.cpp
  test/OpenMP/parallel_for_simd_codegen.cpp
  test/OpenMP/simd_codegen.cpp

Index: test/OpenMP/simd_codegen.cpp
===
--- test/OpenMP/simd_codegen.cpp
+++ test/OpenMP/simd_codegen.cpp
@@ -278,8 +278,11 @@
 // CHECK-NEXT: [[I_2:%.+]] = trunc i64 [[I_1_ADD0]] to i32
 // CHECK-NEXT: store i32 [[I_2]], i32* {{%.+}}{{.*}}!llvm.mem.parallel_loop_access ![[T1_ID]]
 // CHECK: [[IV2:%.+]] = load i64, i64* [[T1_OMP_IV]]{{.*}}!llvm.mem.parallel_loop_access ![[T1_ID]]
-// CHECK-NEXT: [[J_1:%.+]] = srem i64 [[IV2]], 4
-// CHECK-NEXT: [[J_2:%.+]] = mul nsw i64 [[J_1]], 2
+// CHECK: [[IV2_1:%.+]] = load i64, i64* [[T1_OMP_IV]]{{.*}}!llvm.mem.parallel_loop_access ![[T1_ID]]
+// CHECK-NEXT: [[I_1_DIV1:%.+]] = sdiv i64 [[IV2_1]], 4
+// CHECK-NEXT: [[I_1_MUL1:%.+]] = mul nsw i64 [[I_1_DIV1]], 4
+// CHECK-NEXT: [[I_1_SUB0:%.+]] = sub nsw i64 [[IV2]], [[I_1_MUL1]]
+// CHECK-NEXT: [[J_2:%.+]] = mul nsw i64 [[I_1_SUB0]], 2
 // CHECK-NEXT: [[J_2_ADD0:%.+]] = add nsw i64 0, [[J_2]]
 // CHECK-NEXT: store i64 [[J_2_ADD0]], i64* {{%.+}}{{.*}}!llvm.mem.parallel_loop_access ![[T1_ID]]
 // simd.for.inc:
@@ -393,22 +396,70 @@
 // CHECK-NEXT: [[CALC_I_1_MUL1:%.+]] = mul i32 [[CALC_I_1]], 1
 // CHECK-NEXT: [[CALC_I_2:%.+]] = add i32 1, [[CALC_I_1_MUL1]]
 // CHECK-NEXT: store i32 [[CALC_I_2]], i32* [[LC_I:.+]]
+
 // CHECK: [[IV1_2:%.+]] = load i32, i32* [[OMP_IV]]{{.+}}!llvm.mem.parallel_loop_access ![[COLL1_LOOP_ID]]
-// CHECK-NEXT: [[CALC_J_1:%.+]] = udiv i32 [[IV1_2]], 20
-// CHECK-NEXT: [[CALC_J_2:%.+]] = urem i32 [[CALC_J_1]], 3
+// CHECK: [[IV1_2_1:%.+]] = load i32, i32* [[OMP_IV]]{{.+}}!llvm.mem.parallel_loop_access ![[COLL1_LOOP_ID]]
+// CHECK-NEXT: [[CALC_J_1:%.+]] = udiv i32 [[IV1_2_1]], 60
+// CHECK-NEXT: [[MUL_1:%.+]] = mul i32 [[CALC_J_1]], 60
+// CHECK-NEXT: [[SUB_3:%.+]] = sub i32 [[IV1_2]], [[MUL_1]]
+// CHECK-NEXT: [[CALC_J_2:%.+]] = udiv i32 [[SUB_3]], 20
 // CHECK-NEXT: [[CALC_J_2_MUL1:%.+]] = mul i32 [[CALC_J_2]], 1
 // CHECK-NEXT: [[CALC_J_3:%.+]] = add i32 2, [[CALC_J_2_MUL1]]
 // CHECK-NEXT: store i32 [[CALC_J_3]], i32* [[LC_J:.+]]
+
 // CHECK: [[IV1_3:%.+]] = load i32, i32* [[OMP_IV]]{{.+}}!llvm.mem.parallel_loop_access ![[COLL1_LOOP_ID]]
-// CHECK-NEXT: [[CALC_K_1:%.+]] = udiv i32 [[IV1_3]], 5
-// CHECK-NEXT: [[CALC_K_2:%.+]] = urem i32 [[CALC_K_1]], 4
-// CHECK-NEXT: [[CALC_K_2_MUL1:%.+]] = mul i32 [[CALC_K_2]], 1
-// CHECK-NEXT: [[CALC_K_3:%.+]] = add i32 3, [[CALC_K_2_MUL1]]
-// CHECK-NEXT: store i32 [[CALC_K_3]], i32* [[LC_K:.+]]
-// CHECK: [[IV1_4:%.+]] = load i32, i32* [[OMP_IV]]{{.+}}!llvm.mem.parallel_loop_access ![[COLL1_LOOP_ID]]
-// CHECK-NEXT: [[CALC_L_1:%.+]] = urem i32 [[IV1_4]], 5
-// CHECK-NEXT: [[CALC_L_1_MUL1:%.+]] = mul i32 [[CALC_L_1]], 1
-// CHECK-NEXT: [[CALC_L_2:%.+]] = add i32 4, [[CALC_L_1_MUL1]]
+// CHECK: [[IV1_3_1:%.+]] = load i32, i32* [[OMP_IV]]{{.+}}!llvm.mem.parallel_loop_access ![[COLL1_LOOP_ID]]
+// CHECK-NEXT: [[DIV_1:%.+]] = udiv i32 [[IV1_3_1]], 60
+// CHECK-NEXT: [[MUL_2:%.+]] = mul i32 [[DIV_1]], 60
+// CHECK-NEXT: [[ADD_3:%.+]] = sub i32 [[IV1_3]], [[MUL_2]]
+
+// CHECK: [[IV1_4:%.+]] = load i32, i32* [[OMP_IV]]
+// CHECK: [[IV1_4_1:%.+]] = load i32, i32* [[OMP_IV]]
+// CHECK-NEXT: [[DIV_2:%.+]] = udiv i32 [[IV1_4_1]], 60
+// CHECK-NEXT: [[MUL_3:%.+]] = mul i32 [[DIV_2]], 60
+// CHECK-NEXT: [[SUB_6:%.+]] = sub i32 [[IV1_4]], [[MUL_3]]
+// CHECK-NEXT: [[DIV_3:%.+]] = udiv i32 [[SUB_6]], 20
+// CHECK-NEXT: [[MUL_4:%.+]] = mul i32 [[DIV_3]], 20
+// CHECK-NEXT: [[ADD_5:%.+]] = sub i32 [[ADD_3]], [[MUL_4]]
+// CHECK-NEXT: [[DIV_4:%.+]] = udiv i32 [[ADD_5]], 5
+// CHECK-NEXT: [[MUL_5:%.+]] = mul i32 [[DIV_4]], 1
+// CHECK-NEXT: [[ADD_6:%.+]] = add i32 3, [[MUL_5]]
+// CHECK-NEXT: store i32 [[ADD_6]], i32* [[LC_K:.+]]
+
+// CHECK: [[IV1_5:%.+]] = load i32, i32* [[OMP_IV]]{{.+}}!llvm.mem.parallel_loop_access ![[COLL1_LOOP_ID]]
+// CHECK: [[IV1_5_1:%.+]] = load i32, i32* [[OMP_IV]]{{.+}}!llvm.mem.parallel_loop_access ![[COLL1_LOOP_ID]]
+// CHECK-NEXT: [[DIV_5:%.+]] = udiv i32 [[IV1_5_1]], 60
+// CHECK-NEXT: [[MUL_6:%.+]] = mul i32 [[DIV_5]], 60
+// CHECK-NEXT: [[SUB_7:%.+]] = sub i32 [[IV1_5]], [[MUL_6]]
+
+// CHECK: [[IV1_6:%.+]] = load i32, i32* [[OMP_IV]]
+// CHECK: [[IV1_6_1:%.+]] = load i32, i32* [[OMP_IV]]
+// CHECK-NEXT: [[DIV_6:%.+]] = udiv i32 [[IV1_6_1]], 60
+// CHECK-NEXT: [[MUL_7:%.+]] = mul i32 [[DIV_6]], 60
+// CHECK-NEXT: [[SUB_10:%.+]] = sub i32 [[IV1_6]], [[MUL_7]]
+// CHECK-NEXT: [[DIV_7:%.+]] = udiv i32 [[SUB_10]], 20
+// CHECK-NEXT: [[MUL_8:%.+]] = mul i32 [[DIV_7]], 20
+// CHECK-NEXT: [[SUB_11:%.+]] = sub i32 [[SUB_7]], [[MUL_8]]
+
+// CHECK: [[IV1_7:%.+]] = load i32, i32* [[OMP_IV]]
+// CHECK: 

[PATCH] D55483: Introduce the callback attribute and emit !callback metadata

2019-01-08 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert updated this revision to Diff 180710.
jdoerfert marked 3 inline comments as done.
jdoerfert added a comment.

Update encoding, rebase to HEAD


Repository:
  rC Clang

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

https://reviews.llvm.org/D55483

Files:
  include/clang/AST/ASTContext.h
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/Builtins.def
  include/clang/Basic/Builtins.h
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/AST/ASTContext.cpp
  lib/Basic/Builtins.cpp
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/Analysis/retain-release.m
  test/CodeGen/attr-callback.c
  test/CodeGen/callback_annotated.c
  test/CodeGen/callback_openmp.c
  test/CodeGen/callback_pthread_create.c
  test/CodeGenCXX/attr-callback.cpp
  test/Misc/pragma-attribute-supported-attributes-list.test
  test/OpenMP/parallel_codegen.cpp
  test/Sema/attr-callback-broken.c
  test/Sema/attr-callback.c
  test/SemaCXX/attr-callback-broken.cpp
  test/SemaCXX/attr-callback.cpp
  utils/TableGen/ClangAttrEmitter.cpp

Index: utils/TableGen/ClangAttrEmitter.cpp
===
--- utils/TableGen/ClangAttrEmitter.cpp
+++ utils/TableGen/ClangAttrEmitter.cpp
@@ -1275,6 +1275,8 @@
 Ptr = llvm::make_unique(Arg, Attr, "unsigned");
   else if (ArgName == "VariadicUnsignedArgument")
 Ptr = llvm::make_unique(Arg, Attr, "unsigned");
+  else if (ArgName == "VariadicSignedArgument")
+Ptr = llvm::make_unique(Arg, Attr, "int");
   else if (ArgName == "VariadicStringArgument")
 Ptr = llvm::make_unique(Arg, Attr);
   else if (ArgName == "VariadicEnumArgument")
Index: test/SemaCXX/attr-callback.cpp
===
--- /dev/null
+++ test/SemaCXX/attr-callback.cpp
@@ -0,0 +1,67 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+
+// expected-no-diagnostics
+
+class C_in_class {
+#include "../Sema/attr-callback.c"
+};
+
+struct Base {
+
+  void no_args_1(void (*callback)(void));
+  __attribute__((callback(1))) void no_args_2(void (*callback)(void));
+  __attribute__((callback(1))) void no_args_3(void (*callback)(void)) {}
+
+  __attribute__((callback(1, 0))) virtual void
+  this_tr(void (*callback)(Base *));
+
+  __attribute__((callback(1, 0, -1, 0))) virtual void
+  this_unknown_this(void (*callback)(Base *, Base *, Base *));
+
+  __attribute__((callback(1))) virtual void
+  virtual_1(void (*callback)(void));
+
+  __attribute__((callback(1))) virtual void
+  virtual_2(void (*callback)(void));
+
+  __attribute__((callback(1))) virtual void
+  virtual_3(void (*callback)(void));
+};
+
+__attribute__((callback(1))) void
+Base::no_args_1(void (*callback)(void)) {
+}
+
+void Base::no_args_2(void (*callback)(void)) {
+}
+
+struct Derived_1 : public Base {
+
+  __attribute__((callback(1, 0))) virtual void
+  this_tr(void (*callback)(Base *)) override;
+
+  __attribute__((callback(1))) virtual void
+  virtual_1(void (*callback)(void)) override {}
+
+  virtual void
+  virtual_3(void (*callback)(void)) override {}
+};
+
+struct Derived_2 : public Base {
+
+  __attribute__((callback(1))) virtual void
+  virtual_1(void (*callback)(void)) override;
+
+  virtual void
+  virtual_2(void (*callback)(void)) override;
+
+  virtual void
+  virtual_3(void (*callback)(void)) override;
+};
+
+void Derived_2::virtual_1(void (*callback)(void)) {}
+
+__attribute__((callback(1))) void
+Derived_2::virtual_2(void (*callback)(void)) {}
+
+void Derived_2::virtual_3(void (*callback)(void)) {}
Index: test/SemaCXX/attr-callback-broken.cpp
===
--- /dev/null
+++ test/SemaCXX/attr-callback-broken.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+
+class C_in_class {
+#define HAS_THIS
+#include "../Sema/attr-callback-broken.c"
+#undef HAS_THIS
+};
Index: test/Sema/attr-callback.c
===
--- /dev/null
+++ test/Sema/attr-callback.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+
+// expected-no-diagnostics
+
+__attribute__((callback(1))) void no_args(void (*callback)(void));
+__attribute__((callback(1, 2, 3)))   void args_1(void (*callback)(int, double), int a, double b);
+__attribute__((callback(2, 3, 3)))   void args_2(int a, void (*callback)(double, double), double b);
+__attribute__((callback(2, -1, -1))) void args_3(int a, void (*callback)(double, double), double b);
Index: test/Sema/attr-callback-broken.c
===
--- /dev/null
+++ test/Sema/attr-callback-broken.c
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+
+__attribute__((callback())) void no_callee(void (*callback)(void)); // expected-error {{'callback' attribute takes at least 1 argument}}
+
+__attribute__((callback(1, 1)))void 

[PATCH] D56413: [OpenMP] Avoid remainder operations for loop index values on a collapsed loop nest.

2019-01-08 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 180709.
gtbercea added a comment.

  Invert accumulation direction.


Repository:
  rC Clang

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

https://reviews.llvm.org/D56413

Files:
  docs/OpenMPSupport.rst
  include/clang/Basic/LangOptions.def
  include/clang/Driver/Options.td
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Sema/SemaOpenMP.cpp
  test/OpenMP/for_codegen.cpp
  test/OpenMP/for_simd_codegen.cpp
  test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
  test/OpenMP/parallel_for_simd_codegen.cpp
  test/OpenMP/simd_codegen.cpp

Index: test/OpenMP/simd_codegen.cpp
===
--- test/OpenMP/simd_codegen.cpp
+++ test/OpenMP/simd_codegen.cpp
@@ -278,8 +278,11 @@
 // CHECK-NEXT: [[I_2:%.+]] = trunc i64 [[I_1_ADD0]] to i32
 // CHECK-NEXT: store i32 [[I_2]], i32* {{%.+}}{{.*}}!llvm.mem.parallel_loop_access ![[T1_ID]]
 // CHECK: [[IV2:%.+]] = load i64, i64* [[T1_OMP_IV]]{{.*}}!llvm.mem.parallel_loop_access ![[T1_ID]]
-// CHECK-NEXT: [[J_1:%.+]] = srem i64 [[IV2]], 4
-// CHECK-NEXT: [[J_2:%.+]] = mul nsw i64 [[J_1]], 2
+// CHECK: [[IV2_1:%.+]] = load i64, i64* [[T1_OMP_IV]]{{.*}}!llvm.mem.parallel_loop_access ![[T1_ID]]
+// CHECK-NEXT: [[I_1_DIV1:%.+]] = sdiv i64 [[IV2_1]], 4
+// CHECK-NEXT: [[I_1_MUL1:%.+]] = mul nsw i64 [[I_1_DIV1]], 4
+// CHECK-NEXT: [[I_1_SUB0:%.+]] = sub nsw i64 [[IV2]], [[I_1_MUL1]]
+// CHECK-NEXT: [[J_2:%.+]] = mul nsw i64 [[I_1_SUB0]], 2
 // CHECK-NEXT: [[J_2_ADD0:%.+]] = add nsw i64 0, [[J_2]]
 // CHECK-NEXT: store i64 [[J_2_ADD0]], i64* {{%.+}}{{.*}}!llvm.mem.parallel_loop_access ![[T1_ID]]
 // simd.for.inc:
@@ -393,22 +396,70 @@
 // CHECK-NEXT: [[CALC_I_1_MUL1:%.+]] = mul i32 [[CALC_I_1]], 1
 // CHECK-NEXT: [[CALC_I_2:%.+]] = add i32 1, [[CALC_I_1_MUL1]]
 // CHECK-NEXT: store i32 [[CALC_I_2]], i32* [[LC_I:.+]]
+
 // CHECK: [[IV1_2:%.+]] = load i32, i32* [[OMP_IV]]{{.+}}!llvm.mem.parallel_loop_access ![[COLL1_LOOP_ID]]
-// CHECK-NEXT: [[CALC_J_1:%.+]] = udiv i32 [[IV1_2]], 20
-// CHECK-NEXT: [[CALC_J_2:%.+]] = urem i32 [[CALC_J_1]], 3
+// CHECK: [[IV1_2_1:%.+]] = load i32, i32* [[OMP_IV]]{{.+}}!llvm.mem.parallel_loop_access ![[COLL1_LOOP_ID]]
+// CHECK-NEXT: [[CALC_J_1:%.+]] = udiv i32 [[IV1_2_1]], 60
+// CHECK-NEXT: [[MUL_1:%.+]] = mul i32 [[CALC_J_1]], 60
+// CHECK-NEXT: [[SUB_3:%.+]] = sub i32 [[IV1_2]], [[MUL_1]]
+// CHECK-NEXT: [[CALC_J_2:%.+]] = udiv i32 [[SUB_3]], 20
 // CHECK-NEXT: [[CALC_J_2_MUL1:%.+]] = mul i32 [[CALC_J_2]], 1
 // CHECK-NEXT: [[CALC_J_3:%.+]] = add i32 2, [[CALC_J_2_MUL1]]
 // CHECK-NEXT: store i32 [[CALC_J_3]], i32* [[LC_J:.+]]
+
 // CHECK: [[IV1_3:%.+]] = load i32, i32* [[OMP_IV]]{{.+}}!llvm.mem.parallel_loop_access ![[COLL1_LOOP_ID]]
-// CHECK-NEXT: [[CALC_K_1:%.+]] = udiv i32 [[IV1_3]], 5
-// CHECK-NEXT: [[CALC_K_2:%.+]] = urem i32 [[CALC_K_1]], 4
-// CHECK-NEXT: [[CALC_K_2_MUL1:%.+]] = mul i32 [[CALC_K_2]], 1
-// CHECK-NEXT: [[CALC_K_3:%.+]] = add i32 3, [[CALC_K_2_MUL1]]
-// CHECK-NEXT: store i32 [[CALC_K_3]], i32* [[LC_K:.+]]
-// CHECK: [[IV1_4:%.+]] = load i32, i32* [[OMP_IV]]{{.+}}!llvm.mem.parallel_loop_access ![[COLL1_LOOP_ID]]
-// CHECK-NEXT: [[CALC_L_1:%.+]] = urem i32 [[IV1_4]], 5
-// CHECK-NEXT: [[CALC_L_1_MUL1:%.+]] = mul i32 [[CALC_L_1]], 1
-// CHECK-NEXT: [[CALC_L_2:%.+]] = add i32 4, [[CALC_L_1_MUL1]]
+// CHECK: [[IV1_3_1:%.+]] = load i32, i32* [[OMP_IV]]{{.+}}!llvm.mem.parallel_loop_access ![[COLL1_LOOP_ID]]
+// CHECK-NEXT: [[DIV_1:%.+]] = udiv i32 [[IV1_3_1]], 60
+// CHECK-NEXT: [[MUL_2:%.+]] = mul i32 [[DIV_1]], 60
+// CHECK-NEXT: [[ADD_3:%.+]] = sub i32 [[IV1_3]], [[MUL_2]]
+
+// CHECK: [[IV1_4:%.+]] = load i32, i32* [[OMP_IV]]
+// CHECK: [[IV1_4_1:%.+]] = load i32, i32* [[OMP_IV]]
+// CHECK-NEXT: [[DIV_2:%.+]] = udiv i32 [[IV1_4_1]], 60
+// CHECK-NEXT: [[MUL_3:%.+]] = mul i32 [[DIV_2]], 60
+// CHECK-NEXT: [[SUB_6:%.+]] = sub i32 [[IV1_4]], [[MUL_3]]
+// CHECK-NEXT: [[DIV_3:%.+]] = udiv i32 [[SUB_6]], 20
+// CHECK-NEXT: [[MUL_4:%.+]] = mul i32 [[DIV_3]], 20
+// CHECK-NEXT: [[ADD_5:%.+]] = sub i32 [[ADD_3]], [[MUL_4]]
+// CHECK-NEXT: [[DIV_4:%.+]] = udiv i32 [[ADD_5]], 5
+// CHECK-NEXT: [[MUL_5:%.+]] = mul i32 [[DIV_4]], 1
+// CHECK-NEXT: [[ADD_6:%.+]] = add i32 3, [[MUL_5]]
+// CHECK-NEXT: store i32 [[ADD_6]], i32* [[LC_K:.+]]
+
+// CHECK: [[IV1_5:%.+]] = load i32, i32* [[OMP_IV]]{{.+}}!llvm.mem.parallel_loop_access ![[COLL1_LOOP_ID]]
+// CHECK: [[IV1_5_1:%.+]] = load i32, i32* [[OMP_IV]]{{.+}}!llvm.mem.parallel_loop_access ![[COLL1_LOOP_ID]]
+// CHECK-NEXT: [[DIV_5:%.+]] = udiv i32 [[IV1_5_1]], 60
+// CHECK-NEXT: [[MUL_6:%.+]] = mul i32 [[DIV_5]], 60
+// CHECK-NEXT: [[SUB_7:%.+]] = sub i32 [[IV1_5]], [[MUL_6]]
+
+// CHECK: [[IV1_6:%.+]] = load i32, i32* [[OMP_IV]]
+// CHECK: [[IV1_6_1:%.+]] = load i32, i32* [[OMP_IV]]
+// CHECK-NEXT: [[DIV_6:%.+]] = udiv i32 [[IV1_6_1]], 60
+// CHECK-NEXT: [[MUL_7:%.+]] = mul i32 [[DIV_6]], 60
+// CHECK-NEXT: [[SUB_10:%.+]] = sub i32 

[PATCH] D55224: [clangd] Introduce loading of shards within auto-index

2019-01-08 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clangd/index/Background.cpp:259
+  // if this thread sees the older version but finishes later. This should
+  // be rare in practice.
+  DigestIt.first->second = Hash;

ilya-biryukov wrote:
> kadircet wrote:
> > ilya-biryukov wrote:
> > > > "should be rare in practice"
> > > And yet, can we avoid this altogether?
> > > 
> > > Also, I believe it won't be rare. When processing multiple different TUs, 
> > > we can easily run into the same header multiple times, possibly with the 
> > > different contents.
> > > E.g. imagine the index for the whole of clang is being built and the user 
> > > is editing `Sema.h` at the same time. We'll definitely be running into 
> > > this case over and over again.
> > Well I am open to ideas, but currently there is no way of knowing whether 
> > this is the newer version for the file. Because only information we have is 
> > the digest is different than what we currently have and this doesn't yield 
> > any chronological information.
> Do we know which request is "newer" when scheduling it?
> If so, we could keep the map of the **latest** hashes of the files we've seen 
> (in addition to the `IndexedFileDigests`, which correspond to the digest for 
> which we built the index IIUC).
> 
> This would give us a simple invariant of the final state we want to bring the 
> index to: `IndexedFileDigests` should correspond to the latest hashes seen so 
> far. If not, we have to rebuild the index for the corresponding files. That, 
> in turn, gives us a way to resolve conflicts: we should never replace with 
> symbols built for the latest version (hash) of the file we've seen.
> 
> Would that work?
I am not sure if it would work for non-main files. We update the Hash for the 
main files at each indexing action, so we can safely keep track of the latest 
versions. But we collect hashes for dependencies while performing the indexing 
which happens in parallel. Therefore an indexing action triggered earlier might 
get an up-to-date version of a dependency than an action triggered later-on.



Comment at: clangd/index/Background.cpp:468
+if (!Shard || !Shard->Sources) {
+  vlog("Failed to load shard: {0}", CurDependencyPath);
+  continue;

ilya-biryukov wrote:
> Should we mark the file as requiring re-indexing at this point?
> Not sure how that might happen in practice, but still...
All files are marked as requiring re-indexing by default 
`Dependencies.push_back({AbsolutePath, true})`. The second element is always 
true, and we only mark it as false if we are sure file is up-to-date.



Comment at: clangd/index/Background.cpp:475
+if (auto AbsolutePath = URI::resolve(*U, CurDependencyPath)) {
+  if (*AbsolutePath != CurDependencyPath) {
+if (InQueue.try_emplace(*AbsolutePath).second)

ilya-biryukov wrote:
> Why do we need an extra check for self-edges here? Shouldn't 
> `InQueue.try_emplace` handle this too?
It is not looking for a self-edge. It is trying to find source information 
related to current file(which contains symbols, refs and hash). The nesting 
seems to be confusing it was just to prevent one redundant try_emplace seems 
like making the code less readable taking it out.



Comment at: clangd/index/Background.h:108
   BackgroundIndexStorage::Factory IndexStorageFactory;
+  // Loads the shards for all the sources and headers of the Cmd. Returns the
+  // list of dependencies for this Cmd and whether they need to be re-indexed.

ilya-biryukov wrote:
> Could you elaborate what are the "sources and headers of the Cmd"? The 
> compile command is typically created for a **single** source file, so this 
> comment looks a bit confusing.
It seems like comment become out-dated marking as done.



Comment at: clangd/index/Background.h:121
+  std::vector>
+  );
+  void enqueue(tooling::CompileCommand Cmd, BackgroundIndexStorage *Storage);

ilya-biryukov wrote:
> Maybe return `Expected>` instead of using an out parameter?
Actually this function can no longer fail, therefore directly returning the 
vector


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D55224



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


[PATCH] D55224: [clangd] Introduce loading of shards within auto-index

2019-01-08 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 180706.
kadircet marked 23 inline comments as done.
kadircet added a comment.

Address comments


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D55224

Files:
  clangd/SourceCode.cpp
  clangd/SourceCode.h
  clangd/index/Background.cpp
  clangd/index/Background.h
  clangd/index/SymbolCollector.cpp
  test/clangd/background-index.test
  unittests/clangd/BackgroundIndexTests.cpp

Index: unittests/clangd/BackgroundIndexTests.cpp
===
--- unittests/clangd/BackgroundIndexTests.cpp
+++ unittests/clangd/BackgroundIndexTests.cpp
@@ -7,6 +7,7 @@
 
 using testing::_;
 using testing::AllOf;
+using testing::Contains;
 using testing::Not;
 using testing::UnorderedElementsAre;
 
@@ -125,7 +126,7 @@
FileURI("unittest:///root/B.cc")}));
 }
 
-TEST_F(BackgroundIndexTest, ShardStorageWriteTest) {
+TEST_F(BackgroundIndexTest, ShardStorageTest) {
   MockFSProvider FS;
   FS.Files[testPath("root/A.h")] = R"cpp(
   void common();
@@ -154,6 +155,16 @@
   EXPECT_EQ(CacheHits, 0U);
   EXPECT_EQ(Storage.size(), 2U);
 
+  {
+OverlayCDB CDB(/*Base=*/nullptr);
+BackgroundIndex Idx(Context::empty(), "", FS, CDB,
+[&](llvm::StringRef) { return  });
+CDB.setCompileCommand(testPath("root"), Cmd);
+ASSERT_TRUE(Idx.blockUntilIdleForTest());
+  }
+  EXPECT_EQ(CacheHits, 2U); // Check both A.cc and A.h loaded from cache.
+  EXPECT_EQ(Storage.size(), 2U);
+
   auto ShardHeader = MSS.loadShard(testPath("root/A.h"));
   EXPECT_NE(ShardHeader, nullptr);
   EXPECT_THAT(
@@ -221,5 +232,73 @@
   EmptyIncludeNode());
 }
 
+TEST_F(BackgroundIndexTest, ShardStorageLoad) {
+  MockFSProvider FS;
+  FS.Files[testPath("root/A.h")] = R"cpp(
+  void common();
+  void f_b();
+  class A_CC {};
+  )cpp";
+  FS.Files[testPath("root/A.cc")] =
+  "#include \"A.h\"\nvoid g() { (void)common; }";
+
+  llvm::StringMap Storage;
+  size_t CacheHits = 0;
+  MemoryShardStorage MSS(Storage, CacheHits);
+
+  tooling::CompileCommand Cmd;
+  Cmd.Filename = testPath("root/A.cc");
+  Cmd.Directory = testPath("root");
+  Cmd.CommandLine = {"clang++", testPath("root/A.cc")};
+  // Check nothing is loaded from Storage, but A.cc and A.h has been stored.
+  {
+OverlayCDB CDB(/*Base=*/nullptr);
+BackgroundIndex Idx(Context::empty(), "", FS, CDB,
+[&](llvm::StringRef) { return  });
+CDB.setCompileCommand(testPath("root/A.cc"), Cmd);
+ASSERT_TRUE(Idx.blockUntilIdleForTest());
+  }
+
+  // Change header.
+  FS.Files[testPath("root/A.h")] = R"cpp(
+  void common();
+  void f_b();
+  class A_CC {};
+  class A_CCnew {};
+  )cpp";
+  {
+OverlayCDB CDB(/*Base=*/nullptr);
+BackgroundIndex Idx(Context::empty(), "", FS, CDB,
+[&](llvm::StringRef) { return  });
+CDB.setCompileCommand(testPath("root"), Cmd);
+ASSERT_TRUE(Idx.blockUntilIdleForTest());
+  }
+  EXPECT_EQ(CacheHits, 2U); // Check both A.cc and A.h loaded from cache.
+
+  // Check if the new symbol has arrived.
+  auto ShardHeader = MSS.loadShard(testPath("root/A.h"));
+  EXPECT_NE(ShardHeader, nullptr);
+  EXPECT_THAT(*ShardHeader->Symbols, Contains(Named("A_CCnew")));
+
+  // Change source.
+  FS.Files[testPath("root/A.cc")] =
+  "#include \"A.h\"\nvoid g() { (void)common; }\nvoid f_b() {}";
+  {
+CacheHits = 0;
+OverlayCDB CDB(/*Base=*/nullptr);
+BackgroundIndex Idx(Context::empty(), "", FS, CDB,
+[&](llvm::StringRef) { return  });
+CDB.setCompileCommand(testPath("root"), Cmd);
+ASSERT_TRUE(Idx.blockUntilIdleForTest());
+  }
+  EXPECT_EQ(CacheHits, 2U); // Check both A.cc and A.h loaded from cache.
+
+  // Check if the new symbol has arrived.
+  auto ShardSource = MSS.loadShard(testPath("root/A.cc"));
+  EXPECT_NE(ShardHeader, nullptr);
+  EXPECT_THAT(*ShardSource->Symbols,
+  Contains(AllOf(Named("f_b"), Declared(), Defined(;
+}
+
 } // namespace clangd
 } // namespace clang
Index: test/clangd/background-index.test
===
--- test/clangd/background-index.test
+++ test/clangd/background-index.test
@@ -16,6 +16,5 @@
 # RUN: ls %t/.clangd-index/foo.cpp.*.idx
 
 # Test the index is read from disk: delete code and restart clangd.
-# FIXME: This test currently fails as we don't read the index yet.
 # RUN: rm %t/foo.cpp
-# RUN: clangd -background-index -lit-test < %t/definition.jsonrpc | not FileCheck %t/definition.jsonrpc
+# RUN: clangd -background-index -lit-test < %t/definition.jsonrpc | FileCheck %t/definition.jsonrpc
Index: clangd/index/SymbolCollector.cpp
===
--- clangd/index/SymbolCollector.cpp
+++ clangd/index/SymbolCollector.cpp
@@ -58,29 +58,10 @@
   

[PATCH] D56445: [Sema] Teach Clang that aligned allocation is not supported with macosx10.13

2019-01-08 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak accepted this revision.
ahatanak added a comment.
This revision is now accepted and ready to land.

LGTM.

We should probably check that alignedAllocMinVersion returns the correct 
versions for other OSes too, but this patch is fine.


Repository:
  rC Clang

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

https://reviews.llvm.org/D56445



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


r350645 - Fix opencl test broken on windows by r350643.

2019-01-08 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Tue Jan  8 11:10:43 2019
New Revision: 350645

URL: http://llvm.org/viewvc/llvm-project?rev=350645=rev
Log:
Fix opencl test broken on windows by r350643.

Windows doesn't allow common with alignment >32 bits, so these tests
were broken in windows mode.  This patch makes 'common' optional in
these cases.

Change-Id: I4d5fdd07ecdafc3570ef9b09cd816c2e5e4ed15e

Modified:
cfe/trunk/test/CodeGenOpenCL/address-spaces.cl

Modified: cfe/trunk/test/CodeGenOpenCL/address-spaces.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/address-spaces.cl?rev=350645=350644=350645=diff
==
--- cfe/trunk/test/CodeGenOpenCL/address-spaces.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/address-spaces.cl Tue Jan  8 11:10:43 2019
@@ -19,7 +19,7 @@ struct S {
 // CL20-DAG: @g_static_var = internal addrspace(1) global float 0.00e+00
 
 #ifdef CL20
-// CL20-DAG: @g_s = common {{(dso_local )?}}addrspace(1) global %struct.S 
zeroinitializer
+// CL20-DAG: @g_s = {{(common )?}}{{(dso_local )?}}addrspace(1) global 
%struct.S zeroinitializer
 struct S g_s;
 #endif
 
@@ -55,7 +55,7 @@ void fc(constant int *arg) {}
 int i;
 // CL20-DAG: @i = common {{(dso_local )?}}addrspace(1) global i32 0
 int *ptr;
-// CL20SPIR-DAG: @ptr = common {{(dso_local )?}}addrspace(1) global i32 
addrspace(4)* null
+// CL20SPIR-DAG: @ptr = {{(common )?}}{{(dso_local )?}}addrspace(1) global i32 
addrspace(4)* null
 // CL20AMDGCN-DAG: @ptr = common {{(dso_local )?}}addrspace(1) global i32* null
 #endif
 


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


r350643 - Limit COFF 'common' emission to <=32 alignment types.

2019-01-08 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Tue Jan  8 10:44:22 2019
New Revision: 350643

URL: http://llvm.org/viewvc/llvm-project?rev=350643=rev
Log:
Limit COFF 'common' emission to <=32 alignment types.

As reported in PR33035, LLVM crashes if given a common object with an
alignment of greater than 32 bits. This is because the COFF file format
does not support these alignments, so emitting them is broken anyway.

This patch changes any global definitions greater than 32 bit alignment
to no longer be in 'common'.

https://bugs.llvm.org/show_bug.cgi?id=33035

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

Change-Id: I48609289753b7f3b58c5e2bc1712756750fbd45a

Added:
cfe/trunk/test/CodeGen/microsoft-no-common-align.c
Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=350643=350642=350643=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Tue Jan  8 10:44:22 2019
@@ -3761,6 +3761,11 @@ static bool isVarDeclStrongDefinition(co
   }
 }
   }
+  // COFF doesn't support alignments greater than 32, so these cannot be
+  // in common.
+  if (Context.getTargetInfo().getTriple().isKnownWindowsMSVCEnvironment() &&
+  Context.getTypeAlignIfKnown(D->getType()) > 32)
+return true;
 
   return false;
 }

Added: cfe/trunk/test/CodeGen/microsoft-no-common-align.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/microsoft-no-common-align.c?rev=350643=auto
==
--- cfe/trunk/test/CodeGen/microsoft-no-common-align.c (added)
+++ cfe/trunk/test/CodeGen/microsoft-no-common-align.c Tue Jan  8 10:44:22 2019
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -emit-llvm -o - %s | FileCheck 
%s
+typedef float TooLargeAlignment __attribute__((__vector_size__(64)));
+typedef float NormalAlignment __attribute__((__vector_size__(4)));
+
+TooLargeAlignment TooBig;
+// CHECK: @TooBig = dso_local global <16 x float>  zeroinitializer, align 64
+NormalAlignment JustRight;
+// CHECK: @JustRight = common dso_local global <1 x float>  zeroinitializer, 
align 4


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


r350644 - [NFC] Don't over-eagerly check block alignment

2019-01-08 Thread JF Bastien via cfe-commits
Author: jfb
Date: Tue Jan  8 10:51:38 2019
New Revision: 350644

URL: http://llvm.org/viewvc/llvm-project?rev=350644=rev
Log:
[NFC] Don't over-eagerly check block alignment

Alignment of __block isn't relevant to this test, remove its checking.

Modified:
cfe/trunk/test/CodeGenCXX/trivial-auto-var-init.cpp

Modified: cfe/trunk/test/CodeGenCXX/trivial-auto-var-init.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/trivial-auto-var-init.cpp?rev=350644=350643=350644=diff
==
--- cfe/trunk/test/CodeGenCXX/trivial-auto-var-init.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/trivial-auto-var-init.cpp Tue Jan  8 10:51:38 2019
@@ -22,9 +22,9 @@ void test_selfinit() {
 
 // UNINIT-LABEL:  test_block(
 // ZERO-LABEL:test_block(
-// ZERO: store i32 0, i32* %block, align 4
+// ZERO: store i32 0, i32* %block
 // PATTERN-LABEL: test_block(
-// PATTERN: store i32 -1431655766, i32* %block, align 4
+// PATTERN: store i32 -1431655766, i32* %block
 void test_block() {
   __block int block;
   used(block);


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


[PATCH] D56391: Limit COFF 'common' emission to <=32 alignment types.

2019-01-08 Thread Erich Keane via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC350643: Limit COFF common emission to =32 
alignment types. (authored by erichkeane, committed by ).

Repository:
  rC Clang

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

https://reviews.llvm.org/D56391

Files:
  lib/CodeGen/CodeGenModule.cpp
  test/CodeGen/microsoft-no-common-align.c


Index: test/CodeGen/microsoft-no-common-align.c
===
--- test/CodeGen/microsoft-no-common-align.c
+++ test/CodeGen/microsoft-no-common-align.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -emit-llvm -o - %s | FileCheck 
%s
+typedef float TooLargeAlignment __attribute__((__vector_size__(64)));
+typedef float NormalAlignment __attribute__((__vector_size__(4)));
+
+TooLargeAlignment TooBig;
+// CHECK: @TooBig = dso_local global <16 x float>  zeroinitializer, align 64
+NormalAlignment JustRight;
+// CHECK: @JustRight = common dso_local global <1 x float>  zeroinitializer, 
align 4
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -3761,6 +3761,11 @@
   }
 }
   }
+  // COFF doesn't support alignments greater than 32, so these cannot be
+  // in common.
+  if (Context.getTargetInfo().getTriple().isKnownWindowsMSVCEnvironment() &&
+  Context.getTypeAlignIfKnown(D->getType()) > 32)
+return true;
 
   return false;
 }


Index: test/CodeGen/microsoft-no-common-align.c
===
--- test/CodeGen/microsoft-no-common-align.c
+++ test/CodeGen/microsoft-no-common-align.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -emit-llvm -o - %s | FileCheck %s
+typedef float TooLargeAlignment __attribute__((__vector_size__(64)));
+typedef float NormalAlignment __attribute__((__vector_size__(4)));
+
+TooLargeAlignment TooBig;
+// CHECK: @TooBig = dso_local global <16 x float>  zeroinitializer, align 64
+NormalAlignment JustRight;
+// CHECK: @JustRight = common dso_local global <1 x float>  zeroinitializer, align 4
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -3761,6 +3761,11 @@
   }
 }
   }
+  // COFF doesn't support alignments greater than 32, so these cannot be
+  // in common.
+  if (Context.getTargetInfo().getTriple().isKnownWindowsMSVCEnvironment() &&
+  Context.getTypeAlignIfKnown(D->getType()) > 32)
+return true;
 
   return false;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56424: [clang-tidy] Add check for underscores in googletest names.

2019-01-08 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.cpp:27
+static bool isGoogletestTestMacro(StringRef MacroName) {
+  static const llvm::StringSet<> MacroNames = {"TEST", "TEST_F", "TEST_P",
+   "TYPED_TEST", "TYPED_TEST_P"};

Is there value in making the list of macros and option?, I've worked with other 
unit testing packages (some inhouse) that use the same format as google test, 
but don't use TEST() itself

e.g.  (to name a few)

```
TEST_CASE(testclass, testname)
BOOST_TEST(statement, floating_point_comparison_manipulation);
BOOST_DATA_TEST_CASE(test_case_name, dataset)
BOOST_FIXTURE_TEST_CASE( test_case2, F )
BOOST_AUTO_TEST_CASE( test_case3 )

```

too many for you to capture in the checker...but a nice addition for those who 
use alternative frameworks and would like to benefit from similar  "no 
underscore" naming conventions



Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D56424



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


Re: r346652 - Make clang-based tools find libc++ on MacOS

2019-01-08 Thread Nico Weber via cfe-commits
That looks like it should help. Thanks for the quick fix!

On Tue, Jan 8, 2019 at 1:11 PM Ilya Biryukov  wrote:

> Hi Nico,
>
> This is clearly a bug, it's supposed to search in a sibling directory.
> Are you running clang as './clang' in the scripts?  The code seems to
> break in that case, https://reviews.llvm.org/D56446 should fix this.
>
> On Tue, Jan 8, 2019 at 5:12 PM Nico Weber  wrote:
>
>> It looks like clang now looks for libc++ headers in -internal-isystem
>> Release+Asserts/bin/include/c++/v1 , compared to -internal-isystem
>> Release+Asserts/include/c++/v1. `make install` puts the libc++ headers in
>> Release+Asserts/include, the old location. Was this an intentional change?
>>
>> As-is, this seems to break chromium's clang ability to find libc++
>> headers (https://crbug.com/919761) because we bundle libc++ headers in
>> an "include" directory that's a sibling to the "bin" directory (and have
>> been doing so for 4.5 years, since
>> https://codereview.chromium.org/281753002).
>>
>> On Mon, Nov 12, 2018 at 8:58 AM Ilya Biryukov via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: ibiryukov
>>> Date: Mon Nov 12 05:55:55 2018
>>> New Revision: 346652
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=346652=rev
>>> Log:
>>> Make clang-based tools find libc++ on MacOS
>>>
>>> Summary:
>>> When they read compiler args from compile_commands.json.
>>> This change allows to run clang-based tools, like clang-tidy or clangd,
>>> built from head using the compile_commands.json file produced for XCode
>>> toolchains.
>>>
>>> On MacOS clang can find the C++ standard library relative to the
>>> compiler installation dir.
>>>
>>> The logic to do this was based on resource dir as an approximation of
>>> where the compiler is installed. This broke the tools that read
>>> 'compile_commands.json' and don't ship with the compiler, as they
>>> typically change resource dir.
>>>
>>> To workaround this, we now use compiler install dir detected by the
>>> driver
>>> to better mimic the behavior of the original compiler when replaying the
>>> compilations using other tools.
>>>
>>> Reviewers: sammccall, arphaman, EricWF
>>>
>>> Reviewed By: sammccall
>>>
>>> Subscribers: ioeric, christof, kadircet, cfe-commits
>>>
>>> Differential Revision: https://reviews.llvm.org/D54310
>>>
>>> Added:
>>> cfe/trunk/test/Tooling/Inputs/mock-libcxx/
>>> cfe/trunk/test/Tooling/Inputs/mock-libcxx/include/
>>> cfe/trunk/test/Tooling/Inputs/mock-libcxx/include/c++/
>>> cfe/trunk/test/Tooling/Inputs/mock-libcxx/include/c++/v1/
>>> cfe/trunk/test/Tooling/Inputs/mock-libcxx/include/c++/v1/mock_vector
>>> cfe/trunk/test/Tooling/clang-check-mac-libcxx-abspath.cpp
>>> cfe/trunk/test/Tooling/clang-check-mac-libcxx-relpath.cpp
>>> Modified:
>>> cfe/trunk/include/clang/Lex/HeaderSearchOptions.h
>>> cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp
>>> cfe/trunk/lib/Frontend/InitHeaderSearch.cpp
>>> cfe/trunk/lib/Tooling/Tooling.cpp
>>>
>>> Modified: cfe/trunk/include/clang/Lex/HeaderSearchOptions.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderSearchOptions.h?rev=346652=346651=346652=diff
>>>
>>> ==
>>> --- cfe/trunk/include/clang/Lex/HeaderSearchOptions.h (original)
>>> +++ cfe/trunk/include/clang/Lex/HeaderSearchOptions.h Mon Nov 12
>>> 05:55:55 2018
>>> @@ -108,6 +108,13 @@ public:
>>>/// etc.).
>>>std::string ResourceDir;
>>>
>>> +  /// Compiler install dir as detected by the Driver.
>>> +  /// This is typically the directory that contains the clang
>>> executable, i.e.
>>> +  /// the 'bin/' subdir of a clang distribution.
>>> +  /// Only used to add include dirs for libc++ on Darwin. Please avoid
>>> relying
>>> +  /// on this field for other purposes.
>>> +  std::string InstallDir;
>>> +
>>>/// The directory used for the module cache.
>>>std::string ModuleCachePath;
>>>
>>>
>>> Modified: cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp?rev=346652=346651=346652=diff
>>>
>>> ==
>>> --- cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp (original)
>>> +++ cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp Mon Nov
>>> 12 05:55:55 2018
>>> @@ -11,17 +11,18 @@
>>>  //
>>>
>>>  
>>> //===--===//
>>>
>>> -#include "clang/Frontend/Utils.h"
>>>  #include "clang/Basic/DiagnosticOptions.h"
>>> +#include "clang/Driver/Action.h"
>>>  #include "clang/Driver/Compilation.h"
>>>  #include "clang/Driver/Driver.h"
>>> -#include "clang/Driver/Action.h"
>>>  #include "clang/Driver/Options.h"
>>>  #include "clang/Driver/Tool.h"
>>>  #include "clang/Frontend/CompilerInstance.h"
>>>  #include 

[PATCH] D56446: [Driver] Fix libcxx detection on Darwin with clang run as ./clang

2019-01-08 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman accepted this revision.
arphaman added a comment.
This revision is now accepted and ready to land.

That makes sense, LGTM. Thanks!


Repository:
  rC Clang

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

https://reviews.llvm.org/D56446



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


[PATCH] D56424: [clang-tidy] Add check for underscores in googletest names.

2019-01-08 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.cpp:46
+auto IdentifierInfo = MacroNameToken.getIdentifierInfo();
+if (!IdentifierInfo) {
+  return;

Please elide braces.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D56424



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


[PATCH] D55337: NFC: Move dumpDeclRef to NodeDumper

2019-01-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

Once D56407  lands, the rebased changes here 
LGTM


Repository:
  rC Clang

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

https://reviews.llvm.org/D55337



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


Re: r350572 - Add a __has_feature check for namespaces on #pragma clang attribute.

2019-01-08 Thread Erik Pilkington via cfe-commits


On 1/7/19 4:43 PM, Richard Smith wrote:
On Mon, 7 Jan 2019 at 16:12, Erik Pilkington via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:


On 1/7/19 3:51 PM, Richard Smith wrote:


On Mon, 7 Jan 2019 at 13:57, Erik Pilkington via cfe-commits
mailto:cfe-commits@lists.llvm.org>>
wrote:

Author: epilk
Date: Mon Jan  7 13:54:00 2019
New Revision: 350572

URL: http://llvm.org/viewvc/llvm-project?rev=350572=rev
Log:
Add a __has_feature check for namespaces on #pragma clang
attribute.


Should this be __has_extension rather than __has_feature, since
it's not a standard feature?



I suppose, but it doesn't really seem like that's the rule that
we're following here. If you look at every other FEATURE(...)
above this, they all have to do with clang extensions like
attributes and sanitizers, which obviously aren't standard
features. Every EXTENSION(...) has to do with language features
that are shared between languages (cxx_fixed_enum in C, for
instance). So it seems like the most internally consistent place
to put this is in FEATURE(...). WDYT?

What you're seeing is a historical legacy of the time before the 
current approach. The design and documented intent of __has_feature is 
that it checks for standardized features. See the documentation here, 
and particularly the note about backwards compatibility:


https://clang.llvm.org/docs/LanguageExtensions.html#has-feature-and-has-extension

... and the design discussion when __has_extension was introduced:

http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20110425/041452.html

... and the comment on HasFeature in Lex/PPMacroExpansion.cpp:

/// HasFeature - Return true if we recognize and implement the feature
/// specified by the identifier as a standard language feature.

We seem to have detached that comment from the actual list of features 
when the features were moved to a .def file. Oops :(


If we want to revisit the design based on experience using 
__has_feature / __has_extension, I'm all for that (the distinction 
between the two seems confusing and not especially useful to me; the 
behavior of the current language mode can be tested using eg 
__STDC_VERSION__ and __cplusplus, so the only thing that's really 
interesting for us to expose is what features the current compliation 
supports), but we should follow the current design until we do.



Yeah, it doesn't really seem like a useful distinction. Anyways, I added 
a comment to this file and fixed this in r350642. Thanks!




Support for this was added in r349845.

Modified:
    cfe/trunk/docs/LanguageExtensions.rst
cfe/trunk/include/clang/Basic/Features.def
cfe/trunk/test/Sema/pragma-attribute-namespace.c

Modified: cfe/trunk/docs/LanguageExtensions.rst
URL:

http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LanguageExtensions.rst?rev=350572=350571=350572=diff

==
--- cfe/trunk/docs/LanguageExtensions.rst (original)
+++ cfe/trunk/docs/LanguageExtensions.rst Mon Jan  7 13:54:00
2019
@@ -2725,7 +2725,9 @@ same namespace. For instance:
 Without the namespaces on the macros, ``other_function``
will be annotated with
 ``[[noreturn]]`` instead of
``__attribute__((unavailable))``. This may seem like
 a contrived example, but its very possible for this kind of
situation to appear
-in real code if the pragmas are spread out across a large file.
+in real code if the pragmas are spread out across a large
file. You can test if
+your version of clang supports namespaces on ``#pragma clang
attribute`` with
+``__has_feature(pragma_clang_attribute_namespaces)``.

 Subject Match Rules
 ---

Modified: cfe/trunk/include/clang/Basic/Features.def
URL:

http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Features.def?rev=350572=350571=350572=diff

==
--- cfe/trunk/include/clang/Basic/Features.def (original)
+++ cfe/trunk/include/clang/Basic/Features.def Mon Jan  7
13:54:00 2019
@@ -69,6 +69,7 @@ FEATURE(attribute_overloadable, true)
 FEATURE(attribute_unavailable_with_message, true)
 FEATURE(attribute_unused_on_fields, true)
 FEATURE(attribute_diagnose_if_objc, true)
+FEATURE(pragma_clang_attribute_namespaces, true)
 FEATURE(blocks, LangOpts.Blocks)
 FEATURE(c_thread_safety_attributes, true)
 FEATURE(cxx_exceptions, LangOpts.CXXExceptions)

Modified: cfe/trunk/test/Sema/pragma-attribute-namespace.c
URL:


[PATCH] D55433: [clang-tidy] Adding a new modernize use nodiscard checker

2019-01-08 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.



In D55433#1349709 , @JonasToth wrote:

> No problem, thats why we test on real projects first, because there is always 
> something hidden in C++ :)
>
> Is there a test for the lambdas?


test/clang-tidy/modernize-use-nodiscard.cpp line 158  (which is how it 
manifested inside LLVM) as a lambda assigned to an auto


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

https://reviews.llvm.org/D55433



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


r350642 - __has_feature(pragma_clang_attribute_namespaces) should be __has_extension

2019-01-08 Thread Erik Pilkington via cfe-commits
Author: epilk
Date: Tue Jan  8 10:24:39 2019
New Revision: 350642

URL: http://llvm.org/viewvc/llvm-project?rev=350642=rev
Log:
__has_feature(pragma_clang_attribute_namespaces) should be __has_extension

Thanks to Richard Smith for pointing this out.

Modified:
cfe/trunk/docs/LanguageExtensions.rst
cfe/trunk/include/clang/Basic/Features.def
cfe/trunk/test/Sema/pragma-attribute-namespace.c

Modified: cfe/trunk/docs/LanguageExtensions.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LanguageExtensions.rst?rev=350642=350641=350642=diff
==
--- cfe/trunk/docs/LanguageExtensions.rst (original)
+++ cfe/trunk/docs/LanguageExtensions.rst Tue Jan  8 10:24:39 2019
@@ -2727,7 +2727,7 @@ Without the namespaces on the macros, ``
 a contrived example, but its very possible for this kind of situation to appear
 in real code if the pragmas are spread out across a large file. You can test if
 your version of clang supports namespaces on ``#pragma clang attribute`` with
-``__has_feature(pragma_clang_attribute_namespaces)``.
+``__has_extension(pragma_clang_attribute_namespaces)``.
 
 Subject Match Rules
 ---

Modified: cfe/trunk/include/clang/Basic/Features.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Features.def?rev=350642=350641=350642=diff
==
--- cfe/trunk/include/clang/Basic/Features.def (original)
+++ cfe/trunk/include/clang/Basic/Features.def Tue Jan  8 10:24:39 2019
@@ -17,6 +17,12 @@
 //
 // The Predicate field dictates the conditions under which the feature or
 // extension will be made available.
+//
+// FEATURE(...) should be used to advertise support for standard language
+// features, whereas EXTENSION(...) should be used for clang extensions. Note
+// that many of the identifiers in this file don't follow this rule for 
backward
+// compatibility reasons.
+//
 
//===--===//
 
 #if !defined(FEATURE) && !defined(EXTENSION)
@@ -69,7 +75,6 @@ FEATURE(attribute_overloadable, true)
 FEATURE(attribute_unavailable_with_message, true)
 FEATURE(attribute_unused_on_fields, true)
 FEATURE(attribute_diagnose_if_objc, true)
-FEATURE(pragma_clang_attribute_namespaces, true)
 FEATURE(blocks, LangOpts.Blocks)
 FEATURE(c_thread_safety_attributes, true)
 FEATURE(cxx_exceptions, LangOpts.CXXExceptions)
@@ -241,6 +246,7 @@ EXTENSION(cxx_init_captures, LangOpts.CP
 EXTENSION(cxx_variable_templates, LangOpts.CPlusPlus)
 // Miscellaneous language extensions
 EXTENSION(overloadable_unmarked, true)
+EXTENSION(pragma_clang_attribute_namespaces, true)
 
 #undef EXTENSION
 #undef FEATURE

Modified: cfe/trunk/test/Sema/pragma-attribute-namespace.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/pragma-attribute-namespace.c?rev=350642=350641=350642=diff
==
--- cfe/trunk/test/Sema/pragma-attribute-namespace.c (original)
+++ cfe/trunk/test/Sema/pragma-attribute-namespace.c Tue Jan  8 10:24:39 2019
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
 
-#if !__has_feature(pragma_clang_attribute_namespaces)
+#if !__has_extension(pragma_clang_attribute_namespaces)
 #error
 #endif
 


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


Re: r346652 - Make clang-based tools find libc++ on MacOS

2019-01-08 Thread Ilya Biryukov via cfe-commits
Hi Nico,

This is clearly a bug, it's supposed to search in a sibling directory.
Are you running clang as './clang' in the scripts?  The code seems to break
in that case, https://reviews.llvm.org/D56446 should fix this.

On Tue, Jan 8, 2019 at 5:12 PM Nico Weber  wrote:

> It looks like clang now looks for libc++ headers in -internal-isystem
> Release+Asserts/bin/include/c++/v1 , compared to -internal-isystem
> Release+Asserts/include/c++/v1. `make install` puts the libc++ headers in
> Release+Asserts/include, the old location. Was this an intentional change?
>
> As-is, this seems to break chromium's clang ability to find libc++ headers
> (https://crbug.com/919761) because we bundle libc++ headers in an
> "include" directory that's a sibling to the "bin" directory (and have been
> doing so for 4.5 years, since https://codereview.chromium.org/281753002).
>
> On Mon, Nov 12, 2018 at 8:58 AM Ilya Biryukov via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: ibiryukov
>> Date: Mon Nov 12 05:55:55 2018
>> New Revision: 346652
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=346652=rev
>> Log:
>> Make clang-based tools find libc++ on MacOS
>>
>> Summary:
>> When they read compiler args from compile_commands.json.
>> This change allows to run clang-based tools, like clang-tidy or clangd,
>> built from head using the compile_commands.json file produced for XCode
>> toolchains.
>>
>> On MacOS clang can find the C++ standard library relative to the
>> compiler installation dir.
>>
>> The logic to do this was based on resource dir as an approximation of
>> where the compiler is installed. This broke the tools that read
>> 'compile_commands.json' and don't ship with the compiler, as they
>> typically change resource dir.
>>
>> To workaround this, we now use compiler install dir detected by the driver
>> to better mimic the behavior of the original compiler when replaying the
>> compilations using other tools.
>>
>> Reviewers: sammccall, arphaman, EricWF
>>
>> Reviewed By: sammccall
>>
>> Subscribers: ioeric, christof, kadircet, cfe-commits
>>
>> Differential Revision: https://reviews.llvm.org/D54310
>>
>> Added:
>> cfe/trunk/test/Tooling/Inputs/mock-libcxx/
>> cfe/trunk/test/Tooling/Inputs/mock-libcxx/include/
>> cfe/trunk/test/Tooling/Inputs/mock-libcxx/include/c++/
>> cfe/trunk/test/Tooling/Inputs/mock-libcxx/include/c++/v1/
>> cfe/trunk/test/Tooling/Inputs/mock-libcxx/include/c++/v1/mock_vector
>> cfe/trunk/test/Tooling/clang-check-mac-libcxx-abspath.cpp
>> cfe/trunk/test/Tooling/clang-check-mac-libcxx-relpath.cpp
>> Modified:
>> cfe/trunk/include/clang/Lex/HeaderSearchOptions.h
>> cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp
>> cfe/trunk/lib/Frontend/InitHeaderSearch.cpp
>> cfe/trunk/lib/Tooling/Tooling.cpp
>>
>> Modified: cfe/trunk/include/clang/Lex/HeaderSearchOptions.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderSearchOptions.h?rev=346652=346651=346652=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Lex/HeaderSearchOptions.h (original)
>> +++ cfe/trunk/include/clang/Lex/HeaderSearchOptions.h Mon Nov 12 05:55:55
>> 2018
>> @@ -108,6 +108,13 @@ public:
>>/// etc.).
>>std::string ResourceDir;
>>
>> +  /// Compiler install dir as detected by the Driver.
>> +  /// This is typically the directory that contains the clang
>> executable, i.e.
>> +  /// the 'bin/' subdir of a clang distribution.
>> +  /// Only used to add include dirs for libc++ on Darwin. Please avoid
>> relying
>> +  /// on this field for other purposes.
>> +  std::string InstallDir;
>> +
>>/// The directory used for the module cache.
>>std::string ModuleCachePath;
>>
>>
>> Modified: cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp?rev=346652=346651=346652=diff
>>
>> ==
>> --- cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp (original)
>> +++ cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp Mon Nov 12
>> 05:55:55 2018
>> @@ -11,17 +11,18 @@
>>  //
>>
>>  
>> //===--===//
>>
>> -#include "clang/Frontend/Utils.h"
>>  #include "clang/Basic/DiagnosticOptions.h"
>> +#include "clang/Driver/Action.h"
>>  #include "clang/Driver/Compilation.h"
>>  #include "clang/Driver/Driver.h"
>> -#include "clang/Driver/Action.h"
>>  #include "clang/Driver/Options.h"
>>  #include "clang/Driver/Tool.h"
>>  #include "clang/Frontend/CompilerInstance.h"
>>  #include "clang/Frontend/FrontendDiagnostic.h"
>> +#include "clang/Frontend/Utils.h"
>>  #include "llvm/Option/ArgList.h"
>>  #include "llvm/Support/Host.h"
>> +#include "llvm/Support/Path.h"
>>  using namespace clang;
>>  using namespace llvm::opt;
>>

[PATCH] D56446: [Driver] Fix libcxx detection on Darwin with clang run as ./clang

2019-01-08 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added reviewers: arphaman, thakis.
Herald added a reviewer: EricWF.
Herald added a subscriber: christof.

By using '..' instead of fs::parent_path.

The intention of the code was to go from 'path/to/clang/bin' to
'path/to/clang/include'. In most cases parent_path works, however it
would fail when clang is run as './clang'.

This was noticed in Chromium's bug tracker, see
https://bugs.chromium.org/p/chromium/issues/detail?id=919761


Repository:
  rC Clang

https://reviews.llvm.org/D56446

Files:
  lib/Driver/ToolChains/Darwin.cpp
  test/Driver/darwin-stdlib.cpp
  test/Tooling/Inputs/mock-libcxx/bin/clang


Index: test/Tooling/Inputs/mock-libcxx/bin/clang
===
--- /dev/null
+++ test/Tooling/Inputs/mock-libcxx/bin/clang
@@ -0,0 +1 @@
+This file is a placeholder to keep its parent directory in git.
Index: test/Driver/darwin-stdlib.cpp
===
--- test/Driver/darwin-stdlib.cpp
+++ test/Driver/darwin-stdlib.cpp
@@ -14,7 +14,7 @@
 // optional absolute include for libc++ from InitHeaderSearch.cpp also fires.
 
 // CHECK-LIBCXX: "-stdlib=libc++"
-// CHECK-LIBCXX: "-internal-isystem" 
"{{[^"]*}}{{/|}}Inputs{{/|}}darwin_toolchain_tree{{/|}}bin{{/|}}include{{/|}}c++{{/|}}v1"
+// CHECK-LIBCXX: "-internal-isystem" 
"{{[^"]*}}{{/|}}Inputs{{/|}}darwin_toolchain_tree{{/|}}bin{{/|}}..{{/|}}include{{/|}}c++{{/|}}v1"
 
 // CHECK-LIBSTDCXX-NOT: -stdlib=libc++
 // CHECK-LIBSTDCXX-NOT: -stdlib=libstdc++
Index: lib/Driver/ToolChains/Darwin.cpp
===
--- lib/Driver/ToolChains/Darwin.cpp
+++ lib/Driver/ToolChains/Darwin.cpp
@@ -1752,10 +1752,11 @@
   break;
 // On Darwin, libc++ may be installed alongside the compiler in
 // include/c++/v1.
-// Get from 'foo/bin' to 'foo'.
-SmallString<128> P = llvm::sys::path::parent_path(InstallDir);
-// Get to 'foo/include/c++/v1'.
-llvm::sys::path::append(P, "include", "c++", "v1");
+// Get from 'foo/bin' to 'foo/include/c++/v1'.
+SmallString<128> P = InstallDir;
+// Note that InstallDir can be relative, so we have to '..' and not
+// parent_path.
+llvm::sys::path::append(P, "..", "include", "c++", "v1");
 addSystemInclude(DriverArgs, CC1Args, P);
 break;
   }


Index: test/Tooling/Inputs/mock-libcxx/bin/clang
===
--- /dev/null
+++ test/Tooling/Inputs/mock-libcxx/bin/clang
@@ -0,0 +1 @@
+This file is a placeholder to keep its parent directory in git.
Index: test/Driver/darwin-stdlib.cpp
===
--- test/Driver/darwin-stdlib.cpp
+++ test/Driver/darwin-stdlib.cpp
@@ -14,7 +14,7 @@
 // optional absolute include for libc++ from InitHeaderSearch.cpp also fires.
 
 // CHECK-LIBCXX: "-stdlib=libc++"
-// CHECK-LIBCXX: "-internal-isystem" "{{[^"]*}}{{/|}}Inputs{{/|}}darwin_toolchain_tree{{/|}}bin{{/|}}include{{/|}}c++{{/|}}v1"
+// CHECK-LIBCXX: "-internal-isystem" "{{[^"]*}}{{/|}}Inputs{{/|}}darwin_toolchain_tree{{/|}}bin{{/|}}..{{/|}}include{{/|}}c++{{/|}}v1"
 
 // CHECK-LIBSTDCXX-NOT: -stdlib=libc++
 // CHECK-LIBSTDCXX-NOT: -stdlib=libstdc++
Index: lib/Driver/ToolChains/Darwin.cpp
===
--- lib/Driver/ToolChains/Darwin.cpp
+++ lib/Driver/ToolChains/Darwin.cpp
@@ -1752,10 +1752,11 @@
   break;
 // On Darwin, libc++ may be installed alongside the compiler in
 // include/c++/v1.
-// Get from 'foo/bin' to 'foo'.
-SmallString<128> P = llvm::sys::path::parent_path(InstallDir);
-// Get to 'foo/include/c++/v1'.
-llvm::sys::path::append(P, "include", "c++", "v1");
+// Get from 'foo/bin' to 'foo/include/c++/v1'.
+SmallString<128> P = InstallDir;
+// Note that InstallDir can be relative, so we have to '..' and not
+// parent_path.
+llvm::sys::path::append(P, "..", "include", "c++", "v1");
 addSystemInclude(DriverArgs, CC1Args, P);
 break;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56405: Split -Wdelete-non-virtual-dtor into two groups

2019-01-08 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington updated this revision to Diff 180690.
erik.pilkington added a comment.
This revision is now accepted and ready to land.

Split -Wdelete-non-virtual-dtor into -Wdelete-non-abstract-non-virtual-dtor and 
-Wdelete-abstract-non-virtual-dtor.


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

https://reviews.llvm.org/D56405

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/test/SemaCXX/delete-non-virtual-dtor.cpp


Index: clang/test/SemaCXX/delete-non-virtual-dtor.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/delete-non-virtual-dtor.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 %s -verify -DDIAG1
+// RUN: %clang_cc1 %s -verify -DDIAG1 -DDIAG2 -Wdelete-non-virtual-dtor
+// RUN: %clang_cc1 %s -verify -DDIAG1 -Wmost 
-Wno-delete-non-abstract-non-virtual-dtor
+// RUN: %clang_cc1 %s -verify -DDIAG2 -Wmost 
-Wno-delete-abstract-non-virtual-dtor
+// RUN: %clang_cc1 %s -verify -Wmost 
-Wno-delete-non-virtual-dtor
+
+#ifndef DIAG1
+#ifndef DIAG2
+// expected-no-diagnostics
+#endif
+#endif
+
+struct S1 {
+  ~S1() {}
+  virtual void abs() = 0;
+};
+
+void f1(S1 *s1) { delete s1; }
+#ifdef DIAG1
+// expected-warning@-2 {{delete called on 'S1' that is abstract but has 
non-virtual destructor}}
+#endif
+
+struct S2 {
+  ~S2() {}
+  virtual void real() {}
+};
+void f2(S2 *s2) { delete s2; }
+#ifdef DIAG2
+// expected-warning@-2 {{delete called on non-final 'S2' that has virtual 
functions but non-virtual destructor}}
+#endif
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6455,12 +6455,12 @@
 def warn_delete_non_virtual_dtor : Warning<
   "%select{delete|destructor}0 called on non-final %1 that has "
   "virtual functions but non-virtual destructor">,
-  InGroup, DefaultIgnore, ShowInSystemHeader;
+  InGroup, DefaultIgnore, ShowInSystemHeader;
 def note_delete_non_virtual : Note<
   "qualify call to silence this warning">;
 def warn_delete_abstract_non_virtual_dtor : Warning<
   "%select{delete|destructor}0 called on %1 that is abstract but has "
-  "non-virtual destructor">, InGroup, ShowInSystemHeader;
+  "non-virtual destructor">, InGroup, 
ShowInSystemHeader;
 def warn_overloaded_virtual : Warning<
   "%q0 hides overloaded virtual %select{function|functions}1">,
   InGroup, DefaultIgnore;
Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -104,7 +104,11 @@
 def MissingNoEscape : DiagGroup<"missing-noescape">;
 
 def DeleteIncomplete : DiagGroup<"delete-incomplete">;
-def DeleteNonVirtualDtor : DiagGroup<"delete-non-virtual-dtor">;
+def DeleteNonAbstractNonVirtualDtor : 
DiagGroup<"delete-non-abstract-non-virtual-dtor">;
+def DeleteAbstractNonVirtualDtor : 
DiagGroup<"delete-abstract-non-virtual-dtor">;
+def DeleteNonVirtualDtor : DiagGroup<"delete-non-virtual-dtor",
+ [DeleteNonAbstractNonVirtualDtor,
+  DeleteAbstractNonVirtualDtor]>;
 def AbstractFinalClass : DiagGroup<"abstract-final-class">;
 
 def CXX11CompatDeprecatedWritableStr :


Index: clang/test/SemaCXX/delete-non-virtual-dtor.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/delete-non-virtual-dtor.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 %s -verify -DDIAG1
+// RUN: %clang_cc1 %s -verify -DDIAG1 -DDIAG2 -Wdelete-non-virtual-dtor
+// RUN: %clang_cc1 %s -verify -DDIAG1 -Wmost -Wno-delete-non-abstract-non-virtual-dtor
+// RUN: %clang_cc1 %s -verify -DDIAG2 -Wmost -Wno-delete-abstract-non-virtual-dtor
+// RUN: %clang_cc1 %s -verify -Wmost -Wno-delete-non-virtual-dtor
+
+#ifndef DIAG1
+#ifndef DIAG2
+// expected-no-diagnostics
+#endif
+#endif
+
+struct S1 {
+  ~S1() {}
+  virtual void abs() = 0;
+};
+
+void f1(S1 *s1) { delete s1; }
+#ifdef DIAG1
+// expected-warning@-2 {{delete called on 'S1' that is abstract but has non-virtual destructor}}
+#endif
+
+struct S2 {
+  ~S2() {}
+  virtual void real() {}
+};
+void f2(S2 *s2) { delete s2; }
+#ifdef DIAG2
+// expected-warning@-2 {{delete called on non-final 'S2' that has virtual functions but non-virtual destructor}}
+#endif
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6455,12 +6455,12 @@
 def warn_delete_non_virtual_dtor : Warning<
   "%select{delete|destructor}0 called on non-final %1 that has "
   "virtual functions but non-virtual 

r350641 - Rename DIFlagFixedEnum to DIFlagEnumClass. NFC

2019-01-08 Thread Paul Robinson via cfe-commits
Author: probinson
Date: Tue Jan  8 09:52:29 2019
New Revision: 350641

URL: http://llvm.org/viewvc/llvm-project?rev=350641=rev
Log:
Rename DIFlagFixedEnum to DIFlagEnumClass. NFC

Modified:
cfe/trunk/test/CodeGen/debug-info-enum.cpp
cfe/trunk/test/CodeGenCXX/debug-info-enum-class.cpp

Modified: cfe/trunk/test/CodeGen/debug-info-enum.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-info-enum.cpp?rev=350641=350640=350641=diff
==
--- cfe/trunk/test/CodeGen/debug-info-enum.cpp (original)
+++ cfe/trunk/test/CodeGen/debug-info-enum.cpp Tue Jan  8 09:52:29 2019
@@ -12,7 +12,7 @@ enum class E0 : signed char {
 } x0;
 // CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "E0"
 // CHECK-SAME: baseType: ![[SCHAR:[0-9]+]]
-// CHECK-SAME: DIFlagFixedEnum
+// CHECK-SAME: DIFlagEnumClass
 // CHECK-SAME: elements: ![[ELTS0:[0-9]+]]
 // CHECK: ![[SCHAR]] = !DIBasicType(name: "signed char", size: 8, encoding: 
DW_ATE_signed_char)
 // CHECK: ![[ELTS0]] = !{![[A0:[0-9]+]], ![[B0:[0-9]+]]}
@@ -22,7 +22,7 @@ enum class E0 : signed char {
 enum class E1 : unsigned char { A1 = 255 } x1;
 // CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "E1"
 // CHECK-SAME: baseType: ![[UCHAR:[0-9]+]]
-// CHECK-SAME: DIFlagFixedEnum
+// CHECK-SAME: DIFlagEnumClass
 // CHECK-SAME: elements: ![[ELTS1:[0-9]+]]
 // CHECK: ![[UCHAR]] = !DIBasicType(name: "unsigned char", size: 8, encoding: 
DW_ATE_unsigned_char)
 // CHECK: ![[ELTS1]] = !{![[A1:[0-9]+]]}
@@ -34,7 +34,7 @@ enum class E2 : signed short {
 } x2;
 // CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "E2"
 // CHECK-SAME: baseType: ![[SHORT:[0-9]+]]
-// CHECK-SAME: DIFlagFixedEnum
+// CHECK-SAME: DIFlagEnumClass
 // CHECK-SAME: elements: ![[ELTS2:[0-9]+]]
 // CHECK: ![[SHORT]] = !DIBasicType(name: "short", size: 16, encoding: 
DW_ATE_signed)
 // CHECK: ![[ELTS2]] = !{![[A2:[0-9]+]], ![[B2:[0-9]+]]}
@@ -44,7 +44,7 @@ enum class E2 : signed short {
 enum class E3 : unsigned short { A3 = 65535 } x3;
 // CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "E3"
 // CHECK-SAME: baseType: ![[USHORT:[0-9]+]]
-// CHECK-SAME: DIFlagFixedEnum
+// CHECK-SAME: DIFlagEnumClass
 // CHECK-SAME: elements: ![[ELTS3:[0-9]+]]
 // CHECK: ![[USHORT]] = !DIBasicType(name: "unsigned short", size: 16, 
encoding: DW_ATE_unsigned)
 // CHECK: ![[ELTS3]] = !{![[A3:[0-9]+]]}
@@ -53,7 +53,7 @@ enum class E3 : unsigned short { A3 = 65
 enum class E4 : signed int { A4 = -2147483648, B4 = 2147483647 } x4;
 // CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "E4"
 // CHECK-SAME: baseType: ![[INT:[0-9]+]]
-// CHECK-SAME: DIFlagFixedEnum
+// CHECK-SAME: DIFlagEnumClass
 // CHECK-SAME: elements: ![[ELTS4:[0-9]+]]
 // CHECK: ![[INT]] = !DIBasicType(name: "int", size: 32, encoding: 
DW_ATE_signed)
 // CHECK: ![[ELTS4]] = !{![[A4:[0-9]+]], ![[B4:[0-9]+]]}
@@ -63,7 +63,7 @@ enum class E4 : signed int { A4 = -21474
 enum class E5 : unsigned int { A5 = 4294967295 } x5;
 // CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "E5"
 // CHECK-SAME: baseType: ![[UINT:[0-9]+]]
-// CHECK-SAME: DIFlagFixedEnum
+// CHECK-SAME: DIFlagEnumClass
 // CHECK-SAME: elements: ![[ELTS5:[0-9]+]]
 // CHECK: ![[UINT]] = !DIBasicType(name: "unsigned int", size: 32, encoding: 
DW_ATE_unsigned)
 // CHECK: ![[ELTS5]] = !{![[A5:[0-9]+]]}
@@ -75,7 +75,7 @@ enum class E6 : signed long long {
 } x6;
 // CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "E6"
 // CHECK-SAME: baseType: ![[LONG:[0-9]+]]
-// CHECK-SAME: DIFlagFixedEnum
+// CHECK-SAME: DIFlagEnumClass
 // CHECK-SAME: elements: ![[ELTS6:[0-9]+]]
 // CHECK: ![[LONG]] = !DIBasicType(name: "long long int", size: 64, encoding: 
DW_ATE_signed)
 // CHECK: ![[ELTS6]] = !{![[A6:[0-9]+]], ![[B6:[0-9]+]]}
@@ -85,7 +85,7 @@ enum class E6 : signed long long {
 enum class E7 : unsigned long long { A7 = 18446744073709551615ULL } x7;
 // CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "E7"
 // CHECK-SAME: baseType: ![[ULONG:[0-9]+]]
-// CHECK-SAME: DIFlagFixedEnum
+// CHECK-SAME: DIFlagEnumClass
 // CHECK-SAME: elements: ![[ELTS7:[0-9]+]]
 // CHECK: ![[ULONG]] = !DIBasicType(name: "long long unsigned int", size: 64, 
encoding: DW_ATE_unsigned)
 // CHECK: ![[ELTS7]] = !{![[A7:[0-9]+]]}
@@ -95,6 +95,6 @@ enum class E7 : unsigned long long { A7
 enum E8 { A8 = -128, B8 = 127 } x8;
 // CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "E8"
 // CHECK-SAME: baseType: ![[INT]]
-// CHECK-NOT: DIFlagFixedEnum
+// CHECK-NOT: DIFlagEnumClass
 // CHECK: !DIEnumerator(name: "A8", value: -128)
 

Modified: cfe/trunk/test/CodeGenCXX/debug-info-enum-class.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-enum-class.cpp?rev=350641=350640=350641=diff
==
--- cfe/trunk/test/CodeGenCXX/debug-info-enum-class.cpp (original)
+++ 

[PATCH] D47817: [compiler-rt] [sanitizer_common] Remove support for tirpc/rpc/xdr.h

2019-01-08 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

Ping again.


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

https://reviews.llvm.org/D47817



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


[PATCH] D56109: [sanitizer_common] Define __sanitizer_FILE on NetBSD

2019-01-08 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

Ping.


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

https://reviews.llvm.org/D56109



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


[PATCH] D56062: [compiler-rt] [test] Detect glibc-2.27+ and XFAIL appropriate tests

2019-01-08 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

Ping.


Repository:
  rCRT Compiler Runtime

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

https://reviews.llvm.org/D56062



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


[PATCH] D56445: [Sema] Teach Clang that aligned allocation is not supported with macosx10.13

2019-01-08 Thread Louis Dionne via Phabricator via cfe-commits
ldionne created this revision.
ldionne added a reviewer: ahatanak.
Herald added subscribers: cfe-commits, dexonsmith, jkorous, christof.

r306722 added diagnostics when aligned allocation is used with deployment
targets that do not support it, but the first macosx supporting aligned
allocation was incorrectly set to 10.13. In reality, the dylib shipped
with macosx10.13 does not support aligned allocation, but the dylib
shipped with macosx10.14 does.


Repository:
  rC Clang

https://reviews.llvm.org/D56445

Files:
  clang/include/clang/Basic/AlignedAllocation.h
  clang/test/Driver/unavailable_aligned_allocation.cpp
  clang/test/SemaCXX/unavailable_aligned_allocation.cpp
  libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp
  libcxx/test/libcxx/memory/aligned_allocation_macro.pass.cpp

Index: libcxx/test/libcxx/memory/aligned_allocation_macro.pass.cpp
===
--- libcxx/test/libcxx/memory/aligned_allocation_macro.pass.cpp
+++ libcxx/test/libcxx/memory/aligned_allocation_macro.pass.cpp
@@ -9,8 +9,9 @@
 
 // UNSUPPORTED: c++98, c++03, c++11, c++14
 
-// Aligned allocation functions are not provided prior to macosx10.13, but
+// Aligned allocation functions are not provided prior to macosx10.14, but
 // AppleClang <= 10 does not know about this restriction and always enables them.
+// XFAIL: !(apple-clang-9 || apple-clang-10) && availability=macosx10.13
 // XFAIL: !(apple-clang-9 || apple-clang-10) && availability=macosx10.12
 // XFAIL: !(apple-clang-9 || apple-clang-10) && availability=macosx10.11
 // XFAIL: !(apple-clang-9 || apple-clang-10) && availability=macosx10.10
Index: libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp
===
--- libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp
+++ libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp
@@ -14,9 +14,15 @@
 // definitions, which does not yet provide aligned allocation
 // XFAIL: LIBCXX-WINDOWS-FIXME
 
-// Clang 10 (and older) will trigger an availability error when the deployment
+// AppleClang 10 (and older) will trigger an availability error when the deployment
 // target does not support aligned allocation, even if we pass `-faligned-allocation`.
+// XFAIL: apple-clang-10 && availability=macosx10.13
 // XFAIL: apple-clang-10 && availability=macosx10.12
+// XFAIL: apple-clang-10 && availability=macosx10.11
+// XFAIL: apple-clang-10 && availability=macosx10.10
+// XFAIL: apple-clang-10 && availability=macosx10.9
+// XFAIL: apple-clang-10 && availability=macosx10.8
+// XFAIL: apple-clang-10 && availability=macosx10.7
 
 // The dylibs shipped before macosx10.14 do not contain the aligned allocation
 // functions, so trying to force using those with -faligned-allocation results
Index: clang/test/SemaCXX/unavailable_aligned_allocation.cpp
===
--- clang/test/SemaCXX/unavailable_aligned_allocation.cpp
+++ clang/test/SemaCXX/unavailable_aligned_allocation.cpp
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.12.0 -fexceptions -faligned-alloc-unavailable -std=c++1z -verify %s
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.12.0 -fexceptions -std=c++1z -verify -DNO_ERRORS %s
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.12.0 -fexceptions -faligned-allocation -faligned-alloc-unavailable -std=c++14 -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.0 -fexceptions -faligned-alloc-unavailable -std=c++1z -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.0 -fexceptions -std=c++1z -verify -DNO_ERRORS %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.0 -fexceptions -faligned-allocation -faligned-alloc-unavailable -std=c++14 -verify %s
 // RUN: %clang_cc1 -triple arm64-apple-ios10.0.0 -fexceptions -faligned-alloc-unavailable -std=c++1z -verify -DIOS %s
 // RUN: %clang_cc1 -triple arm64-apple-ios10.0.0 -fexceptions -std=c++1z -verify -DNO_ERRORS %s
 // RUN: %clang_cc1 -triple arm64-apple-tvos10.0.0 -fexceptions -faligned-alloc-unavailable -std=c++1z -verify -DTVOS %s
@@ -117,8 +117,8 @@
 // expected-error@-13 {{aligned allocation function of type 'void *(unsigned long, enum std::align_val_t)' is only available on watchOS 4 or newer}}}
 // expected-error@-14 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is only available on watchOS 4 or newer}}}
 #else
-// expected-error@-16 {{aligned allocation function of type 'void *(unsigned long, enum std::align_val_t)' is only available on macOS 10.13 or newer}}}
-// expected-error@-17 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is only available on macOS 10.13 or newer}}}
+// expected-error@-16 {{aligned allocation function of type 'void *(unsigned long, enum std::align_val_t)' is only available on macOS 10.14 

[PATCH] D55433: [clang-tidy] Adding a new modernize use nodiscard checker

2019-01-08 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay updated this revision to Diff 180687.
MyDeveloperDay marked 3 inline comments as done.
MyDeveloperDay added a comment.

Address review comments

- add more lambda tests
- add nested lambda test
- remove hasParent() call,  (seems isConversionOperator()) seems to detect the 
CXXMethodsDecls within a lambda that were causing [[nodiscard]] to be added 
before the []{... )


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

https://reviews.llvm.org/D55433

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseNodiscardCheck.cpp
  clang-tidy/modernize/UseNodiscardCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-use-nodiscard.rst
  test/clang-tidy/modernize-use-nodiscard-clang-unused.cpp
  test/clang-tidy/modernize-use-nodiscard-cxx11.cpp
  test/clang-tidy/modernize-use-nodiscard-gcc-unused.cpp
  test/clang-tidy/modernize-use-nodiscard-no-macro-inscope-cxx11.cpp
  test/clang-tidy/modernize-use-nodiscard-no-macro.cpp
  test/clang-tidy/modernize-use-nodiscard.cpp
  test/clang-tidy/modernize-use-nodiscard.h

Index: test/clang-tidy/modernize-use-nodiscard.h
===
--- /dev/null
+++ test/clang-tidy/modernize-use-nodiscard.h
@@ -0,0 +1,5 @@
+
+#define MUST_USE_RESULT __attribute__((warn_unused_result))
+#define NO_DISCARD [[nodiscard]]
+#define NO_RETURN [[noreturn]]
+
Index: test/clang-tidy/modernize-use-nodiscard.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-nodiscard.cpp
@@ -0,0 +1,256 @@
+// RUN: %check_clang_tidy %s modernize-use-nodiscard %t -- \
+// RUN:   -config="{CheckOptions: [{key: modernize-use-nodiscard.ReplacementString, value: 'NO_DISCARD'}]}" \
+// RUN: -- -std=c++17
+
+#include 
+
+namespace boost {
+template 
+class function;
+}
+
+#include "modernize-use-nodiscard.h"
+
+#define BOOLEAN_FUNC bool f23() const
+
+typedef unsigned my_unsigned;
+typedef unsigned _unsigned_reference;
+typedef const unsigned _unsigned_const_reference;
+
+class Foo {
+public:
+using size_type = unsigned;
+
+bool f1() const;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f1' should be marked NO_DISCARD [modernize-use-nodiscard]
+// CHECK-FIXES: NO_DISCARD bool f1() const;
+
+bool f2(int) const;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f2' should be marked NO_DISCARD [modernize-use-nodiscard]
+// CHECK-FIXES: NO_DISCARD bool f2(int) const;
+
+bool f3(const int &) const;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f3' should be marked NO_DISCARD [modernize-use-nodiscard]
+// CHECK-FIXES: NO_DISCARD bool f3(const int &) const;
+
+bool f4(void) const;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f4' should be marked NO_DISCARD [modernize-use-nodiscard]
+// CHECK-FIXES: NO_DISCARD bool f4(void) const;
+
+// negative tests
+
+void f5() const;
+
+bool f6();
+
+bool f7(int &);
+
+bool f8(int &) const;
+
+bool f9(int *) const;
+
+bool f10(const int &, int &) const;
+
+NO_DISCARD bool f12() const;
+
+MUST_USE_RESULT bool f13() const;
+
+[[nodiscard]] bool f11() const;
+
+[[clang::warn_unused_result]] bool f11a() const;
+
+[[gnu::warn_unused_result]] bool f11b() const;
+
+bool _f20() const;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function '_f20' should be marked NO_DISCARD [modernize-use-nodiscard]
+// CHECK-FIXES: NO_DISCARD bool _f20() const;
+
+NO_RETURN bool f21() const;
+
+~Foo();
+
+bool operator+=(int) const;
+
+// extra keywords (virtual,inline,const) on return type
+
+virtual bool f14() const;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f14' should be marked NO_DISCARD [modernize-use-nodiscard]
+// CHECK-FIXES: NO_DISCARD virtual bool f14() const;
+
+const bool f15() const;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f15' should be marked NO_DISCARD [modernize-use-nodiscard]
+// CHECK-FIXES: NO_DISCARD const bool f15() const;
+
+inline const bool f16() const;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f16' should be marked NO_DISCARD [modernize-use-nodiscard]
+// CHECK-FIXES: NO_DISCARD inline const bool f16() const;
+
+inline const std::string () const;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f45' should be marked NO_DISCARD [modernize-use-nodiscard]
+// CHECK-FIXES: NO_DISCARD inline const std::string () const;
+
+inline virtual const bool f17() const;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f17' should be marked NO_DISCARD [modernize-use-nodiscard]
+// CHECK-FIXES: NO_DISCARD inline virtual const bool f17() const;
+
+// inline with body
+bool f18() const 
+// 

[PATCH] D56405: Split -Wdelete-non-virtual-dtor into two groups

2019-01-08 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington reopened this revision.
erik.pilkington marked an inline comment as done.
erik.pilkington added a comment.
This revision is now accepted and ready to land.

I reverted my commit in r350639.




Comment at: include/clang/Basic/DiagnosticGroups.td:108-109
 def DeleteNonVirtualDtor : DiagGroup<"delete-non-virtual-dtor">;
+def DeleteAbstractNonVirtualDtor : 
DiagGroup<"delete-abstract-non-virtual-dtor",
+ [DeleteNonVirtualDtor]>;
 def AbstractFinalClass : DiagGroup<"abstract-final-class">;

aaron.ballman wrote:
> rsmith wrote:
> > aaron.ballman wrote:
> > > rsmith wrote:
> > > > This is backwards: this says that `-Wdelete-abstract-non-virtual-dtor` 
> > > > also controls `-Wdelete-non-virtual-dtor`. You presumably want the 
> > > > opposite relationship, so that `-Wdelete-non-virtual-dtor` controls 
> > > > both warnings and `-Wdelete-abstract-non-virtual-dtor` only controls 
> > > > the "abstract" warning.
> > > I took this to be the correct order because disabling the abstract case 
> > > is more dangerous than disabling the non-abstract case (if you disable 
> > > the abstract one, you're saying "I don't care how bad it gets, don't tell 
> > > me about it.").
> > That seems reasonable as a strategy, but the end result doesn't seem to 
> > make much sense: `-Wdelete-abstract-non-virtual-dtor` enables, and  
> > `-Wno-delete-abstract-non-virtual-dtor` disables, warnings that have 
> > nothing to do with deleting an abstract class with a non-virtual 
> > destructor, and `-Wno-delete-non-virtual-dtor` fails to silence warnings 
> > about deleting an object of a class type with a non-virtual destructor. 
> > It's also backwards-incompatible, because the meaning of the existing `-W` 
> > flag has been changed.
> > 
> > One way to fix this would be to rename the groups:
> > 
> > * `delete-abstract-non-virtual-dtor` -> `delete-non-virtual-dtor`
> > * `delete-non-virtual-dtor` -> `delete-nonabstract-non-virtual-dtor` (yuck)
> > 
> > (Or we could keep the existing `delete-abstract-non-virtual-dtor`, add 
> > `delete-nonabstract-non-virtual-dtor`, and make `delete-non-virtual-dtor` 
> > be a group that contains those other two groups and has no diagnostics of 
> > its own.)
> > 
> > Instead / as well, we could address the false positives more directly: we 
> > could only warn if the class in question *introduces* a virtual function 
> > (suggesting that it's intended to be used as a base class), rather than 
> > warning if the class merely *has* virtual functions (if it overrides 
> > virtual functions and doesn't introduce any, there's a good chance it's a 
> > leaf class). `-Wdelete-non-virtual-dtor` was supposed to be the "few/no 
> > false positives" version of `-Wnon-virtual-dtor` (which is really really 
> > just a stylistic warning), and if we can improve it so that people don't 
> > want to turn it off, that'd seem better.
> > That seems reasonable as a strategy, but the end result doesn't seem to 
> > make much sense: -Wdelete-abstract-non-virtual-dtor enables, and  
> > -Wno-delete-abstract-non-virtual-dtor disables, warnings that have nothing 
> > to do with deleting an abstract class with a non-virtual destructor, and 
> > -Wno-delete-non-virtual-dtor fails to silence warnings about deleting an 
> > object of a class type with a non-virtual destructor. It's also 
> > backwards-incompatible, because the meaning of the existing -W flag has 
> > been changed.
> 
> Ah, those are all good points!
> 
> > (Or we could keep the existing delete-abstract-non-virtual-dtor, add 
> > delete-nonabstract-non-virtual-dtor, and make delete-non-virtual-dtor be a 
> > group that contains those other two groups and has no diagnostics of its 
> > own.)
> 
> I have a slight preference for this approach; it feels a bit more natural to 
> me. However, do we want to spell it `delete-nonabstract-non-virtual-dtor` or 
> `delete-non-abstract-non-virtual-dtor` or 
> `delete-nonabstract-nonvirtual-dtor`? My preference is for anything but the 
> first spelling. ;-)
> 
> > Instead / as well, we could address the false positives more directly: 
> 
> Yes, improving the fp rate that way would be a great change to make. That 
> said, I would view it as "as well" rather than "instead" because these two 
> diagnostic scenarios seem reasonably separable.
> Instead / as well, we could address the false positives more directly: we 
> could only warn if the class in question *introduces* a virtual function 
> (suggesting that it's intended to be used as a base class), rather than 
> warning if the class merely *has* virtual functions (if it overrides virtual 
> functions and doesn't introduce any, there's a good chance it's a leaf 
> class). -Wdelete-non-virtual-dtor was supposed to be the "few/no false 
> positives" version of -Wnon-virtual-dtor (which is really really just a 
> stylistic warning), and if we can improve it so that people don't want to 
> 

[PATCH] D55224: [clangd] Introduce loading of shards within auto-index

2019-01-08 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Most comments are NITs, the major one that I'd suggest paying most attention to 
is about rewriting newer results with an older ones.




Comment at: clangd/index/Background.cpp:259
+  // if this thread sees the older version but finishes later. This should
+  // be rare in practice.
+  DigestIt.first->second = Hash;

kadircet wrote:
> ilya-biryukov wrote:
> > > "should be rare in practice"
> > And yet, can we avoid this altogether?
> > 
> > Also, I believe it won't be rare. When processing multiple different TUs, 
> > we can easily run into the same header multiple times, possibly with the 
> > different contents.
> > E.g. imagine the index for the whole of clang is being built and the user 
> > is editing `Sema.h` at the same time. We'll definitely be running into this 
> > case over and over again.
> Well I am open to ideas, but currently there is no way of knowing whether 
> this is the newer version for the file. Because only information we have is 
> the digest is different than what we currently have and this doesn't yield 
> any chronological information.
Do we know which request is "newer" when scheduling it?
If so, we could keep the map of the **latest** hashes of the files we've seen 
(in addition to the `IndexedFileDigests`, which correspond to the digest for 
which we built the index IIUC).

This would give us a simple invariant of the final state we want to bring the 
index to: `IndexedFileDigests` should correspond to the latest hashes seen so 
far. If not, we have to rebuild the index for the corresponding files. That, in 
turn, gives us a way to resolve conflicts: we should never replace with symbols 
built for the latest version (hash) of the file we've seen.

Would that work?



Comment at: clangd/index/Background.cpp:338
 std::lock_guard Lock(DigestsMu);
-if (IndexedFileDigests.lookup(AbsolutePath) == Hash) {
-  vlog("No need to index {0}, already up to date", AbsolutePath);

kadircet wrote:
> ilya-biryukov wrote:
> > This looks like an important optimization. Did we move it to some other 
> > place? Why should we remove it?
> We kind of moved it into loadShards logic by not running indexing for same 
> file multiple times. I needed to delete this check since we might wanna run 
> indexing on a TU, even if it is up-to-date, to get new symbols coming from 
> one of it's includes.
Thanks for the explanation, removing the optimization makes sense, we should 
check for dependency hashes in addition to the original file now.



Comment at: clangd/index/Background.cpp:481
+  if (!Buf)
+continue;
+  // If digests match then dependency doesn't need re-indexing.

kadircet wrote:
> ilya-biryukov wrote:
> > maybe log the error? would be nice to somehow recover too, but not sure 
> > what we can do here.
> Well, if this happens we don't have access to file's contents for some 
> reason. I don't think we can do anything. We might actually want to skip 
> loading these files into index, since they are most likely gone and symbols 
> coming from them won't be accessible. WDYT?
Logging the error is enough, thanks!

I think the ideal recovery is tracking whenever the files we were missing were 
added to the filesystem and rebuilding the index when that happens.
That probably requires more work than we'd like to put into it, though, so I 
don't think investing in this now makes any sense.



Comment at: clangd/index/Background.cpp:261
+  auto Hash = I.second.Digest;
+  std::lock_guard Lock(DigestsMu);
+  // Skip if file is already up to date.

This means lock/unlock on every iteration of the loop.
Could we move collecting the files we need to process into a separate loop that 
would only require a single lock over the whole loop?



Comment at: clangd/index/Background.cpp:414
+   BackgroundIndexStorage *IndexStorage,
+   llvm::StringSet<> ) {
+  // Adds the given shard's contents into BackgroundIndex.

NIT: s/VisitedShards/LoadedShards?
To better align with the name of the local var used in `loadShards()`



Comment at: clangd/index/Background.cpp:416
+  // Adds the given shard's contents into BackgroundIndex.
+  // Consumes Symbols and Refs in Shard.
+  auto AddShardToIndex = [this](llvm::StringRef AbsolutePath,

NIT: Instead of writing this comment, we could accept `IndexFileIn &&` as a 
parameter, which clearly states we're consuming it (this would require handling 
the `nullptr` case in the call sites, but that should be ok).



Comment at: clangd/index/Background.cpp:425
+if (Shard->Symbols)
+  SS = llvm::make_unique(std::move(*Shard->Symbols));
+if (Shard->Refs)

NIT: maybe init at the declaration site? i.e. `unique_ptr SS = 

[PATCH] D56415: NFC: Port QueryParser to StringRef

2019-01-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM aside from the nits pointed out; you can fix and commit without another 
round of review.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D56415



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


r350639 - Revert "Split -Wdelete-non-virtual-dtor into -Wdelete-abstract-non-virtual-dtor"

2019-01-08 Thread Erik Pilkington via cfe-commits
Author: epilk
Date: Tue Jan  8 09:04:38 2019
New Revision: 350639

URL: http://llvm.org/viewvc/llvm-project?rev=350639=rev
Log:
Revert "Split -Wdelete-non-virtual-dtor into -Wdelete-abstract-non-virtual-dtor"

This reverts commit r350585. There was some late post-commit review
on phab.

Removed:
cfe/trunk/test/SemaCXX/non-virtual-dtors.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=350639=350638=350639=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Tue Jan  8 09:04:38 2019
@@ -105,8 +105,6 @@ def MissingNoEscape : DiagGroup<"missing
 
 def DeleteIncomplete : DiagGroup<"delete-incomplete">;
 def DeleteNonVirtualDtor : DiagGroup<"delete-non-virtual-dtor">;
-def DeleteAbstractNonVirtualDtor : 
DiagGroup<"delete-abstract-non-virtual-dtor",
- [DeleteNonVirtualDtor]>;
 def AbstractFinalClass : DiagGroup<"abstract-final-class">;
 
 def CXX11CompatDeprecatedWritableStr :

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=350639=350638=350639=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Jan  8 09:04:38 
2019
@@ -6460,7 +6460,7 @@ def note_delete_non_virtual : Note<
   "qualify call to silence this warning">;
 def warn_delete_abstract_non_virtual_dtor : Warning<
   "%select{delete|destructor}0 called on %1 that is abstract but has "
-  "non-virtual destructor">, InGroup, 
ShowInSystemHeader;
+  "non-virtual destructor">, InGroup, ShowInSystemHeader;
 def warn_overloaded_virtual : Warning<
   "%q0 hides overloaded virtual %select{function|functions}1">,
   InGroup, DefaultIgnore;

Removed: cfe/trunk/test/SemaCXX/non-virtual-dtors.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/non-virtual-dtors.cpp?rev=350638=auto
==
--- cfe/trunk/test/SemaCXX/non-virtual-dtors.cpp (original)
+++ cfe/trunk/test/SemaCXX/non-virtual-dtors.cpp (removed)
@@ -1,32 +0,0 @@
-// RUN: %clang_cc1 %s -verify -DDIAG1
-// RUN: %clang_cc1 %s -verify -DDIAG1 -DDIAG2 -Wdelete-non-virtual-dtor
-// RUN: %clang_cc1 %s -verify -DDIAG1 -Wmost 
-Wno-delete-non-virtual-dtor
-// RUN: %clang_cc1 %s -verify -Wmost 
-Wno-delete-abstract-non-virtual-dtor
-
-#ifndef DIAG1
-#ifndef DIAG2
-// expected-no-diagnostics
-#endif
-#endif
-
-struct S1 {
-  ~S1() {}
-  virtual void abs() = 0;
-};
-
-void f1(S1 *s1) { delete s1; }
-#ifdef DIAG1
-// expected-warning@-2 {{delete called on 'S1' that is abstract but has 
non-virtual destructor}}
-#endif
-
-struct Base {
-  virtual void abs() = 0;
-};
-struct S2 : Base {
-  ~S2() {}
-  void abs() {}
-};
-void f2(S2 *s2) { delete s2; }
-#ifdef DIAG2
-// expected-warning@-2 {{delete called on non-final 'S2' that has virtual 
functions but non-virtual destructor}}
-#endif


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


  1   2   >