[PATCH] D19451: [clang-tidy] New checker for redundant expressions.

2016-04-22 Thread Etienne Bergeron via cfe-commits
etienneb created this revision.
etienneb added a reviewer: alexfh.
etienneb added a subscriber: cfe-commits.

This checker finds redundant expression on both side of a binary operator.

The current implementation provide a function to check whether expression
are the equivalent. This implementation is able to recognize the frequent 
subset encounter in C++ program. Side-effects like "x++" are not considered
to be equivalent.

There are many False Positives related to macros and to floating point
computations (detecting NaN). The checker is ignoring these cases.

Example:
```
if( !dst || dst->depth != desired_depth ||
dst->nChannels != desired_num_channels ||
dst_size.width != src_size.width ||
dst_size.height != dst_size.height )<<--- bug
{
```

http://reviews.llvm.org/D19451

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/RedundantExpressionCheck.cpp
  clang-tidy/misc/RedundantExpressionCheck.h
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-redundant-expression.rst
  test/clang-tidy/misc-redundant-expression.cpp

Index: test/clang-tidy/misc-redundant-expression.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-redundant-expression.cpp
@@ -0,0 +1,112 @@
+// RUN: %check_clang_tidy %s misc-redundant-expression %t
+
+struct Point {
+  int x;
+  int y;
+  int a[5];
+} P;
+
+extern int foo(int x);
+extern int bar(int x);
+extern int bat(int x, int y);
+
+int Test(int X, int Y) {
+  if (X - X) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both side of operator are equivalent [misc-redundant-expression]
+  if (X / X) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both side of operator are equivalent
+  if (X % X) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both side of operator are equivalent
+
+  if (X & X) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both side of operator are equivalent
+  if (X | X) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both side of operator are equivalent
+  if (X ^ X) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both side of operator are equivalent
+
+  if (X < X) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both side of operator are equivalent
+  if (X <= X) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both side of operator are equivalent
+  if (X > X) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both side of operator are equivalent
+  if (X >= X) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both side of operator are equivalent
+
+  if (X && X) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both side of operator are equivalent
+  if (X || X) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both side of operator are equivalent
+
+  if (X != (((X return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both side of operator are equivalent
+
+  if (X + 1 == X + 1) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: both side of operator are equivalent
+  if (X + 1 != X + 1) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: both side of operator are equivalent
+  if (X + 1 <= X + 1) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: both side of operator are equivalent
+  if (X + 1 >= X + 1) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: both side of operator are equivalent
+
+  if ((X != 1 || Y != 1) && (X != 1 || Y != 1)) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: both side of operator are equivalent
+  if (P.a[X - P.x] != P.a[X - P.x]) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: both side of operator are equivalent
+
+  if ((int)X < (int)X) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: both side of operator are equivalent
+
+  if ( + "dummy" == + "dummy") return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: both side of operator are equivalent
+  if (L"abc" == L"abc") return 1; 
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: both side of operator are equivalent
+
+  if (foo(0) - 2 < foo(0) - 2) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: both side of operator are equivalent  
+  if (foo(bar(0)) < (foo(bar((0) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: both side of operator are equivalent  
+
+  return 0;
+}
+
+int Valid(int X, int Y) {
+  if (X != Y) return 1;
+  if (X == X + 0) return 1;
+  if (P.x == P.y) return 1;
+  if (P.a[P.x] < P.a[P.y]) return 1;
+  if (P.a[0] < P.a[1]) return 1;
+
+  if (P.a[0] < P.a[0ULL]) return 1;
+  if (0 < 0ULL) return 1;
+  if ((int)0 < (int)0ULL) return 1;
+
+  if (++X != ++X) return 1;
+  if (P.a[X]++ != P.a[X]++) return 1;
+  if (P.a[X++] != P.a[X++]) return 1;
+
+  if ("abc" == "ABC") return 1;
+  if (foo(bar(0)) < (foo(bat(0, 1 return 1;
+  return 0;
+}
+
+#define LT(x, y) (void)((x) < (y))
+
+int TestMacro(int X, int Y) {
+  LT(0, 0)

r267263 - [profile] Fix another use of the driver.

2016-04-22 Thread Sean Silva via cfe-commits
Author: silvas
Date: Fri Apr 22 21:13:48 2016
New Revision: 267263

URL: http://llvm.org/viewvc/llvm-project?rev=267263&view=rev
Log:
[profile] Fix another use of the driver.

Follow-on to r267262.

Modified:
cfe/trunk/test/Profile/cxx-indirect-call.cpp

Modified: cfe/trunk/test/Profile/cxx-indirect-call.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/cxx-indirect-call.cpp?rev=267263&r1=267262&r2=267263&view=diff
==
--- cfe/trunk/test/Profile/cxx-indirect-call.cpp (original)
+++ cfe/trunk/test/Profile/cxx-indirect-call.cpp Fri Apr 22 21:13:48 2016
@@ -1,6 +1,6 @@
 // Check the value profiling instrinsics emitted by instrumentation.
 
-// RUN: %clangxx %s -o - -emit-llvm -S -fprofile-instr-generate -mllvm 
-enable-value-profiling -fexceptions -target %itanium_abi_triple | FileCheck %s
+// RUN: %clang_cc1 %s -o - -emit-llvm -fprofile-instrument=clang -mllvm 
-enable-value-profiling -fexceptions -fcxx-exceptions -triple 
%itanium_abi_triple | FileCheck %s
 
 void (*foo) (void);
 


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


r267262 - [profile] Use cc1 in these tests instead of the driver.

2016-04-22 Thread Sean Silva via cfe-commits
Author: silvas
Date: Fri Apr 22 21:11:16 2016
New Revision: 267262

URL: http://llvm.org/viewvc/llvm-project?rev=267262&view=rev
Log:
[profile] Use cc1 in these tests instead of the driver.

I ran into this when seeing what tests would break if we make a
driver-level decision about whether FEPGO or IRPGO is the default.

Modified:
cfe/trunk/test/Profile/cxx-class.cpp
cfe/trunk/test/Profile/cxx-throws.cpp
cfe/trunk/test/Profile/func-entry.c
cfe/trunk/test/Profile/max-function-count.c
cfe/trunk/test/Profile/profile-summary.c

Modified: cfe/trunk/test/Profile/cxx-class.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/cxx-class.cpp?rev=267262&r1=267261&r2=267262&view=diff
==
--- cfe/trunk/test/Profile/cxx-class.cpp (original)
+++ cfe/trunk/test/Profile/cxx-class.cpp Fri Apr 22 21:11:16 2016
@@ -1,13 +1,13 @@
 // Tests for instrumentation of C++ methods, constructors, and destructors.
 
-// RUN: %clang %s -o - -emit-llvm -S -fprofile-instr-generate -fno-exceptions 
-target %itanium_abi_triple > %tgen
+// RUN: %clang_cc1 %s -o - -emit-llvm -fprofile-instrument=clang -triple 
%itanium_abi_triple > %tgen
 // RUN: FileCheck --input-file=%tgen -check-prefix=CTRGEN %s
 // RUN: FileCheck --input-file=%tgen -check-prefix=DTRGEN %s
 // RUN: FileCheck --input-file=%tgen -check-prefix=MTHGEN %s
 // RUN: FileCheck --input-file=%tgen -check-prefix=WRPGEN %s
 
 // RUN: llvm-profdata merge %S/Inputs/cxx-class.proftext -o %t.profdata
-// RUN: %clang %s -o - -emit-llvm -S -fprofile-instr-use=%t.profdata 
-fno-exceptions -target %itanium_abi_triple > %tuse
+// RUN: %clang_cc1 %s -o - -emit-llvm 
-fprofile-instrument-use-path=%t.profdata -triple %itanium_abi_triple > %tuse
 // RUN: FileCheck --input-file=%tuse -check-prefix=CTRUSE %s
 // RUN: FileCheck --input-file=%tuse -check-prefix=DTRUSE %s
 // RUN: FileCheck --input-file=%tuse -check-prefix=MTHUSE %s

Modified: cfe/trunk/test/Profile/cxx-throws.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/cxx-throws.cpp?rev=267262&r1=267261&r2=267262&view=diff
==
--- cfe/trunk/test/Profile/cxx-throws.cpp (original)
+++ cfe/trunk/test/Profile/cxx-throws.cpp Fri Apr 22 21:11:16 2016
@@ -3,12 +3,12 @@
 // FIXME: Don't seek bb labels, like "if.else"
 // REQUIRES: asserts
 
-// RUN: %clangxx %s -o - -emit-llvm -S -fprofile-instr-generate -fexceptions 
-target %itanium_abi_triple | FileCheck -check-prefix=PGOGEN %s
-// RUN: %clangxx %s -o - -emit-llvm -S -fprofile-instr-generate -fexceptions 
-target %itanium_abi_triple | FileCheck -check-prefix=PGOGEN-EXC %s
+// RUN: %clang_cc1 %s -o - -emit-llvm -fprofile-instrument=clang -fexceptions 
-fcxx-exceptions -triple %itanium_abi_triple | FileCheck -check-prefix=PGOGEN %s
+// RUN: %clang_cc1 %s -o - -emit-llvm -fprofile-instrument=clang -fexceptions 
-fcxx-exceptions -triple %itanium_abi_triple | FileCheck 
-check-prefix=PGOGEN-EXC %s
 
 // RUN: llvm-profdata merge %S/Inputs/cxx-throws.proftext -o %t.profdata
-// RUN: %clang %s -o - -emit-llvm -S -fprofile-instr-use=%t.profdata 
-fcxx-exceptions -target %itanium_abi_triple | FileCheck -check-prefix=PGOUSE %s
-// RUN: %clang %s -o - -emit-llvm -S -fprofile-instr-use=%t.profdata 
-fcxx-exceptions -target %itanium_abi_triple | FileCheck 
-check-prefix=PGOUSE-EXC %s
+// RUN: %clang_cc1 %s -o - -emit-llvm 
-fprofile-instrument-use-path=%t.profdata -fexceptions -fcxx-exceptions -triple 
%itanium_abi_triple | FileCheck -check-prefix=PGOUSE %s
+// RUN: %clang_cc1 %s -o - -emit-llvm 
-fprofile-instrument-use-path=%t.profdata -fexceptions -fcxx-exceptions -triple 
%itanium_abi_triple | FileCheck -check-prefix=PGOUSE-EXC %s
 
 // PGOGEN: @[[THC:__profc__Z6throwsv]] = private global [9 x i64] 
zeroinitializer
 // PGOGEN-EXC: @[[THC:__profc__Z6throwsv]] = private global [9 x i64] 
zeroinitializer

Modified: cfe/trunk/test/Profile/func-entry.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/func-entry.c?rev=267262&r1=267261&r2=267262&view=diff
==
--- cfe/trunk/test/Profile/func-entry.c (original)
+++ cfe/trunk/test/Profile/func-entry.c Fri Apr 22 21:11:16 2016
@@ -1,7 +1,7 @@
 // Test that function entry counts are set correctly.
 
 // RUN: llvm-profdata merge %S/Inputs/func-entry.proftext -o %t.profdata
-// RUN: %clang %s -o - -mllvm -disable-llvm-optzns -emit-llvm -S 
-fprofile-instr-use=%t.profdata | FileCheck %s
+// RUN: %clang_cc1 %s -o - -disable-llvm-optzns -emit-llvm 
-fprofile-instrument-use-path=%t.profdata | FileCheck %s
 
 void foo(void);
 

Modified: cfe/trunk/test/Profile/max-function-count.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/max-function-count.c?rev=267262&r1=267261&r2=267262&view=diff
==
--- 

Re: [PATCH] D19393: Move Checkers.inc to clang/include/.../Checkers

2016-04-22 Thread Chih-Hung Hsieh via cfe-commits
chh updated this revision to Diff 54758.
chh added a comment.

Also move Checkers.td to clang/include/.../Checkers.


http://reviews.llvm.org/D19393

Files:
  include/clang/CMakeLists.txt
  include/clang/StaticAnalyzer/Checkers/CMakeLists.txt
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/ClangCheckers.cpp
  lib/StaticAnalyzer/Checkers/ClangSACheckers.h

Index: lib/StaticAnalyzer/Checkers/ClangSACheckers.h
===
--- lib/StaticAnalyzer/Checkers/ClangSACheckers.h
+++ lib/StaticAnalyzer/Checkers/ClangSACheckers.h
@@ -26,7 +26,7 @@
 #define GET_CHECKERS
 #define CHECKER(FULLNAME,CLASS,CXXFILE,HELPTEXT,GROUPINDEX,HIDDEN)\
   void register##CLASS(CheckerManager &mgr);
-#include "Checkers.inc"
+#include "clang/StaticAnalyzer/Checkers/Checkers.inc"
 #undef CHECKER
 #undef GET_CHECKERS
 
Index: lib/StaticAnalyzer/Checkers/ClangCheckers.cpp
===
--- lib/StaticAnalyzer/Checkers/ClangCheckers.cpp
+++ lib/StaticAnalyzer/Checkers/ClangCheckers.cpp
@@ -27,6 +27,6 @@
 #define GET_CHECKERS
 #define CHECKER(FULLNAME,CLASS,DESCFILE,HELPTEXT,GROUPINDEX,HIDDEN)\
   registry.addChecker(register##CLASS, FULLNAME, HELPTEXT);
-#include "Checkers.inc"
+#include "clang/StaticAnalyzer/Checkers/Checkers.inc"
 #undef GET_CHECKERS
 }
Index: lib/StaticAnalyzer/Checkers/Checkers.td
===
--- lib/StaticAnalyzer/Checkers/Checkers.td
+++ lib/StaticAnalyzer/Checkers/Checkers.td
@@ -1,651 +0,0 @@
-//===--- Checkers.td - Static Analyzer Checkers -===---===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-
-include "clang/StaticAnalyzer/Checkers/CheckerBase.td"
-
-//===--===//
-// Packages.
-//===--===//
-
-// The Alpha package is for checkers that have too many false positives to be
-// turned on by default. The hierarchy under Alpha should be organized in the
-// hierarchy checkers would have had if they were truly at the top level.
-// (For example, a Cocoa-specific checker that is alpha should be in
-// alpha.osx.cocoa).
-def Alpha : Package<"alpha">;
-
-def Core : Package<"core">;
-def CoreBuiltin : Package<"builtin">, InPackage;
-def CoreUninitialized  : Package<"uninitialized">, InPackage;
-def CoreAlpha : Package<"core">, InPackage, Hidden;
-
-// The OptIn package is for checkers that are not alpha and that would normally
-// be on by default but where the driver does not have enough information to
-// determine when they are applicable. For example, localizability checkers fit
-// this criterion because the driver cannot determine whether a project is
-// localized or not -- this is best determined at the IDE or build-system level.
-//
-// The checker hierarchy under OptIn should mirror that in Alpha: checkers
-// should be organized as if they were at the top level.
-//
-// Note: OptIn is *not* intended for checkers that are too noisy to be on by
-// default. Such checkers belong in the alpha package.
-def OptIn : Package<"optin">;
-
-def Nullability : Package<"nullability">;
-
-def Cplusplus : Package<"cplusplus">;
-def CplusplusAlpha : Package<"cplusplus">, InPackage, Hidden;
-
-def DeadCode : Package<"deadcode">;
-def DeadCodeAlpha : Package<"deadcode">, InPackage, Hidden;
-
-def Performance : Package<"performance">, InPackage;
-
-def Security : Package <"security">;
-def InsecureAPI : Package<"insecureAPI">, InPackage;
-def SecurityAlpha : Package<"security">, InPackage, Hidden;
-def Taint : Package<"taint">, InPackage, Hidden;
-
-def Unix : Package<"unix">;
-def UnixAlpha : Package<"unix">, InPackage, Hidden;
-def CString : Package<"cstring">, InPackage, Hidden;
-def CStringAlpha : Package<"cstring">, InPackage, Hidden;
-
-def OSX : Package<"osx">;
-def OSXAlpha : Package<"osx">, InPackage, Hidden;
-def OSXOptIn : Package<"osx">, InPackage;
-
-def Cocoa : Package<"cocoa">, InPackage;
-def CocoaAlpha : Package<"cocoa">, InPackage, Hidden;
-def CocoaOptIn : Package<"cocoa">, InPackage;
-
-def CoreFoundation : Package<"coreFoundation">, InPackage;
-def Containers : Package<"containers">, InPackage;
-
-def LocalizabilityAlpha : Package<"localizability">, InPackage;
-def LocalizabilityOptIn : Package<"localizability">, InPackage;
-
-def LLVM : Package<"llvm">;
-def Debug : Package<"debug">;
-
-//===--===//
-// Core Checkers.
-//===--

Re: [PATCH] D19204: clang-format: [JS] generator and async functions.

2016-04-22 Thread Martin Probst via cfe-commits
mprobst added a comment.

Friendly ping.


http://reviews.llvm.org/D19204



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


LLVM buildmaster will be updated and restarted tonight

2016-04-22 Thread Galina Kistanova via cfe-commits
Hello everyone,

LLVM buildmaster will be updated and restarted after 6 PM Pacific time
today.

Thanks

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


[clang-tools-extra] r267254 - [clang-tidy] Fix misc-macro-repeated-side-effects false positive with stringified arguments

2016-04-22 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Fri Apr 22 19:00:08 2016
New Revision: 267254

URL: http://llvm.org/viewvc/llvm-project?rev=267254&view=rev
Log:
[clang-tidy] Fix misc-macro-repeated-side-effects false positive with 
stringified arguments

Added:
clang-tools-extra/trunk/test/clang-tidy/misc-macro-repeated-side-effects.c
  - copied, changed from r267228, 
clang-tools-extra/trunk/test/clang-tidy/misc-repeated-side-effects-in-macro.c
Removed:

clang-tools-extra/trunk/test/clang-tidy/misc-repeated-side-effects-in-macro.c
Modified:
clang-tools-extra/trunk/clang-tidy/misc/MacroRepeatedSideEffectsCheck.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/misc/MacroRepeatedSideEffectsCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/MacroRepeatedSideEffectsCheck.cpp?rev=267254&r1=267253&r2=267254&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/MacroRepeatedSideEffectsCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/misc/MacroRepeatedSideEffectsCheck.cpp 
Fri Apr 22 19:00:08 2016
@@ -86,6 +86,7 @@ unsigned MacroRepeatedPPCallbacks::count
   int SkipParenCount = 0;
   // Has a __builtin_constant_p been found?
   bool FoundBuiltin = false;
+  bool PrevTokenIsHash = false;
   // Count when "?" is reached. The "Current" will get this value when the ":"
   // is reached.
   std::stack> CountAtQuestion;
@@ -98,6 +99,16 @@ unsigned MacroRepeatedPPCallbacks::count
 if (FoundBuiltin && T.isOneOf(tok::question, tok::ampamp, tok::pipepipe))
   return Max;
 
+// Skip stringified tokens.
+if (T.is(tok::hash)) {
+  PrevTokenIsHash = true;
+  continue;
+}
+if (PrevTokenIsHash) {
+  PrevTokenIsHash = false;
+  continue;
+}
+
 // Handling of ? and :.
 if (T.is(tok::question)) {
   CountAtQuestion.push(Current);

Copied: 
clang-tools-extra/trunk/test/clang-tidy/misc-macro-repeated-side-effects.c 
(from r267228, 
clang-tools-extra/trunk/test/clang-tidy/misc-repeated-side-effects-in-macro.c)
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-macro-repeated-side-effects.c?p2=clang-tools-extra/trunk/test/clang-tidy/misc-macro-repeated-side-effects.c&p1=clang-tools-extra/trunk/test/clang-tidy/misc-repeated-side-effects-in-macro.c&r1=267228&r2=267254&rev=267254&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/misc-repeated-side-effects-in-macro.c 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-macro-repeated-side-effects.c 
Fri Apr 22 19:00:08 2016
@@ -99,3 +99,8 @@ void conditionals(int a, int b)
   condB(a, b++);
 }
 
+void log(const char *s, int v);
+#define LOG(val) log(#val, (val))
+void test_log(int a) {
+  LOG(a++);
+}

Removed: 
clang-tools-extra/trunk/test/clang-tidy/misc-repeated-side-effects-in-macro.c
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-repeated-side-effects-in-macro.c?rev=267253&view=auto
==
--- 
clang-tools-extra/trunk/test/clang-tidy/misc-repeated-side-effects-in-macro.c 
(original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/misc-repeated-side-effects-in-macro.c 
(removed)
@@ -1,101 +0,0 @@
-// RUN: %check_clang_tidy %s misc-macro-repeated-side-effects %t
-
-#define badA(x,y)  ((x)+((x)+(y))+(y))
-void bad(int ret, int a, int b) {
-  ret = badA(a++, b);
-  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: side effects in the 1st macro 
argument 'x' are repeated in macro expansion [misc-macro-repeated-side-effects]
-  ret = badA(++a, b);
-  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: side effects in the 1st macro 
argument 'x'
-  ret = badA(a--, b);
-  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: side effects in the 1st macro 
argument 'x'
-  ret = badA(--a, b);
-  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: side effects in the 1st macro 
argument 'x'
-  ret = badA(a, b++);
-  // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: side effects in the 2nd macro 
argument 'y'
-  ret = badA(a, ++b);
-  // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: side effects in the 2nd macro 
argument 'y'
-  ret = badA(a, b--);
-  // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: side effects in the 2nd macro 
argument 'y'
-  ret = badA(a, --b);
-  // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: side effects in the 2nd macro 
argument 'y'
-}
-
-
-#define MIN(A,B) ((A) < (B) ? (A) : (B))// single 
?:
-#define LIMIT(X,A,B) ((X) < (A) ? (A) : ((X) > (B) ? (B) : (X)))// two ?:
-void question(int x) {
-  MIN(x++, 12);
-  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: side effects in the 1st macro 
argument 'A'
-  MIN(34, x++);
-  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: side effects in the 2nd macro 
argument 'B'
-  LIMIT(x++, 0, 100);
-  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: sid

Re: [PATCH] D18768: Refactoring attribute subject diagnostics

2016-04-22 Thread Richard Smith via cfe-commits
rsmith added a comment.

I think this is a reasonable direction. I'd like to see some kind of %list form 
added to our diagnostics system, but I don't mind whether that happens before 
or after this change.

(I'd also prefer to use singular forms in the various subject names, but that 
seems to create problems with the presence/absence of "a" / "an". If you see a 
way to make that work, we should consider it, but otherwise don't worry about 
it.)


http://reviews.llvm.org/D18768



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


Re: [PATCH] D17741: adds __FILE_BASENAME__ builtin macro

2016-04-22 Thread Weiming Zhao via cfe-commits
weimingz added a comment.

Ping ?


http://reviews.llvm.org/D17741



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


[PATCH] D19443: Module Debugging: Fix the condition for determining whether a template instantiation is in a module.

2016-04-22 Thread Adrian Prantl via cfe-commits
aprantl created this revision.
aprantl added a reviewer: doug.gregor.
aprantl added a subscriber: cfe-commits.
aprantl set the repository for this revision to rL LLVM.

This patch fixes the condition for determining whether the debug info for a 
template instantiation will exist in an imported clang module by:
- checking whether the ClassTemplateSpecializationDecl is complete and
- checking that the instantiation was in a module by looking at the first field.

I also added a negative check to make sure that a typedef to a forward-declared 
template (with the definition outside of the module) is handled correctly.

Repository:
  rL LLVM

http://reviews.llvm.org/D19443

Files:
  lib/CodeGen/CGDebugInfo.cpp
  test/Modules/ExtDebugInfo.cpp
  test/Modules/Inputs/DebugCXX.h
  test/Modules/ModuleDebugInfo.cpp

Index: test/Modules/ModuleDebugInfo.cpp
===
--- test/Modules/ModuleDebugInfo.cpp
+++ test/Modules/ModuleDebugInfo.cpp
@@ -47,15 +47,20 @@
 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "Struct"
 // CHECK-SAME: identifier: "_ZTSN8DebugCXX6StructE")
 
+// This type is anchored by an explicit template instantiation.
 // CHECK: !DICompositeType(tag: DW_TAG_class_type,
 // CHECK-SAME: name: "Template >"
+// CHECK-SAME: templateParams:
 // CHECK-SAME: identifier: "_ZTSN8DebugCXX8TemplateIiNS_6traitsIi")
 
+// This type is anchored by a function parameter.
 // CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "A"
+// CHECK-SAME: templateParams:
 // CHECK-SAME: identifier: "_ZTSN8DebugCXX1AIJvEEE")
 
 // CHECK: !DICompositeType(tag: DW_TAG_class_type,
 // CHECK-SAME: name: "Template >"
+// CHECK-SAME: flags: DIFlagFwdDecl
 // CHECK-SAME: identifier: "_ZTSN8DebugCXX8TemplateIfNS_6traitsIf")
 
 // CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "B",
@@ -81,7 +86,20 @@
 // CHECK: ![[B_MBRS]] = !{{{.*}}, ![[GET_PARENT:.*]]}
 // CHECK: ![[GET_PARENT]] = !DISubprogram(name: "getParent"
 
-// CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "FloatInstatiation"
+// CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "Template1",
+// CHECK-SAME: flags: DIFlagFwdDecl
+// CHECK-SAME: identifier: "_ZTS9Template1IPvE")
+
+// Explicit instatiation.
+// CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "Template1",
+// CHECK-SAME: templateParams:
+// CHECK-SAME: identifier: "_ZTS9Template1IiE")
+
+// CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "FwdDeclTemplate",
+// CHECK-SAME: flags: DIFlagFwdDecl
+// CHECK-SAME: identifier: "_ZTS15FwdDeclTemplateIiE")
+
+// CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "FloatInstantiation"
 // no mangled name here yet.
 
 // CHECK: !DICompositeType(tag: DW_TAG_union_type,
@@ -96,4 +114,8 @@
 // CHECK-SAME: name: "InAnonymousNamespace",
 // CHECK-SAME: elements: !{{[0-9]+}})
 
+// CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "TypedefTemplate",
+// CHECK-SAME:   baseType: !"_ZTS9Template1IPvE")
+
+
 // CHECK-NEG-NOT: !DICompositeType(tag: DW_TAG_structure_type, name: "PureForwardDecl"
Index: test/Modules/Inputs/DebugCXX.h
===
--- test/Modules/Inputs/DebugCXX.h
+++ test/Modules/Inputs/DebugCXX.h
@@ -24,10 +24,11 @@
   > class Template {
 T member;
   };
+  // Explicit template instantiation.
   extern template class Template;
 
   extern template struct traits;
-  typedef class Template FloatInstatiation;
+  typedef class Template FloatInstantiation;
 
   inline void fn() {
 Template invisible;
@@ -48,6 +49,7 @@
   template  class A;
   template  class A {};
   typedef A B;
+  // Anchored by a function parameter.
   void foo(B) {}
 }
 
@@ -83,3 +85,13 @@
 Derived *getParent() const override;
   };
 };
+
+template 
+class Template1 {
+  T t;
+};
+typedef Template1 TypedefTemplate;
+extern template class Template1;
+
+template  class FwdDeclTemplate;
+typedef FwdDeclTemplate TypedefFwdDeclTemplate;
Index: test/Modules/ExtDebugInfo.cpp
===
--- test/Modules/ExtDebugInfo.cpp
+++ test/Modules/ExtDebugInfo.cpp
@@ -30,7 +30,9 @@
 DebugCXX::Enum e;
 DebugCXX::Template implicitTemplate;
 DebugCXX::Template explicitTemplate;
-DebugCXX::FloatInstatiation typedefTemplate;
+DebugCXX::FloatInstantiation typedefTemplate;
+DebugCXX::B anchoredTemplate;
+
 int Struct::static_member = -1;
 enum {
   e3 = -1
@@ -41,14 +43,25 @@
 TypedefUnion tdu;
 TypedefEnum tde;
 TypedefStruct tds;
+TypedefTemplate tdt;
+Template1 explicitTemplate1;
+
+template  class FwdDeclTemplate { T t; };
+TypedefFwdDeclTemplate tdfdt;
 
 InAnonymousNamespace anon;
 
 void foo() {
   anon.i = GlobalStruct.i = GlobalUnion.i = GlobalEnum;
 }
 
-// CHECK: ![[NS:.*]] = !DINamespace

r267234 - Revert the bool portion of r267054

2016-04-22 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Fri Apr 22 17:14:32 2016
New Revision: 267234

URL: http://llvm.org/viewvc/llvm-project?rev=267234&view=rev
Log:
Revert the bool portion of r267054

Remove the floating point to bool conversion warnings.  Some of these
conversions will be caught by -Wliteral-conversion and -Wfloat-conversion

Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp
cfe/trunk/test/SemaCXX/warn-float-conversion.cpp
cfe/trunk/test/SemaCXX/warn-literal-conversion.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=267234&r1=267233&r2=267234&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Fri Apr 22 17:14:32 2016
@@ -49,12 +49,8 @@ def EnumConversion : DiagGroup<"enum-con
 
 def FloatOverflowConversion : DiagGroup<"float-overflow-conversion">;
 def FloatZeroConversion : DiagGroup<"float-zero-conversion">;
-def FloatBoolConstantConversion : DiagGroup<"float-bool-constant-conversion">;
-def FloatBoolConversion :
-  DiagGroup<"float-bool-conversion", [FloatBoolConstantConversion]>;
 def FloatConversion :
-  DiagGroup<"float-conversion", [FloatBoolConversion,
- FloatOverflowConversion,
+  DiagGroup<"float-conversion", [FloatOverflowConversion,
  FloatZeroConversion]>;
 
 def DoublePromotion : DiagGroup<"double-promotion">;

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=267234&r1=267233&r2=267234&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Apr 22 17:14:32 
2016
@@ -2768,13 +2768,6 @@ def warn_impcast_float_integer : Warning
   "implicit conversion turns floating-point number into integer: %0 to %1">,
   InGroup, DefaultIgnore;
 
-def warn_impcast_float_bool : Warning<
-  "implicit conversion turns floating-point number into boolean: %0 to %1">,
-  InGroup, DefaultIgnore;
-def warn_impcast_float_to_bool : Warning<
-  "implicit conversion from %0 to %1 changes value from %2 to %3">,
-  InGroup;
-
 def warn_impcast_float_to_integer : Warning<
   "implicit conversion of out of range value from %0 to %1 changes value "
   "from %2 to %3">,

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=267234&r1=267233&r2=267234&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Fri Apr 22 17:14:32 2016
@@ -7403,13 +7403,8 @@ void DiagnoseFloatingImpCast(Sema &S, Ex
   bool IsConstant =
 E->EvaluateAsFloat(Value, S.Context, Expr::SE_AllowSideEffects);
   if (!IsConstant) {
-if (IsBool) {
-  return DiagnoseImpCast(S, E, T, CContext, diag::warn_impcast_float_bool,
- PruneWarnings);
-} else {
-  return DiagnoseImpCast(S, E, T, CContext,
- diag::warn_impcast_float_integer, PruneWarnings);
-}
+return DiagnoseImpCast(S, E, T, CContext,
+   diag::warn_impcast_float_integer, PruneWarnings);
   }
 
   bool isExact = false;
@@ -7418,17 +7413,14 @@ void DiagnoseFloatingImpCast(Sema &S, Ex
 T->hasUnsignedIntegerRepresentation());
   if (Value.convertToInteger(IntegerValue, llvm::APFloat::rmTowardZero,
  &isExact) == llvm::APFloat::opOK &&
-  isExact && !IsBool) {
+  isExact) {
 if (IsLiteral) return;
 return DiagnoseImpCast(S, E, T, CContext, diag::warn_impcast_float_integer,
PruneWarnings);
   }
 
   unsigned DiagID = 0;
-  if (IsBool) {
-// Warn on all floating point to bool conversions
-DiagID = diag::warn_impcast_float_to_bool;
-  } else if (IsLiteral) {
+  if (IsLiteral) {
 // Warn on floating point literal to integer.
 DiagID = diag::warn_impcast_literal_float_to_integer;
   } else if (IntegerValue == 0) {

Modified: cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp?rev=267234&r1=267233&r2=267234&view=diff
==
--- cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp (original)
+++ cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0

Re: [PATCH] D19312: Warn about UB at member function calls from base class ctor initializers.

2016-04-22 Thread Raphael Isemann via cfe-commits
teemperor marked 4 inline comments as done.
teemperor added a comment.

No, didn't saw the thread so far. I assume the comments in there are still 
valid, so I'll update this patch.
Thanks for the feedback so far!


http://reviews.llvm.org/D19312



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


[clang-tools-extra] r267228 - [Clang-tidy] Fix Clang warning in misc/StringConstructorCheck.h.

2016-04-22 Thread Eugene Zelenko via cfe-commits
Author: eugenezelenko
Date: Fri Apr 22 16:33:33 2016
New Revision: 267228

URL: http://llvm.org/viewvc/llvm-project?rev=267228&view=rev
Log:
[Clang-tidy] Fix Clang warning in misc/StringConstructorCheck.h.

Using LLVM_ENABLE_WARNINGS=ON is good idea.

Modified:
clang-tools-extra/trunk/clang-tidy/misc/StringConstructorCheck.h

Modified: clang-tools-extra/trunk/clang-tidy/misc/StringConstructorCheck.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/StringConstructorCheck.h?rev=267228&r1=267227&r2=267228&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/StringConstructorCheck.h (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/StringConstructorCheck.h Fri Apr 22 
16:33:33 2016
@@ -23,7 +23,7 @@ namespace misc {
 class StringConstructorCheck : public ClangTidyCheck {
 public:
   StringConstructorCheck(StringRef Name, ClangTidyContext *Context);
-  void storeOptions(ClangTidyOptions::OptionMap &Opts);
+  void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
 


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


r267224 - PGO] PGOFuncName meta data if PGOFuncName is different from function's raw name

2016-04-22 Thread Rong Xu via cfe-commits
Author: xur
Date: Fri Apr 22 16:19:05 2016
New Revision: 267224

URL: http://llvm.org/viewvc/llvm-project?rev=267224&view=rev
Log:
PGO] PGOFuncName meta data if PGOFuncName is different from function's raw name

Write out the PGOFuncName meta data if PGOFuncName is different from function's
raw name. This should only apply to internal linkage functions. This is to be
consumed by indirect-call promotion when called in LTO optimization pass.

Differential Revision: http://reviews.llvm.org/D18624

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

Modified: cfe/trunk/lib/CodeGen/CodeGenPGO.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenPGO.cpp?rev=267224&r1=267223&r2=267224&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenPGO.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenPGO.cpp Fri Apr 22 16:19:05 2016
@@ -43,6 +43,8 @@ void CodeGenPGO::setFuncName(StringRef N
 
 void CodeGenPGO::setFuncName(llvm::Function *Fn) {
   setFuncName(Fn->getName(), Fn->getLinkage());
+  // Create PGOFuncName meta data.
+  llvm::createPGOFuncNameMetadata(*Fn, FuncName);
 }
 
 namespace {


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


Re: [PATCH] D18624: [PGO] PGOFuncName meta data if PGOFuncName is different from function's raw name.

2016-04-22 Thread Rong Xu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL267224: PGO] PGOFuncName meta data if PGOFuncName is 
different from function's raw name (authored by xur).

Changed prior to commit:
  http://reviews.llvm.org/D18624?vs=54717&id=54725#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D18624

Files:
  cfe/trunk/lib/CodeGen/CodeGenPGO.cpp

Index: cfe/trunk/lib/CodeGen/CodeGenPGO.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenPGO.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenPGO.cpp
@@ -43,6 +43,8 @@
 
 void CodeGenPGO::setFuncName(llvm::Function *Fn) {
   setFuncName(Fn->getName(), Fn->getLinkage());
+  // Create PGOFuncName meta data.
+  llvm::createPGOFuncNameMetadata(*Fn, FuncName);
 }
 
 namespace {


Index: cfe/trunk/lib/CodeGen/CodeGenPGO.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenPGO.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenPGO.cpp
@@ -43,6 +43,8 @@
 
 void CodeGenPGO::setFuncName(llvm::Function *Fn) {
   setFuncName(Fn->getName(), Fn->getLinkage());
+  // Create PGOFuncName meta data.
+  llvm::createPGOFuncNameMetadata(*Fn, FuncName);
 }
 
 namespace {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18624: [PGO] PGOFuncName meta data if PGOFuncName is different from function's raw name.

2016-04-22 Thread Rong Xu via cfe-commits
xur added a comment.

tested with povray with full path names  in the command line and it works fine.


http://reviews.llvm.org/D18624



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


Re: r267054 - Split interesting warnings off from -Wfloat-conversion

2016-04-22 Thread Richard Trieu via cfe-commits
On Fri, Apr 22, 2016 at 10:50 AM, David Blaikie  wrote:

>
>
> On Thu, Apr 21, 2016 at 2:04 PM, Richard Trieu via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: rtrieu
>> Date: Thu Apr 21 16:04:55 2016
>> New Revision: 267054
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=267054&view=rev
>> Log:
>> Split interesting warnings off from -Wfloat-conversion
>>
>> Restructure the implict floating point to integer conversions so that
>> interesting sub-groups are under different flags.  Breakdown of warnings:
>>
>> No warning:
>> Exact conversions from floating point to integer:
>> int x = 10.0;
>> int x = 1e10;
>>
>> -Wliteral-conversion - Floating point literal to integer with rounding:
>> int x = 5.5;
>> int x = -3.4;
>>
>> -Wfloat-conversion - All conversions not covered by the above two:
>> int x = GetFloat();
>> int x = 5.5 + 3.5;
>>
>> -Wfloat-zero-conversion - The expression converted has a non-zero floating
>> point value that gets converted to a zero integer value, excluded the
>> cases
>> falling under -Wliteral-conversion.  Subset of -Wfloat-conversion.
>> int x = 1.0 / 2.0;
>>
>
> This ^ seems like a slightly odd special case. Why is it particularly
> beneficial to have that slice separate from, say, 3.0/2.0 ?
>

I was seeing things such as sleep(.5), where sleep takes an int of seconds,
or error_rate = .001 where the intention was for a small non-zero value to
be used and there was a large jump between meanings of non-zero value and
zero values.   For non-zero to non-zero conversion, the change in meaning
is smaller, and usually intentional.

>
>
>> -Wfloat-overflow-conversion - The floating point value is outside the
>> range
>> of the integer type, exluding cases from -Wliteral conversion.  Subset of
>> -Wfloat-conversion.
>> char x = 500;
>> char x = -1000;
>>
>> -Wfloat-bool-conversion - Any conversion of a floating point type to bool.
>> Subset of -Wfloat-conversion.
>> if (GetFloat()) {}
>> bool x = 5.0;
>
>
>> -Wfloat-bool-constant-conversion - Conversion of a compile time
>> evaluatable
>> floating point value to bool.  Subset of -Wfloat-bool-conversion.
>> bool x = 1.0;
>> bool x = 4.0 / 20.0;
>>
>
> Why this particular slice? Are there cases where literal floats converted
> to bool are desirable that you're carving out by having this (& the
> float-overflow-conversion, float-zero-conversion, etc) split out?
>
Float to bool conversion is being reverted for the time being.

>
>
>>
>> Also add EvaluateAsFloat to Sema, which is similar to EvaluateAsInt, but
>> for
>> floating point values.
>>
>>
>> Modified:
>> cfe/trunk/include/clang/AST/Expr.h
>> cfe/trunk/include/clang/Basic/DiagnosticGroups.td
>> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> cfe/trunk/lib/AST/ExprConstant.cpp
>> cfe/trunk/lib/Sema/SemaChecking.cpp
>> cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp
>> cfe/trunk/test/SemaCXX/warn-float-conversion.cpp
>> cfe/trunk/test/SemaCXX/warn-literal-conversion.cpp
>>
>> Modified: cfe/trunk/include/clang/AST/Expr.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=267054&r1=267053&r2=267054&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/AST/Expr.h (original)
>> +++ cfe/trunk/include/clang/AST/Expr.h Thu Apr 21 16:04:55 2016
>> @@ -594,6 +594,13 @@ public:
>>bool EvaluateAsInt(llvm::APSInt &Result, const ASTContext &Ctx,
>>   SideEffectsKind AllowSideEffects =
>> SE_NoSideEffects) const;
>>
>> +  /// EvaluateAsFloat - Return true if this is a constant which we can
>> fold and
>> +  /// convert to a floating point value, using any crazy technique that
>> we
>> +  /// want to.
>> +  bool
>> +  EvaluateAsFloat(llvm::APFloat &Result, const ASTContext &Ctx,
>> +  SideEffectsKind AllowSideEffects = SE_NoSideEffects)
>> const;
>> +
>>/// isEvaluatable - Call EvaluateAsRValue to see if this expression
>> can be
>>/// constant folded without side-effects, but discard the result.
>>bool isEvaluatable(const ASTContext &Ctx,
>>
>> Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=267054&r1=267053&r2=267054&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
>> +++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Thu Apr 21 16:04:55
>> 2016
>> @@ -46,7 +46,17 @@ def BoolConversion : DiagGroup<"bool-con
>>
>> UndefinedBoolConversion]>;
>>  def IntConversion : DiagGroup<"int-conversion">;
>>  def EnumConversion : DiagGroup<"enum-conversion">;
>> -def FloatConversion : DiagGroup<"float-conversion">;
>> +
>> +def FloatOverflowConversion : DiagGroup<"float-overflow-conversion">;
>> +def FloatZeroConversion : DiagGroup<"float-zero-conversion">;
>> +

Re: r267054 - Split interesting warnings off from -Wfloat-conversion

2016-04-22 Thread Richard Trieu via cfe-commits
Nico,

With this warning, I was attempting to catch different cases of floating to
bool conversion:
  bool x = 5.0;  // Wrong type
  void test(bool, float);
  test(5.0, true);  // Switched arguments.

I did not see anything like your example come up.  See as there are many
edge cases in with floating point to bool conversions, I will be reverting
the bool portions of this change and following up with a different thread
to discuss how to handle the bool conversions.

-Wfloat-* are subgroups of -Wfloat-conversion which is a subgroup of
-Wconversion.

Richard

On Fri, Apr 22, 2016 at 7:41 AM, Nico Weber  wrote:

> Hi Richard,
>
> 1.) Are these new warnings in -Wconversion? If not, they probably should
> be, right?
>
> 2.) It looks like -Wfloat-bool-constant-conversion is on by default and
> warns on things like
>
>   if (kHotspotRadius)
>
> if kHotspotRadius is a float. Do you have data that suggests that this is
> a common buggy pattern? Omitting `!= 0` is extremely common in practice,
> and it's even dictated in some style guides (e.g.
> https://webkit.org/code-style-guidelines/#null-false-and-zero ("Tests for
> [...] zero/non-zero should all be done without equality comparisons."). So
> making this a warning for floats but not for others seems weird to me.
>
> Nico
>
>
> On Thu, Apr 21, 2016 at 5:04 PM, Richard Trieu via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: rtrieu
>> Date: Thu Apr 21 16:04:55 2016
>> New Revision: 267054
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=267054&view=rev
>> Log:
>> Split interesting warnings off from -Wfloat-conversion
>>
>> Restructure the implict floating point to integer conversions so that
>> interesting sub-groups are under different flags.  Breakdown of warnings:
>>
>> No warning:
>> Exact conversions from floating point to integer:
>> int x = 10.0;
>> int x = 1e10;
>>
>> -Wliteral-conversion - Floating point literal to integer with rounding:
>> int x = 5.5;
>> int x = -3.4;
>>
>> -Wfloat-conversion - All conversions not covered by the above two:
>> int x = GetFloat();
>> int x = 5.5 + 3.5;
>>
>> -Wfloat-zero-conversion - The expression converted has a non-zero floating
>> point value that gets converted to a zero integer value, excluded the
>> cases
>> falling under -Wliteral-conversion.  Subset of -Wfloat-conversion.
>> int x = 1.0 / 2.0;
>>
>> -Wfloat-overflow-conversion - The floating point value is outside the
>> range
>> of the integer type, exluding cases from -Wliteral conversion.  Subset of
>> -Wfloat-conversion.
>> char x = 500;
>> char x = -1000;
>>
>> -Wfloat-bool-conversion - Any conversion of a floating point type to bool.
>> Subset of -Wfloat-conversion.
>> if (GetFloat()) {}
>> bool x = 5.0;
>>
>> -Wfloat-bool-constant-conversion - Conversion of a compile time
>> evaluatable
>> floating point value to bool.  Subset of -Wfloat-bool-conversion.
>> bool x = 1.0;
>> bool x = 4.0 / 20.0;
>>
>> Also add EvaluateAsFloat to Sema, which is similar to EvaluateAsInt, but
>> for
>> floating point values.
>>
>>
>> Modified:
>> cfe/trunk/include/clang/AST/Expr.h
>> cfe/trunk/include/clang/Basic/DiagnosticGroups.td
>> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> cfe/trunk/lib/AST/ExprConstant.cpp
>> cfe/trunk/lib/Sema/SemaChecking.cpp
>> cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp
>> cfe/trunk/test/SemaCXX/warn-float-conversion.cpp
>> cfe/trunk/test/SemaCXX/warn-literal-conversion.cpp
>>
>> Modified: cfe/trunk/include/clang/AST/Expr.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=267054&r1=267053&r2=267054&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/AST/Expr.h (original)
>> +++ cfe/trunk/include/clang/AST/Expr.h Thu Apr 21 16:04:55 2016
>> @@ -594,6 +594,13 @@ public:
>>bool EvaluateAsInt(llvm::APSInt &Result, const ASTContext &Ctx,
>>   SideEffectsKind AllowSideEffects =
>> SE_NoSideEffects) const;
>>
>> +  /// EvaluateAsFloat - Return true if this is a constant which we can
>> fold and
>> +  /// convert to a floating point value, using any crazy technique that
>> we
>> +  /// want to.
>> +  bool
>> +  EvaluateAsFloat(llvm::APFloat &Result, const ASTContext &Ctx,
>> +  SideEffectsKind AllowSideEffects = SE_NoSideEffects)
>> const;
>> +
>>/// isEvaluatable - Call EvaluateAsRValue to see if this expression
>> can be
>>/// constant folded without side-effects, but discard the result.
>>bool isEvaluatable(const ASTContext &Ctx,
>>
>> Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=267054&r1=267053&r2=267054&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
>> +++ cfe/trunk/include/clang/Basic

Re: [PATCH] D18624: [PGO] PGOFuncName meta data if PGOFuncName is different from function's raw name.

2016-04-22 Thread David Li via cfe-commits
davidxl accepted this revision.
davidxl added a comment.
This revision is now accepted and ready to land.

lgtm


http://reviews.llvm.org/D18624



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


Re: r267186 - Fix a bug involving deferred decl emission and PCH

2016-04-22 Thread Richard Smith via cfe-commits
On Fri, Apr 22, 2016 at 12:59 PM, Reid Kleckner via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> On Fri, Apr 22, 2016 at 12:29 PM, Richard Smith 
> wrote:
>
>> On Fri, Apr 22, 2016 at 11:46 AM, Reid Kleckner via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: rnk
>>> Date: Fri Apr 22 13:46:33 2016
>>> New Revision: 267186
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=267186&view=rev
>>> Log:
>>> Fix a bug involving deferred decl emission and PCH
>>>
>>> For various reasons, involving dllexport and class linkage compuations,
>>> we have to wait until after the semicolon after a class declaration to
>>> emit inline methods. These are "deferred" decls. Before this change,
>>> finishing the tag decl would trigger us to deserialize some PCH so that
>>> we could make a "pretty" IR-level type. Deserializing the PCH triggered
>>> calls to HandleTopLevelDecl, which, when done, checked the deferred decl
>>> list, and emitted some dllexported decls that weren't ready.
>>>
>>> Avoid this re-entrancy. Deferred decls should not get emitted when a tag
>>> is finished, they should only be emitted after a real top level decl in
>>> the main file.
>>>
>>
>> What if there is no subsequent top-level decl after such a call? It seems
>> like the deferred decls won't be emitted at all in that case. Is that
>> acceptable?
>>
>
> I think what happens is that we finish the tag declaration, and then call
> HandleTopLevelDecl on it directly, and that is supposed to flush the
> deferred methods.
>
> I can't think of any ways to create a C++ tag definition in a way that
> doesn't create a top level decl.
>

This seems like a fragile thing to rely on. What about template
instantiation performed at end of TU? (I /think/ that case is currently
fine because all the kinds of template we instantiate ultimately do result
in a call to HandleTopLevelDecl or some other ASTConsumer callback, but I
don't really like relying on that.)

Could we trigger processing of any remaining deferred declarations in
HandleTranslationUnit?
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18768: Refactoring attribute subject diagnostics

2016-04-22 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

Ping


http://reviews.llvm.org/D18768



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


Re: [PATCH] D19244: Extend checking of va_start builtin

2016-04-22 Thread Aaron Ballman via cfe-commits
aaron.ballman marked an inline comment as done.
aaron.ballman added a comment.

Ping.


http://reviews.llvm.org/D19244



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


Re: [PATCH] D18624: [PGO] PGOFuncName meta data if PGOFuncName is different from function's raw name.

2016-04-22 Thread Rong Xu via cfe-commits
xur updated this revision to Diff 54717.
xur added a comment.

Handling the path-stripped prefix in PGOFuncName.

This new patch depends on http://reviews.llvm.org/D19433


http://reviews.llvm.org/D18624

Files:
  CodeGenPGO.cpp

Index: CodeGenPGO.cpp
===
--- CodeGenPGO.cpp
+++ CodeGenPGO.cpp
@@ -43,6 +43,8 @@
 
 void CodeGenPGO::setFuncName(llvm::Function *Fn) {
   setFuncName(Fn->getName(), Fn->getLinkage());
+  // Create PGOFuncName meta data.
+  llvm::createPGOFuncNameMetadata(*Fn, FuncName);
 }
 
 namespace {


Index: CodeGenPGO.cpp
===
--- CodeGenPGO.cpp
+++ CodeGenPGO.cpp
@@ -43,6 +43,8 @@
 
 void CodeGenPGO::setFuncName(llvm::Function *Fn) {
   setFuncName(Fn->getName(), Fn->getLinkage());
+  // Create PGOFuncName meta data.
+  llvm::createPGOFuncNameMetadata(*Fn, FuncName);
 }
 
 namespace {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D19432: [SystemZ] Support Swift calling convention

2016-04-22 Thread Bryan Chan via cfe-commits
bryanpkc created this revision.
bryanpkc added reviewers: rjmccall, kbarton.
bryanpkc added a subscriber: cfe-commits.
bryanpkc added a dependency: D19414: [SystemZ] Support Swift Calling Convention.

Port rL265324 to SystemZ to allow using the 'swiftcall' attribute on that 
architecture.

Depends on D19414.

http://reviews.llvm.org/D19432

Files:
  lib/Basic/Targets.cpp
  lib/CodeGen/TargetInfo.cpp

Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -5702,12 +5702,12 @@
 
 namespace {
 
-class SystemZABIInfo : public ABIInfo {
+class SystemZABIInfo : public SwiftABIInfo {
   bool HasVector;
 
 public:
   SystemZABIInfo(CodeGenTypes &CGT, bool HV)
-: ABIInfo(CGT), HasVector(HV) {}
+: SwiftABIInfo(CGT), HasVector(HV) {}
 
   bool isPromotableIntegerType(QualType Ty) const;
   bool isCompoundType(QualType Ty) const;
@@ -5727,6 +5727,12 @@
 
   Address EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
 QualType Ty) const override;
+
+  bool shouldPassIndirectlyForSwift(CharUnits totalSize,
+ArrayRef scalars,
+bool asReturnValue) const override {
+return occupiesMoreThan(CGT, scalars, /*total*/ 4);
+  }
 };
 
 class SystemZTargetCodeGenInfo : public TargetCodeGenInfo {
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -6543,6 +6543,16 @@
 .Default(false);
   }
 
+  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override 
{
+switch (CC) {
+case CC_C:
+case CC_Swift:
+  return CCCR_OK;
+default:
+  return CCCR_Warning;
+}
+  }
+
   StringRef getABI() const override {
 if (HasVector)
   return "vector";


Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -5702,12 +5702,12 @@
 
 namespace {
 
-class SystemZABIInfo : public ABIInfo {
+class SystemZABIInfo : public SwiftABIInfo {
   bool HasVector;
 
 public:
   SystemZABIInfo(CodeGenTypes &CGT, bool HV)
-: ABIInfo(CGT), HasVector(HV) {}
+: SwiftABIInfo(CGT), HasVector(HV) {}
 
   bool isPromotableIntegerType(QualType Ty) const;
   bool isCompoundType(QualType Ty) const;
@@ -5727,6 +5727,12 @@
 
   Address EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
 QualType Ty) const override;
+
+  bool shouldPassIndirectlyForSwift(CharUnits totalSize,
+ArrayRef scalars,
+bool asReturnValue) const override {
+return occupiesMoreThan(CGT, scalars, /*total*/ 4);
+  }
 };
 
 class SystemZTargetCodeGenInfo : public TargetCodeGenInfo {
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -6543,6 +6543,16 @@
 .Default(false);
   }
 
+  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override {
+switch (CC) {
+case CC_C:
+case CC_Swift:
+  return CCCR_OK;
+default:
+  return CCCR_Warning;
+}
+  }
+
   StringRef getABI() const override {
 if (HasVector)
   return "vector";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19385: [scan-build] fix logic error warnings emitted on clang code base

2016-04-22 Thread John McCall via cfe-commits
rjmccall added inline comments.


Comment at: lib/Frontend/CompilerInstance.cpp:763
@@ -762,8 +762,3 @@
   Includers.push_back(std::make_pair(FindFile, FindFile->getDir()));
-  File = HS->LookupFile(InputFile, SourceLocation(), /*isAngled=*/false,
-/*FromDir=*/nullptr,
-/*CurDir=*/UnusedCurDir, Includers,
-/*SearchPath=*/nullptr,
-/*RelativePath=*/nullptr,
-/*RequestingModule=*/nullptr,
-/*SuggestedModule=*/nullptr, /*SkipCache=*/true);
+  if (HS)
+File = HS->LookupFile(InputFile, SourceLocation(), /*isAngled=*/false,

apelete wrote:
> rjmccall wrote:
> > What's the justification for this one?
> CompilerInstance::InitializeSourceManager() could call 
> CompilerInstance::InitializeSourceManager() and pass a null pointer value via 
> the 5th parameter 'HS':
> 
> 718. bool CompilerInstance::InitializeSourceManager(const FrontendInputFile 
> &Input){
> 719.   return InitializeSourceManager(
> 720.   Input, getDiagnostics(), getFileManager(), getSourceManager(),
> 721.   hasPreprocessor() ? &getPreprocessor().getHeaderSearchInfo() : 
> nullptr,
> 722.   getDependencyOutputOpts(), getFrontendOpts());
> 723. }
> 
> In that case, 'HS' object pointer would be null at this point.
> I chose not to assert 'HS' and just check it because we already check if 
> 'File' is assigned a null pointer as the result of HS->LookupFile() below.
> 
> Should it be fixed otherwise ?
I don't really know.

The Sema and AST changes LGTM.


http://reviews.llvm.org/D19385



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


Re: [PATCH] D18657: Propagate missing empty exception spec from function declared in system header

2016-04-22 Thread John McCall via cfe-commits
rjmccall added inline comments.


Comment at: lib/Sema/SemaExceptionSpec.cpp:260
@@ -261,1 +259,3 @@
+  (First->getLocation().isInvalid() ||
+   Context.getSourceManager().isInSystemHeader(First->getLocation( {
 New->setType(Context.getFunctionType(

rsmith wrote:
> rjmccall wrote:
> > Please find a way to sink the call to getFirstDecl() to the point where we 
> > need it.
> `getFirstDecl` is cheap these days.
Ah, nevermind then.


http://reviews.llvm.org/D18657



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


Re: [PATCH] D19275: Do not register incompatible C++ destructors with __cxa_atexit

2016-04-22 Thread Derek Schuff via cfe-commits
dschuff added a subscriber: rengolin.
dschuff added a comment.

any comments from @t.p.northover or perhaps @rengolin ?
(This does have a potential new cost on ARM, as it requires one thunk (which is 
just a tail call) per static initializer on ARM and WebAssembly)


http://reviews.llvm.org/D19275



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


Re: r267186 - Fix a bug involving deferred decl emission and PCH

2016-04-22 Thread Reid Kleckner via cfe-commits
On Fri, Apr 22, 2016 at 12:29 PM, Richard Smith 
wrote:

> On Fri, Apr 22, 2016 at 11:46 AM, Reid Kleckner via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: rnk
>> Date: Fri Apr 22 13:46:33 2016
>> New Revision: 267186
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=267186&view=rev
>> Log:
>> Fix a bug involving deferred decl emission and PCH
>>
>> For various reasons, involving dllexport and class linkage compuations,
>> we have to wait until after the semicolon after a class declaration to
>> emit inline methods. These are "deferred" decls. Before this change,
>> finishing the tag decl would trigger us to deserialize some PCH so that
>> we could make a "pretty" IR-level type. Deserializing the PCH triggered
>> calls to HandleTopLevelDecl, which, when done, checked the deferred decl
>> list, and emitted some dllexported decls that weren't ready.
>>
>> Avoid this re-entrancy. Deferred decls should not get emitted when a tag
>> is finished, they should only be emitted after a real top level decl in
>> the main file.
>>
>
> What if there is no subsequent top-level decl after such a call? It seems
> like the deferred decls won't be emitted at all in that case. Is that
> acceptable?
>

I think what happens is that we finish the tag declaration, and then call
HandleTopLevelDecl on it directly, and that is supposed to flush the
deferred methods.

I can't think of any ways to create a C++ tag definition in a way that
doesn't create a top level decl.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18540: [Sema] Note when we've actually encountered a failure in ExprConstant, and take that into account when looking up objects.

2016-04-22 Thread George Burgess IV via cfe-commits
george.burgess.iv added a comment.

Ping :)


http://reviews.llvm.org/D18540



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


Re: r267186 - Fix a bug involving deferred decl emission and PCH

2016-04-22 Thread Richard Smith via cfe-commits
On Fri, Apr 22, 2016 at 11:46 AM, Reid Kleckner via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rnk
> Date: Fri Apr 22 13:46:33 2016
> New Revision: 267186
>
> URL: http://llvm.org/viewvc/llvm-project?rev=267186&view=rev
> Log:
> Fix a bug involving deferred decl emission and PCH
>
> For various reasons, involving dllexport and class linkage compuations,
> we have to wait until after the semicolon after a class declaration to
> emit inline methods. These are "deferred" decls. Before this change,
> finishing the tag decl would trigger us to deserialize some PCH so that
> we could make a "pretty" IR-level type. Deserializing the PCH triggered
> calls to HandleTopLevelDecl, which, when done, checked the deferred decl
> list, and emitted some dllexported decls that weren't ready.
>
> Avoid this re-entrancy. Deferred decls should not get emitted when a tag
> is finished, they should only be emitted after a real top level decl in
> the main file.
>

What if there is no subsequent top-level decl after such a call? It seems
like the deferred decls won't be emitted at all in that case. Is that
acceptable?


> Added:
> cfe/trunk/test/PCH/Inputs/pr27445.h
> cfe/trunk/test/PCH/pr27445.cpp
> Modified:
> cfe/trunk/lib/CodeGen/ModuleBuilder.cpp
>
> Modified: cfe/trunk/lib/CodeGen/ModuleBuilder.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ModuleBuilder.cpp?rev=267186&r1=267185&r2=267186&view=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/ModuleBuilder.cpp (original)
> +++ cfe/trunk/lib/CodeGen/ModuleBuilder.cpp Fri Apr 22 13:46:33 2016
> @@ -36,13 +36,21 @@ namespace {
>  const CodeGenOptions CodeGenOpts;  // Intentionally copied in.
>
>  unsigned HandlingTopLevelDecls;
> +
> +/// Use this when emitting decls to block re-entrant decl emission.
> It will
> +/// emit all deferred decls on scope exit. Set EmitDeferred to false
> if decl
> +/// emission must be deferred longer, like at the end of a tag
> definition.
>  struct HandlingTopLevelDeclRAII {
>CodeGeneratorImpl &Self;
> -  HandlingTopLevelDeclRAII(CodeGeneratorImpl &Self) : Self(Self) {
> +  bool EmitDeferred;
> +  HandlingTopLevelDeclRAII(CodeGeneratorImpl &Self,
> +   bool EmitDeferred = true)
> +  : Self(Self), EmitDeferred(EmitDeferred) {
>  ++Self.HandlingTopLevelDecls;
>}
>~HandlingTopLevelDeclRAII() {
> -if (--Self.HandlingTopLevelDecls == 0)
> +unsigned Level = --Self.HandlingTopLevelDecls;
> +if (Level == 0 && EmitDeferred)
>Self.EmitDeferredDecls();
>}
>  };
> @@ -185,6 +193,10 @@ namespace {
>if (Diags.hasErrorOccurred())
>  return;
>
> +  // Don't allow re-entrant calls to CodeGen triggered by PCH
> +  // deserialization to emit deferred decls.
> +  HandlingTopLevelDeclRAII HandlingDecl(*this,
> /*EmitDeferred=*/false);
> +
>Builder->UpdateCompletedType(D);
>
>// For MSVC compatibility, treat declarations of static data
> members with
> @@ -214,6 +226,10 @@ namespace {
>if (Diags.hasErrorOccurred())
>  return;
>
> +  // Don't allow re-entrant calls to CodeGen triggered by PCH
> +  // deserialization to emit deferred decls.
> +  HandlingTopLevelDeclRAII HandlingDecl(*this,
> /*EmitDeferred=*/false);
> +
>if (CodeGen::CGDebugInfo *DI = Builder->getModuleDebugInfo())
>  if (const RecordDecl *RD = dyn_cast(D))
>DI->completeRequiredType(RD);
>
> Added: cfe/trunk/test/PCH/Inputs/pr27445.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/Inputs/pr27445.h?rev=267186&view=auto
>
> ==
> --- cfe/trunk/test/PCH/Inputs/pr27445.h (added)
> +++ cfe/trunk/test/PCH/Inputs/pr27445.h Fri Apr 22 13:46:33 2016
> @@ -0,0 +1,4 @@
> +struct Info {
> +  virtual ~Info();
> +  void hash() {}
> +};
>
> Added: cfe/trunk/test/PCH/pr27445.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/pr27445.cpp?rev=267186&view=auto
>
> ==
> --- cfe/trunk/test/PCH/pr27445.cpp (added)
> +++ cfe/trunk/test/PCH/pr27445.cpp Fri Apr 22 13:46:33 2016
> @@ -0,0 +1,14 @@
> +// RUN: %clang_cc1 -triple x86_64-windows-msvc -fms-extensions -x c++
> %S/Inputs/pr27445.h -emit-pch -o %t.pch
> +// RUN: %clang_cc1 -triple x86_64-windows-msvc -fms-extensions %s
> -include-pch %t.pch -emit-llvm -o - | FileCheck %s
> +
> +class A;
> +void fn1(A &) {}
> +
> +class __declspec(dllexport) A {
> +  int operator=(A) { return field_; }
> +  void (*on_arena_allocation_)(Info);
> +  int field_;
> +};
> +
> +// CHECK: %class.A = type { void (%struct.Info*)*, i32 }
> +// CHECK: %struct.Info = type { i32 (...)** }
>
>
> ___
> cfe-commit

Re: [PATCH] D18657: Propagate missing empty exception spec from function declared in system header

2016-04-22 Thread Richard Smith via cfe-commits
rsmith added a subscriber: rsmith.


Comment at: lib/Sema/SemaExceptionSpec.cpp:260
@@ -261,1 +259,3 @@
+  (First->getLocation().isInvalid() ||
+   Context.getSourceManager().isInSystemHeader(First->getLocation( {
 New->setType(Context.getFunctionType(

rjmccall wrote:
> Please find a way to sink the call to getFirstDecl() to the point where we 
> need it.
`getFirstDecl` is cheap these days.


http://reviews.llvm.org/D18657



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


Re: [PATCH] D19385: [scan-build] fix logic error warnings emitted on clang code base

2016-04-22 Thread Apelete Seketeli via cfe-commits
apelete added inline comments.


Comment at: lib/Frontend/CompilerInstance.cpp:763
@@ -762,8 +762,3 @@
   Includers.push_back(std::make_pair(FindFile, FindFile->getDir()));
-  File = HS->LookupFile(InputFile, SourceLocation(), /*isAngled=*/false,
-/*FromDir=*/nullptr,
-/*CurDir=*/UnusedCurDir, Includers,
-/*SearchPath=*/nullptr,
-/*RelativePath=*/nullptr,
-/*RequestingModule=*/nullptr,
-/*SuggestedModule=*/nullptr, /*SkipCache=*/true);
+  if (HS)
+File = HS->LookupFile(InputFile, SourceLocation(), /*isAngled=*/false,

rjmccall wrote:
> What's the justification for this one?
CompilerInstance::InitializeSourceManager() could call 
CompilerInstance::InitializeSourceManager() and pass a null pointer value via 
the 5th parameter 'HS':

718. bool CompilerInstance::InitializeSourceManager(const FrontendInputFile 
&Input){
719.   return InitializeSourceManager(
720.   Input, getDiagnostics(), getFileManager(), getSourceManager(),
721.   hasPreprocessor() ? &getPreprocessor().getHeaderSearchInfo() : 
nullptr,
722.   getDependencyOutputOpts(), getFrontendOpts());
723. }

In that case, 'HS' object pointer would be null at this point.
I chose not to assert 'HS' and just check it because we already check if 'File' 
is assigned a null pointer as the result of HS->LookupFile() below.

Should it be fixed otherwise ?


http://reviews.llvm.org/D19385



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


r267186 - Fix a bug involving deferred decl emission and PCH

2016-04-22 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Fri Apr 22 13:46:33 2016
New Revision: 267186

URL: http://llvm.org/viewvc/llvm-project?rev=267186&view=rev
Log:
Fix a bug involving deferred decl emission and PCH

For various reasons, involving dllexport and class linkage compuations,
we have to wait until after the semicolon after a class declaration to
emit inline methods. These are "deferred" decls. Before this change,
finishing the tag decl would trigger us to deserialize some PCH so that
we could make a "pretty" IR-level type. Deserializing the PCH triggered
calls to HandleTopLevelDecl, which, when done, checked the deferred decl
list, and emitted some dllexported decls that weren't ready.

Avoid this re-entrancy. Deferred decls should not get emitted when a tag
is finished, they should only be emitted after a real top level decl in
the main file.

Added:
cfe/trunk/test/PCH/Inputs/pr27445.h
cfe/trunk/test/PCH/pr27445.cpp
Modified:
cfe/trunk/lib/CodeGen/ModuleBuilder.cpp

Modified: cfe/trunk/lib/CodeGen/ModuleBuilder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ModuleBuilder.cpp?rev=267186&r1=267185&r2=267186&view=diff
==
--- cfe/trunk/lib/CodeGen/ModuleBuilder.cpp (original)
+++ cfe/trunk/lib/CodeGen/ModuleBuilder.cpp Fri Apr 22 13:46:33 2016
@@ -36,13 +36,21 @@ namespace {
 const CodeGenOptions CodeGenOpts;  // Intentionally copied in.
 
 unsigned HandlingTopLevelDecls;
+
+/// Use this when emitting decls to block re-entrant decl emission. It will
+/// emit all deferred decls on scope exit. Set EmitDeferred to false if 
decl
+/// emission must be deferred longer, like at the end of a tag definition.
 struct HandlingTopLevelDeclRAII {
   CodeGeneratorImpl &Self;
-  HandlingTopLevelDeclRAII(CodeGeneratorImpl &Self) : Self(Self) {
+  bool EmitDeferred;
+  HandlingTopLevelDeclRAII(CodeGeneratorImpl &Self,
+   bool EmitDeferred = true)
+  : Self(Self), EmitDeferred(EmitDeferred) {
 ++Self.HandlingTopLevelDecls;
   }
   ~HandlingTopLevelDeclRAII() {
-if (--Self.HandlingTopLevelDecls == 0)
+unsigned Level = --Self.HandlingTopLevelDecls;
+if (Level == 0 && EmitDeferred)
   Self.EmitDeferredDecls();
   }
 };
@@ -185,6 +193,10 @@ namespace {
   if (Diags.hasErrorOccurred())
 return;
 
+  // Don't allow re-entrant calls to CodeGen triggered by PCH
+  // deserialization to emit deferred decls.
+  HandlingTopLevelDeclRAII HandlingDecl(*this, /*EmitDeferred=*/false);
+
   Builder->UpdateCompletedType(D);
 
   // For MSVC compatibility, treat declarations of static data members with
@@ -214,6 +226,10 @@ namespace {
   if (Diags.hasErrorOccurred())
 return;
 
+  // Don't allow re-entrant calls to CodeGen triggered by PCH
+  // deserialization to emit deferred decls.
+  HandlingTopLevelDeclRAII HandlingDecl(*this, /*EmitDeferred=*/false);
+
   if (CodeGen::CGDebugInfo *DI = Builder->getModuleDebugInfo())
 if (const RecordDecl *RD = dyn_cast(D))
   DI->completeRequiredType(RD);

Added: cfe/trunk/test/PCH/Inputs/pr27445.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/Inputs/pr27445.h?rev=267186&view=auto
==
--- cfe/trunk/test/PCH/Inputs/pr27445.h (added)
+++ cfe/trunk/test/PCH/Inputs/pr27445.h Fri Apr 22 13:46:33 2016
@@ -0,0 +1,4 @@
+struct Info {
+  virtual ~Info();
+  void hash() {}
+};

Added: cfe/trunk/test/PCH/pr27445.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/pr27445.cpp?rev=267186&view=auto
==
--- cfe/trunk/test/PCH/pr27445.cpp (added)
+++ cfe/trunk/test/PCH/pr27445.cpp Fri Apr 22 13:46:33 2016
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -fms-extensions -x c++ 
%S/Inputs/pr27445.h -emit-pch -o %t.pch
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -fms-extensions %s -include-pch 
%t.pch -emit-llvm -o - | FileCheck %s
+
+class A;
+void fn1(A &) {}
+
+class __declspec(dllexport) A {
+  int operator=(A) { return field_; }
+  void (*on_arena_allocation_)(Info);
+  int field_;
+};
+
+// CHECK: %class.A = type { void (%struct.Info*)*, i32 }
+// CHECK: %struct.Info = type { i32 (...)** }


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


[PATCH] D19425: driver: Add a `--rsp-quoting` flag to choose which unquoting behavior to use in rsp files.

2016-04-22 Thread Nico Weber via cfe-commits
thakis created this revision.
thakis added a reviewer: rnk.
thakis added a subscriber: cfe-commits.

Currently, clang-cl always uses Windows style for unquoting, and clang always 
uses POSIX style for unquoting.

In general, response file quoting should match the shell the response file is 
used in. On Windows, it's possible to run clang-cl in a bash shell, or clang in 
cmd.exe, so a flag for overriding the default behavior is natural there. On 
non-Windows, Windows probably never makes sense (except maybe in Wine), but 
having clang-cl behave differently based on the host OS seems strange too -- 
people who want to use clang-cl on non-Windows with "native" response files 
will have to pass --rsp-quoting=posix.

This also includes the clang-side test changes needed for 
http://reviews.llvm.org/D19417

http://reviews.llvm.org/D19425

Files:
  include/clang/Driver/Options.td
  lib/Driver/Driver.cpp
  test/Driver/at_file.c
  test/Driver/at_file.c.args
  test/Driver/at_file_win.c
  test/Driver/at_file_win.c.args
  tools/driver/driver.cpp

Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -1813,8 +1813,9 @@
   // Claim -### here.
   (void)C.getArgs().hasArg(options::OPT__HASH_HASH_HASH);
 
-  // Claim --driver-mode, it was handled earlier.
+  // Claim --driver-mode, --rsp-quoting, it was handled earlier.
   (void)C.getArgs().hasArg(options::OPT_driver_mode);
+  (void)C.getArgs().hasArg(options::OPT_rsp_quoting);
 
   for (Arg *A : C.getArgs()) {
 // FIXME: It would be nice to be able to send the argument to the
Index: test/Driver/at_file_win.c.args
===
--- test/Driver/at_file_win.c.args
+++ test/Driver/at_file_win.c.args
@@ -0,0 +1,13 @@
+-Dfoo1=bar1 -Dfoo2="bar2 zed2"
+-Dfoo3="bar3 zed3"
+"-Dfoo4=bar4 zed4"
+"-Dfoo5=bar5 zed5"
+-Dfoo6="'bar6 zed6'"
+-Dfoo7='"bar7 zed7"'
+-Dfoo8=foo8"bar8"zed8
+-Dfoo9=foo9\'bar9\'zed9
+-Dfoo10=foo10\"bar10\"zed10
+-D foo11
+-Dfoo12=zed12
+-Dfoo13=one\two
+-Dfoo14=c:\foo\bar.c
Index: test/Driver/at_file_win.c
===
--- test/Driver/at_file_win.c
+++ test/Driver/at_file_win.c
@@ -0,0 +1,34 @@
+// RUN: %clang --rsp-quoting=windows -E %s @%s.args -o %t.log
+// RUN: FileCheck --input-file=%t.log %s
+
+// CHECK: bar1
+// CHECK-NEXT: bar2 zed2
+// CHECK-NEXT: bar3 zed3
+// CHECK-NEXT: bar4 zed4
+// CHECK-NEXT: bar5 zed5
+// CHECK-NEXT: 'bar6 zed6'
+// CHECK-NEXT: 'bar7 zed7'
+// CHECK-NEXT: foo8bar8zed8
+// CHECK-NEXT: foo9\'bar9\'zed9
+// CHECK-NEXT: foo10"bar10"zed10
+// CHECK: bar
+// CHECK: zed12
+// CHECK: one\two
+// CHECK: c:\foo\bar.c
+
+foo1
+foo2
+foo3
+foo4
+foo5
+foo6
+foo7
+foo8
+foo9
+foo10
+#ifdef foo11
+bar
+#endif
+foo12
+foo13
+foo14
Index: test/Driver/at_file.c.args
===
--- test/Driver/at_file.c.args
+++ test/Driver/at_file.c.args
@@ -8,6 +8,7 @@
 -Dfoo9=foo9\'bar9\'zed9
 -Dfoo10=foo10\"bar10\"zed10
 -D foo11
--Dfoo12=zed12\
+-Dfoo12=zed1\
+2
 -Dfoo13='one\\two'
 -Dfoo14='c:\foo\bar.c'
Index: test/Driver/at_file.c
===
--- test/Driver/at_file.c
+++ test/Driver/at_file.c
@@ -14,9 +14,9 @@
 // CHECK-NEXT: foo9'bar9'zed9
 // CHECK-NEXT: foo10"bar10"zed10
 // CHECK: bar
-// CHECK: zed12
+// CHECK: zed1
 // CHECK: one\two
-// CHECK: c:\foo\bar.c
+// CHECK: c:foobar.c
 
 foo1
 foo2
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -152,6 +152,9 @@
 def driver_mode : Joined<["--"], "driver-mode=">, Group,
   Flags<[CoreOption, DriverOption, HelpHidden]>,
   HelpText<"Set the driver mode to either 'gcc', 'g++', 'cpp', or 'cl'">;
+def rsp_quoting : Joined<["--"], "rsp-quoting=">, Group,
+  Flags<[CoreOption, DriverOption, HelpHidden]>,
+  HelpText<"Set the rsp quoting to either 'posix', or 'windows'">;
 def ccc_gcc_name : Separate<["-"], "ccc-gcc-name">, InternalDriverOpt,
   HelpText<"Name for native GCC compiler">,
   MetaVarName<"">;
Index: tools/driver/driver.cpp
===
--- tools/driver/driver.cpp
+++ tools/driver/driver.cpp
@@ -345,17 +345,24 @@
   }) != argv.end()) {
 ClangCLMode = true;
   }
+  enum { Default, POSIX, Windows } RSPQuoting = Default;
+  for (const char *F : argv) {
+if (strcmp(F, "--rsp-quoting=posix") == 0)
+  RSPQuoting = POSIX;
+else if (strcmp(F, "--rsp-quoting=windows") == 0)
+  RSPQuoting = Windows;
+  }
 
   // Determines whether we want nullptr markers in argv to indicate response
   // files end-of-lines. We only use this for the /LINK driver argument with
   // clang-cl.exe on Windows.
-  bool MarkEOLs = false;
+  bool MarkEOLs = ClangCLMode;
 
-  llvm::cl::TokenizerCallback Toke

Re: [PATCH] D18657: Propagate missing empty exception spec from function declared in system header

2016-04-22 Thread John McCall via cfe-commits
rjmccall added inline comments.


Comment at: lib/Sema/SemaExceptionSpec.cpp:260
@@ -261,1 +259,3 @@
+  (First->getLocation().isInvalid() ||
+   Context.getSourceManager().isInSystemHeader(First->getLocation( {
 New->setType(Context.getFunctionType(

Please find a way to sink the call to getFirstDecl() to the point where we need 
it.


http://reviews.llvm.org/D18657



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


Re: [PATCH] D19385: [scan-build] fix logic error warnings emitted on clang code base

2016-04-22 Thread John McCall via cfe-commits
rjmccall added inline comments.


Comment at: lib/Frontend/CompilerInstance.cpp:763
@@ -762,8 +762,3 @@
   Includers.push_back(std::make_pair(FindFile, FindFile->getDir()));
-  File = HS->LookupFile(InputFile, SourceLocation(), /*isAngled=*/false,
-/*FromDir=*/nullptr,
-/*CurDir=*/UnusedCurDir, Includers,
-/*SearchPath=*/nullptr,
-/*RelativePath=*/nullptr,
-/*RequestingModule=*/nullptr,
-/*SuggestedModule=*/nullptr, /*SkipCache=*/true);
+  if (HS)
+File = HS->LookupFile(InputFile, SourceLocation(), /*isAngled=*/false,

What's the justification for this one?


http://reviews.llvm.org/D19385



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


Re: [PATCH] D18369: [OpenCL] Upstreaming khronos OpenCL header file.

2016-04-22 Thread Alexey Bader via cfe-commits
bader added a comment.

In http://reviews.llvm.org/D18369#409011, @yaxunl wrote:

> In http://reviews.llvm.org/D18369#408773, @bader wrote:
>
> > BTW, there is a comment on GitHub that opencl.h might be a bad name for 
> > that header, since Khronos group provides the header with the same name, 
> > but it defines host API. So if some developer is using clang to compile 
> > OpenCL application it might accidentally include opencl.h provided with 
> > Clang instead of opencl.h with OpenCL host API.
>
>
> Right. We'd better come up with another name. How about opencl-c.h?


Sounds good to me.


http://reviews.llvm.org/D18369



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


Re: r267054 - Split interesting warnings off from -Wfloat-conversion

2016-04-22 Thread David Blaikie via cfe-commits
On Thu, Apr 21, 2016 at 2:04 PM, Richard Trieu via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rtrieu
> Date: Thu Apr 21 16:04:55 2016
> New Revision: 267054
>
> URL: http://llvm.org/viewvc/llvm-project?rev=267054&view=rev
> Log:
> Split interesting warnings off from -Wfloat-conversion
>
> Restructure the implict floating point to integer conversions so that
> interesting sub-groups are under different flags.  Breakdown of warnings:
>
> No warning:
> Exact conversions from floating point to integer:
> int x = 10.0;
> int x = 1e10;
>
> -Wliteral-conversion - Floating point literal to integer with rounding:
> int x = 5.5;
> int x = -3.4;
>
> -Wfloat-conversion - All conversions not covered by the above two:
> int x = GetFloat();
> int x = 5.5 + 3.5;
>
> -Wfloat-zero-conversion - The expression converted has a non-zero floating
> point value that gets converted to a zero integer value, excluded the cases
> falling under -Wliteral-conversion.  Subset of -Wfloat-conversion.
> int x = 1.0 / 2.0;
>

This ^ seems like a slightly odd special case. Why is it particularly
beneficial to have that slice separate from, say, 3.0/2.0 ?


> -Wfloat-overflow-conversion - The floating point value is outside the range
> of the integer type, exluding cases from -Wliteral conversion.  Subset of
> -Wfloat-conversion.
> char x = 500;
> char x = -1000;
>
> -Wfloat-bool-conversion - Any conversion of a floating point type to bool.
> Subset of -Wfloat-conversion.
> if (GetFloat()) {}
> bool x = 5.0;


> -Wfloat-bool-constant-conversion - Conversion of a compile time evaluatable
> floating point value to bool.  Subset of -Wfloat-bool-conversion.
> bool x = 1.0;
> bool x = 4.0 / 20.0;
>

Why this particular slice? Are there cases where literal floats converted
to bool are desirable that you're carving out by having this (& the
float-overflow-conversion, float-zero-conversion, etc) split out?


>
> Also add EvaluateAsFloat to Sema, which is similar to EvaluateAsInt, but
> for
> floating point values.
>
>
> Modified:
> cfe/trunk/include/clang/AST/Expr.h
> cfe/trunk/include/clang/Basic/DiagnosticGroups.td
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> cfe/trunk/lib/AST/ExprConstant.cpp
> cfe/trunk/lib/Sema/SemaChecking.cpp
> cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp
> cfe/trunk/test/SemaCXX/warn-float-conversion.cpp
> cfe/trunk/test/SemaCXX/warn-literal-conversion.cpp
>
> Modified: cfe/trunk/include/clang/AST/Expr.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=267054&r1=267053&r2=267054&view=diff
>
> ==
> --- cfe/trunk/include/clang/AST/Expr.h (original)
> +++ cfe/trunk/include/clang/AST/Expr.h Thu Apr 21 16:04:55 2016
> @@ -594,6 +594,13 @@ public:
>bool EvaluateAsInt(llvm::APSInt &Result, const ASTContext &Ctx,
>   SideEffectsKind AllowSideEffects = SE_NoSideEffects)
> const;
>
> +  /// EvaluateAsFloat - Return true if this is a constant which we can
> fold and
> +  /// convert to a floating point value, using any crazy technique that we
> +  /// want to.
> +  bool
> +  EvaluateAsFloat(llvm::APFloat &Result, const ASTContext &Ctx,
> +  SideEffectsKind AllowSideEffects = SE_NoSideEffects)
> const;
> +
>/// isEvaluatable - Call EvaluateAsRValue to see if this expression can
> be
>/// constant folded without side-effects, but discard the result.
>bool isEvaluatable(const ASTContext &Ctx,
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=267054&r1=267053&r2=267054&view=diff
>
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Thu Apr 21 16:04:55
> 2016
> @@ -46,7 +46,17 @@ def BoolConversion : DiagGroup<"bool-con
>
> UndefinedBoolConversion]>;
>  def IntConversion : DiagGroup<"int-conversion">;
>  def EnumConversion : DiagGroup<"enum-conversion">;
> -def FloatConversion : DiagGroup<"float-conversion">;
> +
> +def FloatOverflowConversion : DiagGroup<"float-overflow-conversion">;
> +def FloatZeroConversion : DiagGroup<"float-zero-conversion">;
> +def FloatBoolConstantConversion :
> DiagGroup<"float-bool-constant-conversion">;
> +def FloatBoolConversion :
> +  DiagGroup<"float-bool-conversion", [FloatBoolConstantConversion]>;
> +def FloatConversion :
> +  DiagGroup<"float-conversion", [FloatBoolConversion,
> + FloatOverflowConversion,
> + FloatZeroConversion]>;
> +
>  def DoublePromotion : DiagGroup<"double-promotion">;
>  def EnumTooLarge : DiagGroup<"enum-too-large">;
>  def UnsupportedNan : DiagGroup<"unsupported-nan">;
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSem

[libunwind] r267169 - unwind: unify some more macros

2016-04-22 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Fri Apr 22 12:11:05 2016
New Revision: 267169

URL: http://llvm.org/viewvc/llvm-project?rev=267169&view=rev
Log:
unwind: unify some more macros

The macros were defined identically across both cases.  Unify the definitions to
have a single definition for _LIBUWNIND_{HIDDEN,EXPORT} and _LIBUNWIND_LOG.
NFC.

Modified:
libunwind/trunk/src/config.h

Modified: libunwind/trunk/src/config.h
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/config.h?rev=267169&r1=267168&r2=267169&view=diff
==
--- libunwind/trunk/src/config.h (original)
+++ libunwind/trunk/src/config.h Fri Apr 22 12:11:05 2016
@@ -40,9 +40,6 @@
   #endif
 
   #define _LIBUNWIND_BUILD_SJLJ_APIS  defined(__arm__)
-  #define _LIBUNWIND_EXPORT   
__attribute__((visibility("default")))
-  #define _LIBUNWIND_HIDDEN   __attribute__((visibility("hidden")))
-  #define _LIBUNWIND_LOG(msg, ...) fprintf(stderr, "libuwind: " msg, 
__VA_ARGS__)
   #define _LIBUNWIND_ABORT(msg) __assert_rtn(__func__, __FILE__, __LINE__, msg)
 
   #if defined(FOR_DYLD)
@@ -54,7 +51,6 @@
 #define _LIBUNWIND_SUPPORT_DWARF_UNWIND   1
 #define _LIBUNWIND_SUPPORT_DWARF_INDEX0
   #endif
-
 #else
   #include 
 
@@ -66,9 +62,6 @@
   }
 
   #define _LIBUNWIND_BUILD_SJLJ_APIS  0
-  #define _LIBUNWIND_EXPORT   
__attribute__((visibility("default")))
-  #define _LIBUNWIND_HIDDEN   __attribute__((visibility("hidden")))
-  #define _LIBUNWIND_LOG(msg, ...) fprintf(stderr, "libuwind: " msg, 
__VA_ARGS__)
   #define _LIBUNWIND_ABORT(msg) assert_rtn(__func__, __FILE__, __LINE__, msg)
 
   #if defined(__ARM_DWARF_EH__) || !defined(__arm__)
@@ -82,6 +75,10 @@
   #endif
 #endif
 
+// FIXME: these macros are not correct for COFF targets
+#define _LIBUNWIND_EXPORT __attribute__((visibility("default")))
+#define _LIBUNWIND_HIDDEN __attribute__((visibility("hidden")))
+
 #if defined(__i386__) || defined(__x86_64__)
 #define _LIBUNWIND_SUPPORT_FRAME_APIS 1
 #else
@@ -97,6 +94,8 @@
 #define _LIBUNWIND_BUILD_ZERO_COST_APIS 0
 #endif
 
+#define _LIBUNWIND_LOG(msg, ...) fprintf(stderr, "libuwind: " msg, __VA_ARGS__)
+
 // Macros that define away in non-Debug builds
 #ifdef NDEBUG
   #define _LIBUNWIND_DEBUG_LOG(msg, ...)


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


Re: [PATCH] D19382: [OpenMP] Improve mappable expressions Sema.

2016-04-22 Thread Samuel Antao via cfe-commits
sfantao added a comment.

Hi Alexey,

Thanks for the review!



Comment at: include/clang/AST/OpenMPClause.h:2789-2797
@@ +2788,11 @@
+// \brief Expression associated with the component.
+Expr *AssociatedExpression;
+// \brief Declaration associated with the declaration. If the component 
does
+// not have a declaration (e.g. array subscripts or section), this is set 
to
+// nullptr.
+ValueDecl *AssociatedDeclaration;
+
+  public:
+MappableComponent()
+: AssociatedExpression(nullptr), AssociatedDeclaration(nullptr) {}
+MappableComponent(Expr *AssociatedExpression,

ABataev wrote:
> Please, use in-class initialization of class members, like:
> ```
> Expr *AssociatedExpression = nullptr;
> ```
> Also, mark this constructor as `explicit`
Done!


Comment at: include/clang/AST/OpenMPClause.h:2859
@@ +2858,3 @@
+  /// class.
+  ArrayRef getUniqueDeclsRef() const {
+return ArrayRef(

ABataev wrote:
> I'm not sure exactly, but `ArrayRef<>` adds `const` modifier automatically, 
> so you can use just `ValueDecl*`, without `const`, as template specialization 
> parameter
I am doing as you say.


Comment at: include/clang/AST/OpenMPClause.h:3135
@@ +3134,3 @@
+  if (ListSizeCur == CumulativeListSizes.end()) {
+this->I = End;
+RemainingLists = 0u;

ABataev wrote:
> remove `this->`
We have to use `this` because `I` is member of a template parent class and 
cannot be resolved by the template class definition. It can only be resolved by 
accessing the specific template instance pointed to by `this`.


Comment at: include/clang/AST/OpenMPClause.h:3150
@@ +3149,3 @@
+  // that start the list is the size of the previous list.
+  std::advance(this->I, PrevListSize);
+}

ABataev wrote:
> remove `this->`
Have to keep this for the reason I mentioned above.


Comment at: include/clang/AST/OpenMPClause.h:3160
@@ +3159,3 @@
+  *DeclCur,
+  MappableExprComponentListRef(&*this->I, *ListSizeCur - 
PrevListSize));
+}

ABataev wrote:
> remove `this->`
Have to keep this for the reason I mentioned above.


Comment at: include/clang/AST/OpenMPClause.h:3175
@@ +3174,3 @@
+  if (std::next(ListSizeCur) == ListSizeEnd) {
+this->I = End;
+RemainingLists = 0;

ABataev wrote:
> remove `this->`
Have to keep this for the reason I mentioned above.


Comment at: include/clang/AST/OpenMPClause.h:3178
@@ +3177,3 @@
+  } else {
+std::advance(this->I, *ListSizeCur - PrevListSize);
+PrevListSize = *ListSizeCur;

ABataev wrote:
> remove `this->`
Have to keep this for the reason I mentioned above.


Comment at: lib/AST/OpenMPClause.cpp:546-547
@@ +545,4 @@
+  for (auto *D : Declarations) {
+if (Cache.count(D))
+  continue;
+++TotalNum;

ABataev wrote:
> I don't see where you modifies `Cache` set, so I presume this won't work at 
> all.
Thanks for catching that! You are right. I fixed that. This was not causing bad 
behavior, other than allocating more memory than what is actually required in 
the trailing objects.






Comment at: lib/Sema/SemaOpenMP.cpp:345-348
@@ -348,1 +344,6 @@
+  // any issue is found.
+  template 
+  bool
+  checkMappableExprComponentListsForDecl(ValueDecl *VD, bool CurrentRegionOnly,
+ MappableExprComponentListCheck Check) 
{
 auto SI = Stack.rbegin();

ABataev wrote:
> Maybe it can be converted to:
> ```
> bool checkMappableExprComponentListsForDecl(ValueDecl *VD, bool 
> CurrentRegionOnly,
>  const 
> llvm::function_ref
>  &Check)
> ```
Done!


http://reviews.llvm.org/D19382



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


Re: [PATCH] D19382: [OpenMP] Improve mappable expressions Sema.

2016-04-22 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 54672.
sfantao marked 15 inline comments as done.
sfantao added a comment.

- Address review comments. Fix bug in the evaluation of the unique declarations.


http://reviews.llvm.org/D19382

Files:
  include/clang/AST/OpenMPClause.h
  lib/AST/OpenMPClause.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp

Index: lib/Serialization/ASTWriterStmt.cpp
===
--- lib/Serialization/ASTWriterStmt.cpp
+++ lib/Serialization/ASTWriterStmt.cpp
@@ -2021,13 +2021,26 @@
 
 void OMPClauseWriter::VisitOMPMapClause(OMPMapClause *C) {
   Record.push_back(C->varlist_size());
+  Record.push_back(C->getUniqueDeclarationsNum());
+  Record.push_back(C->getTotalComponentListNum());
+  Record.push_back(C->getTotalComponentsNum());
   Record.AddSourceLocation(C->getLParenLoc());
   Record.push_back(C->getMapTypeModifier());
   Record.push_back(C->getMapType());
   Record.AddSourceLocation(C->getMapLoc());
   Record.AddSourceLocation(C->getColonLoc());
-  for (auto *VE : C->varlists())
-Record.AddStmt(VE);
+  for (auto *E : C->varlists())
+Record.AddStmt(E);
+  for (auto *D : C->all_decls())
+Record.AddDeclRef(D);
+  for (auto N : C->all_num_lists())
+Record.push_back(N);
+  for (auto N : C->all_lists_sizes())
+Record.push_back(N);
+  for (auto &M : C->all_components()) {
+Record.AddStmt(M.getAssociatedExpression());
+Record.AddDeclRef(M.getAssociatedDeclaration());
+  }
 }
 
 void OMPClauseWriter::VisitOMPNumTeamsClause(OMPNumTeamsClause *C) {
Index: lib/Serialization/ASTReaderStmt.cpp
===
--- lib/Serialization/ASTReaderStmt.cpp
+++ lib/Serialization/ASTReaderStmt.cpp
@@ -1861,9 +1861,15 @@
   case OMPC_device:
 C = new (Context) OMPDeviceClause();
 break;
-  case OMPC_map:
-C = OMPMapClause::CreateEmpty(Context, Record[Idx++]);
+  case OMPC_map: {
+unsigned NumVars = Record[Idx++];
+unsigned NumDeclarations = Record[Idx++];
+unsigned NumLists = Record[Idx++];
+unsigned NumComponents = Record[Idx++];
+C = OMPMapClause::CreateEmpty(Context, NumVars, NumDeclarations, NumLists,
+  NumComponents);
 break;
+  }
   case OMPC_num_teams:
 C = new (Context) OMPNumTeamsClause();
 break;
@@ -2225,12 +2231,45 @@
   C->setMapLoc(Reader->ReadSourceLocation(Record, Idx));
   C->setColonLoc(Reader->ReadSourceLocation(Record, Idx));
   auto NumVars = C->varlist_size();
+  auto UniqueDecls = C->getUniqueDeclarationsNum();
+  auto TotalLists = C->getTotalComponentListNum();
+  auto TotalComponents = C->getTotalComponentsNum();
+
   SmallVector Vars;
   Vars.reserve(NumVars);
-  for (unsigned i = 0; i != NumVars; ++i) {
+  for (unsigned i = 0; i != NumVars; ++i)
 Vars.push_back(Reader->Reader.ReadSubExpr());
-  }
   C->setVarRefs(Vars);
+
+  SmallVector Decls;
+  Decls.reserve(UniqueDecls);
+  for (unsigned i = 0; i < UniqueDecls; ++i)
+Decls.push_back(
+Reader->Reader.ReadDeclAs(Reader->F, Record, Idx));
+  C->setUniqueDecls(Decls);
+
+  SmallVector ListsPerDecl;
+  ListsPerDecl.reserve(UniqueDecls);
+  for (unsigned i = 0; i < UniqueDecls; ++i)
+ListsPerDecl.push_back(Record[Idx++]);
+  C->setDeclNumLists(ListsPerDecl);
+
+  SmallVector ListSizes;
+  ListSizes.reserve(TotalLists);
+  for (unsigned i = 0; i < TotalLists; ++i)
+ListSizes.push_back(Record[Idx++]);
+  C->setComponentListSizes(ListSizes);
+
+  SmallVector Components;
+  Components.reserve(TotalComponents);
+  for (unsigned i = 0; i < TotalComponents; ++i) {
+Expr *AssociatedExpr = Reader->Reader.ReadSubExpr();
+ValueDecl *AssociatedDecl =
+Reader->Reader.ReadDeclAs(Reader->F, Record, Idx);
+Components.push_back(OMPClauseMappableExprCommon::MappableComponent(
+AssociatedExpr, AssociatedDecl));
+  }
+  C->setComponents(Components, ListSizes);
 }
 
 void OMPClauseReader::VisitOMPNumTeamsClause(OMPNumTeamsClause *C) {
Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -81,8 +81,6 @@
   };
 
 private:
-  typedef SmallVector MapInfo;
-
   struct DSAInfo {
 OpenMPClauseKind Attributes;
 Expr *RefExpr;
@@ -92,14 +90,16 @@
   typedef llvm::DenseMap AlignedMapTy;
   typedef std::pair LCDeclInfo;
   typedef llvm::DenseMap LoopControlVariablesMapTy;
-  typedef llvm::DenseMap MappedDeclsTy;
+  typedef llvm::DenseMap<
+  ValueDecl *, OMPClauseMappableExprCommon::MappableExprComponentLists>
+  MappedExprComponentsTy;
   typedef llvm::StringMap>
   CriticalsWithHintsTy;
 
   struct SharingMapTy {
 DeclSAMapTy SharingMap;
 AlignedMapTy AlignedMap;
-MappedDeclsTy MappedDecls;
+MappedExprComponentsTy MappedExprComponents;
 LoopControlVariablesMapTy LCVMap;
 DefaultDataSharingAttributes Defa

Re: [PATCH] D19201: [clang-tidy] misc-throw-with-noexcept

2016-04-22 Thread Alexander Kornienko via cfe-commits
alexfh requested changes to this revision.
alexfh added a comment.
This revision now requires changes to proceed.

Please fix formatting, btw.


Repository:
  rL LLVM

http://reviews.llvm.org/D19201



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


[PATCH] D19415: [libcxx][rfc] Externalized threading support

2016-04-22 Thread Asiri Rathnayake via cfe-commits
rmaprath created this revision.
rmaprath added reviewers: EricWF, mclow.lists, theraven, jroelofs.
rmaprath added a subscriber: cfe-commits.
Herald added a subscriber: aemerson.

This patch builds on D19412.

The motivation here is to allow toolchain vendors to build a version of 
`libcxx` with all the underlying os threading mechanics differed to runtime - 
sacrificing some performance for flexibility.

This API (`_LIBCPP_THREAD_API_EXTERNAL`) currently only works when `libcxx` is 
build as a static library. This is because the shared library builds pass `-z 
defs` linker flag, which disallows undefined symbols in the library. I'm not 
familiar with shared library limitations on specific platforms, but in theory, 
this could work on shared library builds as well.

Currently there are quite a lot of test failures because the testing 
infrastructure need to be updated to provide an implementation of this 
threading API (pthreads will do). Our plan is to hide this whole extension 
under some cmake variable at some point.

Before putting more effort into this, I thought of checking if the community if 
open to this kind of an API. Of course, we (ARM) will be committed to 
maintaining this API in the long run.

http://reviews.llvm.org/D19415

Files:
  include/__mutex_base
  include/__os_support
  include/thread
  src/algorithm.cpp
  src/condition_variable.cpp
  src/memory.cpp
  src/mutex.cpp
  src/thread.cpp

Index: src/thread.cpp
===
--- src/thread.cpp
+++ src/thread.cpp
@@ -50,6 +50,8 @@
 {
 #if defined(_LIBCPP_THREAD_API_PTHREAD)
 int ec = pthread_join(__t_, 0);
+#elif defined(_LIBCPP_THREAD_API_EXTERNAL)
+int ec = __os_thread_join(__t_);
 #else
 #error "Not implemented for the selected thread API."
 #endif
@@ -70,6 +72,8 @@
 {
 #if defined(_LIBCPP_THREAD_API_PTHREAD)
 ec = pthread_detach(__t_);
+#elif defined(_LIBCPP_THREAD_API_EXTERNAL)
+ec = __os_thread_detach(__t_);
 #else
 #error "Not implemented for the selected thread API."
 #endif
Index: src/mutex.cpp
===
--- src/mutex.cpp
+++ src/mutex.cpp
@@ -27,6 +27,8 @@
 {
 #if defined(_LIBCPP_THREAD_API_PTHREAD)
 pthread_mutex_destroy(&__m_);
+#elif defined(_LIBCPP_THREAD_API_EXTERNAL)
+__os_mutex_destroy(__m_);
 #else
 #error "Not implemented for the selected thread API."
 #endif
@@ -37,6 +39,8 @@
 {
 #if defined(_LIBCPP_THREAD_API_PTHREAD)
 int ec = pthread_mutex_lock(&__m_);
+#elif defined(_LIBCPP_THREAD_API_EXTERNAL)
+int ec = __os_mutex_lock(__m_);
 #else
 #error "Not implemented for the selected thread API."
 #endif
@@ -49,6 +53,8 @@
 {
 #if defined(_LIBCPP_THREAD_API_PTHREAD)
 return pthread_mutex_trylock(&__m_) == 0;
+#elif defined(_LIBCPP_THREAD_API_EXTERNAL)
+return __os_mutex_trylock(__m_) == 0;
 #else
 #error "Not implemented for the selected thread API."
 #endif
@@ -59,6 +65,8 @@
 {
 #if defined(_LIBCPP_THREAD_API_PTHREAD)
 int ec = pthread_mutex_unlock(&__m_);
+#elif defined(_LIBCPP_THREAD_API_EXTERNAL)
+int ec = __os_mutex_unlock(__m_);
 #else
 #error "Not implemented for the selected thread API."
 #endif
@@ -93,18 +101,24 @@
 pthread_mutex_destroy(&__m_);
 goto fail;
 }
-return;
-fail:
-__throw_system_error(ec, "recursive_mutex constructor failed");
+#elif defined(_LIBCPP_THREAD_API_EXTERNAL)
+int ec = __os_mutex_init(&__m_, true);
+if (ec)
+  goto fail;
 #else
 #error "Not implemented for the selected thread API."
 #endif
+return;
+fail:
+__throw_system_error(ec, "recursive_mutex constructor failed");
 }
 
 recursive_mutex::~recursive_mutex()
 {
 #if defined(_LIBCPP_THREAD_API_PTHREAD)
 int e = pthread_mutex_destroy(&__m_);
+#elif defined(_LIBCPP_THREAD_API_EXTERNAL)
+int e = __os_mutex_destroy(__m_);
 #else
 #error "Not implemented for the selected thread API."
 #endif
@@ -117,6 +131,8 @@
 {
 #if defined(_LIBCPP_THREAD_API_PTHREAD)
 int ec = pthread_mutex_lock(&__m_);
+#elif defined(_LIBCPP_THREAD_API_EXTERNAL)
+int ec = __os_mutex_lock(__m_);
 #else
 #error "Not implemented for the selected thread API."
 #endif
@@ -129,6 +145,8 @@
 {
 #if defined(_LIBCPP_THREAD_API_PTHREAD)
 int e = pthread_mutex_unlock(&__m_);
+#elif defined(_LIBCPP_THREAD_API_EXTERNAL)
+int e = __os_mutex_unlock(__m_);
 #else
 #error "Not implemented for the selected thread API."
 #endif
@@ -141,6 +159,8 @@
 {
 #if defined(_LIBCPP_THREAD_API_PTHREAD)
 return pthread_mutex_trylock(&__m_) == 0;
+#elif defined(_LIBCPP_THREAD_API_EXTERNAL)
+return __os_mutex_trylock(__m_) == 0;
 #else
 #error "Not implemented for the selected thread API."
 #endif
@@ -311,7 +331,9 @@
 }
 else
 pthread_mutex_unlock(&mut);
-#else // !_LIBCPP_THREAD_API_PTHREAD
+#elif defined(_LIBCPP_THREAD_API_EXTERNAL)
+ __os_call_once(flag, arg, func);
+#else
 #error "Not imple

Re: [PATCH] D19412: [libcxx] Refactor pthread usage - II

2016-04-22 Thread Asiri Rathnayake via cfe-commits
rmaprath updated this revision to Diff 54658.
rmaprath added a comment.

Added bit more context to the diff.


http://reviews.llvm.org/D19412

Files:
  include/__config
  include/__mutex_base
  include/__os_support
  include/mutex
  include/thread
  src/algorithm.cpp
  src/condition_variable.cpp
  src/memory.cpp
  src/mutex.cpp
  src/thread.cpp

Index: src/thread.cpp
===
--- src/thread.cpp
+++ src/thread.cpp
@@ -37,6 +37,8 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
+using namespace __libcpp_os_support;
+
 thread::~thread()
 {
 if (__t_ != 0)
@@ -46,7 +48,11 @@
 void
 thread::join()
 {
+#if defined(_LIBCPP_THREAD_API_PTHREAD)
 int ec = pthread_join(__t_, 0);
+#else
+#error "Not implemented for the selected thread API."
+#endif
 #ifndef _LIBCPP_NO_EXCEPTIONS
 if (ec)
 throw system_error(error_code(ec, system_category()), "thread::join failed");
@@ -62,7 +68,11 @@
 int ec = EINVAL;
 if (__t_ != 0)
 {
+#if defined(_LIBCPP_THREAD_API_PTHREAD)
 ec = pthread_detach(__t_);
+#else
+#error "Not implemented for the selected thread API."
+#endif
 if (ec == 0)
 __t_ = 0;
 }
@@ -109,8 +119,7 @@
 namespace this_thread
 {
 
-void
-sleep_for(const chrono::nanoseconds& ns)
+void sleep_for(const chrono::nanoseconds& ns)
 {
 using namespace chrono;
 if (ns > nanoseconds::zero())
@@ -135,8 +144,7 @@
 }
 }
 
-}  // this_thread
-
+}
 __thread_specific_ptr<__thread_struct>&
 __thread_local_data()
 {
Index: src/mutex.cpp
===
--- src/mutex.cpp
+++ src/mutex.cpp
@@ -21,37 +21,56 @@
 const try_to_lock_t try_to_lock = {};
 const adopt_lock_t  adopt_lock = {};
 
+using namespace __libcpp_os_support;
+
 mutex::~mutex()
 {
+#if defined(_LIBCPP_THREAD_API_PTHREAD)
 pthread_mutex_destroy(&__m_);
+#else
+#error "Not implemented for the selected thread API."
+#endif
 }
 
 void
 mutex::lock()
 {
+#if defined(_LIBCPP_THREAD_API_PTHREAD)
 int ec = pthread_mutex_lock(&__m_);
+#else
+#error "Not implemented for the selected thread API."
+#endif
 if (ec)
 __throw_system_error(ec, "mutex lock failed");
 }
 
 bool
 mutex::try_lock() _NOEXCEPT
 {
+#if defined(_LIBCPP_THREAD_API_PTHREAD)
 return pthread_mutex_trylock(&__m_) == 0;
+#else
+#error "Not implemented for the selected thread API."
+#endif
 }
 
 void
 mutex::unlock() _NOEXCEPT
 {
+#if defined(_LIBCPP_THREAD_API_PTHREAD)
 int ec = pthread_mutex_unlock(&__m_);
+#else
+#error "Not implemented for the selected thread API."
+#endif
 (void)ec;
 assert(ec == 0);
 }
 
 // recursive_mutex
 
 recursive_mutex::recursive_mutex()
 {
+#if defined(_LIBCPP_THREAD_API_PTHREAD)
 pthread_mutexattr_t attr;
 int ec = pthread_mutexattr_init(&attr);
 if (ec)
@@ -77,35 +96,54 @@
 return;
 fail:
 __throw_system_error(ec, "recursive_mutex constructor failed");
+#else
+#error "Not implemented for the selected thread API."
+#endif
 }
 
 recursive_mutex::~recursive_mutex()
 {
+#if defined(_LIBCPP_THREAD_API_PTHREAD)
 int e = pthread_mutex_destroy(&__m_);
+#else
+#error "Not implemented for the selected thread API."
+#endif
 (void)e;
 assert(e == 0);
 }
 
 void
 recursive_mutex::lock()
 {
+#if defined(_LIBCPP_THREAD_API_PTHREAD)
 int ec = pthread_mutex_lock(&__m_);
+#else
+#error "Not implemented for the selected thread API."
+#endif
 if (ec)
 __throw_system_error(ec, "recursive_mutex lock failed");
 }
 
 void
 recursive_mutex::unlock() _NOEXCEPT
 {
+#if defined(_LIBCPP_THREAD_API_PTHREAD)
 int e = pthread_mutex_unlock(&__m_);
+#else
+#error "Not implemented for the selected thread API."
+#endif
 (void)e;
 assert(e == 0);
 }
 
 bool
 recursive_mutex::try_lock() _NOEXCEPT
 {
+#if defined(_LIBCPP_THREAD_API_PTHREAD)
 return pthread_mutex_trylock(&__m_) == 0;
+#else
+#error "Not implemented for the selected thread API."
+#endif
 }
 
 // timed_mutex
@@ -165,9 +203,9 @@
 void
 recursive_timed_mutex::lock()
 {
-pthread_t id = pthread_self();
+__os_thread_id id = __os_thread_get_current_id();
 unique_lock lk(__m_);
-if (pthread_equal(id, __id_))
+if (__os_thread_id_compare(id, __id_) == 0)
 {
 if (__count_ == numeric_limits::max())
 __throw_system_error(EAGAIN, "recursive_timed_mutex lock limit reached");
@@ -183,9 +221,9 @@
 bool
 recursive_timed_mutex::try_lock() _NOEXCEPT
 {
-pthread_t id = pthread_self();
+__os_thread_id id = __os_thread_get_current_id();
 unique_lock lk(__m_, try_to_lock);
-if (lk.owns_lock() && (__count_ == 0 || pthread_equal(id, __id_)))
+if (lk.owns_lock() && (__count_ == 0 || __os_thread_id_compare(id, __id_) == 0))
 {
 if (__count_ == numeric_limits::max())
 return false;
@@ -210,22 +248,17 @@
 
 #endif // !_LIBCPP_HAS_NO_THREADS
 
+#if !defined(_LIBCPP_HAS_NO_THREADS) && defin

Re: [PATCH] D18963: PR27216: Only define __ARM_FEATURE_FMA when the target has VFPv4

2016-04-22 Thread silviu.bara...@arm.com via cfe-commits
sbaranga added a comment.

A gentle ping?

Cheers,
Silviu


http://reviews.llvm.org/D18963



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


[PATCH] D19412: [libcxx] Refactor pthread usage - II

2016-04-22 Thread Asiri Rathnayake via cfe-commits
rmaprath created this revision.
rmaprath added reviewers: EricWF, theraven, mclow.lists, jroelofs.
rmaprath added subscribers: espositofulvio, cfe-commits.

This is mostly D11781 with the final review comments addressed:
- Merged all the headers into a single `__os_support` header
- Moved all internal functions (those only used by the library sources) away 
from the headers. This required adding a few `#ifdef`s into the library sources 
to select between the thread API.

Note that this is only a refactoring, in that it isolates pthread usage of 
libcxx allowing anyone to easily plug-in a different thread implementation into 
libcxx sources.

The final goal of this work (at least for us) is a bit more involved: we want 
to allow libcxx users to plug-in their own thread implementation at compile 
time. I have a patch for this which builds on the current one, I will be 
uploading it soon for comments.



http://reviews.llvm.org/D19412

Files:
  include/__config
  include/__mutex_base
  include/__os_support
  include/mutex
  include/thread
  src/algorithm.cpp
  src/condition_variable.cpp
  src/memory.cpp
  src/mutex.cpp
  src/thread.cpp

Index: src/thread.cpp
===
--- src/thread.cpp
+++ src/thread.cpp
@@ -37,6 +37,8 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
+using namespace __libcpp_os_support;
+
 thread::~thread()
 {
 if (__t_ != 0)
@@ -46,7 +48,11 @@
 void
 thread::join()
 {
+#if defined(_LIBCPP_THREAD_API_PTHREAD)
 int ec = pthread_join(__t_, 0);
+#else
+#error "Not implemented for the selected thread API."
+#endif
 #ifndef _LIBCPP_NO_EXCEPTIONS
 if (ec)
 throw system_error(error_code(ec, system_category()), "thread::join failed");
@@ -62,7 +68,11 @@
 int ec = EINVAL;
 if (__t_ != 0)
 {
+#if defined(_LIBCPP_THREAD_API_PTHREAD)
 ec = pthread_detach(__t_);
+#else
+#error "Not implemented for the selected thread API."
+#endif
 if (ec == 0)
 __t_ = 0;
 }
@@ -109,8 +119,7 @@
 namespace this_thread
 {
 
-void
-sleep_for(const chrono::nanoseconds& ns)
+void sleep_for(const chrono::nanoseconds& ns)
 {
 using namespace chrono;
 if (ns > nanoseconds::zero())
@@ -135,8 +144,7 @@
 }
 }
 
-}  // this_thread
-
+}
 __thread_specific_ptr<__thread_struct>&
 __thread_local_data()
 {
Index: src/mutex.cpp
===
--- src/mutex.cpp
+++ src/mutex.cpp
@@ -21,15 +21,25 @@
 const try_to_lock_t try_to_lock = {};
 const adopt_lock_t  adopt_lock = {};
 
+using namespace __libcpp_os_support;
+
 mutex::~mutex()
 {
+#if defined(_LIBCPP_THREAD_API_PTHREAD)
 pthread_mutex_destroy(&__m_);
+#else
+#error "Not implemented for the selected thread API."
+#endif
 }
 
 void
 mutex::lock()
 {
+#if defined(_LIBCPP_THREAD_API_PTHREAD)
 int ec = pthread_mutex_lock(&__m_);
+#else
+#error "Not implemented for the selected thread API."
+#endif
 if (ec)
 __throw_system_error(ec, "mutex lock failed");
 }
@@ -37,13 +47,21 @@
 bool
 mutex::try_lock() _NOEXCEPT
 {
+#if defined(_LIBCPP_THREAD_API_PTHREAD)
 return pthread_mutex_trylock(&__m_) == 0;
+#else
+#error "Not implemented for the selected thread API."
+#endif
 }
 
 void
 mutex::unlock() _NOEXCEPT
 {
+#if defined(_LIBCPP_THREAD_API_PTHREAD)
 int ec = pthread_mutex_unlock(&__m_);
+#else
+#error "Not implemented for the selected thread API."
+#endif
 (void)ec;
 assert(ec == 0);
 }
@@ -52,6 +70,7 @@
 
 recursive_mutex::recursive_mutex()
 {
+#if defined(_LIBCPP_THREAD_API_PTHREAD)
 pthread_mutexattr_t attr;
 int ec = pthread_mutexattr_init(&attr);
 if (ec)
@@ -77,11 +96,18 @@
 return;
 fail:
 __throw_system_error(ec, "recursive_mutex constructor failed");
+#else
+#error "Not implemented for the selected thread API."
+#endif
 }
 
 recursive_mutex::~recursive_mutex()
 {
+#if defined(_LIBCPP_THREAD_API_PTHREAD)
 int e = pthread_mutex_destroy(&__m_);
+#else
+#error "Not implemented for the selected thread API."
+#endif
 (void)e;
 assert(e == 0);
 }
@@ -89,7 +115,11 @@
 void
 recursive_mutex::lock()
 {
+#if defined(_LIBCPP_THREAD_API_PTHREAD)
 int ec = pthread_mutex_lock(&__m_);
+#else
+#error "Not implemented for the selected thread API."
+#endif
 if (ec)
 __throw_system_error(ec, "recursive_mutex lock failed");
 }
@@ -97,7 +127,11 @@
 void
 recursive_mutex::unlock() _NOEXCEPT
 {
+#if defined(_LIBCPP_THREAD_API_PTHREAD)
 int e = pthread_mutex_unlock(&__m_);
+#else
+#error "Not implemented for the selected thread API."
+#endif
 (void)e;
 assert(e == 0);
 }
@@ -105,7 +139,11 @@
 bool
 recursive_mutex::try_lock() _NOEXCEPT
 {
+#if defined(_LIBCPP_THREAD_API_PTHREAD)
 return pthread_mutex_trylock(&__m_) == 0;
+#else
+#error "Not implemented for the selected thread API."
+#endif
 }
 
 // timed_mutex
@@ -165,9 +203,9 @@
 void
 recursive_timed_mutex::lock()
 {
-pthread_t id = pth

Re: [PATCH] D14293: [libcxx] Add -fno-exceptions libcxx builders to zorg

2016-04-22 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

In http://reviews.llvm.org/D14293#350570, @rengolin wrote:

> Sorry, this fell out of my radar. I'm ok with the changes. Ping me when you 
> commit so I can monitor the bot for a while.


Sorry, I missed your message this time around :)

I'll double-check the patch and commit. Thanks!

/ Asiri


http://reviews.llvm.org/D14293



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


r267159 - [Hexagon] Add definitions for circular and bit-reverse loads/stores

2016-04-22 Thread Krzysztof Parzyszek via cfe-commits
Author: kparzysz
Date: Fri Apr 22 09:58:46 2016
New Revision: 267159

URL: http://llvm.org/viewvc/llvm-project?rev=267159&view=rev
Log:
[Hexagon] Add definitions for circular and bit-reverse loads/stores

Modified:
cfe/trunk/include/clang/Basic/BuiltinsHexagon.def
cfe/trunk/test/CodeGen/builtins-hexagon.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsHexagon.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsHexagon.def?rev=267159&r1=267158&r2=267159&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsHexagon.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsHexagon.def Fri Apr 22 09:58:46 2016
@@ -18,7 +18,28 @@
 // Make sure you do not overwrite these.
 
 BUILTIN(__builtin_SI_to_SXTHI_asrh, "ii", "")
-BUILTIN(__builtin_circ_ldd, "LLi*LLi*LLi*ii", "")
+BUILTIN(__builtin_brev_ldd,   "LLi*LLi*LLi*i", "")
+BUILTIN(__builtin_brev_ldw,   "i*i*i*i", "")
+BUILTIN(__builtin_brev_ldh,   "s*s*s*i", "")
+BUILTIN(__builtin_brev_lduh,  "Us*Us*Us*i", "")
+BUILTIN(__builtin_brev_ldb,   "c*c*c*i", "")
+BUILTIN(__builtin_brev_ldub,  "Uc*Uc*Uc*i", "")
+BUILTIN(__builtin_circ_ldd,   "LLi*LLi*LLi*iIi", "")
+BUILTIN(__builtin_circ_ldw,   "i*i*i*iIi", "")
+BUILTIN(__builtin_circ_ldh,   "s*s*s*iIi", "")
+BUILTIN(__builtin_circ_lduh,  "Us*Us*Us*iIi", "")
+BUILTIN(__builtin_circ_ldb,   "c*c*c*iIi", "")
+BUILTIN(__builtin_circ_ldub,  "Uc*Uc*Uc*iIi", "")
+BUILTIN(__builtin_brev_std,   "LLi*LLi*LLii", "")
+BUILTIN(__builtin_brev_stw,   "i*i*ii", "")
+BUILTIN(__builtin_brev_sth,   "s*s*ii", "")
+BUILTIN(__builtin_brev_sthhi, "s*s*ii", "")
+BUILTIN(__builtin_brev_stb,   "c*c*ii", "")
+BUILTIN(__builtin_circ_std,   "LLi*LLi*LLiiIi", "")
+BUILTIN(__builtin_circ_stw,   "i*i*iiIi", "")
+BUILTIN(__builtin_circ_sth,   "s*s*iiIi", "")
+BUILTIN(__builtin_circ_sthhi, "s*s*iiIi", "")
+BUILTIN(__builtin_circ_stb,   "c*c*iiIi", "")
 
 // The builtins above are not autogenerated from iset.py.
 // Make sure you do not overwrite these.

Modified: cfe/trunk/test/CodeGen/builtins-hexagon.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-hexagon.c?rev=267159&r1=267158&r2=267159&view=diff
==
--- cfe/trunk/test/CodeGen/builtins-hexagon.c (original)
+++ cfe/trunk/test/CodeGen/builtins-hexagon.c Fri Apr 22 09:58:46 2016
@@ -6,6 +6,52 @@ void foo() {
   int v32 __attribute__((__vector_size__(128)));
   int v64 __attribute__((__vector_size__(256)));
 
+  // The circ/brev intrinsics do not have _HEXAGON_ in the name.
+  __builtin_brev_ldb(0, 0, 0);
+  // CHECK: @llvm.hexagon.brev.ldb
+  __builtin_brev_ldd(0, 0, 0);
+  // CHECK: @llvm.hexagon.brev.ldd
+  __builtin_brev_ldh(0, 0, 0);
+  // CHECK: @llvm.hexagon.brev.ldh
+  __builtin_brev_ldub(0, 0, 0);
+  // CHECK: @llvm.hexagon.brev.ldub
+  __builtin_brev_lduh(0, 0, 0);
+  // CHECK: @llvm.hexagon.brev.lduh
+  __builtin_brev_ldw(0, 0, 0);
+  // CHECK: @llvm.hexagon.brev.ldw
+  __builtin_brev_stb(0, 0, 0);
+  // CHECK: @llvm.hexagon.brev.stb
+  __builtin_brev_std(0, 0LL, 0);
+  // CHECK: @llvm.hexagon.brev.std
+  __builtin_brev_sth(0, 0, 0);
+  // CHECK: @llvm.hexagon.brev.sth
+  __builtin_brev_sthhi(0, 0, 0);
+  // CHECK: @llvm.hexagon.brev.sthhi
+  __builtin_brev_stw(0, 0, 0);
+  // CHECK: @llvm.hexagon.brev.stw
+  __builtin_circ_ldb(0, 0, 0, 0);
+  // CHECK: llvm.hexagon.circ.ldb
+  __builtin_circ_ldd(0, 0, 0, 0);
+  // CHECK: llvm.hexagon.circ.ldd
+  __builtin_circ_ldh(0, 0, 0, 0);
+  // CHECK: llvm.hexagon.circ.ldh
+  __builtin_circ_ldub(0, 0, 0, 0);
+  // CHECK: llvm.hexagon.circ.ldub
+  __builtin_circ_lduh(0, 0, 0, 0);
+  // CHECK: llvm.hexagon.circ.lduh
+  __builtin_circ_ldw(0, 0, 0, 0);
+  // CHECK: llvm.hexagon.circ.ldw
+  __builtin_circ_stb(0, 0, 0, 0);
+  // CHECK: llvm.hexagon.circ.stb
+  __builtin_circ_std(0, 0LL, 0, 0);
+  // CHECK: llvm.hexagon.circ.std
+  __builtin_circ_sth(0, 0, 0, 0);
+  // CHECK: llvm.hexagon.circ.sth
+  __builtin_circ_sthhi(0, 0, 0, 0);
+  // CHECK: llvm.hexagon.circ.sthhi
+  __builtin_circ_stw(0, 0, 0, 0);
+  // CHECK: llvm.hexagon.circ.stw
+
   __builtin_HEXAGON_A2_abs(0);
   // CHECK: @llvm.hexagon.A2.abs
   __builtin_HEXAGON_A2_absp(0);


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


Re: [PATCH] D18369: [OpenCL] Upstreaming khronos OpenCL header file.

2016-04-22 Thread Yaxun Liu via cfe-commits
yaxunl added a comment.

In http://reviews.llvm.org/D18369#408773, @bader wrote:

> BTW, there is a comment on GitHub that opencl.h might be a bad name for that 
> header, since Khronos group provides the header with the same name, but it 
> defines host API. So if some developer is using clang to compile OpenCL 
> application it might accidentally include opencl.h provided with Clang 
> instead of opencl.h with OpenCL host API.


Right. We'd better come up with another name. How about opencl-c.h?



Comment at: lib/Headers/opencl.h:4870
@@ +4869,3 @@
+
+#ifdef cl_khr_fp64
+char __const_func __attribute__((overloadable)) convert_char(double);

bader wrote:
> Sam, could you confirm that this macro id implicitly defined for OpenCL 
> versions 1.2+?
AMDGPU target defines it. However, SPIR target does not. As discussed at 
cfe-dev, SPIR target should define all extensions/optional core features as 
supported. I will open a review for that.


http://reviews.llvm.org/D18369



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


Re: [PATCH] D19406: [clang-tidy] fix link in Release Notes

2016-04-22 Thread Haojian Wu via cfe-commits
hokein added a comment.

In http://reviews.llvm.org/D19406#408893, @omtcyf0 wrote:

> @hokein
>
> Great, thanks!
>
> I'd be very grateful if you could land it!


Sure. Done.


Repository:
  rL LLVM

http://reviews.llvm.org/D19406



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


Re: [PATCH] D19062: Add functions in ctype.h to builtin function database (Fix)

2016-04-22 Thread Taewook Oh via cfe-commits
twoh added a comment.

Ping. @joerg, could you please take a look?


http://reviews.llvm.org/D19062



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


[clang-tools-extra] r267155 - [clang-tidy] fix link in Release Notes

2016-04-22 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Fri Apr 22 09:43:39 2016
New Revision: 267155

URL: http://llvm.org/viewvc/llvm-project?rev=267155&view=rev
Log:
[clang-tidy] fix link in Release Notes

Summary: This is intended to fix https://llvm.org/bugs/show_bug.cgi?id=27426

Patch by Kirill Bobyrev!

Reviewers: alexfh, LegalizeAdulthood, hokein

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D19406

Modified:
clang-tools-extra/trunk/docs/ReleaseNotes.rst

Modified: clang-tools-extra/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/ReleaseNotes.rst?rev=267155&r1=267154&r2=267155&view=diff
==
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst (original)
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst Fri Apr 22 09:43:39 2016
@@ -109,7 +109,7 @@ identified.  The improvements since the
   Detect multiple statement macros that are used in unbraced conditionals.
 
 - New `misc-pointer-and-integral-operation
-  
`_
 check
+  
`_
 check
 
   Warns about suspicious operations involving pointers and integral types.
 


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


Re: [PATCH] D19406: [clang-tidy] fix link in Release Notes

2016-04-22 Thread Haojian Wu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL267155: [clang-tidy] fix link in Release Notes (authored by 
hokein).

Changed prior to commit:
  http://reviews.llvm.org/D19406?vs=54620&id=54649#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19406

Files:
  clang-tools-extra/trunk/docs/ReleaseNotes.rst

Index: clang-tools-extra/trunk/docs/ReleaseNotes.rst
===
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst
@@ -109,7 +109,7 @@
   Detect multiple statement macros that are used in unbraced conditionals.
 
 - New `misc-pointer-and-integral-operation
-  
`_
 check
+  
`_
 check
 
   Warns about suspicious operations involving pointers and integral types.
 


Index: clang-tools-extra/trunk/docs/ReleaseNotes.rst
===
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst
@@ -109,7 +109,7 @@
   Detect multiple statement macros that are used in unbraced conditionals.
 
 - New `misc-pointer-and-integral-operation
-  `_ check
+  `_ check
 
   Warns about suspicious operations involving pointers and integral types.
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r267054 - Split interesting warnings off from -Wfloat-conversion

2016-04-22 Thread Nico Weber via cfe-commits
Hi Richard,

1.) Are these new warnings in -Wconversion? If not, they probably should
be, right?

2.) It looks like -Wfloat-bool-constant-conversion is on by default and
warns on things like

  if (kHotspotRadius)

if kHotspotRadius is a float. Do you have data that suggests that this is a
common buggy pattern? Omitting `!= 0` is extremely common in practice, and
it's even dictated in some style guides (e.g.
https://webkit.org/code-style-guidelines/#null-false-and-zero ("Tests for
[...] zero/non-zero should all be done without equality comparisons."). So
making this a warning for floats but not for others seems weird to me.

Nico


On Thu, Apr 21, 2016 at 5:04 PM, Richard Trieu via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rtrieu
> Date: Thu Apr 21 16:04:55 2016
> New Revision: 267054
>
> URL: http://llvm.org/viewvc/llvm-project?rev=267054&view=rev
> Log:
> Split interesting warnings off from -Wfloat-conversion
>
> Restructure the implict floating point to integer conversions so that
> interesting sub-groups are under different flags.  Breakdown of warnings:
>
> No warning:
> Exact conversions from floating point to integer:
> int x = 10.0;
> int x = 1e10;
>
> -Wliteral-conversion - Floating point literal to integer with rounding:
> int x = 5.5;
> int x = -3.4;
>
> -Wfloat-conversion - All conversions not covered by the above two:
> int x = GetFloat();
> int x = 5.5 + 3.5;
>
> -Wfloat-zero-conversion - The expression converted has a non-zero floating
> point value that gets converted to a zero integer value, excluded the cases
> falling under -Wliteral-conversion.  Subset of -Wfloat-conversion.
> int x = 1.0 / 2.0;
>
> -Wfloat-overflow-conversion - The floating point value is outside the range
> of the integer type, exluding cases from -Wliteral conversion.  Subset of
> -Wfloat-conversion.
> char x = 500;
> char x = -1000;
>
> -Wfloat-bool-conversion - Any conversion of a floating point type to bool.
> Subset of -Wfloat-conversion.
> if (GetFloat()) {}
> bool x = 5.0;
>
> -Wfloat-bool-constant-conversion - Conversion of a compile time evaluatable
> floating point value to bool.  Subset of -Wfloat-bool-conversion.
> bool x = 1.0;
> bool x = 4.0 / 20.0;
>
> Also add EvaluateAsFloat to Sema, which is similar to EvaluateAsInt, but
> for
> floating point values.
>
>
> Modified:
> cfe/trunk/include/clang/AST/Expr.h
> cfe/trunk/include/clang/Basic/DiagnosticGroups.td
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> cfe/trunk/lib/AST/ExprConstant.cpp
> cfe/trunk/lib/Sema/SemaChecking.cpp
> cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp
> cfe/trunk/test/SemaCXX/warn-float-conversion.cpp
> cfe/trunk/test/SemaCXX/warn-literal-conversion.cpp
>
> Modified: cfe/trunk/include/clang/AST/Expr.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=267054&r1=267053&r2=267054&view=diff
>
> ==
> --- cfe/trunk/include/clang/AST/Expr.h (original)
> +++ cfe/trunk/include/clang/AST/Expr.h Thu Apr 21 16:04:55 2016
> @@ -594,6 +594,13 @@ public:
>bool EvaluateAsInt(llvm::APSInt &Result, const ASTContext &Ctx,
>   SideEffectsKind AllowSideEffects = SE_NoSideEffects)
> const;
>
> +  /// EvaluateAsFloat - Return true if this is a constant which we can
> fold and
> +  /// convert to a floating point value, using any crazy technique that we
> +  /// want to.
> +  bool
> +  EvaluateAsFloat(llvm::APFloat &Result, const ASTContext &Ctx,
> +  SideEffectsKind AllowSideEffects = SE_NoSideEffects)
> const;
> +
>/// isEvaluatable - Call EvaluateAsRValue to see if this expression can
> be
>/// constant folded without side-effects, but discard the result.
>bool isEvaluatable(const ASTContext &Ctx,
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=267054&r1=267053&r2=267054&view=diff
>
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Thu Apr 21 16:04:55
> 2016
> @@ -46,7 +46,17 @@ def BoolConversion : DiagGroup<"bool-con
>
> UndefinedBoolConversion]>;
>  def IntConversion : DiagGroup<"int-conversion">;
>  def EnumConversion : DiagGroup<"enum-conversion">;
> -def FloatConversion : DiagGroup<"float-conversion">;
> +
> +def FloatOverflowConversion : DiagGroup<"float-overflow-conversion">;
> +def FloatZeroConversion : DiagGroup<"float-zero-conversion">;
> +def FloatBoolConstantConversion :
> DiagGroup<"float-bool-constant-conversion">;
> +def FloatBoolConversion :
> +  DiagGroup<"float-bool-conversion", [FloatBoolConstantConversion]>;
> +def FloatConversion :
> +  DiagGroup<"float-conversion", [FloatBoolConversion,
> + FloatOverflo

Re: [PATCH] D19357: [ASTMatchers] New matcher forFunction

2016-04-22 Thread Balogh , Ádám via cfe-commits
baloghadamsoftware marked 9 inline comments as done.
baloghadamsoftware added a comment.

http://reviews.llvm.org/D19357



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


Re: [PATCH] D19357: [ASTMatchers] New matcher forFunction

2016-04-22 Thread Balogh , Ádám via cfe-commits
baloghadamsoftware updated this revision to Diff 54642.
baloghadamsoftware added a comment.

Updated according to the comments.


http://reviews.llvm.org/D19357

Files:
  docs/LibASTMatchersReference.html
  include/clang/ASTMatchers/ASTMatchers.h
  lib/ASTMatchers/Dynamic/Registry.cpp
  unittests/ASTMatchers/ASTMatchersTest.cpp

Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -5568,5 +5568,40 @@
   EXPECT_FALSE(matches("void F() { return; }", RetVal));
 }
 
+TEST(StatementMatcher, ForFunction) {
+  const auto CppString1 =
+"struct PosVec {"
+"  PosVec& operator=(const PosVec&) {"
+"auto x = [] { return 1; };"
+"return *this;"
+"  }"
+"};";
+  const auto CppString2 =
+"void F() {"
+"  struct S {"
+"void F2() {"
+"   return;"
+"}"
+"  };"
+"}";
+  EXPECT_TRUE(
+matches(
+  CppString1,
+  returnStmt(forFunction(hasName("operator=")),
+ has(unaryOperator(hasOperatorName("*"));
+  EXPECT_TRUE(
+notMatches(
+  CppString1,
+  returnStmt(forFunction(hasName("operator=")),
+ has(integerLiteral();
+  EXPECT_TRUE(
+matches(
+  CppString1,
+  returnStmt(forFunction(hasName("operator()")),
+ has(integerLiteral();
+  EXPECT_TRUE(matches(CppString2, returnStmt(forFunction(hasName("F2");
+  EXPECT_TRUE(notMatches(CppString2, returnStmt(forFunction(hasName("F");
+}
+
 } // end namespace ast_matchers
 } // end namespace clang
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -184,6 +184,7 @@
   REGISTER_MATCHER(forEachDescendant);
   REGISTER_MATCHER(forEachSwitchCase);
   REGISTER_MATCHER(forField);
+  REGISTER_MATCHER(forFunction);
   REGISTER_MATCHER(forStmt);
   REGISTER_MATCHER(friendDecl);
   REGISTER_MATCHER(functionDecl);
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -5108,6 +5108,45 @@
   gnuNullExpr(), cxxNullPtrLiteralExpr(),
   integerLiteral(equals(0), hasParent(expr(hasType(pointerType());
 }
+
+/// \brief Matches declaration of the function the statemenet belongs to
+///
+/// Given:
+/// \code
+/// F& operator=(const F& o) {
+///   std::copy_if(o.begin(), o.end(), begin(), [](V v) { return v > 0; });
+///   return *this;
+/// }
+/// \endcode
+/// returnStmt(forFunction(hasName("operator=")))
+///   matches 'return *this'
+///   but does match 'return > 0'
+AST_MATCHER_P(Stmt, forFunction, internal::Matcher,
+  InnerMatcher) {
+  const auto &Parents = Finder->getASTContext().getParents(Node);
+
+  llvm::SmallVector Stack(Parents.begin(),
+Parents.end());
+  while(!Stack.empty()) {
+const auto &CurNode = Stack.back();
+Stack.pop_back();
+if(const auto *FuncDeclNode = CurNode.get()) {
+  if(InnerMatcher.matches(*FuncDeclNode, Finder, Builder)) {
+return true;
+  }
+} else if(const auto *LambdaExprNode = CurNode.get()) {
+  if(InnerMatcher.matches(*LambdaExprNode->getCallOperator(),
+  Finder, Builder)) {
+return true;
+  }
+} else {
+  for(const auto &Parent: Finder->getASTContext().getParents(CurNode))
+Stack.push_back(Parent);
+}
+  }
+  return false;
+}
+
 } // end namespace ast_matchers
 } // end namespace clang
 
Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -4923,6 +4923,20 @@
 
 
 
+MatcherStmt>forFunctionMatcherFunctionDecl> InnerMatcher
+Matches declaration of the function the statemenet belongs to
+
+Given:
+F& operator=(const F& o) {
+  std::copy_if(o.begin(), o.end(), begin(), [](V v) { return v > 0; });
+  return *this;
+}
+returnStmt(forFunction(hasName("operator=")))
+  matches 'return *this'
+  but does match 'return > 0'
+
+
+
 MatcherStmt>sizeOfExprMatcherUnaryExprOrTypeTraitExpr>  InnerMatcher
 Same as unaryExprOrTypeTraitExpr, but only matching
 sizeof.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12200: Add framework for iterative compilation to clang

2016-04-22 Thread Zoran Jovanovic via cfe-commits
zoran.jovanovic updated this revision to Diff 54640.
zoran.jovanovic added a comment.

New patch version rebased to r256194.
Any comments to this work?


http://reviews.llvm.org/D12200

Files:
  include/clang/Driver/Compilation.h
  include/clang/Driver/Driver.h
  include/clang/Driver/Options.td
  lib/CodeGen/BackendUtil.cpp
  lib/Driver/Driver.cpp
  lib/Driver/Tools.cpp
  tools/driver/driver.cpp

Index: tools/driver/driver.cpp
===
--- tools/driver/driver.cpp
+++ tools/driver/driver.cpp
@@ -50,6 +50,11 @@
 #include "llvm/Support/raw_ostream.h"
 #include 
 #include 
+#include "llvm/Analysis/IterativeCompilation.h"
+#include "llvm/Support/Program.h"
+#include 
+#include 
+#include 
 using namespace clang;
 using namespace clang::driver;
 using namespace llvm::opt;
@@ -307,6 +312,80 @@
   return 1;
 }
 
+void initControlFiles(llvm::ModuleDecisionTrees &MDT, int CurrentIteration)
+{
+  std::string ICResultsFile;
+  std::string ICResultsFile2;
+
+  // assign control files
+  llvm::ICResultsFile results1("ic-results", CurrentIteration);
+  llvm::ICResultsFile results2("ic-results2", CurrentIteration);
+  MDT.getICResultsFile() = results1;
+  MDT.getICResultsFile2() = results2;
+
+  llvm::ICInputFile input1("ic-input", CurrentIteration);
+  llvm::ICInputFile input2("ic-input2", CurrentIteration);
+  MDT.getICInputFile() = input1;
+  MDT.getICInputFile2() = input2;
+}
+
+void writeInputFiles(llvm::ModuleDecisionTrees &MDT)
+{
+  // inits and declarations
+  llvm::ICPathsMap paths;
+  llvm::ICPathsMap pathBeforeCodegen;
+  llvm::ICPathsMap pathAfterCodegen;
+
+  // split paths
+  MDT.getPaths(paths);
+  MDT.splitPaths(paths, pathBeforeCodegen, pathAfterCodegen);
+
+  // convert paths to strings and write them to files
+  llvm::ICInputFile input1 = MDT.getICInputFile();
+  llvm::ICInputFile input2 = MDT.getICInputFile2();
+
+  input1.setPaths(pathBeforeCodegen);
+  input2.setPaths(pathAfterCodegen);
+
+  input1.write();
+  input2.write();
+}
+
+void removeControlFiles(llvm::ModuleDecisionTrees &MDT) {
+  MDT.getICResultsFile().remove();
+  MDT.getICResultsFile2().remove();
+}
+
+int loadResultFiles(llvm::ModuleDecisionTrees &MDT,
+std::vector &merged) {
+  llvm::ICResultsFile results1 = MDT.getICResultsFile();
+  llvm::ICResultsFile results2 = MDT.getICResultsFile2();
+
+  int r1 = results1.read();
+  int r2 = results2.read();
+
+  if(r1 || r2)
+return 1;
+
+  llvm::MdtResults::mergeMdtResults(merged,
+  results1.getResults(), results2.getResults());
+
+  return 0;
+}
+
+llvm::MdtResults* getModuleResults(std::vector &merged,
+   std::string name)
+{
+  llvm::MdtResults *moduleResults = NULL;
+
+  for(auto res : merged) {
+if (res.FunctionNameAndPhase.getName() == name)
+  moduleResults = new llvm::MdtResults(res);
+  }
+
+  return moduleResults;
+}
+
 int main(int argc_, const char **argv_) {
   llvm::sys::PrintStackTraceOnErrorSignal();
   llvm::PrettyStackTraceProgram X(argc_, argv_);
@@ -437,6 +516,34 @@
 Diags.takeClient(), std::move(SerializedConsumer)));
   }
 
+  // Get number of iterations for iterative compilation.
+  // declare files and number of iterations
+  int ICNumberOfIterations = 0;
+
+  // extract number of iterations from cli args
+  std::unique_ptr CCopts(createDriverOptTable());
+  unsigned MissingArgIndex, MissingArgCount;
+  ArrayRef argv_ref(argv);
+  InputArgList Args = CCopts->ParseArgs(argv_ref.slice(1),
+MissingArgIndex, MissingArgCount);
+  if (Args.getLastArg(options::OPT_fiterative_comp_EQ)) {
+std::string Val = Args.getLastArgValue(options::OPT_fiterative_comp_EQ, "1");
+std::stringstream Convert(Val);
+Convert >> ICNumberOfIterations;
+   }
+  if (!ICNumberOfIterations)
+ICNumberOfIterations = 1; // Default value is 1.
+
+  std::string moduleName = llvm::getModuleName(argc_, argv_);
+
+  llvm::ModuleDecisionTrees moduleDecisionTrees(ICNumberOfIterations, true, moduleName);
+  int CurrentIteration = 0;
+  int Res = 0;
+
+  llvm::FnNameAndPhase::ICPhase CurrICPhase = llvm::FnNameAndPhase::ModulePhase;
+
+  // start of iterative compilation loop
+  for (; CurrentIteration < ICNumberOfIterations; CurrentIteration++) {
   ProcessWarningOptions(Diags, *DiagOpts, /*ReportDiags=*/false);
 
   Driver TheDriver(Path, llvm::sys::getDefaultTargetTriple(), Diags);
@@ -447,12 +554,34 @@
 
   SetBackdoorDriverOutputsFromEnvVars(TheDriver);
 
+  if (ICNumberOfIterations > 1) {
+TheDriver.setModuleDecisionTrees(&moduleDecisionTrees);
+
+initControlFiles(moduleDecisionTrees, CurrentIteration);
+writeInputFiles(moduleDecisionTrees);
+
+moduleDecisionTrees.startNewIteration();
+  }
+
   std::unique_ptr C(TheDriver.BuildCompilation(argv));
   int Res = 0;
   SmallVector, 4> FailingCommands;
   if (C.get())
 Res = TheDriver.ExecuteCompilation(*C, FailingCommands);
 
+  if (ICNumberOfIteration

Re: [PATCH] D19406: [clang-tidy] fix link in Release Notes

2016-04-22 Thread Kirill Bobyrev via cfe-commits
omtcyf0 added a comment.

@hokein

Great, thanks!

I'd be very grateful if you could land it!


http://reviews.llvm.org/D19406



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


r267135 - [clang][AVX512][Builtin] adding intrinsics for vf{n}madd{ss|sd} and vf{n}sub{ss|sd} instruction set

2016-04-22 Thread Michael Zuckerman via cfe-commits
Author: mzuckerm
Date: Fri Apr 22 05:56:24 2016
New Revision: 267135

URL: http://llvm.org/viewvc/llvm-project?rev=267135&view=rev
Log:
[clang][AVX512][Builtin] adding intrinsics for vf{n}madd{ss|sd} and 
vf{n}sub{ss|sd} instruction set

Differential Revision: http://reviews.llvm.org/D19320


Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/Headers/avx512fintrin.h
cfe/trunk/test/CodeGen/avx512f-builtins.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=267135&r1=267134&r2=267135&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Fri Apr 22 05:56:24 2016
@@ -2145,6 +2145,12 @@ TARGET_BUILTIN(__builtin_ia32_getmantpd5
 TARGET_BUILTIN(__builtin_ia32_getmantps512_mask, 
"V16fV16fiV16fUsIi","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_getexppd512_mask, "V8dV8dV8dUcIi","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_getexpps512_mask, 
"V16fV16fV16fUsIi","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_vfmaddss3_mask,  "V4fV4fV4fV4fUcIi", "", 
"avx512f")
+TARGET_BUILTIN(__builtin_ia32_vfmaddss3_maskz, "V4fV4fV4fV4fUcIi", "", 
"avx512f")
+TARGET_BUILTIN(__builtin_ia32_vfmaddss3_mask3, "V4fV4fV4fV4fUcIi", "", 
"avx512f")
+TARGET_BUILTIN(__builtin_ia32_vfmaddsd3_mask,  "V2dV2dV2dV2dUcIi", "", 
"avx512f")
+TARGET_BUILTIN(__builtin_ia32_vfmaddsd3_maskz, "V2dV2dV2dV2dUcIi", "", 
"avx512f")
+TARGET_BUILTIN(__builtin_ia32_vfmaddsd3_mask3, "V2dV2dV2dV2dUcIi", "", 
"avx512f")
 
 #undef BUILTIN
 #undef TARGET_BUILTIN

Modified: cfe/trunk/lib/Headers/avx512fintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=267135&r1=267134&r2=267135&view=diff
==
--- cfe/trunk/lib/Headers/avx512fintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512fintrin.h Fri Apr 22 05:56:24 2016
@@ -6617,6 +6617,437 @@ __builtin_ia32_gathersiv8di ((__v8di) __
   __addr, (__v8si) __index, __mask , __scale);\
 })
 
+static __inline__ __m128 __DEFAULT_FN_ATTRS
+_mm_mask_fmadd_ss (__m128 __W, __mmask8 __U, __m128 __A, __m128 __B) 
+{
+ return (__m128) __builtin_ia32_vfmaddss3_mask ((__v4sf) __A,
+  (__v4sf) __B,
+  (__v4sf) __W,
+  (__mmask8) __U,
+  _MM_FROUND_CUR_DIRECTION);
+}
+
+#define _mm_mask_fmadd_round_ss( __W, __U, __A, __B, __R) __extension__({\
+__builtin_ia32_vfmaddss3_mask ((__v4sf) __A,\
+  (__v4sf) __B,\
+  (__v4sf) __W,\
+  (__mmask8) __U,\
+  __R);\
+})
+
+static __inline__ __m128 __DEFAULT_FN_ATTRS
+_mm_maskz_fmadd_ss (__mmask8 __U, __m128 __A, __m128 __B, __m128 __C) 
+{
+ return (__m128) __builtin_ia32_vfmaddss3_maskz ((__v4sf) __A,
+  (__v4sf) __B,
+  (__v4sf) __C,
+  (__mmask8) __U,
+  _MM_FROUND_CUR_DIRECTION);
+}
+
+#define _mm_maskz_fmadd_round_ss( __U, __A, __B, __C, __R) __extension__ ({\
+__builtin_ia32_vfmaddss3_maskz ((__v4sf) __A,\
+  (__v4sf) __B,\
+  (__v4sf) __C,\
+  (__mmask8) __U,\
+  _MM_FROUND_CUR_DIRECTION);\
+})
+
+static __inline__ __m128 __DEFAULT_FN_ATTRS
+_mm_mask3_fmadd_ss (__m128 __W, __m128 __X, __m128 __Y, __mmask8 __U) 
+{
+ return (__m128) __builtin_ia32_vfmaddss3_mask3 ((__v4sf) __W,
+  (__v4sf) __X,
+  (__v4sf) __Y,
+  (__mmask8) __U,
+  _MM_FROUND_CUR_DIRECTION);
+}
+
+#define _mm_mask3_fmadd_round_ss( __W, __X, __Y, __U, __R) __extension__ ({\
+__builtin_ia32_vfmaddss3_mask3 ((__v4sf) __W,\
+  (__v4sf) __X,\
+  (__v4sf) __Y,\
+  (__mmask8) __U,\
+  __R);\
+})
+
+static __inline__ __m128 __DEFAULT_FN_ATTRS
+_mm_mask_fmsub_ss (__m128 __W, __mmask8 __U, __m128 __A, __m128 __B) 
+{
+ return (__m128) __builtin_ia32_vfmaddss3_mask ((__v4sf) __A,
+  (__v4sf) -(__B),
+  (__v4sf) __W,
+  (__mmask8) __U,
+  _MM_FROUND_CUR_DIRECTION);
+}
+
+#define _mm_mask_fmsub_round_ss( __W, __U, __A, __B, __R) __extension__ ({\
+__builtin_ia32_vfmaddss3_mask ((__v4sf) __A,\
+  (__v4sf) -(__B),\
+  (__v4sf) __W,\
+  (__mmask8) __U,\
+  __R);\
+})
+
+static __inline__ __m128 __DEFAULT_FN_ATTRS
+_mm_maskz_fmsub_ss (__mmask8 __U, __m128 __A, __m128 __B, __m128 __C) 
+{
+ return (__m128) __builtin_ia32_vfmaddss3_maskz ((__v4sf) __A,
+  (__v4sf) __B,
+  (__v4sf) -(__C),
+  (__mmask8) __U,
+  _MM_FROUND_CUR_DIRECTION);
+}
+
+#define _mm_maskz_fmsub_round_ss( __U, __A, __B, __C, __R) __extension__ ({\
+__builtin_ia32_vfmaddss3_maskz ((__v4sf) __A,\
+  (__v4sf) __B,\
+  (__v4sf) -(__C),\
+  (__mmask8) __U,\
+  __R);\
+})
+
+static __inline__ __m128 __DEFAULT_FN_ATTRS
+_mm_mask3_fmsub_ss (__m128 __W, __m128 __X,

Re: [PATCH] D18551: Added Fixer implementation and fix() interface in clang-format for removing redundant code.

2016-04-22 Thread Daniel Jasper via cfe-commits
djasper added inline comments.


Comment at: lib/Format/Format.cpp:1544
@@ -1508,2 +1543,3 @@
 deriveLocalStyle(AnnotatedLines);
-computeAffectedLines(AnnotatedLines.begin(), AnnotatedLines.end());
+AffectedRangeMgr.computeAffectedLines(AnnotatedLines.begin(),
+  AnnotatedLines.end());

Move this into the base class?


Comment at: lib/Format/Format.cpp:2097
@@ +2096,3 @@
+static tooling::Replacements
+setupEnvironmentAndProcess(T Callback, const FormatStyle &Style, StringRef 
Code,
+   ArrayRef Ranges, StringRef FileName,

Instead, create a class Environment that does all of these and makes SourceMgr, 
ID and CharRanges available via getters (maybe more). Then you should be able 
to just instantiate an environment and call the other reformat/cleanup function 
with the corresponding arguments.


http://reviews.llvm.org/D18551



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


Re: [PATCH] D19406: [clang-tidy] fix link in Release Notes

2016-04-22 Thread Haojian Wu via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!


http://reviews.llvm.org/D19406



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


r267129 - [Clang][AVX512][BUILTIN] Adding scalar intrinsics for rsqrt14 , rcp14, getexp and getmant instruction set

2016-04-22 Thread Michael Zuckerman via cfe-commits
Author: mzuckerm
Date: Fri Apr 22 05:06:10 2016
New Revision: 267129

URL: http://llvm.org/viewvc/llvm-project?rev=267129&view=rev
Log:
[Clang][AVX512][BUILTIN] Adding scalar intrinsics for rsqrt14 ,rcp14, getexp 
and getmant instruction set

Differential Revision: http://reviews.llvm.org/D19326


Modified:
cfe/trunk/lib/Headers/avx512fintrin.h
cfe/trunk/test/CodeGen/avx512f-builtins.c

Modified: cfe/trunk/lib/Headers/avx512fintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=267129&r1=267128&r2=267129&view=diff
==
--- cfe/trunk/lib/Headers/avx512fintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512fintrin.h Fri Apr 22 05:06:10 2016
@@ -1021,6 +1021,24 @@ _mm_rsqrt14_ss(__m128 __A, __m128 __B)
  (__mmask8) -1);
 }
 
+static __inline__ __m128 __DEFAULT_FN_ATTRS
+_mm_mask_rsqrt14_ss (__m128 __W, __mmask8 __U, __m128 __A, __m128 __B) 
+{
+ return (__m128) __builtin_ia32_rsqrt14ss_mask ((__v4sf) __A,
+  (__v4sf) __B,
+  (__v4sf) __W,
+  (__mmask8) __U);
+}
+
+static __inline__ __m128 __DEFAULT_FN_ATTRS
+_mm_maskz_rsqrt14_ss (__mmask8 __U, __m128 __A, __m128 __B) 
+{
+ return (__m128) __builtin_ia32_rsqrt14ss_mask ((__v4sf) __A,
+  (__v4sf) __B,
+  (__v4sf) _mm_setzero_ps (),
+  (__mmask8) __U);
+}
+
 static  __inline__ __m128d __DEFAULT_FN_ATTRS
 _mm_rsqrt14_sd(__m128d __A, __m128d __B)
 {
@@ -1031,6 +1049,24 @@ _mm_rsqrt14_sd(__m128d __A, __m128d __B)
   (__mmask8) -1);
 }
 
+static __inline__ __m128d __DEFAULT_FN_ATTRS
+_mm_mask_rsqrt14_sd (__m128d __W, __mmask8 __U, __m128d __A, __m128d __B) 
+{
+ return (__m128d) __builtin_ia32_rsqrt14sd_mask ( (__v2df) __A,
+  (__v2df) __B,
+  (__v2df) __W,
+  (__mmask8) __U);
+}
+
+static __inline__ __m128d __DEFAULT_FN_ATTRS
+_mm_maskz_rsqrt14_sd (__mmask8 __U, __m128d __A, __m128d __B) 
+{
+ return (__m128d) __builtin_ia32_rsqrt14sd_mask ( (__v2df) __A,
+  (__v2df) __B,
+  (__v2df) _mm_setzero_pd (),
+  (__mmask8) __U);
+}
+
 static  __inline__ __m512d __DEFAULT_FN_ATTRS
 _mm512_rcp14_pd(__m512d __A)
 {
@@ -1058,6 +1094,24 @@ _mm_rcp14_ss(__m128 __A, __m128 __B)
  (__mmask8) -1);
 }
 
+static __inline__ __m128 __DEFAULT_FN_ATTRS
+_mm_mask_rcp14_ss (__m128 __W, __mmask8 __U, __m128 __A, __m128 __B) 
+{
+ return (__m128) __builtin_ia32_rcp14ss_mask ((__v4sf) __A,
+  (__v4sf) __B,
+  (__v4sf) __W,
+  (__mmask8) __U);
+}
+
+static __inline__ __m128 __DEFAULT_FN_ATTRS
+_mm_maskz_rcp14_ss (__mmask8 __U, __m128 __A, __m128 __B) 
+{
+ return (__m128) __builtin_ia32_rcp14ss_mask ((__v4sf) __A,
+  (__v4sf) __B,
+  (__v4sf) _mm_setzero_ps (),
+  (__mmask8) __U);
+}
+
 static  __inline__ __m128d __DEFAULT_FN_ATTRS
 _mm_rcp14_sd(__m128d __A, __m128d __B)
 {
@@ -1068,6 +1122,24 @@ _mm_rcp14_sd(__m128d __A, __m128d __B)
 (__mmask8) -1);
 }
 
+static __inline__ __m128d __DEFAULT_FN_ATTRS
+_mm_mask_rcp14_sd (__m128d __W, __mmask8 __U, __m128d __A, __m128d __B) 
+{
+ return (__m128d) __builtin_ia32_rcp14sd_mask ( (__v2df) __A,
+  (__v2df) __B,
+  (__v2df) __W,
+  (__mmask8) __U);
+}
+
+static __inline__ __m128d __DEFAULT_FN_ATTRS
+_mm_maskz_rcp14_sd (__mmask8 __U, __m128d __A, __m128d __B) 
+{
+ return (__m128d) __builtin_ia32_rcp14sd_mask ( (__v2df) __A,
+  (__v2df) __B,
+  (__v2df) _mm_setzero_pd (),
+  (__mmask8) __U);
+}
+
 static __inline __m512 __DEFAULT_FN_ATTRS
 _mm512_floor_ps(__m512 __A)
 {
@@ -4008,6 +4080,42 @@ _mm_getexp_sd (__m128d __A, __m128d __B)
  (__v2df) __B, (__v2df) _mm_setzero_pd(), (__mmask8) -1, 
_MM_FROUND_CUR_DIRECTION);
 }
 
+static __inline__ __m128d __DEFAULT_FN_ATTRS
+_mm_mask_getexp_sd (__m128d __W, __mmask8 __U, __m128d __A, __m128d __B) 
+{
+ return (__m128d) __builtin_ia32_getexpsd128_round_mask ( (__v2df) __A,
+  (__v2df) __B,
+  (__v2df) __W,
+  (__mmask8) __U,
+  _MM_FROUND_CUR_DIRECTION);
+}
+
+#define _mm_mask_getexp_round_sd( __W, __U, __A, __B, __R) __extension__ ({\
+__builtin_ia32_getexpsd128_round_mask ((__v2df) __A,\
+  (__v2df) __B,\
+  (__v2df) __W,\
+  (__mmask8) __U,\
+  __R);\
+})
+
+static __inline__ __m128d __DEFAULT_FN_ATTRS
+_mm_maskz_getexp_sd (__mmask8 __U, __m128d __A, __m128d __B) 
+{
+ return (__m128d) __builtin_ia32_getexpsd128_round_mask ( (__v2df) __A,
+  (__v2df) __B,
+  (__v2df) _mm_setzero_pd (),
+  (__mmask8) __U,
+  _MM_FROUND_CUR_DIRECTION);
+}
+
+#define _mm_maskz_getexp_round_sd( __U, __A, __B, __R) __extension__ ({\
+__builtin_ia32_getexpsd128_round_mask ( (__v2df) __A,\
+  (__v2df) __B,\
+  (__v2df) _mm_setzero_pd (),\
+  (__mmask8) __U,\
+  __R);\
+})
+
 #define _mm_getexp_round_ss( __A, __B, __R) __extension__

[PATCH] D19406: [clang-tidy] Release Notes fix typo in check link

2016-04-22 Thread Kirill Bobyrev via cfe-commits
omtcyf0 created this revision.
omtcyf0 added reviewers: alexfh, LegalizeAdulthood, hokein.
omtcyf0 added a subscriber: cfe-commits.

This is intended to fix https://llvm.org/bugs/show_bug.cgi?id=27426

http://reviews.llvm.org/D19406

Files:
  docs/ReleaseNotes.rst

Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -109,7 +109,7 @@
   Detect multiple statement macros that are used in unbraced conditionals.
 
 - New `misc-pointer-and-integral-operation
-  
`_
 check
+  
`_
 check
 
   Warns about suspicious operations involving pointers and integral types.
 


Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -109,7 +109,7 @@
   Detect multiple statement macros that are used in unbraced conditionals.
 
 - New `misc-pointer-and-integral-operation
-  `_ check
+  `_ check
 
   Warns about suspicious operations involving pointers and integral types.
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18551: Added Fixer implementation and fix() interface in clang-format for removing redundant code.

2016-04-22 Thread Eric Liu via cfe-commits
PING.

On Thu, Apr 21, 2016 at 11:48 AM Eric Liu  wrote:

> ioeric updated this revision to Diff 54476.
> ioeric added a comment.
>
> - Added comments for endsWithInternal().
>
>
> http://reviews.llvm.org/D18551
>
> Files:
>   include/clang/Format/Format.h
>   lib/Format/AffectedRangeManager.cpp
>   lib/Format/AffectedRangeManager.h
>   lib/Format/CMakeLists.txt
>   lib/Format/Format.cpp
>   lib/Format/TokenAnnotator.h
>   unittests/Format/CMakeLists.txt
>   unittests/Format/CleanupTest.cpp
>   unittests/Format/FormatTest.cpp
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18551: Added Fixer implementation and fix() interface in clang-format for removing redundant code.

2016-04-22 Thread Eric Liu via cfe-commits
ioeric added a subscriber: ioeric.
ioeric added a comment.

PING.


http://reviews.llvm.org/D18551



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


Re: [PATCH] D18369: [OpenCL] Upstreaming khronos OpenCL header file.

2016-04-22 Thread Alexey Bader via cfe-commits
bader added inline comments.


Comment at: lib/Headers/opencl.h:2
@@ +1,3 @@
+//
+// SPIR Tools
+//

This comment should be updated.


http://reviews.llvm.org/D18369



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


r267125 - [OPENMP] Fix for PR27463: Privatizing struct fields with array type

2016-04-22 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Fri Apr 22 04:05:03 2016
New Revision: 267125

URL: http://llvm.org/viewvc/llvm-project?rev=267125&view=rev
Log:
[OPENMP] Fix for PR27463: Privatizing struct fields with array type
causes code generation failure.

The codegen part of firstprivate clause for member decls used type of
original variable without skipping reference type from
OMPCapturedExprDecl. Patch fixes this problem.

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

Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=267125&r1=267124&r2=267125&view=diff
==
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Fri Apr 22 04:05:03 2016
@@ -548,7 +548,7 @@ bool CodeGenFunction::EmitOMPFirstprivat
 OrigVD) != nullptr,
 (*IRef)->getType(), VK_LValue, (*IRef)->getExprLoc());
 Address OriginalAddr = EmitLValue(&DRE).getAddress();
-QualType Type = OrigVD->getType();
+QualType Type = VD->getType();
 if (Type->isArrayType()) {
   // Emit VarDecl with copy init for arrays.
   // Get the address of the original variable captured in current

Modified: cfe/trunk/test/OpenMP/parallel_firstprivate_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/parallel_firstprivate_codegen.cpp?rev=267125&r1=267124&r2=267125&view=diff
==
--- cfe/trunk/test/OpenMP/parallel_firstprivate_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/parallel_firstprivate_codegen.cpp Fri Apr 22 04:05:03 
2016
@@ -22,8 +22,9 @@ struct SS {
   int a;
   int b : 4;
   int &c;
+  int e[4];
   SS(int &d) : a(0), b(0), c(d) {
-#pragma omp parallel firstprivate(a, b, c)
+#pragma omp parallel firstprivate(a, b, c, e)
 #ifdef LAMBDA
 [&]() {
   ++this->a, --b, (this)->c /= 1;
@@ -39,7 +40,7 @@ struct SS {
   ++(this)->a, --b, this->c /= 1;
 }();
 #else
-++this->a, --b, c /= 1;
+++this->a, --b, c /= 1, e[2] = ;
 #endif
   }
 };
@@ -129,10 +130,10 @@ int main() {
 // LAMBDA: getelementptr inbounds [[SS_TY]], [[SS_TY]]* %{{.+}}, i32 0, 
i32 0
 // LAMBDA: getelementptr inbounds [[SS_TY]], [[SS_TY]]* %{{.+}}, i32 0, 
i32 1
 // LAMBDA: getelementptr inbounds [[SS_TY]], [[SS_TY]]* %{{.+}}, i32 0, 
i32 2
-// LAMBDA: call void (%{{.+}}*, i{{[0-9]+}}, void (i{{[0-9]+}}*, 
i{{[0-9]+}}*, ...)*, ...) @__kmpc_fork_call(%{{.+}}* @{{.+}}, i{{[0-9]+}} 4, 
void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)* bitcast (void (i{{[0-9]+}}*, 
i{{[0-9]+}}*, [[SS_TY]]*, i32*, i32*, i32*)* [[SS_MICROTASK:@.+]] to void
+// LAMBDA: call void (%{{.+}}*, i{{[0-9]+}}, void (i{{[0-9]+}}*, 
i{{[0-9]+}}*, ...)*, ...) @__kmpc_fork_call(%{{.+}}* @{{.+}}, i{{[0-9]+}} 5, 
void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)* bitcast (void (i{{[0-9]+}}*, 
i{{[0-9]+}}*, [[SS_TY]]*, i32*, i32*, i32*, [4 x i{{[0-9]+}}]*)* 
[[SS_MICROTASK:@.+]] to void
 // LAMBDA: ret
 
-// LAMBDA: define internal void [[SS_MICROTASK]](i{{[0-9]+}}* noalias 
[[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}}, [[SS_TY]]* %{{.+}}, i32* 
{{.+}}, i32* {{.+}}, i32* {{.+}})
+// LAMBDA: define internal void [[SS_MICROTASK]](i{{[0-9]+}}* noalias 
[[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}}, [[SS_TY]]* %{{.+}}, i32* 
{{.+}}, i32* {{.+}}, i32* {{.+}}, [4 x i{{[0-9]+}}]* {{.+}})
 // LAMBDA-NOT: getelementptr {{.*}}[[SS_TY]], [[SS_TY]]* %
 // LAMBDA: call{{.*}} void
 // LAMBDA: ret void
@@ -247,10 +248,10 @@ int main() {
 // BLOCKS: getelementptr inbounds [[SS_TY]], [[SS_TY]]* %{{.+}}, i32 0, i32 0
 // BLOCKS: getelementptr inbounds [[SS_TY]], [[SS_TY]]* %{{.+}}, i32 0, i32 1
 // BLOCKS: getelementptr inbounds [[SS_TY]], [[SS_TY]]* %{{.+}}, i32 0, i32 2
-// BLOCKS: call void (%{{.+}}*, i{{[0-9]+}}, void (i{{[0-9]+}}*, i{{[0-9]+}}*, 
...)*, ...) @__kmpc_fork_call(%{{.+}}* @{{.+}}, i{{[0-9]+}} 4, void 
(i{{[0-9]+}}*, i{{[0-9]+}}*, ...)* bitcast (void (i{{[0-9]+}}*, i{{[0-9]+}}*, 
[[SS_TY]]*, i32*, i32*, i32*)* [[SS_MICROTASK:@.+]] to void
+// BLOCKS: call void (%{{.+}}*, i{{[0-9]+}}, void (i{{[0-9]+}}*, i{{[0-9]+}}*, 
...)*, ...) @__kmpc_fork_call(%{{.+}}* @{{.+}}, i{{[0-9]+}} 5, void 
(i{{[0-9]+}}*, i{{[0-9]+}}*, ...)* bitcast (void (i{{[0-9]+}}*, i{{[0-9]+}}*, 
[[SS_TY]]*, i32*, i32*, i32*, [4 x i{{[0-9]+}}]*)* [[SS_MICROTASK:@.+]] to void
 // BLOCKS: ret
 
-// BLOCKS: define internal void [[SS_MICROTASK]](i{{[0-9]+}}* noalias 
[[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}}, [[SS_TY]]* %{{.+}}, i32* 
{{.+}}, i32* {{.+}}, i32* {{.+}})
+// BLOCKS: define internal void [[SS_MICROTASK]](i{{[0-9]+}}* noalias 
[[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}}, [[SS_TY]]* %{{.+}}, i32* 
{{.+}}, i32* {{.+}}, i32* {{.+}}, [4 x i{{[0-9]+}}]* {{.+}})
 // BLOCKS-NOT: getelementpt

Re: [PATCH] D18369: [OpenCL] Upstreaming khronos OpenCL header file.

2016-04-22 Thread Alexey Bader via cfe-commits
bader added a comment.

BTW, there is a comment on GitHub that opencl.h might be a bad name for that 
header, since Khronos group provides the header with the same name, but it 
defines host API. So if some developer is using clang to compile OpenCL 
application it might accidentally include opencl.h provided with Clang instead 
of opencl.h with OpenCL host API.


http://reviews.llvm.org/D18369



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


Re: [PATCH] D18369: [OpenCL] Upstreaming khronos OpenCL header file.

2016-04-22 Thread Alexey Bader via cfe-commits
bader added inline comments.


Comment at: lib/Headers/opencl.h:4870
@@ +4869,3 @@
+
+#ifdef cl_khr_fp64
+char __const_func __attribute__((overloadable)) convert_char(double);

Sam, could you confirm that this macro id implicitly defined for OpenCL 
versions 1.2+?


http://reviews.llvm.org/D18369



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


Re: [PATCH] D18035: [GCC] PR23529 Mangler part of attrbute abi_tag support

2016-04-22 Thread Dmitry Polukhin via cfe-commits
DmitryPolukhin added a comment.

Weekly friendly ping, PTAL!


http://reviews.llvm.org/D18035



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


[libcxx] r267119 - Add missing include of

2016-04-22 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Fri Apr 22 02:39:05 2016
New Revision: 267119

URL: http://llvm.org/viewvc/llvm-project?rev=267119&view=rev
Log:
Add missing include of 

Modified:

libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/eval.pass.cpp

libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/eval_param.pass.cpp

Modified: 
libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/eval.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/eval.pass.cpp?rev=267119&r1=267118&r2=267119&view=diff
==
--- 
libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/eval.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/eval.pass.cpp
 Fri Apr 22 02:39:05 2016
@@ -20,6 +20,7 @@
 #include 
 #include 
 #include 
+#include// for sort
 #include 
 
 template 

Modified: 
libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/eval_param.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/eval_param.pass.cpp?rev=267119&r1=267118&r2=267119&view=diff
==
--- 
libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/eval_param.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/eval_param.pass.cpp
 Fri Apr 22 02:39:05 2016
@@ -20,6 +20,7 @@
 #include 
 #include 
 #include 
+#include// for sort
 #include 
 
 template 


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


r267118 - [index] Add SymbolSubKinds for ObjC IB annotations.

2016-04-22 Thread Argyrios Kyrtzidis via cfe-commits
Author: akirtzidis
Date: Fri Apr 22 02:21:16 2016
New Revision: 267118

URL: http://llvm.org/viewvc/llvm-project?rev=267118&view=rev
Log:
[index] Add SymbolSubKinds for ObjC IB annotations.

Modified:
cfe/trunk/include/clang/Index/IndexSymbol.h
cfe/trunk/lib/Index/IndexSymbol.cpp
cfe/trunk/test/Index/Core/index-subkinds.m

Modified: cfe/trunk/include/clang/Index/IndexSymbol.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Index/IndexSymbol.h?rev=267118&r1=267117&r2=267118&view=diff
==
--- cfe/trunk/include/clang/Index/IndexSymbol.h (original)
+++ cfe/trunk/include/clang/Index/IndexSymbol.h Fri Apr 22 02:21:16 2016
@@ -64,8 +64,10 @@ enum class SymbolSubKind : uint8_t {
   TemplatePartialSpecialization = 1 << 1,
   TemplateSpecialization= 1 << 2,
   UnitTest  = 1 << 3,
+  IBAnnotated   = 1 << 4,
+  IBOutletCollection= 1 << 5,
 };
-static const unsigned SymbolSubKindBitNum = 4;
+static const unsigned SymbolSubKindBitNum = 6;
 typedef unsigned SymbolSubKindSet;
 
 /// Set of roles that are attributed to symbol occurrences.

Modified: cfe/trunk/lib/Index/IndexSymbol.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexSymbol.cpp?rev=267118&r1=267117&r2=267118&view=diff
==
--- cfe/trunk/lib/Index/IndexSymbol.cpp (original)
+++ cfe/trunk/lib/Index/IndexSymbol.cpp Fri Apr 22 02:21:16 2016
@@ -40,6 +40,15 @@ static bool isUnitTest(const ObjCMethodD
   return isUnitTestCase(D->getClassInterface());
 }
 
+static void checkForIBOutlets(const Decl *D, SymbolSubKindSet &SubKindSet) {
+  if (D->hasAttr()) {
+SubKindSet |= (unsigned)SymbolSubKind::IBAnnotated;
+  } else if (D->hasAttr()) {
+SubKindSet |= (unsigned)SymbolSubKind::IBAnnotated;
+SubKindSet |= (unsigned)SymbolSubKind::IBOutletCollection;
+  }
+}
+
 SymbolInfo index::getSymbolInfo(const Decl *D) {
   assert(D);
   SymbolInfo Info;
@@ -135,14 +144,18 @@ SymbolInfo index::getSymbolInfo(const De
   Info.Lang = SymbolLanguage::ObjC;
   if (isUnitTest(cast(D)))
 Info.SubKinds |= (unsigned)SymbolSubKind::UnitTest;
+  if (D->hasAttr())
+Info.SubKinds |= (unsigned)SymbolSubKind::IBAnnotated;
   break;
 case Decl::ObjCProperty:
   Info.Kind = SymbolKind::InstanceProperty;
   Info.Lang = SymbolLanguage::ObjC;
+  checkForIBOutlets(D, Info.SubKinds);
   break;
 case Decl::ObjCIvar:
   Info.Kind = SymbolKind::Field;
   Info.Lang = SymbolLanguage::ObjC;
+  checkForIBOutlets(D, Info.SubKinds);
   break;
 case Decl::Namespace:
   Info.Kind = SymbolKind::Namespace;
@@ -347,6 +360,8 @@ void index::applyForEachSymbolSubKind(Sy
   APPLY_FOR_SUBKIND(TemplatePartialSpecialization);
   APPLY_FOR_SUBKIND(TemplateSpecialization);
   APPLY_FOR_SUBKIND(UnitTest);
+  APPLY_FOR_SUBKIND(IBAnnotated);
+  APPLY_FOR_SUBKIND(IBOutletCollection);
 
 #undef APPLY_FOR_SUBKIND
 }
@@ -363,6 +378,8 @@ void index::printSymbolSubKinds(SymbolSu
 case SymbolSubKind::TemplatePartialSpecialization: OS << "TPS"; break;
 case SymbolSubKind::TemplateSpecialization: OS << "TS"; break;
 case SymbolSubKind::UnitTest: OS << "test"; break;
+case SymbolSubKind::IBAnnotated: OS << "IB"; break;
+case SymbolSubKind::IBOutletCollection: OS << "IBColl"; break;
 }
   });
 }

Modified: cfe/trunk/test/Index/Core/index-subkinds.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Core/index-subkinds.m?rev=267118&r1=267117&r2=267118&view=diff
==
--- cfe/trunk/test/Index/Core/index-subkinds.m (original)
+++ cfe/trunk/test/Index/Core/index-subkinds.m Fri Apr 22 02:21:16 2016
@@ -34,3 +34,15 @@
 // CHECK: [[@LINE+1]]:1 | instance-method(test)/ObjC | testInCat | 
c:objc(cs)MyTestCase(im)testInCat | -[MyTestCase(cat) testInCat] | 
Def,Dyn,RelChild | rel: 1
 - (void)testInCat {}
 @end
+
+
+@class NSButton;
+@interface IBCls
+// CHECK: [[@LINE+2]]:34 | instance-method/ObjC | prop | 
c:objc(cs)IBCls(im)prop | -[IBCls prop] | Decl,Dyn,RelChild | rel: 1
+// CHECK: [[@LINE+1]]:34 | instance-property(IB)/ObjC | prop | 
c:objc(cs)IBCls(py)prop |  | Decl,RelChild | rel: 1
+@property (readonly) IBOutlet id prop;
+// CHECK: [[@LINE+1]]:54 | instance-property(IB,IBColl)/ObjC | propColl | 
c:objc(cs)IBCls(py)propColl |  | Decl,RelChild | rel: 1
+@property (readonly) IBOutletCollection(NSButton) id propColl;
+// CHECK: [[@LINE+1]]:1 | instance-method(IB)/ObjC | doIt | 
c:objc(cs)IBCls(im)doIt | -[IBCls doIt] | Decl,Dyn,RelChild | rel: 1
+-(IBAction)doIt;
+@end


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


r267117 - [index] Add a SymbolSubKind for an ObjC unit test.

2016-04-22 Thread Argyrios Kyrtzidis via cfe-commits
Author: akirtzidis
Date: Fri Apr 22 02:21:10 2016
New Revision: 267117

URL: http://llvm.org/viewvc/llvm-project?rev=267117&view=rev
Log:
[index] Add a SymbolSubKind for an ObjC unit test.

Added:
cfe/trunk/test/Index/Core/index-subkinds.m
Modified:
cfe/trunk/include/clang/Index/IndexSymbol.h
cfe/trunk/lib/Index/IndexSymbol.cpp
cfe/trunk/tools/c-index-test/core_main.cpp

Modified: cfe/trunk/include/clang/Index/IndexSymbol.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Index/IndexSymbol.h?rev=267117&r1=267116&r2=267117&view=diff
==
--- cfe/trunk/include/clang/Index/IndexSymbol.h (original)
+++ cfe/trunk/include/clang/Index/IndexSymbol.h Fri Apr 22 02:21:10 2016
@@ -63,8 +63,9 @@ enum class SymbolSubKind : uint8_t {
   Generic   = 1 << 0,
   TemplatePartialSpecialization = 1 << 1,
   TemplateSpecialization= 1 << 2,
+  UnitTest  = 1 << 3,
 };
-static const unsigned SymbolSubKindBitNum = 3;
+static const unsigned SymbolSubKindBitNum = 4;
 typedef unsigned SymbolSubKindSet;
 
 /// Set of roles that are attributed to symbol occurrences.

Modified: cfe/trunk/lib/Index/IndexSymbol.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexSymbol.cpp?rev=267117&r1=267116&r2=267117&view=diff
==
--- cfe/trunk/lib/Index/IndexSymbol.cpp (original)
+++ cfe/trunk/lib/Index/IndexSymbol.cpp Fri Apr 22 02:21:10 2016
@@ -16,6 +16,30 @@
 using namespace clang;
 using namespace clang::index;
 
+/// \returns true if \c D is a subclass of 'XCTestCase'.
+static bool isUnitTestCase(const ObjCInterfaceDecl *D) {
+  if (!D)
+return false;
+  while (const ObjCInterfaceDecl *SuperD = D->getSuperClass()) {
+if (SuperD->getName() == "XCTestCase")
+  return true;
+D = SuperD;
+  }
+  return false;
+}
+
+/// \returns true if \c D is in a subclass of 'XCTestCase', returns void, has
+/// no parameters, and its name starts with 'test'.
+static bool isUnitTest(const ObjCMethodDecl *D) {
+  if (!D->parameters().empty())
+return false;
+  if (!D->getReturnType()->isVoidType())
+return false;
+  if (!D->getSelector().getNameForSlot(0).startswith("test"))
+return false;
+  return isUnitTestCase(D->getClassInterface());
+}
+
 SymbolInfo index::getSymbolInfo(const Decl *D) {
   assert(D);
   SymbolInfo Info;
@@ -84,10 +108,16 @@ SymbolInfo index::getSymbolInfo(const De
 case Decl::EnumConstant:
   Info.Kind = SymbolKind::EnumConstant; break;
 case Decl::ObjCInterface:
-case Decl::ObjCImplementation:
+case Decl::ObjCImplementation: {
   Info.Kind = SymbolKind::Class;
   Info.Lang = SymbolLanguage::ObjC;
+  const ObjCInterfaceDecl *ClsD = dyn_cast(D);
+  if (!ClsD)
+ClsD = cast(D)->getClassInterface();
+  if (isUnitTestCase(ClsD))
+Info.SubKinds |= (unsigned)SymbolSubKind::UnitTest;
   break;
+}
 case Decl::ObjCProtocol:
   Info.Kind = SymbolKind::Protocol;
   Info.Lang = SymbolLanguage::ObjC;
@@ -103,6 +133,8 @@ SymbolInfo index::getSymbolInfo(const De
   else
 Info.Kind = SymbolKind::ClassMethod;
   Info.Lang = SymbolLanguage::ObjC;
+  if (isUnitTest(cast(D)))
+Info.SubKinds |= (unsigned)SymbolSubKind::UnitTest;
   break;
 case Decl::ObjCProperty:
   Info.Kind = SymbolKind::InstanceProperty;
@@ -314,6 +346,7 @@ void index::applyForEachSymbolSubKind(Sy
   APPLY_FOR_SUBKIND(Generic);
   APPLY_FOR_SUBKIND(TemplatePartialSpecialization);
   APPLY_FOR_SUBKIND(TemplateSpecialization);
+  APPLY_FOR_SUBKIND(UnitTest);
 
 #undef APPLY_FOR_SUBKIND
 }
@@ -329,6 +362,7 @@ void index::printSymbolSubKinds(SymbolSu
 case SymbolSubKind::Generic: OS << "Gen"; break;
 case SymbolSubKind::TemplatePartialSpecialization: OS << "TPS"; break;
 case SymbolSubKind::TemplateSpecialization: OS << "TS"; break;
+case SymbolSubKind::UnitTest: OS << "test"; break;
 }
   });
 }

Added: cfe/trunk/test/Index/Core/index-subkinds.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Core/index-subkinds.m?rev=267117&view=auto
==
--- cfe/trunk/test/Index/Core/index-subkinds.m (added)
+++ cfe/trunk/test/Index/Core/index-subkinds.m Fri Apr 22 02:21:10 2016
@@ -0,0 +1,36 @@
+// RUN: c-index-test core -print-source-symbols -- %s -target 
x86_64-apple-macosx10.7 | FileCheck %s
+
+// CHECK: [[@LINE+1]]:12 | class/ObjC | XCTestCase | c:objc(cs)XCTestCase | 
_OBJC_CLASS_$_XCTestCase | Decl | rel: 0
+@interface XCTestCase
+@end
+
+// CHECK: [[@LINE+1]]:12 | class(test)/ObjC | MyTestCase | 
c:objc(cs)MyTestCase | _OBJC_CLASS_$_MyTestCase | Decl | rel: 0
+@interface MyTestCase : XCTestCase
+@end
+// CHECK: [[@LINE+1]]:17 | class(test)/ObjC | MyTestCase | 
c:objc(cs)MyTestCase |  | Def | rel: 0
+@implementa

r267116 - [index] Change SymbolCXXTemplateKind to a 'SymbolSubKinds' bitset.

2016-04-22 Thread Argyrios Kyrtzidis via cfe-commits
Author: akirtzidis
Date: Fri Apr 22 02:21:04 2016
New Revision: 267116

URL: http://llvm.org/viewvc/llvm-project?rev=267116&view=rev
Log:
[index] Change SymbolCXXTemplateKind to a 'SymbolSubKinds' bitset.

This provides a more general and flexible way to annotate special symbols.

Modified:
cfe/trunk/include/clang/Index/IndexSymbol.h
cfe/trunk/lib/Index/IndexSymbol.cpp
cfe/trunk/tools/c-index-test/core_main.cpp
cfe/trunk/tools/libclang/CXIndexDataConsumer.cpp

Modified: cfe/trunk/include/clang/Index/IndexSymbol.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Index/IndexSymbol.h?rev=267116&r1=267115&r2=267116&view=diff
==
--- cfe/trunk/include/clang/Index/IndexSymbol.h (original)
+++ cfe/trunk/include/clang/Index/IndexSymbol.h Fri Apr 22 02:21:04 2016
@@ -59,12 +59,13 @@ enum class SymbolLanguage {
   CXX,
 };
 
-enum class SymbolCXXTemplateKind {
-  NonTemplate,
-  Template,
-  TemplatePartialSpecialization,
-  TemplateSpecialization,
+enum class SymbolSubKind : uint8_t {
+  Generic   = 1 << 0,
+  TemplatePartialSpecialization = 1 << 1,
+  TemplateSpecialization= 1 << 2,
 };
+static const unsigned SymbolSubKindBitNum = 3;
+typedef unsigned SymbolSubKindSet;
 
 /// Set of roles that are attributed to symbol occurrences.
 enum class SymbolRole : uint16_t {
@@ -99,7 +100,7 @@ struct SymbolRelation {
 
 struct SymbolInfo {
   SymbolKind Kind;
-  SymbolCXXTemplateKind TemplateKind;
+  SymbolSubKindSet SubKinds;
   SymbolLanguage Lang;
 };
 
@@ -113,9 +114,12 @@ void printSymbolRoles(SymbolRoleSet Role
 bool printSymbolName(const Decl *D, const LangOptions &LO, raw_ostream &OS);
 
 StringRef getSymbolKindString(SymbolKind K);
-StringRef getTemplateKindStr(SymbolCXXTemplateKind TK);
 StringRef getSymbolLanguageString(SymbolLanguage K);
 
+void applyForEachSymbolSubKind(SymbolSubKindSet SubKinds,
+llvm::function_ref Fn);
+void printSymbolSubKinds(SymbolSubKindSet SubKinds, raw_ostream &OS);
+
 } // namespace index
 } // namespace clang
 

Modified: cfe/trunk/lib/Index/IndexSymbol.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexSymbol.cpp?rev=267116&r1=267115&r2=267116&view=diff
==
--- cfe/trunk/lib/Index/IndexSymbol.cpp (original)
+++ cfe/trunk/lib/Index/IndexSymbol.cpp Fri Apr 22 02:21:04 2016
@@ -20,7 +20,7 @@ SymbolInfo index::getSymbolInfo(const De
   assert(D);
   SymbolInfo Info;
   Info.Kind = SymbolKind::Unknown;
-  Info.TemplateKind = SymbolCXXTemplateKind::NonTemplate;
+  Info.SubKinds = SymbolSubKindSet();
   Info.Lang = SymbolLanguage::C;
 
   if (const TagDecl *TD = dyn_cast(D)) {
@@ -46,9 +46,11 @@ SymbolInfo index::getSymbolInfo(const De
 Info.Lang = SymbolLanguage::CXX;
 
 if (isa(D)) {
-  Info.TemplateKind = SymbolCXXTemplateKind::TemplatePartialSpecialization;
+  Info.SubKinds |= (unsigned)SymbolSubKind::Generic;
+  Info.SubKinds |= (unsigned)SymbolSubKind::TemplatePartialSpecialization;
 } else if (isa(D)) {
-  Info.TemplateKind = SymbolCXXTemplateKind::TemplateSpecialization;
+  Info.SubKinds |= (unsigned)SymbolSubKind::Generic;
+  Info.SubKinds |= (unsigned)SymbolSubKind::TemplateSpecialization;
 }
 
   } else {
@@ -141,12 +143,12 @@ SymbolInfo index::getSymbolInfo(const De
 }
 case Decl::ClassTemplate:
   Info.Kind = SymbolKind::Class;
-  Info.TemplateKind = SymbolCXXTemplateKind::Template;
+  Info.SubKinds |= (unsigned)SymbolSubKind::Generic;
   Info.Lang = SymbolLanguage::CXX;
   break;
 case Decl::FunctionTemplate:
   Info.Kind = SymbolKind::Function;
-  Info.TemplateKind = SymbolCXXTemplateKind::Template;
+  Info.SubKinds |= (unsigned)SymbolSubKind::Generic;
   Info.Lang = SymbolLanguage::CXX;
   if (const CXXMethodDecl *MD = dyn_cast_or_null(
cast(D)->getTemplatedDecl())) 
{
@@ -167,7 +169,7 @@ SymbolInfo index::getSymbolInfo(const De
 case Decl::TypeAliasTemplate:
   Info.Kind = SymbolKind::TypeAlias;
   Info.Lang = SymbolLanguage::CXX;
-  Info.TemplateKind = SymbolCXXTemplateKind::Template;
+  Info.SubKinds |= (unsigned)SymbolSubKind::Generic;
   break;
 case Decl::TypeAlias:
   Info.Kind = SymbolKind::TypeAlias;
@@ -183,11 +185,13 @@ SymbolInfo index::getSymbolInfo(const De
 
   if (const FunctionDecl *FD = dyn_cast(D)) {
 if (FD->getTemplatedKind() ==
-  FunctionDecl::TK_FunctionTemplateSpecialization)
-  Info.TemplateKind = SymbolCXXTemplateKind::TemplateSpecialization;
+  FunctionDecl::TK_FunctionTemplateSpecialization) {
+  Info.SubKinds |= (unsigned)SymbolSubKind::Generic;
+  Info.SubKinds |= (unsigned)SymbolSubKind::TemplateSpecialization;
+}
   }
 
-  if (Info.TemplateKind != SymbolCXXTemplateKind::NonTemplate)
+  if (Info.SubK