[PATCH] D37143: [clang-format] Fixed missing enter before bracket in typedef enum and extern

2017-08-26 Thread Pawel Maciocha via Phabricator via cfe-commits
PriMee added a comment.

I merged them just because of their presence in the same bug report... As to 
the unit tests, I'll add them as soon as possible.

With reference to `extern` part, once again:
There is no brace wrapping flag that let us control opening brace's position. 
In case of other keywords (class, function, control statement etc.) we have 
opportunity to decide how should it look like. Here, we can't do it similarly. 
What we want is leaving braces **unformatted** (leave them as in the input), 
but what's more we still want to call **parseBlock** function. The only option 
is to set MustBreakBefore flag manually (only when needed, when the left brace 
is on non-header line, parseBlock does move it by default).

One more correction: Would be probably better to replace the line 
`MustBreakBeforeNextToken = true;` with `FormatTok->MustBreakBefore = true;`
It does work as expected as well (still passes every test - there are some!), 
but is more intuitive and understandable.

I'll work on these problems on monday.


https://reviews.llvm.org/D37143



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


[PATCH] D37120: [analyzer] Fix modeling arithmetic

2017-08-26 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Yeah, `LocAsInteger` is supported very poorly in most places. We can only get 
away with it because people rarely cast pointers to integers.

Your reasoning about how `LocAsInteger` works poorly with eg. multiplication or 
bitwise operations (consider some sanitizer computing shadow memory) is one of 
the reasons why i think `LocAsInteger` should be turned into a special symbol 
class ("`SymbolRegionAddress`"), to be able to participate in symbolic 
expressions. Even if our constraint manager is unable to reason about such 
expressions, having correct opaque expressions is better than having 
`UnknownVal`s because at least we can carry constraints on exact same 
expressions, and also better than conjured symbols because we are sure to 
assign the same symbol if such expression is computed more than once. Such 
change would allow us to remove special handling of `LocAsInteger` in some 
cases (just treat it as any other symbol), while still performing 
simplifications where we want. We'd probably be able to collapse addresses of 
symbolic pointers into `SymbolCast`s, eg. `$addr().getLoc(),

alexshap wrote:
> @NoQ , @dcoughlin 
> while we are looking at this code - just to double check - is this line (363) 
> actually correct ?
> Let's take a look at the following example:
>bool f(long x, double *p1, double *p2) {
>   long y = (long)p1 - (long) p2; 
>   // or,alternatively (long)p1 * (long)p2  or (long)p1 / (long)p2
>   return y == x;
> }
> it looks like again the analyzer will try to use evalBinOpLL and evaluate 
> this as an operation over pointers, while (if my understanding is correct) we 
> should be working with integers here (and yes, in most cases it should return 
> UnknownVal)
>   
Yeah, even pointer substraction would be handled incorrectly, because pointer 
types would be incorrectly taken into account (if only we actually had pointer 
substraction).



Comment at: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp:371-373
+return makeSymExprValNN(
+state, op, lhs.castAs(),
+rhs.castAs(), resultTy);

alexshap wrote:
> NoQ wrote:
> > For now this code would return `UnknownVal` in most cases (pointer is not 
> > tainted, or not symbolic, or contains an offset), and still construct an 
> > invalid symbol in the rest of the cases (`makeSymExprValNN` would add the 
> > number to the pointer symbol, instead of modelling an offset within the 
> > pointed-to region).
> > 
> > Once D35450 finally lands (sorry for the delays...), it'd return 
> > `UnknownVal` less often and crash more often.
> @NoQ - many thanks for the code review!
> 
> i assume i might be missing smth, anyway, (replying to this comment and 
> another one below)
> 
>   >This is probably the way to go: just take the Loc behind the LocAsInteger, 
> cast it to char * (because 
>   >pointer type shouldn't affect how much bytes of offset are added, 
> anymore), add your integer to it, 
>   >pack back into LocAsInteger
> 
> i'm not sure i understand how that would work here and somehow don't like it. 
> For example, op can be MultiplicativeOp (i.e. long y = ((long)p) * 13;) 
> extracting the Loc and doing smth with the Loc -  doesn't seem to be the 
> right thing (if i understood your suggestion correctly)
> 
>   >For now this code would return UnknownVal in 
>   >most cases (pointer is not tainted, or not symbolic, 
>   >or contains an offset)
> 
> that was my understanding what this code should do (return UnknownVal in most 
> cases unless we can reason about the actual (integer) values of LHS,RHS)
> 
> 
Yeah, we should still return `UnknownVal` for now in most cases. I just wanted 
to point out that addition and substraction can be handled this way. And also 
that `makeSymExprValNN()` seems to be unable to handle `LocAsInteger` arguments 
correctly, so manual intervention would be necessary anyway. So i think it'd be 
better to just return `UnknownVal` directly.


Repository:
  rL LLVM

https://reviews.llvm.org/D37120



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


[PATCH] D36354: [clang-tidy] Implement type-based check for `gsl::owner`

2017-08-26 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added inline comments.



Comment at: clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp:294
+
+diag(BadClass->getLocStart(),
+ "class with an 'gsl::owner<>' as member but without declared "

aaron.ballman wrote:
> Instead of diagnosing this on the class, why not diagnose the individual 
> offending members (and then you don't need a note, either)? (Note, that may 
> change the suggested diagnostic wording below).
yes, this is probably better.
i plan to add deeper analysis, that `gsl::owner<>` will always be released or 
moved.
That would check, if destructors do this correctly, so offending the member is 
the better way.


https://reviews.llvm.org/D36354



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


[PATCH] D36527: Implemented P0428R2 - Familiar template syntax for generic lambdas

2017-08-26 Thread Hamza Sood via Phabricator via cfe-commits
hamzasood added a comment.

Thanks for all of your feedback! It’s really helped to improve this patch.




Comment at: lib/AST/ExprCXX.cpp:979
 
+SourceRange LambdaExpr::getExplicitTemplateParameterListRange() const {
+  TemplateParameterList *List = getTemplateParameterList();

faisalv wrote:
> hamzasood wrote:
> > faisalv wrote:
> > > I think this should return an invalid range if getExplicitCount is 0.
> > > might assert that when not 0, langleloc does not equal rangleloc.
> > > 
> > I think it does return an invalid range in that case. Without explicit 
> > template parameters, getLAngleLoc and getRAngleLoc return invalid 
> > locations. And a range of invalid locations is an invalid range. But I 
> > suppose that could be asserted to make sure.
> fyi - Since getGenericLambdaTPL sets the LAngleLoc and RAngleLoc to the 
> introducer range - unless one handles that case spearately- those funcs won't 
> return an invalid loc?  
That’s changed in this patch. LAngleLoc and RAngleLoc are invalid unless 
there’s an explicit template parameter list.



Comment at: lib/Parse/ParseExprCXX.cpp:1116
+  if (HasExplicitTemplateParams) {
+SmallVector TemplateParams;
+SourceLocation LAngleLoc, RAngleLoc;

faisalv wrote:
> hamzasood wrote:
> > faisalv wrote:
> > > hamzasood wrote:
> > > > faisalv wrote:
> > > > > Why not Just use/pass LSI->TemplateParams?
> > > > I thought that Parser and Sema stay separate, and communicate through 
> > > > various ActOn functions? Directly accessing LSI would violate that.
> > > Aah yes - you're right.  Still it does seem a little wasteful to create 
> > > two of those (and then append).  What are your thoughts about passing the 
> > > argument by (moved from) value, and then swapping their guts within ActOn 
> > > (i..e value-semantics) ?  (I suppose the only concern would be the small 
> > > array case - but i think that would be quite easy for any optimizer to 
> > > inline).   
> > > 
> > I don't think a SmallVectorImpl can be passed by value.
> > 
> > So to make that work, the function would either needed to be templated 
> > (SmallVector) or only accept a SmallVector. And I don't 
> > think either of those options are worthwhile.
> OK - add a FIXME that alerts folks that we currently make two copies of this 
> and ideally we shouldn't need to.
I disagree with this. I don’t think that needing to copy a few pointers is a 
big deal; it happens all the time. E.g. a few lines below this is a vector of 
ParamInfo that’s filled locally and then copied to its destination. The 
performance gain from eliminating that copy isn’t worth making the code more 
confusing, especially since the small case will be hit most of the time.


https://reviews.llvm.org/D36527



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


[PATCH] D37120: [analyzer] Fix modeling arithmetic

2017-08-26 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexshap updated this revision to Diff 112784.
alexshap added a comment.

Return UnknownVal for non-comparison operations.
Add FIXME (improve modeling of "pointers as integers").


Repository:
  rL LLVM

https://reviews.llvm.org/D37120

Files:
  lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  test/Analysis/ptr-arith.cpp


Index: test/Analysis/ptr-arith.cpp
===
--- test/Analysis/ptr-arith.cpp
+++ test/Analysis/ptr-arith.cpp
@@ -105,3 +105,9 @@
 return 0;
   return N;
 }
+
+// Bug 34309
+bool ptrAsIntegerSubtractionNoCrash(long x, char *p) {
+  long y = (long)p - 1;
+  return y == x;
+}
Index: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -360,10 +360,18 @@
   Loc lhsL = lhs.castAs().getLoc();
   switch (rhs.getSubKind()) {
 case nonloc::LocAsIntegerKind:
+  // FIXME: at the moment the implementation 
+  // of modeling "pointers as integers" is not complete.
+  if (!BinaryOperator::isComparisonOp(op))
+return UnknownVal(); 
   return evalBinOpLL(state, op, lhsL,
  rhs.castAs().getLoc(),
  resultTy);
 case nonloc::ConcreteIntKind: {
+  // FIXME: at the moment the implementation 
+  // of modeling "pointers as integers" is not complete.
+  if (!BinaryOperator::isComparisonOp(op))
+return UnknownVal();
   // Transform the integer into a location and compare.
   // FIXME: This only makes sense for comparisons. If we want to, say,
   // add 1 to a LocAsInteger, we'd better unpack the Loc and add to it,


Index: test/Analysis/ptr-arith.cpp
===
--- test/Analysis/ptr-arith.cpp
+++ test/Analysis/ptr-arith.cpp
@@ -105,3 +105,9 @@
 return 0;
   return N;
 }
+
+// Bug 34309
+bool ptrAsIntegerSubtractionNoCrash(long x, char *p) {
+  long y = (long)p - 1;
+  return y == x;
+}
Index: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -360,10 +360,18 @@
   Loc lhsL = lhs.castAs().getLoc();
   switch (rhs.getSubKind()) {
 case nonloc::LocAsIntegerKind:
+  // FIXME: at the moment the implementation 
+  // of modeling "pointers as integers" is not complete.
+  if (!BinaryOperator::isComparisonOp(op))
+return UnknownVal(); 
   return evalBinOpLL(state, op, lhsL,
  rhs.castAs().getLoc(),
  resultTy);
 case nonloc::ConcreteIntKind: {
+  // FIXME: at the moment the implementation 
+  // of modeling "pointers as integers" is not complete.
+  if (!BinaryOperator::isComparisonOp(op))
+return UnknownVal();
   // Transform the integer into a location and compare.
   // FIXME: This only makes sense for comparisons. If we want to, say,
   // add 1 to a LocAsInteger, we'd better unpack the Loc and add to it,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D37181: {StaticAnalyzer} LoopUnrolling: Keep track the maximum number of steps for each loop

2017-08-26 Thread Peter Szecsi via Phabricator via cfe-commits
szepet created this revision.
Herald added subscribers: baloghadamsoftware, whisperity.

This way the unrolling can be restricted for loops which will take at most a 
given number of steps. It is defined as 128 in this patch and it seems to have 
a good number for that purpose.


https://reviews.llvm.org/D37181

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/LoopUnrolling.h
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  lib/StaticAnalyzer/Core/LoopUnrolling.cpp
  test/Analysis/loop-unrolling.cpp

Index: test/Analysis/loop-unrolling.cpp
===
--- test/Analysis/loop-unrolling.cpp
+++ test/Analysis/loop-unrolling.cpp
@@ -5,7 +5,7 @@
 
 int getNum();
 void foo(int &);
-// Testing for loops.
+
 int simple_unroll1() {
   int a[9];
   int k = 42;
@@ -259,7 +259,6 @@
   return 0;
 }
 
-
 int recursion_unroll1(bool b) {
   int k = 2;
   for (int i = 0; i < 5; i++) {
@@ -289,7 +288,7 @@
   int k = 2;
   for (int i = 0; i < 5; i++) {
 clang_analyzer_numTimesReached(); // expected-warning {{10}}
-if(i == 4 && b) {
+if (i == 4 && b) {
   recursion_unroll3(false);
   break;
 }
@@ -319,3 +318,57 @@
   ;
   return 0;
 }
+
+int num_steps_on_limit() {
+  for (int i = 0; i < 128; i++) {
+clang_analyzer_numTimesReached(); // expected-warning {{128}}
+  }
+  clang_analyzer_numTimesReached(); // expected-warning {{1}}
+  return 0;
+}
+
+int num_steps_over_limit1() {
+  for (int i = 0; i < 129; i++) {
+clang_analyzer_numTimesReached(); // expected-warning {{4}}
+  }
+  return 0;
+}
+
+int num_steps_on_limit2() {
+  for (int i = 0; i < 2; i++) {
+for (int j = 0; j < 64; j++) {
+  clang_analyzer_numTimesReached(); // expected-warning {{128}}
+}
+  }
+  return 0;
+}
+
+int num_steps_over_limit2() {
+  for (int i = 0; i < 2; i++) {
+clang_analyzer_numTimesReached(); // expected-warning {{1}}
+for (int j = 0; j <= 64; j++) {
+  clang_analyzer_numTimesReached(); // expected-warning {{4}}
+}
+  }
+  return 0;
+}
+
+int num_steps_on_limit3() {
+  for (int i = 0; i < getNum(); i++) {
+clang_analyzer_numTimesReached(); // expected-warning {{4}}
+for (int j = 0; j < 32; j++) {
+  clang_analyzer_numTimesReached(); // expected-warning {{128}}
+}
+  }
+  return 0;
+}
+
+int num_steps_over_limit3() {
+  for (int i = 0; i < getNum(); i++) {
+clang_analyzer_numTimesReached(); // expected-warning {{1}}
+for (int j = 0; j < 33; j++) {
+  clang_analyzer_numTimesReached(); // expected-warning {{4}}
+}
+  }
+  return 0;
+}
Index: lib/StaticAnalyzer/Core/LoopUnrolling.cpp
===
--- lib/StaticAnalyzer/Core/LoopUnrolling.cpp
+++ lib/StaticAnalyzer/Core/LoopUnrolling.cpp
@@ -23,22 +23,28 @@
 using namespace ento;
 using namespace clang::ast_matchers;
 
+#define MAXIMUM_STEP_UNROLLED 128
+
 struct LoopState {
 private:
   enum Kind { Normal, Unrolled } K;
   const Stmt *LoopStmt;
   const LocationContext *LCtx;
-  LoopState(Kind InK, const Stmt *S, const LocationContext *L)
-  : K(InK), LoopStmt(S), LCtx(L) {}
+  unsigned maxStep;
+  LoopState(Kind InK, const Stmt *S, const LocationContext *L, unsigned N)
+  : K(InK), LoopStmt(S), LCtx(L), maxStep(N) {}
 
 public:
-  static LoopState getNormal(const Stmt *S, const LocationContext *L) {
-return LoopState(Normal, S, L);
+  static LoopState getNormal(const Stmt *S, const LocationContext *L,
+ unsigned N) {
+return LoopState(Normal, S, L, N);
   }
-  static LoopState getUnrolled(const Stmt *S, const LocationContext *L) {
-return LoopState(Unrolled, S, L);
+  static LoopState getUnrolled(const Stmt *S, const LocationContext *L,
+   unsigned N) {
+return LoopState(Unrolled, S, L, N);
   }
   bool isUnrolled() const { return K == Unrolled; }
+  unsigned getMaxStep() const { return maxStep; }
   const Stmt *getLoopStmt() const { return LoopStmt; }
   const LocationContext *getLocationContext() const { return LCtx; }
   bool operator==(const LoopState &X) const {
@@ -48,6 +54,7 @@
 ID.AddInteger(K);
 ID.AddPointer(LoopStmt);
 ID.AddPointer(LCtx);
+ID.AddInteger(maxStep);
   }
 };
 
@@ -74,12 +81,14 @@
 }
 
 static internal::Matcher simpleCondition(StringRef BindName) {
-  return binaryOperator(
-  anyOf(hasOperatorName("<"), hasOperatorName(">"), hasOperatorName("<="),
-hasOperatorName(">="), hasOperatorName("!=")),
-  hasEitherOperand(ignoringParenImpCasts(
-  declRefExpr(to(varDecl(hasType(isInteger())).bind(BindName),
-  hasEitherOperand(ignoringParenImpCasts(integerLiteral(;
+  return binaryOperator(anyOf(hasOperatorName("<"), hasOperatorName(">"),
+  hasOperatorName("<="), hasOperatorName(">="),
+  hasOperatorName("!=")),
+hasEitherOperand(ignoringParenImpCasts(declRefExpr(
+

[PATCH] D26796: [Driver] Use arch type to find compiler-rt libraries (on Linux)

2017-08-26 Thread Michał Górny via Phabricator via cfe-commits
mgorny updated this revision to Diff 112796.
mgorny added a comment.

Rebased the patch since it no longer applied.


https://reviews.llvm.org/D26796

Files:
  lib/Driver/ToolChain.cpp
  test/Driver/Inputs/basic_linux_tree/usr/i686-unknown-linux/lib/.keep
  
test/Driver/Inputs/basic_linux_tree/usr/lib/gcc/i686-unknown-linux/4.6.0/crtbegin.o
  test/Driver/linux-ld.c
  test/Driver/nostdlib.c
  test/Driver/print-libgcc-file-name-clangrt.c
  test/Driver/windows-cross.c


Index: test/Driver/windows-cross.c
===
--- test/Driver/windows-cross.c
+++ test/Driver/windows-cross.c
@@ -64,7 +64,7 @@
 // RUN:| FileCheck %s --check-prefix CHECK-SANITIZE-ADDRESS-EXE-X86
 
 // CHECK-SANITIZE-ADDRESS-EXE-X86: "-fsanitize=address"
-// CHECK-SANITIZE-ADDRESS-EXE-X86: "{{.*}}clang_rt.asan_dynamic-i686.lib" 
"{{.*}}clang_rt.asan_dynamic_runtime_thunk-i686.lib" "--undefined" 
"___asan_seh_interceptor"
+// CHECK-SANITIZE-ADDRESS-EXE-X86: "{{.*}}clang_rt.asan_dynamic-i386.lib" 
"{{.*}}clang_rt.asan_dynamic_runtime_thunk-i386.lib" "--undefined" 
"___asan_seh_interceptor"
 
 // RUN: %clang -### -target armv7-windows-itanium --sysroot 
%S/Inputs/Windows/ARM/8.1 -B %S/Inputs/Windows/ARM/8.1/usr/bin 
-fuse-ld=lld-link2 -shared -o shared.dll -fsanitize=tsan -x c++ %s 2>&1 \
 // RUN:| FileCheck %s --check-prefix CHECK-SANITIZE-TSAN
Index: test/Driver/print-libgcc-file-name-clangrt.c
===
--- test/Driver/print-libgcc-file-name-clangrt.c
+++ test/Driver/print-libgcc-file-name-clangrt.c
@@ -5,10 +5,16 @@
 // RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-X8664 %s
 // CHECK-CLANGRT-X8664: libclang_rt.builtins-x86_64.a
 
+// RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \
+// RUN: --target=i386-pc-linux \
+// RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-I386 %s
+// CHECK-CLANGRT-I386: libclang_rt.builtins-i386.a
+
+// Check whether alternate arch values map to the correct library.
+//
 // RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \
 // RUN: --target=i686-pc-linux \
-// RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-I686 %s
-// CHECK-CLANGRT-I686: libclang_rt.builtins-i686.a
+// RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-I386 %s
 
 // RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \
 // RUN: --target=arm-linux-gnueabi \
Index: test/Driver/nostdlib.c
===
--- test/Driver/nostdlib.c
+++ test/Driver/nostdlib.c
@@ -27,5 +27,5 @@
 //
 // CHECK-LINUX-NOSTDLIB: warning: argument unused during compilation: 
'--rtlib=compiler-rt'
 // CHECK-LINUX-NOSTDLIB: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
-// CHECK-LINUX-NOSTDLIB-NOT: 
"{{.*}}/Inputs/resource_dir{{/|}}lib{{/|}}linux{{/|}}libclang_rt.builtins-i686.a"
+// CHECK-LINUX-NOSTDLIB-NOT: 
"{{.*}}/Inputs/resource_dir{{/|}}lib{{/|}}linux{{/|}}libclang_rt.builtins-i386.a"
 // CHECK-MSVC-NOSTDLIB: warning: argument unused during compilation: 
'--rtlib=compiler-rt'
Index: test/Driver/linux-ld.c
===
--- test/Driver/linux-ld.c
+++ test/Driver/linux-ld.c
@@ -71,6 +71,27 @@
 // CHECK-LD-RT: libclang_rt.builtins-x86_64.a"
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: --target=i686-unknown-linux \
+// RUN: --gcc-toolchain="" \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN: --rtlib=compiler-rt \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-RT-I686 %s
+// CHECK-LD-RT-I686-NOT: warning:
+// CHECK-LD-RT-I686: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-LD-RT-I686: "--eh-frame-hdr"
+// CHECK-LD-RT-I686: "-m" "elf_i386"
+// CHECK-LD-RT-I686: "-dynamic-linker"
+// CHECK-LD-RT-I686: 
"{{.*}}/usr/lib/gcc/i686-unknown-linux/4.6.0{{/|}}crtbegin.o"
+// CHECK-LD-RT-I686: "-L[[SYSROOT]]/usr/lib/gcc/i686-unknown-linux/4.6.0"
+// CHECK-LD-RT-I686: 
"-L[[SYSROOT]]/usr/lib/gcc/i686-unknown-linux/4.6.0/../../../../i686-unknown-linux/lib"
+// CHECK-LD-RT-I686: 
"-L[[SYSROOT]]/usr/lib/gcc/i686-unknown-linux/4.6.0/../../.."
+// CHECK-LD-RT-I686: "-L[[SYSROOT]]/lib"
+// CHECK-LD-RT-I686: "-L[[SYSROOT]]/usr/lib"
+// CHECK-LD-RT-I686: libclang_rt.builtins-i386.a"
+// CHECK-LD-RT-I686: "-lc"
+// CHECK-LD-RT-I686: libclang_rt.builtins-i386.a"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: --target=arm-linux-androideabi \
 // RUN: --gcc-toolchain="" \
 // RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \
Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -297,15 +297,12 @@
   const llvm::Triple &Triple = TC.getTriple();
   bool IsWindows = Triple.isOSWindows();
 
-  if (Triple.isWindowsMSVCEnvironment() && TC.getArch() == llvm::Triple::x86)
-return "i386";
-
   if (T

[PATCH] D26796: [Driver] Use arch type to find compiler-rt libraries (on Linux)

2017-08-26 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd accepted this revision.
compnerd added a comment.

I don't think that there is a guarantee that compiler-rt and clang are upgraded 
in lockstep.  At least for the builtins, there is a relatively stable 
interface.  However, I don't think that at this point the Windows MSVC 
environment depends on compiler-rt much (except for complex 
multiplication/division in C99+).  That can be satisfied with `vcclang.lib`.  
So, this is probably better off now than before.


https://reviews.llvm.org/D26796



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


r311836 - [Driver] Use arch type to find compiler-rt libraries (on Linux)

2017-08-26 Thread Michal Gorny via cfe-commits
Author: mgorny
Date: Sat Aug 26 14:35:11 2017
New Revision: 311836

URL: http://llvm.org/viewvc/llvm-project?rev=311836&view=rev
Log:
[Driver] Use arch type to find compiler-rt libraries (on Linux)

Use llvm::Triple::getArchTypeName() when looking for compiler-rt
libraries, rather than the exact arch string from the triple. This is
more correct as it matches the values used when building compiler-rt
(builtin-config-ix.cmake) which are the subset of the values allowed
in triples.

For example, this fixes an issue when the compiler set for
i686-pc-linux-gnu triple would not find an i386 compiler-rt library,
while this is the exact arch that is detected by compiler-rt. The same
applies to any other i?86 variant allowed by LLVM.

This also makes the special case for MSVC unnecessary, since now i386
will be used reliably for all 32-bit x86 variants.

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

Added:
cfe/trunk/test/Driver/Inputs/basic_linux_tree/usr/i686-unknown-linux/
cfe/trunk/test/Driver/Inputs/basic_linux_tree/usr/i686-unknown-linux/lib/

cfe/trunk/test/Driver/Inputs/basic_linux_tree/usr/i686-unknown-linux/lib/.keep

cfe/trunk/test/Driver/Inputs/basic_linux_tree/usr/lib/gcc/i686-unknown-linux/

cfe/trunk/test/Driver/Inputs/basic_linux_tree/usr/lib/gcc/i686-unknown-linux/4.6.0/

cfe/trunk/test/Driver/Inputs/basic_linux_tree/usr/lib/gcc/i686-unknown-linux/4.6.0/crtbegin.o
Modified:
cfe/trunk/lib/Driver/ToolChain.cpp
cfe/trunk/test/Driver/linux-ld.c
cfe/trunk/test/Driver/nostdlib.c
cfe/trunk/test/Driver/print-libgcc-file-name-clangrt.c
cfe/trunk/test/Driver/windows-cross.c

Modified: cfe/trunk/lib/Driver/ToolChain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=311836&r1=311835&r2=311836&view=diff
==
--- cfe/trunk/lib/Driver/ToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChain.cpp Sat Aug 26 14:35:11 2017
@@ -297,15 +297,12 @@ static StringRef getArchNameForCompilerR
   const llvm::Triple &Triple = TC.getTriple();
   bool IsWindows = Triple.isOSWindows();
 
-  if (Triple.isWindowsMSVCEnvironment() && TC.getArch() == llvm::Triple::x86)
-return "i386";
-
   if (TC.getArch() == llvm::Triple::arm || TC.getArch() == llvm::Triple::armeb)
 return (arm::getARMFloatABI(TC, Args) == arm::FloatABI::Hard && !IsWindows)
? "armhf"
: "arm";
 
-  return TC.getArchName();
+  return llvm::Triple::getArchTypeName(TC.getArch());
 }
 
 std::string ToolChain::getCompilerRTPath() const {

Added: 
cfe/trunk/test/Driver/Inputs/basic_linux_tree/usr/i686-unknown-linux/lib/.keep
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/basic_linux_tree/usr/i686-unknown-linux/lib/.keep?rev=311836&view=auto
==
(empty)

Added: 
cfe/trunk/test/Driver/Inputs/basic_linux_tree/usr/lib/gcc/i686-unknown-linux/4.6.0/crtbegin.o
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/basic_linux_tree/usr/lib/gcc/i686-unknown-linux/4.6.0/crtbegin.o?rev=311836&view=auto
==
(empty)

Modified: cfe/trunk/test/Driver/linux-ld.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/linux-ld.c?rev=311836&r1=311835&r2=311836&view=diff
==
--- cfe/trunk/test/Driver/linux-ld.c (original)
+++ cfe/trunk/test/Driver/linux-ld.c Sat Aug 26 14:35:11 2017
@@ -71,6 +71,27 @@
 // CHECK-LD-RT: libclang_rt.builtins-x86_64.a"
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: --target=i686-unknown-linux \
+// RUN: --gcc-toolchain="" \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN: --rtlib=compiler-rt \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-RT-I686 %s
+// CHECK-LD-RT-I686-NOT: warning:
+// CHECK-LD-RT-I686: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-LD-RT-I686: "--eh-frame-hdr"
+// CHECK-LD-RT-I686: "-m" "elf_i386"
+// CHECK-LD-RT-I686: "-dynamic-linker"
+// CHECK-LD-RT-I686: 
"{{.*}}/usr/lib/gcc/i686-unknown-linux/4.6.0{{/|}}crtbegin.o"
+// CHECK-LD-RT-I686: "-L[[SYSROOT]]/usr/lib/gcc/i686-unknown-linux/4.6.0"
+// CHECK-LD-RT-I686: 
"-L[[SYSROOT]]/usr/lib/gcc/i686-unknown-linux/4.6.0/../../../../i686-unknown-linux/lib"
+// CHECK-LD-RT-I686: 
"-L[[SYSROOT]]/usr/lib/gcc/i686-unknown-linux/4.6.0/../../.."
+// CHECK-LD-RT-I686: "-L[[SYSROOT]]/lib"
+// CHECK-LD-RT-I686: "-L[[SYSROOT]]/usr/lib"
+// CHECK-LD-RT-I686: libclang_rt.builtins-i386.a"
+// CHECK-LD-RT-I686: "-lc"
+// CHECK-LD-RT-I686: libclang_rt.builtins-i386.a"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: --target=arm-linux-androideabi \
 // RUN: --gcc-toolchain="" \
 // RUN: --sysroot=%S/Inputs/basic_android_tree/s

[PATCH] D26796: [Driver] Use arch type to find compiler-rt libraries (on Linux)

2017-08-26 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL311836: [Driver] Use arch type to find compiler-rt libraries 
(on Linux) (authored by mgorny).

Changed prior to commit:
  https://reviews.llvm.org/D26796?vs=112796&id=112800#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26796

Files:
  cfe/trunk/lib/Driver/ToolChain.cpp
  cfe/trunk/test/Driver/Inputs/basic_linux_tree/usr/i686-unknown-linux/lib/.keep
  
cfe/trunk/test/Driver/Inputs/basic_linux_tree/usr/lib/gcc/i686-unknown-linux/4.6.0/crtbegin.o
  cfe/trunk/test/Driver/linux-ld.c
  cfe/trunk/test/Driver/nostdlib.c
  cfe/trunk/test/Driver/print-libgcc-file-name-clangrt.c
  cfe/trunk/test/Driver/windows-cross.c


Index: cfe/trunk/test/Driver/print-libgcc-file-name-clangrt.c
===
--- cfe/trunk/test/Driver/print-libgcc-file-name-clangrt.c
+++ cfe/trunk/test/Driver/print-libgcc-file-name-clangrt.c
@@ -6,9 +6,15 @@
 // CHECK-CLANGRT-X8664: libclang_rt.builtins-x86_64.a
 
 // RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \
+// RUN: --target=i386-pc-linux \
+// RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-I386 %s
+// CHECK-CLANGRT-I386: libclang_rt.builtins-i386.a
+
+// Check whether alternate arch values map to the correct library.
+//
+// RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \
 // RUN: --target=i686-pc-linux \
-// RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-I686 %s
-// CHECK-CLANGRT-I686: libclang_rt.builtins-i686.a
+// RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-I386 %s
 
 // RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \
 // RUN: --target=arm-linux-gnueabi \
Index: cfe/trunk/test/Driver/linux-ld.c
===
--- cfe/trunk/test/Driver/linux-ld.c
+++ cfe/trunk/test/Driver/linux-ld.c
@@ -71,6 +71,27 @@
 // CHECK-LD-RT: libclang_rt.builtins-x86_64.a"
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: --target=i686-unknown-linux \
+// RUN: --gcc-toolchain="" \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN: --rtlib=compiler-rt \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-RT-I686 %s
+// CHECK-LD-RT-I686-NOT: warning:
+// CHECK-LD-RT-I686: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-LD-RT-I686: "--eh-frame-hdr"
+// CHECK-LD-RT-I686: "-m" "elf_i386"
+// CHECK-LD-RT-I686: "-dynamic-linker"
+// CHECK-LD-RT-I686: 
"{{.*}}/usr/lib/gcc/i686-unknown-linux/4.6.0{{/|}}crtbegin.o"
+// CHECK-LD-RT-I686: "-L[[SYSROOT]]/usr/lib/gcc/i686-unknown-linux/4.6.0"
+// CHECK-LD-RT-I686: 
"-L[[SYSROOT]]/usr/lib/gcc/i686-unknown-linux/4.6.0/../../../../i686-unknown-linux/lib"
+// CHECK-LD-RT-I686: 
"-L[[SYSROOT]]/usr/lib/gcc/i686-unknown-linux/4.6.0/../../.."
+// CHECK-LD-RT-I686: "-L[[SYSROOT]]/lib"
+// CHECK-LD-RT-I686: "-L[[SYSROOT]]/usr/lib"
+// CHECK-LD-RT-I686: libclang_rt.builtins-i386.a"
+// CHECK-LD-RT-I686: "-lc"
+// CHECK-LD-RT-I686: libclang_rt.builtins-i386.a"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: --target=arm-linux-androideabi \
 // RUN: --gcc-toolchain="" \
 // RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \
Index: cfe/trunk/test/Driver/nostdlib.c
===
--- cfe/trunk/test/Driver/nostdlib.c
+++ cfe/trunk/test/Driver/nostdlib.c
@@ -27,5 +27,5 @@
 //
 // CHECK-LINUX-NOSTDLIB: warning: argument unused during compilation: 
'--rtlib=compiler-rt'
 // CHECK-LINUX-NOSTDLIB: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
-// CHECK-LINUX-NOSTDLIB-NOT: 
"{{.*}}/Inputs/resource_dir{{/|}}lib{{/|}}linux{{/|}}libclang_rt.builtins-i686.a"
+// CHECK-LINUX-NOSTDLIB-NOT: 
"{{.*}}/Inputs/resource_dir{{/|}}lib{{/|}}linux{{/|}}libclang_rt.builtins-i386.a"
 // CHECK-MSVC-NOSTDLIB: warning: argument unused during compilation: 
'--rtlib=compiler-rt'
Index: cfe/trunk/test/Driver/windows-cross.c
===
--- cfe/trunk/test/Driver/windows-cross.c
+++ cfe/trunk/test/Driver/windows-cross.c
@@ -64,7 +64,7 @@
 // RUN:| FileCheck %s --check-prefix CHECK-SANITIZE-ADDRESS-EXE-X86
 
 // CHECK-SANITIZE-ADDRESS-EXE-X86: "-fsanitize=address"
-// CHECK-SANITIZE-ADDRESS-EXE-X86: "{{.*}}clang_rt.asan_dynamic-i686.lib" 
"{{.*}}clang_rt.asan_dynamic_runtime_thunk-i686.lib" "--undefined" 
"___asan_seh_interceptor"
+// CHECK-SANITIZE-ADDRESS-EXE-X86: "{{.*}}clang_rt.asan_dynamic-i386.lib" 
"{{.*}}clang_rt.asan_dynamic_runtime_thunk-i386.lib" "--undefined" 
"___asan_seh_interceptor"
 
 // RUN: %clang -### -target armv7-windows-itanium --sysroot 
%S/Inputs/Windows/ARM/8.1 -B %S/Inputs/Windows/ARM/8.1/usr/bin 
-fuse-ld=lld-link2 -shared -o shared.dll -fsanitize=tsan -x c++ %s 2>&1 \
 // RUN:| FileCheck %s --check-prefix CHECK-SANITIZE-TSAN
Index: cfe/trunk/lib/Driver/ToolChain.cpp
=

[PATCH] D26796: [Driver] Use arch type to find compiler-rt libraries (on Linux)

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

Thanks a lot. Let's hope no buildbot complains now ;-).


Repository:
  rL LLVM

https://reviews.llvm.org/D26796



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


[PATCH] D15465: [git-clang-format]: New option to perform formatting against staged changes only

2017-08-26 Thread Alexander Shukaev via Phabricator via cfe-commits
Alexander-Shukaev updated this revision to Diff 112801.
Alexander-Shukaev added a comment.

Alright, so you got me excited about this task once again.  Now, I've just 
rebased to the latest `git-clang-format` and it has changed a bit.  
Nevertheless, I've updated the previous patch accordingly and applied those 
changes which @lodato was proposing (except for getting rid of 
`run_git_ls_files_and_save_to_tree` as I'm still not sure whether this would be 
the same as `git write-tree`).  Anyway, just tested the exact scenario posted 
by @lodato, and indeed with the current patch it works as he expects.  Namely, 
there is no diff from unstaged tree interfering anymore.  So far so good, but 
as I said in my previous post, there is another side of the medal.  If you 
didn't get it, then read through it again and try, for example, the following 
amended @lodato's scenario:

  $ mkdir tmp
  $ cd tmp
  $ git init
  $ cat > foo.cc < foo.cc  1:
 if not opts.diff:
   die('--diff is required when two commits are given')
+if opts.staged:
+  die('--staged is not allowed when two commits are given')
   else:
 if len(commits) > 2:
   die('at most two commits allowed; %d given' % len(commits))
-  changed_lines = compute_diff_and_extract_lines(commits, files)
+  changed_lines = compute_diff_and_extract_lines(commits, files, opts.staged)
   if opts.verbose >= 1:
 ignored_files = set(changed_lines)
   filter_by_extension(changed_lines, opts.extensions.lower().split(','))
@@ -159,10 +163,14 @@
  binary=opts.binary,
  style=opts.style)
   else:
-old_tree = create_tree_from_workdir(changed_lines)
+if opts.staged:
+  old_tree = run_git_ls_files_and_save_to_tree(changed_lines)
+else:
+  old_tree = create_tree_from_workdir(changed_lines)
 new_tree = run_clang_format_and_save_to_tree(changed_lines,
  binary=opts.binary,
- style=opts.style)
+ style=opts.style,
+ staged=opts.staged)
   if opts.verbose >= 1:
 print('old tree: %s' % old_tree)
 print('new tree: %s' % new_tree)
@@ -261,9 +269,10 @@
   return convert_string(stdout.strip())
 
 
-def compute_diff_and_extract_lines(commits, files):
+def compute_diff_and_extract_lines(commits, files, staged=False):
   """Calls compute_diff() followed by extract_lines()."""
-  diff_process = compute_diff(commits, files)
+  assert not staged or len(commits) < 2
+  diff_process = compute_diff(commits, files, staged)
   changed_lines = extract_lines(diff_process.stdout)
   diff_process.stdout.close()
   diff_process.wait()
@@ -273,17 +282,22 @@
   return changed_lines
 
 
-def compute_diff(commits, files):
+def compute_diff(commits, files, staged=False):
   """Return a subprocess object producing the diff from `commits`.
 
   The return value's `stdin` file object will produce a patch with the
   differences between the working directory and the first commit if a single
   one was specified, or the difference between both specified commits, filtered
   on `files` (if non-empty).  Zero context lines are used in the patch."""
-  git_tool = 'diff-index'
+  assert not staged or len(commits) < 2
+  cmd = ['git']
   if len(commits) > 1:
-git_tool = 'diff-tree'
-  cmd = ['git', git_tool, '-p', '-U0'] + commits + ['--']
+cmd.append('diff-tree')
+  else:
+cmd.append('diff-index')
+  if staged:
+cmd.append('--cached')
+  cmd.extend(['-p', '-U0'] + commits + ['--'])
   cmd.extend(files)
   p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
   p.stdin.close()
@@ -343,11 +357,43 @@
   return create_tree(filenames, '--stdin')
 
 
+def run_git_ls_files_and_save_to_tree(changed_lines):
+  """Run git ls-files and save the result to a git tree.
+
+  Returns the object ID (SHA-1) of the created tree."""
+  index_path = os.environ.get('GIT_INDEX_FILE')
+  def iteritems(container):
+  try:
+  return container.iteritems() # Python 2
+  except AttributeError:
+  return container.items() # Python 3
+  def index_info_generator():
+for filename, lin

r311839 - Pass the correct object argument when a member call to an 'unrelated' class is made.

2017-08-26 Thread Faisal Vali via cfe-commits
Author: faisalv
Date: Sat Aug 26 19:21:21 2017
New Revision: 311839

URL: http://llvm.org/viewvc/llvm-project?rev=311839&view=rev
Log:
Pass the correct object argument when a member call to an 'unrelated' class is 
made.

Prior to this patch, clang would do the wrong thing here (see inline comments 
for pre-patch behavior):

  struct A {
void bar(int) { }
static void bar(double) { }

void g(int*);
static void g(char *);
  };


  struct B {
void f() {
  A::bar(3);  // selects (double) ??!!
  A::g((int*)0); // Instead of no object argument, states conversion 
error?!!
}
  };


The fix is as follows:  When we detect that what appears to be an implicit 
member function call (A::bar) is actually a call to a member of a class (A) 
unrelated to the type (B) that contains the member function (B::f) from which 
the call is being made, don't treat it (A::bar) as an Implicit Member Call 
Expression.

P.S. I wonder if there is an existing bug report related to this? 
(Surprisingly, a cursory search did not find one).


Modified:
cfe/trunk/lib/Sema/SemaExprMember.cpp
cfe/trunk/test/SemaCXX/member-expr.cpp

Modified: cfe/trunk/lib/Sema/SemaExprMember.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprMember.cpp?rev=311839&r1=311838&r2=311839&view=diff
==
--- cfe/trunk/lib/Sema/SemaExprMember.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprMember.cpp Sat Aug 26 19:21:21 2017
@@ -243,7 +243,6 @@ Sema::BuildPossibleImplicitMemberExpr(co
 return BuildImplicitMemberExpr(SS, TemplateKWLoc, R, TemplateArgs, true, 
S);
 
   case IMA_Mixed:
-  case IMA_Mixed_Unrelated:
   case IMA_Unresolved:
 return BuildImplicitMemberExpr(SS, TemplateKWLoc, R, TemplateArgs, false,
S);
@@ -252,6 +251,7 @@ Sema::BuildPossibleImplicitMemberExpr(co
 Diag(R.getNameLoc(), diag::warn_cxx98_compat_non_static_member_use)
   << R.getLookupNameInfo().getName();
 // Fall through.
+  case IMA_Mixed_Unrelated:
   case IMA_Static:
   case IMA_Abstract:
   case IMA_Mixed_StaticContext:

Modified: cfe/trunk/test/SemaCXX/member-expr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/member-expr.cpp?rev=311839&r1=311838&r2=311839&view=diff
==
--- cfe/trunk/test/SemaCXX/member-expr.cpp (original)
+++ cfe/trunk/test/SemaCXX/member-expr.cpp Sat Aug 26 19:21:21 2017
@@ -228,3 +228,25 @@ namespace pr16676 {
 .i;  // expected-error {{member reference type 'pr16676::S *' is a 
pointer; did you mean to use '->'}}
   }
 }
+
+namespace unrelated_class_instance_call_should_be_illformed {
+
+
+struct A {
+  void bar(int) { }
+  static void bar(double) { }
+  
+  void g(int*);
+  static void g(char *);
+};
+
+
+struct B {
+  void f() {
+A::bar(3);  //expected-error{{call to non-static member}}
+A::g((int*)0); //expected-error{{call to non-static member}}
+  }
+};
+
+
+} // ns unrelated_class_mixed_static_nonstatic_call_should_be_illformed


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


[PATCH] D33852: Enable __declspec(selectany) on linux

2017-08-26 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek marked 9 inline comments as done.
Prazek added a comment.

Sorry for so late fixes, but it would be good to put it in 5.0


https://reviews.llvm.org/D33852



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


[PATCH] D33852: Enable __declspec(selectany) on linux

2017-08-26 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek updated this revision to Diff 112805.
Prazek added a comment.

remove empty line


https://reviews.llvm.org/D33852

Files:
  include/clang/Basic/Attr.td
  test/Sema/attr-selectany.c
  test/SemaCXX/attr-selectany.cpp


Index: test/SemaCXX/attr-selectany.cpp
===
--- test/SemaCXX/attr-selectany.cpp
+++ test/SemaCXX/attr-selectany.cpp
@@ -1,4 +1,7 @@
 // RUN: %clang_cc1 -triple x86_64-win32 -fms-compatibility -fms-extensions 
-fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -fms-compatibility 
-fms-extensions -fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -triple x86_64-win32-macho -fms-compatibility 
-fms-extensions -fsyntax-only -verify -std=c++11 %s
+
 // MSVC produces similar diagnostics.
 
 __declspec(selectany) void foo() { } // expected-error{{'selectany' can only 
be applied to data items with external linkage}}
Index: test/Sema/attr-selectany.c
===
--- test/Sema/attr-selectany.c
+++ test/Sema/attr-selectany.c
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 -triple x86_64-win32 -fdeclspec -verify %s
 // RUN: %clang_cc1 -triple x86_64-mingw32 -verify %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -verify -fdeclspec %s
+// RUN: %clang_cc1 -triple x86_64-win32-macho -verify -fdeclspec %s
 
 extern __declspec(selectany) const int x1 = 1; // no warning, const means we 
need extern in C++
 
Index: include/clang/Basic/Attr.td
===
--- include/clang/Basic/Attr.td
+++ include/clang/Basic/Attr.td
@@ -2472,7 +2472,7 @@
   let Documentation = [DLLImportDocs];
 }
 
-def SelectAny : InheritableAttr, TargetSpecificAttr {
+def SelectAny : InheritableAttr {
   let Spellings = [Declspec<"selectany">, GCC<"selectany">];
   let Documentation = [Undocumented];
 }


Index: test/SemaCXX/attr-selectany.cpp
===
--- test/SemaCXX/attr-selectany.cpp
+++ test/SemaCXX/attr-selectany.cpp
@@ -1,4 +1,7 @@
 // RUN: %clang_cc1 -triple x86_64-win32 -fms-compatibility -fms-extensions -fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -fms-compatibility -fms-extensions -fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -triple x86_64-win32-macho -fms-compatibility -fms-extensions -fsyntax-only -verify -std=c++11 %s
+
 // MSVC produces similar diagnostics.
 
 __declspec(selectany) void foo() { } // expected-error{{'selectany' can only be applied to data items with external linkage}}
Index: test/Sema/attr-selectany.c
===
--- test/Sema/attr-selectany.c
+++ test/Sema/attr-selectany.c
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 -triple x86_64-win32 -fdeclspec -verify %s
 // RUN: %clang_cc1 -triple x86_64-mingw32 -verify %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -verify -fdeclspec %s
+// RUN: %clang_cc1 -triple x86_64-win32-macho -verify -fdeclspec %s
 
 extern __declspec(selectany) const int x1 = 1; // no warning, const means we need extern in C++
 
Index: include/clang/Basic/Attr.td
===
--- include/clang/Basic/Attr.td
+++ include/clang/Basic/Attr.td
@@ -2472,7 +2472,7 @@
   let Documentation = [DLLImportDocs];
 }
 
-def SelectAny : InheritableAttr, TargetSpecificAttr {
+def SelectAny : InheritableAttr {
   let Spellings = [Declspec<"selectany">, GCC<"selectany">];
   let Documentation = [Undocumented];
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33852: Enable __declspec(selectany) on linux

2017-08-26 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek updated this revision to Diff 112804.
Prazek added a comment.

Enable it on every platform


https://reviews.llvm.org/D33852

Files:
  include/clang/Basic/Attr.td
  test/Sema/attr-selectany.c
  test/SemaCXX/attr-selectany.cpp
  utils/TableGen/ClangAttrEmitter.cpp


Index: utils/TableGen/ClangAttrEmitter.cpp
===
--- utils/TableGen/ClangAttrEmitter.cpp
+++ utils/TableGen/ClangAttrEmitter.cpp
@@ -2680,6 +2680,7 @@
 }
 Test += ")";
   }
+
 }
 
 static void GenerateHasAttrSpellingStringSwitch(
Index: test/SemaCXX/attr-selectany.cpp
===
--- test/SemaCXX/attr-selectany.cpp
+++ test/SemaCXX/attr-selectany.cpp
@@ -1,4 +1,7 @@
 // RUN: %clang_cc1 -triple x86_64-win32 -fms-compatibility -fms-extensions 
-fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -fms-compatibility 
-fms-extensions -fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -triple x86_64-win32-macho -fms-compatibility 
-fms-extensions -fsyntax-only -verify -std=c++11 %s
+
 // MSVC produces similar diagnostics.
 
 __declspec(selectany) void foo() { } // expected-error{{'selectany' can only 
be applied to data items with external linkage}}
Index: test/Sema/attr-selectany.c
===
--- test/Sema/attr-selectany.c
+++ test/Sema/attr-selectany.c
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 -triple x86_64-win32 -fdeclspec -verify %s
 // RUN: %clang_cc1 -triple x86_64-mingw32 -verify %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -verify -fdeclspec %s
+// RUN: %clang_cc1 -triple x86_64-win32-macho -verify -fdeclspec %s
 
 extern __declspec(selectany) const int x1 = 1; // no warning, const means we 
need extern in C++
 
Index: include/clang/Basic/Attr.td
===
--- include/clang/Basic/Attr.td
+++ include/clang/Basic/Attr.td
@@ -2472,7 +2472,7 @@
   let Documentation = [DLLImportDocs];
 }
 
-def SelectAny : InheritableAttr, TargetSpecificAttr {
+def SelectAny : InheritableAttr {
   let Spellings = [Declspec<"selectany">, GCC<"selectany">];
   let Documentation = [Undocumented];
 }


Index: utils/TableGen/ClangAttrEmitter.cpp
===
--- utils/TableGen/ClangAttrEmitter.cpp
+++ utils/TableGen/ClangAttrEmitter.cpp
@@ -2680,6 +2680,7 @@
 }
 Test += ")";
   }
+
 }
 
 static void GenerateHasAttrSpellingStringSwitch(
Index: test/SemaCXX/attr-selectany.cpp
===
--- test/SemaCXX/attr-selectany.cpp
+++ test/SemaCXX/attr-selectany.cpp
@@ -1,4 +1,7 @@
 // RUN: %clang_cc1 -triple x86_64-win32 -fms-compatibility -fms-extensions -fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -fms-compatibility -fms-extensions -fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -triple x86_64-win32-macho -fms-compatibility -fms-extensions -fsyntax-only -verify -std=c++11 %s
+
 // MSVC produces similar diagnostics.
 
 __declspec(selectany) void foo() { } // expected-error{{'selectany' can only be applied to data items with external linkage}}
Index: test/Sema/attr-selectany.c
===
--- test/Sema/attr-selectany.c
+++ test/Sema/attr-selectany.c
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 -triple x86_64-win32 -fdeclspec -verify %s
 // RUN: %clang_cc1 -triple x86_64-mingw32 -verify %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -verify -fdeclspec %s
+// RUN: %clang_cc1 -triple x86_64-win32-macho -verify -fdeclspec %s
 
 extern __declspec(selectany) const int x1 = 1; // no warning, const means we need extern in C++
 
Index: include/clang/Basic/Attr.td
===
--- include/clang/Basic/Attr.td
+++ include/clang/Basic/Attr.td
@@ -2472,7 +2472,7 @@
   let Documentation = [DLLImportDocs];
 }
 
-def SelectAny : InheritableAttr, TargetSpecificAttr {
+def SelectAny : InheritableAttr {
   let Spellings = [Declspec<"selectany">, GCC<"selectany">];
   let Documentation = [Undocumented];
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits