[PATCH] D35216: [analyzer] Escape symbols when creating std::initializer_list.

2017-07-18 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin added a comment.

In this case, I would be fine with some sort of AbstractStorageMemoryRegion 
that meant "here is a memory region and somewhere reachable from here exists 
another region of type T". Or even multiple regions with different identifiers. 
This wouldn't specify how the memory is reachable, but it would allow for 
transfer functions to get at those regions and it would allow for invalidation.

For std::initializer_list this reachable region would the region for the 
backing array and the transfer functions for begin() and end() yield the 
beginning and end element regions for it.

In my view this differs from ghost variables in that (1) this storage does 
actually exist (it is just a library implementation detail where that storage 
lives) and (2) it is perfectly valid for a pointer into that storage to be 
returned and for another part of the program to read or write from that 
storage. (Well, in this case just read since it is allowed to be read-only 
memory).

What I'm not OK with is modeling abstract analysis state (for example, the 
count of a NSMutableArray or the typestate of a file handle) as a value stored 
in some ginned up region in the store. This takes an easy problem that the 
analyzer does well at (modeling typestate) and turns it into a hard one that 
the analyzer is bad at (reasoning about the contents of the heap).

I think the key criterion here is: "is the region accessible from outside the 
library". That is, does the library expose the region as a pointer that can be 
read to or written from in the client program? If so, then it makes sense for 
this to be in the store: we are modeling reachable storage as storage. But if 
we're just modeling arbitrary analysis facts that need to be invalidated when a 
pointer escapes then we shouldn't try to gin up storage for them just to get 
invalidation for free.


https://reviews.llvm.org/D35216



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


Re: r308044 - Add documentation for @available

2017-07-18 Thread Tanya Lattner via cfe-commits

> On Jul 18, 2017, at 8:07 AM, Nico Weber  wrote:
> 
> On Mon, Jul 17, 2017 at 8:39 AM, Aaron Ballman  > wrote:
> On Sun, Jul 16, 2017 at 7:49 PM, Nico Weber  > wrote:
> > Aaron, https://clang.llvm.org/docs/AttributeReference.html#availability 
> > 
> > still doesn't have the AttrDocs.td change I made in this change 2 days ago.
> > Do I have to do anything to get it to update?
> 
> No, it's expected to update once a day, usually pretty early in the
> morning EST (ridiculously early PST).
> 
> Tanya, I've not seen any failure emails for building from AttrDocs.td.
> Did I get removed from that list when we updated? If so, I'm happy to
> continue to receive it to help resolve problems, but in the interim,
> do you happen to know more about what's going on?
> 
> Tanya, ping?
>  

FYI this is fixed. Had a permission problem that occurred after the SVN move.

Aaron, I will add you back to the script email as its just sending to the 
mailing list right now.

-Tanya


> 
> Thanks!
> 
> ~Aaron
> 
> >
> > On Fri, Jul 14, 2017 at 2:40 PM, Nico Weber via cfe-commits
> > > wrote:
> >>
> >> Author: nico
> >> Date: Fri Jul 14 11:40:52 2017
> >> New Revision: 308044
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=308044=rev 
> >> 
> >> Log:
> >> Add documentation for @available
> >>
> >> https://reviews.llvm.org/D35379 
> >>
> >> Modified:
> >> cfe/trunk/docs/LanguageExtensions.rst
> >> cfe/trunk/include/clang/Basic/AttrDocs.td
> >>
> >> Modified: cfe/trunk/docs/LanguageExtensions.rst
> >> URL:
> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LanguageExtensions.rst?rev=308044=308043=308044=diff
> >>  
> >> 
> >>
> >> ==
> >> --- cfe/trunk/docs/LanguageExtensions.rst (original)
> >> +++ cfe/trunk/docs/LanguageExtensions.rst Fri Jul 14 11:40:52 2017
> >> @@ -1271,6 +1271,87 @@ Further examples of these attributes are
> >>  Query for these features with ``__has_attribute(ns_consumed)``,
> >>  ``__has_attribute(ns_returns_retained)``, etc.
> >>
> >> +Objective-C @available
> >> +--
> >> +
> >> +It is possible to use the newest SDK but still build a program that can
> >> run on
> >> +older versions of macOS and iOS by passing ``-mmacosx-version-info=`` /
> >> +``--miphoneos-version-min=``.
> >> +
> >> +Before LLVM 5.0, when calling a function that exists only in the OS
> >> that's
> >> +newer than the target OS (as determined by the minimum deployment
> >> version),
> >> +programmers had to carefully check if the function exists at runtime,
> >> using
> >> +null checks for weakly-linked C functions, ``+class`` for Objective-C
> >> classes,
> >> +and ``-respondsToSelector:`` or ``+instancesRespondToSelector:`` for
> >> +Objective-C methods.  If such a check was missed, the program would
> >> compile
> >> +fine, run fine on newer systems, but crash on older systems.
> >> +
> >> +As of LLVM 5.0, ``-Wunguarded-availability`` uses the `availability
> >> attributes
> >> + >> >`_
> >> together
> >> +with the new ``@available()`` keyword to assist with this issue.
> >> +When a method that's introduced in the OS newer than the target OS is
> >> called, a
> >> +-Wunguarded-availability warning is emitted if that call is not guarded:
> >> +
> >> +.. code-block:: objc
> >> +
> >> +  void my_fun(NSSomeClass* var) {
> >> +// If fancyNewMethod was added in e.g. macOS 10.12, but the code is
> >> +// built with -mmacosx-version-min=10.11, then this unconditional
> >> call
> >> +// will emit a -Wunguarded-availability warning:
> >> +[var fancyNewMethod];
> >> +  }
> >> +
> >> +To fix the warning and to avoid the crash on macOS 10.11, wrap it in
> >> +``if(@available())``:
> >> +
> >> +.. code-block:: objc
> >> +
> >> +  void my_fun(NSSomeClass* var) {
> >> +if (@available(macOS 10.12, *)) {
> >> +  [var fancyNewMethod];
> >> +} else {
> >> +  // Put fallback behavior for old macOS versions (and for non-mac
> >> +  // platforms) here.
> >> +}
> >> +  }
> >> +
> >> +The ``*`` is required and means that platforms not explicitly listed will
> >> take
> >> +the true branch, and the compiler will emit ``-Wunguarded-availability``
> >> +warnings for unlisted platforms based on those platform's deployment
> >> target.
> >> +More than one platform can be listed in ``@available()``:
> >> +
> >> +.. code-block:: objc
> >> +
> >> 

[PATCH] D35479: [CodeGen][mips] Support `long_call/far/near` attributes

2017-07-18 Thread Simon Atanasyan via Phabricator via cfe-commits
atanasyan updated this revision to Diff 107246.
atanasyan added a comment.

- Pass `IsForDefinition` argument to the `setTargetAttributes` method.


Repository:
  rL LLVM

https://reviews.llvm.org/D35479

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/CodeGen/TargetInfo.cpp
  lib/CodeGen/TargetInfo.h
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGen/long-call-attr.c
  test/Misc/pragma-attribute-supported-attributes-list.test
  test/Sema/attr-long-call.c

Index: test/Sema/attr-long-call.c
===
--- /dev/null
+++ test/Sema/attr-long-call.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -triple mips-linux-gnu -fsyntax-only -verify %s
+
+__attribute__((long_call(0))) void foo1();  // expected-error {{'long_call' attribute takes no arguments}}
+__attribute__((far(0))) void foo2();  // expected-error {{'far' attribute takes no arguments}}
+__attribute__((near(0))) void foo3();  // expected-error {{'near' attribute takes no arguments}}
+
+__attribute((long_call)) int a; // expected-warning {{attribute only applies to functions}}
+__attribute((far)) int a; // expected-warning {{attribute only applies to functions}}
+__attribute((near)) int a; // expected-warning {{attribute only applies to functions}}
+
+__attribute((long_call)) void foo4();
+__attribute((far)) void foo5();
+__attribute((near)) void foo6();
+
+__attribute((long_call, far)) void foo7();
+
+__attribute((far, near)) void foo8(); // expected-error {{'far' and 'near' attributes are not compatible}} \
+  // expected-note {{conflicting attribute is here}}
Index: test/Misc/pragma-attribute-supported-attributes-list.test
===
--- test/Misc/pragma-attribute-supported-attributes-list.test
+++ test/Misc/pragma-attribute-supported-attributes-list.test
@@ -2,7 +2,7 @@
 
 // The number of supported attributes should never go down!
 
-// CHECK: #pragma clang attribute supports 62 attributes:
+// CHECK: #pragma clang attribute supports 64 attributes:
 // CHECK-NEXT: AMDGPUFlatWorkGroupSize (SubjectMatchRule_function)
 // CHECK-NEXT: AMDGPUNumSGPR (SubjectMatchRule_function)
 // CHECK-NEXT: AMDGPUNumVGPR (SubjectMatchRule_function)
@@ -31,6 +31,8 @@
 // CHECK-NEXT: InternalLinkage (SubjectMatchRule_variable, SubjectMatchRule_function, SubjectMatchRule_record)
 // CHECK-NEXT: LTOVisibilityPublic (SubjectMatchRule_record)
 // CHECK-NEXT: MicroMips (SubjectMatchRule_function)
+// CHECK-NEXT: MipsLongCall (SubjectMatchRule_function)
+// CHECK-NEXT: MipsShortCall (SubjectMatchRule_function)
 // CHECK-NEXT: NoDebug (SubjectMatchRule_hasType_functionType, SubjectMatchRule_objc_method, SubjectMatchRule_variable_not_is_parameter)
 // CHECK-NEXT: NoDuplicate (SubjectMatchRule_function)
 // CHECK-NEXT: NoMicroMips (SubjectMatchRule_function)
Index: test/CodeGen/long-call-attr.c
===
--- /dev/null
+++ test/CodeGen/long-call-attr.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple mips-linux-gnu -emit-llvm  -o  - %s | FileCheck %s
+
+void __attribute__((long_call)) foo1 (void);
+
+void __attribute__((far)) foo2 (void) {}
+
+// CHECK: define void @foo2() [[FAR:#[0-9]+]]
+
+void __attribute__((near)) foo3 (void) { foo1(); }
+
+// CHECK: define void @foo3() [[NEAR:#[0-9]+]]
+
+// CHECK: declare void @foo1() [[LONGDECL:#[0-9]+]]
+
+// CHECK: attributes [[FAR]] = { {{.*}} "long-call" {{.*}} }
+// CHECK: attributes [[NEAR]] = { {{.*}} "short-call" {{.*}} }
+// CHECK: attributes [[LONGDECL]] = { {{.*}} "long-call" {{.*}} }
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -5965,6 +5965,14 @@
   case AttributeList::AT_NoMicroMips:
 handleSimpleAttribute(S, D, Attr);
 break;
+  case AttributeList::AT_MipsLongCall:
+handleSimpleAttributeWithExclusions(
+S, D, Attr);
+break;
+  case AttributeList::AT_MipsShortCall:
+handleSimpleAttributeWithExclusions(
+S, D, Attr);
+break;
   case AttributeList::AT_AMDGPUFlatWorkGroupSize:
 handleAMDGPUFlatWorkGroupSizeAttr(S, D, Attr);
 break;
Index: lib/CodeGen/TargetInfo.h
===
--- lib/CodeGen/TargetInfo.h
+++ lib/CodeGen/TargetInfo.h
@@ -15,6 +15,7 @@
 #ifndef LLVM_CLANG_LIB_CODEGEN_TARGETINFO_H
 #define LLVM_CLANG_LIB_CODEGEN_TARGETINFO_H
 
+#include "CodeGenModule.h"
 #include "CGValue.h"
 #include "clang/AST/Type.h"
 #include "clang/Basic/LLVM.h"
@@ -34,7 +35,6 @@
 namespace CodeGen {
 class ABIInfo;
 class CallArgList;
-class CodeGenModule;
 class CodeGenFunction;
 class CGFunctionInfo;
 
@@ -55,7 +55,8 @@
   /// setTargetAttributes - Provides a convenient hook to 

[PATCH] D35572: Add isValidCPUName and isValidFeature to TargetInfo

2017-07-18 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: lib/Basic/Targets.cpp:2931
+
+  // Fallthrough
+case CK_Nocona:

Use LLVM_FALLTHROUGH?


https://reviews.llvm.org/D35572



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


[PATCH] D34937: Suppressing Reference Counting Diagnostics for Functions Containing 'rc_ownership_trusted_implementation' Annotate Attribute

2017-07-18 Thread Devin Coughlin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL308416: [analyzer] Add annotation attribute to trust retain 
count implementation (authored by dcoughlin).

Changed prior to commit:
  https://reviews.llvm.org/D34937?vs=107020=107243#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D34937

Files:
  cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
  cfe/trunk/test/Analysis/retain-release-inline.m

Index: cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
@@ -1304,6 +1304,21 @@
   DoNothing, DoNothing);
 }
 
+/// Returns true if the declaration 'D' is annotated with 'rcAnnotation'.
+static bool hasRCAnnotation(const Decl *D, StringRef rcAnnotation) {
+  for (const auto *Ann : D->specific_attrs()) {
+if (Ann->getAnnotation() == rcAnnotation)
+  return true;
+  }
+  return false;
+}
+
+/// Returns true if the function declaration 'FD' contains
+/// 'rc_ownership_trusted_implementation' annotate attribute.
+static bool isTrustedReferenceCountImplementation(const FunctionDecl *FD) {
+  return hasRCAnnotation(FD, "rc_ownership_trusted_implementation");
+}
+
 //===--===//
 // Summary creation for Selectors.
 //===--===//
@@ -3380,6 +3395,9 @@
 
   // See if it's one of the specific functions we know how to eval.
   bool canEval = false;
+  // See if the function has 'rc_ownership_trusted_implementation'
+  // annotate attribute. If it does, we will not inline it.
+  bool hasTrustedImplementationAnnotation = false;
 
   QualType ResultTy = CE->getCallReturnType(C.getASTContext());
   if (ResultTy->isObjCIdType()) {
@@ -3395,6 +3413,11 @@
 cocoa::isRefType(ResultTy, "CV", FName)) {
   canEval = isRetain(FD, FName) || isAutorelease(FD, FName) ||
 isMakeCollectable(FD, FName);
+} else {
+  if (FD->getDefinition()) {
+canEval = isTrustedReferenceCountImplementation(FD->getDefinition());
+hasTrustedImplementationAnnotation = canEval;
+  }
 }
   }
 
@@ -3404,8 +3427,11 @@
   // Bind the return value.
   const LocationContext *LCtx = C.getLocationContext();
   SVal RetVal = state->getSVal(CE->getArg(0), LCtx);
-  if (RetVal.isUnknown()) {
-// If the receiver is unknown, conjure a return value.
+  if (RetVal.isUnknown() ||
+  (hasTrustedImplementationAnnotation && !ResultTy.isNull())) {
+// If the receiver is unknown or the function has
+// 'rc_ownership_trusted_implementation' annotate attribute, conjure a
+// return value.
 SValBuilder  = C.getSValBuilder();
 RetVal = SVB.conjureSymbolVal(nullptr, CE, LCtx, ResultTy, C.blockCount());
   }
@@ -3421,8 +3447,9 @@
   Binding = getRefBinding(state, Sym);
 
 // Invalidate the argument region.
-state = state->invalidateRegions(ArgRegion, CE, C.blockCount(), LCtx,
- /*CausesPointerEscape*/ false);
+state = state->invalidateRegions(
+ArgRegion, CE, C.blockCount(), LCtx,
+/*CausesPointerEscape*/ hasTrustedImplementationAnnotation);
 
 // Restore the refcount status of the argument.
 if (Binding)
Index: cfe/trunk/test/Analysis/retain-release-inline.m
===
--- cfe/trunk/test/Analysis/retain-release-inline.m
+++ cfe/trunk/test/Analysis/retain-release-inline.m
@@ -12,7 +12,7 @@
 //
 // It includes the basic definitions for the test cases below.
 //===--===//
-
+#define NULL 0
 typedef unsigned int __darwin_natural_t;
 typedef unsigned long uintptr_t;
 typedef unsigned int uint32_t;
@@ -267,6 +267,10 @@
 
 extern CFStringRef CFStringCreateWithCStringNoCopy(CFAllocatorRef alloc, const char *cStr, CFStringEncoding encoding, CFAllocatorRef contentsDeallocator);
 
+typedef struct {
+  int ref;
+} isl_basic_map;
+
 //===--===//
 // Test cases.
 //===--===//
@@ -285,6 +289,7 @@
   foo(s);
   bar(s);
 }
+
 void test_neg() {
   NSString *s = [[NSString alloc] init]; // no-warning  
   foo(s);
@@ -294,6 +299,55 @@
   bar(s);
 }
 
+__attribute__((cf_returns_retained)) isl_basic_map *isl_basic_map_cow(__attribute__((cf_consumed)) isl_basic_map *bmap);
+void free(void *);
+
+// As 'isl_basic_map_free' is annotated with 'rc_ownership_trusted_implementation', RetainCountChecker trusts its
+// implementation and doesn't analyze its body. If the annotation 'rc_ownership_trusted_implementation' is removed,
+// a leak warning is raised by 

[PATCH] D34937: Suppressing Reference Counting Diagnostics for Functions Containing 'rc_ownership_trusted_implementation' Annotate Attribute

2017-07-18 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin added a comment.

Committed in r308416.


Repository:
  rL LLVM

https://reviews.llvm.org/D34937



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


r308416 - [analyzer] Add annotation attribute to trust retain count implementation

2017-07-18 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Tue Jul 18 21:10:44 2017
New Revision: 308416

URL: http://llvm.org/viewvc/llvm-project?rev=308416=rev
Log:
[analyzer] Add annotation attribute to trust retain count implementation

Add support to the retain-count checker for an annotation indicating that a
function's implementation should be trusted by the retain count checker.
Functions with these attributes will not be inlined and the arguments will
be treating as escaping.

Adding this annotation avoids spurious diagnostics when the implementation of
a reference counting operation is visible but the analyzer can't reason
precisely about the ref count.

Patch by Malhar Thakkar!

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
cfe/trunk/test/Analysis/retain-release-inline.m

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp?rev=308416=308415=308416=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp Tue Jul 18 
21:10:44 2017
@@ -1304,6 +1304,21 @@ RetainSummaryManager::getCFSummaryGetRul
   DoNothing, DoNothing);
 }
 
+/// Returns true if the declaration 'D' is annotated with 'rcAnnotation'.
+static bool hasRCAnnotation(const Decl *D, StringRef rcAnnotation) {
+  for (const auto *Ann : D->specific_attrs()) {
+if (Ann->getAnnotation() == rcAnnotation)
+  return true;
+  }
+  return false;
+}
+
+/// Returns true if the function declaration 'FD' contains
+/// 'rc_ownership_trusted_implementation' annotate attribute.
+static bool isTrustedReferenceCountImplementation(const FunctionDecl *FD) {
+  return hasRCAnnotation(FD, "rc_ownership_trusted_implementation");
+}
+
 
//===--===//
 // Summary creation for Selectors.
 
//===--===//
@@ -3380,6 +3395,9 @@ bool RetainCountChecker::evalCall(const
 
   // See if it's one of the specific functions we know how to eval.
   bool canEval = false;
+  // See if the function has 'rc_ownership_trusted_implementation'
+  // annotate attribute. If it does, we will not inline it.
+  bool hasTrustedImplementationAnnotation = false;
 
   QualType ResultTy = CE->getCallReturnType(C.getASTContext());
   if (ResultTy->isObjCIdType()) {
@@ -3395,6 +3413,11 @@ bool RetainCountChecker::evalCall(const
 cocoa::isRefType(ResultTy, "CV", FName)) {
   canEval = isRetain(FD, FName) || isAutorelease(FD, FName) ||
 isMakeCollectable(FD, FName);
+} else {
+  if (FD->getDefinition()) {
+canEval = isTrustedReferenceCountImplementation(FD->getDefinition());
+hasTrustedImplementationAnnotation = canEval;
+  }
 }
   }
 
@@ -3404,8 +3427,11 @@ bool RetainCountChecker::evalCall(const
   // Bind the return value.
   const LocationContext *LCtx = C.getLocationContext();
   SVal RetVal = state->getSVal(CE->getArg(0), LCtx);
-  if (RetVal.isUnknown()) {
-// If the receiver is unknown, conjure a return value.
+  if (RetVal.isUnknown() ||
+  (hasTrustedImplementationAnnotation && !ResultTy.isNull())) {
+// If the receiver is unknown or the function has
+// 'rc_ownership_trusted_implementation' annotate attribute, conjure a
+// return value.
 SValBuilder  = C.getSValBuilder();
 RetVal = SVB.conjureSymbolVal(nullptr, CE, LCtx, ResultTy, C.blockCount());
   }
@@ -3421,8 +3447,9 @@ bool RetainCountChecker::evalCall(const
   Binding = getRefBinding(state, Sym);
 
 // Invalidate the argument region.
-state = state->invalidateRegions(ArgRegion, CE, C.blockCount(), LCtx,
- /*CausesPointerEscape*/ false);
+state = state->invalidateRegions(
+ArgRegion, CE, C.blockCount(), LCtx,
+/*CausesPointerEscape*/ hasTrustedImplementationAnnotation);
 
 // Restore the refcount status of the argument.
 if (Binding)

Modified: cfe/trunk/test/Analysis/retain-release-inline.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/retain-release-inline.m?rev=308416=308415=308416=diff
==
--- cfe/trunk/test/Analysis/retain-release-inline.m (original)
+++ cfe/trunk/test/Analysis/retain-release-inline.m Tue Jul 18 21:10:44 2017
@@ -12,7 +12,7 @@
 //
 // It includes the basic definitions for the test cases below.
 
//===--===//
-
+#define NULL 0
 typedef unsigned int __darwin_natural_t;
 typedef unsigned long uintptr_t;
 typedef unsigned int uint32_t;
@@ -267,6 +267,10 @@ typedef NSUInteger 

[PATCH] D34937: Suppressing Reference Counting Diagnostics for Functions Containing 'rc_ownership_trusted_implementation' Annotate Attribute

2017-07-18 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin accepted this revision.
dcoughlin added a comment.
This revision is now accepted and ready to land.

LGTM! One thing I should have noted in a prior review is that the helper 
functions should be declared 'static' so that we don't have a public symbol for 
them. Making them static will prevent a linker error if some other part of 
clang declares a function with the same signature. This is unlikely, but we try 
to keep things clean.

I will update the two functions to be static and commit.


Repository:
  rL LLVM

https://reviews.llvm.org/D34937



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


[PATCH] D35338: Add the -fdestroy-globals flag

2017-07-18 Thread George Burgess IV via Phabricator via cfe-commits
george.burgess.iv added a comment.

Thanks for working on this!

One small drive-by nit for you. Same "no need to update the diff this very 
second" as vsk; I can't LGTM this with confidence.

(Also, in the future, please try to include context 

 with your patch. Doing so makes reviewing it on Phab much easier. :) )




Comment at: include/clang/Frontend/CodeGenOptions.def:47
  ///< aliases to base ctors when possible.
+CODEGENOPT(DestroyGlobals, 1, 1) ///< -fdestroy-globals
 CODEGENOPT(DataSections  , 1, 0) ///< Set when -fdata-sections is enabled.

Nit: Please align the `///` with the above/below ones.


https://reviews.llvm.org/D35338



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


[PATCH] D32817: [CMake] Build runtimes for Fuchsia targets

2017-07-18 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL308412: [CMake] Build runtimes for Fuchsia targets (authored 
by phosek).

Changed prior to commit:
  https://reviews.llvm.org/D32817?vs=107236=107240#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32817

Files:
  cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
  cfe/trunk/cmake/caches/Fuchsia.cmake


Index: cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
===
--- cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
+++ cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
@@ -7,7 +7,6 @@
 
 set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "")
 set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "")
-set(LLVM_TOOL_CLANG_TOOLS_EXTRA_BUILD OFF CACHE BOOL "")
 set(LLVM_ENABLE_ZLIB ON CACHE BOOL "")
 set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
 set(LLVM_EXTERNALIZE_DEBUGINFO ON CACHE BOOL "")
@@ -27,11 +26,27 @@
 set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -gline-tables-only -DNDEBUG" CACHE 
STRING "")
 set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -gline-tables-only -DNDEBUG" CACHE 
STRING "")
 
-set(LLVM_BUILTIN_TARGETS "x86_64-fuchsia-none;aarch64-fuchsia-none" CACHE 
STRING "")
-set(BUILTINS_x86_64-fuchsia-none_CMAKE_SYSROOT ${FUCHSIA_SYSROOT} CACHE STRING 
"")
-set(BUILTINS_x86_64-fuchsia-none_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
-set(BUILTINS_aarch64-fuchsia-none_CMAKE_SYSROOT ${FUCHSIA_SYSROOT} CACHE 
STRING "")
-set(BUILTINS_aarch64-fuchsia-none_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
+set(LLVM_BUILTIN_TARGETS "x86_64-fuchsia;aarch64-fuchsia" CACHE STRING "")
+foreach(target x86_64;aarch64)
+  set(BUILTINS_${target}-fuchsia_CMAKE_SYSROOT ${FUCHSIA_${target}_SYSROOT} 
CACHE PATH "")
+  set(BUILTINS_${target}-fuchsia_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
+endforeach()
+if(NOT APPLE)
+  list(APPEND LLVM_BUILTIN_TARGETS "default")
+endif()
+
+set(LLVM_RUNTIME_TARGETS "default;x86_64-fuchsia;aarch64-fuchsia" CACHE STRING 
"")
+foreach(target x86_64;aarch64)
+  set(RUNTIMES_${target}-fuchsia_CMAKE_BUILD_WITH_INSTALL_RPATH ON CACHE BOOL 
"")
+  set(RUNTIMES_${target}-fuchsia_CMAKE_SYSROOT ${FUCHSIA_${target}_SYSROOT} 
CACHE PATH "")
+  set(RUNTIMES_${target}-fuchsia_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
+  set(RUNTIMES_${target}-fuchsia_UNIX 1 CACHE BOOL "")
+  set(RUNTIMES_${target}-fuchsia_LLVM_ENABLE_LIBCXX ON CACHE BOOL "")
+  set(RUNTIMES_${target}-fuchsia_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
+  set(RUNTIMES_${target}-fuchsia_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
+  set(RUNTIMES_${target}-fuchsia_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
+  set(RUNTIMES_${target}-fuchsia_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
+endforeach()
 
 # Setup toolchain.
 set(LLVM_INSTALL_TOOLCHAIN_ONLY ON CACHE BOOL "")
@@ -47,6 +62,7 @@
   llvm-objdump
   llvm-profdata
   llvm-ranlib
+  llvm-readelf
   llvm-readobj
   llvm-size
   llvm-symbolizer
@@ -61,8 +77,9 @@
   LTO
   clang-format
   clang-headers
-  builtins-x86_64-fuchsia-none
-  builtins-aarch64-fuchsia-none
+  clang-tidy
+  clangd
+  builtins
   runtimes
   ${LLVM_TOOLCHAIN_TOOLS}
   CACHE STRING "")
Index: cfe/trunk/cmake/caches/Fuchsia.cmake
===
--- cfe/trunk/cmake/caches/Fuchsia.cmake
+++ cfe/trunk/cmake/caches/Fuchsia.cmake
@@ -38,9 +38,11 @@
   install-distribution
   clang CACHE STRING "")
 
-if(FUCHSIA_SYSROOT)
-  set(EXTRA_ARGS -DFUCHSIA_SYSROOT=${FUCHSIA_SYSROOT})
-endif()
+foreach(target x86_64;aarch64)
+  if(FUCHSIA_${target}_SYSROOT)
+list(APPEND EXTRA_ARGS 
-DFUCHSIA_${target}_SYSROOT=${FUCHSIA_${target}_SYSROOT})
+  endif()
+endforeach()
 
 # Setup the bootstrap build.
 set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "")


Index: cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
===
--- cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
+++ cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
@@ -7,7 +7,6 @@
 
 set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "")
 set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "")
-set(LLVM_TOOL_CLANG_TOOLS_EXTRA_BUILD OFF CACHE BOOL "")
 set(LLVM_ENABLE_ZLIB ON CACHE BOOL "")
 set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
 set(LLVM_EXTERNALIZE_DEBUGINFO ON CACHE BOOL "")
@@ -27,11 +26,27 @@
 set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -gline-tables-only -DNDEBUG" CACHE STRING "")
 set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -gline-tables-only -DNDEBUG" CACHE STRING "")
 
-set(LLVM_BUILTIN_TARGETS "x86_64-fuchsia-none;aarch64-fuchsia-none" CACHE STRING "")
-set(BUILTINS_x86_64-fuchsia-none_CMAKE_SYSROOT ${FUCHSIA_SYSROOT} CACHE STRING "")
-set(BUILTINS_x86_64-fuchsia-none_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
-set(BUILTINS_aarch64-fuchsia-none_CMAKE_SYSROOT ${FUCHSIA_SYSROOT} CACHE STRING "")
-set(BUILTINS_aarch64-fuchsia-none_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
+set(LLVM_BUILTIN_TARGETS "x86_64-fuchsia;aarch64-fuchsia" CACHE STRING "")
+foreach(target x86_64;aarch64)
+  

r308412 - [CMake] Build runtimes for Fuchsia targets

2017-07-18 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Tue Jul 18 19:57:47 2017
New Revision: 308412

URL: http://llvm.org/viewvc/llvm-project?rev=308412=rev
Log:
[CMake] Build runtimes for Fuchsia targets

This relies on the multi-target runtimes build support.

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

Modified:
cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
cfe/trunk/cmake/caches/Fuchsia.cmake

Modified: cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/Fuchsia-stage2.cmake?rev=308412=308411=308412=diff
==
--- cfe/trunk/cmake/caches/Fuchsia-stage2.cmake (original)
+++ cfe/trunk/cmake/caches/Fuchsia-stage2.cmake Tue Jul 18 19:57:47 2017
@@ -7,7 +7,6 @@ set(PACKAGE_VENDOR Fuchsia CACHE STRING
 
 set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "")
 set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "")
-set(LLVM_TOOL_CLANG_TOOLS_EXTRA_BUILD OFF CACHE BOOL "")
 set(LLVM_ENABLE_ZLIB ON CACHE BOOL "")
 set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
 set(LLVM_EXTERNALIZE_DEBUGINFO ON CACHE BOOL "")
@@ -27,11 +26,27 @@ set(CMAKE_BUILD_TYPE RelWithDebInfo CACH
 set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -gline-tables-only -DNDEBUG" CACHE 
STRING "")
 set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -gline-tables-only -DNDEBUG" CACHE 
STRING "")
 
-set(LLVM_BUILTIN_TARGETS "x86_64-fuchsia-none;aarch64-fuchsia-none" CACHE 
STRING "")
-set(BUILTINS_x86_64-fuchsia-none_CMAKE_SYSROOT ${FUCHSIA_SYSROOT} CACHE STRING 
"")
-set(BUILTINS_x86_64-fuchsia-none_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
-set(BUILTINS_aarch64-fuchsia-none_CMAKE_SYSROOT ${FUCHSIA_SYSROOT} CACHE 
STRING "")
-set(BUILTINS_aarch64-fuchsia-none_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
+set(LLVM_BUILTIN_TARGETS "x86_64-fuchsia;aarch64-fuchsia" CACHE STRING "")
+foreach(target x86_64;aarch64)
+  set(BUILTINS_${target}-fuchsia_CMAKE_SYSROOT ${FUCHSIA_${target}_SYSROOT} 
CACHE PATH "")
+  set(BUILTINS_${target}-fuchsia_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
+endforeach()
+if(NOT APPLE)
+  list(APPEND LLVM_BUILTIN_TARGETS "default")
+endif()
+
+set(LLVM_RUNTIME_TARGETS "default;x86_64-fuchsia;aarch64-fuchsia" CACHE STRING 
"")
+foreach(target x86_64;aarch64)
+  set(RUNTIMES_${target}-fuchsia_CMAKE_BUILD_WITH_INSTALL_RPATH ON CACHE BOOL 
"")
+  set(RUNTIMES_${target}-fuchsia_CMAKE_SYSROOT ${FUCHSIA_${target}_SYSROOT} 
CACHE PATH "")
+  set(RUNTIMES_${target}-fuchsia_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
+  set(RUNTIMES_${target}-fuchsia_UNIX 1 CACHE BOOL "")
+  set(RUNTIMES_${target}-fuchsia_LLVM_ENABLE_LIBCXX ON CACHE BOOL "")
+  set(RUNTIMES_${target}-fuchsia_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
+  set(RUNTIMES_${target}-fuchsia_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
+  set(RUNTIMES_${target}-fuchsia_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
+  set(RUNTIMES_${target}-fuchsia_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
+endforeach()
 
 # Setup toolchain.
 set(LLVM_INSTALL_TOOLCHAIN_ONLY ON CACHE BOOL "")
@@ -47,6 +62,7 @@ set(LLVM_TOOLCHAIN_TOOLS
   llvm-objdump
   llvm-profdata
   llvm-ranlib
+  llvm-readelf
   llvm-readobj
   llvm-size
   llvm-symbolizer
@@ -61,8 +77,9 @@ set(LLVM_DISTRIBUTION_COMPONENTS
   LTO
   clang-format
   clang-headers
-  builtins-x86_64-fuchsia-none
-  builtins-aarch64-fuchsia-none
+  clang-tidy
+  clangd
+  builtins
   runtimes
   ${LLVM_TOOLCHAIN_TOOLS}
   CACHE STRING "")

Modified: cfe/trunk/cmake/caches/Fuchsia.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/Fuchsia.cmake?rev=308412=308411=308412=diff
==
--- cfe/trunk/cmake/caches/Fuchsia.cmake (original)
+++ cfe/trunk/cmake/caches/Fuchsia.cmake Tue Jul 18 19:57:47 2017
@@ -38,9 +38,11 @@ set(CLANG_BOOTSTRAP_TARGETS
   install-distribution
   clang CACHE STRING "")
 
-if(FUCHSIA_SYSROOT)
-  set(EXTRA_ARGS -DFUCHSIA_SYSROOT=${FUCHSIA_SYSROOT})
-endif()
+foreach(target x86_64;aarch64)
+  if(FUCHSIA_${target}_SYSROOT)
+list(APPEND EXTRA_ARGS 
-DFUCHSIA_${target}_SYSROOT=${FUCHSIA_${target}_SYSROOT})
+  endif()
+endforeach()
 
 # Setup the bootstrap build.
 set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "")


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


[PATCH] D32817: [CMake] Build runtimes for Fuchsia targets

2017-07-18 Thread Petr Hosek via Phabricator via cfe-commits
phosek updated this revision to Diff 107236.

Repository:
  rL LLVM

https://reviews.llvm.org/D32817

Files:
  cmake/caches/Fuchsia-stage2.cmake
  cmake/caches/Fuchsia.cmake


Index: cmake/caches/Fuchsia.cmake
===
--- cmake/caches/Fuchsia.cmake
+++ cmake/caches/Fuchsia.cmake
@@ -38,9 +38,11 @@
   install-distribution
   clang CACHE STRING "")
 
-if(FUCHSIA_SYSROOT)
-  set(EXTRA_ARGS -DFUCHSIA_SYSROOT=${FUCHSIA_SYSROOT})
-endif()
+foreach(target x86_64;aarch64)
+  if(FUCHSIA_${target}_SYSROOT)
+list(APPEND EXTRA_ARGS 
-DFUCHSIA_${target}_SYSROOT=${FUCHSIA_${target}_SYSROOT})
+  endif()
+endforeach()
 
 # Setup the bootstrap build.
 set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "")
Index: cmake/caches/Fuchsia-stage2.cmake
===
--- cmake/caches/Fuchsia-stage2.cmake
+++ cmake/caches/Fuchsia-stage2.cmake
@@ -7,7 +7,6 @@
 
 set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "")
 set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "")
-set(LLVM_TOOL_CLANG_TOOLS_EXTRA_BUILD OFF CACHE BOOL "")
 set(LLVM_ENABLE_ZLIB ON CACHE BOOL "")
 set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
 set(LLVM_EXTERNALIZE_DEBUGINFO ON CACHE BOOL "")
@@ -27,11 +26,27 @@
 set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -gline-tables-only -DNDEBUG" CACHE 
STRING "")
 set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -gline-tables-only -DNDEBUG" CACHE 
STRING "")
 
-set(LLVM_BUILTIN_TARGETS "x86_64-fuchsia-none;aarch64-fuchsia-none" CACHE 
STRING "")
-set(BUILTINS_x86_64-fuchsia-none_CMAKE_SYSROOT ${FUCHSIA_SYSROOT} CACHE STRING 
"")
-set(BUILTINS_x86_64-fuchsia-none_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
-set(BUILTINS_aarch64-fuchsia-none_CMAKE_SYSROOT ${FUCHSIA_SYSROOT} CACHE 
STRING "")
-set(BUILTINS_aarch64-fuchsia-none_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
+set(LLVM_BUILTIN_TARGETS "x86_64-fuchsia;aarch64-fuchsia" CACHE STRING "")
+foreach(target x86_64;aarch64)
+  set(BUILTINS_${target}-fuchsia_CMAKE_SYSROOT ${FUCHSIA_${target}_SYSROOT} 
CACHE PATH "")
+  set(BUILTINS_${target}-fuchsia_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
+endforeach()
+if(NOT APPLE)
+  list(APPEND LLVM_BUILTIN_TARGETS "default")
+endif()
+
+set(LLVM_RUNTIME_TARGETS "default;x86_64-fuchsia;aarch64-fuchsia" CACHE STRING 
"")
+foreach(target x86_64;aarch64)
+  set(RUNTIMES_${target}-fuchsia_CMAKE_BUILD_WITH_INSTALL_RPATH ON CACHE BOOL 
"")
+  set(RUNTIMES_${target}-fuchsia_CMAKE_SYSROOT ${FUCHSIA_${target}_SYSROOT} 
CACHE PATH "")
+  set(RUNTIMES_${target}-fuchsia_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
+  set(RUNTIMES_${target}-fuchsia_UNIX 1 CACHE BOOL "")
+  set(RUNTIMES_${target}-fuchsia_LLVM_ENABLE_LIBCXX ON CACHE BOOL "")
+  set(RUNTIMES_${target}-fuchsia_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
+  set(RUNTIMES_${target}-fuchsia_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
+  set(RUNTIMES_${target}-fuchsia_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
+  set(RUNTIMES_${target}-fuchsia_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
+endforeach()
 
 # Setup toolchain.
 set(LLVM_INSTALL_TOOLCHAIN_ONLY ON CACHE BOOL "")
@@ -47,6 +62,7 @@
   llvm-objdump
   llvm-profdata
   llvm-ranlib
+  llvm-readelf
   llvm-readobj
   llvm-size
   llvm-symbolizer
@@ -61,8 +77,9 @@
   LTO
   clang-format
   clang-headers
-  builtins-x86_64-fuchsia-none
-  builtins-aarch64-fuchsia-none
+  clang-tidy
+  clangd
+  builtins
   runtimes
   ${LLVM_TOOLCHAIN_TOOLS}
   CACHE STRING "")


Index: cmake/caches/Fuchsia.cmake
===
--- cmake/caches/Fuchsia.cmake
+++ cmake/caches/Fuchsia.cmake
@@ -38,9 +38,11 @@
   install-distribution
   clang CACHE STRING "")
 
-if(FUCHSIA_SYSROOT)
-  set(EXTRA_ARGS -DFUCHSIA_SYSROOT=${FUCHSIA_SYSROOT})
-endif()
+foreach(target x86_64;aarch64)
+  if(FUCHSIA_${target}_SYSROOT)
+list(APPEND EXTRA_ARGS -DFUCHSIA_${target}_SYSROOT=${FUCHSIA_${target}_SYSROOT})
+  endif()
+endforeach()
 
 # Setup the bootstrap build.
 set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "")
Index: cmake/caches/Fuchsia-stage2.cmake
===
--- cmake/caches/Fuchsia-stage2.cmake
+++ cmake/caches/Fuchsia-stage2.cmake
@@ -7,7 +7,6 @@
 
 set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "")
 set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "")
-set(LLVM_TOOL_CLANG_TOOLS_EXTRA_BUILD OFF CACHE BOOL "")
 set(LLVM_ENABLE_ZLIB ON CACHE BOOL "")
 set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
 set(LLVM_EXTERNALIZE_DEBUGINFO ON CACHE BOOL "")
@@ -27,11 +26,27 @@
 set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -gline-tables-only -DNDEBUG" CACHE STRING "")
 set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -gline-tables-only -DNDEBUG" CACHE STRING "")
 
-set(LLVM_BUILTIN_TARGETS "x86_64-fuchsia-none;aarch64-fuchsia-none" CACHE STRING "")
-set(BUILTINS_x86_64-fuchsia-none_CMAKE_SYSROOT ${FUCHSIA_SYSROOT} CACHE STRING "")
-set(BUILTINS_x86_64-fuchsia-none_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")

[PATCH] D35603: [Driver] Consider -fno-sanitize=... state when filtering out -fsanitize-coverage=...

2017-07-18 Thread Roland McGrath via Phabricator via cfe-commits
mcgrathr created this revision.

The driver ignores -fsanitize-coverage=... flags when also given
-fsanitize=... flags for sanitizer flavors that don't support the
coverage runtime.  This logic failed to account for subsequent
-fno-sanitize=... flags that disable the sanitizer flavors that
conflict with -fsanitize-coverage=... flags.


Repository:
  rL LLVM

https://reviews.llvm.org/D35603

Files:
  lib/Driver/SanitizerArgs.cpp
  test/Driver/fsanitize-coverage.c


Index: test/Driver/fsanitize-coverage.c
===
--- test/Driver/fsanitize-coverage.c
+++ test/Driver/fsanitize-coverage.c
@@ -95,3 +95,15 @@
 // CLANG-CL-COVERAGE-NOT: unknown argument
 // CLANG-CL-COVERAGE: -fsanitize-coverage-type=1
 // CLANG-CL-COVERAGE: -fsanitize=address
+
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=safe-stack 
-fsanitize-coverage=trace-pc-guard %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-VS-SAFESTACK
+// CHECK-VS-SAFESTACK: -fsanitize=safe-stack
+// CHECK-VS-SAFESTACK-NOT: -fsanitize-coverage-trace-pc-guard
+
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=safe-stack 
-fsanitize-coverage=trace-pc-guard -fno-sanitize=safe-stack %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-NO-SAFESTACK
+// CHECK-NO-SAFESTACK-NOT: error:
+// CHECK-NO-SAFESTACK-NOT: warning:
+// CHECK-NO-SAFESTACK-NOT: argument unused
+// CHECK-NO-SAFESTACK-NOT: unknown argument
+// CHECK-NO-SAFESTACK-NOT: -fsanitize=safe-stack
+// CHECK-NO-SAFESTACK: -fsanitize-coverage-trace-pc-guard
Index: lib/Driver/SanitizerArgs.cpp
===
--- lib/Driver/SanitizerArgs.cpp
+++ lib/Driver/SanitizerArgs.cpp
@@ -504,7 +504,7 @@
 
   // Disable coverage and not claim the flags if there is at least one
   // non-supporting sanitizer.
-  if (!(AllAddedKinds & ~setGroupBits(SupportsCoverage))) {
+  if (!(AllAddedKinds & ~AllRemove & ~setGroupBits(SupportsCoverage))) {
 Arg->claim();
   } else {
 CoverageFeatures = 0;


Index: test/Driver/fsanitize-coverage.c
===
--- test/Driver/fsanitize-coverage.c
+++ test/Driver/fsanitize-coverage.c
@@ -95,3 +95,15 @@
 // CLANG-CL-COVERAGE-NOT: unknown argument
 // CLANG-CL-COVERAGE: -fsanitize-coverage-type=1
 // CLANG-CL-COVERAGE: -fsanitize=address
+
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=safe-stack -fsanitize-coverage=trace-pc-guard %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-VS-SAFESTACK
+// CHECK-VS-SAFESTACK: -fsanitize=safe-stack
+// CHECK-VS-SAFESTACK-NOT: -fsanitize-coverage-trace-pc-guard
+
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=safe-stack -fsanitize-coverage=trace-pc-guard -fno-sanitize=safe-stack %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-SAFESTACK
+// CHECK-NO-SAFESTACK-NOT: error:
+// CHECK-NO-SAFESTACK-NOT: warning:
+// CHECK-NO-SAFESTACK-NOT: argument unused
+// CHECK-NO-SAFESTACK-NOT: unknown argument
+// CHECK-NO-SAFESTACK-NOT: -fsanitize=safe-stack
+// CHECK-NO-SAFESTACK: -fsanitize-coverage-trace-pc-guard
Index: lib/Driver/SanitizerArgs.cpp
===
--- lib/Driver/SanitizerArgs.cpp
+++ lib/Driver/SanitizerArgs.cpp
@@ -504,7 +504,7 @@
 
   // Disable coverage and not claim the flags if there is at least one
   // non-supporting sanitizer.
-  if (!(AllAddedKinds & ~setGroupBits(SupportsCoverage))) {
+  if (!(AllAddedKinds & ~AllRemove & ~setGroupBits(SupportsCoverage))) {
 Arg->claim();
   } else {
 CoverageFeatures = 0;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D35538: [CodeGen][ARM] ARM runtime helper functions are not always soft-fp

2017-07-18 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd requested changes to this revision.
compnerd added a comment.
This revision now requires changes to proceed.

Can you please add a test that shows that the AEABI functions are not given the 
wrong CC?  Also, can you show that if someone also passes `-meabi=gnu` with a 
VFP target, that we still annotate the functions with the differing CC (since 
that should prefer the GNU functions over the AEABI functions).


https://reviews.llvm.org/D35538



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


[PATCH] D35338: Add the -fdestroy-globals flag

2017-07-18 Thread Ian Tessier via Phabricator via cfe-commits
itessier added a comment.

In https://reviews.llvm.org/D35338#809146, @vsk wrote:

> This is interesting. Do you have any results/metrics to share (e.g some any 
> binary size reduction for projects you've looked at)?


I only tested this with Project Loon's avionics firmware which freed up ~1.2% 
of ROM space. A small amount, but for us every bit counts.

I did look at creating a templated wrapper class instead which uses 
placement-new to construct the wrapped type in a private char buffer. This 
results in the same effect as this patch (no dtor references are emitted). The 
only issue is the code is a big uglier to read, and we might forgot to use the 
wrapper (though a static checker could be added for this case). I figured it'd 
be best to add compiler support so other C++ based firmware projects can 
benefit as well.


https://reviews.llvm.org/D35338



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


Re: [PATCH v3] [PPC64]: Add support for Swift calling convention

2017-07-18 Thread Andrew Jeffery via cfe-commits
Another friendly ping :)

Cheers,

Andrew

On Wed, 2017-07-05 at 11:23 +0930, Andrew Jeffery wrote:
> Ping - is anyone able to provide feedback?
> 
> Cheers,
> 
> Andrew
> 
> On Thu, 2017-06-22 at 16:02 +0930, Andrew Jeffery wrote:
> > For the tests I've extracted the int5 and int8 cases to cater for
> > different alignments for different platform ABIs. For Linux on
> > POWER the
> > 5 and 8 element vectors must be naturally aligned with respect to
> > the
> > total "soft" vector size, despite being represented as an
> > aggregate.
> > Specifically, the patch caters for the following differences in
> > supporting powerpc64le-unknown-linux:
> > 
> >    $ diff -u test/CodeGen/64bit-swiftcall.c test/CodeGen/ppc64-
> > swiftcall.c
> > >    --- test/CodeGen/64bit-swiftcall.c 2017-04-20
> > > 17:14:59.797963820 +0930
> > >    +++ test/CodeGen/ppc64-swiftcall.c 2017-04-20
> > > 17:15:11.621965118 +0930
> > 
> >    @@ -1,7 +1,6 @@
> >    -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -target-cpu
> > core2 -emit-llvm -o - %s | FileCheck %s
> >    -// RUN: %clang_cc1 -triple arm64-apple-ios9 -target-cpu cyclone
> > -emit-llvm -o - %s | FileCheck %s
> >    +// RUN: %clang_cc1 -triple powerpc64le-unknown-linux -emit-llvm 
> > -o - %s | FileCheck %s
> > 
> >    -// REQUIRES: aarch64-registered-target,x86-registered-target
> >    +// REQUIRES: powerpc-registered-target
> > 
> > #define SWIFTCALL __attribute__((swiftcall))
> > #define OUT __attribute__((swift_indirect_result))
> >    @@ -370,8 +369,8 @@
> > 
> > TEST(int8)
> > // CHECK-LABEL: define {{.*}} @return_int8()
> >    -// CHECK:   [[RET:%.*]] = alloca [[REC:<8 x i32>]], align 16
> >    +// CHECK:   [[RET:%.*]] = alloca [[REC:<8 x i32>]], align 32
> > // CHECK:   [[VAR:%.*]] = alloca [[REC]], align
> > // CHECK:   store
> > // CHECK:   load
> > // CHECK:   store
> >    @@ -414,8 +413,8 @@
> > 
> > TEST(int5)
> > // CHECK-LABEL: define {{.*}} @return_int5()
> >    -// CHECK:   [[RET:%.*]] = alloca [[REC:<5 x i32>]], align 16
> >    +// CHECK:   [[RET:%.*]] = alloca [[REC:<5 x i32>]], align 32
> > // CHECK:   [[VAR:%.*]] = alloca [[REC]], align
> > // CHECK:   store
> > // CHECK:   load
> > // CHECK:   store
> > 
> > Despite some duplication, the advantage of this approach over using
> > pattern matching for alignment in 64bit-swiftcall.c is that we
> > ensure
> > each platform is using the expected alignment but without
> > duplicating
> > the entirety of 64bit-swiftcall.c.
> > 
> > > Signed-off-by: Andrew Jeffery 
> > 
> > ---
> > 
> > Hello,
> > 
> > The only change in v3 is rebasing it on top upstream HEAD, fixing a
> > conflict in
> > one of the lit REQUIRES lines.
> > 
> > Ulrich, Hal, Bill: I've Cc'ed you as you were fingered by the blame
> > output. As
> > some background I sent the patch several months ago but it hasn't
> > got much
> > traction aside from a LGTM from Adrian (thanks!). I'm hoping it
> > gets a bit more
> > attention as without it we get build failures for Swift on POWER,
> > which is
> > in-turn blocking some CI efforts. 
> > 
> > Cheers,
> > 
> > Andrew
> > 
> >  lib/Basic/Targets.cpp |  11 ++
> >  lib/CodeGen/TargetInfo.cpp|  14 ++-
> >  test/CodeGen/64bit-swiftcall-extvec-agg-align16.c | 117
> > ++
> >  test/CodeGen/64bit-swiftcall-extvec-agg-align32.c | 116
> > +
> >  test/CodeGen/64bit-swiftcall.c|  93 +-
> > ---
> >  5 files changed, 258 insertions(+), 93 deletions(-)
> >  create mode 100644 test/CodeGen/64bit-swiftcall-extvec-agg-
> > align16.c
> >  create mode 100644 test/CodeGen/64bit-swiftcall-extvec-agg-
> > align32.c
> > 
> > diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp
> > index e23a93e..54b5911 100644
> > --- a/lib/Basic/Targets.cpp
> > +++ b/lib/Basic/Targets.cpp
> > @@ -1753,6 +1753,17 @@ public:
> >  }
> >  return false;
> >    }
> > +
> > +  CallingConvCheckResult checkCallingConvention(CallingConv CC)
> > const override {
> > +switch (CC) {
> > +case CC_C:
> > +case CC_Swift:
> > +return CCCR_OK;
> > +default:
> > +break;
> > +}
> > +return CCCR_Warning;
> > +  }
> >  };
> >  
> >  class DarwinPPC32TargetInfo : public
> > DarwinTargetInfo {
> > diff --git a/lib/CodeGen/TargetInfo.cpp
> > b/lib/CodeGen/TargetInfo.cpp
> > index 8d00e05..a82cd24 100644
> > --- a/lib/CodeGen/TargetInfo.cpp
> > +++ b/lib/CodeGen/TargetInfo.cpp
> > @@ -4179,7 +4179,7 @@
> > PPC32TargetCodeGenInfo::initDwarfEHRegSizeTable(CodeGen::CodeGenFun
> > ction ,
> >  
> >  namespace {
> >  /// PPC64_SVR4_ABIInfo - The 64-bit PowerPC ELF (SVR4) ABI
> > information.
> > -class PPC64_SVR4_ABIInfo : public ABIInfo {
> > +class PPC64_SVR4_ABIInfo : public SwiftABIInfo {
> >  public:
> >    enum ABIKind {
> >  ELFv1 = 0,
> > @@ -4223,7 +4223,7 @@ private:
> >  public:
> >    

[PATCH] D34489: [scan-build-py] Patch to fix "-analyzer-config" option

2017-07-18 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL308401: [scan-build-py] Patch to fix "-analyzer-config" 
option (authored by phosek).

Changed prior to commit:
  https://reviews.llvm.org/D34489?vs=103490=107214#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D34489

Files:
  cfe/trunk/tools/scan-build-py/libscanbuild/analyze.py


Index: cfe/trunk/tools/scan-build-py/libscanbuild/analyze.py
===
--- cfe/trunk/tools/scan-build-py/libscanbuild/analyze.py
+++ cfe/trunk/tools/scan-build-py/libscanbuild/analyze.py
@@ -249,7 +249,7 @@
 if args.output_format:
 result.append('-analyzer-output={0}'.format(args.output_format))
 if args.analyzer_config:
-result.append(args.analyzer_config)
+result.extend(['-analyzer-config', args.analyzer_config])
 if args.verbose >= 4:
 result.append('-analyzer-display-progress')
 if args.plugins:


Index: cfe/trunk/tools/scan-build-py/libscanbuild/analyze.py
===
--- cfe/trunk/tools/scan-build-py/libscanbuild/analyze.py
+++ cfe/trunk/tools/scan-build-py/libscanbuild/analyze.py
@@ -249,7 +249,7 @@
 if args.output_format:
 result.append('-analyzer-output={0}'.format(args.output_format))
 if args.analyzer_config:
-result.append(args.analyzer_config)
+result.extend(['-analyzer-config', args.analyzer_config])
 if args.verbose >= 4:
 result.append('-analyzer-display-progress')
 if args.plugins:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r308401 - [scan-build-py] Patch to fix "-analyzer-config" option

2017-07-18 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Tue Jul 18 17:29:41 2017
New Revision: 308401

URL: http://llvm.org/viewvc/llvm-project?rev=308401=rev
Log:
[scan-build-py] Patch to fix "-analyzer-config" option

I noticed that when I use "-analyze-config" option in scan-build-py, it
behaves differently from original perl based scan-build.

For example, command:

$ scan-build -analyzer-config ipa=basic-inlining make

Will work without any issues on perl version of scan-build. But on
scan-build-py it will throw an error message "error reading
'ipa=basic-inlining'".

After debugging, it turns out that the scan-build-py does not put
"-analyzer-config" flag in front of the analyzer config flags (in this
case is the "ipa=basic-inlining") in the final clang command line. This
patch fixes this issue.

Patch by Haowei Wu

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

Modified:
cfe/trunk/tools/scan-build-py/libscanbuild/analyze.py

Modified: cfe/trunk/tools/scan-build-py/libscanbuild/analyze.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-build-py/libscanbuild/analyze.py?rev=308401=308400=308401=diff
==
--- cfe/trunk/tools/scan-build-py/libscanbuild/analyze.py (original)
+++ cfe/trunk/tools/scan-build-py/libscanbuild/analyze.py Tue Jul 18 17:29:41 
2017
@@ -249,7 +249,7 @@ def analyzer_params(args):
 if args.output_format:
 result.append('-analyzer-output={0}'.format(args.output_format))
 if args.analyzer_config:
-result.append(args.analyzer_config)
+result.extend(['-analyzer-config', args.analyzer_config])
 if args.verbose >= 4:
 result.append('-analyzer-display-progress')
 if args.plugins:


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


[PATCH] D34724: [analyzer] Add MagentaHandleChecker for the Magenta kernel

2017-07-18 Thread Haowei Wu via Phabricator via cfe-commits
haowei updated this revision to Diff 107201.
haowei added a comment.

Thanks for reviewing this patch. I have modified the checker according NoQ's 
suggestions and refactored some long functions.

> We're trying to use this CallDescription thing for this purpose recently.

I took a look at CallDescption, but it can only be used when a CallEvent object 
is present, which is not available in evalCall callbacks. So we cannot use it 
in our checker. BTW, we have been working on a function matching based on 
annotation attributes to avoid string comparison as much as possible. But the 
patch is relatively huge so we would like to land this patch first before 
publishing the annotation attribute stuff.

> This should be fixed by allowing checkPointerEscape report non-pointer 
> escapes, or making a separate callback for non-pointer escapes. This huge 
> boilerplate shouldn't be repeated in every checker that needs it.

I agree. For example following code is not covered by the workaround I used in 
the checker:
struct A {

  mx_handle_t data,
  mx_status_t status,

};
escapeFunction(A arg1);

And it would be hard to implement a workaround in the checker to cover this 
case. I would like to help but I quite new to the Clang and Clang Static 
Analyzer. Currently I don't know where to start to fix this issue in the static 
analyzer. If you have any suggestions on how to fix it in the Clang, let me 
know.

> While this is the easiest thing to do, it halves the analyzer performance 
> every time it happens, exploding the complexity exponentially - because the 
> remaining path would be split up into two paths, which are analyzed 
> independently. So it is really really rarely a good idea to split the state 
> in the checker.

When I first worked on this checker, I actually use ProgramState to track 
return values of syscalls, which is very similar to the approach used by 
https://reviews.llvm.org/D32449. But after I read the implementation of 
StreamChecker, I noticed that it uses program state bifurcation which is more 
straightforward. So I changed my checker to use this feature as well.

After receiving your suggestion, I conducted a benchmark to compare the 
performance of my previous return value approach with current state bifurcation 
approach. It took 11m46.383s to analyze magenta kernel code base by tracking 
the return value of syscalls compare to 11m39.034s by using state bifurcation. 
So in my case, the state bifurcation is actually faster, though I am not quite 
sure about the reason.

Another reason that we would like to keep the state bifurcation approach is 
that for magenta handle acquire and release syscalls. Both handle acquire 
syscall and handle release syscall may fail, so the return value of both types 
of syscalls should be tracked and should be tracked separately. The 
PthreadLockChecker only tracked one. It would be a lot of harder to get things 
right if we use return value tracking approach when adding more syscalls 
support.

Let me know if you have further suggestions or concerns.

Thanks,
Haowei


https://reviews.llvm.org/D34724

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/MagentaHandleChecker.cpp
  test/Analysis/mxhandle.c

Index: test/Analysis/mxhandle.c
===
--- /dev/null
+++ test/Analysis/mxhandle.c
@@ -0,0 +1,217 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.magenta.MagentaHandleChecker -analyzer-store=region -verify %s
+
+typedef __typeof__(sizeof(int)) size_t;
+typedef int mx_status_t;
+typedef __typeof__(sizeof(int)) mx_handle_t;
+typedef unsigned int uint32_t;
+#define NULL ((void *)0)
+
+mx_status_t mx_channel_create(
+   uint32_t options,
+   mx_handle_t* out0,
+   mx_handle_t* out1);
+
+mx_status_t mx_handle_close(mx_handle_t handle);
+
+mx_status_t mx_channel_read(mx_handle_t handle, uint32_t options,
+void* bytes, mx_handle_t* handles,
+uint32_t num_bytes, uint32_t num_handles,
+uint32_t* actual_bytes, uint32_t* actual_handles);
+
+mx_status_t mx_channel_write(mx_handle_t handle, uint32_t options,
+ void* bytes, uint32_t num_bytes,
+ mx_handle_t* handles, uint32_t num_handles);
+
+void escapeMethod(mx_handle_t *in);
+void useHandle(mx_handle_t handle);
+
+// End of declaration
+
+void checkNoLeak01() {
+  mx_handle_t sa, sb;
+  mx_channel_create(0, , );
+  mx_handle_close(sa);
+  mx_handle_close(sb);
+}
+
+void checkNoLeak02() {
+  mx_handle_t ay[2];
+  mx_channel_create(0, [0], [1]);
+  mx_handle_close(ay[0]);
+  mx_handle_close(ay[1]);
+}
+
+void checkNoLeak03() {
+  mx_handle_t ay[2];
+  mx_channel_create(0, [0], [1]);
+  for (int i = 0; i < 2; i++) {
+mx_handle_close(ay[i]);
+  }
+}
+
+mx_handle_t checkNoLeak04() {
+  mx_handle_t sa, sb;
+  mx_channel_create(0, , );
+  

[PATCH] D35583: Debug Info: Add a file: field to DIImportedEntity

2017-07-18 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL308398: Debug Info: Add a file: field to DIImportedEntity. 
(authored by adrian).

Changed prior to commit:
  https://reviews.llvm.org/D35583?vs=107180=107211#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D35583

Files:
  llvm/trunk/include/llvm/IR/DIBuilder.h
  llvm/trunk/include/llvm/IR/DebugInfoMetadata.h
  llvm/trunk/lib/AsmParser/LLParser.cpp
  llvm/trunk/lib/Bitcode/Reader/MetadataLoader.cpp
  llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
  llvm/trunk/lib/IR/AsmWriter.cpp
  llvm/trunk/lib/IR/DIBuilder.cpp
  llvm/trunk/lib/IR/DebugInfoMetadata.cpp
  llvm/trunk/lib/IR/LLVMContextImpl.h
  llvm/trunk/test/Assembler/diimportedentity.ll
  llvm/trunk/test/Bitcode/DIGlobalVariableExpression.ll
  llvm/trunk/test/Bitcode/upgrade-importedentity.ll
  llvm/trunk/test/Bitcode/upgrade-importedentity.ll.bc
  llvm/trunk/test/DebugInfo/Generic/namespace.ll
  llvm/trunk/test/DebugInfo/X86/DIModule.ll
  llvm/trunk/test/DebugInfo/X86/DIModuleContext.ll
  llvm/trunk/test/DebugInfo/X86/fission-inline.ll
  llvm/trunk/test/DebugInfo/X86/gnu-public-names.ll
  llvm/trunk/test/DebugInfo/X86/lexical-block-file-inline.ll
  llvm/trunk/test/DebugInfo/X86/pr19307.ll
  llvm/trunk/test/Linker/pr26037.ll
  llvm/trunk/test/ThinLTO/X86/debuginfo-cu-import.ll
  llvm/trunk/unittests/IR/IRBuilderTest.cpp
  llvm/trunk/unittests/IR/MetadataTest.cpp

Index: llvm/trunk/lib/IR/LLVMContextImpl.h
===
--- llvm/trunk/lib/IR/LLVMContextImpl.h
+++ llvm/trunk/lib/IR/LLVMContextImpl.h
@@ -990,24 +990,26 @@
   unsigned Tag;
   Metadata *Scope;
   Metadata *Entity;
+  Metadata *File;
   unsigned Line;
   MDString *Name;
 
-  MDNodeKeyImpl(unsigned Tag, Metadata *Scope, Metadata *Entity, unsigned Line,
-MDString *Name)
-  : Tag(Tag), Scope(Scope), Entity(Entity), Line(Line), Name(Name) {}
+  MDNodeKeyImpl(unsigned Tag, Metadata *Scope, Metadata *Entity, Metadata *File,
+unsigned Line, MDString *Name)
+  : Tag(Tag), Scope(Scope), Entity(Entity), File(File), Line(Line),
+Name(Name) {}
   MDNodeKeyImpl(const DIImportedEntity *N)
   : Tag(N->getTag()), Scope(N->getRawScope()), Entity(N->getRawEntity()),
-Line(N->getLine()), Name(N->getRawName()) {}
+File(N->getRawFile()), Line(N->getLine()), Name(N->getRawName()) {}
 
   bool isKeyOf(const DIImportedEntity *RHS) const {
 return Tag == RHS->getTag() && Scope == RHS->getRawScope() &&
-   Entity == RHS->getRawEntity() && Line == RHS->getLine() &&
-   Name == RHS->getRawName();
+   Entity == RHS->getRawEntity() && File == RHS->getFile() &&
+   Line == RHS->getLine() && Name == RHS->getRawName();
   }
 
   unsigned getHashValue() const {
-return hash_combine(Tag, Scope, Entity, Line, Name);
+return hash_combine(Tag, Scope, Entity, File, Line, Name);
   }
 };
 
Index: llvm/trunk/lib/IR/DIBuilder.cpp
===
--- llvm/trunk/lib/IR/DIBuilder.cpp
+++ llvm/trunk/lib/IR/DIBuilder.cpp
@@ -148,45 +148,53 @@
 
 static DIImportedEntity *
 createImportedModule(LLVMContext , dwarf::Tag Tag, DIScope *Context,
- Metadata *NS, unsigned Line, StringRef Name,
+ Metadata *NS, DIFile *File, unsigned Line, StringRef Name,
  SmallVectorImpl ) {
+  if (Line)
+assert(File && "Source location has line number but no file");
   unsigned EntitiesCount = C.pImpl->DIImportedEntitys.size();
-  auto *M = DIImportedEntity::get(C, Tag, Context, DINodeRef(NS), Line, Name);
+  auto *M =
+  DIImportedEntity::get(C, Tag, Context, DINodeRef(NS), File, Line, Name);
   if (EntitiesCount < C.pImpl->DIImportedEntitys.size())
 // A new Imported Entity was just added to the context.
 // Add it to the Imported Modules list.
 AllImportedModules.emplace_back(M);
   return M;
 }
 
 DIImportedEntity *DIBuilder::createImportedModule(DIScope *Context,
-  DINamespace *NS,
+  DINamespace *NS, DIFile *File,
   unsigned Line) {
   return ::createImportedModule(VMContext, dwarf::DW_TAG_imported_module,
-Context, NS, Line, StringRef(), AllImportedModules);
+Context, NS, File, Line, StringRef(),
+AllImportedModules);
 }
 
 DIImportedEntity *DIBuilder::createImportedModule(DIScope *Context,
   DIImportedEntity *NS,
-  unsigned Line) {
+  DIFile *File, unsigned Line) {
   return ::createImportedModule(VMContext, 

r308399 - Update for LLVM IR metadata changes (DIImportedEntity now needs a DIFile).

2017-07-18 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Tue Jul 18 17:09:58 2017
New Revision: 308399

URL: http://llvm.org/viewvc/llvm-project?rev=308399=rev
Log:
Update for LLVM IR metadata changes (DIImportedEntity now needs a DIFile).


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

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

Added:
cfe/trunk/test/Modules/Inputs/DebugObjCImport.h
cfe/trunk/test/Modules/debug-info-moduleimport-in-module.m
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/test/CodeGen/debug-info-imported-entity.cpp
cfe/trunk/test/CodeGenCXX/debug-info-anon-namespace.cpp
cfe/trunk/test/CodeGenCXX/debug-info-namespace.cpp
cfe/trunk/test/Modules/DebugInfoTransitiveImport.m
cfe/trunk/test/Modules/ExtDebugInfo.cpp
cfe/trunk/test/Modules/Inputs/module.map
cfe/trunk/test/Modules/debug-info-moduleimport.m

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=308399=308398=308399=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Jul 18 17:09:58 2017
@@ -3970,10 +3970,10 @@ void CGDebugInfo::EmitUsingDirective(con
   const NamespaceDecl *NSDecl = UD.getNominatedNamespace();
   if (!NSDecl->isAnonymousNamespace() ||
   CGM.getCodeGenOpts().DebugExplicitImport) {
+auto Loc = UD.getLocation();
 DBuilder.createImportedModule(
 getCurrentContextDescriptor(cast(UD.getDeclContext())),
-getOrCreateNamespace(NSDecl),
-getLineNumber(UD.getLocation()));
+getOrCreateNamespace(NSDecl), getOrCreateFile(Loc), 
getLineNumber(Loc));
   }
 }
 
@@ -3996,10 +3996,12 @@ void CGDebugInfo::EmitUsingDecl(const Us
   if (AT->getDeducedType().isNull())
 return;
   if (llvm::DINode *Target =
-  getDeclarationOrDefinition(USD.getUnderlyingDecl()))
+  getDeclarationOrDefinition(USD.getUnderlyingDecl())) {
+auto Loc = USD.getLocation();
 DBuilder.createImportedDeclaration(
 getCurrentContextDescriptor(cast(USD.getDeclContext())), Target,
-getLineNumber(USD.getLocation()));
+getOrCreateFile(Loc), getLineNumber(Loc));
+  }
 }
 
 void CGDebugInfo::EmitImportDecl(const ImportDecl ) {
@@ -4007,10 +4009,11 @@ void CGDebugInfo::EmitImportDecl(const I
 return;
   if (Module *M = ID.getImportedModule()) {
 auto Info = ExternalASTSource::ASTSourceDescriptor(*M);
+auto Loc = ID.getLocation();
 DBuilder.createImportedDeclaration(
 getCurrentContextDescriptor(cast(ID.getDeclContext())),
-getOrCreateModuleRef(Info, DebugTypeExtRefs),
-getLineNumber(ID.getLocation()));
+getOrCreateModuleRef(Info, DebugTypeExtRefs), getOrCreateFile(Loc),
+getLineNumber(Loc));
   }
 }
 
@@ -4022,18 +4025,19 @@ CGDebugInfo::EmitNamespaceAlias(const Na
   if (VH)
 return cast(VH);
   llvm::DIImportedEntity *R;
+  auto Loc = NA.getLocation();
   if (const auto *Underlying =
   dyn_cast(NA.getAliasedNamespace()))
 // This could cache & dedup here rather than relying on metadata deduping.
 R = DBuilder.createImportedDeclaration(
 getCurrentContextDescriptor(cast(NA.getDeclContext())),
-EmitNamespaceAlias(*Underlying), getLineNumber(NA.getLocation()),
-NA.getName());
+EmitNamespaceAlias(*Underlying), getOrCreateFile(Loc),
+getLineNumber(Loc), NA.getName());
   else
 R = DBuilder.createImportedDeclaration(
 getCurrentContextDescriptor(cast(NA.getDeclContext())),
 getOrCreateNamespace(cast(NA.getAliasedNamespace())),
-getLineNumber(NA.getLocation()), NA.getName());
+getOrCreateFile(Loc), getLineNumber(Loc), NA.getName());
   VH.reset(R);
   return R;
 }

Modified: cfe/trunk/test/CodeGen/debug-info-imported-entity.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-info-imported-entity.cpp?rev=308399=308398=308399=diff
==
--- cfe/trunk/test/CodeGen/debug-info-imported-entity.cpp (original)
+++ cfe/trunk/test/CodeGen/debug-info-imported-entity.cpp Tue Jul 18 17:09:58 
2017
@@ -5,5 +5,6 @@ using std::A; using ::A;
 
 // CHECK: [[CompileUnit:![0-9]+]] = distinct !DICompileUnit({{.+}} imports: 
[[Imports:![0-9]+]]
 // CHECK: [[Imports]] = !{[[ImportedEntity:![0-9]+]]}
-// CHECK: [[ImportedEntity]] = !DIImportedEntity(tag: 
DW_TAG_imported_declaration, scope: [[CompileUnit]], entity: [[STDA:![0-9]+]], 
line: 4)
+// CHECK: [[ImportedEntity]] = !DIImportedEntity(tag: 
DW_TAG_imported_declaration, scope: [[CompileUnit]], entity: [[STDA:![0-9]+]], 
file: [[FILE:![0-9]+]], line: 4)
 // CHECK: [[STDA]] = !DICompositeType(tag: DW_TAG_class_type, name: "A",
+// CHECK: [[FILE]] = !DIFile(filename: {{.*}}debug-info-imported-entity.cpp

Modified: cfe/trunk/test/CodeGenCXX/debug-info-anon-namespace.cpp

r308397 - Debug Info: Set the MainFileName when generating -gmodules debug info for PCM.

2017-07-18 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Tue Jul 18 16:58:34 2017
New Revision: 308397

URL: http://llvm.org/viewvc/llvm-project?rev=308397=rev
Log:
Debug Info: Set the MainFileName when generating -gmodules debug info for PCM.

Previously it was uninitialized and thus always defaulted to "".
This is mostly a cosmetic change that helps making the debug info more readable.

Modified:
cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
cfe/trunk/test/Modules/ModuleDebugInfo.m

Modified: cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp?rev=308397=308396=308397=diff
==
--- cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp (original)
+++ cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp Tue Jul 18 
16:58:34 2017
@@ -152,6 +152,9 @@ public:
 CodeGenOpts.CodeModel = "default";
 CodeGenOpts.ThreadModel = "single";
 CodeGenOpts.DebugTypeExtRefs = true;
+// When building a module MainFileName is the name of the modulemap file.
+CodeGenOpts.MainFileName =
+LangOpts.CurrentModule.empty() ? MainFileName : LangOpts.CurrentModule;
 CodeGenOpts.setDebugInfo(codegenoptions::FullDebugInfo);
 CodeGenOpts.setDebuggerTuning(CI.getCodeGenOpts().getDebuggerTuning());
   }

Modified: cfe/trunk/test/Modules/ModuleDebugInfo.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/ModuleDebugInfo.m?rev=308397=308396=308397=diff
==
--- cfe/trunk/test/Modules/ModuleDebugInfo.m (original)
+++ cfe/trunk/test/Modules/ModuleDebugInfo.m Tue Jul 18 16:58:34 2017
@@ -23,8 +23,10 @@
 @import DebugObjC;
 #endif
 
-// CHECK: distinct !DICompileUnit(language: DW_LANG_ObjC
-// CHECK-SAME:isOptimized: false,
+// CHECK: distinct !DICompileUnit(language: DW_LANG_ObjC, file: 
![[FILE:[0-9]+]],
+// CHECK-SAME:isOptimized: false
+
+// CHECK: ![[FILE]] = !DIFile(filename: "{{DebugObjC|.*DebugObjC.h}}"
 
 // CHECK: !DICompositeType(tag: DW_TAG_enumeration_type,
 // CHECK-SAME: scope: ![[MODULE:[0-9]+]],


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


[PATCH] D35582: [Driver] Always use -z rodynamic for Fuchsia

2017-07-18 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL308390: [Driver] Always use -z rodynamic for Fuchsia 
(authored by phosek).

Changed prior to commit:
  https://reviews.llvm.org/D35582?vs=107185=107200#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D35582

Files:
  cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp
  cfe/trunk/test/Driver/fuchsia.c
  cfe/trunk/test/Driver/fuchsia.cpp


Index: cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp
@@ -46,6 +46,9 @@
   if (llvm::sys::path::stem(Exec).equals_lower("lld")) {
 CmdArgs.push_back("-flavor");
 CmdArgs.push_back("gnu");
+
+CmdArgs.push_back("-z");
+CmdArgs.push_back("rodynamic");
   }
 
   if (!D.SysRoot.empty())
Index: cfe/trunk/test/Driver/fuchsia.c
===
--- cfe/trunk/test/Driver/fuchsia.c
+++ cfe/trunk/test/Driver/fuchsia.c
@@ -5,6 +5,7 @@
 // CHECK: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK: "-internal-externc-isystem" "[[SYSROOT]]{{/|}}include"
 // CHECK: {{.*}}lld{{.*}}" "-flavor" "gnu"
+// CHECK: "-z" "rodynamic"
 // CHECK: "--sysroot=[[SYSROOT]]"
 // CHECK: "-pie"
 // CHECK: "--build-id"
Index: cfe/trunk/test/Driver/fuchsia.cpp
===
--- cfe/trunk/test/Driver/fuchsia.cpp
+++ cfe/trunk/test/Driver/fuchsia.cpp
@@ -7,6 +7,7 @@
 // CHECK: "-internal-isystem" 
"{{.*[/\\]}}x86_64-fuchsia{{/|}}include{{/|}}c++{{/|}}v1"
 // CHECK: "-internal-externc-isystem" "[[SYSROOT]]{{/|}}include"
 // CHECK: {{.*}}lld{{.*}}" "-flavor" "gnu"
+// CHECK: "-z" "rodynamic"
 // CHECK: "--sysroot=[[SYSROOT]]"
 // CHECK: "-pie"
 // CHECK: "--build-id"


Index: cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp
@@ -46,6 +46,9 @@
   if (llvm::sys::path::stem(Exec).equals_lower("lld")) {
 CmdArgs.push_back("-flavor");
 CmdArgs.push_back("gnu");
+
+CmdArgs.push_back("-z");
+CmdArgs.push_back("rodynamic");
   }
 
   if (!D.SysRoot.empty())
Index: cfe/trunk/test/Driver/fuchsia.c
===
--- cfe/trunk/test/Driver/fuchsia.c
+++ cfe/trunk/test/Driver/fuchsia.c
@@ -5,6 +5,7 @@
 // CHECK: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK: "-internal-externc-isystem" "[[SYSROOT]]{{/|}}include"
 // CHECK: {{.*}}lld{{.*}}" "-flavor" "gnu"
+// CHECK: "-z" "rodynamic"
 // CHECK: "--sysroot=[[SYSROOT]]"
 // CHECK: "-pie"
 // CHECK: "--build-id"
Index: cfe/trunk/test/Driver/fuchsia.cpp
===
--- cfe/trunk/test/Driver/fuchsia.cpp
+++ cfe/trunk/test/Driver/fuchsia.cpp
@@ -7,6 +7,7 @@
 // CHECK: "-internal-isystem" "{{.*[/\\]}}x86_64-fuchsia{{/|}}include{{/|}}c++{{/|}}v1"
 // CHECK: "-internal-externc-isystem" "[[SYSROOT]]{{/|}}include"
 // CHECK: {{.*}}lld{{.*}}" "-flavor" "gnu"
+// CHECK: "-z" "rodynamic"
 // CHECK: "--sysroot=[[SYSROOT]]"
 // CHECK: "-pie"
 // CHECK: "--build-id"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r308390 - [Driver] Always use -z rodynamic for Fuchsia

2017-07-18 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Tue Jul 18 16:23:16 2017
New Revision: 308390

URL: http://llvm.org/viewvc/llvm-project?rev=308390=rev
Log:
[Driver] Always use -z rodynamic for Fuchsia

Fuchsia uses read-only .dynamic section.

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp
cfe/trunk/test/Driver/fuchsia.c
cfe/trunk/test/Driver/fuchsia.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp?rev=308390=308389=308390=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp Tue Jul 18 16:23:16 2017
@@ -46,6 +46,9 @@ void fuchsia::Linker::ConstructJob(Compi
   if (llvm::sys::path::stem(Exec).equals_lower("lld")) {
 CmdArgs.push_back("-flavor");
 CmdArgs.push_back("gnu");
+
+CmdArgs.push_back("-z");
+CmdArgs.push_back("rodynamic");
   }
 
   if (!D.SysRoot.empty())

Modified: cfe/trunk/test/Driver/fuchsia.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fuchsia.c?rev=308390=308389=308390=diff
==
--- cfe/trunk/test/Driver/fuchsia.c (original)
+++ cfe/trunk/test/Driver/fuchsia.c Tue Jul 18 16:23:16 2017
@@ -5,6 +5,7 @@
 // CHECK: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK: "-internal-externc-isystem" "[[SYSROOT]]{{/|}}include"
 // CHECK: {{.*}}lld{{.*}}" "-flavor" "gnu"
+// CHECK: "-z" "rodynamic"
 // CHECK: "--sysroot=[[SYSROOT]]"
 // CHECK: "-pie"
 // CHECK: "--build-id"

Modified: cfe/trunk/test/Driver/fuchsia.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fuchsia.cpp?rev=308390=308389=308390=diff
==
--- cfe/trunk/test/Driver/fuchsia.cpp (original)
+++ cfe/trunk/test/Driver/fuchsia.cpp Tue Jul 18 16:23:16 2017
@@ -7,6 +7,7 @@
 // CHECK: "-internal-isystem" 
"{{.*[/\\]}}x86_64-fuchsia{{/|}}include{{/|}}c++{{/|}}v1"
 // CHECK: "-internal-externc-isystem" "[[SYSROOT]]{{/|}}include"
 // CHECK: {{.*}}lld{{.*}}" "-flavor" "gnu"
+// CHECK: "-z" "rodynamic"
 // CHECK: "--sysroot=[[SYSROOT]]"
 // CHECK: "-pie"
 // CHECK: "--build-id"


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


[PATCH] D35479: [CodeGen][mips] Support `long_call/far/near` attributes

2017-07-18 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

One minor revision, but otherwise looks great, thank you.




Comment at: lib/CodeGen/CodeGenModule.cpp:1166
+if (!IsForDefinition)
+  getTargetCodeGenInfo().setTargetAttributes(FD, F, *this);
+  }

I think you should probably pass IsForDefinition to setTargetAttributes.  
Targets may want to only set certain attributes on function definitions.


Repository:
  rL LLVM

https://reviews.llvm.org/D35479



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


[PATCH] D35583: Debug Info: Add a file: field to DIImportedEntity

2017-07-18 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added inline comments.



Comment at: lib/Bitcode/Reader/MetadataLoader.cpp:1684
+ HasFile ? getMDOrNull(Record[6]) : nullptr,
+ HasFile ? Record[4] : 0, getMDString(Record[5]))),
 NextMetadataNo);

probinson wrote:
> That's a nice touch.
That was the best "upgrade" I could come up with for reliably dealing with the 
old format. There is an assertion in DIBuilder that discourages creating new 
nodes with a location with a line but no file. We could upgrade that to a 
verifier check if we want to.


https://reviews.llvm.org/D35583



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


[PATCH] D35038: [libunwind] Add a test harness

2017-07-18 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

> Checking out libcxx should not be a requirement since libunwind should be 
> usable independently on libcxx.

Nope, Sorry. As jroelofs said the code duplication is not worth it. 
Unfortunately you'll need the libc++ sources, and I also don't think that's a 
bug.


https://reviews.llvm.org/D35038



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


[PATCH] D35583: Debug Info: Add a file: field to DIImportedEntity

2017-07-18 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

Sweet.  I don't have the chops to understand the Objective-C test but otherwise 
LGTM.




Comment at: lib/Bitcode/Reader/MetadataLoader.cpp:1684
+ HasFile ? getMDOrNull(Record[6]) : nullptr,
+ HasFile ? Record[4] : 0, getMDString(Record[5]))),
 NextMetadataNo);

That's a nice touch.


https://reviews.llvm.org/D35583



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


[PATCH] D35479: [CodeGen][mips] Support `long_call/far/near` attributes

2017-07-18 Thread Simon Atanasyan via Phabricator via cfe-commits
atanasyan updated this revision to Diff 107193.
atanasyan added a comment.

Addressed review comment:

- Split MipsLongCall into a couple of attributes MipsLongCall and MipsShortCall.
- Change the documentation wording.
- Keep the attributes handling in the setTargetAttributes.
- Show error in case of combining incompatible attributes.


Repository:
  rL LLVM

https://reviews.llvm.org/D35479

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/CodeGen/TargetInfo.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGen/long-call-attr.c
  test/Misc/pragma-attribute-supported-attributes-list.test
  test/Sema/attr-long-call.c

Index: test/Sema/attr-long-call.c
===
--- /dev/null
+++ test/Sema/attr-long-call.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -triple mips-linux-gnu -fsyntax-only -verify %s
+
+__attribute__((long_call(0))) void foo1();  // expected-error {{'long_call' attribute takes no arguments}}
+__attribute__((far(0))) void foo2();  // expected-error {{'far' attribute takes no arguments}}
+__attribute__((near(0))) void foo3();  // expected-error {{'near' attribute takes no arguments}}
+
+__attribute((long_call)) int a; // expected-warning {{attribute only applies to functions}}
+__attribute((far)) int a; // expected-warning {{attribute only applies to functions}}
+__attribute((near)) int a; // expected-warning {{attribute only applies to functions}}
+
+__attribute((long_call)) void foo4();
+__attribute((far)) void foo5();
+__attribute((near)) void foo6();
+
+__attribute((long_call, far)) void foo7();
+
+__attribute((far, near)) void foo8(); // expected-error {{'far' and 'near' attributes are not compatible}} \
+  // expected-note {{conflicting attribute is here}}
Index: test/Misc/pragma-attribute-supported-attributes-list.test
===
--- test/Misc/pragma-attribute-supported-attributes-list.test
+++ test/Misc/pragma-attribute-supported-attributes-list.test
@@ -2,7 +2,7 @@
 
 // The number of supported attributes should never go down!
 
-// CHECK: #pragma clang attribute supports 62 attributes:
+// CHECK: #pragma clang attribute supports 64 attributes:
 // CHECK-NEXT: AMDGPUFlatWorkGroupSize (SubjectMatchRule_function)
 // CHECK-NEXT: AMDGPUNumSGPR (SubjectMatchRule_function)
 // CHECK-NEXT: AMDGPUNumVGPR (SubjectMatchRule_function)
@@ -31,6 +31,8 @@
 // CHECK-NEXT: InternalLinkage (SubjectMatchRule_variable, SubjectMatchRule_function, SubjectMatchRule_record)
 // CHECK-NEXT: LTOVisibilityPublic (SubjectMatchRule_record)
 // CHECK-NEXT: MicroMips (SubjectMatchRule_function)
+// CHECK-NEXT: MipsLongCall (SubjectMatchRule_function)
+// CHECK-NEXT: MipsShortCall (SubjectMatchRule_function)
 // CHECK-NEXT: NoDebug (SubjectMatchRule_hasType_functionType, SubjectMatchRule_objc_method, SubjectMatchRule_variable_not_is_parameter)
 // CHECK-NEXT: NoDuplicate (SubjectMatchRule_function)
 // CHECK-NEXT: NoMicroMips (SubjectMatchRule_function)
Index: test/CodeGen/long-call-attr.c
===
--- /dev/null
+++ test/CodeGen/long-call-attr.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple mips-linux-gnu -emit-llvm  -o  - %s | FileCheck %s
+
+void __attribute__((long_call)) foo1 (void);
+
+void __attribute__((far)) foo2 (void) {}
+
+// CHECK: define void @foo2() [[FAR:#[0-9]+]]
+
+void __attribute__((near)) foo3 (void) { foo1(); }
+
+// CHECK: define void @foo3() [[NEAR:#[0-9]+]]
+
+// CHECK: declare void @foo1() [[LONGDECL:#[0-9]+]]
+
+// CHECK: attributes [[FAR]] = { {{.*}} "long-call" {{.*}} }
+// CHECK: attributes [[NEAR]] = { {{.*}} "short-call" {{.*}} }
+// CHECK: attributes [[LONGDECL]] = { {{.*}} "long-call" {{.*}} }
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -5965,6 +5965,14 @@
   case AttributeList::AT_NoMicroMips:
 handleSimpleAttribute(S, D, Attr);
 break;
+  case AttributeList::AT_MipsLongCall:
+handleSimpleAttributeWithExclusions(
+S, D, Attr);
+break;
+  case AttributeList::AT_MipsShortCall:
+handleSimpleAttributeWithExclusions(
+S, D, Attr);
+break;
   case AttributeList::AT_AMDGPUFlatWorkGroupSize:
 handleAMDGPUFlatWorkGroupSizeAttr(S, D, Attr);
 break;
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -6619,6 +6619,11 @@
 else if (FD->hasAttr())
   Fn->addFnAttr("nomicromips");
 
+if (FD->hasAttr())
+  Fn->addFnAttr("long-call");
+else if (FD->hasAttr())
+  Fn->addFnAttr("short-call");
+
 const MipsInterruptAttr *Attr = FD->getAttr();

[PATCH] D35038: [libunwind] Add a test harness

2017-07-18 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs added inline comments.



Comment at: test/lit.cfg:36
+else:
+lit_config.fatal('Could not find libcxx test directory for test imports'
+ ' in: %s' % libcxx_test_src_root)

manojgupta wrote:
> jroelofs wrote:
> > manojgupta wrote:
> > > I do not have libcxx checked out since I am want to use only compiler-rt 
> > > + libunwind to replace libgcc_s. This libcxx dependency  breaks this 
> > > testing.
> > This only requires that you check it out, not that you build it. Note that 
> > libcxxabi has the same constraint.
> Checking out libcxx should not be a requirement since libunwind should be 
> usable independently on libcxx.
> Not sure if it can be compared to libcxxabi, since most people working on 
> libcxx/libcxxabi will checkout both libcxx and libcxxabi.
The code duplication required to give you what you want is not worth it. When 
the monorepo happens, you won't have a choice but to check both out... if this 
was a bug report, I'd close it "WONTFIX".


https://reviews.llvm.org/D35038



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


[PATCH] D35577: Add -flookup-tables and -fno-lookup-tables flags

2017-07-18 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg added inline comments.



Comment at: test/CodeGen/nouselookuptable.c:1
+// RUN: %clang_cc1 -S -fno-lookup-tables %s -emit-llvm -o - | FileCheck %s
+

Check positive flag and the default case as well.



Comment at: test/CodeGen/nouselookuptable.c:6
+
+int main() {
+  return 0;

Just use f(void) or so. main is special enough, so avoiding it in test cases is 
often a good idea.


https://reviews.llvm.org/D35577



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


[PATCH] D35450: [analyzer] Support generating and reasoning over more symbolic constraint types

2017-07-18 Thread Dominic Chen via Phabricator via cfe-commits
ddcc updated this revision to Diff 107190.
ddcc added a comment.

Minor style fix


https://reviews.llvm.org/D35450

Files:
  include/clang/AST/Expr.h
  include/clang/Config/config.h.cmake
  include/clang/StaticAnalyzer/Checkers/SValExplainer.h
  include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
  lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  lib/StaticAnalyzer/Core/RangedConstraintManager.cpp
  lib/StaticAnalyzer/Core/SValBuilder.cpp
  lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
  test/Analysis/analyzer_test.py
  test/Analysis/bitwise-ops.c
  test/Analysis/conditional-path-notes.c
  test/Analysis/explain-svals.cpp
  test/Analysis/plist-macros-z3.cpp
  test/Analysis/plist-macros.cpp
  test/Analysis/range_casts.c
  test/Analysis/std-c-library-functions.c

Index: test/Analysis/std-c-library-functions.c
===
--- test/Analysis/std-c-library-functions.c
+++ test/Analysis/std-c-library-functions.c
@@ -57,8 +57,7 @@
   size_t y = fread(buf, sizeof(int), 10, fp);
   clang_analyzer_eval(y <= 10); // expected-warning{{TRUE}}
   size_t z = fwrite(buf, sizeof(int), y, fp);
-  // FIXME: should be TRUE once symbol-symbol constraint support is improved.
-  clang_analyzer_eval(z <= y); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(z <= y); // expected-warning{{TRUE}}
 }
 
 ssize_t getline(char **, size_t *, FILE *);
Index: test/Analysis/range_casts.c
===
--- test/Analysis/range_casts.c
+++ test/Analysis/range_casts.c
@@ -67,7 +67,7 @@
 {
   unsigned index = -1;
   if (index < foo) index = foo;
-  if (index - 1 == 0) // Was not reached prior fix.
+  if (index - 1 == 0)
 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
   else
 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
@@ -87,7 +87,7 @@
 {
   unsigned index = -1;
   if (index < foo) index = foo;
-  if (index - 1L == 0L) // Was not reached prior fix.
+  if (index - 1L == 0L)
 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
   else
 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
@@ -117,7 +117,7 @@
 {
   unsigned index = -1;
   if (index < foo) index = foo;
-  if (index - 1UL == 0L) // Was not reached prior fix.
+  if (index - 1UL == 0L)
 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
   else
 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
Index: test/Analysis/plist-macros.cpp
===
--- test/Analysis/plist-macros.cpp
+++ test/Analysis/plist-macros.cpp
@@ -1,7 +1,7 @@
 // RUN: %clang_analyze_cc1 -analyzer-checker=core,unix -analyzer-eagerly-assume -verify %s
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix -analyzer-eagerly-assume -analyzer-output=plist-multi-file -analyzer-config path-diagnostics-alternate=ture %s -o %t.plist
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix -analyzer-eagerly-assume -analyzer-output=plist-multi-file -analyzer-config path-diagnostics-alternate=true %s -o %t.plist
 // RUN: FileCheck --input-file=%t.plist %s
-
+// REQUIRES: !z3
 
 typedef __typeof(sizeof(int)) size_t;
 void *malloc(size_t);
@@ -11,13 +11,13 @@
   y++;
   y--;
   mallocmemory
-  y++; 
+  y++;
   y++;
   delete x; // expected-warning {{Memory allocated by malloc() should be deallocated by free(), not 'delete'}}
 }
 
 void macroIsFirstInFunction(int y) {
-  mallocmemory 
+  mallocmemory
   y++; // expected-warning {{Potential leak of memory pointed to by 'x'}}
 }
 
@@ -39,7 +39,7 @@
   return *p; // expected-warning {{Dereference of null pointer}}
 }
 
-#define macroWithArg(mp) mp==0 
+#define macroWithArg(mp) mp==0
 int macroWithArgInExpression(int *p, int y) {;
   y++;
   if (macroWithArg(p))
@@ -85,6 +85,7 @@
 void test2(int *p) {
   CALL_FN(p);
 }
+
 // CHECK:  diagnostics
 // CHECK-NEXT:  
 // CHECK-NEXT:   
@@ -636,6 +637,69 @@
 // CHECK-NEXT: end
 // CHECK-NEXT:  
 // CHECK-NEXT:   
+// CHECK-NEXT:line36
+// CHECK-NEXT:col7
+// CHECK-NEXT:file0
+// CHECK-NEXT:   
+// CHECK-NEXT:   
+// CHECK-NEXT:line36
+// CHECK-NEXT:col7
+// CHECK-NEXT:file0
+// CHECK-NEXT:   
+// CHECK-NEXT:  
+// CHECK-NEXT:
+// CHECK-NEXT:   
+// CHECK-NEXT: 
+// CHECK-NEXT: 
+// CHECK-NEXT:  kindevent
+// CHECK-NEXT:  location
+// CHECK-NEXT:  
+// CHECK-NEXT:   line36
+// CHECK-NEXT:   col7
+// CHECK-NEXT:   file0
+// CHECK-NEXT:  
+// CHECK-NEXT:  ranges
+// CHECK-NEXT:  
+// CHECK-NEXT:
+// CHECK-NEXT: 
+// CHECK-NEXT:  line36
+// CHECK-NEXT:  col7
+// CHECK-NEXT:  file0
+// CHECK-NEXT: 
+// CHECK-NEXT: 
+// CHECK-NEXT:  line36
+// 

[PATCH] D35038: [libunwind] Add a test harness

2017-07-18 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added inline comments.



Comment at: test/lit.cfg:36
+else:
+lit_config.fatal('Could not find libcxx test directory for test imports'
+ ' in: %s' % libcxx_test_src_root)

jroelofs wrote:
> manojgupta wrote:
> > I do not have libcxx checked out since I am want to use only compiler-rt + 
> > libunwind to replace libgcc_s. This libcxx dependency  breaks this testing.
> This only requires that you check it out, not that you build it. Note that 
> libcxxabi has the same constraint.
Checking out libcxx should not be a requirement since libunwind should be 
usable independently on libcxx.
Not sure if it can be compared to libcxxabi, since most people working on 
libcxx/libcxxabi will checkout both libcxx and libcxxabi.


https://reviews.llvm.org/D35038



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


[PATCH] D35582: [Driver] Always use -z rodynamic for Fuchsia

2017-07-18 Thread Roland McGrath via Phabricator via cfe-commits
mcgrathr accepted this revision.
mcgrathr added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rL LLVM

https://reviews.llvm.org/D35582



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


[PATCH] D35578: Add -fswitch-tables and -fno-switch-tables flags

2017-07-18 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added a comment.

If the goal is fine-grained control over the heuristics for compiling switch 
statements, perhaps one should enumerate all the possible ways to lower switch 
statements --- jump-tables, lookup-tables, if-trees, if-chains, (more?) --- and 
add a separate flag for each of them.
...Although I'm not sure what purpose there'd really be in saying "This switch 
statement *must* be compiled into an if-else tree" or "this one *must* be a 
lookup table"; couldn't that end up being a pessimization one day, as the 
optimizer gets smarter?

Either way, it sounds like "-fno-switch-tables" is just a synonym for the 
(soon-to-be-)existing options "-fno-jump-tables -fno-lookup-tables" and 
therefore doesn't need to exist as a separate option.

Question: Is the intention really specifically about switch heuristics? Or are 
you trying to prevent the compiler from embedding data into the text section 
and/or taking computed jumps? Because Clang *can* generate a lookup table in 
.rodata even if the input code contains no "switch" constructs --- e.g. a long 
enough chain of "if"s will do the trick. https://godbolt.org/g/ZQqkaB


https://reviews.llvm.org/D35578



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


[PATCH] D35038: [libunwind] Add a test harness

2017-07-18 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs added inline comments.



Comment at: test/lit.cfg:36
+else:
+lit_config.fatal('Could not find libcxx test directory for test imports'
+ ' in: %s' % libcxx_test_src_root)

manojgupta wrote:
> I do not have libcxx checked out since I am want to use only compiler-rt + 
> libunwind to replace libgcc_s. This libcxx dependency  breaks this testing.
This only requires that you check it out, not that you build it. Note that 
libcxxabi has the same constraint.


https://reviews.llvm.org/D35038



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


[PATCH] D35548: [mips] Teach the driver to accept -m(no-)gpopt.

2017-07-18 Thread Simon Atanasyan via Phabricator via cfe-commits
atanasyan accepted this revision.
atanasyan added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D35548



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


[PATCH] D35582: [Driver] Always use -z rodynamic for Fuchsia

2017-07-18 Thread Petr Hosek via Phabricator via cfe-commits
phosek updated this revision to Diff 107185.
phosek marked an inline comment as done.

Repository:
  rL LLVM

https://reviews.llvm.org/D35582

Files:
  lib/Driver/ToolChains/Fuchsia.cpp
  test/Driver/fuchsia.c
  test/Driver/fuchsia.cpp


Index: test/Driver/fuchsia.cpp
===
--- test/Driver/fuchsia.cpp
+++ test/Driver/fuchsia.cpp
@@ -7,6 +7,7 @@
 // CHECK: "-internal-isystem" 
"{{.*[/\\]}}x86_64-fuchsia{{/|}}include{{/|}}c++{{/|}}v1"
 // CHECK: "-internal-externc-isystem" "[[SYSROOT]]{{/|}}include"
 // CHECK: {{.*}}lld{{.*}}" "-flavor" "gnu"
+// CHECK: "-z" "rodynamic"
 // CHECK: "--sysroot=[[SYSROOT]]"
 // CHECK: "-pie"
 // CHECK: "--build-id"
Index: test/Driver/fuchsia.c
===
--- test/Driver/fuchsia.c
+++ test/Driver/fuchsia.c
@@ -5,6 +5,7 @@
 // CHECK: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK: "-internal-externc-isystem" "[[SYSROOT]]{{/|}}include"
 // CHECK: {{.*}}lld{{.*}}" "-flavor" "gnu"
+// CHECK: "-z" "rodynamic"
 // CHECK: "--sysroot=[[SYSROOT]]"
 // CHECK: "-pie"
 // CHECK: "--build-id"
Index: lib/Driver/ToolChains/Fuchsia.cpp
===
--- lib/Driver/ToolChains/Fuchsia.cpp
+++ lib/Driver/ToolChains/Fuchsia.cpp
@@ -46,6 +46,9 @@
   if (llvm::sys::path::stem(Exec).equals_lower("lld")) {
 CmdArgs.push_back("-flavor");
 CmdArgs.push_back("gnu");
+
+CmdArgs.push_back("-z");
+CmdArgs.push_back("rodynamic");
   }
 
   if (!D.SysRoot.empty())


Index: test/Driver/fuchsia.cpp
===
--- test/Driver/fuchsia.cpp
+++ test/Driver/fuchsia.cpp
@@ -7,6 +7,7 @@
 // CHECK: "-internal-isystem" "{{.*[/\\]}}x86_64-fuchsia{{/|}}include{{/|}}c++{{/|}}v1"
 // CHECK: "-internal-externc-isystem" "[[SYSROOT]]{{/|}}include"
 // CHECK: {{.*}}lld{{.*}}" "-flavor" "gnu"
+// CHECK: "-z" "rodynamic"
 // CHECK: "--sysroot=[[SYSROOT]]"
 // CHECK: "-pie"
 // CHECK: "--build-id"
Index: test/Driver/fuchsia.c
===
--- test/Driver/fuchsia.c
+++ test/Driver/fuchsia.c
@@ -5,6 +5,7 @@
 // CHECK: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK: "-internal-externc-isystem" "[[SYSROOT]]{{/|}}include"
 // CHECK: {{.*}}lld{{.*}}" "-flavor" "gnu"
+// CHECK: "-z" "rodynamic"
 // CHECK: "--sysroot=[[SYSROOT]]"
 // CHECK: "-pie"
 // CHECK: "--build-id"
Index: lib/Driver/ToolChains/Fuchsia.cpp
===
--- lib/Driver/ToolChains/Fuchsia.cpp
+++ lib/Driver/ToolChains/Fuchsia.cpp
@@ -46,6 +46,9 @@
   if (llvm::sys::path::stem(Exec).equals_lower("lld")) {
 CmdArgs.push_back("-flavor");
 CmdArgs.push_back("gnu");
+
+CmdArgs.push_back("-z");
+CmdArgs.push_back("rodynamic");
   }
 
   if (!D.SysRoot.empty())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D35038: [libunwind] Add a test harness

2017-07-18 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added inline comments.



Comment at: test/lit.cfg:36
+else:
+lit_config.fatal('Could not find libcxx test directory for test imports'
+ ' in: %s' % libcxx_test_src_root)

I do not have libcxx checked out since I am want to use only compiler-rt + 
libunwind to replace libgcc_s. This libcxx dependency  breaks this testing.


https://reviews.llvm.org/D35038



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


[PATCH] D35582: [Driver] Always use -z rodynamic for Fuchsia

2017-07-18 Thread Roland McGrath via Phabricator via cfe-commits
mcgrathr requested changes to this revision.
mcgrathr added a comment.
This revision now requires changes to proceed.

Looks almost right.  Might be overkill to add a test case that -z rodynamic is 
omitted with -fuse-ld=gold or something.




Comment at: lib/Driver/ToolChains/Fuchsia.cpp:51
 
+  CmdArgs.push_back("-z");
+  CmdArgs.push_back("rodynamic");

Should be inside the lld conditional, since only lld groks -z rodynamic.


Repository:
  rL LLVM

https://reviews.llvm.org/D35582



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


[libunwind] r308380 - [CMake] Set library dir to be LLVM's intermediate output dir

2017-07-18 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Tue Jul 18 14:30:18 2017
New Revision: 308380

URL: http://llvm.org/viewvc/llvm-project?rev=308380=rev
Log:
[CMake] Set library dir to be LLVM's intermediate output dir

This matches the behavior of libc++abi and libc++ and ensures that
we get a working toolchain when building libunwind as part of LLVM.

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

Modified:
libunwind/trunk/CMakeLists.txt

Modified: libunwind/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/CMakeLists.txt?rev=308380=308379=308380=diff
==
--- libunwind/trunk/CMakeLists.txt (original)
+++ libunwind/trunk/CMakeLists.txt Tue Jul 18 14:30:18 2017
@@ -162,7 +162,15 @@ set(CMAKE_MODULE_PATH
 set(LIBUNWIND_COMPILER${CMAKE_CXX_COMPILER})
 set(LIBUNWIND_SOURCE_DIR  ${CMAKE_CURRENT_SOURCE_DIR})
 set(LIBUNWIND_BINARY_DIR  ${CMAKE_CURRENT_BINARY_DIR})
-set(LIBUNWIND_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX})
+if (LLVM_LIBRARY_OUTPUT_INTDIR)
+  set(LIBUNWIND_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR})
+else()
+  set(LIBUNWIND_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX})
+endif()
+
+set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBUNWIND_LIBRARY_DIR})
+set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIBUNWIND_LIBRARY_DIR})
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LIBUNWIND_LIBRARY_DIR})
 
 set(LIBUNWIND_INSTALL_PREFIX "" CACHE STRING
 "Define libunwind destination prefix.")


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


[PATCH] D35572: Add isValidCPUName and isValidFeature to TargetInfo

2017-07-18 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 107183.
erichkeane added a comment.

Fixed a rebase issue, didn't do anything in CGBuiltin yet.


https://reviews.llvm.org/D35572

Files:
  include/clang/Basic/TargetInfo.h
  lib/Basic/Targets.cpp

Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -963,8 +963,8 @@
   //  401, 403, 405, 405fp, 440fp, 464, 464fp, 476, 476fp, 505, 740, 801,
   //  821, 823, 8540, 8548, e300c2, e300c3, e500mc64, e6500, 860, cell,
   //  titan, rs64.
-  bool setCPU(const std::string ) override {
-bool CPUKnown = llvm::StringSwitch(Name)
+  bool isValidCPUName(StringRef Name) const override {
+return llvm::StringSwitch(Name)
   .Case("generic", true)
   .Case("440", true)
   .Case("450", true)
@@ -1014,10 +1014,12 @@
   .Case("powerpc64le", true)
   .Case("ppc64le", true)
   .Default(false);
+  }
 
+  bool setCPU(const std::string ) override {
+bool CPUKnown = isValidCPUName(Name);
 if (CPUKnown)
   CPU = Name;
-
 return CPUKnown;
   }
 
@@ -2006,6 +2008,9 @@
 // FIXME: implement
 return TargetInfo::CharPtrBuiltinVaList;
   }
+  bool isValidCPUName(StringRef Name) const override {
+return StringToCudaArch(Name) != CudaArch::UNKNOWN;
+  }
   bool setCPU(const std::string ) override {
 GPU = StringToCudaArch(Name);
 return GPU != CudaArch::UNKNOWN;
@@ -2367,6 +2372,13 @@
   .Default(GK_NONE);
   }
 
+  bool isValidCPUName(StringRef Name) const override {
+if (getTriple().getArch() == llvm::Triple::amdgcn)
+  return GK_NONE !=  parseAMDGCNName(Name);
+else
+  return GK_NONE !=  parseR600Name(Name);
+  }
+
   bool setCPU(const std::string ) override {
 if (getTriple().getArch() == llvm::Triple::amdgcn)
   GPU = parseAMDGCNName(Name);
@@ -2873,6 +2885,87 @@
 //@}
   } CPU = CK_Generic;
 
+  bool checkCPUKind(CPUKind Kind) const {
+// Perform any per-CPU checks necessary to determine if this CPU is
+// acceptable.
+// FIXME: This results in terrible diagnostics. Clang just says the CPU is
+// invalid without explaining *why*.
+switch (Kind) {
+case CK_Generic:
+  // No processor selected!
+  return false;
+
+case CK_i386:
+case CK_i486:
+case CK_WinChipC6:
+case CK_WinChip2:
+case CK_C3:
+case CK_i586:
+case CK_Pentium:
+case CK_PentiumMMX:
+case CK_i686:
+case CK_PentiumPro:
+case CK_Pentium2:
+case CK_Pentium3:
+case CK_Pentium3M:
+case CK_PentiumM:
+case CK_Yonah:
+case CK_C3_2:
+case CK_Pentium4:
+case CK_Pentium4M:
+case CK_Lakemont:
+case CK_Prescott:
+case CK_K6:
+case CK_K6_2:
+case CK_K6_3:
+case CK_Athlon:
+case CK_AthlonThunderbird:
+case CK_Athlon4:
+case CK_AthlonXP:
+case CK_AthlonMP:
+case CK_Geode:
+  // Only accept certain architectures when compiling in 32-bit mode.
+  if (getTriple().getArch() != llvm::Triple::x86)
+return false;
+
+  // Fallthrough
+case CK_Nocona:
+case CK_Core2:
+case CK_Penryn:
+case CK_Bonnell:
+case CK_Silvermont:
+case CK_Goldmont:
+case CK_Nehalem:
+case CK_Westmere:
+case CK_SandyBridge:
+case CK_IvyBridge:
+case CK_Haswell:
+case CK_Broadwell:
+case CK_SkylakeClient:
+case CK_SkylakeServer:
+case CK_Cannonlake:
+case CK_KNL:
+case CK_Athlon64:
+case CK_Athlon64SSE3:
+case CK_AthlonFX:
+case CK_K8:
+case CK_K8SSE3:
+case CK_Opteron:
+case CK_OpteronSSE3:
+case CK_AMDFAM10:
+case CK_BTVER1:
+case CK_BTVER2:
+case CK_BDVER1:
+case CK_BDVER2:
+case CK_BDVER3:
+case CK_BDVER4:
+case CK_ZNVER1:
+case CK_x86_64:
+  return true;
+}
+llvm_unreachable("Unhandled CPU kind");
+  }
+
   CPUKind getCPUKind(StringRef CPU) const {
 return llvm::StringSwitch(CPU)
 .Case("i386", CK_i386)
@@ -3053,6 +3146,7 @@
   initFeatureMap(llvm::StringMap , DiagnosticsEngine ,
  StringRef CPU,
  const std::vector ) const override;
+  bool isValidFeatureName(StringRef Name) const override;
   bool hasFeature(StringRef Feature) const override;
   bool handleTargetFeatures(std::vector ,
 DiagnosticsEngine ) override;
@@ -3066,87 +3160,13 @@
   return "no-mmx";
 return "";
   }
-  bool setCPU(const std::string ) override {
-CPU = getCPUKind(Name);
 
-// Perform any per-CPU checks necessary to determine if this CPU is
-// acceptable.
-// FIXME: This results in terrible diagnostics. Clang just says the CPU is
-// invalid without explaining *why*.
-switch (CPU) {
-case CK_Generic:
-  // No processor selected!
-  return false;
-
-case CK_i386:
-case CK_i486:
-case CK_WinChipC6:
-case CK_WinChip2:
-case CK_C3:
-case CK_i586:
-case CK_Pentium:
-   

[PATCH] D35578: Add -fswitch-tables and -fno-switch-tables flags

2017-07-18 Thread Chad Rosier via Phabricator via cfe-commits
mcrosier added a comment.

In https://reviews.llvm.org/D35578#813548, @sgundapa wrote:

> The switch-case statements generate two kinds of tables.
>
> 1. Jump tables
> 2. Lookup tables.
>
>   While the general assumption is that switch-case statements generate jump 
> tables, the below case generates a lookup table by late simplifycfg
>
>   int foo(int x) { switch (x) { case 0: return 9; case 1: return 20; case 2: 
> return 14; case 3: return 22; case 4: return 12; default: return 19; } } 
> generates a @switch.table.foo = private unnamed_addr constant [5 x i32] [i32 
> 9, i32 20, i32 14, i32 22, i32 12] The lookup table is an array of return 
> values as opposed to an array of pointers in jump table.


IIRC, we lower switches to a combination of binaries trees, jump tables and 
some bitmagic when there are 3 or fewer cases in the subtree.  Somewhat beside 
the point, but just a bit of clarification...  ...but before lowering the 
switch, simplifycfg may come along and introduce a lookup table if the cases 
are returning a constant value.

> The "-fno-XXX-flags" disable the generation of these tables. 
>  -fno-switch-tables implies both -fno-jump-tables and -fno-lookup-tables

Okay, now I understand the differences between the flags.

What exactly is the motivation?  I'm trying to narrow down the justification 
for adding yet more flags.


https://reviews.llvm.org/D35578



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


[PATCH] D35583: Debug Info: Add a file: field to DIImportedEntity

2017-07-18 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl updated this revision to Diff 107180.
aprantl added a comment.

Forgot to git-add new clang test case input files.


https://reviews.llvm.org/D35583

Files:
  include/llvm/IR/DIBuilder.h
  include/llvm/IR/DebugInfoMetadata.h
  lib/AsmParser/LLParser.cpp
  lib/Bitcode/Reader/MetadataLoader.cpp
  lib/Bitcode/Writer/BitcodeWriter.cpp
  lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
  lib/IR/AsmWriter.cpp
  lib/IR/DIBuilder.cpp
  lib/IR/DebugInfoMetadata.cpp
  lib/IR/LLVMContextImpl.h
  test/Assembler/diimportedentity.ll
  test/Bitcode/DIGlobalVariableExpression.ll
  test/Bitcode/upgrade-importedentity.ll
  test/Bitcode/upgrade-importedentity.ll.bc
  test/DebugInfo/Generic/namespace.ll
  test/DebugInfo/X86/DIModule.ll
  test/DebugInfo/X86/DIModuleContext.ll
  test/DebugInfo/X86/fission-inline.ll
  test/DebugInfo/X86/gnu-public-names.ll
  test/DebugInfo/X86/lexical-block-file-inline.ll
  test/DebugInfo/X86/pr19307.ll
  test/Linker/pr26037.ll
  test/ThinLTO/X86/debuginfo-cu-import.ll
  tools/clang/lib/CodeGen/CGDebugInfo.cpp
  tools/clang/test/CodeGen/debug-info-imported-entity.cpp
  tools/clang/test/CodeGenCXX/debug-info-anon-namespace.cpp
  tools/clang/test/CodeGenCXX/debug-info-namespace.cpp
  tools/clang/test/Modules/DebugInfoTransitiveImport.m
  tools/clang/test/Modules/ExtDebugInfo.cpp
  tools/clang/test/Modules/Inputs/DebugObjCImport.h
  tools/clang/test/Modules/Inputs/module.map
  tools/clang/test/Modules/debug-info-moduleimport-in-module.m
  tools/clang/test/Modules/debug-info-moduleimport.m
  unittests/IR/IRBuilderTest.cpp
  unittests/IR/MetadataTest.cpp

Index: tools/clang/test/Modules/debug-info-moduleimport.m
===
--- tools/clang/test/Modules/debug-info-moduleimport.m
+++ tools/clang/test/Modules/debug-info-moduleimport.m
@@ -10,12 +10,13 @@
 // CHECK: ![[CU:.*]] = distinct !DICompileUnit
 @import DebugObjC;
 // CHECK: !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: ![[CU]],
-// CHECK-SAME:  entity: ![[MODULE:.*]], line: [[@LINE-2]])
+// CHECK-SAME:  entity: ![[MODULE:.*]], file: ![[F:[0-9]+]],
+// CHECK-SAME:  line: [[@LINE-3]])
 // CHECK: ![[MODULE]] = !DIModule(scope: null, name: "DebugObjC",
 // CHECK-SAME:  configMacros: "\22-DGREETING=Hello World\22 \22-UNDEBUG\22",
 // CHECK-SAME:  includePath: "{{.*}}test{{.*}}Modules{{.*}}Inputs",
 // CHECK-SAME:  isysroot: "/tmp/..")
-
+// CHECK: ![[F]] = !DIFile(filename: {{.*}}debug-info-moduleimport.m
 
 // RUN: %clang_cc1 -debug-info-kind=limited -fmodules -fimplicit-module-maps -fmodules-cache-path=%t \
 // RUN:   %s -I %S/Inputs -isysroot /tmp/.. -I %t -emit-llvm -o - \
Index: tools/clang/test/Modules/debug-info-moduleimport-in-module.m
===
--- /dev/null
+++ tools/clang/test/Modules/debug-info-moduleimport-in-module.m
@@ -0,0 +1,21 @@
+// Test that an @import inside a module is not represented in the debug info.
+
+// REQUIRES: asserts
+
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -x objective-c -fmodules -fmodule-format=obj \
+// RUN:   -fimplicit-module-maps -fmodules-cache-path=%t %s \
+// RUN:   -debugger-tuning=lldb -I %S/Inputs -emit-llvm -o %t.ll \
+// RUN:   -mllvm -debug-only=pchcontainer &>%t-mod.ll
+// RUN: cat %t-mod.ll | FileCheck %s
+
+@import DebugObjCImport.SubModule;
+
+// CHECK: distinct !DICompileUnit(language: DW_LANG_ObjC
+// CHECK: DW_TAG_structure_type, name: "DebugObjCImport"
+// CHECK: ![[HEADER:.*]] = !DIFile(filename: {{.*}}DebugObjCImport.h"
+// CHECK: ![[SUBMOD:.*]] = !DIModule({{.*}}name: "SubModule"
+// CHECK: !DIImportedEntity(tag: DW_TAG_imported_declaration,
+// CHECK-SAME:  scope: ![[SUBMOD]], entity: ![[EMPTY:[0-9]+]],
+// CHECK-SAME:  file: ![[HEADER]], line: 1)
+// CHECK: ![[EMPTY]] = !DIModule(scope: null, name: "Empty"
Index: tools/clang/test/Modules/Inputs/module.map
===
--- tools/clang/test/Modules/Inputs/module.map
+++ tools/clang/test/Modules/Inputs/module.map
@@ -347,6 +347,12 @@
   header "DebugObjC.h"
 }
 
+module DebugObjCImport {
+  module SubModule {
+header "DebugObjCImport.h"
+  }
+}
+
 module ImportNameInDir {
   header "ImportNameInDir.h"
   export *
Index: tools/clang/test/Modules/Inputs/DebugObjCImport.h
===
--- /dev/null
+++ tools/clang/test/Modules/Inputs/DebugObjCImport.h
@@ -0,0 +1,2 @@
+@import Empty;
+struct DebugObjCImport {};
Index: tools/clang/test/Modules/ExtDebugInfo.cpp
===
--- tools/clang/test/Modules/ExtDebugInfo.cpp
+++ tools/clang/test/Modules/ExtDebugInfo.cpp
@@ -71,6 +71,8 @@
   anon.i = GlobalStruct.i = GlobalUnion.i = GlobalEnum;
 }
 
+// CHECK: ![[CPP:.*]] = !DIFile(filename: {{.*}}ExtDebugInfo.cpp"
+
 // CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "Enum",
 // CHECK-SAME: 

[PATCH] D35583: Debug Info: Add a file: field to DIImportedEntity

2017-07-18 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added a comment.

Note that this review contains also the corresponding clang changes in the 
tools/ directory.


Repository:
  rL LLVM

https://reviews.llvm.org/D35583



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


[PATCH] D35583: Debug Info: Add a file: field to DIImportedEntity

2017-07-18 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl created this revision.
Herald added subscribers: eraman, mehdi_amini.

DIImportedEntity has a line number, but not a file field. To determine the 
decl_line/decl_file we combine the line number from the DIImportedEntity with 
the file from the DIImportedEntity's scope. This does not work correctly when 
the parent scope is a DINamespace or a DIModule, both of which do not have a 
source file.

This patch adds a file field to DIImportedEntity to unambiguously identify the 
source location of the using/import declaration.
Most testcase updates are mechanical, the interesting one is the removal of the 
FIXME in test/DebugInfo/Generic/namespace.ll.

This fixes PR33822. See https://bugs.llvm.org/show_bug.cgi?id=33822 for more 
context.


Repository:
  rL LLVM

https://reviews.llvm.org/D35583

Files:
  include/llvm/IR/DIBuilder.h
  include/llvm/IR/DebugInfoMetadata.h
  lib/AsmParser/LLParser.cpp
  lib/Bitcode/Reader/MetadataLoader.cpp
  lib/Bitcode/Writer/BitcodeWriter.cpp
  lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
  lib/IR/AsmWriter.cpp
  lib/IR/DIBuilder.cpp
  lib/IR/DebugInfoMetadata.cpp
  lib/IR/LLVMContextImpl.h
  test/Assembler/diimportedentity.ll
  test/Bitcode/DIGlobalVariableExpression.ll
  test/Bitcode/upgrade-importedentity.ll
  test/Bitcode/upgrade-importedentity.ll.bc
  test/DebugInfo/Generic/namespace.ll
  test/DebugInfo/X86/DIModule.ll
  test/DebugInfo/X86/DIModuleContext.ll
  test/DebugInfo/X86/fission-inline.ll
  test/DebugInfo/X86/gnu-public-names.ll
  test/DebugInfo/X86/lexical-block-file-inline.ll
  test/DebugInfo/X86/pr19307.ll
  test/Linker/pr26037.ll
  test/ThinLTO/X86/debuginfo-cu-import.ll
  tools/clang/lib/CodeGen/CGDebugInfo.cpp
  tools/clang/test/CodeGen/debug-info-imported-entity.cpp
  tools/clang/test/CodeGenCXX/debug-info-anon-namespace.cpp
  tools/clang/test/CodeGenCXX/debug-info-namespace.cpp
  tools/clang/test/Modules/DebugInfoTransitiveImport.m
  tools/clang/test/Modules/ExtDebugInfo.cpp
  tools/clang/test/Modules/Inputs/module.map
  tools/clang/test/Modules/debug-info-moduleimport.m
  unittests/IR/IRBuilderTest.cpp
  unittests/IR/MetadataTest.cpp

Index: tools/clang/test/Modules/debug-info-moduleimport.m
===
--- tools/clang/test/Modules/debug-info-moduleimport.m
+++ tools/clang/test/Modules/debug-info-moduleimport.m
@@ -10,12 +10,13 @@
 // CHECK: ![[CU:.*]] = distinct !DICompileUnit
 @import DebugObjC;
 // CHECK: !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: ![[CU]],
-// CHECK-SAME:  entity: ![[MODULE:.*]], line: [[@LINE-2]])
+// CHECK-SAME:  entity: ![[MODULE:.*]], file: ![[F:[0-9]+]],
+// CHECK-SAME:  line: [[@LINE-3]])
 // CHECK: ![[MODULE]] = !DIModule(scope: null, name: "DebugObjC",
 // CHECK-SAME:  configMacros: "\22-DGREETING=Hello World\22 \22-UNDEBUG\22",
 // CHECK-SAME:  includePath: "{{.*}}test{{.*}}Modules{{.*}}Inputs",
 // CHECK-SAME:  isysroot: "/tmp/..")
-
+// CHECK: ![[F]] = !DIFile(filename: {{.*}}debug-info-moduleimport.m
 
 // RUN: %clang_cc1 -debug-info-kind=limited -fmodules -fimplicit-module-maps -fmodules-cache-path=%t \
 // RUN:   %s -I %S/Inputs -isysroot /tmp/.. -I %t -emit-llvm -o - \
Index: tools/clang/test/Modules/Inputs/module.map
===
--- tools/clang/test/Modules/Inputs/module.map
+++ tools/clang/test/Modules/Inputs/module.map
@@ -347,6 +347,12 @@
   header "DebugObjC.h"
 }
 
+module DebugObjCImport {
+  module SubModule {
+header "DebugObjCImport.h"
+  }
+}
+
 module ImportNameInDir {
   header "ImportNameInDir.h"
   export *
Index: tools/clang/test/Modules/ExtDebugInfo.cpp
===
--- tools/clang/test/Modules/ExtDebugInfo.cpp
+++ tools/clang/test/Modules/ExtDebugInfo.cpp
@@ -71,6 +71,8 @@
   anon.i = GlobalStruct.i = GlobalUnion.i = GlobalEnum;
 }
 
+// CHECK: ![[CPP:.*]] = !DIFile(filename: {{.*}}ExtDebugInfo.cpp"
+
 // CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "Enum",
 // CHECK-SAME: scope: ![[NS:[0-9]+]],
 // CHECK-SAME: flags: DIFlagFwdDecl,
@@ -201,7 +203,7 @@
 // CHECK-SAME:  name: "InAnonymousNamespace", {{.*}}DIFlagFwdDecl)
 
 
-// CHECK: !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !{{[0-9]+}}, entity: ![[STRUCT]], line: 27)
+// CHECK: !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !{{[0-9]+}}, entity: ![[STRUCT]], file: ![[CPP]], line: 27)
 
 // CHECK: !DICompileUnit(
 // CHECK-SAME:   splitDebugFilename:
Index: tools/clang/test/Modules/DebugInfoTransitiveImport.m
===
--- tools/clang/test/Modules/DebugInfoTransitiveImport.m
+++ tools/clang/test/Modules/DebugInfoTransitiveImport.m
@@ -12,9 +12,9 @@
 
 // Definition of left:
 // CHECK: !DICompileUnit({{.*}}dwoId:
-// CHECK: !DIFile({{.*}}diamond_left
+// CHECK: ![[LEFT:[0-9]+]] = 

[PATCH] D32817: [CMake] Build runtimes for Fuchsia targets

2017-07-18 Thread Petr Hosek via Phabricator via cfe-commits
phosek updated this revision to Diff 107178.

Repository:
  rL LLVM

https://reviews.llvm.org/D32817

Files:
  cmake/caches/Fuchsia-stage2.cmake
  cmake/caches/Fuchsia.cmake


Index: cmake/caches/Fuchsia.cmake
===
--- cmake/caches/Fuchsia.cmake
+++ cmake/caches/Fuchsia.cmake
@@ -38,9 +38,11 @@
   install-distribution
   clang CACHE STRING "")
 
-if(FUCHSIA_SYSROOT)
-  set(EXTRA_ARGS -DFUCHSIA_SYSROOT=${FUCHSIA_SYSROOT})
-endif()
+foreach(target x86_64;aarch64)
+  if(FUCHSIA_${target}_SYSROOT)
+list(APPEND EXTRA_ARGS 
-DFUCHSIA_${target}_SYSROOT=${FUCHSIA_${target}_SYSROOT})
+  endif()
+endforeach()
 
 # Setup the bootstrap build.
 set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "")
Index: cmake/caches/Fuchsia-stage2.cmake
===
--- cmake/caches/Fuchsia-stage2.cmake
+++ cmake/caches/Fuchsia-stage2.cmake
@@ -7,7 +7,6 @@
 
 set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "")
 set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "")
-set(LLVM_TOOL_CLANG_TOOLS_EXTRA_BUILD OFF CACHE BOOL "")
 set(LLVM_ENABLE_ZLIB ON CACHE BOOL "")
 set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
 set(LLVM_EXTERNALIZE_DEBUGINFO ON CACHE BOOL "")
@@ -27,11 +26,27 @@
 set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -gline-tables-only -DNDEBUG" CACHE 
STRING "")
 set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -gline-tables-only -DNDEBUG" CACHE 
STRING "")
 
-set(LLVM_BUILTIN_TARGETS "x86_64-fuchsia-none;aarch64-fuchsia-none" CACHE 
STRING "")
-set(BUILTINS_x86_64-fuchsia-none_CMAKE_SYSROOT ${FUCHSIA_SYSROOT} CACHE STRING 
"")
-set(BUILTINS_x86_64-fuchsia-none_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
-set(BUILTINS_aarch64-fuchsia-none_CMAKE_SYSROOT ${FUCHSIA_SYSROOT} CACHE 
STRING "")
-set(BUILTINS_aarch64-fuchsia-none_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
+set(LLVM_BUILTIN_TARGETS "x86_64-fuchsia;aarch64-fuchsia" CACHE STRING "")
+foreach(target x86_64;aarch64)
+  set(BUILTINS_${target}-fuchsia_CMAKE_SYSROOT ${FUCHSIA_${target}_SYSROOT} 
CACHE PATH "")
+  set(BUILTINS_${target}-fuchsia_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
+endforeach()
+if(NOT APPLE)
+  list(APPEND LLVM_BUILTIN_TARGETS "default")
+endif()
+
+set(LLVM_RUNTIME_TARGETS "default;x86_64-fuchsia;aarch64-fuchsia" CACHE STRING 
"")
+foreach(target x86_64;aarch64)
+  set(RUNTIMES_${target}-fuchsia_CMAKE_BUILD_WITH_INSTALL_RPATH ON CACHE BOOL 
"")
+  set(RUNTIMES_${target}-fuchsia_CMAKE_SYSROOT ${FUCHSIA_${target}_SYSROOT} 
CACHE PATH "")
+  set(RUNTIMES_${target}-fuchsia_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
+  set(RUNTIMES_${target}-fuchsia_UNIX 1 CACHE BOOL "")
+  set(RUNTIMES_${target}-fuchsia_LLVM_ENABLE_LIBCXX ON CACHE BOOL "")
+  set(RUNTIMES_${target}-fuchsia_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
+  set(RUNTIMES_${target}-fuchsia_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
+  set(RUNTIMES_${target}-fuchsia_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
+  set(RUNTIMES_${target}-fuchsia_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
+endforeach()
 
 # Setup toolchain.
 set(LLVM_INSTALL_TOOLCHAIN_ONLY ON CACHE BOOL "")
@@ -61,8 +76,9 @@
   LTO
   clang-format
   clang-headers
-  builtins-x86_64-fuchsia-none
-  builtins-aarch64-fuchsia-none
+  clang-tidy
+  clangd
+  builtins
   runtimes
   ${LLVM_TOOLCHAIN_TOOLS}
   CACHE STRING "")


Index: cmake/caches/Fuchsia.cmake
===
--- cmake/caches/Fuchsia.cmake
+++ cmake/caches/Fuchsia.cmake
@@ -38,9 +38,11 @@
   install-distribution
   clang CACHE STRING "")
 
-if(FUCHSIA_SYSROOT)
-  set(EXTRA_ARGS -DFUCHSIA_SYSROOT=${FUCHSIA_SYSROOT})
-endif()
+foreach(target x86_64;aarch64)
+  if(FUCHSIA_${target}_SYSROOT)
+list(APPEND EXTRA_ARGS -DFUCHSIA_${target}_SYSROOT=${FUCHSIA_${target}_SYSROOT})
+  endif()
+endforeach()
 
 # Setup the bootstrap build.
 set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "")
Index: cmake/caches/Fuchsia-stage2.cmake
===
--- cmake/caches/Fuchsia-stage2.cmake
+++ cmake/caches/Fuchsia-stage2.cmake
@@ -7,7 +7,6 @@
 
 set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "")
 set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "")
-set(LLVM_TOOL_CLANG_TOOLS_EXTRA_BUILD OFF CACHE BOOL "")
 set(LLVM_ENABLE_ZLIB ON CACHE BOOL "")
 set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
 set(LLVM_EXTERNALIZE_DEBUGINFO ON CACHE BOOL "")
@@ -27,11 +26,27 @@
 set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -gline-tables-only -DNDEBUG" CACHE STRING "")
 set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -gline-tables-only -DNDEBUG" CACHE STRING "")
 
-set(LLVM_BUILTIN_TARGETS "x86_64-fuchsia-none;aarch64-fuchsia-none" CACHE STRING "")
-set(BUILTINS_x86_64-fuchsia-none_CMAKE_SYSROOT ${FUCHSIA_SYSROOT} CACHE STRING "")
-set(BUILTINS_x86_64-fuchsia-none_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
-set(BUILTINS_aarch64-fuchsia-none_CMAKE_SYSROOT ${FUCHSIA_SYSROOT} CACHE STRING "")
-set(BUILTINS_aarch64-fuchsia-none_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")

[PATCH] D35582: [Driver] Always use -z rodynamic for Fuchsia

2017-07-18 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.

Fuchsia uses read-only .dynamic section.


Repository:
  rL LLVM

https://reviews.llvm.org/D35582

Files:
  lib/Driver/ToolChains/Fuchsia.cpp
  test/Driver/fuchsia.c
  test/Driver/fuchsia.cpp


Index: test/Driver/fuchsia.cpp
===
--- test/Driver/fuchsia.cpp
+++ test/Driver/fuchsia.cpp
@@ -7,6 +7,7 @@
 // CHECK: "-internal-isystem" 
"{{.*[/\\]}}x86_64-fuchsia{{/|}}include{{/|}}c++{{/|}}v1"
 // CHECK: "-internal-externc-isystem" "[[SYSROOT]]{{/|}}include"
 // CHECK: {{.*}}lld{{.*}}" "-flavor" "gnu"
+// CHECK: "-z" "rodynamic"
 // CHECK: "--sysroot=[[SYSROOT]]"
 // CHECK: "-pie"
 // CHECK: "--build-id"
Index: test/Driver/fuchsia.c
===
--- test/Driver/fuchsia.c
+++ test/Driver/fuchsia.c
@@ -5,6 +5,7 @@
 // CHECK: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK: "-internal-externc-isystem" "[[SYSROOT]]{{/|}}include"
 // CHECK: {{.*}}lld{{.*}}" "-flavor" "gnu"
+// CHECK: "-z" "rodynamic"
 // CHECK: "--sysroot=[[SYSROOT]]"
 // CHECK: "-pie"
 // CHECK: "--build-id"
Index: lib/Driver/ToolChains/Fuchsia.cpp
===
--- lib/Driver/ToolChains/Fuchsia.cpp
+++ lib/Driver/ToolChains/Fuchsia.cpp
@@ -48,6 +48,9 @@
 CmdArgs.push_back("gnu");
   }
 
+  CmdArgs.push_back("-z");
+  CmdArgs.push_back("rodynamic");
+
   if (!D.SysRoot.empty())
 CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot));
 


Index: test/Driver/fuchsia.cpp
===
--- test/Driver/fuchsia.cpp
+++ test/Driver/fuchsia.cpp
@@ -7,6 +7,7 @@
 // CHECK: "-internal-isystem" "{{.*[/\\]}}x86_64-fuchsia{{/|}}include{{/|}}c++{{/|}}v1"
 // CHECK: "-internal-externc-isystem" "[[SYSROOT]]{{/|}}include"
 // CHECK: {{.*}}lld{{.*}}" "-flavor" "gnu"
+// CHECK: "-z" "rodynamic"
 // CHECK: "--sysroot=[[SYSROOT]]"
 // CHECK: "-pie"
 // CHECK: "--build-id"
Index: test/Driver/fuchsia.c
===
--- test/Driver/fuchsia.c
+++ test/Driver/fuchsia.c
@@ -5,6 +5,7 @@
 // CHECK: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK: "-internal-externc-isystem" "[[SYSROOT]]{{/|}}include"
 // CHECK: {{.*}}lld{{.*}}" "-flavor" "gnu"
+// CHECK: "-z" "rodynamic"
 // CHECK: "--sysroot=[[SYSROOT]]"
 // CHECK: "-pie"
 // CHECK: "--build-id"
Index: lib/Driver/ToolChains/Fuchsia.cpp
===
--- lib/Driver/ToolChains/Fuchsia.cpp
+++ lib/Driver/ToolChains/Fuchsia.cpp
@@ -48,6 +48,9 @@
 CmdArgs.push_back("gnu");
   }
 
+  CmdArgs.push_back("-z");
+  CmdArgs.push_back("rodynamic");
+
   if (!D.SysRoot.empty())
 CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot));
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D35578: Add -fswitch-tables and -fno-switch-tables flags

2017-07-18 Thread Sumanth Gundapaneni via Phabricator via cfe-commits
sgundapa added a comment.

The switch-case statements generate two kinds of tables.

1. Jump tables
2. Lookup tables.

While the general assumption is that switch-case statements generate jump 
tables, the below case generates a lookup table by late simplifycfg

int foo(int x) {

  switch (x) {
  case 0: return 9;
  case 1: return 20;
  case 2: return 14;
  case 3: return 22;
  case 4: return 12;
  default: return 19;
  }

}
generates a 
@switch.table.foo = private unnamed_addr constant [5 x i32] [i32 9, i32 20, i32 
14, i32 22, i32 12]
The lookup table is more an array return values as opposed to an array of 
pointers in jump table.

The "-fno-XXX-flags" disable the generation of these tables. 
-fno-switch-tables implies both -fno-jump-tables and -fno-lookup-tables


https://reviews.llvm.org/D35578



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


[PATCH] D35572: Add isValidCPUName and isValidFeature to TargetInfo

2017-07-18 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In https://reviews.llvm.org/D35572#813369, @echristo wrote:

> Can you update the code in CGBuiltin to use this as part of this patch? :)
>
> Thanks!


I'm not sure which you're referring to?  I don't see a bit in CGBuiltin that 
checks for a subset of the "Features", however it is a much smaller list (since 
it is only things that the compiler-rt can check).  Is it perhaps more closely 
related to that one?


https://reviews.llvm.org/D35572



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


[PATCH] D35574: Convert attribute 'target' parsing from a 'pair' to a 'struct' to make further improvements easier

2017-07-18 Thread Erich Keane via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL308357: Convert attribute 'target' parsing from a 'pair' to 
a 'struct' to make further… (authored by erichkeane).

Changed prior to commit:
  https://reviews.llvm.org/D35574?vs=107131=107171#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D35574

Files:
  cfe/trunk/include/clang/Basic/Attr.td
  cfe/trunk/lib/CodeGen/CGCall.cpp
  cfe/trunk/lib/CodeGen/CodeGenModule.cpp


Index: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp
@@ -4499,18 +4499,19 @@
 
 // Make a copy of the features as passed on the command line into the
 // beginning of the additional features from the function to override.
-ParsedAttr.first.insert(ParsedAttr.first.begin(),
+ParsedAttr.Features.insert(ParsedAttr.Features.begin(),
 Target.getTargetOpts().FeaturesAsWritten.begin(),
 Target.getTargetOpts().FeaturesAsWritten.end());
 
-if (ParsedAttr.second != "")
-  TargetCPU = ParsedAttr.second;
+if (ParsedAttr.Architecture != "")
+  TargetCPU = ParsedAttr.Architecture ;
 
 // Now populate the feature map, first with the TargetCPU which is either
 // the default or a new one from the target attribute string. Then we'll 
use
 // the passed in features (FeaturesAsWritten) along with the new ones from
 // the attribute.
-Target.initFeatureMap(FeatureMap, getDiags(), TargetCPU, ParsedAttr.first);
+Target.initFeatureMap(FeatureMap, getDiags(), TargetCPU,
+  ParsedAttr.Features);
   } else {
 Target.initFeatureMap(FeatureMap, getDiags(), TargetCPU,
   Target.getTargetOpts().Features);
Index: cfe/trunk/lib/CodeGen/CGCall.cpp
===
--- cfe/trunk/lib/CodeGen/CGCall.cpp
+++ cfe/trunk/lib/CodeGen/CGCall.cpp
@@ -1877,8 +1877,8 @@
   // the function.
   const auto *TD = FD->getAttr();
   TargetAttr::ParsedTargetAttr ParsedAttr = TD->parse();
-  if (ParsedAttr.second != "")
-TargetCPU = ParsedAttr.second;
+  if (ParsedAttr.Architecture != "")
+TargetCPU = ParsedAttr.Architecture;
   if (TargetCPU != "")
 FuncAttrs.addAttribute("target-cpu", TargetCPU);
   if (!Features.empty()) {
Index: cfe/trunk/include/clang/Basic/Attr.td
===
--- cfe/trunk/include/clang/Basic/Attr.td
+++ cfe/trunk/include/clang/Basic/Attr.td
@@ -1802,11 +1802,18 @@
   let Subjects = SubjectList<[Function], ErrorDiag>;
   let Documentation = [TargetDocs];
   let AdditionalMembers = [{
-typedef std::pair ParsedTargetAttr;
+struct ParsedTargetAttr {
+  std::vector Features;
+  StringRef Architecture;
+  bool DuplicateArchitecture = false;
+};
 ParsedTargetAttr parse() const {
+  return parse(getFeaturesStr());
+}
+static ParsedTargetAttr parse(StringRef Features) {
   ParsedTargetAttr Ret;
   SmallVector AttrFeatures;
-  getFeaturesStr().split(AttrFeatures, ",");
+  Features.split(AttrFeatures, ",");
 
   // Grab the various features and prepend a "+" to turn on the feature to
   // the backend and add them to our existing set of features.
@@ -1823,12 +1830,15 @@
  continue;
 
 // While we're here iterating check for a different target cpu.
-if (Feature.startswith("arch="))
-  Ret.second = Feature.split("=").second.trim();
-else if (Feature.startswith("no-"))
-  Ret.first.push_back("-" + Feature.split("-").second.str());
+if (Feature.startswith("arch=")) {
+  if (!Ret.Architecture.empty())
+Ret.DuplicateArchitecture = true;
+  else
+Ret.Architecture = Feature.split("=").second.trim();
+} else if (Feature.startswith("no-"))
+  Ret.Features.push_back("-" + Feature.split("-").second.str());
 else
-  Ret.first.push_back("+" + Feature.str());
+  Ret.Features.push_back("+" + Feature.str());
   }
   return Ret;
 }


Index: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp
@@ -4499,18 +4499,19 @@
 
 // Make a copy of the features as passed on the command line into the
 // beginning of the additional features from the function to override.
-ParsedAttr.first.insert(ParsedAttr.first.begin(),
+ParsedAttr.Features.insert(ParsedAttr.Features.begin(),
 Target.getTargetOpts().FeaturesAsWritten.begin(),
 Target.getTargetOpts().FeaturesAsWritten.end());
 
-if 

[PATCH] D33561: [CMake] Add Android toolchain CMake cache files.

2017-07-18 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs added inline comments.



Comment at: cmake/caches/Android-stage2.cmake:37
+  set(RUNTIMES_${target}-linux-android_COMPILER_RT_INCLUDE_TESTS OFF CACHE 
BOOL "")
+  set(RUNTIMES_${target}-linux-android_LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "")
+  set(RUNTIMES_${target}-linux-android_LLVM_ENABLE_THREADS OFF CACHE BOOL "")

pirama wrote:
> jroelofs wrote:
> > pirama wrote:
> > > Should we initialize it to LLVM_ENABLE_ASSERTIONS rather than defaulting 
> > > to ON?  So assertions can be enabled/disabled for all targets with just 
> > > one switch (and then over-ride with per-target flags, if necessary).
> > No. Absolutely not. Whether or not the bits of the toolchain that run on 
> > the host have assertions should be *completely* independent of whether the 
> > target bits do or don't. Do not conflate the host with the target.
> Maybe I wasn't clear.  I suggest that we don't set 
> RUNTIMES_${target}_LLVM_ENABLE_ASSERTIONS to ON here and rather initialize it 
> based on another flag.  I was incorrect to suggest we reuse 
> LLVM_ENABLE_ASSERTIONS.  We should rather have something like 
> ANDROID_RUNTIMES_ENABLE_ASSERTIONS.
> 
> The motivation is to reduce the number of additional flags/switches, under 
> the assumption that assert-enabled or assert-disabled builds of the runtimes 
> are generated simultaneously.
> 
> To generate assert-enabled builds, the invocation would be:
> 
> ```
> $ cmake ... -DANDROID_RUNTIMES_ENABLE_ASSERTIONS=ON
> 
> ```
> instead of
> 
> ```
> $ cmake ... -DRUNTIMES_armv7-linux-android_LLVM_ENABLE_ASSERTIONS=ON 
> -DRUNTIMES-aarch64-linux-android_LLVM_ENABLE_ASSERTIONS=ON ...
> 
> ```
> If I understand CMake correctly, we can still enable assertions only for a 
> particular target by:
> 
> ```
> $ cmake ...  -DANDROID_RUNTIMES_ENABLE_ASSERTIONS=OFF 
> -DRUNTIMES-aarch64-linux-android_LLVM_ENABLE_ASSERTIONS=ON
> ```
Yeah, collecting them under a common default seems fine. The only thing I was 
objecting to was having that default be tied to the settings of the host part 
of the build.


https://reviews.llvm.org/D33561



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


r308357 - Convert attribute 'target' parsing from a 'pair' to a 'struct' to make further improvements easier

2017-07-18 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Tue Jul 18 13:41:02 2017
New Revision: 308357

URL: http://llvm.org/viewvc/llvm-project?rev=308357=rev
Log:
Convert attribute 'target' parsing from a 'pair' to a 'struct' to make further 
improvements easier


Convert attribute 'target' parsing from a 'pair' to a 'struct' to make further 
improvements easier

The attribute 'target' parse function previously returned a pair. Convert 
this to a 'pair' in order to add more functionality, and improve usability.

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

Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=308357=308356=308357=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Tue Jul 18 13:41:02 2017
@@ -1802,11 +1802,18 @@ def Target : InheritableAttr {
   let Subjects = SubjectList<[Function], ErrorDiag>;
   let Documentation = [TargetDocs];
   let AdditionalMembers = [{
-typedef std::pair ParsedTargetAttr;
+struct ParsedTargetAttr {
+  std::vector Features;
+  StringRef Architecture;
+  bool DuplicateArchitecture = false;
+};
 ParsedTargetAttr parse() const {
+  return parse(getFeaturesStr());
+}
+static ParsedTargetAttr parse(StringRef Features) {
   ParsedTargetAttr Ret;
   SmallVector AttrFeatures;
-  getFeaturesStr().split(AttrFeatures, ",");
+  Features.split(AttrFeatures, ",");
 
   // Grab the various features and prepend a "+" to turn on the feature to
   // the backend and add them to our existing set of features.
@@ -1823,12 +1830,15 @@ def Target : InheritableAttr {
  continue;
 
 // While we're here iterating check for a different target cpu.
-if (Feature.startswith("arch="))
-  Ret.second = Feature.split("=").second.trim();
-else if (Feature.startswith("no-"))
-  Ret.first.push_back("-" + Feature.split("-").second.str());
+if (Feature.startswith("arch=")) {
+  if (!Ret.Architecture.empty())
+Ret.DuplicateArchitecture = true;
+  else
+Ret.Architecture = Feature.split("=").second.trim();
+} else if (Feature.startswith("no-"))
+  Ret.Features.push_back("-" + Feature.split("-").second.str());
 else
-  Ret.first.push_back("+" + Feature.str());
+  Ret.Features.push_back("+" + Feature.str());
   }
   return Ret;
 }

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=308357=308356=308357=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Tue Jul 18 13:41:02 2017
@@ -1877,8 +1877,8 @@ void CodeGenModule::ConstructAttributeLi
   // the function.
   const auto *TD = FD->getAttr();
   TargetAttr::ParsedTargetAttr ParsedAttr = TD->parse();
-  if (ParsedAttr.second != "")
-TargetCPU = ParsedAttr.second;
+  if (ParsedAttr.Architecture != "")
+TargetCPU = ParsedAttr.Architecture;
   if (TargetCPU != "")
 FuncAttrs.addAttribute("target-cpu", TargetCPU);
   if (!Features.empty()) {

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=308357=308356=308357=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Tue Jul 18 13:41:02 2017
@@ -4499,18 +4499,19 @@ void CodeGenModule::getFunctionFeatureMa
 
 // Make a copy of the features as passed on the command line into the
 // beginning of the additional features from the function to override.
-ParsedAttr.first.insert(ParsedAttr.first.begin(),
+ParsedAttr.Features.insert(ParsedAttr.Features.begin(),
 Target.getTargetOpts().FeaturesAsWritten.begin(),
 Target.getTargetOpts().FeaturesAsWritten.end());
 
-if (ParsedAttr.second != "")
-  TargetCPU = ParsedAttr.second;
+if (ParsedAttr.Architecture != "")
+  TargetCPU = ParsedAttr.Architecture ;
 
 // Now populate the feature map, first with the TargetCPU which is either
 // the default or a new one from the target attribute string. Then we'll 
use
 // the passed in features (FeaturesAsWritten) along with the new ones from
 // the attribute.
-Target.initFeatureMap(FeatureMap, getDiags(), TargetCPU, ParsedAttr.first);
+Target.initFeatureMap(FeatureMap, getDiags(), TargetCPU,
+  

[PATCH] D35578: Add -fswitch-tables and -fno-switch-tables flags

2017-07-18 Thread Chad Rosier via Phabricator via cfe-commits
mcrosier added a comment.

What exactly is the difference between -fno-jump-tables, -fno-switch-tables, 
and -fno-lookup-tables?


https://reviews.llvm.org/D35578



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


r308356 - [Sema] NFC: Move all availability checking code to SemaDeclAttr.cpp

2017-07-18 Thread Erik Pilkington via cfe-commits
Author: epilk
Date: Tue Jul 18 13:32:07 2017
New Revision: 308356

URL: http://llvm.org/viewvc/llvm-project?rev=308356=rev
Log:
[Sema] NFC: Move all availability checking code to SemaDeclAttr.cpp

Previously, this was awkwardly split up between SemaExpr.cpp.

Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=308356=308355=308356=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Tue Jul 18 13:32:07 2017
@@ -3881,13 +3881,10 @@ public:
 
   void redelayDiagnostics(sema::DelayedDiagnosticPool );
 
-  void EmitAvailabilityWarning(AvailabilityResult AR,
-   const NamedDecl *ReferringDecl,
-   const NamedDecl *OffendingDecl,
-   StringRef Message, SourceLocation Loc,
-   const ObjCInterfaceDecl *UnknownObjCClass,
-   const ObjCPropertyDecl *ObjCProperty,
-   bool ObjCPropertyAccess);
+  void DiagnoseAvailabilityOfDecl(NamedDecl *D, SourceLocation Loc,
+  const ObjCInterfaceDecl *UnknownObjCClass,
+  bool ObjCPropertyAccess,
+  bool AvoidPartialAvailabilityChecks = false);
 
   bool makeUnavailableInSystemHeader(SourceLocation loc,
  UnavailableAttr::ImplicitReason reason);
@@ -10426,15 +10423,6 @@ public:
 return OriginalLexicalContext ? OriginalLexicalContext : CurContext;
   }
 
-  /// The diagnostic we should emit for \c D, and the declaration that
-  /// originated it, or \c AR_Available.
-  ///
-  /// \param D The declaration to check.
-  /// \param Message If non-null, this will be populated with the message from
-  /// the availability attribute that is selected.
-  std::pair
-  ShouldDiagnoseAvailabilityOfDecl(const NamedDecl *D, std::string *Message);
-
   const DeclContext *getCurObjCLexicalContext() const {
 const DeclContext *DC = getCurLexicalContext();
 // A category implicitly has the attribute of the interface.

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=308356=308355=308356=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Tue Jul 18 13:32:07 2017
@@ -6853,6 +6853,50 @@ static const AvailabilityAttr *getAttrFo
   return nullptr;
 }
 
+/// The diagnostic we should emit for \c D, and the declaration that
+/// originated it, or \c AR_Available.
+///
+/// \param D The declaration to check.
+/// \param Message If non-null, this will be populated with the message from
+/// the availability attribute that is selected.
+static std::pair
+ShouldDiagnoseAvailabilityOfDecl(const NamedDecl *D, std::string *Message) {
+  AvailabilityResult Result = D->getAvailability(Message);
+
+  // For typedefs, if the typedef declaration appears available look
+  // to the underlying type to see if it is more restrictive.
+  while (const TypedefNameDecl *TD = dyn_cast(D)) {
+if (Result == AR_Available) {
+  if (const TagType *TT = TD->getUnderlyingType()->getAs()) {
+D = TT->getDecl();
+Result = D->getAvailability(Message);
+continue;
+  }
+}
+break;
+  }
+
+  // Forward class declarations get their attributes from their definition.
+  if (const ObjCInterfaceDecl *IDecl = dyn_cast(D)) {
+if (IDecl->getDefinition()) {
+  D = IDecl->getDefinition();
+  Result = D->getAvailability(Message);
+}
+  }
+
+  if (const auto *ECD = dyn_cast(D))
+if (Result == AR_Available) {
+  const DeclContext *DC = ECD->getDeclContext();
+  if (const auto *TheEnumDecl = dyn_cast(DC)) {
+Result = TheEnumDecl->getAvailability(Message);
+D = TheEnumDecl;
+  }
+}
+
+  return {Result, D};
+}
+
+
 /// \brief 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.
@@ -7220,24 +7264,24 @@ void Sema::redelayDiagnostics(DelayedDia
   curPool->steal(pool);
 }
 
-void Sema::EmitAvailabilityWarning(AvailabilityResult AR,
-   const NamedDecl *ReferringDecl,
-   const NamedDecl *OffendingDecl,
-   StringRef Message, SourceLocation Loc,
-   const ObjCInterfaceDecl 

r308352 - [OPENMP] Initial support for 'task_reduction' clause.

2017-07-18 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Jul 18 13:17:46 2017
New Revision: 308352

URL: http://llvm.org/viewvc/llvm-project?rev=308352=rev
Log:
[OPENMP] Initial support for 'task_reduction' clause.

Parsing/sema analysis of the 'task_reduction' clause.

Added:
cfe/trunk/test/OpenMP/taskgroup_task_reduction_messages.cpp
Modified:
cfe/trunk/include/clang/AST/OpenMPClause.h
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
cfe/trunk/include/clang/AST/StmtOpenMP.h
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Basic/OpenMPKinds.def
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/OpenMPClause.cpp
cfe/trunk/lib/AST/StmtOpenMP.cpp
cfe/trunk/lib/AST/StmtPrinter.cpp
cfe/trunk/lib/AST/StmtProfile.cpp
cfe/trunk/lib/Basic/OpenMPKinds.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/Parse/ParseOpenMP.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
cfe/trunk/test/OpenMP/taskgroup_ast_print.cpp
cfe/trunk/test/OpenMP/taskgroup_messages.cpp
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/include/clang/AST/OpenMPClause.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OpenMPClause.h?rev=308352=308351=308352=diff
==
--- cfe/trunk/include/clang/AST/OpenMPClause.h (original)
+++ cfe/trunk/include/clang/AST/OpenMPClause.h Tue Jul 18 13:17:46 2017
@@ -1890,6 +1890,217 @@ public:
   }
 };
 
+/// This represents clause 'task_reduction' in the '#pragma omp taskgroup'
+/// directives.
+///
+/// \code
+/// #pragma omp taskgroup task_reduction(+:a,b)
+/// \endcode
+/// In this example directive '#pragma omp taskgroup' has clause
+/// 'task_reduction' with operator '+' and the variables 'a' and 'b'.
+///
+class OMPTaskReductionClause final
+: public OMPVarListClause,
+  public OMPClauseWithPostUpdate,
+  private llvm::TrailingObjects {
+  friend TrailingObjects;
+  friend OMPVarListClause;
+  friend class OMPClauseReader;
+  /// Location of ':'.
+  SourceLocation ColonLoc;
+  /// Nested name specifier for C++.
+  NestedNameSpecifierLoc QualifierLoc;
+  /// Name of custom operator.
+  DeclarationNameInfo NameInfo;
+
+  /// Build clause with number of variables \a N.
+  ///
+  /// \param StartLoc Starting location of the clause.
+  /// \param LParenLoc Location of '('.
+  /// \param EndLoc Ending location of the clause.
+  /// \param ColonLoc Location of ':'.
+  /// \param N Number of the variables in the clause.
+  /// \param QualifierLoc The nested-name qualifier with location information
+  /// \param NameInfo The full name info for reduction identifier.
+  ///
+  OMPTaskReductionClause(SourceLocation StartLoc, SourceLocation LParenLoc,
+ SourceLocation ColonLoc, SourceLocation EndLoc,
+ unsigned N, NestedNameSpecifierLoc QualifierLoc,
+ const DeclarationNameInfo )
+  : OMPVarListClause(OMPC_task_reduction, StartLoc,
+ LParenLoc, EndLoc, N),
+OMPClauseWithPostUpdate(this), ColonLoc(ColonLoc),
+QualifierLoc(QualifierLoc), NameInfo(NameInfo) {}
+
+  /// Build an empty clause.
+  ///
+  /// \param N Number of variables.
+  ///
+  explicit OMPTaskReductionClause(unsigned N)
+  : OMPVarListClause(
+OMPC_task_reduction, SourceLocation(), SourceLocation(),
+SourceLocation(), N),
+OMPClauseWithPostUpdate(this), ColonLoc(), QualifierLoc(), NameInfo() 
{}
+
+  /// Sets location of ':' symbol in clause.
+  void setColonLoc(SourceLocation CL) { ColonLoc = CL; }
+  /// Sets the name info for specified reduction identifier.
+  void setNameInfo(DeclarationNameInfo DNI) { NameInfo = DNI; }
+  /// Sets the nested name specifier.
+  void setQualifierLoc(NestedNameSpecifierLoc NSL) { QualifierLoc = NSL; }
+
+  /// Set list of helper expressions, required for proper codegen of the 
clause.
+  /// These expressions represent private copy of the reduction variable.
+  void setPrivates(ArrayRef Privates);
+
+  /// Get the list of helper privates.
+  MutableArrayRef getPrivates() {
+return MutableArrayRef(varlist_end(), varlist_size());
+  }
+  ArrayRef getPrivates() const {
+return llvm::makeArrayRef(varlist_end(), varlist_size());
+  }
+
+  /// Set list of helper expressions, required for proper codegen of the 
clause.
+  /// These expressions represent LHS expression in the final reduction
+  /// expression performed by the reduction clause.
+  void setLHSExprs(ArrayRef LHSExprs);
+
+  /// Get the list of helper LHS expressions.
+  MutableArrayRef getLHSExprs() {
+return MutableArrayRef(getPrivates().end(), varlist_size());
+  }
+  ArrayRef getLHSExprs() const {
+return 

[PATCH] D33561: [CMake] Add Android toolchain CMake cache files.

2017-07-18 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama added inline comments.



Comment at: cmake/caches/Android-stage2.cmake:37
+  set(RUNTIMES_${target}-linux-android_COMPILER_RT_INCLUDE_TESTS OFF CACHE 
BOOL "")
+  set(RUNTIMES_${target}-linux-android_LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "")
+  set(RUNTIMES_${target}-linux-android_LLVM_ENABLE_THREADS OFF CACHE BOOL "")

jroelofs wrote:
> pirama wrote:
> > Should we initialize it to LLVM_ENABLE_ASSERTIONS rather than defaulting to 
> > ON?  So assertions can be enabled/disabled for all targets with just one 
> > switch (and then over-ride with per-target flags, if necessary).
> No. Absolutely not. Whether or not the bits of the toolchain that run on the 
> host have assertions should be *completely* independent of whether the target 
> bits do or don't. Do not conflate the host with the target.
Maybe I wasn't clear.  I suggest that we don't set 
RUNTIMES_${target}_LLVM_ENABLE_ASSERTIONS to ON here and rather initialize it 
based on another flag.  I was incorrect to suggest we reuse 
LLVM_ENABLE_ASSERTIONS.  We should rather have something like 
ANDROID_RUNTIMES_ENABLE_ASSERTIONS.

The motivation is to reduce the number of additional flags/switches, under the 
assumption that assert-enabled or assert-disabled builds of the runtimes are 
generated simultaneously.

To generate assert-enabled builds, the invocation would be:

```
$ cmake ... -DANDROID_RUNTIMES_ENABLE_ASSERTIONS=ON

```
instead of

```
$ cmake ... -DRUNTIMES_armv7-linux-android_LLVM_ENABLE_ASSERTIONS=ON 
-DRUNTIMES-aarch64-linux-android_LLVM_ENABLE_ASSERTIONS=ON ...

```
If I understand CMake correctly, we can still enable assertions only for a 
particular target by:

```
$ cmake ...  -DANDROID_RUNTIMES_ENABLE_ASSERTIONS=OFF 
-DRUNTIMES-aarch64-linux-android_LLVM_ENABLE_ASSERTIONS=ON
```


https://reviews.llvm.org/D33561



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


[PATCH] D33561: [CMake] Add Android toolchain CMake cache files.

2017-07-18 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs added inline comments.



Comment at: cmake/caches/Android-stage2.cmake:37
+  set(RUNTIMES_${target}-linux-android_COMPILER_RT_INCLUDE_TESTS OFF CACHE 
BOOL "")
+  set(RUNTIMES_${target}-linux-android_LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "")
+  set(RUNTIMES_${target}-linux-android_LLVM_ENABLE_THREADS OFF CACHE BOOL "")

pirama wrote:
> Should we initialize it to LLVM_ENABLE_ASSERTIONS rather than defaulting to 
> ON?  So assertions can be enabled/disabled for all targets with just one 
> switch (and then over-ride with per-target flags, if necessary).
No. Absolutely not. Whether or not the bits of the toolchain that run on the 
host have assertions should be *completely* independent of whether the target 
bits do or don't. Do not conflate the host with the target.


https://reviews.llvm.org/D33561



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


[PATCH] D33561: [CMake] Add Android toolchain CMake cache files.

2017-07-18 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama added inline comments.



Comment at: cmake/caches/Android-stage2.cmake:27
+  set(RUNTIMES_${target}-linux-android_CMAKE_ASM_FLAGS 
${ANDROID_${target}_C_FLAGS} CACHE PATH "")
+  set(RUNTIMES_${target}-linux-android_CMAKE_BUILD_TYPE RELEASE CACHE STRING 
"")
+  set(RUNTIMES_${target}-linux-android_CMAKE_C_FLAGS 
${ANDROID_${target}_C_FLAGS} CACHE PATH "")

Same comment as ASSERTIONS below.



Comment at: cmake/caches/Android-stage2.cmake:37
+  set(RUNTIMES_${target}-linux-android_COMPILER_RT_INCLUDE_TESTS OFF CACHE 
BOOL "")
+  set(RUNTIMES_${target}-linux-android_LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "")
+  set(RUNTIMES_${target}-linux-android_LLVM_ENABLE_THREADS OFF CACHE BOOL "")

Should we initialize it to LLVM_ENABLE_ASSERTIONS rather than defaulting to ON? 
 So assertions can be enabled/disabled for all targets with just one switch 
(and then over-ride with per-target flags, if necessary).


https://reviews.llvm.org/D33561



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


[libcxx] r308347 - [CMake] Use MATCHES for regular expression.

2017-07-18 Thread Leo Li via cfe-commits
Author: aoli
Date: Tue Jul 18 12:48:02 2017
New Revision: 308347

URL: http://llvm.org/viewvc/llvm-project?rev=308347=rev
Log:
[CMake] Use MATCHES for regular expression.

Subscribers: mgorny

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

Modified:
libcxx/trunk/lib/CMakeLists.txt

Modified: libcxx/trunk/lib/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/lib/CMakeLists.txt?rev=308347=308346=308347=diff
==
--- libcxx/trunk/lib/CMakeLists.txt (original)
+++ libcxx/trunk/lib/CMakeLists.txt Tue Jul 18 12:48:02 2017
@@ -258,7 +258,7 @@ if (LIBCXX_ENABLE_STATIC)
   set(MERGE_ARCHIVES_SEARCH_PATHS "-L${LIBCXX_CXX_ABI_LIBRARY_PATH}")
 endif()
 if ((TARGET ${LIBCXX_CXX_ABI_LIBRARY}) OR
-(${LIBCXX_CXX_ABI_LIBRARY} STREQUAL "cxxabi(_static|_shared)?" AND 
HAVE_LIBCXXABI))
+(${LIBCXX_CXX_ABI_LIBRARY} MATCHES "cxxabi(_static|_shared)?" AND 
HAVE_LIBCXXABI))
   set(MERGE_ARCHIVES_ABI_TARGET 
"$")
 else()
   set(MERGE_ARCHIVES_ABI_TARGET


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


[PATCH] D34440: [Clang] Expand response files before loading compilation database

2017-07-18 Thread Vladimir Plyashkun via Phabricator via cfe-commits
vladimir.plyashkun added a comment.

Thanks for the response @klimek !
Sorry for possible confusions.

> Yes. I'm still confused why in this case clang-tidy @file --  would be 
> expected to expand the response file? Am I missing something?

I think that we discussed use-case when @response files can appear in the 
compiler options (right after `--` symbol).

> I don't understand this. Can you elaborate?

As IDE developers we can't control how users pass options to compiler.
For example, user can set compiler options directly in the CMake, like this:

  set(CMAKE_CXX_FLAGS "@response.rsp")

and our goal is to pass this options to Clang-Tidy as is. 
It doesn't matter how will we pass them to Clang-Tidy through // 
compile_command.json//:

  {
"directory" : "",
 "command": "clang++ ... @response.rsp",
 "file": "..."
  }

or through command line (we choosed this method):

  clang-tidy ... -- @response.rsp

If compiler options will contain response files, all contents will be 
discarded, because Clang based tools don't expand response files.
By this fact we can loose important compiler information (header paths, 
definitions,  etc.) which will lead us to inaccurate analysis result.


Repository:
  rL LLVM

https://reviews.llvm.org/D34440



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


[PATCH] D35514: [CMake] Use MATCHES for regular expression comparison.

2017-07-18 Thread Leo Li via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL308347: [CMake] Use MATCHES for regular expression. 
(authored by aoli).

Repository:
  rL LLVM

https://reviews.llvm.org/D35514

Files:
  libcxx/trunk/lib/CMakeLists.txt


Index: libcxx/trunk/lib/CMakeLists.txt
===
--- libcxx/trunk/lib/CMakeLists.txt
+++ libcxx/trunk/lib/CMakeLists.txt
@@ -258,7 +258,7 @@
   set(MERGE_ARCHIVES_SEARCH_PATHS "-L${LIBCXX_CXX_ABI_LIBRARY_PATH}")
 endif()
 if ((TARGET ${LIBCXX_CXX_ABI_LIBRARY}) OR
-(${LIBCXX_CXX_ABI_LIBRARY} STREQUAL "cxxabi(_static|_shared)?" AND 
HAVE_LIBCXXABI))
+(${LIBCXX_CXX_ABI_LIBRARY} MATCHES "cxxabi(_static|_shared)?" AND 
HAVE_LIBCXXABI))
   set(MERGE_ARCHIVES_ABI_TARGET 
"$")
 else()
   set(MERGE_ARCHIVES_ABI_TARGET


Index: libcxx/trunk/lib/CMakeLists.txt
===
--- libcxx/trunk/lib/CMakeLists.txt
+++ libcxx/trunk/lib/CMakeLists.txt
@@ -258,7 +258,7 @@
   set(MERGE_ARCHIVES_SEARCH_PATHS "-L${LIBCXX_CXX_ABI_LIBRARY_PATH}")
 endif()
 if ((TARGET ${LIBCXX_CXX_ABI_LIBRARY}) OR
-(${LIBCXX_CXX_ABI_LIBRARY} STREQUAL "cxxabi(_static|_shared)?" AND HAVE_LIBCXXABI))
+(${LIBCXX_CXX_ABI_LIBRARY} MATCHES "cxxabi(_static|_shared)?" AND HAVE_LIBCXXABI))
   set(MERGE_ARCHIVES_ABI_TARGET "$")
 else()
   set(MERGE_ARCHIVES_ABI_TARGET
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33561: [CMake] Add Android toolchain CMake cache files.

2017-07-18 Thread Leo Li via Phabricator via cfe-commits
aoli updated this revision to Diff 107158.
aoli added a comment.

Add more configs.


https://reviews.llvm.org/D33561

Files:
  cmake/caches/Android-stage2.cmake
  cmake/caches/Android.cmake

Index: cmake/caches/Android.cmake
===
--- /dev/null
+++ cmake/caches/Android.cmake
@@ -0,0 +1,50 @@
+# This file sets up a CMakeCache for an Android toolchain build.
+
+set(LLVM_TARGETS_TO_BUILD X86 CACHE STRING "")
+
+set(CLANG_ENABLE_ARCMT OFF CACHE BOOL "")
+set(CLANG_ENABLE_STATIC_ANALYZER OFF CACHE BOOL "")
+set(CLANG_VENDOR Android CACHE STRING "")
+
+set(CMAKE_BUILD_TYPE RELEASE CACHE STRING "")
+
+set(HAVE_LIBCXXABI ON CACHE BOOL "")
+set(LLVM_BUILD_TOOLS OFF CACHE BOOL "")
+set(LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "")
+set(LLVM_ENABLE_THREADS OFF CACHE BOOL "")
+set(LLVM_LIBDIR_SUFFIX 64 CACHE STRING "")
+set(LLVM_TOOL_CLANG_TOOLS_EXTRA_BUILD OFF CACHE BOOL "")
+set(LLVM_TOOL_OPENMP_BUILD OFF CACHE BOOL "")
+set(LLVM_ENABLE_LIBCXX ON CACHE BOOL "")
+
+foreach(target i686;x86_64;aarch64;armv7)
+  if (ANDROID_${target}_C_FLAGS)
+list(APPEND EXTRA_ARGS -DANDROID_${target}_C_FLAGS=${ANDROID_${target}_C_FLAGS})
+  endif()
+  if (ANDROID_${target}_SYSROOT)
+list(APPEND EXTRA_ARGS -DANDROID_${target}_SYSROOT=${ANDROID_${target}_SYSROOT})
+  endif()
+  if (ANDROID_${target}_CXX_FLAGS)
+list(APPEND EXTRA_ARGS -DANDROID_${target}_CXX_FLAGS=${ANDROID_${target}_CXX_FLAGS})
+  endif()
+  if (ANDROID_${target}_LINKER_FLAGS)
+list(APPEND EXTRA_ARGS -DANDROID_${target}_LINKER_FLAGS=${ANDROID_${target}_LINKER_FLAGS})
+  endif()
+endforeach()
+
+if (LIBCXX_ENABLE_ABI_LINKER_SCRIPT)
+  list(APPEND EXTRA_ARGS -DLIBCXX_ENABLE_ABI_LINKER_SCRIPT=${LIBCXX_ENABLE_ABI_LINKER_SCRIPT})
+endif()
+
+if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY)
+  list(APPEND EXTRA_ARGS -DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=${LIBCXX_ENABLE_STATIC_ABI_LIBRARY})
+endif()
+
+if (LLVM_BUILD_EXTERNAL_COMPILER_RT)
+  set(APPEND EXTRA_ARGS -DLLVM_BUILD_EXTERNAL_COMPILER_RT=${LLVM_BUILD_EXTERNAL_COMPILER_RT})
+endif()
+
+set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "")
+set(CLANG_BOOTSTRAP_CMAKE_ARGS
+  ${EXTRA_ARGS}
+  -C${CMAKE_CURRENT_LIST_DIR}/Android-stage2.cmake CACHE STRING "")
Index: cmake/caches/Android-stage2.cmake
===
--- /dev/null
+++ cmake/caches/Android-stage2.cmake
@@ -0,0 +1,45 @@
+set(LLVM_TARGETS_TO_BUILD X86;ARM;AArch64 CACHE STRING "")
+
+set(CLANG_VENDOR Android CACHE STRING "")
+set(CMAKE_BUILD_TYPE RELEASE CACHE STRING "")
+set(LLVM_ENABLE_THREADS OFF CACHE BOOL "")
+set(LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "")
+set(LLVM_LIBDIR_SUFFIX 64 CACHE STRING "")
+set(LLVM_ENABLE_LIBCXX ON CACHE BOOL "")
+
+
+set(LLVM_BUILTIN_TARGETS "i686-linux-android;x86_64-linux-android;aarch64-linux-android;armv7-linux-android" CACHE STRING "")
+foreach(target i686;x86_64;aarch64;armv7)
+  set(BUILTINS_${target}-linux-android_ANDROID 1 CACHE STRING "")
+  set(BUILTINS_${target}-linux-android_CMAKE_ASM_FLAGS ${ANDROID_${target}_C_FLAGS} CACHE PATH "")
+  set(BUILTINS_${target}-linux-android_CMAKE_C_FLAGS ${ANDROID_${target}_C_FLAGS} CACHE PATH "")
+  set(BUILTINS_${target}-linux-android_CMAKE_SYSROOT ${ANDROID_${target}_SYSROOT} CACHE PATH "")
+  set(BUILTINS_${target}-linux-android_CMAKE_EXE_LINKER_FLAGS ${ANDROID_${target}_LINKER_FLAGS} CACHE PATH "")
+  set(BUILTINS_${target}-linux-android_CMAKE_SHARED_LINKER_FLAGS ${ANDROID_${target}_LINKER_FLAGS} CACHE PATH "")
+  set(BUILTINS_${target}-linux-android_CMAKE_MOUDLE_LINKER_FLAGS ${ANDROID_${target}_LINKER_FLAGS} CACHE PATH "")
+endforeach()
+
+
+set(LLVM_RUNTIME_TARGETS "i686-linux-android;x86_64-linux-android;aarch64-linux-android;armv7-linux-android" CACHE STRING "")
+foreach(target i686;x86_64;aarch64;armv7)
+  set(RUNTIMES_${target}-linux-android_ANDROID 1 CACHE STRING "")
+  set(RUNTIMES_${target}-linux-android_CMAKE_ASM_FLAGS ${ANDROID_${target}_C_FLAGS} CACHE PATH "")
+  set(RUNTIMES_${target}-linux-android_CMAKE_BUILD_TYPE RELEASE CACHE STRING "")
+  set(RUNTIMES_${target}-linux-android_CMAKE_C_FLAGS ${ANDROID_${target}_C_FLAGS} CACHE PATH "")
+  set(RUNTIMES_${target}-linux-android_CMAKE_CXX_FLAGS ${ANDROID_${target}_CXX_FLAGS} CACHE PATH "")
+  set(RUNTIMES_${target}-linux-android_CMAKE_SYSROOT ${ANDROID_${target}_SYSROOT} CACHE PATH "")
+  set(RUNTIMES_${target}-linux-android_CMAKE_EXE_LINKER_FLAGS ${ANDROID_${target}_LINKER_FLAGS} CACHE PATH "")
+  set(RUNTIMES_${target}-linux-android_CMAKE_SHARED_LINKER_FLAGS ${ANDROID_${target}_LINKER_FLAGS} CACHE PATH "")
+  set(RUNTIMES_${target}-linux-android_CMAKE_MOUDLE_LINKER_FLAGS ${ANDROID_${target}_LINKER_FLAGS} CACHE PATH "")
+  set(RUNTIMES_${target}-linux-android_COMPILER_RT_ENABLE_WERROR ON CACHE BOOL "")
+  set(RUNTIMES_${target}-linux-android_COMPILER_RT_TEST_COMPILER_CFLAGS ${ANDROID_${target}_C_FLAGS} CACHE PATH "")
+  set(RUNTIMES_${target}-linux-android_COMPILER_RT_INCLUDE_TESTS OFF CACHE BOOL "")
+  

[PATCH] D35574: Convert attribute 'target' parsing from a 'pair' to a 'struct' to make further improvements easier

2017-07-18 Thread Eric Christopher via Phabricator via cfe-commits
echristo accepted this revision.
echristo added a comment.
This revision is now accepted and ready to land.

LGTM.


https://reviews.llvm.org/D35574



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


[PATCH] D35573: Improve SEMA for attribute-target

2017-07-18 Thread Eric Christopher via Phabricator via cfe-commits
echristo accepted this revision.
echristo added a comment.
This revision is now accepted and ready to land.

LGTM pending dependency approval


https://reviews.llvm.org/D35573



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


[PATCH] D35572: Add isValidCPUName and isValidFeature to TargetInfo

2017-07-18 Thread Eric Christopher via Phabricator via cfe-commits
echristo added a comment.

Can you update the code in CGBuiltin to use this as part of this patch? :)

Thanks!


https://reviews.llvm.org/D35572



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


r308340 - Add GCC's noexcept-type alias for c++1z-compat-mangling

2017-07-18 Thread Raphael Isemann via cfe-commits
Author: teemperor
Date: Tue Jul 18 11:52:58 2017
New Revision: 308340

URL: http://llvm.org/viewvc/llvm-project?rev=308340=rev
Log:
Add GCC's noexcept-type alias for c++1z-compat-mangling

Summary: GCC has named this `-Wnoexcept-type`, so let's add an alias to stay 
compatible with the GCC flags.

Reviewers: rsmith, dexonsmith

Reviewed By: dexonsmith

Subscribers: cfe-commits, karies, v.g.vassilev, ahatanak

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

Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/test/SemaCXX/cxx1z-noexcept-function-type.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=308340=308339=308340=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Tue Jul 18 11:52:58 2017
@@ -152,6 +152,8 @@ def GNUFoldingConstant : DiagGroup<"gnu-
 def FormatExtraArgs : DiagGroup<"format-extra-args">;
 def FormatZeroLength : DiagGroup<"format-zero-length">;
 def CXX1zCompatMangling : DiagGroup<"c++1z-compat-mangling">;
+// Name of this warning in GCC.
+def NoexceptType : DiagGroup<"noexcept-type", [CXX1zCompatMangling]>;
 
 // Warnings for C++1y code which is not compatible with prior C++ standards.
 def CXXPre14Compat : DiagGroup<"c++98-c++11-compat">;

Modified: cfe/trunk/test/SemaCXX/cxx1z-noexcept-function-type.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx1z-noexcept-function-type.cpp?rev=308340=308339=308340=diff
==
--- cfe/trunk/test/SemaCXX/cxx1z-noexcept-function-type.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx1z-noexcept-function-type.cpp Tue Jul 18 11:52:58 
2017
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -std=c++14 -verify -fexceptions -fcxx-exceptions %s
 // RUN: %clang_cc1 -std=c++1z -verify -fexceptions -fcxx-exceptions %s 
-Wno-dynamic-exception-spec
 // RUN: %clang_cc1 -std=c++14 -verify -fexceptions -fcxx-exceptions 
-Wno-c++1z-compat-mangling -DNO_COMPAT_MANGLING %s
+// RUN: %clang_cc1 -std=c++14 -verify -fexceptions -fcxx-exceptions 
-Wno-noexcept-type -DNO_COMPAT_MANGLING %s
 
 #if __cplusplus > 201402L
 


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


[PATCH] D34654: Allow passing a regex for headers to exclude from clang-tidy

2017-07-18 Thread Todd Lipcon via Phabricator via cfe-commits
toddlipcon updated this revision to Diff 107148.
toddlipcon added a comment.

Regenerated patch with full context


Repository:
  rL LLVM

https://reviews.llvm.org/D34654

Files:
  clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tidy/ClangTidyDiagnosticConsumer.h
  clang-tidy/ClangTidyOptions.cpp
  clang-tidy/ClangTidyOptions.h
  clang-tidy/tool/ClangTidyMain.cpp
  docs/clang-tidy/index.rst
  test/clang-tidy/file-filter.cpp

Index: test/clang-tidy/file-filter.cpp
===
--- test/clang-tidy/file-filter.cpp
+++ test/clang-tidy/file-filter.cpp
@@ -9,6 +9,7 @@
 //   file-filter\header*.h due to code order between '/' and '\\'.
 // RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='.*' -system-headers %s -- -I %S/Inputs/file-filter/system/.. -isystem %S/Inputs/file-filter/system 2>&1 | FileCheck --check-prefix=CHECK4 %s
 // RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='.*' -system-headers -quiet %s -- -I %S/Inputs/file-filter/system/.. -isystem %S/Inputs/file-filter/system 2>&1 | FileCheck --check-prefix=CHECK4-QUIET %s
+// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='.*' -exclude-header-filter='header1\.h' %s -- -I %S/Inputs/file-filter -isystem %S/Inputs/file-filter/system 2>&1 | FileCheck --check-prefix=CHECK5 %s
 
 #include "header1.h"
 // CHECK-NOT: warning:
@@ -19,6 +20,7 @@
 // CHECK3-QUIET-NOT: warning:
 // CHECK4: header1.h:1:12: warning: single-argument constructors
 // CHECK4-QUIET: header1.h:1:12: warning: single-argument constructors
+// CHECK5-NOT: warning:
 
 #include "header2.h"
 // CHECK-NOT: warning:
@@ -29,6 +31,7 @@
 // CHECK3-QUIET: header2.h:1:12: warning: single-argument constructors
 // CHECK4: header2.h:1:12: warning: single-argument constructors
 // CHECK4-QUIET: header2.h:1:12: warning: single-argument constructors
+// CHECK5: header2.h:1:12: warning: single-argument constructors
 
 #include 
 // CHECK-NOT: warning:
@@ -39,6 +42,7 @@
 // CHECK3-QUIET-NOT: warning:
 // CHECK4: system-header.h:1:12: warning: single-argument constructors
 // CHECK4-QUIET: system-header.h:1:12: warning: single-argument constructors
+// CHECK5-NOT: warning:
 
 class A { A(int); };
 // CHECK: :[[@LINE-1]]:11: warning: single-argument constructors
@@ -49,6 +53,7 @@
 // CHECK3-QUIET: :[[@LINE-6]]:11: warning: single-argument constructors
 // CHECK4: :[[@LINE-7]]:11: warning: single-argument constructors
 // CHECK4-QUIET: :[[@LINE-8]]:11: warning: single-argument constructors
+// CHECK5: :[[@LINE-9]]:11: warning: single-argument constructors
 
 // CHECK-NOT: warning:
 // CHECK-QUIET-NOT: warning:
@@ -58,9 +63,10 @@
 // CHECK3-QUIET-NOT: warning:
 // CHECK4-NOT: warning:
 // CHECK4-QUIET-NOT: warning:
+// CHECK5-NOT: warning:
 
 // CHECK: Suppressed 3 warnings (3 in non-user code)
-// CHECK: Use -header-filter=.* to display errors from all non-system headers.
+// CHECK: Use -header-filter=.* -exclude-header-filter='' to display errors from all non-system headers.
 // CHECK-QUIET-NOT: Suppressed
 // CHECK2: Suppressed 1 warnings (1 in non-user code)
 // CHECK2: Use -header-filter=.* {{.*}}
@@ -71,3 +77,5 @@
 // CHECK4-NOT: Suppressed {{.*}} warnings
 // CHECK4-NOT: Use -header-filter=.* {{.*}}
 // CHECK4-QUIET-NOT: Suppressed
+// CHECK5: Suppressed 2 warnings (2 in non-user code)
+// CHECK5: Use -header-filter=.* {{.*}}
Index: docs/clang-tidy/index.rst
===
--- docs/clang-tidy/index.rst
+++ docs/clang-tidy/index.rst
@@ -240,6 +240,7 @@
   Checks:  '-*,some-check'
   WarningsAsErrors: ''
   HeaderFilterRegex: ''
+  ExcludeHeaderFilterRegex: ''
   AnalyzeTemporaryDtors: false
   FormatStyle: none
   User:user
Index: clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tidy/tool/ClangTidyMain.cpp
@@ -40,6 +40,7 @@
 Checks:  '-*,some-check'
 WarningsAsErrors: ''
 HeaderFilterRegex: ''
+ExcludeHeaderFilterRegex: ''
 AnalyzeTemporaryDtors: false
 FormatStyle: none
 User:user
@@ -89,6 +90,19 @@
  cl::init(""),
  cl::cat(ClangTidyCategory));
 
+static cl::opt
+ExcludeHeaderFilter("exclude-header-filter", cl::desc(R"(
+Regular expression matching the names of the
+headers to exclude when outputting diagnostics.
+Diagnostics from the main file of each translation
+unit are always displayed.
+Can be used together with -line-filter.
+This option overrides the 'ExcludeHeaderFilter' option
+in .clang-tidy file, if any.
+)"),
+ cl::init(""),
+ cl::cat(ClangTidyCategory));
+
 static cl::opt
 SystemHeaders("system-headers",
   cl::desc("Display 

[PATCH] D35329: [clang-reorder-fields] Enable reordering for plain C structs

2017-07-18 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexshap updated this revision to Diff 107143.
alexshap added a comment.

update the comments


Repository:
  rL LLVM

https://reviews.llvm.org/D35329

Files:
  clang-reorder-fields/ReorderFieldsAction.cpp
  test/clang-reorder-fields/PlainCStructFieldsOrder.c

Index: test/clang-reorder-fields/PlainCStructFieldsOrder.c
===
--- test/clang-reorder-fields/PlainCStructFieldsOrder.c
+++ test/clang-reorder-fields/PlainCStructFieldsOrder.c
@@ -0,0 +1,14 @@
+// RUN: clang-reorder-fields -record-name Foo -fields-order z,w,y,x %s -- | FileCheck %s
+
+struct Foo {
+  const int* x; // CHECK:  {{^  double z;}}
+  int y;// CHECK-NEXT: {{^  int w;}}
+  double z; // CHECK-NEXT: {{^  int y;}}
+  int w;// CHECK-NEXT: {{^  const int\* x}}
+};
+
+int main() {
+  const int x = 13;
+  struct Foo foo = { , 0, 1.29, 17 }; // CHECK: {{^  struct Foo foo = { 1.29, 17, 0,  };}} 
+  return 0;
+}
Index: clang-reorder-fields/ReorderFieldsAction.cpp
===
--- clang-reorder-fields/ReorderFieldsAction.cpp
+++ clang-reorder-fields/ReorderFieldsAction.cpp
@@ -32,10 +32,10 @@
 /// \brief Finds the definition of a record by name.
 ///
 /// \returns nullptr if the name is ambiguous or not found.
-static const CXXRecordDecl *findDefinition(StringRef RecordName,
-   ASTContext ) {
+static const RecordDecl *findDefinition(StringRef RecordName,
+ASTContext ) {
   auto Results = match(
-  recordDecl(hasName(RecordName), isDefinition()).bind("cxxRecordDecl"),
+  recordDecl(hasName(RecordName), isDefinition()).bind("recordDecl"),
   Context);
   if (Results.empty()) {
 llvm::errs() << "Definition of " << RecordName << "  not found\n";
@@ -46,14 +46,14 @@
  << " is ambiguous, several definitions found\n";
 return nullptr;
   }
-  return selectFirst("cxxRecordDecl", Results);
+  return selectFirst("recordDecl", Results);
 }
 
 /// \brief Calculates the new order of fields.
 ///
 /// \returns empty vector if the list of fields doesn't match the definition.
 static SmallVector
-getNewFieldsOrder(const CXXRecordDecl *Definition,
+getNewFieldsOrder(const RecordDecl *Definition,
   ArrayRef DesiredFieldsOrder) {
   assert(Definition && "Definition is null");
 
@@ -97,7 +97,7 @@
 /// different accesses (public/protected/private) is not supported.
 /// \returns true on success.
 static bool reorderFieldsInDefinition(
-const CXXRecordDecl *Definition, ArrayRef NewFieldsOrder,
+const RecordDecl *Definition, ArrayRef NewFieldsOrder,
 const ASTContext ,
 std::map ) {
   assert(Definition && "Definition is null");
@@ -223,25 +223,30 @@
   ReorderingConsumer =(const ReorderingConsumer &) = delete;
 
   void HandleTranslationUnit(ASTContext ) override {
-const CXXRecordDecl *RD = findDefinition(RecordName, Context);
+const RecordDecl *RD = findDefinition(RecordName, Context);
 if (!RD)
   return;
 SmallVector NewFieldsOrder =
 getNewFieldsOrder(RD, DesiredFieldsOrder);
 if (NewFieldsOrder.empty())
   return;
 if (!reorderFieldsInDefinition(RD, NewFieldsOrder, Context, Replacements))
   return;
-for (const auto *C : RD->ctors())
-  if (const auto *D = dyn_cast(C->getDefinition()))
-reorderFieldsInConstructor(cast(D),
-   NewFieldsOrder, Context, Replacements);
 
-// We only need to reorder init list expressions for aggregate types.
+// CXXRD will be nullptr if C code (not C++) is being processed.
+const CXXRecordDecl *CXXRD = dyn_cast(RD);
+if (CXXRD)
+  for (const auto *C : CXXRD->ctors())
+if (const auto *D = dyn_cast(C->getDefinition()))
+  reorderFieldsInConstructor(cast(D),
+  NewFieldsOrder, Context, Replacements);
+
+// We only need to reorder init list expressions for 
+// plain C structs or C++ aggregate types.
 // For other types the order of constructor parameters is used,
 // which we don't change at the moment.
 // Now (v0) partial initialization is not supported.
-if (RD->isAggregate())
+if (!CXXRD || CXXRD->isAggregate())
   for (auto Result :
match(initListExpr(hasType(equalsNode(RD))).bind("initListExpr"),
  Context))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r308333 - Don't set TUScope to null when generating a module in incremental processing mode.

2017-07-18 Thread Raphael Isemann via cfe-commits
Author: teemperor
Date: Tue Jul 18 11:24:42 2017
New Revision: 308333

URL: http://llvm.org/viewvc/llvm-project?rev=308333=rev
Log:
Don't set TUScope to null when generating a module in incremental processing 
mode.

Summary: When in incremental processing mode, we should never set `TUScope` to 
a nullptr otherwise any future lookups fail. We already have similar checks in 
the rest of the code, but we never hit this one because so far we didn't try to 
generate a module from the AST that Cling generates.

Reviewers: rsmith, v.g.vassilev

Reviewed By: v.g.vassilev

Subscribers: cfe-commits, v.g.vassilev

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

Modified:
cfe/trunk/lib/Sema/Sema.cpp

Modified: cfe/trunk/lib/Sema/Sema.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=308333=308332=308333=diff
==
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Tue Jul 18 11:24:42 2017
@@ -850,7 +850,8 @@ void Sema::ActOnEndOfTranslationUnit() {
 emitAndClearUnusedLocalTypedefWarnings();
 
 // Modules don't need any of the checking below.
-TUScope = nullptr;
+if (!PP.isIncrementalProcessingEnabled())
+  TUScope = nullptr;
 return;
   }
 


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


[PATCH] D35514: [CMake] Use MATCHES for regular expression comparison.

2017-07-18 Thread Petr Hosek via Phabricator via cfe-commits
phosek accepted this revision.
phosek added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rL LLVM

https://reviews.llvm.org/D35514



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


[PATCH] D35329: [clang-reorder-fields] Enable reordering for plain C structs

2017-07-18 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-reorder-fields/ReorderFieldsAction.cpp:236
+
+// CXXRD will be nullptr if C code (not C++) is being processed 
+const CXXRecordDecl *CXXRD = dyn_cast(RD);

Nit:  missing a trailing `.`.

I think we could use `Context.getLangOpts()` to determine whether the file 
being processed is C or C++. Use early return If the code is C.


Repository:
  rL LLVM

https://reviews.llvm.org/D35329



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


[PATCH] D35520: [Sema] Improve diagnostic message for unavailable c++17 aligned allocation functions

2017-07-18 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 107140.
ahatanak marked 6 inline comments as done.
ahatanak added a comment.

Address review comments.


https://reviews.llvm.org/D35520

Files:
  include/clang/Basic/AlignedAllocation.h
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Driver/ToolChains/Darwin.cpp
  lib/Sema/SemaExprCXX.cpp
  test/SemaCXX/unavailable_aligned_allocation.cpp

Index: test/SemaCXX/unavailable_aligned_allocation.cpp
===
--- test/SemaCXX/unavailable_aligned_allocation.cpp
+++ test/SemaCXX/unavailable_aligned_allocation.cpp
@@ -1,6 +1,12 @@
 // 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 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
+// RUN: %clang_cc1 -triple arm64-apple-tvos10.0.0 -fexceptions -std=c++1z -verify -DNO_ERRORS %s
+// RUN: %clang_cc1 -triple armv7k-apple-watchos3.0.0 -fexceptions -faligned-alloc-unavailable -std=c++1z -verify -DWATCHOS %s
+// RUN: %clang_cc1 -triple armv7k-apple-watchos3.0.0 -fexceptions -std=c++1z -verify -DNO_ERRORS %s
 
 namespace std {
   typedef decltype(sizeof(0)) size_t;
@@ -56,44 +62,68 @@
 #ifdef NO_ERRORS
 // expected-no-diagnostics
 #else
-// expected-error@-16 {{aligned allocation function of type 'void *(unsigned long, enum std::align_val_t)' possibly unavailable on}}
+// expected-error@-16 {{aligned allocation function of type 'void *(unsigned long, enum std::align_val_t)' is only available on}}
 // expected-note@-17 {{if you supply your own aligned allocation functions}}
-// expected-error@-18 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' possibly unavailable on}}
+// expected-error@-18 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is only available on}}
 // expected-note@-19 {{if you supply your own aligned allocation functions}}
 
-// expected-error@-20 {{aligned allocation function of type 'void *(unsigned long, enum std::align_val_t)' possibly unavailable on}}
+// expected-error@-20 {{aligned allocation function of type 'void *(unsigned long, enum std::align_val_t)' is only available on}}
 // expected-note@-21 {{if you supply your own aligned allocation functions}}
-// expected-error@-22 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' possibly unavailable on}}
+// expected-error@-22 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is only available on}}
 // expected-note@-23 {{if you supply your own aligned allocation functions}}
 
-// expected-error@-24 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' possibly unavailable on}}
+// expected-error@-24 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is only available on}}
 // expected-note@-25 {{if you supply your own aligned allocation functions}}
 
-// expected-error@-26 {{aligned allocation function of type 'void *(std::size_t, std::align_val_t, const std::nothrow_t &) noexcept' possibly unavailable on}}
+// expected-error@-26 {{aligned allocation function of type 'void *(std::size_t, std::align_val_t, const std::nothrow_t &) noexcept' is only available on}}
 // expected-note@-27 {{if you supply your own aligned allocation functions}}
-// expected-error@-28 {{aligned deallocation function of type 'void (void *, std::align_val_t, const std::nothrow_t &) noexcept' possibly unavailable on}}
+// expected-error@-28 {{aligned deallocation function of type 'void (void *, std::align_val_t, const std::nothrow_t &) noexcept' is only available on}}
 // expected-note@-29 {{if you supply your own aligned allocation functions}}
 
-// expected-error@-29 {{aligned allocation function of type 'void *(unsigned long, enum std::align_val_t)' possibly unavailable on}}
+// expected-error@-29 {{aligned allocation function of type 'void *(unsigned long, enum std::align_val_t)' is only available on}}
 // expected-note@-30 {{if you supply your own aligned allocation functions}}
-// expected-error@-31 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' possibly unavailable on}}
+// expected-error@-31 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is only available on}}
 // expected-note@-32 {{if you supply your own aligned allocation functions}}
 

[PATCH] D35559: [CMake][Modules] Tweak Modules-unfriendly builds

2017-07-18 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

I know Richard Smith has a modules buildbot - so I'm curious: How is it working 
without these changes? Are these changes an effort to broaden the coverage of 
modular self hosting builds (what's the current coverage? (only LLVM proper) 
what's the new coverage? (all LLVM subprojects?))


Repository:
  rL LLVM

https://reviews.llvm.org/D35559



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


[PATCH] D35533: [Basic] Update CMakeLists.txt to handle Repo

2017-07-18 Thread don hinton via Phabricator via cfe-commits
hintonda added inline comments.



Comment at: lib/Basic/CMakeLists.txt:17
 
 macro(find_first_existing_vc_file out_var path)
   set(git_path "${path}/.git")

LLVM already has a version of find_first_existing_vc_file in 
llvm/include/llvm/Support/CMakelists.txt.

Would it make sense move it to an llvm module and reuse it in clang?


https://reviews.llvm.org/D35533



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


[PATCH] D35012: [refactor] Add the AST source selection component

2017-07-18 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman updated this revision to Diff 107138.
arphaman added a comment.

rm early exit bug


Repository:
  rL LLVM

https://reviews.llvm.org/D35012

Files:
  include/clang/AST/LexicallyOrderedRecursiveASTVisitor.h
  include/clang/Basic/SourceLocation.h
  include/clang/Basic/SourceManager.h
  include/clang/Tooling/Refactoring/ASTSelection.h
  lib/Tooling/Refactoring/ASTSelection.cpp
  lib/Tooling/Refactoring/CMakeLists.txt
  unittests/Tooling/ASTSelectionTest.cpp
  unittests/Tooling/CMakeLists.txt
  unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp

Index: unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp
===
--- /dev/null
+++ unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp
@@ -0,0 +1,141 @@
+//===- unittest/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp ---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "TestVisitor.h"
+#include "clang/AST/LexicallyOrderedRecursiveASTVisitor.h"
+#include 
+
+using namespace clang;
+
+namespace {
+
+class DummyMatchVisitor;
+
+class LexicallyOrderedDeclVisitor
+: public LexicallyOrderedRecursiveASTVisitor {
+public:
+  LexicallyOrderedDeclVisitor(DummyMatchVisitor ,
+  const SourceManager )
+  : LexicallyOrderedRecursiveASTVisitor(SM), Matcher(Matcher) {}
+
+  bool TraverseDecl(Decl *D) {
+TraversalStack.push_back(D);
+LexicallyOrderedRecursiveASTVisitor::TraverseDecl(D);
+TraversalStack.pop_back();
+return true;
+  }
+
+  bool VisitNamedDecl(const NamedDecl *D);
+
+private:
+  DummyMatchVisitor 
+  llvm::SmallVector TraversalStack;
+};
+
+class DummyMatchVisitor : public ExpectedLocationVisitor {
+public:
+  bool VisitTranslationUnitDecl(TranslationUnitDecl *TU) {
+const ASTContext  = TU->getASTContext();
+const SourceManager  = Context.getSourceManager();
+LexicallyOrderedDeclVisitor SubVisitor(*this, SM);
+SubVisitor.TraverseDecl(TU);
+return false;
+  }
+
+  void match(StringRef Path, const Decl *D) { Match(Path, D->getLocStart()); }
+};
+
+bool LexicallyOrderedDeclVisitor::VisitNamedDecl(const NamedDecl *D) {
+  std::string Path;
+  llvm::raw_string_ostream OS(Path);
+  assert(TraversalStack.back() == D);
+  for (const Decl *D : TraversalStack) {
+if (isa(D)) {
+  OS << "/";
+  continue;
+}
+if (const auto *ND = dyn_cast(D))
+  OS << ND->getNameAsString();
+else
+  OS << "???";
+if (isa(D))
+  OS << "/";
+  }
+  Matcher.match(OS.str(), D);
+  return true;
+}
+
+TEST(LexicallyOrderedRecursiveASTVisitor, VisitDeclsInImplementation) {
+  StringRef Source = R"(
+@interface I
+@end
+@implementation I
+
+int nestedFunction() { }
+
+- (void) method{ }
+
+int anotherNestedFunction(int x) {
+  return x;
+}
+
+int innerVariable = 0;
+
+@end
+
+int outerVariable = 0;
+
+@implementation I(Cat)
+
+void catF() { }
+
+@end
+
+void outerFunction() { }
+)";
+  DummyMatchVisitor Visitor;
+  Visitor.DisallowMatch("/nestedFunction/", 6, 1);
+  Visitor.ExpectMatch("/I/nestedFunction/", 6, 1);
+  Visitor.ExpectMatch("/I/method/", 8, 1);
+  Visitor.DisallowMatch("/anotherNestedFunction/", 10, 1);
+  Visitor.ExpectMatch("/I/anotherNestedFunction/", 10, 1);
+  Visitor.DisallowMatch("/innerVariable", 14, 1);
+  Visitor.ExpectMatch("/I/innerVariable", 14, 1);
+  Visitor.ExpectMatch("/outerVariable", 18, 1);
+  Visitor.DisallowMatch("/catF/", 22, 1);
+  Visitor.ExpectMatch("/Cat/catF/", 22, 1);
+  Visitor.ExpectMatch("/outerFunction/", 26, 1);
+  EXPECT_TRUE(Visitor.runOver(Source, DummyMatchVisitor::Lang_OBJC));
+}
+
+TEST(LexicallyOrderedRecursiveASTVisitor, VisitMacroDeclsInImplementation) {
+  StringRef Source = R"(
+@interface I
+@end
+
+void outerFunction() { }
+
+#define MACRO_F(x) void nestedFunction##x() { }
+
+@implementation I
+
+MACRO_F(1)
+
+@end
+
+MACRO_F(2)
+)";
+  DummyMatchVisitor Visitor;
+  Visitor.ExpectMatch("/outerFunction/", 5, 1);
+  Visitor.ExpectMatch("/I/nestedFunction1/", 7, 20);
+  Visitor.ExpectMatch("/nestedFunction2/", 7, 20);
+  EXPECT_TRUE(Visitor.runOver(Source, DummyMatchVisitor::Lang_OBJC));
+}
+
+} // end anonymous namespace
Index: unittests/Tooling/CMakeLists.txt
===
--- unittests/Tooling/CMakeLists.txt
+++ unittests/Tooling/CMakeLists.txt
@@ -11,11 +11,13 @@
 endif()
 
 add_clang_unittest(ToolingTests
+  ASTSelectionTest.cpp
   CastExprTest.cpp
   CommentHandlerTest.cpp
   CompilationDatabaseTest.cpp
   DiagnosticsYamlTest.cpp
   FixItTest.cpp
+  LexicallyOrderedRecursiveASTVisitorTest.cpp
   LookupTest.cpp
   QualTypeNamesTest.cpp
   RecursiveASTVisitorTest.cpp
Index: unittests/Tooling/ASTSelectionTest.cpp

[PATCH] D35573: Improve SEMA for attribute-target

2017-07-18 Thread Erich Keane via Phabricator via cfe-commits
erichkeane created this revision.

Add more diagnosis for the non-multiversioning case.


https://reviews.llvm.org/D35573

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/Sema/SemaDeclAttr.cpp
  test/Sema/attr-target.c

Index: test/Sema/attr-target.c
===
--- test/Sema/attr-target.c
+++ test/Sema/attr-target.c
@@ -2,7 +2,13 @@
 
 int __attribute__((target("avx,sse4.2,arch=ivybridge"))) foo() { return 4; }
 int __attribute__((target())) bar() { return 4; } //expected-error {{'target' attribute takes one argument}}
-int __attribute__((target("tune=sandybridge"))) baz() { return 4; } //expected-warning {{Ignoring unsupported 'tune=' in the target attribute string}}
-int __attribute__((target("fpmath=387"))) walrus() { return 4; } //expected-warning {{Ignoring unsupported 'fpmath=' in the target attribute string}}
+int __attribute__((target("tune=sandybridge"))) baz() { return 4; } //expected-warning {{ignoring unsupported 'tune=' in the target attribute string}}
+int __attribute__((target("fpmath=387"))) walrus() { return 4; } //expected-warning {{ignoring unsupported 'fpmath=' in the target attribute string}}
+int __attribute__((target("avx,sse4.2,arch=hiss"))) meow() {  return 4; }//expected-warning {{ignoring unsupported architecture 'hiss' in the target attribute string}}
+int __attribute__((target("woof"))) bark() {  return 4; }//expected-warning {{ignoring unsupported 'woof' in the target attribute string}}
+int __attribute__((target("arch="))) turtle() { return 4; } // no warning, same as saying 'nothing'.
+int __attribute__((target("arch=hiss,arch=woof"))) pine_tree() { return 4; } //expected-warning {{ignoring unsupported architecture 'hiss' in the target attribute string}}
+int __attribute__((target("arch=ivybridge,arch=haswell"))) oak_tree() { return 4; } //expected-warning {{ignoring duplicate 'arch=' in the target attribute string}}
+
 
 
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -2993,22 +2993,43 @@
 D->addAttr(NewAttr);
 }
 
-// Check for things we'd like to warn about, no errors or validation for now.
-// TODO: Validation should use a backend target library that specifies
-// the allowable subtarget features and cpus. We could use something like a
-// TargetCodeGenInfo hook here to do validation.
-void Sema::checkTargetAttr(SourceLocation LiteralLoc, StringRef AttrStr) {
+// Check for things we'd like to warn about. Multiversioning issues are
+// handled later in the process, once we know how many exist.
+bool Sema::checkTargetAttr(SourceLocation LiteralLoc, StringRef AttrStr) {
+  enum FirstParam { Unsupported, Duplicate };
+  enum SecondParam { None, Architecture };
   for (auto Str : {"tune=", "fpmath="})
 if (AttrStr.find(Str) != StringRef::npos)
-  Diag(LiteralLoc, diag::warn_unsupported_target_attribute) << Str;
+  return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
+ << Unsupported << None << Str;
+
+  TargetAttr::ParsedTargetAttr ParsedAttrs = TargetAttr::parse(AttrStr);
+
+  if (!ParsedAttrs.Architecture.empty() &&
+  !Context.getTargetInfo().isValidCPUName(ParsedAttrs.Architecture))
+return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
+   << Unsupported << Architecture << ParsedAttrs.Architecture;
+
+  if (ParsedAttrs.DuplicateArchitecture)
+return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
+   << Duplicate << None << "arch=";
+
+  for (const auto  : ParsedAttrs.Features) {
+auto CurFeature = StringRef(Feature).drop_front(); // remove + or -.
+if (!Context.getTargetInfo().isValidFeatureName(CurFeature))
+  return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
+ << Unsupported << None << CurFeature;
+  }
+
+  return true;
 }
 
 static void handleTargetAttr(Sema , Decl *D, const AttributeList ) {
   StringRef Str;
   SourceLocation LiteralLoc;
-  if (!S.checkStringLiteralArgumentAttr(Attr, 0, Str, ))
+  if (!S.checkStringLiteralArgumentAttr(Attr, 0, Str, ) ||
+  !S.checkTargetAttr(LiteralLoc, Str))
 return;
-  S.checkTargetAttr(LiteralLoc, Str);
   unsigned Index = Attr.getAttributeSpellingListIndex();
   TargetAttr *NewAttr =
   ::new (S.Context) TargetAttr(Attr.getRange(), S.Context, Str, Index);
Index: include/clang/Sema/Sema.h
===
--- include/clang/Sema/Sema.h
+++ include/clang/Sema/Sema.h
@@ -3271,7 +3271,7 @@
   unsigned ArgNum, StringRef ,
   SourceLocation *ArgLocation = nullptr);
   bool checkSectionName(SourceLocation LiteralLoc, StringRef Str);
-  void checkTargetAttr(SourceLocation LiteralLoc, StringRef Str);
+  bool checkTargetAttr(SourceLocation LiteralLoc, StringRef Str);
   

[PATCH] D35574: Convert attribute 'target' parsing from a 'pair' to a 'struct' to make further improvements easier

2017-07-18 Thread Erich Keane via Phabricator via cfe-commits
erichkeane created this revision.

The attribute 'target' parse function previously returned a pair.  Convert this 
to a 'pair' in order to add more functionality, and improve usability.


https://reviews.llvm.org/D35574

Files:
  include/clang/Basic/Attr.td
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CodeGenModule.cpp


Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -4499,18 +4499,19 @@
 
 // Make a copy of the features as passed on the command line into the
 // beginning of the additional features from the function to override.
-ParsedAttr.first.insert(ParsedAttr.first.begin(),
+ParsedAttr.Features.insert(ParsedAttr.Features.begin(),
 Target.getTargetOpts().FeaturesAsWritten.begin(),
 Target.getTargetOpts().FeaturesAsWritten.end());
 
-if (ParsedAttr.second != "")
-  TargetCPU = ParsedAttr.second;
+if (ParsedAttr.Architecture != "")
+  TargetCPU = ParsedAttr.Architecture ;
 
 // Now populate the feature map, first with the TargetCPU which is either
 // the default or a new one from the target attribute string. Then we'll 
use
 // the passed in features (FeaturesAsWritten) along with the new ones from
 // the attribute.
-Target.initFeatureMap(FeatureMap, getDiags(), TargetCPU, ParsedAttr.first);
+Target.initFeatureMap(FeatureMap, getDiags(), TargetCPU,
+  ParsedAttr.Features);
   } else {
 Target.initFeatureMap(FeatureMap, getDiags(), TargetCPU,
   Target.getTargetOpts().Features);
Index: lib/CodeGen/CGCall.cpp
===
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -1877,8 +1877,8 @@
   // the function.
   const auto *TD = FD->getAttr();
   TargetAttr::ParsedTargetAttr ParsedAttr = TD->parse();
-  if (ParsedAttr.second != "")
-TargetCPU = ParsedAttr.second;
+  if (ParsedAttr.Architecture != "")
+TargetCPU = ParsedAttr.Architecture;
   if (TargetCPU != "")
 FuncAttrs.addAttribute("target-cpu", TargetCPU);
   if (!Features.empty()) {
Index: include/clang/Basic/Attr.td
===
--- include/clang/Basic/Attr.td
+++ include/clang/Basic/Attr.td
@@ -1802,11 +1802,18 @@
   let Subjects = SubjectList<[Function], ErrorDiag>;
   let Documentation = [TargetDocs];
   let AdditionalMembers = [{
-typedef std::pair ParsedTargetAttr;
+struct ParsedTargetAttr {
+  std::vector Features;
+  StringRef Architecture;
+  bool DuplicateArchitecture = false;
+};
 ParsedTargetAttr parse() const {
+  return parse(getFeaturesStr());
+}
+static ParsedTargetAttr parse(StringRef Features) {
   ParsedTargetAttr Ret;
   SmallVector AttrFeatures;
-  getFeaturesStr().split(AttrFeatures, ",");
+  Features.split(AttrFeatures, ",");
 
   // Grab the various features and prepend a "+" to turn on the feature to
   // the backend and add them to our existing set of features.
@@ -1823,12 +1830,15 @@
  continue;
 
 // While we're here iterating check for a different target cpu.
-if (Feature.startswith("arch="))
-  Ret.second = Feature.split("=").second.trim();
-else if (Feature.startswith("no-"))
-  Ret.first.push_back("-" + Feature.split("-").second.str());
+if (Feature.startswith("arch=")) {
+  if (!Ret.Architecture.empty())
+Ret.DuplicateArchitecture = true;
+  else
+Ret.Architecture = Feature.split("=").second.trim();
+} else if (Feature.startswith("no-"))
+  Ret.Features.push_back("-" + Feature.split("-").second.str());
 else
-  Ret.first.push_back("+" + Feature.str());
+  Ret.Features.push_back("+" + Feature.str());
   }
   return Ret;
 }


Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -4499,18 +4499,19 @@
 
 // Make a copy of the features as passed on the command line into the
 // beginning of the additional features from the function to override.
-ParsedAttr.first.insert(ParsedAttr.first.begin(),
+ParsedAttr.Features.insert(ParsedAttr.Features.begin(),
 Target.getTargetOpts().FeaturesAsWritten.begin(),
 Target.getTargetOpts().FeaturesAsWritten.end());
 
-if (ParsedAttr.second != "")
-  TargetCPU = ParsedAttr.second;
+if (ParsedAttr.Architecture != "")
+  TargetCPU = ParsedAttr.Architecture ;
 
 // Now populate the feature map, first with the TargetCPU which is either
 // the default or a new one from the target 

[PATCH] D35572: Add isValidCPUName and isValidFeature to TargetInfo

2017-07-18 Thread Erich Keane via Phabricator via cfe-commits
erichkeane created this revision.

These two functions are really useful for implementations of attributes 
(including attribute-target), so add the functionality.


https://reviews.llvm.org/D35572

Files:
  include/clang/Basic/TargetInfo.h
  lib/Basic/Targets.cpp

Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -963,8 +963,8 @@
   //  401, 403, 405, 405fp, 440fp, 464, 464fp, 476, 476fp, 505, 740, 801,
   //  821, 823, 8540, 8548, e300c2, e300c3, e500mc64, e6500, 860, cell,
   //  titan, rs64.
-  bool setCPU(const std::string ) override {
-bool CPUKnown = llvm::StringSwitch(Name)
+  bool isValidCPUName(StringRef Name) const override {
+return llvm::StringSwitch(Name)
   .Case("generic", true)
   .Case("440", true)
   .Case("450", true)
@@ -1014,10 +1014,12 @@
   .Case("powerpc64le", true)
   .Case("ppc64le", true)
   .Default(false);
+  }
 
+  bool setCPU(const std::string ) override {
+bool CPUKnown = isValidCPUName(Name);
 if (CPUKnown)
   CPU = Name;
-
 return CPUKnown;
   }
 
@@ -2006,6 +2008,9 @@
 // FIXME: implement
 return TargetInfo::CharPtrBuiltinVaList;
   }
+  bool isValidCPUName(StringRef Name) const override {
+return StringToCudaArch(Name) != CudaArch::UNKNOWN;
+  }
   bool setCPU(const std::string ) override {
 GPU = StringToCudaArch(Name);
 return GPU != CudaArch::UNKNOWN;
@@ -2367,6 +2372,13 @@
   .Default(GK_NONE);
   }
 
+  bool isValidCPUName(StringRef Name) const override {
+if (getTriple().getArch() == llvm::Triple::amdgcn)
+  return GK_NONE !=  parseAMDGCNName(Name);
+else
+  return GK_NONE !=  parseR600Name(Name);
+  }
+
   bool setCPU(const std::string ) override {
 if (getTriple().getArch() == llvm::Triple::amdgcn)
   GPU = parseAMDGCNName(Name);
@@ -2873,6 +2885,87 @@
 //@}
   } CPU = CK_Generic;
 
+  bool checkCPUKind(CPUKind Kind) const {
+// Perform any per-CPU checks necessary to determine if this CPU is
+// acceptable.
+// FIXME: This results in terrible diagnostics. Clang just says the CPU is
+// invalid without explaining *why*.
+switch (Kind) {
+case CK_Generic:
+  // No processor selected!
+  return false;
+
+case CK_i386:
+case CK_i486:
+case CK_WinChipC6:
+case CK_WinChip2:
+case CK_C3:
+case CK_i586:
+case CK_Pentium:
+case CK_PentiumMMX:
+case CK_i686:
+case CK_PentiumPro:
+case CK_Pentium2:
+case CK_Pentium3:
+case CK_Pentium3M:
+case CK_PentiumM:
+case CK_Yonah:
+case CK_C3_2:
+case CK_Pentium4:
+case CK_Pentium4M:
+case CK_Lakemont:
+case CK_Prescott:
+case CK_K6:
+case CK_K6_2:
+case CK_K6_3:
+case CK_Athlon:
+case CK_AthlonThunderbird:
+case CK_Athlon4:
+case CK_AthlonXP:
+case CK_AthlonMP:
+case CK_Geode:
+  // Only accept certain architectures when compiling in 32-bit mode.
+  if (getTriple().getArch() != llvm::Triple::x86)
+return false;
+
+  // Fallthrough
+case CK_Nocona:
+case CK_Core2:
+case CK_Penryn:
+case CK_Bonnell:
+case CK_Silvermont:
+case CK_Goldmont:
+case CK_Nehalem:
+case CK_Westmere:
+case CK_SandyBridge:
+case CK_IvyBridge:
+case CK_Haswell:
+case CK_Broadwell:
+case CK_SkylakeClient:
+case CK_SkylakeServer:
+case CK_Cannonlake:
+case CK_KNL:
+case CK_Athlon64:
+case CK_Athlon64SSE3:
+case CK_AthlonFX:
+case CK_K8:
+case CK_K8SSE3:
+case CK_Opteron:
+case CK_OpteronSSE3:
+case CK_AMDFAM10:
+case CK_BTVER1:
+case CK_BTVER2:
+case CK_BDVER1:
+case CK_BDVER2:
+case CK_BDVER3:
+case CK_BDVER4:
+case CK_ZNVER1:
+case CK_x86_64:
+  return true;
+}
+llvm_unreachable("Unhandled CPU kind");
+  }
+
   CPUKind getCPUKind(StringRef CPU) const {
 return llvm::StringSwitch(CPU)
 .Case("i386", CK_i386)
@@ -3053,6 +3146,7 @@
   initFeatureMap(llvm::StringMap , DiagnosticsEngine ,
  StringRef CPU,
  const std::vector ) const override;
+  bool isValidFeatureName(StringRef Name) const override;
   bool hasFeature(StringRef Feature) const override;
   bool handleTargetFeatures(std::vector ,
 DiagnosticsEngine ) override;
@@ -3066,87 +3160,13 @@
   return "no-mmx";
 return "";
   }
-  bool setCPU(const std::string ) override {
-CPU = getCPUKind(Name);
-
-// Perform any per-CPU checks necessary to determine if this CPU is
-// acceptable.
-// FIXME: This results in terrible diagnostics. Clang just says the CPU is
-// invalid without explaining *why*.
-switch (CPU) {
-case CK_Generic:
-  // No processor selected!
-  return false;
 
-case CK_i386:
-case CK_i486:
-case CK_WinChipC6:
-case CK_WinChip2:
-case CK_C3:
-case 

r308328 - Revert r308327

2017-07-18 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Tue Jul 18 10:36:42 2017
New Revision: 308328

URL: http://llvm.org/viewvc/llvm-project?rev=308328=rev
Log:
Revert r308327

I forgot to test clang-tools-extra which is now failing.

Removed:
cfe/trunk/test/PCH/suspicious-pragma-pack.c
cfe/trunk/test/Sema/Inputs/pragma-pack1.h
cfe/trunk/test/Sema/Inputs/pragma-pack2.h
cfe/trunk/test/Sema/suspicious-pragma-pack.c
cfe/trunk/test/SemaObjC/Inputs/empty.h
cfe/trunk/test/SemaObjC/suspicious-pragma-pack.m
Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/lib/Parse/ParsePragma.cpp
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/lib/Sema/SemaAttr.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/test/OpenMP/declare_simd_messages.cpp
cfe/trunk/test/PCH/pragma-pack.c
cfe/trunk/test/Parser/pragma-options.c
cfe/trunk/test/Parser/pragma-options.cpp
cfe/trunk/test/Parser/pragma-pack.c
cfe/trunk/test/Sema/pragma-pack.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=308328=308327=308328=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Tue Jul 18 10:36:42 2017
@@ -467,9 +467,8 @@ def IgnoredPragmaIntrinsic : DiagGroup<"
 def UnknownPragmas : DiagGroup<"unknown-pragmas">;
 def IgnoredPragmas : DiagGroup<"ignored-pragmas", [IgnoredPragmaIntrinsic]>;
 def PragmaClangAttribute : DiagGroup<"pragma-clang-attribute">;
-def PragmaPack : DiagGroup<"pragma-pack">;
 def Pragmas : DiagGroup<"pragmas", [UnknownPragmas, IgnoredPragmas,
-PragmaClangAttribute, PragmaPack]>;
+PragmaClangAttribute]>;
 def UnknownWarningOption : DiagGroup<"unknown-warning-option">;
 def NSobjectAttribute : DiagGroup<"NSObject-attribute">;
 def IndependentClassAttribute : DiagGroup<"IndependentClass-attribute">;

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=308328=308327=308328=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Jul 18 10:36:42 
2017
@@ -712,16 +712,6 @@ def err_pragma_options_align_mac68k_targ
 def warn_pragma_pack_invalid_alignment : Warning<
   "expected #pragma pack parameter to be '1', '2', '4', '8', or '16'">,
   InGroup;
-def warn_pragma_pack_non_default_at_include : Warning<
-  "non-default #pragma pack value might change the alignment of struct or "
-  "union members in the included file">, InGroup;
-def warn_pragma_pack_modified_after_include : Warning<
-  "the current #pragma pack aligment value is modified in the included "
-  "file">, InGroup;
-def warn_pragma_pack_no_pop_eof : Warning<"unterminated "
-  "'#pragma pack (push, ...)' at end of file">, InGroup;
-def note_pragma_pack_here : Note<
-  "previous '#pragma pack' directive that modifies alignment is here">;
 // Follow the Microsoft implementation.
 def warn_pragma_pack_show : Warning<"value of #pragma pack(show) == %0">;
 def warn_pragma_pack_pop_identifer_and_alignment : Warning<

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=308328=308327=308328=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Tue Jul 18 10:36:42 2017
@@ -208,7 +208,6 @@ namespace sema {
   class FunctionScopeInfo;
   class LambdaScopeInfo;
   class PossiblyUnreachableDiag;
-  class SemaPPCallbacks;
   class TemplateDeductionInfo;
 }
 
@@ -382,12 +381,11 @@ public:
   llvm::StringRef StackSlotLabel;
   ValueType Value;
   SourceLocation PragmaLocation;
-  SourceLocation PragmaPushLocation;
-  Slot(llvm::StringRef StackSlotLabel, ValueType Value,
-   SourceLocation PragmaLocation, SourceLocation PragmaPushLocation)
-  : StackSlotLabel(StackSlotLabel), Value(Value),
-PragmaLocation(PragmaLocation),
-PragmaPushLocation(PragmaPushLocation) {}
+  Slot(llvm::StringRef StackSlotLabel,
+   ValueType Value,
+   SourceLocation PragmaLocation)
+: StackSlotLabel(StackSlotLabel), Value(Value),
+  PragmaLocation(PragmaLocation) {}
 };
 void Act(SourceLocation PragmaLocation,
  PragmaMsStackAction Action,
@@ -418,8 +416,6 @@ public:
 explicit 

[PATCH] D34158: For standards compatibility, preinclude if the file is available

2017-07-18 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

OK folks, I was off the grid last week but I'm back now, and at my grindstone 
again.
I haven't received any comments since I updated the patch to remove the checks 
on "-nostdinc".  
Look OK to commit?
Many thanks for all your reviews
--Melanie


Repository:
  rL LLVM

https://reviews.llvm.org/D34158



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


[PATCH] D35533: [Basic] Update CMakeLists.txt to handle Repo

2017-07-18 Thread Jordan Rose via Phabricator via cfe-commits
jordan_rose added a comment.

As commented at https://reviews.llvm.org/D34955#798369, this isn't sufficient 
because it doesn't force a rebuild when new changes are merged in from 
upstream. It's not //harmful// to stick with the old version information, but 
if you can find something better that would be, um, better.


https://reviews.llvm.org/D35533



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


[PATCH] D35484: Add a warning for missing '#pragma pack (pop)' and suspicious '#pragma pack' uses when including files

2017-07-18 Thread Alex Lorenz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL308327: Add a warning for missing '#pragma pack (pop)' and 
suspicious uses (authored by arphaman).

Changed prior to commit:
  https://reviews.llvm.org/D35484?vs=107090=107130#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D35484

Files:
  cfe/trunk/include/clang/Basic/DiagnosticGroups.td
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/include/clang/Serialization/ASTReader.h
  cfe/trunk/lib/Parse/ParsePragma.cpp
  cfe/trunk/lib/Sema/Sema.cpp
  cfe/trunk/lib/Sema/SemaAttr.cpp
  cfe/trunk/lib/Serialization/ASTReader.cpp
  cfe/trunk/lib/Serialization/ASTWriter.cpp
  cfe/trunk/test/OpenMP/declare_simd_messages.cpp
  cfe/trunk/test/PCH/pragma-pack.c
  cfe/trunk/test/PCH/suspicious-pragma-pack.c
  cfe/trunk/test/Parser/pragma-options.c
  cfe/trunk/test/Parser/pragma-options.cpp
  cfe/trunk/test/Parser/pragma-pack.c
  cfe/trunk/test/Sema/Inputs/pragma-pack1.h
  cfe/trunk/test/Sema/Inputs/pragma-pack2.h
  cfe/trunk/test/Sema/pragma-pack.c
  cfe/trunk/test/Sema/suspicious-pragma-pack.c
  cfe/trunk/test/SemaObjC/Inputs/empty.h
  cfe/trunk/test/SemaObjC/suspicious-pragma-pack.m

Index: cfe/trunk/include/clang/Sema/Sema.h
===
--- cfe/trunk/include/clang/Sema/Sema.h
+++ cfe/trunk/include/clang/Sema/Sema.h
@@ -208,6 +208,7 @@
   class FunctionScopeInfo;
   class LambdaScopeInfo;
   class PossiblyUnreachableDiag;
+  class SemaPPCallbacks;
   class TemplateDeductionInfo;
 }
 
@@ -381,11 +382,12 @@
   llvm::StringRef StackSlotLabel;
   ValueType Value;
   SourceLocation PragmaLocation;
-  Slot(llvm::StringRef StackSlotLabel,
-   ValueType Value,
-   SourceLocation PragmaLocation)
-: StackSlotLabel(StackSlotLabel), Value(Value),
-  PragmaLocation(PragmaLocation) {}
+  SourceLocation PragmaPushLocation;
+  Slot(llvm::StringRef StackSlotLabel, ValueType Value,
+   SourceLocation PragmaLocation, SourceLocation PragmaPushLocation)
+  : StackSlotLabel(StackSlotLabel), Value(Value),
+PragmaLocation(PragmaLocation),
+PragmaPushLocation(PragmaPushLocation) {}
 };
 void Act(SourceLocation PragmaLocation,
  PragmaMsStackAction Action,
@@ -416,6 +418,8 @@
 explicit PragmaStack(const ValueType )
 : DefaultValue(Default), CurrentValue(Default) {}
 
+bool hasValue() const { return CurrentValue != DefaultValue; }
+
 SmallVector Stack;
 ValueType DefaultValue; // Value used for PSK_Reset action.
 ValueType CurrentValue;
@@ -437,6 +441,8 @@
   // Sentinel to represent when the stack is set to mac68k alignment.
   static const unsigned kMac68kAlignmentSentinel = ~0U;
   PragmaStack PackStack;
+  // The current #pragma pack values and locations at each #include.
+  SmallVector, 8> PackIncludeStack;
   // Segment #pragmas.
   PragmaStack DataSegStack;
   PragmaStack BSSSegStack;
@@ -8185,6 +8191,15 @@
   void ActOnPragmaPack(SourceLocation PragmaLoc, PragmaMsStackAction Action,
StringRef SlotLabel, Expr *Alignment);
 
+  enum class PragmaPackDiagnoseKind {
+NonDefaultStateAtInclude,
+ChangedStateAtExit
+  };
+
+  void DiagnoseNonDefaultPragmaPack(PragmaPackDiagnoseKind Kind,
+SourceLocation IncludeLoc);
+  void DiagnoseUnterminatedPragmaPack();
+
   /// ActOnPragmaMSStruct - Called on well formed \#pragma ms_struct [on|off].
   void ActOnPragmaMSStruct(PragmaMSStructKind Kind);
 
@@ -10378,6 +10393,12 @@
 
   IdentifierInfo *Ident_NSError = nullptr;
 
+  /// \brief The handler for the FileChanged preprocessor events.
+  ///
+  /// Used for diagnostics that implement custom semantic analysis for #include
+  /// directives, like -Wpragma-pack.
+  sema::SemaPPCallbacks *SemaPPCallbackHandler;
+
 protected:
   friend class Parser;
   friend class InitializationSequence;
Index: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td
@@ -467,8 +467,9 @@
 def UnknownPragmas : DiagGroup<"unknown-pragmas">;
 def IgnoredPragmas : DiagGroup<"ignored-pragmas", [IgnoredPragmaIntrinsic]>;
 def PragmaClangAttribute : DiagGroup<"pragma-clang-attribute">;
+def PragmaPack : DiagGroup<"pragma-pack">;
 def Pragmas : DiagGroup<"pragmas", [UnknownPragmas, IgnoredPragmas,
-PragmaClangAttribute]>;
+PragmaClangAttribute, PragmaPack]>;
 def UnknownWarningOption : DiagGroup<"unknown-warning-option">;
 def NSobjectAttribute : DiagGroup<"NSObject-attribute">;
 def IndependentClassAttribute : DiagGroup<"IndependentClass-attribute">;
Index: 

r308327 - Add a warning for missing '#pragma pack (pop)' and suspicious uses

2017-07-18 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Tue Jul 18 10:23:51 2017
New Revision: 308327

URL: http://llvm.org/viewvc/llvm-project?rev=308327=rev
Log:
Add a warning for missing '#pragma pack (pop)' and suspicious uses
of '#pragma pack' in included files

This commit adds a new -Wpragma-pack warning. It warns in the following cases:

- When a translation unit is missing terminating #pragma pack (pop) directives.
- When entering an included file if the current alignment value as determined
  by '#pragma pack' directives is different from the default alignment value.
- When leaving an included file that changed the state of the current alignment
  value.

rdar://10184173

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

Added:
cfe/trunk/test/PCH/suspicious-pragma-pack.c
cfe/trunk/test/Sema/Inputs/pragma-pack1.h
cfe/trunk/test/Sema/Inputs/pragma-pack2.h
cfe/trunk/test/Sema/suspicious-pragma-pack.c
cfe/trunk/test/SemaObjC/Inputs/empty.h
cfe/trunk/test/SemaObjC/suspicious-pragma-pack.m
Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/lib/Parse/ParsePragma.cpp
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/lib/Sema/SemaAttr.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/test/OpenMP/declare_simd_messages.cpp
cfe/trunk/test/PCH/pragma-pack.c
cfe/trunk/test/Parser/pragma-options.c
cfe/trunk/test/Parser/pragma-options.cpp
cfe/trunk/test/Parser/pragma-pack.c
cfe/trunk/test/Sema/pragma-pack.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=308327=308326=308327=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Tue Jul 18 10:23:51 2017
@@ -467,8 +467,9 @@ def IgnoredPragmaIntrinsic : DiagGroup<"
 def UnknownPragmas : DiagGroup<"unknown-pragmas">;
 def IgnoredPragmas : DiagGroup<"ignored-pragmas", [IgnoredPragmaIntrinsic]>;
 def PragmaClangAttribute : DiagGroup<"pragma-clang-attribute">;
+def PragmaPack : DiagGroup<"pragma-pack">;
 def Pragmas : DiagGroup<"pragmas", [UnknownPragmas, IgnoredPragmas,
-PragmaClangAttribute]>;
+PragmaClangAttribute, PragmaPack]>;
 def UnknownWarningOption : DiagGroup<"unknown-warning-option">;
 def NSobjectAttribute : DiagGroup<"NSObject-attribute">;
 def IndependentClassAttribute : DiagGroup<"IndependentClass-attribute">;

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=308327=308326=308327=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Jul 18 10:23:51 
2017
@@ -712,6 +712,16 @@ def err_pragma_options_align_mac68k_targ
 def warn_pragma_pack_invalid_alignment : Warning<
   "expected #pragma pack parameter to be '1', '2', '4', '8', or '16'">,
   InGroup;
+def warn_pragma_pack_non_default_at_include : Warning<
+  "non-default #pragma pack value might change the alignment of struct or "
+  "union members in the included file">, InGroup;
+def warn_pragma_pack_modified_after_include : Warning<
+  "the current #pragma pack aligment value is modified in the included "
+  "file">, InGroup;
+def warn_pragma_pack_no_pop_eof : Warning<"unterminated "
+  "'#pragma pack (push, ...)' at end of file">, InGroup;
+def note_pragma_pack_here : Note<
+  "previous '#pragma pack' directive that modifies alignment is here">;
 // Follow the Microsoft implementation.
 def warn_pragma_pack_show : Warning<"value of #pragma pack(show) == %0">;
 def warn_pragma_pack_pop_identifer_and_alignment : Warning<

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=308327=308326=308327=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Tue Jul 18 10:23:51 2017
@@ -208,6 +208,7 @@ namespace sema {
   class FunctionScopeInfo;
   class LambdaScopeInfo;
   class PossiblyUnreachableDiag;
+  class SemaPPCallbacks;
   class TemplateDeductionInfo;
 }
 
@@ -381,11 +382,12 @@ public:
   llvm::StringRef StackSlotLabel;
   ValueType Value;
   SourceLocation PragmaLocation;
-  Slot(llvm::StringRef StackSlotLabel,
-   ValueType Value,
-   SourceLocation PragmaLocation)
-: StackSlotLabel(StackSlotLabel), Value(Value),
-  

[PATCH] D35012: [refactor] Add the AST source selection component

2017-07-18 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

Oops, I just realised that now there's a small bug with early exits. Since we 
don't actually have true lexical order for declarations in the @implementation 
we might exit early after visiting a method in the @implementation before a 
function that's actually written before that method. I will probably constraint 
early exits to avoid this case.


Repository:
  rL LLVM

https://reviews.llvm.org/D35012



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


[PATCH] D35012: [refactor] Add the AST source selection component

2017-07-18 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman updated this revision to Diff 107121.
arphaman added a comment.

Factor out the lexical ordering code into a new visitor and simplify the 
implementation of the ast selection visitor


Repository:
  rL LLVM

https://reviews.llvm.org/D35012

Files:
  include/clang/AST/LexicallyOrderedRecursiveASTVisitor.h
  include/clang/Basic/SourceLocation.h
  include/clang/Basic/SourceManager.h
  include/clang/Tooling/Refactoring/ASTSelection.h
  lib/Tooling/Refactoring/ASTSelection.cpp
  lib/Tooling/Refactoring/CMakeLists.txt
  unittests/Tooling/ASTSelectionTest.cpp
  unittests/Tooling/CMakeLists.txt
  unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp

Index: unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp
===
--- /dev/null
+++ unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp
@@ -0,0 +1,141 @@
+//===- unittest/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp ---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "TestVisitor.h"
+#include "clang/AST/LexicallyOrderedRecursiveASTVisitor.h"
+#include 
+
+using namespace clang;
+
+namespace {
+
+class DummyMatchVisitor;
+
+class LexicallyOrderedDeclVisitor
+: public LexicallyOrderedRecursiveASTVisitor {
+public:
+  LexicallyOrderedDeclVisitor(DummyMatchVisitor ,
+  const SourceManager )
+  : LexicallyOrderedRecursiveASTVisitor(SM), Matcher(Matcher) {}
+
+  bool TraverseDecl(Decl *D) {
+TraversalStack.push_back(D);
+LexicallyOrderedRecursiveASTVisitor::TraverseDecl(D);
+TraversalStack.pop_back();
+return true;
+  }
+
+  bool VisitNamedDecl(const NamedDecl *D);
+
+private:
+  DummyMatchVisitor 
+  llvm::SmallVector TraversalStack;
+};
+
+class DummyMatchVisitor : public ExpectedLocationVisitor {
+public:
+  bool VisitTranslationUnitDecl(TranslationUnitDecl *TU) {
+const ASTContext  = TU->getASTContext();
+const SourceManager  = Context.getSourceManager();
+LexicallyOrderedDeclVisitor SubVisitor(*this, SM);
+SubVisitor.TraverseDecl(TU);
+return false;
+  }
+
+  void match(StringRef Path, const Decl *D) { Match(Path, D->getLocStart()); }
+};
+
+bool LexicallyOrderedDeclVisitor::VisitNamedDecl(const NamedDecl *D) {
+  std::string Path;
+  llvm::raw_string_ostream OS(Path);
+  assert(TraversalStack.back() == D);
+  for (const Decl *D : TraversalStack) {
+if (isa(D)) {
+  OS << "/";
+  continue;
+}
+if (const auto *ND = dyn_cast(D))
+  OS << ND->getNameAsString();
+else
+  OS << "???";
+if (isa(D))
+  OS << "/";
+  }
+  Matcher.match(OS.str(), D);
+  return true;
+}
+
+TEST(LexicallyOrderedRecursiveASTVisitor, VisitDeclsInImplementation) {
+  StringRef Source = R"(
+@interface I
+@end
+@implementation I
+
+int nestedFunction() { }
+
+- (void) method{ }
+
+int anotherNestedFunction(int x) {
+  return x;
+}
+
+int innerVariable = 0;
+
+@end
+
+int outerVariable = 0;
+
+@implementation I(Cat)
+
+void catF() { }
+
+@end
+
+void outerFunction() { }
+)";
+  DummyMatchVisitor Visitor;
+  Visitor.DisallowMatch("/nestedFunction/", 6, 1);
+  Visitor.ExpectMatch("/I/nestedFunction/", 6, 1);
+  Visitor.ExpectMatch("/I/method/", 8, 1);
+  Visitor.DisallowMatch("/anotherNestedFunction/", 10, 1);
+  Visitor.ExpectMatch("/I/anotherNestedFunction/", 10, 1);
+  Visitor.DisallowMatch("/innerVariable", 14, 1);
+  Visitor.ExpectMatch("/I/innerVariable", 14, 1);
+  Visitor.ExpectMatch("/outerVariable", 18, 1);
+  Visitor.DisallowMatch("/catF/", 22, 1);
+  Visitor.ExpectMatch("/Cat/catF/", 22, 1);
+  Visitor.ExpectMatch("/outerFunction/", 26, 1);
+  EXPECT_TRUE(Visitor.runOver(Source, DummyMatchVisitor::Lang_OBJC));
+}
+
+TEST(LexicallyOrderedRecursiveASTVisitor, VisitMacroDeclsInImplementation) {
+  StringRef Source = R"(
+@interface I
+@end
+
+void outerFunction() { }
+
+#define MACRO_F(x) void nestedFunction##x() { }
+
+@implementation I
+
+MACRO_F(1)
+
+@end
+
+MACRO_F(2)
+)";
+  DummyMatchVisitor Visitor;
+  Visitor.ExpectMatch("/outerFunction/", 5, 1);
+  Visitor.ExpectMatch("/I/nestedFunction1/", 7, 20);
+  Visitor.ExpectMatch("/nestedFunction2/", 7, 20);
+  EXPECT_TRUE(Visitor.runOver(Source, DummyMatchVisitor::Lang_OBJC));
+}
+
+} // end anonymous namespace
Index: unittests/Tooling/CMakeLists.txt
===
--- unittests/Tooling/CMakeLists.txt
+++ unittests/Tooling/CMakeLists.txt
@@ -11,11 +11,13 @@
 endif()
 
 add_clang_unittest(ToolingTests
+  ASTSelectionTest.cpp
   CastExprTest.cpp
   CommentHandlerTest.cpp
   CompilationDatabaseTest.cpp
   DiagnosticsYamlTest.cpp
   FixItTest.cpp
+  LexicallyOrderedRecursiveASTVisitorTest.cpp
   LookupTest.cpp
   QualTypeNamesTest.cpp
   

[PATCH] D35548: [mips] Teach the driver to accept -m(no-)gpopt.

2017-07-18 Thread Simon Dardis via Phabricator via cfe-commits
sdardis updated this revision to Diff 107114.
sdardis marked an inline comment as done.
sdardis added a comment.

Addressed review comment, added warning when combining -mabicalls and -mgpopt.


https://reviews.llvm.org/D35548

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Driver/Options.td
  lib/Driver/ToolChains/Clang.cpp
  test/Driver/mips-features.c
  test/Driver/mips-gpopt-warning.c

Index: test/Driver/mips-gpopt-warning.c
===
--- /dev/null
+++ test/Driver/mips-gpopt-warning.c
@@ -0,0 +1,6 @@
+// REQUIRES: mips-registered-target
+// RUN: %clang -### -c -target mips-mti-elf %s -mgpopt 2>&1 | FileCheck -check-prefix=IMPLICIT %s
+// IMPLICIT: warning: ignoring '-mgpopt' option as it cannot be used with the implicit usage of-mabicalls
+
+// RUN: %clang -### -c -target mips-mti-elf %s -mgpopt -mabicalls 2>&1 | FileCheck -check-prefix=EXPLICIT %s
+// EXPLICIT: warning: ignoring '-mgpopt' option as it cannot be used with -mabicalls
Index: test/Driver/mips-features.c
===
--- test/Driver/mips-features.c
+++ test/Driver/mips-features.c
@@ -10,6 +10,31 @@
 // RUN:   | FileCheck --check-prefix=CHECK-MNOABICALLS %s
 // CHECK-MNOABICALLS: "-target-feature" "+noabicalls"
 //
+// -mgpopt
+// RUN: %clang -target mips-linux-gnu -### -c %s -mno-gpopt -mgpopt 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MGPOPT-DEF-ABICALLS %s
+// CHECK-MGPOPT-DEF-ABICALLS-NOT: "-mllvm" "-mgpopt"
+//
+// -mabicalls -mgpopt
+// RUN: %clang -target mips-linux-gnu -### -c %s -mabicalls -mno-gpopt -mgpopt 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MGPOPT-EXPLICIT-ABICALLS %s
+// CHECK-MGPOPT-EXPLICIT-ABICALLS-NOT: "-mllvm" "-mgpopt"
+//
+// -mno-abicalls -mgpopt
+// RUN: %clang -target mips-linux-gnu -### -c %s -mno-abicalls -mno-gpopt -mgpopt 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MGPOPT %s
+// CHECK-MGPOPT: "-mllvm" "-mgpopt=1"
+//
+// -mno-abicalls -mno-gpopt
+// RUN: %clang -target mips-linux-gnu -### -c %s -mno-abicalls -mgpopt -mno-gpopt 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MNOGPOPT %s
+// CHECK-MNOGPOPT: "-mllvm" "-mgpopt=0"
+//
+// -mno-abicalls
+// RUN: %clang -target mips-linux-gnu -### -c %s -mno-abicalls 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MGPOPTDEF %s
+// CHECK-MGPOPTDEF: "-mllvm" "-mgpopt=1"
+//
 // -mips16
 // RUN: %clang -target mips-linux-gnu -### -c %s \
 // RUN: -mno-mips16 -mips16 2>&1 \
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -1462,6 +1462,32 @@
 A->claim();
   }
 
+  Arg *GPOpt = Args.getLastArg(options::OPT_mgpopt, options::OPT_mno_gpopt);
+  Arg *ABICalls = Args.getLastArg(options::OPT_mabicalls, options::OPT_mno_abicalls);
+
+  // -mabicalls is the default for many MIPS environments, even with -fno-pic.
+  // -mgpopt is the default for static, -fno-pic environments but these two
+  // options conflict. We want to be certain that -mno-abicalls -mgpopt is
+  // the only case where -mllvm -mgpopt is passed.
+  // NOTE: We need a warning here or in the backend to warn when -mgpopt is
+  //   passed explicitly when compiling something with -mabicalls
+  //   (implictly) in affect. Currently the warning is in the backend.
+  bool NoABICalls =
+  ABICalls && ABICalls->getOption().matches(options::OPT_mno_abicalls);
+  bool WantGPOpt = GPOpt && GPOpt->getOption().matches(options::OPT_mgpopt);
+  if (NoABICalls && (!GPOpt || WantGPOpt)) {
+  CmdArgs.push_back("-mllvm");
+  CmdArgs.push_back("-mgpopt=1");
+  } else {
+  CmdArgs.push_back("-mllvm");
+  CmdArgs.push_back("-mgpopt=0");
+  if ((!ABICalls || (!NoABICalls && ABICalls)) && (!GPOpt || WantGPOpt))
+D.Diag(diag::warn_drv_unsupported_gpopt) << (ABICalls ? 0 : 1);
+  }
+
+  if (GPOpt)
+GPOpt->claim();
+
   if (Arg *A = Args.getLastArg(options::OPT_mcompact_branches_EQ)) {
 StringRef Val = StringRef(A->getValue());
 if (mips::hasCompactBranches(CPUName)) {
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -2035,6 +2035,12 @@
   HelpText<"Use 64-bit floating point registers (MIPS only)">;
 def mfp32 : Flag<["-"], "mfp32">, Group,
   HelpText<"Use 32-bit floating point registers (MIPS only)">;
+def mgpopt : Flag<["-"], "mgpopt">, Group,
+  HelpText<"Use GP relative accesses for symbols known to be in a small"
+   " data section (MIPS)">;
+def mno_gpopt : Flag<["-"], "mno-gpopt">, Group,
+  HelpText<"Do not use GP relative accesses for symbols known to be in a small"
+   " data section (MIPS)">;
 def mnan_EQ : Joined<["-"], "mnan=">, Group;
 def mabicalls : Flag<["-"], "mabicalls">, 

[PATCH] D35449: [X86] Implement __builtin_cpu_is

2017-07-18 Thread Eric Christopher via Phabricator via cfe-commits
echristo added a comment.

FWIW the duplication in CGCall.cpp of the enum set is painful if you can come 
up with anything else it'd be awesome. I don't have any good ideas, just a fond 
wish :)


https://reviews.llvm.org/D35449



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


[PATCH] D35449: [X86] Implement __builtin_cpu_is

2017-07-18 Thread Eric Christopher via Phabricator via cfe-commits
echristo added a comment.

From my perspective here once you and Erich get some agreement on the checking 
between your two bits I'm fine :)

-eric


https://reviews.llvm.org/D35449



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


[PATCH] D35449: [X86] Implement __builtin_cpu_is

2017-07-18 Thread Eric Christopher via Phabricator via cfe-commits
echristo added a subscriber: erichkeane.
echristo added a comment.

Adding Erich Keane here on this since he's working on something similar for the 
target attribute.

-eric


https://reviews.llvm.org/D35449



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


[PATCH] D35519: Add SEMA checking to attribute 'target'

2017-07-18 Thread Erich Keane via Phabricator via cfe-commits
erichkeane abandoned this revision.
erichkeane added a comment.

Going to split this into a few patches as Eric requested.


https://reviews.llvm.org/D35519



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


[PATCH] D35519: Add SEMA checking to attribute 'target'

2017-07-18 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In https://reviews.llvm.org/D35519#813082, @echristo wrote:

> If you wouldn't mind I'd like to see this separated out a bit -
>  a) I think we can make the attribute info a struct rather than a pair as a 
> simple change first
>  b) setCPU split
>  c) let's see where we are after that?
>
> Also the description makes it sound like you're adding support for the 
> feature rather than fixing the terrible error diagnostics - or at least to my 
> early morning brain. :)
>
> Also, one inline comment so far.
>
> Thanks!
>
> -eric


Caught me just in time :)

Sure, I can split this into a couple of patches.  I'll abandon this one and go 
from there.


https://reviews.llvm.org/D35519



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


[PATCH] D35519: Add SEMA checking to attribute 'target'

2017-07-18 Thread Eric Christopher via Phabricator via cfe-commits
echristo added a comment.

If you wouldn't mind I'd like to see this separated out a bit -
a) I think we can make the attribute info a struct rather than a pair as a 
simple change first
b) setCPU split
c) let's see where we are after that?

Also the description makes it sound like you're adding support for the feature 
rather than fixing the terrible error diagnostics - or at least to my early 
morning brain. :)

Also, one inline comment so far.

Thanks!

-eric




Comment at: test/Sema/attr-target.c:10
+int __attribute__((target("arch="))) turtle() { return 4; } // no warning, 
same as saying 'nothing'.
+int __attribute__((target("arch=hiss,arch=woof"))) pine_tree() { return 4; } 
//expected-warning {{ignoring duplicate 'arch=' in the target attribute string}}
+

Precedence issue maybe, but I'd have expected this to error on the architecture 
name rather than the duplicate?


https://reviews.llvm.org/D35519



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


[PATCH] D35329: [clang-reorder-fields] Enable reordering for plain C structs

2017-07-18 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexshap added a comment.

ping


Repository:
  rL LLVM

https://reviews.llvm.org/D35329



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


[PATCH] D30946: [ScopePrinting] Added support to print full scopes of types and declarations.

2017-07-18 Thread Simon Schroeder via Phabricator via cfe-commits
schroedersi added a comment.

Ping :)


https://reviews.llvm.org/D30946



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


[PATCH] D35519: Add SEMA checking to attribute 'target'

2017-07-18 Thread Erich Keane via Phabricator via cfe-commits
erichkeane marked 2 inline comments as done.
erichkeane added a comment.

Thanks Aaron!  Fixed those things and will be submitting soon.  Also ran format 
on the function in SemaDeclAttr. For some reason it didn't right the first time.


https://reviews.llvm.org/D35519



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


r308317 - [OPENMP] Generalization of sema analysis of reduction-based clauses,

2017-07-18 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Jul 18 08:32:58 2017
New Revision: 308317

URL: http://llvm.org/viewvc/llvm-project?rev=308317=rev
Log:
[OPENMP] Generalization of sema analysis of reduction-based clauses,
NFC.

Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=308317=308316=308317=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Tue Jul 18 08:32:58 2017
@@ -8903,15 +8903,66 @@ buildDeclareReductionRef(Sema ,
   return ExprEmpty();
 }
 
-OMPClause *Sema::ActOnOpenMPReductionClause(
-ArrayRef VarList, SourceLocation StartLoc, SourceLocation 
LParenLoc,
-SourceLocation ColonLoc, SourceLocation EndLoc,
-CXXScopeSpec , const DeclarationNameInfo ,
-ArrayRef UnresolvedReductions) {
+namespace {
+/// Data for the reduction-based clauses.
+struct ReductionData {
+  /// List of original reduction items.
+  SmallVector Vars;
+  /// List of private copies of the reduction items.
+  SmallVector Privates;
+  /// LHS expressions for the reduction_op expressions.
+  SmallVector LHSs;
+  /// RHS expressions for the reduction_op expressions.
+  SmallVector RHSs;
+  /// Reduction operation expression.
+  SmallVector ReductionOps;
+  /// List of captures for clause.
+  SmallVector ExprCaptures;
+  /// List of postupdate expressions.
+  SmallVector ExprPostUpdates;
+  ReductionData() = delete;
+  /// Reserves required memory for the reduction data.
+  ReductionData(unsigned Size) {
+Vars.reserve(Size);
+Privates.reserve(Size);
+LHSs.reserve(Size);
+RHSs.reserve(Size);
+ReductionOps.reserve(Size);
+ExprCaptures.reserve(Size);
+ExprPostUpdates.reserve(Size);
+  }
+  /// Stores reduction item and reduction operation only (required for 
dependent
+  /// reduction item).
+  void push(Expr *Item, Expr *ReductionOp) {
+Vars.emplace_back(Item);
+Privates.emplace_back(nullptr);
+LHSs.emplace_back(nullptr);
+RHSs.emplace_back(nullptr);
+ReductionOps.emplace_back(ReductionOp);
+  }
+  /// Stores reduction data.
+  void push(Expr *Item, Expr *Private, Expr *LHS, Expr *RHS,
+Expr *ReductionOp) {
+Vars.emplace_back(Item);
+Privates.emplace_back(Private);
+LHSs.emplace_back(LHS);
+RHSs.emplace_back(RHS);
+ReductionOps.emplace_back(ReductionOp);
+  }
+};
+} // namespace
+
+static bool ActOnOMPReductionKindClause(
+Sema , DSAStackTy *Stack, ArrayRef VarList,
+SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc,
+SourceLocation EndLoc, CXXScopeSpec ,
+const DeclarationNameInfo ,
+ArrayRef UnresolvedReductions, ReductionData ) {
   auto DN = ReductionId.getName();
   auto OOK = DN.getCXXOverloadedOperator();
   BinaryOperatorKind BOK = BO_Comma;
 
+  ASTContext  = S.Context;
   // OpenMP [2.14.3.6, reduction clause]
   // C
   // reduction-identifier is either an identifier or one of the following
@@ -8995,13 +9046,6 @@ OMPClause *Sema::ActOnOpenMPReductionCla
 ReductionIdRange.setBegin(ReductionIdScopeSpec.getBeginLoc());
   ReductionIdRange.setEnd(ReductionId.getEndLoc());
 
-  SmallVector Vars;
-  SmallVector Privates;
-  SmallVector LHSs;
-  SmallVector RHSs;
-  SmallVector ReductionOps;
-  SmallVector ExprCaptures;
-  SmallVector ExprPostUpdates;
   auto IR = UnresolvedReductions.begin(), ER = UnresolvedReductions.end();
   bool FirstIter = true;
   for (auto RefExpr : VarList) {
@@ -9019,27 +9063,23 @@ OMPClause *Sema::ActOnOpenMPReductionCla
 SourceLocation ELoc;
 SourceRange ERange;
 Expr *SimpleRefExpr = RefExpr;
-auto Res = getPrivateItem(*this, SimpleRefExpr, ELoc, ERange,
+auto Res = getPrivateItem(S, SimpleRefExpr, ELoc, ERange,
   /*AllowArraySection=*/true);
 if (Res.second) {
-  // It will be analyzed later.
-  Vars.push_back(RefExpr);
-  Privates.push_back(nullptr);
-  LHSs.push_back(nullptr);
-  RHSs.push_back(nullptr);
   // Try to find 'declare reduction' corresponding construct before using
   // builtin/overloaded operators.
   QualType Type = Context.DependentTy;
   CXXCastPath BasePath;
   ExprResult DeclareReductionRef = buildDeclareReductionRef(
-  *this, ELoc, ERange, DSAStack->getCurScope(), ReductionIdScopeSpec,
+  S, ELoc, ERange, Stack->getCurScope(), ReductionIdScopeSpec,
   ReductionId, Type, BasePath, IR == ER ? nullptr : *IR);
-  if (CurContext->isDependentContext() &&
+  Expr *ReductionOp = nullptr;
+  if (S.CurContext->isDependentContext() &&
   (DeclareReductionRef.isUnset() ||
isa(DeclareReductionRef.get(
-ReductionOps.push_back(DeclareReductionRef.get());
-  else
-ReductionOps.push_back(nullptr);
+ReductionOp = DeclareReductionRef.get();
+  // It 

Re: r308044 - Add documentation for @available

2017-07-18 Thread via cfe-commits
Its getting an error. Will update in a bit when I can.

-Tanya

> On Jul 18, 2017, at 8:07 AM, Nico Weber  wrote:
> 
>> On Mon, Jul 17, 2017 at 8:39 AM, Aaron Ballman  
>> wrote:
>> On Sun, Jul 16, 2017 at 7:49 PM, Nico Weber  wrote:
>> > Aaron, https://clang.llvm.org/docs/AttributeReference.html#availability
>> > still doesn't have the AttrDocs.td change I made in this change 2 days ago.
>> > Do I have to do anything to get it to update?
>> 
>> No, it's expected to update once a day, usually pretty early in the
>> morning EST (ridiculously early PST).
>> 
>> Tanya, I've not seen any failure emails for building from AttrDocs.td.
>> Did I get removed from that list when we updated? If so, I'm happy to
>> continue to receive it to help resolve problems, but in the interim,
>> do you happen to know more about what's going on?
> 
> Tanya, ping?
>  
>> 
>> Thanks!
>> 
>> ~Aaron
>> 
>> >
>> > On Fri, Jul 14, 2017 at 2:40 PM, Nico Weber via cfe-commits
>> >  wrote:
>> >>
>> >> Author: nico
>> >> Date: Fri Jul 14 11:40:52 2017
>> >> New Revision: 308044
>> >>
>> >> URL: http://llvm.org/viewvc/llvm-project?rev=308044=rev
>> >> Log:
>> >> Add documentation for @available
>> >>
>> >> https://reviews.llvm.org/D35379
>> >>
>> >> Modified:
>> >> cfe/trunk/docs/LanguageExtensions.rst
>> >> cfe/trunk/include/clang/Basic/AttrDocs.td
>> >>
>> >> Modified: cfe/trunk/docs/LanguageExtensions.rst
>> >> URL:
>> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LanguageExtensions.rst?rev=308044=308043=308044=diff
>> >>
>> >> ==
>> >> --- cfe/trunk/docs/LanguageExtensions.rst (original)
>> >> +++ cfe/trunk/docs/LanguageExtensions.rst Fri Jul 14 11:40:52 2017
>> >> @@ -1271,6 +1271,87 @@ Further examples of these attributes are
>> >>  Query for these features with ``__has_attribute(ns_consumed)``,
>> >>  ``__has_attribute(ns_returns_retained)``, etc.
>> >>
>> >> +Objective-C @available
>> >> +--
>> >> +
>> >> +It is possible to use the newest SDK but still build a program that can
>> >> run on
>> >> +older versions of macOS and iOS by passing ``-mmacosx-version-info=`` /
>> >> +``--miphoneos-version-min=``.
>> >> +
>> >> +Before LLVM 5.0, when calling a function that exists only in the OS
>> >> that's
>> >> +newer than the target OS (as determined by the minimum deployment
>> >> version),
>> >> +programmers had to carefully check if the function exists at runtime,
>> >> using
>> >> +null checks for weakly-linked C functions, ``+class`` for Objective-C
>> >> classes,
>> >> +and ``-respondsToSelector:`` or ``+instancesRespondToSelector:`` for
>> >> +Objective-C methods.  If such a check was missed, the program would
>> >> compile
>> >> +fine, run fine on newer systems, but crash on older systems.
>> >> +
>> >> +As of LLVM 5.0, ``-Wunguarded-availability`` uses the `availability
>> >> attributes
>> >> +`_
>> >> together
>> >> +with the new ``@available()`` keyword to assist with this issue.
>> >> +When a method that's introduced in the OS newer than the target OS is
>> >> called, a
>> >> +-Wunguarded-availability warning is emitted if that call is not guarded:
>> >> +
>> >> +.. code-block:: objc
>> >> +
>> >> +  void my_fun(NSSomeClass* var) {
>> >> +// If fancyNewMethod was added in e.g. macOS 10.12, but the code is
>> >> +// built with -mmacosx-version-min=10.11, then this unconditional
>> >> call
>> >> +// will emit a -Wunguarded-availability warning:
>> >> +[var fancyNewMethod];
>> >> +  }
>> >> +
>> >> +To fix the warning and to avoid the crash on macOS 10.11, wrap it in
>> >> +``if(@available())``:
>> >> +
>> >> +.. code-block:: objc
>> >> +
>> >> +  void my_fun(NSSomeClass* var) {
>> >> +if (@available(macOS 10.12, *)) {
>> >> +  [var fancyNewMethod];
>> >> +} else {
>> >> +  // Put fallback behavior for old macOS versions (and for non-mac
>> >> +  // platforms) here.
>> >> +}
>> >> +  }
>> >> +
>> >> +The ``*`` is required and means that platforms not explicitly listed will
>> >> take
>> >> +the true branch, and the compiler will emit ``-Wunguarded-availability``
>> >> +warnings for unlisted platforms based on those platform's deployment
>> >> target.
>> >> +More than one platform can be listed in ``@available()``:
>> >> +
>> >> +.. code-block:: objc
>> >> +
>> >> +  void my_fun(NSSomeClass* var) {
>> >> +if (@available(macOS 10.12, iOS 10, *)) {
>> >> +  [var fancyNewMethod];
>> >> +}
>> >> +  }
>> >> +
>> >> +If the caller of ``my_fun()`` already checks that ``my_fun()`` is only
>> >> called
>> >> +on 10.12, then add an `availability attribute
>> >> +`_ to
>> >> it,
>> >> +which will also suppress the warning and require that calls to my_fun()
>> 

[PATCH] D35519: Add SEMA checking to attribute 'target'

2017-07-18 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.

A few small nits, but otherwise LGTM




Comment at: lib/Sema/SemaDeclAttr.cpp:2999-3000
+bool Sema::checkTargetAttr(SourceLocation LiteralLoc, StringRef AttrStr) {
+  // Error message enums.  Enum vs enum class since the scope is limited,
+  // and it otherwise simplifies the error messages.
+  enum FirstParam { unsupported, duplicate};

I don't think this comment is needed (the code is pretty obvious), so I'd just 
drop it entirely.



Comment at: lib/Sema/SemaDeclAttr.cpp:3001-3002
+  // and it otherwise simplifies the error messages.
+  enum FirstParam { unsupported, duplicate};
+  enum SecondParam { None, architecture };
   for (auto Str : {"tune=", "fpmath="})

enumerator casing should be Unsupported, Duplicate, Architecture.


https://reviews.llvm.org/D35519



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


[PATCH] D35564: Suppress -pedantic warnings about GNU extension StmtExpr in glibc's assert macro

2017-07-18 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

Ping - Richard, what'd you reckon? (This came up on another review where 
-Wzero-as-null-pointer triggered in a system header in libstdc++ I think)


https://reviews.llvm.org/D35564



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


  1   2   >