r282227 - [X86] Split up the single switch statement in Sema::CheckX86BuiltinFunctionCall into different switches or ifs for each type of check.

2016-09-22 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Thu Sep 22 23:48:27 2016
New Revision: 282227

URL: http://llvm.org/viewvc/llvm-project?rev=282227=rev
Log:
[X86] Split up the single switch statement in Sema::CheckX86BuiltinFunctionCall 
into different switches or ifs for each type of check.

This in preparation for a new check that will check some of the builtins that 
already had the immediate range check.

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

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=282227=282226=282227=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Thu Sep 22 23:48:27 2016
@@ -1590,15 +1590,9 @@ static bool SemaBuiltinCpuSupports(Sema
   return false;
 }
 
-bool Sema::CheckX86BuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) {
-  int i = 0, l = 0, u = 0;
+static bool isX86_64Builtin(unsigned BuiltinID) {
+  // These builtins only work on x86-64 targets.
   switch (BuiltinID) {
-  default:
-return false;
-  case X86::BI__builtin_cpu_supports:
-return SemaBuiltinCpuSupports(*this, TheCall);
-  case X86::BI__builtin_ms_va_start:
-return SemaBuiltinMSVAStart(TheCall);
   case X86::BI__builtin_ia32_addcarryx_u64:
   case X86::BI__builtin_ia32_addcarry_u64:
   case X86::BI__builtin_ia32_subborrow_u64:
@@ -1641,14 +1635,32 @@ bool Sema::CheckX86BuiltinFunctionCall(u
   case X86::BI__builtin_ia32_cvtsi2ss64:
   case X86::BI__builtin_ia32_cvtusi2sd64:
   case X86::BI__builtin_ia32_cvtusi2ss64:
-  case X86::BI__builtin_ia32_rdseed64_step: {
-// These builtins only work on x86-64 targets.
-const llvm::Triple  = Context.getTargetInfo().getTriple();
-if (TT.getArch() != llvm::Triple::x86_64)
-  return Diag(TheCall->getCallee()->getLocStart(),
-  diag::err_x86_builtin_32_bit_tgt);
-return false;
+  case X86::BI__builtin_ia32_rdseed64_step:
+return true;
   }
+
+  return false;
+}
+
+bool Sema::CheckX86BuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) {
+  if (BuiltinID == X86::BI__builtin_cpu_supports)
+return SemaBuiltinCpuSupports(*this, TheCall);
+
+  if (BuiltinID == X86::BI__builtin_ms_va_start)
+return SemaBuiltinMSVAStart(TheCall);
+
+  // Check for 64-bit only builtins on a 32-bit target.
+  const llvm::Triple  = Context.getTargetInfo().getTriple();
+  if (TT.getArch() != llvm::Triple::x86_64 && isX86_64Builtin(BuiltinID))
+return Diag(TheCall->getCallee()->getLocStart(),
+diag::err_x86_builtin_32_bit_tgt);
+
+  // For intrinsics which take an immediate value as part of the instruction,
+  // range check them here.
+  int i = 0, l = 0, u = 0;
+  switch (BuiltinID) {
+  default:
+return false;
   case X86::BI__builtin_ia32_extractf64x4_mask:
   case X86::BI__builtin_ia32_extracti64x4_mask:
   case X86::BI__builtin_ia32_extractf32x8_mask:


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


r282228 - [AVX-512] Add initial support for checking rounding mode arguments of builtins.

2016-09-22 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Thu Sep 22 23:48:31 2016
New Revision: 282228

URL: http://llvm.org/viewvc/llvm-project?rev=282228=rev
Log:
[AVX-512] Add initial support for checking rounding mode arguments of builtins.

The backend can't encode all possible values of the argument and will fail 
isel. Checking in the frontend presents a friendlier experience to the user.

I started with builtins that can only take _MM_CUR_DIRECTION or _MM_NO_EXC. 
More builtins coming in the future.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/Sema/builtins-x86.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=282228=282227=282228=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Sep 22 23:48:31 
2016
@@ -7722,6 +7722,8 @@ def err_ppc_builtin_only_on_pwr7 : Error
   "this builtin is only valid on POWER7 or later CPUs">;
 def err_x86_builtin_32_bit_tgt : Error<
   "this builtin is only available on x86-64 targets">;
+def err_x86_builtin_invalid_rounding : Error<
+  "invalid rounding argument">;
 
 def err_builtin_longjmp_unsupported : Error<
   "__builtin_longjmp is not supported for the current target">;

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=282228=282227=282228=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Sep 22 23:48:31 2016
@@ -9482,6 +9482,7 @@ private:
   bool CheckAArch64BuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
   bool CheckMipsBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
   bool CheckSystemZBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
+  bool CheckX86BuiltinRoundingOrSAE(unsigned BuiltinID, CallExpr *TheCall);
   bool CheckX86BuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
   bool CheckPPCBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
 

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=282228=282227=282228=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Thu Sep 22 23:48:31 2016
@@ -1642,6 +1642,102 @@ static bool isX86_64Builtin(unsigned Bui
   return false;
 }
 
+// Check if the rounding mode is legal.
+bool Sema::CheckX86BuiltinRoundingOrSAE(unsigned BuiltinID, CallExpr *TheCall) 
{
+  // Indicates if this instruction has rounding control or just SAE.
+  bool HasRC = false;
+
+  unsigned ArgNum = 0;
+  switch (BuiltinID) {
+  default:
+return false;
+  case X86::BI__builtin_ia32_vcvttsd2si32:
+  case X86::BI__builtin_ia32_vcvttsd2si64:
+  case X86::BI__builtin_ia32_vcvttsd2usi32:
+  case X86::BI__builtin_ia32_vcvttsd2usi64:
+  case X86::BI__builtin_ia32_vcvttss2si32:
+  case X86::BI__builtin_ia32_vcvttss2si64:
+  case X86::BI__builtin_ia32_vcvttss2usi32:
+  case X86::BI__builtin_ia32_vcvttss2usi64:
+ArgNum = 1;
+break;
+  case X86::BI__builtin_ia32_cvtps2pd512_mask:
+  case X86::BI__builtin_ia32_cvttpd2dq512_mask:
+  case X86::BI__builtin_ia32_cvttpd2qq512_mask:
+  case X86::BI__builtin_ia32_cvttpd2udq512_mask:
+  case X86::BI__builtin_ia32_cvttpd2uqq512_mask:
+  case X86::BI__builtin_ia32_cvttps2dq512_mask:
+  case X86::BI__builtin_ia32_cvttps2qq512_mask:
+  case X86::BI__builtin_ia32_cvttps2udq512_mask:
+  case X86::BI__builtin_ia32_cvttps2uqq512_mask:
+  case X86::BI__builtin_ia32_exp2pd_mask:
+  case X86::BI__builtin_ia32_exp2ps_mask:
+  case X86::BI__builtin_ia32_getexppd512_mask:
+  case X86::BI__builtin_ia32_getexpps512_mask:
+  case X86::BI__builtin_ia32_rcp28pd_mask:
+  case X86::BI__builtin_ia32_rcp28ps_mask:
+  case X86::BI__builtin_ia32_rsqrt28pd_mask:
+  case X86::BI__builtin_ia32_rsqrt28ps_mask:
+  case X86::BI__builtin_ia32_vcomisd:
+  case X86::BI__builtin_ia32_vcomiss:
+  case X86::BI__builtin_ia32_vcvtph2ps512_mask:
+ArgNum = 3;
+break;
+  case X86::BI__builtin_ia32_cmppd512_mask:
+  case X86::BI__builtin_ia32_cmpps512_mask:
+  case X86::BI__builtin_ia32_cmpsd_mask:
+  case X86::BI__builtin_ia32_cmpss_mask:
+  case X86::BI__builtin_ia32_getexpsd128_round_mask:
+  case X86::BI__builtin_ia32_getexpss128_round_mask:
+  case X86::BI__builtin_ia32_rcp28sd_round_mask:
+  case X86::BI__builtin_ia32_rcp28ss_round_mask:
+  case X86::BI__builtin_ia32_reducepd512_mask:
+  case X86::BI__builtin_ia32_reduceps512_mask:
+  case X86::BI__builtin_ia32_rndscalepd_mask:
+  case X86::BI__builtin_ia32_rndscaleps_mask:

Re: [PATCH] D24513: [AMDGPU] Expose flat work group size, register and wave control attributes

2016-09-22 Thread Tom Stellard via cfe-commits
tstellarAMD accepted this revision.
tstellarAMD added a comment.

LGTM.


https://reviews.llvm.org/D24513



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


Re: [PATCH] D21022: [ARM] Fix linker emulation for arm 32 big endian

2016-09-22 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added a subscriber: Eugene.Zelenko.
Eugene.Zelenko closed this revision.
Eugene.Zelenko added a comment.

Committed in r272402.


https://reviews.llvm.org/D21022



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


Re: [PATCH] D21343: Implement `lcm` and `gcd` from library fundamentals V2

2016-09-22 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added a subscriber: Eugene.Zelenko.
Eugene.Zelenko closed this revision.
Eugene.Zelenko added a comment.

Committed in r276750.


https://reviews.llvm.org/D21343



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


Re: [PATCH] D21677: Add ignoringImplicit matcher

2016-09-22 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added a subscriber: Eugene.Zelenko.
Eugene.Zelenko closed this revision.
Eugene.Zelenko added a comment.

Committed in r273659. Please specify Differential revision in commit message.


Repository:
  rL LLVM

https://reviews.llvm.org/D21677



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


Re: [PATCH] D24826: [LTO] Add -flto-jobs=N to control backend parallelism

2016-09-22 Thread Duncan P. N. Exon Smith via cfe-commits

> On 2016-Sep-22, at 09:53, Teresa Johnson  wrote:
> 
> tejohnson added a comment.
> 
> In https://reviews.llvm.org/D24826#549788, @mehdi_amini wrote:
> 
>> The Gold path looks fine. 
>> On OSX, we would have the clang driver relying on a LLVM cl::opt, for which 
>> I don't think there is any precedent. CC Duncan for advice.
> 
> 
> I do see other uses of -mllvm in lib/Driver/Tools.cpp, but are you talking 
> about something else?

I think this is okay, since clang is talking to the same version of 
libLTO.dylib.  I feel like there might be another case where clang talks to 
libLTO.dylib through ld64 using -mllvm... perhaps, -O0?

Let's ask around though to be sure.

> 
>> Also I don't think the same option should be used for the parallel LTO 
>> codegen: it actually does not generate the same binary, which should deserve 
>> a dedicated opt-in (What if I mix ThinLTO and LTO, and I don't want // 
>> codegen?)
> 
> 
> Ok good point. I can change this to -fthinlto_jobs. However, while the two 
> parallel settings are separate in the LTO API, currently the gold-plugin jobs 
> option controls both, so I will need to do a preparatory gold-plugin patch to 
> split this into thinlto_jobs and lto_jobs. On the libLTO/ld64 path, looks 
> like the current -mllvm -threads only affects ThinLTO so there is no work to 
> do there.

I actually like -flto-jobs=N better for this.  I expect "jobs" not to affect 
output at all.

I think the current parallel FullLTO CodeGen (where it *does* affect output) 
should have a special name that calls this out, perhaps -flto-partitions=N?  
-flto-slices=N?  -flto-random-partitions=N?  Is it urgent to add that flag now 
though?

Note that I imagine someone will parallelizing FullLTO the hard way in the 
future, which won't affect output.  That implementation should use -flto-jobs=N.

> 
> https://reviews.llvm.org/D24826
> 
> 
> 

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


[PATCH] D24848: [clang-tidy] fix false-positive for cppcoreguidelines-pro-type-member-init with in-class initializers

2016-09-22 Thread Matthias Gehre via cfe-commits
mgehre created this revision.
mgehre added reviewers: alexfh, aaron.ballman.
mgehre added a subscriber: cfe-commits.
Herald added a subscriber: nemanjai.

This fixes https://llvm.org/bugs/show_bug.cgi?id=30487 where
```
warning: uninitialized record type: 's' [cppcoreguidelines-pro-type-member-init]
```
is emitted on
```
struct MyStruct
{
int a = 5;
int b = 7;
};

int main()
{
MyStruct s;
}
```

https://reviews.llvm.org/D24848

Files:
  clang-tidy/utils/TypeTraits.cpp
  test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp

Index: test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
===
--- test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
+++ test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
@@ -367,3 +367,14 @@
   PositiveIndirectMember() {}
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize 
these fields: A
 };
+
+
+struct Bug30487
+{
+  int a = 0;
+};
+
+void Bug30487_f()
+{
+  Bug30487 s;
+}
Index: clang-tidy/utils/TypeTraits.cpp
===
--- clang-tidy/utils/TypeTraits.cpp
+++ clang-tidy/utils/TypeTraits.cpp
@@ -62,8 +62,10 @@
   if (ClassDecl->hasTrivialDefaultConstructor())
 return true;
 
-  // If all its fields are trivially constructible.
+  // If all its fields are trivially constructible and have no default 
initializers.
   for (const FieldDecl *Field : ClassDecl->fields()) {
+if (Field->hasInClassInitializer())
+  return false;
 if (!isTriviallyDefaultConstructible(Field->getType(), Context))
   return false;
   }


Index: test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
===
--- test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
+++ test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
@@ -367,3 +367,14 @@
   PositiveIndirectMember() {}
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize these fields: A
 };
+
+
+struct Bug30487
+{
+  int a = 0;
+};
+
+void Bug30487_f()
+{
+  Bug30487 s;
+}
Index: clang-tidy/utils/TypeTraits.cpp
===
--- clang-tidy/utils/TypeTraits.cpp
+++ clang-tidy/utils/TypeTraits.cpp
@@ -62,8 +62,10 @@
   if (ClassDecl->hasTrivialDefaultConstructor())
 return true;
 
-  // If all its fields are trivially constructible.
+  // If all its fields are trivially constructible and have no default initializers.
   for (const FieldDecl *Field : ClassDecl->fields()) {
+if (Field->hasInClassInitializer())
+  return false;
 if (!isTriviallyDefaultConstructible(Field->getType(), Context))
   return false;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24845: [clang-tidy] fix for NOLINT after macro expansion

2016-09-22 Thread Matthias Gehre via cfe-commits
mgehre created this revision.
mgehre added reviewers: alexfh, aaron.ballman, hokein.
mgehre added a subscriber: cfe-commits.

When having
``` c++
#define MACRO code-with-warning
MACRO; // NOLINT
```
clang-tidy would still show the warning, because
it searched for "NOLINT" only in the first line,
not on the second.
This caused e.g. https://llvm.org/bugs/show_bug.cgi?id=29089
(where the macro was defined in a system header). See also
the added test cases.
Now clang-tidy looks at the line of macro invocation and every line
of macro definition for a NOLINT comment.

https://reviews.llvm.org/D24845

Files:
  clang-tidy/ClangTidyDiagnosticConsumer.cpp
  test/clang-tidy/nolint.cpp

Index: test/clang-tidy/nolint.cpp
===
--- test/clang-tidy/nolint.cpp
+++ test/clang-tidy/nolint.cpp
@@ -13,4 +13,18 @@
   int j; // NOLINT
 }
 
-// CHECK-MESSAGES: Suppressed 3 warnings (3 NOLINT)
+#define MACRO(X) class X { X(int i); };
+MACRO(D)
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: single-argument constructors must 
be marked explicit
+MACRO(E) // NOLINT
+
+#define MACRO_NOARG class F { F(int i); };
+MACRO_NOARG // NOLINT
+
+#define MACRO_NOLINT class G { G(int i); }; // NOLINT
+MACRO_NOLINT
+
+#define DOUBLE_MACRO MACRO(H) // NOLINT
+DOUBLE_MACRO
+
+// CHECK-MESSAGES: Suppressed 7 warnings (7 NOLINT)
Index: clang-tidy/ClangTidyDiagnosticConsumer.cpp
===
--- clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -294,12 +294,24 @@
   return false;
 }
 
+static bool LineIsMarkedWithNOLINTinMacro(SourceManager ,
+  SourceLocation Loc) {
+  while (true) {
+if (LineIsMarkedWithNOLINT(SM, Loc))
+  return true;
+if (!Loc.isMacroID())
+  break;
+Loc = SM.getImmediateExpansionRange(Loc).first;
+  }
+  return false;
+}
+
 void ClangTidyDiagnosticConsumer::HandleDiagnostic(
 DiagnosticsEngine::Level DiagLevel, const Diagnostic ) {
   if (Info.getLocation().isValid() &&
   DiagLevel != DiagnosticsEngine::Error &&
   DiagLevel != DiagnosticsEngine::Fatal &&
-  LineIsMarkedWithNOLINT(Diags->getSourceManager(), Info.getLocation())) {
+  LineIsMarkedWithNOLINTinMacro(Diags->getSourceManager(), 
Info.getLocation())) {
 ++Context.Stats.ErrorsIgnoredNOLINT;
 return;
   }


Index: test/clang-tidy/nolint.cpp
===
--- test/clang-tidy/nolint.cpp
+++ test/clang-tidy/nolint.cpp
@@ -13,4 +13,18 @@
   int j; // NOLINT
 }
 
-// CHECK-MESSAGES: Suppressed 3 warnings (3 NOLINT)
+#define MACRO(X) class X { X(int i); };
+MACRO(D)
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: single-argument constructors must be marked explicit
+MACRO(E) // NOLINT
+
+#define MACRO_NOARG class F { F(int i); };
+MACRO_NOARG // NOLINT
+
+#define MACRO_NOLINT class G { G(int i); }; // NOLINT
+MACRO_NOLINT
+
+#define DOUBLE_MACRO MACRO(H) // NOLINT
+DOUBLE_MACRO
+
+// CHECK-MESSAGES: Suppressed 7 warnings (7 NOLINT)
Index: clang-tidy/ClangTidyDiagnosticConsumer.cpp
===
--- clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -294,12 +294,24 @@
   return false;
 }
 
+static bool LineIsMarkedWithNOLINTinMacro(SourceManager ,
+  SourceLocation Loc) {
+  while (true) {
+if (LineIsMarkedWithNOLINT(SM, Loc))
+  return true;
+if (!Loc.isMacroID())
+  break;
+Loc = SM.getImmediateExpansionRange(Loc).first;
+  }
+  return false;
+}
+
 void ClangTidyDiagnosticConsumer::HandleDiagnostic(
 DiagnosticsEngine::Level DiagLevel, const Diagnostic ) {
   if (Info.getLocation().isValid() &&
   DiagLevel != DiagnosticsEngine::Error &&
   DiagLevel != DiagnosticsEngine::Fatal &&
-  LineIsMarkedWithNOLINT(Diags->getSourceManager(), Info.getLocation())) {
+  LineIsMarkedWithNOLINTinMacro(Diags->getSourceManager(), Info.getLocation())) {
 ++Context.Stats.ErrorsIgnoredNOLINT;
 return;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24841: [asan] Fix incorrect SEH symbol mangling on win64.

2016-09-22 Thread David Majnemer via cfe-commits
majnemer added a subscriber: majnemer.
majnemer accepted this revision.
majnemer added a reviewer: majnemer.
majnemer added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D24841



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


Re: [PATCH] D24693: [CodeGen] Don't emit lifetime intrinsics for some local variables

2016-09-22 Thread Akira Hatanaka via cfe-commits
ahatanak added a comment.

Thank you for the great example! I can now see this patch does fix mis-compiles.

There are probably other lifetime bugs you'll see when the code being compiled 
includes gotos that jump past variable declarations, including the one here: 
http://lists.llvm.org/pipermail/cfe-dev/2016-July/050066.html. Do you think you 
can extend the approach taken in this patch to prevent mis-compiles for those 
too?

Also, rather than removing the intrinsics altogether, have you considered 
making changes to IRGen to insert them to different locations or insert extra 
lifetime.starts? In your example, if I insert lifetime.start for "tmp" at the 
beginning of label "l1", it doesn't assert. I made the same changes for the 
example I sent to cfe-dev, but it didn't work because DSE removed the store to 
"i" (if I disable DSE, I see the expected result).


https://reviews.llvm.org/D24693



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


Re: [PATCH] D24792: [analyzer] Fix crash in RetainCountChecker::checkEndFunction

2016-09-22 Thread Artem Dergachev via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

Thanks again! LGTM.



Comment at: lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:656
@@ +655,3 @@
+  // Clear the AnalysisManager of old AnalysisDeclContexts.
+  Mgr->ClearContexts();
+  // Ignore autosynthesized code.

We could skip that as well, forgot to mention :o
Doesn't really matter.


Repository:
  rL LLVM

https://reviews.llvm.org/D24792



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


Re: [PATCH] D24754: [cleanup] Remove excessive padding from RedeclarableResult

2016-09-22 Thread Александр Шапошников via cfe-commits
>What's the purpose of this change
PaddingChecker generates a report on it,
yeah, you are right that it won't save too much (just a little), but
it was easy to fix. Another reason why i am doing this -
it reduces the number of reports produced by static analyzer (less noisy)
- and since it saves smth (and i don't see other regressions) - decided to
change it. (btw - the order FirstId, IsKeyDecl, MergeWith is another option
and also looks natural (if i am not mistaken)).

On Thu, Sep 22, 2016 at 1:04 PM, Richard Smith 
wrote:

> What's the purpose of this change? We only put these objects in the stack,
> and never have many of them at once. If we don't care about size, a natural
> field order seems preferable to one that minimises padding.
>
> On 22 Sep 2016 12:41 pm, "Alexander Shaposhnikov" 
> wrote:
>
>> alexshap added inline comments.
>>
>> 
>> Comment at: lib/Serialization/ASTReaderDecl.cpp:154
>> @@ -153,3 +153,3 @@
>>  public:
>> -  RedeclarableResult(GlobalDeclID FirstID, Decl *MergeWith, bool
>> IsKeyDecl)
>> -  : FirstID(FirstID), MergeWith(MergeWith), IsKeyDecl(IsKeyDecl)
>> {}
>> +  RedeclarableResult(Decl *MergeWith, GlobalDeclID FirstID, bool
>> IsKeyDecl)
>> +  : MergeWith(MergeWith), FirstID(FirstID), IsKeyDecl(IsKeyDecl)
>> {}
>> 
>> vsk wrote:
>> > alexshap wrote:
>> > > vsk wrote:
>> > > > Why do you need to change the order of the parameters in the
>> constructor?
>> > > To avoid inconsistency. Here the parameters match the fields and it
>> seemed to me that it would be better to update the order.
>> > OK. But why not do the same thing for ObjCCategoriesVisitor?
>> The thing is that while the order of initializers needs to match the
>> order of fields (and compilers catch it by generating a warning (and it's
>> awesome), the order of ctor arguments doesn't need to match the order of
>> fields (unless we are speaking about some readability concerns etc). The
>> tool clang-reorder-fields handles correctly aggregate types & brace
>> initializations (updates all the call sites) but doesn't change the order
>> of ctor arguments (for now (v0)) - sometimes (for example when some fields
>> use several arguments, or there is a non-trivial ctor body or there are
>> other complications) it's not always easy to reason which order of ctor
>> arguments is "natural" - and i try to preserve the old order (especially
>> remembering about the compatible types and some call sites like
>> emplace_back).
>> Having said that - yea, the case of ObjCCategoriesVisitor is simple and i
>> will update that diff as well (thanks for pointing out).
>>
>>
>> Repository:
>>   rL LLVM
>>
>> https://reviews.llvm.org/D24754
>>
>>
>>
>>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24792: [analyzer] Fix crash in RetainCountChecker::checkEndFunction

2016-09-22 Thread Alexander Shaposhnikov via cfe-commits
alexshap updated this revision to Diff 72206.
alexshap added a comment.

Move the check to AnalysisConsumer::HandleCode.


Repository:
  rL LLVM

https://reviews.llvm.org/D24792

Files:
  lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
  lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
  test/Analysis/NSString.m

Index: test/Analysis/NSString.m
===
--- test/Analysis/NSString.m
+++ test/Analysis/NSString.m
@@ -289,7 +289,11 @@
 _Bool OSAtomicCompareAndSwapPtr( void *__oldValue, void *__newValue, void * 
volatile *__theValue ) {
   return opaque_OSAtomicCompareAndSwapPtr(__oldValue, __newValue, __theValue);
 }
-
+// Test that the analyzer doesn't crash when the farm model is used. 
+// The analyzer ignores the autosynthesized code.
+_Bool OSAtomicCompareAndSwapEmptyFunction( void *__oldValue, void *__newValue, 
void * volatile *__theValue ) {
+  return 0;
+}
 extern BOOL opaque_objc_atomicCompareAndSwapPtr(id predicate, id replacement, 
volatile id *objectLocation);
 extern BOOL objc_atomicCompareAndSwapPtr(id predicate, id replacement, 
volatile id *objectLocation) {
   return opaque_objc_atomicCompareAndSwapPtr(predicate, replacement, 
objectLocation);
@@ -441,4 +445,4 @@
 - (void)callValue {
   [self _value];
 }
-@end
\ No newline at end of file
+@end
Index: lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
===
--- lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
+++ lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
@@ -652,15 +652,19 @@
   if (Mode == AM_None)
 return;
 
+  // Clear the AnalysisManager of old AnalysisDeclContexts.
+  Mgr->ClearContexts();
+  // Ignore autosynthesized code.
+  if (Mgr->getAnalysisDeclContext(D)->isBodyAutosynthesized())
+return;
+
   DisplayFunction(D, Mode, IMode);
   CFG *DeclCFG = Mgr->getCFG(D);
   if (DeclCFG) {
 unsigned CFGSize = DeclCFG->size();
 MaxCFGSize = MaxCFGSize < CFGSize ? CFGSize : MaxCFGSize;
   }
 
-  // Clear the AnalysisManager of old AnalysisDeclContexts.
-  Mgr->ClearContexts();
   BugReporter BR(*Mgr);
 
   if (Mode & AM_Syntax)
Index: lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
+++ lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
@@ -3863,7 +3863,7 @@
   // Don't process anything within synthesized bodies.
   const LocationContext *LCtx = Pred->getLocationContext();
   if (LCtx->getAnalysisDeclContext()->isBodyAutosynthesized()) {
-assert(LCtx->getParent());
+assert(!LCtx->inTopFrame()); 
 return;
   }
 


Index: test/Analysis/NSString.m
===
--- test/Analysis/NSString.m
+++ test/Analysis/NSString.m
@@ -289,7 +289,11 @@
 _Bool OSAtomicCompareAndSwapPtr( void *__oldValue, void *__newValue, void * volatile *__theValue ) {
   return opaque_OSAtomicCompareAndSwapPtr(__oldValue, __newValue, __theValue);
 }
-
+// Test that the analyzer doesn't crash when the farm model is used. 
+// The analyzer ignores the autosynthesized code.
+_Bool OSAtomicCompareAndSwapEmptyFunction( void *__oldValue, void *__newValue, void * volatile *__theValue ) {
+  return 0;
+}
 extern BOOL opaque_objc_atomicCompareAndSwapPtr(id predicate, id replacement, volatile id *objectLocation);
 extern BOOL objc_atomicCompareAndSwapPtr(id predicate, id replacement, volatile id *objectLocation) {
   return opaque_objc_atomicCompareAndSwapPtr(predicate, replacement, objectLocation);
@@ -441,4 +445,4 @@
 - (void)callValue {
   [self _value];
 }
-@end
\ No newline at end of file
+@end
Index: lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
===
--- lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
+++ lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
@@ -652,15 +652,19 @@
   if (Mode == AM_None)
 return;
 
+  // Clear the AnalysisManager of old AnalysisDeclContexts.
+  Mgr->ClearContexts();
+  // Ignore autosynthesized code.
+  if (Mgr->getAnalysisDeclContext(D)->isBodyAutosynthesized())
+return;
+
   DisplayFunction(D, Mode, IMode);
   CFG *DeclCFG = Mgr->getCFG(D);
   if (DeclCFG) {
 unsigned CFGSize = DeclCFG->size();
 MaxCFGSize = MaxCFGSize < CFGSize ? CFGSize : MaxCFGSize;
   }
 
-  // Clear the AnalysisManager of old AnalysisDeclContexts.
-  Mgr->ClearContexts();
   BugReporter BR(*Mgr);
 
   if (Mode & AM_Syntax)
Index: lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
+++ lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
@@ -3863,7 +3863,7 @@
   // Don't process anything within synthesized bodies.
   const LocationContext *LCtx = Pred->getLocationContext();
   if (LCtx->getAnalysisDeclContext()->isBodyAutosynthesized()) {
-

Re: [PATCH] D24754: [cleanup] Remove excessive padding from RedeclarableResult

2016-09-22 Thread Richard Smith via cfe-commits
What's the purpose of this change? We only put these objects in the stack,
and never have many of them at once. If we don't care about size, a natural
field order seems preferable to one that minimises padding.

On 22 Sep 2016 12:41 pm, "Alexander Shaposhnikov" 
wrote:

> alexshap added inline comments.
>
> 
> Comment at: lib/Serialization/ASTReaderDecl.cpp:154
> @@ -153,3 +153,3 @@
>  public:
> -  RedeclarableResult(GlobalDeclID FirstID, Decl *MergeWith, bool
> IsKeyDecl)
> -  : FirstID(FirstID), MergeWith(MergeWith), IsKeyDecl(IsKeyDecl)
> {}
> +  RedeclarableResult(Decl *MergeWith, GlobalDeclID FirstID, bool
> IsKeyDecl)
> +  : MergeWith(MergeWith), FirstID(FirstID), IsKeyDecl(IsKeyDecl)
> {}
> 
> vsk wrote:
> > alexshap wrote:
> > > vsk wrote:
> > > > Why do you need to change the order of the parameters in the
> constructor?
> > > To avoid inconsistency. Here the parameters match the fields and it
> seemed to me that it would be better to update the order.
> > OK. But why not do the same thing for ObjCCategoriesVisitor?
> The thing is that while the order of initializers needs to match the order
> of fields (and compilers catch it by generating a warning (and it's
> awesome), the order of ctor arguments doesn't need to match the order of
> fields (unless we are speaking about some readability concerns etc). The
> tool clang-reorder-fields handles correctly aggregate types & brace
> initializations (updates all the call sites) but doesn't change the order
> of ctor arguments (for now (v0)) - sometimes (for example when some fields
> use several arguments, or there is a non-trivial ctor body or there are
> other complications) it's not always easy to reason which order of ctor
> arguments is "natural" - and i try to preserve the old order (especially
> remembering about the compatible types and some call sites like
> emplace_back).
> Having said that - yea, the case of ObjCCategoriesVisitor is simple and i
> will update that diff as well (thanks for pointing out).
>
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D24754
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24841: [asan] Fix incorrect SEH symbol mangling on win64.

2016-09-22 Thread Etienne Bergeron via cfe-commits
etienneb created this revision.
etienneb added reviewers: rnk, kcc.
etienneb added subscribers: cfe-commits, chrisha.

The ASAN unittests are failing (check-asan-dynamic) due to an incorrect symbol 
name:
```
LINK : error LNK2001: unresolved external symbol ___asan_seh_interceptor
```

On win64, the linker is not adding an extra underscore. This was correctly 
fixed in the same file for other uses.

After that patch, most of the unittests are passing, but some related to SEH 
needs to be fixed.
```
Failing Tests (4):
AddressSanitizer-x86_64-windows-dynamic :: 
TestCases/Windows/dll_intercept_memchr.cc
AddressSanitizer-x86_64-windows-dynamic :: 
TestCases/Windows/dll_intercept_memcpy_indirect.cc
AddressSanitizer-x86_64-windows-dynamic :: TestCases/Windows/dll_seh.cc
AddressSanitizer-x86_64-windows-dynamic :: TestCases/Windows/seh.cc

  Expected Passes: 339
  Passes With Retry  : 3
  Expected Failures  : 16
  Unsupported Tests  : 152
  Unexpected Failures: 4
```

https://reviews.llvm.org/D24841

Files:
  lib/Driver/Tools.cpp

Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -10235,7 +10235,10 @@
 CmdArgs.push_back(TC.getCompilerRTArgString(Args, Lib));
   // Make sure the dynamic runtime thunk is not optimized out at link time
   // to ensure proper SEH handling.
-  
CmdArgs.push_back(Args.MakeArgString("-include:___asan_seh_interceptor"));
+  CmdArgs.push_back(Args.MakeArgString(
+  TC.getArch() == llvm::Triple::x86
+  ? "-include:___asan_seh_interceptor"
+  : "-include:__asan_seh_interceptor"));
 } else if (DLL) {
   CmdArgs.push_back(TC.getCompilerRTArgString(Args, "asan_dll_thunk"));
 } else {


Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -10235,7 +10235,10 @@
 CmdArgs.push_back(TC.getCompilerRTArgString(Args, Lib));
   // Make sure the dynamic runtime thunk is not optimized out at link time
   // to ensure proper SEH handling.
-  CmdArgs.push_back(Args.MakeArgString("-include:___asan_seh_interceptor"));
+  CmdArgs.push_back(Args.MakeArgString(
+  TC.getArch() == llvm::Triple::x86
+  ? "-include:___asan_seh_interceptor"
+  : "-include:__asan_seh_interceptor"));
 } else if (DLL) {
   CmdArgs.push_back(TC.getCompilerRTArgString(Args, "asan_dll_thunk"));
 } else {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24785: [AVX512] Fix return types on __builtin_ia32_gather3XivXdi builtins

2016-09-22 Thread Cameron McInally via cfe-commits
cameron.mcinally closed this revision.
cameron.mcinally added a comment.

This was fixed with r282082.

My cfe-commits email is being held for moderation (not a member of the list), 
so there was no automatic update.


Repository:
  rL LLVM

https://reviews.llvm.org/D24785



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


Re: OpenBSD/arm types

2016-09-22 Thread Mark Kettenis via cfe-commits
> From: Renato Golin 
> Date: Thu, 22 Sep 2016 20:37:19 +0100
> 
> On 22 September 2016 at 16:19, Mark Kettenis  wrote:
> > No I don't.
> 
> No problems. Committed in r282184.

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


Re: [PATCH] D24754: [cleanup] Remove excessive padding from RedeclarableResult

2016-09-22 Thread Alexander Shaposhnikov via cfe-commits
alexshap added inline comments.


Comment at: lib/Serialization/ASTReaderDecl.cpp:154
@@ -153,3 +153,3 @@
 public:
-  RedeclarableResult(GlobalDeclID FirstID, Decl *MergeWith, bool IsKeyDecl)
-  : FirstID(FirstID), MergeWith(MergeWith), IsKeyDecl(IsKeyDecl) {}
+  RedeclarableResult(Decl *MergeWith, GlobalDeclID FirstID, bool IsKeyDecl)
+  : MergeWith(MergeWith), FirstID(FirstID), IsKeyDecl(IsKeyDecl) {}

vsk wrote:
> alexshap wrote:
> > vsk wrote:
> > > Why do you need to change the order of the parameters in the constructor?
> > To avoid inconsistency. Here the parameters match the fields and it seemed 
> > to me that it would be better to update the order. 
> OK. But why not do the same thing for ObjCCategoriesVisitor?
The thing is that while the order of initializers needs to match the order of 
fields (and compilers catch it by generating a warning (and it's awesome), the 
order of ctor arguments doesn't need to match the order of fields (unless we 
are speaking about some readability concerns etc). The tool 
clang-reorder-fields handles correctly aggregate types & brace initializations 
(updates all the call sites) but doesn't change the order of ctor arguments 
(for now (v0)) - sometimes (for example when some fields use several arguments, 
or there is a non-trivial ctor body or there are other complications) it's not 
always easy to reason which order of ctor arguments is "natural" - and i try to 
preserve the old order (especially remembering about the compatible types and 
some call sites like emplace_back). 
Having said that - yea, the case of ObjCCategoriesVisitor is simple and i will 
update that diff as well (thanks for pointing out).


Repository:
  rL LLVM

https://reviews.llvm.org/D24754



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


r282184 - [OpenBSD] Add type sign information for OpenBSD

2016-09-22 Thread Renato Golin via cfe-commits
Author: rengolin
Date: Thu Sep 22 14:28:20 2016
New Revision: 282184

URL: http://llvm.org/viewvc/llvm-project?rev=282184=rev
Log:
[OpenBSD] Add type sign information for OpenBSD

Like NetBSD, OpenBSD prefers having a consistent set of typedefs
across the architectures it supports over strictly following the ARM
ABIs.  The diff below makes sure that clang's view of those types
matches OpenBSD's system header files.  It also adds a test that
checks the relevant types on all OpenBSD platforms that clang works
on.  Hopefully we can add mips64 and powerpc to that list in the
future.

Patch by Mark Kettenis 

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

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=282184=282183=282184=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Thu Sep 22 14:28:20 2016
@@ -4679,8 +4679,10 @@ class ARMTargetInfo : public TargetInfo
 DoubleAlign = LongLongAlign = LongDoubleAlign = SuitableAlign = 64;
 const llvm::Triple  = getTriple();
 
-// size_t is unsigned long on MachO-derived environments, NetBSD and 
Bitrig.
+// size_t is unsigned long on MachO-derived environments, NetBSD,
+// OpenBSD and Bitrig.
 if (T.isOSBinFormatMachO() || T.getOS() == llvm::Triple::NetBSD ||
+T.getOS() == llvm::Triple::OpenBSD ||
 T.getOS() == llvm::Triple::Bitrig)
   SizeType = UnsignedLong;
 else
@@ -4688,6 +4690,7 @@ class ARMTargetInfo : public TargetInfo
 
 switch (T.getOS()) {
 case llvm::Triple::NetBSD:
+case llvm::Triple::OpenBSD:
   WCharType = SignedInt;
   break;
 case llvm::Triple::Win32:
@@ -4885,6 +4888,7 @@ public:
 
 switch (getTriple().getOS()) {
 case llvm::Triple::NetBSD:
+case llvm::Triple::OpenBSD:
   PtrDiffType = SignedLong;
   break;
 default:

Modified: cfe/trunk/test/Preprocessor/init.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=282184=282183=282184=diff
==
--- cfe/trunk/test/Preprocessor/init.c (original)
+++ cfe/trunk/test/Preprocessor/init.c Thu Sep 22 14:28:20 2016
@@ -8463,6 +8463,29 @@
 // RUN: %clang_cc1 -triple lanai-unknown-unknown -E -dM < /dev/null | 
FileCheck -match-full-lines -check-prefix LANAI %s
 // LANAI: #define __lanai__ 1
 //
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=amd64-unknown-openbsd6.1 < 
/dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s
+// RUN: %clang_cc1 -E -dM -ffreestanding 
-triple=arm-unknown-openbsd6.1-gnueabi < /dev/null | FileCheck 
-match-full-lines -check-prefix OPENBSD %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=i386-unknown-openbsd6.1 < 
/dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=sparc64-unknown-openbsd6.1 < 
/dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s
+// OPENBSD:#define __ELF__ 1
+// OPENBSD:#define __INT16_TYPE__ short
+// OPENBSD:#define __INT32_TYPE__ int
+// OPENBSD:#define __INT64_TYPE__ long long int
+// OPENBSD:#define __INT8_TYPE__ signed char
+// OPENBSD:#define __INTMAX_TYPE__ long long int
+// OPENBSD:#define __INTPTR_TYPE__ long int
+// OPENBSD:#define __OpenBSD__ 1
+// OPENBSD:#define __PTRDIFF_TYPE__ long int
+// OPENBSD:#define __SIZE_TYPE__ long unsigned int
+// OPENBSD:#define __UINT16_TYPE__ unsigned short
+// OPENBSD:#define __UINT32_TYPE__ unsigned int
+// OPENBSD:#define __UINT64_TYPE__ long long unsigned int
+// OPENBSD:#define __UINT8_TYPE__ unsigned char
+// OPENBSD:#define __UINTMAX_TYPE__ long long unsigned int
+// OPENBSD:#define __UINTPTR_TYPE__ long unsigned int
+// OPENBSD:#define __WCHAR_TYPE__ int
+// OPENBSD:#define __WINT_TYPE__ int
+//
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-unknown-freebsd < 
/dev/null | FileCheck -match-full-lines -check-prefix PPC64-FREEBSD %s
 // PPC64-FREEBSD-NOT: #define __LONG_DOUBLE_128__ 1
 //


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


Re: OpenBSD/arm types

2016-09-22 Thread Renato Golin via cfe-commits
On 22 September 2016 at 16:19, Mark Kettenis  wrote:
> No I don't.

No problems. Committed in r282184.

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


Re: [PATCH] D24397: Target Power9 bit counting and vector comparison instructions through builtins (front end portion)

2016-09-22 Thread Kit Barton via cfe-commits
kbarton added a comment.

Aside from one minor comment, this LGTM.



Comment at: lib/Basic/Targets.cpp:1364
@@ -1358,3 +1363,3 @@
 // Handle explicit options being passed to the compiler here: if we've
 // explicitly turned off vsx and turned on power8-vector or direct-move then
 // go ahead and error since the customer has expressed a somewhat incompatible

Please  update this comment to also include float128 and power9-vector.



Repository:
  rL LLVM

https://reviews.llvm.org/D24397



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


Re: [PATCH] D20014: [libc++] Explicit return in non-void function

2016-09-22 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added a subscriber: Eugene.Zelenko.
Eugene.Zelenko closed this revision.
Eugene.Zelenko added a comment.

Committed in r269298.


https://reviews.llvm.org/D20014



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


Re: [PATCH] D24481: make “#pragma STDC FP_CONTRACT” on by default

2016-09-22 Thread Steve Canon via cfe-commits
scanon accepted this revision.
scanon added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D24481



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


Re: [PATCH] D24481: make “#pragma STDC FP_CONTRACT” on by default

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

LGTM. Thanks.


https://reviews.llvm.org/D24481



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


Re: [PATCH] D24792: [analyzer] Fix crash in RetainCountChecker::checkEndFunction

2016-09-22 Thread Artem Dergachev via cfe-commits
NoQ added a comment.

Thanks, this makes a lot more sense to me!



Comment at: lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:691
@@ -690,1 +690,3 @@
 
+  // Ignore autosynthesized code.
+  if (Mgr->getAnalysisDeclContext(D)->isBodyAutosynthesized())

I think this can be moved above, to `HandleCode()`. Because not only we need to 
skip path-sensitive analysis for synthesized bodies, but also we should 
probably skip the callback for AST checkers (`runCheckersOnASTBody()`, which 
corresponds to `check::ASTCodeBody`), and then we should also skip the 
`-analyzer-display-progress` debug output (the `DisplayFunction()` thingy).


Repository:
  rL LLVM

https://reviews.llvm.org/D24792



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


Re: [PATCH] D24826: [LTO] Add -flto-jobs=N to control backend parallelism

2016-09-22 Thread Teresa Johnson via cfe-commits
tejohnson added a comment.

In https://reviews.llvm.org/D24826#549788, @mehdi_amini wrote:

> The Gold path looks fine. 
>  On OSX, we would have the clang driver relying on a LLVM cl::opt, for which 
> I don't think there is any precedent. CC Duncan for advice.


I do see other uses of -mllvm in lib/Driver/Tools.cpp, but are you talking 
about something else?

> Also I don't think the same option should be used for the parallel LTO 
> codegen: it actually does not generate the same binary, which should deserve 
> a dedicated opt-in (What if I mix ThinLTO and LTO, and I don't want // 
> codegen?)


Ok good point. I can change this to -fthinlto_jobs. However, while the two 
parallel settings are separate in the LTO API, currently the gold-plugin jobs 
option controls both, so I will need to do a preparatory gold-plugin patch to 
split this into thinlto_jobs and lto_jobs. On the libLTO/ld64 path, looks like 
the current -mllvm -threads only affects ThinLTO so there is no work to do 
there.


https://reviews.llvm.org/D24826



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


Re: [PATCH] D24481: make “#pragma STDC FP_CONTRACT” on by default

2016-09-22 Thread Abe Skolnik via cfe-commits
Abe updated this revision to Diff 72186.
Abe added a comment.

Minor edits for style-guidelines conformance.


https://reviews.llvm.org/D24481

Files:
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/aarch64-neon-fma.c
  clang/test/CodeGen/aarch64-scalar-fma.c
  clang/test/CodeGen/fp-contract-pragma.cpp
  clang/test/CodeGen/fp-contract-pragma___on-by-default.c
  clang/test/Driver/clang_f_opts.c

Index: clang/test/Driver/clang_f_opts.c
===
--- clang/test/Driver/clang_f_opts.c
+++ clang/test/Driver/clang_f_opts.c
@@ -34,10 +34,13 @@
 // DEPRECATED-OFF-CHECK-NOT: -fdeprecated-macro
 
 // RUN: %clang -### -S -ffp-contract=fast %s 2>&1 | FileCheck -check-prefix=FP-CONTRACT-FAST-CHECK %s
-// RUN: %clang -### -S -ffast-math %s 2>&1 | FileCheck -check-prefix=FP-CONTRACT-FAST-CHECK %s
-// RUN: %clang -### -S -ffp-contract=off %s 2>&1 | FileCheck -check-prefix=FP-CONTRACT-OFF-CHECK %s
+// RUN: %clang -### -S -ffast-math%s 2>&1 | FileCheck -check-prefix=FP-CONTRACT-FAST-CHECK %s
+// RUN: %clang -### -S -ffp-contract=off  %s 2>&1 | FileCheck -check-prefix=FP-CONTRACT-OFF-CHECK  %s
+// RUN: %clang -### -S -ffp-contract=on   %s 2>&1 | FileCheck -check-prefix=FP-CONTRACT-ON-CHECK   %s
+
 // FP-CONTRACT-FAST-CHECK: -ffp-contract=fast
-// FP-CONTRACT-OFF-CHECK: -ffp-contract=off
+// FP-CONTRACT-OFF-CHECK:  -ffp-contract=off
+// FP-CONTRACT-ON-CHECK:   -ffp-contract=on
 
 // RUN: %clang -### -S -funroll-loops %s 2>&1 | FileCheck -check-prefix=CHECK-UNROLL-LOOPS %s
 // RUN: %clang -### -S -fno-unroll-loops %s 2>&1 | FileCheck -check-prefix=CHECK-NO-UNROLL-LOOPS %s
Index: clang/test/CodeGen/fp-contract-pragma___on-by-default.c
===
--- /dev/null
+++ clang/test/CodeGen/fp-contract-pragma___on-by-default.c
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -triple aarch64 -O0 -S -o - %s | FileCheck %s --check-prefix   ALL_BUILDS
+// RUN: %clang_cc1 -triple aarch64 -O1 -S -o - %s | FileCheck %s --check-prefixes ALL_BUILDS,NON_O0
+// RUN: %clang_cc1 -triple aarch64 -O2 -S -o - %s | FileCheck %s --check-prefixes ALL_BUILDS,NON_O0
+// RUN: %clang_cc1 -triple aarch64 -O3 -S -o - %s | FileCheck %s --check-prefixes ALL_BUILDS,NON_O0
+
+// REQUIRES: aarch64-registered-target
+
+// ALL_BUILDS-LABEL: fmadd_double:
+// ALL_BUILDS: fmadd d0, d{{[0-7]}}, d{{[0-7]}}, d{{[0-7]}}
+// NON_O0-NEXT: ret
+double fmadd_double(double a, double b, double c) {
+  return a*b+c;
+}
+
+// ALL_BUILDS: fmadd_single:
+// ALL_BUILDS: fmadd s0, s{{[0-7]}}, s{{[0-7]}}, s{{[0-7]}}
+// NON_O0-NEXT: ret
+float  fmadd_single(float  a, float  b, float  c) {
+  return a*b+c;
+}
+
Index: clang/test/CodeGen/fp-contract-pragma.cpp
===
--- clang/test/CodeGen/fp-contract-pragma.cpp
+++ clang/test/CodeGen/fp-contract-pragma.cpp
@@ -1,27 +1,25 @@
 // RUN: %clang_cc1 -O3 -triple %itanium_abi_triple -emit-llvm -o - %s | FileCheck %s
 
-// Is FP_CONTRACT honored in a simple case?
-float fp_contract_1(float a, float b, float c) {
-// CHECK: _Z13fp_contract_1fff
+// Is FP_CONTRACT on by default, at least at -O3?
+float fp_contract_8(float a, float b, float c) {
+// CHECK: _Z13fp_contract_8fff
 // CHECK: tail call float @llvm.fmuladd
-  #pragma STDC FP_CONTRACT ON
   return a * b + c;
 }
 
 // Is FP_CONTRACT state cleared on exiting compound statements?
 float fp_contract_2(float a, float b, float c) {
 // CHECK: _Z13fp_contract_2fff
 // CHECK: %[[M:.+]] = fmul float %a, %b
 // CHECK-NEXT: fadd float %[[M]], %c
+  #pragma STDC FP_CONTRACT OFF
   {
 #pragma STDC FP_CONTRACT ON
   }
   return a * b + c;  
 }
 
 // Does FP_CONTRACT survive template instantiation?
-class Foo {};
-Foo operator+(Foo, Foo);
 
 template 
 T template_muladd(T a, T b, T c) {
@@ -62,15 +60,23 @@
   return a * b + c;
 }
 
+// Does FP_CONTRACT inside a function override the same in the file scope?
+float fp_contract_1(float a, float b, float c) {
+// CHECK: _Z13fp_contract_1fff
+// CHECK: tail call float @llvm.fmuladd
+  #pragma STDC FP_CONTRACT ON
+  return a * b + c;
+}
+
+
 // If the multiply has multiple uses, don't produce fmuladd.
 // This used to assert (PR25719):
 // https://llvm.org/bugs/show_bug.cgi?id=25719
 
-float fp_contract_7(float a, float b, float c) {
+float fp_contract_7(float a, float b, float c, float& d_passed_by_ref) {
 // CHECK: _Z13fp_contract_7fff
 // CHECK:  %[[M:.+]] = fmul float %b, 2.00e+00
-// CHECK-NEXT: fsub float %[[M]], %c
   #pragma STDC FP_CONTRACT ON
-  return (a = 2 * b) - c;
+  return (d_passed_by_ref = 2 * b) - c;
 }
 
Index: clang/test/CodeGen/aarch64-scalar-fma.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-scalar-fma.c
@@ -0,0 +1,177 @@
+// RUN: %clang_cc1 -triple=aarch64-unknown -Os -ffp-contract=fast -S -o - %s | FileCheck -check-prefix=CHECK-FAST -check-prefix=CHECK-ALL %s
+// RUN: 

Re: [PATCH] D24826: [LTO] Add -flto-jobs=N to control backend parallelism

2016-09-22 Thread Mehdi AMINI via cfe-commits
mehdi_amini added a comment.

Also I don't think the same option should be used for the parallel LTO codegen: 
it actually does not generate the same binary, which should deserve a dedicated 
opt-in (What if I mix ThinLTO and LTO, and I don't want // codegen?)


https://reviews.llvm.org/D24826



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


Re: [PATCH] D24826: [LTO] Add -flto-jobs=N to control backend parallelism

2016-09-22 Thread Mehdi AMINI via cfe-commits
mehdi_amini added a comment.

The Gold path looks fine. 
On OSX, we would have the clang driver relying on a LLVM cl::opt, for which I 
don't think there is any precedent. CC Duncan for advice.


https://reviews.llvm.org/D24826



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


Re: [PATCH] D24339: [clang-tidy] Add check 'readability-redundant-member-init'

2016-09-22 Thread Malcolm Parsons via cfe-commits
malcolm.parsons updated this revision to Diff 72181.
malcolm.parsons added a comment.

Don't remove init of const members.
Do remove calls to constructors that introduce cleanups.


https://reviews.llvm.org/D24339

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tidy/readability/RedundantMemberInitCheck.cpp
  clang-tidy/readability/RedundantMemberInitCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-redundant-member-init.rst
  test/clang-tidy/readability-redundant-member-init.cpp

Index: test/clang-tidy/readability-redundant-member-init.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-redundant-member-init.cpp
@@ -0,0 +1,156 @@
+// RUN: %check_clang_tidy %s readability-redundant-member-init %t
+
+struct S {
+  S() = default;
+  S(int i) : i(i) {}
+  int i = 1;
+};
+
+struct T {
+  T(int i = 1) : i(i) {}
+  int i;
+};
+
+struct U {
+  int i;
+};
+
+// Initializer calls default constructor
+struct F1 {
+  F1() : f() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: initializer for member 'f' is redundant [readability-redundant-member-init]
+  // CHECK-FIXES:  F1()  {}
+  S f;
+};
+
+// Initializer calls default constructor with default argument
+struct F2 {
+  F2() : f() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: initializer for member 'f' is redundant [readability-redundant-member-init]
+  // CHECK-FIXES:  F2()  {}
+  T f;
+};
+
+// Multiple redundant initializers for same constructor
+struct F3 {
+  F3() : f(), g(1), h() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: initializer for member 'f' is redundant [readability-redundant-member-init]
+  // CHECK-MESSAGES: :[[@LINE-2]]:21: warning: initializer for member 'h' is redundant [readability-redundant-member-init]
+  // CHECK-FIXES:  F3() : g(1) {}
+  S f, g, h;
+};
+
+// Templated class independent type
+template 
+struct F4 {
+  F4() : f() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: initializer for member 'f' is redundant [readability-redundant-member-init]
+  // CHECK-FIXES:  F4()  {}
+  S f;
+};
+F4 f4i;
+F4 f4s;
+
+// Base class
+struct F5 : S {
+  F5() : S() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: initializer for base class 'S' is redundant [readability-redundant-member-init]
+  // CHECK-FIXES:  F5()  {}
+};
+
+// Constructor call requires cleanup
+struct Cleanup {
+  ~Cleanup() {}
+};
+
+struct UsesCleanup {
+  UsesCleanup(const Cleanup  = Cleanup()) {}
+};
+
+struct F6 {
+  F6() : uc() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: initializer for member 'uc' is redundant [readability-redundant-member-init]
+  // CHECK-FIXES:  F6()  {}
+  UsesCleanup uc;
+};
+
+// Initializer not written
+struct NF1 {
+  NF1() {}
+  S f;
+};
+
+// Initializer doesn't call default constructor
+struct NF2 {
+  NF2() : f(1) {}
+  S f;
+};
+
+// Initializer calls default constructor without using default argument
+struct NF3 {
+  NF3() : f(1) {}
+  T f;
+};
+
+// Initializer calls default constructor without using default argument
+struct NF4 {
+  NF4() : f(2) {}
+  T f;
+};
+
+// Initializer is zero-initialization
+struct NF5 {
+  NF5() : i() {}
+  int i;
+};
+
+// Initializer is direct-initialization
+struct NF6 {
+  NF6() : i(1) {}
+  int i;
+};
+
+// Initializer is aggregate initialization of struct
+struct NF7 {
+  NF7() : f{} {}
+  U f;
+};
+
+// Initializer is aggregate initialization of array
+struct NF8 {
+  NF8() : f{} {}
+  int f[2];
+};
+
+struct NF9 {
+  NF9() : f{} {}
+  S f[2];
+};
+
+// Initializing member of union
+union NF10 {
+  NF10() : s() {}
+  int i;
+  S s;
+};
+
+// Templated class dependent type
+template 
+struct NF11 {
+  NF11() : f() {}
+  V f;
+};
+NF11 nf11i;
+NF11 nf11s;
+
+// Delegating constructor
+class NF12 {
+  NF12() = default;
+  NF12(int) : NF12() {}
+};
+
+// Const member
+struct NF13 {
+  NF13() : f() {}
+  const S f;
+};
Index: docs/clang-tidy/checks/readability-redundant-member-init.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/readability-redundant-member-init.rst
@@ -0,0 +1,20 @@
+.. title:: clang-tidy - readability-redundant-member-init
+
+readability-redundant-member-init
+=
+
+Finds member initializations that are unnecessary because the same default
+constructor would be called if they were not present.
+
+Example:
+
+.. code-block:: c++
+
+  // Explicitly initializing the member s is unnecessary.  
+  class Foo {
+  public:
+Foo() : s() {}
+
+  private:
+std::string s;
+  };
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ 

Re: [PATCH] D24820: Add -stats-file option

2016-09-22 Thread Adrian Prantl via cfe-commits
aprantl added inline comments.


Comment at: include/clang/Basic/DiagnosticFrontendKinds.td:111
@@ -110,1 +110,3 @@
+def warn_fe_unable_to_open_stats_file : Warning<
+"unable to open statistic output file '%0': '%1'">;
 def err_fe_no_pch_in_dir : Error<

statstic"s"? not sure.


Comment at: lib/Driver/Tools.cpp:6093
@@ -6092,1 +6092,3 @@
 
+  // Setup statistic file output.
+  if (const Arg *A = Args.getLastArg(options::OPT_save_stats_EQ)) {

ditto :-)


Comment at: test/Driver/save-stats.c:12
@@ +11,3 @@
+// RUN: %clang -target x86_64-apple-darwin -save-stats=obj -c -o 
obj/dir/save-stats.o %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-OBJ
+// CHECK-OBJ: "-stats-file=obj/dir{{/|}}save-stats.stats"
+// CHECK-OBJ: "-o" "obj/dir{{/|}}save-stats.o"

This is up to taste, but just accepting {{.}} as the path separator would be 
sufficient IMO and might be more readable.


Repository:
  rL LLVM

https://reviews.llvm.org/D24820



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


r282169 - [docs] Touch up the coverage docs some more

2016-09-22 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Thu Sep 22 10:34:33 2016
New Revision: 282169

URL: http://llvm.org/viewvc/llvm-project?rev=282169=rev
Log:
[docs] Touch up the coverage docs some more

Modified:
cfe/trunk/docs/SourceBasedCodeCoverage.rst

Modified: cfe/trunk/docs/SourceBasedCodeCoverage.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/SourceBasedCodeCoverage.rst?rev=282169=282168=282169=diff
==
--- cfe/trunk/docs/SourceBasedCodeCoverage.rst (original)
+++ cfe/trunk/docs/SourceBasedCodeCoverage.rst Thu Sep 22 10:34:33 2016
@@ -61,7 +61,7 @@ To compile code with coverage enabled, p
 % clang++ -fprofile-instr-generate -fcoverage-mapping foo.cc -o foo
 
 Note that linking together code with and without coverage instrumentation is
-supported: any uninstrumented code simply won't be accounted for.
+supported. Uninstrumented code simply won't be accounted for in reports.
 
 Running the instrumented program
 
@@ -95,28 +95,22 @@ Creating coverage reports
 =
 
 Raw profiles have to be **indexed** before they can be used to generate
-coverage reports. This is done using the "merge" tool in ``llvm-profdata``, so
-named because it can combine and index profiles at the same time:
+coverage reports. This is done using the "merge" tool in ``llvm-profdata``
+(which can combine multiple raw profiles and index them at the same time):
 
 .. code-block:: console
 
 # Step 3(a): Index the raw profile.
 % llvm-profdata merge -sparse foo.profraw -o foo.profdata
 
-There are multiple different ways to render coverage reports. One option is to
-generate a line-oriented report:
+There are multiple different ways to render coverage reports. The simplest
+option is to generate a line-oriented report:
 
 .. code-block:: console
 
 # Step 3(b): Create a line-oriented coverage report.
 % llvm-cov show ./foo -instr-profile=foo.profdata
 
-To generate the same report in html with demangling turned on, use:
-
-.. code-block:: console
-
-% llvm-cov show ./foo -instr-profile=foo.profdata -format html -o 
report.dir -Xdemangler c++filt -Xdemangler -n
-
 This report includes a summary view as well as dedicated sub-views for
 templated functions and their instantiations. For our example program, we get
 distinct views for ``foo(...)`` and ``foo(...)``.  If
@@ -145,8 +139,8 @@ region counts (even in macro expansions)
 |  4|1|}
 --
 
-It's possible to generate a file-level summary of coverage statistics (instead
-of a line-oriented report) with:
+To generate a file-level summary of coverage statistics instead of a
+line-oriented report, try:
 
 .. code-block:: console
 
@@ -158,6 +152,11 @@ of a line-oriented report) with:
 
--
 TOTAL   13 0   100.00%   3 
0   100.00%  13 0   100.00%
 
+The ``llvm-cov`` tool supports specifying a custom demangler, writing out
+reports in a directory structure, and generating html reports. For the full
+list of options, please refer to the `command guide
+`_.
+
 A few final notes:
 
 * The ``-sparse`` flag is optional but can result in dramatically smaller
@@ -190,7 +189,7 @@ Interpreting reports
 There are four statistics tracked in a coverage summary:
 
 * Function coverage is the percentage of functions which have been executed at
-  least once. A function is treated as having been executed if any of its
+  least once. A function is considered to be executed if any of its
   instantiations are executed.
 
 * Instantiation coverage is the percentage of function instantiations which
@@ -200,13 +199,12 @@ There are four statistics tracked in a c
 
 * Line coverage is the percentage of code lines which have been executed at
   least once. Only executable lines within function bodies are considered to be
-  code lines, so e.g coverage for macro definitions in a header might not be
-  included.
+  code lines.
 
 * Region coverage is the percentage of code regions which have been executed at
-  least once. A code region may span multiple lines (e.g a large function with
-  no control flow). However, it's also possible for a single line to contain
-  multiple code regions or even nested code regions (e.g "return x || y && z").
+  least once. A code region may span multiple lines (e.g in a large function
+  body with no control flow). However, it's also possible for a single line to
+  contain multiple code regions (e.g in "return x || y && z").
 
 Of these four statistics, function coverage is usually the least granular while
 region coverage is the most granular. The project-wide totals for each
@@ -224,9 +222,9 @@ Format compatibility guarantees
   These formats 

Re: OpenBSD/arm types

2016-09-22 Thread Mark Kettenis via cfe-commits
> From: Renato Golin 
> Date: Thu, 22 Sep 2016 16:06:53 +0100
> 
> Hi Mark,
> 
> It seems not many people have additional comments, so LGTM.
> 
> Do you have commit access?

No I don't.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24829: [clang-format] support header deletion in cleanupAroundReplacemnts.

2016-09-22 Thread Eric Liu via cfe-commits
ioeric created this revision.
ioeric added a reviewer: djasper.
ioeric added subscribers: klimek, cfe-commits.

- If a replacement has offset UINT_MAX, length 0, and a replacement text
  that is an #include directive, this will insert the #include into the
  correct block in the \p Code.
- If a replacement has offset UINT_MAX, length 1, and a replacement text
  that is the name of the header to be removed, the header will be removed
  from \p Code if it exists.

https://reviews.llvm.org/D24829

Files:
  include/clang/Format/Format.h
  lib/Format/Format.cpp
  unittests/Format/CleanupTest.cpp

Index: unittests/Format/CleanupTest.cpp
===
--- unittests/Format/CleanupTest.cpp
+++ unittests/Format/CleanupTest.cpp
@@ -247,8 +247,12 @@
 return tooling::Replacement(FileName, Offset, Length, Text);
   }
 
-  tooling::Replacement createInsertion(StringRef HeaderName) {
-return createReplacement(UINT_MAX, 0, HeaderName);
+  tooling::Replacement createInsertion(StringRef IncludeDirective) {
+return createReplacement(UINT_MAX, 0, IncludeDirective);
+  }
+
+  tooling::Replacement createDeletion(StringRef HeaderName) {
+return createReplacement(UINT_MAX, 1, HeaderName);
   }
 
   inline std::string apply(StringRef Code,
@@ -740,6 +744,57 @@
   EXPECT_EQ(Expected, apply(Code, Replaces));
 }
 
+TEST_F(CleanUpReplacementsTest, SimpleDeleteIncludes) {
+  std::string Code = "#include \"abc.h\"\n"
+ "#include \"xyz.h\" // comment\n"
+ "#include \"xyz\"\n"
+ "int x;\n";
+  std::string Expected = "#include \"xyz\"\n"
+ "int x;\n";
+  tooling::Replacements Replaces =
+  toReplacements({createDeletion("abc.h"), createDeletion("xyz.h")});
+  EXPECT_EQ(Expected, apply(Code, Replaces));
+}
+
+TEST_F(CleanUpReplacementsTest, DeleteAllCode) {
+  std::string Code = "#include \"xyz.h\"\n"
+ "#include ";
+  std::string Expected = "";
+  tooling::Replacements Replaces = toReplacements({createDeletion("xyz.h")});
+  EXPECT_EQ(Expected, apply(Code, Replaces));
+}
+
+TEST_F(CleanUpReplacementsTest, DeleteAllIncludesWithSameNameIfNoType) {
+  std::string Code = "#include \"xyz.h\"\n"
+ "#include \"xyz\"\n"
+ "#include \n";
+  std::string Expected = "#include \"xyz\"\n";
+  tooling::Replacements Replaces = toReplacements({createDeletion("xyz.h")});
+  EXPECT_EQ(Expected, apply(Code, Replaces));
+}
+
+TEST_F(CleanUpReplacementsTest, OnlyDeleteHeaderWithType) {
+  std::string Code = "#include \"xyz.h\"\n"
+ "#include \"xyz\"\n"
+ "#include ";
+  std::string Expected = "#include \"xyz.h\"\n"
+ "#include \"xyz\"\n";
+  tooling::Replacements Replaces = toReplacements({createDeletion("")});
+  EXPECT_EQ(Expected, apply(Code, Replaces));
+}
+
+TEST_F(CleanUpReplacementsTest, InsertionAndDeleteHeader) {
+  std::string Code = "#include \"a.h\"\n"
+ "\n"
+ "#include \n";
+  std::string Expected = "#include \"a.h\"\n"
+ "\n"
+ "#include \n";
+  tooling::Replacements Replaces = toReplacements(
+  {createDeletion(""), createInsertion("#include ")});
+  EXPECT_EQ(Expected, apply(Code, Replaces));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -1504,10 +1504,14 @@
 namespace {
 
 inline bool isHeaderInsertion(const tooling::Replacement ) {
-  return Replace.getOffset() == UINT_MAX &&
+  return Replace.getOffset() == UINT_MAX && Replace.getLength() == 0 &&
  llvm::Regex(IncludeRegexPattern).match(Replace.getReplacementText());
 }
 
+inline bool isHeaderDeletion(const tooling::Replacement ) {
+  return Replace.getOffset() == UINT_MAX && Replace.getLength() == 1;
+}
+
 void skipComments(Lexer , Token ) {
   while (Tok.is(tok::comment))
 if (Lex.LexFromRawLexer(Tok))
@@ -1548,6 +1552,14 @@
   return AfterComments;
 }
 
+bool isDeletedHeader(llvm::StringRef HeaderName,
+ const std::set HeadersToDelete) {
+  if (HeadersToDelete.find(HeaderName) != HeadersToDelete.end())
+return true;
+  HeaderName = HeaderName.trim("\"<>");
+  return HeadersToDelete.find(HeaderName) != HeadersToDelete.end();
+}
+
 // FIXME: we also need to insert a '\n' at the end of the code if we have an
 // insertion with offset Code.size(), and there is no '\n' at the end of the
 // code.
@@ -1561,21 +1573,24 @@
 return Replaces;
 
   tooling::Replacements HeaderInsertions;
+  std::set HeadersToDelete;
   tooling::Replacements Result;
   for (const auto  : Replaces) {
 if (isHeaderInsertion(R)) {
   // Replacements from \p Replaces must be conflict-free already, so we can
   // simply 

Re: OpenBSD/arm types

2016-09-22 Thread Renato Golin via cfe-commits
Hi Mark,

It seems not many people have additional comments, so LGTM.

Do you have commit access?

cheers,
--renato

On 20 September 2016 at 19:41, Mark Kettenis via cfe-commits
 wrote:
> As discussed in cfe-dev@:
>
> Like NetBSD, OpenBSD prefers having a consistent set of typedefs
> across the architectures it supports over strictly following the ARM
> ABIs.  The diff below makes sure that clang's view of those types
> matches OpenBSD's system header files.  It also adds a test that
> checks the relevant types on all OpenBSD platforms that clang works
> on.  Hopefully we can add mips64 and powerpc to that list in the
> future.
>
>
> Index: lib/Basic/Targets.cpp
> ===
> --- lib/Basic/Targets.cpp   (revision 281825)
> +++ lib/Basic/Targets.cpp   (working copy)
> @@ -4679,8 +4679,10 @@
>  DoubleAlign = LongLongAlign = LongDoubleAlign = SuitableAlign = 64;
>  const llvm::Triple  = getTriple();
>
> -// size_t is unsigned long on MachO-derived environments, NetBSD and 
> Bitrig.
> +// size_t is unsigned long on MachO-derived environments, NetBSD,
> +// OpenBSD and Bitrig.
>  if (T.isOSBinFormatMachO() || T.getOS() == llvm::Triple::NetBSD ||
> +T.getOS() == llvm::Triple::OpenBSD ||
>  T.getOS() == llvm::Triple::Bitrig)
>SizeType = UnsignedLong;
>  else
> @@ -4688,6 +4690,7 @@
>
>  switch (T.getOS()) {
>  case llvm::Triple::NetBSD:
> +case llvm::Triple::OpenBSD:
>WCharType = SignedInt;
>break;
>  case llvm::Triple::Win32:
> @@ -4885,6 +4888,7 @@
>
>  switch (getTriple().getOS()) {
>  case llvm::Triple::NetBSD:
> +case llvm::Triple::OpenBSD:
>PtrDiffType = SignedLong;
>break;
>  default:
> Index: test/Preprocessor/init.c
> ===
> --- test/Preprocessor/init.c(revision 281825)
> +++ test/Preprocessor/init.c(working copy)
> @@ -8463,6 +8463,29 @@
>  // RUN: %clang_cc1 -triple lanai-unknown-unknown -E -dM < /dev/null | 
> FileCheck -match-full-lines -check-prefix LANAI %s
>  // LANAI: #define __lanai__ 1
>  //
> +// RUN: %clang_cc1 -E -dM -ffreestanding -triple=amd64-unknown-openbsd6.1 < 
> /dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s
> +// RUN: %clang_cc1 -E -dM -ffreestanding 
> -triple=arm-unknown-openbsd6.1-gnueabi < /dev/null | FileCheck 
> -match-full-lines -check-prefix OPENBSD %s
> +// RUN: %clang_cc1 -E -dM -ffreestanding -triple=i386-unknown-openbsd6.1 < 
> /dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s
> +// RUN: %clang_cc1 -E -dM -ffreestanding -triple=sparc64-unknown-openbsd6.1 
> < /dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s
> +// OPENBSD:#define __ELF__ 1
> +// OPENBSD:#define __INT16_TYPE__ short
> +// OPENBSD:#define __INT32_TYPE__ int
> +// OPENBSD:#define __INT64_TYPE__ long long int
> +// OPENBSD:#define __INT8_TYPE__ signed char
> +// OPENBSD:#define __INTMAX_TYPE__ long long int
> +// OPENBSD:#define __INTPTR_TYPE__ long int
> +// OPENBSD:#define __OpenBSD__ 1
> +// OPENBSD:#define __PTRDIFF_TYPE__ long int
> +// OPENBSD:#define __SIZE_TYPE__ long unsigned int
> +// OPENBSD:#define __UINT16_TYPE__ unsigned short
> +// OPENBSD:#define __UINT32_TYPE__ unsigned int
> +// OPENBSD:#define __UINT64_TYPE__ long long unsigned int
> +// OPENBSD:#define __UINT8_TYPE__ unsigned char
> +// OPENBSD:#define __UINTMAX_TYPE__ long long unsigned int
> +// OPENBSD:#define __UINTPTR_TYPE__ long unsigned int
> +// OPENBSD:#define __WCHAR_TYPE__ int
> +// OPENBSD:#define __WINT_TYPE__ int
> +//
>  // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-unknown-freebsd < 
> /dev/null | FileCheck -match-full-lines -check-prefix PPC64-FREEBSD %s
>  // PPC64-FREEBSD-NOT: #define __LONG_DOUBLE_128__ 1
>  //
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24828: [clang-move] The new.cc file should include new_header.h instead of old_header.h

2016-09-22 Thread Eric Liu via cfe-commits
ioeric accepted this revision.
ioeric added a comment.
This revision is now accepted and ready to land.

Lg with nits.



Comment at: clang-move/ClangMove.cpp:290
@@ -294,1 +289,3 @@
 llvm::StringRef FileName) {
+  // Don't add the old_header.h to the new files.
+  if (!Spec.OldHeader.empty() && IncludeHeader.endswith(Spec.OldHeader))

I think we also need a FIXME here. There could be interesting dependency: if 
the new target depends on the old target, then it makes sense to add the 
header. 


Comment at: clang-move/ClangMove.cpp:295
@@ +294,3 @@
+  std::string IncludeLine = IsAngled
+? "#include <" + IncludeHeader.str() + ">\n"
+: "#include \"" + IncludeHeader.str() + "\"\n";

I think `("#include <" + IncludeHeader + ">\n").str()` is more efficient since 
it only creates one string instance.


https://reviews.llvm.org/D24828



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


Re: [PATCH] D24380: [migrate-tool] Framework for a codebase-dependent migration tool.

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

The interfaces look good to me roughly.



Comment at: migrate-tool/MigrationEnvironment.h:22
@@ +21,3 @@
+// RefactoringManager, and AffectedFilesFinder.
+class MigrationEnvironment {
+public:

`MigrationContext` might be better?


Comment at: migrate-tool/MigrationEnvironment.h:24
@@ +23,3 @@
+public:
+  MigrationEnvironment() = delete;
+  // Creates a migration environement containing codebase-dependent component.

This is not needed IMO since you have defined a four-parameters constructor 
below, compiler won't generate the default constructor implicitly.


https://reviews.llvm.org/D24380



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


[clang-tools-extra] r282158 - [clang-tidy] Add doc for `explain-config` option.

2016-09-22 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Thu Sep 22 09:36:43 2016
New Revision: 282158

URL: http://llvm.org/viewvc/llvm-project?rev=282158=rev
Log:
[clang-tidy] Add doc for `explain-config` option.

Modified:
clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp
clang-tools-extra/trunk/docs/clang-tidy/index.rst

Modified: clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp?rev=282158=282157=282158=diff
==
--- clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp Thu Sep 22 
09:36:43 2016
@@ -129,8 +129,9 @@ List all enabled checks and exit. Use wi
 cl::init(false), cl::cat(ClangTidyCategory));
 
 static cl::opt ExplainConfig("explain-config", cl::desc(R"(
-for each enabled check explains, where it is enabled, i.e. in clang-tidy 
binary,
-command line or a specific configuration file.
+For each enabled check explains, where it is
+enabled, i.e. in clang-tidy binary, command
+line or a specific configuration file.
 )"),
cl::init(false), 
cl::cat(ClangTidyCategory));
 

Modified: clang-tools-extra/trunk/docs/clang-tidy/index.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/index.rst?rev=282158=282157=282158=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/index.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/index.rst Thu Sep 22 09:36:43 2016
@@ -139,6 +139,10 @@ An overview of all the command-line opti
 -enable-check-profile- 
Enable per-check timing profiles, and print 
a
report to stderr.
+-explain-config  - 
+   For each enabled check explains, where it is
+   enabled, i.e. in clang-tidy binary, command
+   line or a specific configuration file.
 -export-fixes= - 
YAML file to store suggested fixes in. The
stored fixes can be applied to the input 
source


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


Re: [PATCH] D23712: [OpenCL] Override supported OpenCL extensions with -cl-ext option

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

I think we need two more tests for concatenating and overriding the option, e.g

  -cl-ext=-cl_khr_fp64 -cl-ext=+cl_khr_fp64

and

  -cl-ext=-cl_khr_fp64,+cl_khr_fp64



Comment at: include/clang/Basic/OpenCLOptions.h:39
@@ +38,3 @@
+
+  void set(llvm::StringRef Ext, bool Enable = true) {
+assert(!Ext.empty() && "Extension is empty.");

Better add a comments for this function about its semantics, i.e., if Ext does 
not starts with +/-, it is enabled/disabled by \p Enable, otherwise +/- 
overrides \p Enable, since this is not obvious.


https://reviews.llvm.org/D23712



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


Re: [PATCH] D24754: [cleanup] Remove excessive padding from RedeclarableResult

2016-09-22 Thread Vedant Kumar via cfe-commits
vsk accepted this revision.
vsk added a comment.
This revision is now accepted and ready to land.

LGTM.



Comment at: lib/Serialization/ASTReaderDecl.cpp:154
@@ -153,3 +153,3 @@
 public:
-  RedeclarableResult(GlobalDeclID FirstID, Decl *MergeWith, bool IsKeyDecl)
-  : FirstID(FirstID), MergeWith(MergeWith), IsKeyDecl(IsKeyDecl) {}
+  RedeclarableResult(Decl *MergeWith, GlobalDeclID FirstID, bool IsKeyDecl)
+  : MergeWith(MergeWith), FirstID(FirstID), IsKeyDecl(IsKeyDecl) {}

alexshap wrote:
> vsk wrote:
> > Why do you need to change the order of the parameters in the constructor?
> To avoid inconsistency. Here the parameters match the fields and it seemed to 
> me that it would be better to update the order. 
OK. But why not do the same thing for ObjCCategoriesVisitor?


Repository:
  rL LLVM

https://reviews.llvm.org/D24754



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


r282156 - Fix Wbitfield-constant-conversion false positives

2016-09-22 Thread Daniel Marjamaki via cfe-commits
Author: danielmarjamaki
Date: Thu Sep 22 09:13:46 2016
New Revision: 282156

URL: http://llvm.org/viewvc/llvm-project?rev=282156=rev
Log:
Fix Wbitfield-constant-conversion false positives

Summary:
The diagnostic did not handle ~ well. An expression such as ~0 is often used 
when 'all ones' is needed.

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


Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/Sema/constant-conversion.c

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=282156=282155=282156=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Thu Sep 22 09:13:46 2016
@@ -8006,11 +8006,10 @@ bool AnalyzeBitFieldAssignment(Sema ,
   unsigned OriginalWidth = Value.getBitWidth();
   unsigned FieldWidth = Bitfield->getBitWidthValue(S.Context);
 
-  if (Value.isSigned() && Value.isNegative())
+  if (!Value.isSigned() || Value.isNegative())
 if (UnaryOperator *UO = dyn_cast(OriginalInit))
-  if (UO->getOpcode() == UO_Minus)
-if (isa(UO->getSubExpr()))
-  OriginalWidth = Value.getMinSignedBits();
+  if (UO->getOpcode() == UO_Minus || UO->getOpcode() == UO_Not)
+OriginalWidth = Value.getMinSignedBits();
 
   if (OriginalWidth <= FieldWidth)
 return false;

Modified: cfe/trunk/test/Sema/constant-conversion.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/constant-conversion.c?rev=282156=282155=282156=diff
==
--- cfe/trunk/test/Sema/constant-conversion.c (original)
+++ cfe/trunk/test/Sema/constant-conversion.c Thu Sep 22 09:13:46 2016
@@ -69,7 +69,8 @@ void test7() {
unsigned int reserved:28;
} f;
 
-   f.twoBits1 = ~1; // expected-warning {{implicit truncation from 'int' 
to bitfield changes value from -2 to 2}}
+   f.twoBits1 = ~0; // no-warning
+   f.twoBits1 = ~1; // no-warning
f.twoBits2 = ~2; // expected-warning {{implicit truncation from 'int' 
to bitfield changes value from -3 to 1}}
f.twoBits1 &= ~1; // no-warning
f.twoBits2 &= ~2; // no-warning
@@ -114,6 +115,8 @@ void test9() {
   char array_init[] = { 255, 127, 128, 129, 0 };
 }
 
+#define A 1
+
 void test10() {
   struct S {
 unsigned a : 4;
@@ -121,7 +124,10 @@ void test10() {
   s.a = -1;
   s.a = 15;
   s.a = -8;
+  s.a = ~0;
+  s.a = ~0U;
+  s.a = ~(1<

Re: [PATCH] D24798: [mips] Fix msa builtins test

2016-09-22 Thread Simon Dardis via cfe-commits
sdardis abandoned this revision.
sdardis added a comment.

I'm abandoning this revision. This test is riddled with errors such as out of 
range immediates and type errors that aren't warned about. I'll post a more 
substantial patch to address the handling of those cases + update this test and 
I'll squash these small changes into that patch.


https://reviews.llvm.org/D24798



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


Re: [PATCH] D24828: [clang-move] Don't add old_header to the new files.

2016-09-22 Thread Eric Liu via cfe-commits
ioeric added a comment.

Could you elaborate on what this CL does in the description?


https://reviews.llvm.org/D24828



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


r282154 - Third attempt to fix Sphinx bot

2016-09-22 Thread Teresa Johnson via cfe-commits
Author: tejohnson
Date: Thu Sep 22 08:58:33 2016
New Revision: 282154

URL: http://llvm.org/viewvc/llvm-project?rev=282154=rev
Log:
Third attempt to fix Sphinx bot

Bot now complaining about -flto=thin reference, used similar workaround
for that failure.

Modified:
cfe/trunk/docs/CommandGuide/clang.rst

Modified: cfe/trunk/docs/CommandGuide/clang.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/CommandGuide/clang.rst?rev=282154=282153=282154=diff
==
--- cfe/trunk/docs/CommandGuide/clang.rst (original)
+++ cfe/trunk/docs/CommandGuide/clang.rst Thu Sep 22 08:58:33 2016
@@ -338,7 +338,7 @@ Code Generation Options
   The default for :option:`-flto` is "full", in which the
   LLVM bitcode is suitable for monolithic Link Time Optimization (LTO), where
   the linker merges all such modules into a single combined module for
-  optimization. With :option:`-flto=thin`, :doc:`ThinLTO <../ThinLTO>`
+  optimization. With "thin", :doc:`ThinLTO <../ThinLTO>`
   compilation is invoked instead.
 
 Driver Options


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


[PATCH] D24828: [clang-move] Don't add old_header to the new files.

2016-09-22 Thread Haojian Wu via cfe-commits
hokein created this revision.
hokein added a reviewer: ioeric.
hokein added a subscriber: cfe-commits.

https://reviews.llvm.org/D24828

Files:
  clang-move/ClangMove.cpp
  clang-move/ClangMove.h
  unittests/clang-move/ClangMoveTests.cpp

Index: unittests/clang-move/ClangMoveTests.cpp
===
--- unittests/clang-move/ClangMoveTests.cpp
+++ unittests/clang-move/ClangMoveTests.cpp
@@ -119,8 +119,7 @@
  "} // namespace b\n"
  "} // namespace a\n";
 
-const char ExpectedNewCC[] = "#include \"foo.h\"\n"
- "namespace a {\n"
+const char ExpectedNewCC[] = "namespace a {\n"
  "namespace b {\n"
  "namespace {\n"
  "void f1() {}\n"
@@ -181,11 +180,12 @@
   Spec.OldCC = "foo.cc";
   Spec.NewHeader = "new_foo.h";
   Spec.NewCC = "new_foo.cc";
+  std::string ExpectedHeader = "#include \"" + Spec.NewHeader + "\"\n";
   auto Results = runClangMoveOnCode(Spec);
   EXPECT_EQ(ExpectedTestHeader, Results[Spec.OldHeader]);
   EXPECT_EQ(ExpectedTestCC, Results[Spec.OldCC]);
   EXPECT_EQ(ExpectedNewHeader, Results[Spec.NewHeader]);
-  EXPECT_EQ(ExpectedNewCC, Results[Spec.NewCC]);
+  EXPECT_EQ(ExpectedHeader + ExpectedNewCC, Results[Spec.NewCC]);
 }
 
 TEST(ClangMove, MoveHeaderOnly) {
@@ -204,10 +204,11 @@
   Spec.Name = "a::b::Foo";
   Spec.OldCC = "foo.cc";
   Spec.NewCC = "new_foo.cc";
+  std::string ExpectedHeader = "#include \"foo.h\"\n";
   auto Results = runClangMoveOnCode(Spec);
   EXPECT_EQ(2u, Results.size());
   EXPECT_EQ(ExpectedTestCC, Results[Spec.OldCC]);
-  EXPECT_EQ(ExpectedNewCC, Results[Spec.NewCC]);
+  EXPECT_EQ(ExpectedHeader + ExpectedNewCC, Results[Spec.NewCC]);
 }
 
 TEST(ClangMove, MoveNonExistClass) {
Index: clang-move/ClangMove.h
===
--- clang-move/ClangMove.h
+++ clang-move/ClangMove.h
@@ -55,7 +55,8 @@
 
   // Add #includes from old.h/cc files. The FileName is where the #include
   // comes from.
-  void addIncludes(llvm::StringRef IncludeLine, llvm::StringRef FileName);
+  void addIncludes(llvm::StringRef IncludeHeader, bool IsAngled,
+   llvm::StringRef FileName);
 
 private:
   void removeClassDefinitionInOldFiles();
Index: clang-move/ClangMove.cpp
===
--- clang-move/ClangMove.cpp
+++ clang-move/ClangMove.cpp
@@ -41,15 +41,8 @@
   const clang::FileEntry * /*File*/,
   StringRef /*SearchPath*/, StringRef /*RelativePath*/,
   const clang::Module * /*Imported*/) override {
-if (const auto *FileEntry = SM.getFileEntryForID(SM.getFileID(HashLoc))) {
-  if (IsAngled) {
-MoveTool->addIncludes("#include <" + FileName.str() + ">\n",
-  FileEntry->getName());
-  } else {
-MoveTool->addIncludes("#include \"" + FileName.str() + "\"\n",
-  FileEntry->getName());
-  }
-}
+if (const auto *FileEntry = SM.getFileEntryForID(SM.getFileID(HashLoc)))
+  MoveTool->addIncludes(FileName, IsAngled, FileEntry->getName());
   }
 
 private:
@@ -135,7 +128,7 @@
 
   // Add #Includes.
   std::string AllIncludesString;
-  // FIXME: Filter out the old_header.h and add header guard.
+  // FIXME: Add header guard.
   for (const auto  : Includes)
 AllIncludesString += Include;
   clang::tooling::Replacement InsertInclude(FileName, 0, 0, AllIncludesString);
@@ -205,6 +198,8 @@
   std::map )
   : Spec(MoveSpec), FileToReplacements(FileToReplacements) {
   Spec.Name = llvm::StringRef(Spec.Name).ltrim(':');
+  if (!Spec.NewHeader.empty())
+CCIncludes.push_back("#include \"" + Spec.NewHeader + "\"\n");
 }
 
 void ClangMoveTool::registerMatchers(ast_matchers::MatchFinder *Finder) {
@@ -290,12 +285,19 @@
   }
 }
 
-void ClangMoveTool::addIncludes(llvm::StringRef IncludeLine,
+void ClangMoveTool::addIncludes(llvm::StringRef IncludeHeader, bool IsAngled,
 llvm::StringRef FileName) {
+  // Don't add the old_header.h to the new files.
+  if (!Spec.OldHeader.empty() && IncludeHeader.endswith(Spec.OldHeader))
+return;
+
+  std::string IncludeLine = IsAngled
+? "#include <" + IncludeHeader.str() + ">\n"
+: "#include \"" + IncludeHeader.str() + "\"\n";
   if (!Spec.OldHeader.empty() && FileName.endswith(Spec.OldHeader))
-HeaderIncludes.push_back(IncludeLine.str());
+HeaderIncludes.push_back(IncludeLine);
   else if (!Spec.OldCC.empty() && FileName.endswith(Spec.OldCC))
-CCIncludes.push_back(IncludeLine.str());
+CCIncludes.push_back(IncludeLine);
 }
 
 void ClangMoveTool::removeClassDefinitionInOldFiles() {

Re: [PATCH] D24807: [Serialization] ArrayTypeTraitExpr: serialize sub-expression to avoid keeping it undefined

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

Serialization tests usually come from PCH, so you could probably look in 
test/PCH to get ideas on how to test this.


https://reviews.llvm.org/D24807



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


Re: [PATCH] D24807: [Serialization] ArrayTypeTraitExpr: serialize sub-expression to avoid keeping it undefined

2016-09-22 Thread Alexey Bataev via cfe-commits
ABataev added a subscriber: ABataev.
ABataev added a comment.

You need to add tests for serialization/deserialization


https://reviews.llvm.org/D24807



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


[PATCH] D24826: [LTO] Add -flto-jobs=N to control backend parallelism

2016-09-22 Thread Teresa Johnson via cfe-commits
tejohnson created this revision.
tejohnson added a reviewer: mehdi_amini.
tejohnson added a subscriber: cfe-commits.
Herald added a subscriber: mehdi_amini.

Currently, a linker option must be used to control the backend
parallelism of ThinLTO or full LTO (where it only applies to
parallel code gen). The linker option varies depending on the
linker (e.g. gold vs ld64). Add a new clang option -flto-jobs=N
to control this.

I've added in the wiring to pass this to the gold plugin. I also
added in the logic to pass this down in the form I understand that
ld64 uses on MacOS, for the darwin target.

https://reviews.llvm.org/D24826

Files:
  include/clang/Driver/Options.td
  lib/Driver/Tools.cpp
  test/Driver/lto-jobs.c

Index: test/Driver/lto-jobs.c
===
--- /dev/null
+++ test/Driver/lto-jobs.c
@@ -0,0 +1,11 @@
+// Confirm that -flto-jobs=N is passed to linker
+
+// RUN: %clang -target x86_64-unknown-linux -### %s -flto=thin -flto-jobs=5 2> %t
+// RUN: FileCheck -check-prefix=CHECK-LINK-THIN-JOBS-ACTION < %t %s
+//
+// CHECK-LINK-THIN-JOBS-ACTION: "-plugin-opt=jobs=5"
+
+// RUN: %clang -target x86_64-apple-darwin13.3.0 -### %s -flto=thin -flto-jobs=5 2> %t
+// RUN: FileCheck -check-prefix=CHECK-LINK-THIN-JOBS2-ACTION < %t %s
+//
+// CHECK-LINK-THIN-JOBS2-ACTION: "-mllvm" "-threads=5"
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -1998,8 +1998,19 @@
   }
 }
 
+static unsigned getLTOParallelism(const ArgList , const Driver ) {
+  unsigned Parallelism = 0;
+  Arg *LtoJobsArg = Args.getLastArg(options::OPT_flto_jobs_EQ);
+  if (LtoJobsArg &&
+  StringRef(LtoJobsArg->getValue()).getAsInteger(10, Parallelism))
+D.Diag(diag::err_drv_invalid_int_value) << LtoJobsArg->getAsString(Args)
+<< LtoJobsArg->getValue();
+  return Parallelism;
+}
+
 static void AddGoldPlugin(const ToolChain , const ArgList ,
-  ArgStringList , bool IsThinLTO) {
+  ArgStringList , bool IsThinLTO,
+  const Driver ) {
   // Tell the linker to load the plugin. This has to come before AddLinkerInputs
   // as gold requires -plugin to come before any -plugin-opt that -Wl might
   // forward.
@@ -2032,6 +2043,10 @@
   if (IsThinLTO)
 CmdArgs.push_back("-plugin-opt=thinlto");
 
+  if (unsigned Parallelism = getLTOParallelism(Args, D))
+CmdArgs.push_back(Args.MakeArgString(Twine("-plugin-opt=jobs=") +
+ std::to_string(Parallelism)));
+
   // If an explicit debugger tuning argument appeared, pass it along.
   if (Arg *A = Args.getLastArg(options::OPT_gTune_Group,
options::OPT_ggdbN_Group)) {
@@ -7639,7 +7654,7 @@
options::OPT_t, options::OPT_Z_Flag, options::OPT_r});
 
   if (D.isUsingLTO())
-AddGoldPlugin(ToolChain, Args, CmdArgs, D.getLTOMode() == LTOK_Thin);
+AddGoldPlugin(ToolChain, Args, CmdArgs, D.getLTOMode() == LTOK_Thin, D);
 
   AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs);
 
@@ -8060,6 +8075,13 @@
 
   getMachOToolChain().addProfileRTLibs(Args, CmdArgs);
 
+  if (unsigned Parallelism =
+  getLTOParallelism(Args, getToolChain().getDriver())) {
+CmdArgs.push_back("-mllvm");
+CmdArgs.push_back(
+Args.MakeArgString(Twine("-threads=") + std::to_string(Parallelism)));
+  }
+
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
 if (getToolChain().getDriver().CCCIsCXX())
   getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
@@ -8790,7 +8812,7 @@
   Args.AddAllArgs(CmdArgs, options::OPT_r);
 
   if (D.isUsingLTO())
-AddGoldPlugin(ToolChain, Args, CmdArgs, D.getLTOMode() == LTOK_Thin);
+AddGoldPlugin(ToolChain, Args, CmdArgs, D.getLTOMode() == LTOK_Thin, D);
 
   bool NeedsSanitizerDeps = addSanitizerRuntimes(ToolChain, Args, CmdArgs);
   AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs);
@@ -9623,7 +9645,7 @@
   ToolChain.AddFilePathLibArgs(Args, CmdArgs);
 
   if (D.isUsingLTO())
-AddGoldPlugin(ToolChain, Args, CmdArgs, D.getLTOMode() == LTOK_Thin);
+AddGoldPlugin(ToolChain, Args, CmdArgs, D.getLTOMode() == LTOK_Thin, D);
 
   if (Args.hasArg(options::OPT_Z_Xlinker__no_demangle))
 CmdArgs.push_back("--no-demangle");
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -812,6 +812,11 @@
   HelpText<"Enable LTO in 'full' mode">;
 def fno_lto : Flag<["-"], "fno-lto">, Group,
   HelpText<"Disable LTO mode (default)">;
+def flto_jobs_EQ : Joined<["-"], "flto-jobs=">,
+  Flags<[CC1Option]>, Group,
+  HelpText<"Controls the backend parallelism of -flto=thin (default "
+   "std::thread::hardware_concurrency) or the code generation "
+   

Re: [PATCH] D24799: [XRay] Check in Clang whether XRay supports the target when -fxray-instrument is passed

2016-09-22 Thread Dean Michael Berris via cfe-commits
dberris added a comment.

In https://reviews.llvm.org/D24799#549634, @rSerge wrote:

> In https://reviews.llvm.org/D24799#549442, @dberris wrote:
>
> > What does the error actually look like? Can you add a test for it? It's 
> > unclear to me how this would read... for example does it say "XRay for arm 
> > is unsupported"?
>
>
> In the attached picture you can see how the error looks when cross-compiling 
> with Clang from x86_64-Windows host to Thumb-Linux target. 
>  F2439489: Unsupported XRay target error.jpg 
> 
>  It says
>
> > clang++.exe: error: the clang compiler does not support 'XRay for 
> > armv6kz--linux-gnueabihf'
>


Thanks -- I that's really helpful.

A clearer message I think might read something like:

> the clang compiler does not support '-fxray-instrument' on 
> '-mtriple=armv6kz-linux-gnueabihf'


Even if you drop the '-mtriple=' prefix, I think that might work better than 
"XRay for".

> I'll try to add tests.


Thanks -- an XFAIL for a platform you know it should fail for should be 
sufficient, without spelling out the actual error message in the test.


https://reviews.llvm.org/D24799



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


Re: r282148 - Fixing sphinx build due to diagnostic:

2016-09-22 Thread Teresa Johnson via cfe-commits
On Thu, Sep 22, 2016 at 6:43 AM, Aaron Ballman 
wrote:

> On Thu, Sep 22, 2016 at 9:41 AM, Teresa Johnson 
> wrote:
> >
> >
> >
> > On Thu, Sep 22, 2016 at 6:38 AM, Aaron Ballman 
> wrote:
> >>
> >> On Thu, Sep 22, 2016 at 9:34 AM, Teresa Johnson 
> wrote:
> >> > Hi Aaron,
> >> >
> >> > I just went back to the bot, which had first failed with a process
> error
> >> > when I made my commit which is why I didn't see this error. It looks
> like it
> >> > is still failing with the same error:
> >> >
> >> > http://lab.llvm.org:8011/builders/clang-sphinx-docs/
> builds/16313/steps/docs-clang-html/logs/stdio
> >> > (that build has your fix).
> >> >
> >> > Unfortunately, I can't reproduce this locally, which is why I didn't
> see it
> >> > in my testing. I confirmed my build is using the same command line,
> so I can
> >> > only surmise that I must be using a different version of sphinx.
> >>
> >> I run into the same problem -- I cannot reproduce it locally either.
> >> I've just hit this problem several times before and was speculatively
> >> fixing it. I have no idea how this bot is configured and why
> >> configuration is different. :-(
> >>
> >> > AFAICT your change should have fixed this error. Any idea why it is
> still
> >> > giving it?
> >>
> >> The option directives are really persnickety about how things are
> >> spelled. It's possible that it just doesn't like the "=blah" part at
> >> all. We could remove the :option: usage from the paragraph and leave
> >> the .. option:: directive in the title. That's another way I've solved
> >> this in the past.
> >
> >
> > Ok, I'll go ahead and do that. It's odd that it doesn't seem to be
> complaining about the -flto=thin reference a few lines below.
>
> Thank you for taking care of it! Also, welcome to the world of Sphinx,
> where that's not odd, it's The Way Things Work. :-D Once Sphinx hits
> an error, it seems to stop reporting more errors.
>

I only fixed the -flto=full reference (r282151) - will keep an eye on the
bot and if it starts complaining about the -flto=thin reference next I will
do the same there!


> > Do you know if the pages at http://clang.llvm.org/docs/ will
> automatically be refreshed once this is fixed?
>
> I believe they should, yes.
>

Ok, great, thanks

Teresa


>
> ~Aaron
>
> >
> > Teresa
> >
> >>
> >> ~Aaron
> >>
> >> >
> >> > Thanks,
> >> > Teresa
> >> >
> >> >
> >> > On Thu, Sep 22, 2016 at 6:10 AM, Teresa Johnson  >
> >> > wrote:
> >> >>
> >> >> Thank you!
> >> >> Teresa
> >> >>
> >> >> On Thu, Sep 22, 2016 at 5:15 AM, Aaron Ballman via cfe-commits
> >> >>  wrote:
> >> >>>
> >> >>> Author: aaronballman
> >> >>> Date: Thu Sep 22 07:15:18 2016
> >> >>> New Revision: 282148
> >> >>>
> >> >>> URL: http://llvm.org/viewvc/llvm-project?rev=282148=rev
> >> >>> Log:
> >> >>> Fixing sphinx build due to diagnostic:
> >> >>>
> >> >>>
> >> >>> /opt/llvm/build.attributes.src/tools/clang/docs/
> CommandGuide/clang.rst:338:
> >> >>> WARNING: unknown option: -flto=full
> >> >>>
> >> >>> Modified:
> >> >>> cfe/trunk/docs/CommandGuide/clang.rst
> >> >>>
> >> >>> Modified: cfe/trunk/docs/CommandGuide/clang.rst
> >> >>> URL:
> >> >>> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/
> CommandGuide/clang.rst?rev=282148=282147=282148=diff
> >> >>>
> >> >>> 
> ==
> >> >>> --- cfe/trunk/docs/CommandGuide/clang.rst (original)
> >> >>> +++ cfe/trunk/docs/CommandGuide/clang.rst Thu Sep 22 07:15:18 2016
> >> >>> @@ -328,7 +328,7 @@ Code Generation Options
> >> >>>model can be overridden with the tls_model attribute. The
> compiler
> >> >>> will try
> >> >>>to choose a more efficient model if possible.
> >> >>>
> >> >>> -.. option:: -flto[=full,thin], -emit-llvm
> >> >>> +.. option:: -flto, -flto=full, -flto=thin, -emit-llvm
> >> >>>
> >> >>>Generate output files in LLVM formats, suitable for link time
> >> >>> optimization.
> >> >>>When used with :option:`-S` this generates LLVM intermediate
> language
> >> >>>
> >> >>>
> >> >>> ___
> >> >>> cfe-commits mailing list
> >> >>> cfe-commits@lists.llvm.org
> >> >>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
> >> >>
> >> >>
> >> >>
> >> >>
> >> >> --
> >> >> Teresa Johnson | Software Engineer | tejohn...@google.com |
> 408-460-2413
> >> >
> >> >
> >> >
> >> >
> >> > --
> >> > Teresa Johnson | Software Engineer | tejohn...@google.com |
> 408-460-2413
> >
> >
> >
> >
> > --
> > Teresa Johnson | Software Engineer | tejohn...@google.com | 408-460-2413
>



-- 
Teresa Johnson |  Software Engineer |  tejohn...@google.com |  408-460-2413
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24799: [XRay] Check in Clang whether XRay supports the target when -fxray-instrument is passed

2016-09-22 Thread Serge Rogatch via cfe-commits
rSerge added a comment.

In https://reviews.llvm.org/D24799#549442, @dberris wrote:

> What does the error actually look like? Can you add a test for it? It's 
> unclear to me how this would read... for example does it say "XRay for arm is 
> unsupported"?


In the attached picture you can see how the error looks when cross-compiling 
with Clang from x86_64-Windows host to Thumb-Linux target. 
F2439489: Unsupported XRay target error.jpg 
It says

> clang++.exe: error: the clang compiler does not support 'XRay for 
> armv6kz--linux-gnueabihf'


I'll try to add tests.


https://reviews.llvm.org/D24799



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


r282151 - Second attempt to fix Sphinx bot

2016-09-22 Thread Teresa Johnson via cfe-commits
Author: tejohnson
Date: Thu Sep 22 08:41:10 2016
New Revision: 282151

URL: http://llvm.org/viewvc/llvm-project?rev=282151=rev
Log:
Second attempt to fix Sphinx bot

The fix in r282148 was not enough to fix the following error:
/home/llvmbb/llvm-build-dir/clang-sphinx-docs/llvm/src/tools/clang/docs/CommandGuide/clang.rst:338:
WARNING: unknown option: -flto=full

on the sphinx bot:
  http://lab.llvm.org:8011/builders/clang-sphinx-docs/builds/16313

(not reproducible locally).

This time, simply remove the option reference.

Modified:
cfe/trunk/docs/CommandGuide/clang.rst

Modified: cfe/trunk/docs/CommandGuide/clang.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/CommandGuide/clang.rst?rev=282151=282150=282151=diff
==
--- cfe/trunk/docs/CommandGuide/clang.rst (original)
+++ cfe/trunk/docs/CommandGuide/clang.rst Thu Sep 22 08:41:10 2016
@@ -335,7 +335,7 @@ Code Generation Options
   assembly files, otherwise this generates LLVM bitcode format object files
   (which may be passed to the linker depending on the stage selection options).
 
-  The default for :option:`-flto` is :option:`-flto=full`, in which the
+  The default for :option:`-flto` is "full", in which the
   LLVM bitcode is suitable for monolithic Link Time Optimization (LTO), where
   the linker merges all such modules into a single combined module for
   optimization. With :option:`-flto=thin`, :doc:`ThinLTO <../ThinLTO>`


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


Re: r282148 - Fixing sphinx build due to diagnostic:

2016-09-22 Thread Aaron Ballman via cfe-commits
On Thu, Sep 22, 2016 at 9:41 AM, Teresa Johnson  wrote:
>
>
>
> On Thu, Sep 22, 2016 at 6:38 AM, Aaron Ballman  wrote:
>>
>> On Thu, Sep 22, 2016 at 9:34 AM, Teresa Johnson  wrote:
>> > Hi Aaron,
>> >
>> > I just went back to the bot, which had first failed with a process error
>> > when I made my commit which is why I didn't see this error. It looks like 
>> > it
>> > is still failing with the same error:
>> >
>> > http://lab.llvm.org:8011/builders/clang-sphinx-docs/builds/16313/steps/docs-clang-html/logs/stdio
>> > (that build has your fix).
>> >
>> > Unfortunately, I can't reproduce this locally, which is why I didn't see it
>> > in my testing. I confirmed my build is using the same command line, so I 
>> > can
>> > only surmise that I must be using a different version of sphinx.
>>
>> I run into the same problem -- I cannot reproduce it locally either.
>> I've just hit this problem several times before and was speculatively
>> fixing it. I have no idea how this bot is configured and why
>> configuration is different. :-(
>>
>> > AFAICT your change should have fixed this error. Any idea why it is still
>> > giving it?
>>
>> The option directives are really persnickety about how things are
>> spelled. It's possible that it just doesn't like the "=blah" part at
>> all. We could remove the :option: usage from the paragraph and leave
>> the .. option:: directive in the title. That's another way I've solved
>> this in the past.
>
>
> Ok, I'll go ahead and do that. It's odd that it doesn't seem to be 
> complaining about the -flto=thin reference a few lines below.

Thank you for taking care of it! Also, welcome to the world of Sphinx,
where that's not odd, it's The Way Things Work. :-D Once Sphinx hits
an error, it seems to stop reporting more errors.

> Do you know if the pages at http://clang.llvm.org/docs/ will automatically be 
> refreshed once this is fixed?

I believe they should, yes.

~Aaron

>
> Teresa
>
>>
>> ~Aaron
>>
>> >
>> > Thanks,
>> > Teresa
>> >
>> >
>> > On Thu, Sep 22, 2016 at 6:10 AM, Teresa Johnson 
>> > wrote:
>> >>
>> >> Thank you!
>> >> Teresa
>> >>
>> >> On Thu, Sep 22, 2016 at 5:15 AM, Aaron Ballman via cfe-commits
>> >>  wrote:
>> >>>
>> >>> Author: aaronballman
>> >>> Date: Thu Sep 22 07:15:18 2016
>> >>> New Revision: 282148
>> >>>
>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=282148=rev
>> >>> Log:
>> >>> Fixing sphinx build due to diagnostic:
>> >>>
>> >>>
>> >>> /opt/llvm/build.attributes.src/tools/clang/docs/CommandGuide/clang.rst:338:
>> >>> WARNING: unknown option: -flto=full
>> >>>
>> >>> Modified:
>> >>> cfe/trunk/docs/CommandGuide/clang.rst
>> >>>
>> >>> Modified: cfe/trunk/docs/CommandGuide/clang.rst
>> >>> URL:
>> >>> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/CommandGuide/clang.rst?rev=282148=282147=282148=diff
>> >>>
>> >>> ==
>> >>> --- cfe/trunk/docs/CommandGuide/clang.rst (original)
>> >>> +++ cfe/trunk/docs/CommandGuide/clang.rst Thu Sep 22 07:15:18 2016
>> >>> @@ -328,7 +328,7 @@ Code Generation Options
>> >>>model can be overridden with the tls_model attribute. The compiler
>> >>> will try
>> >>>to choose a more efficient model if possible.
>> >>>
>> >>> -.. option:: -flto[=full,thin], -emit-llvm
>> >>> +.. option:: -flto, -flto=full, -flto=thin, -emit-llvm
>> >>>
>> >>>Generate output files in LLVM formats, suitable for link time
>> >>> optimization.
>> >>>When used with :option:`-S` this generates LLVM intermediate language
>> >>>
>> >>>
>> >>> ___
>> >>> cfe-commits mailing list
>> >>> cfe-commits@lists.llvm.org
>> >>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>> >>
>> >>
>> >>
>> >>
>> >> --
>> >> Teresa Johnson | Software Engineer | tejohn...@google.com | 408-460-2413
>> >
>> >
>> >
>> >
>> > --
>> > Teresa Johnson | Software Engineer | tejohn...@google.com | 408-460-2413
>
>
>
>
> --
> Teresa Johnson | Software Engineer | tejohn...@google.com | 408-460-2413
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24825: [X86] Remove the mm_malloc.h include guard hack from the X86 builtins tests

2016-09-22 Thread Elad Cohen via cfe-commits
eladcohen created this revision.
eladcohen added a subscriber: cfe-commits.

The X86 clang/test/CodeGen/*builtins.c tests define the mm_malloc.h include 
guard as a hack for avoiding its inclusion (mm_malloc.h requires a hosted 
environment since it expects stdlib.h to be available - which is not the case 
in these internal clang codegen tests).

This patch removes this hack and instead passes -ffreestanding to clang cc1.


https://reviews.llvm.org/D24825

Files:
  test/CodeGen/3dnow-builtins.c
  test/CodeGen/avx-builtins.c
  test/CodeGen/avx-cmp-builtins.c
  test/CodeGen/avx-shuffle-builtins.c
  test/CodeGen/avx2-builtins.c
  test/CodeGen/avx512bw-builtins.c
  test/CodeGen/avx512cdintrin.c
  test/CodeGen/avx512dq-builtins.c
  test/CodeGen/avx512er-builtins.c
  test/CodeGen/avx512f-builtins.c
  test/CodeGen/avx512ifma-builtins.c
  test/CodeGen/avx512pf-builtins.c
  test/CodeGen/avx512vbmi-builtins.c
  test/CodeGen/avx512vbmivl-builtin.c
  test/CodeGen/avx512vl-builtins.c
  test/CodeGen/avx512vlbw-builtins.c
  test/CodeGen/avx512vlcd-builtins.c
  test/CodeGen/avx512vldq-builtins.c
  test/CodeGen/bitscan-builtins.c
  test/CodeGen/bmi-builtins.c
  test/CodeGen/bmi2-builtins.c
  test/CodeGen/f16c-builtins.c
  test/CodeGen/fma-builtins.c
  test/CodeGen/fma4-builtins.c
  test/CodeGen/fsgsbase-builtins.c
  test/CodeGen/lzcnt-builtins.c
  test/CodeGen/mmx-builtins.c
  test/CodeGen/pclmul-builtins.c
  test/CodeGen/pku.c
  test/CodeGen/popcnt-builtins.c
  test/CodeGen/prefetchw-builtins.c
  test/CodeGen/rd-builtins.c
  test/CodeGen/rdrand-builtins.c
  test/CodeGen/rtm-builtins.c
  test/CodeGen/sha-builtins.c
  test/CodeGen/sse-builtins.c
  test/CodeGen/sse.c
  test/CodeGen/sse2-builtins.c
  test/CodeGen/sse3-builtins.c
  test/CodeGen/sse41-builtins.c
  test/CodeGen/sse42-builtins.c
  test/CodeGen/sse4a-builtins.c
  test/CodeGen/ssse3-builtins.c
  test/CodeGen/tbm-builtins.c
  test/CodeGen/vector.c
  test/CodeGen/xop-builtins.c

Index: test/CodeGen/xop-builtins.c
===
--- test/CodeGen/xop-builtins.c
+++ test/CodeGen/xop-builtins.c
@@ -1,8 +1,6 @@
-// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin -target-feature +xop -emit-llvm -o - -Wall -Werror | FileCheck %s
-// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin -target-feature +xop -fno-signed-char -emit-llvm -o - -Wall -Werror | FileCheck %s
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +xop -emit-llvm -o - -Wall -Werror | FileCheck %s
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +xop -fno-signed-char -emit-llvm -o - -Wall -Werror | FileCheck %s
 
-// Don't include mm_malloc.h, it's system specific.
-#define __MM_MALLOC_H
 
 #include 
 
Index: test/CodeGen/vector.c
===
--- test/CodeGen/vector.c
+++ test/CodeGen/vector.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple i386-apple-darwin9 -O1 -target-cpu core2 -debug-info-kind=limited -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -ffreestanding -triple i386-apple-darwin9 -O1 -target-cpu core2 -debug-info-kind=limited -emit-llvm %s -o - | FileCheck %s
 typedef short __v4hi __attribute__ ((__vector_size__ (8)));
 
 void test1() {
@@ -20,8 +20,6 @@
 
 
 
-// Don't include mm_malloc.h, it's system specific.
-#define __MM_MALLOC_H
 
 #include 
 
Index: test/CodeGen/tbm-builtins.c
===
--- test/CodeGen/tbm-builtins.c
+++ test/CodeGen/tbm-builtins.c
@@ -1,10 +1,8 @@
-// RUN: %clang_cc1 %s -O3 -triple=x86_64-unknown-unknown -target-feature +tbm -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -ffreestanding %s -O3 -triple=x86_64-unknown-unknown -target-feature +tbm -emit-llvm -o - | FileCheck %s
 // FIXME: The code generation checks for add/sub and/or are depending on the optimizer.
 // The REQUIRES keyword will be removed when the FIXME is complete.
 // REQUIRES: x86-registered-target
 
-// Don't include mm_malloc.h, it's system specific.
-#define __MM_MALLOC_H
 
 #include 
 
Index: test/CodeGen/ssse3-builtins.c
===
--- test/CodeGen/ssse3-builtins.c
+++ test/CodeGen/ssse3-builtins.c
@@ -1,7 +1,5 @@
-// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin -target-feature +ssse3 -emit-llvm -o - -Wall -Werror | FileCheck %s
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +ssse3 -emit-llvm -o - -Wall -Werror | FileCheck %s
 
-// Don't include mm_malloc.h, it's system specific.
-#define __MM_MALLOC_H
 
 #include 
 
Index: test/CodeGen/sse4a-builtins.c
===
--- test/CodeGen/sse4a-builtins.c
+++ test/CodeGen/sse4a-builtins.c
@@ -1,7 +1,5 @@
-// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin -target-feature +sse4a -emit-llvm -o - -Wall -Werror | FileCheck %s
+// RUN: %clang_cc1 -ffreestanding %s 

Re: r282148 - Fixing sphinx build due to diagnostic:

2016-09-22 Thread Teresa Johnson via cfe-commits
On Thu, Sep 22, 2016 at 6:38 AM, Aaron Ballman 
wrote:

> On Thu, Sep 22, 2016 at 9:34 AM, Teresa Johnson 
> wrote:
> > Hi Aaron,
> >
> > I just went back to the bot, which had first failed with a process error
> > when I made my commit which is why I didn't see this error. It looks
> like it
> > is still failing with the same error:
> >
> > http://lab.llvm.org:8011/builders/clang-sphinx-docs/
> builds/16313/steps/docs-clang-html/logs/stdio
> > (that build has your fix).
> >
> > Unfortunately, I can't reproduce this locally, which is why I didn't see
> it
> > in my testing. I confirmed my build is using the same command line, so I
> can
> > only surmise that I must be using a different version of sphinx.
>
> I run into the same problem -- I cannot reproduce it locally either.
> I've just hit this problem several times before and was speculatively
> fixing it. I have no idea how this bot is configured and why
> configuration is different. :-(
>
> > AFAICT your change should have fixed this error. Any idea why it is still
> > giving it?
>
> The option directives are really persnickety about how things are
> spelled. It's possible that it just doesn't like the "=blah" part at
> all. We could remove the :option: usage from the paragraph and leave
> the .. option:: directive in the title. That's another way I've solved
> this in the past.
>

Ok, I'll go ahead and do that. It's odd that it doesn't seem to be
complaining about the -flto=thin reference a few lines below.

Do you know if the pages at http://clang.llvm.org/docs/ will automatically
be refreshed once this is fixed?

Teresa


> ~Aaron
>
> >
> > Thanks,
> > Teresa
> >
> >
> > On Thu, Sep 22, 2016 at 6:10 AM, Teresa Johnson 
> > wrote:
> >>
> >> Thank you!
> >> Teresa
> >>
> >> On Thu, Sep 22, 2016 at 5:15 AM, Aaron Ballman via cfe-commits
> >>  wrote:
> >>>
> >>> Author: aaronballman
> >>> Date: Thu Sep 22 07:15:18 2016
> >>> New Revision: 282148
> >>>
> >>> URL: http://llvm.org/viewvc/llvm-project?rev=282148=rev
> >>> Log:
> >>> Fixing sphinx build due to diagnostic:
> >>>
> >>>
> >>> /opt/llvm/build.attributes.src/tools/clang/docs/
> CommandGuide/clang.rst:338:
> >>> WARNING: unknown option: -flto=full
> >>>
> >>> Modified:
> >>> cfe/trunk/docs/CommandGuide/clang.rst
> >>>
> >>> Modified: cfe/trunk/docs/CommandGuide/clang.rst
> >>> URL:
> >>> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/
> CommandGuide/clang.rst?rev=282148=282147=282148=diff
> >>>
> >>> 
> ==
> >>> --- cfe/trunk/docs/CommandGuide/clang.rst (original)
> >>> +++ cfe/trunk/docs/CommandGuide/clang.rst Thu Sep 22 07:15:18 2016
> >>> @@ -328,7 +328,7 @@ Code Generation Options
> >>>model can be overridden with the tls_model attribute. The compiler
> >>> will try
> >>>to choose a more efficient model if possible.
> >>>
> >>> -.. option:: -flto[=full,thin], -emit-llvm
> >>> +.. option:: -flto, -flto=full, -flto=thin, -emit-llvm
> >>>
> >>>Generate output files in LLVM formats, suitable for link time
> >>> optimization.
> >>>When used with :option:`-S` this generates LLVM intermediate
> language
> >>>
> >>>
> >>> ___
> >>> cfe-commits mailing list
> >>> cfe-commits@lists.llvm.org
> >>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
> >>
> >>
> >>
> >>
> >> --
> >> Teresa Johnson | Software Engineer | tejohn...@google.com |
> 408-460-2413
> >
> >
> >
> >
> > --
> > Teresa Johnson | Software Engineer | tejohn...@google.com | 408-460-2413
>



-- 
Teresa Johnson |  Software Engineer |  tejohn...@google.com |  408-460-2413
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r282148 - Fixing sphinx build due to diagnostic:

2016-09-22 Thread Aaron Ballman via cfe-commits
On Thu, Sep 22, 2016 at 9:34 AM, Teresa Johnson  wrote:
> Hi Aaron,
>
> I just went back to the bot, which had first failed with a process error
> when I made my commit which is why I didn't see this error. It looks like it
> is still failing with the same error:
>
> http://lab.llvm.org:8011/builders/clang-sphinx-docs/builds/16313/steps/docs-clang-html/logs/stdio
> (that build has your fix).
>
> Unfortunately, I can't reproduce this locally, which is why I didn't see it
> in my testing. I confirmed my build is using the same command line, so I can
> only surmise that I must be using a different version of sphinx.

I run into the same problem -- I cannot reproduce it locally either.
I've just hit this problem several times before and was speculatively
fixing it. I have no idea how this bot is configured and why
configuration is different. :-(

> AFAICT your change should have fixed this error. Any idea why it is still
> giving it?

The option directives are really persnickety about how things are
spelled. It's possible that it just doesn't like the "=blah" part at
all. We could remove the :option: usage from the paragraph and leave
the .. option:: directive in the title. That's another way I've solved
this in the past.

~Aaron

>
> Thanks,
> Teresa
>
>
> On Thu, Sep 22, 2016 at 6:10 AM, Teresa Johnson 
> wrote:
>>
>> Thank you!
>> Teresa
>>
>> On Thu, Sep 22, 2016 at 5:15 AM, Aaron Ballman via cfe-commits
>>  wrote:
>>>
>>> Author: aaronballman
>>> Date: Thu Sep 22 07:15:18 2016
>>> New Revision: 282148
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=282148=rev
>>> Log:
>>> Fixing sphinx build due to diagnostic:
>>>
>>>
>>> /opt/llvm/build.attributes.src/tools/clang/docs/CommandGuide/clang.rst:338:
>>> WARNING: unknown option: -flto=full
>>>
>>> Modified:
>>> cfe/trunk/docs/CommandGuide/clang.rst
>>>
>>> Modified: cfe/trunk/docs/CommandGuide/clang.rst
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/CommandGuide/clang.rst?rev=282148=282147=282148=diff
>>>
>>> ==
>>> --- cfe/trunk/docs/CommandGuide/clang.rst (original)
>>> +++ cfe/trunk/docs/CommandGuide/clang.rst Thu Sep 22 07:15:18 2016
>>> @@ -328,7 +328,7 @@ Code Generation Options
>>>model can be overridden with the tls_model attribute. The compiler
>>> will try
>>>to choose a more efficient model if possible.
>>>
>>> -.. option:: -flto[=full,thin], -emit-llvm
>>> +.. option:: -flto, -flto=full, -flto=thin, -emit-llvm
>>>
>>>Generate output files in LLVM formats, suitable for link time
>>> optimization.
>>>When used with :option:`-S` this generates LLVM intermediate language
>>>
>>>
>>> ___
>>> cfe-commits mailing list
>>> cfe-commits@lists.llvm.org
>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>>
>>
>>
>> --
>> Teresa Johnson | Software Engineer | tejohn...@google.com | 408-460-2413
>
>
>
>
> --
> Teresa Johnson | Software Engineer | tejohn...@google.com | 408-460-2413
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r282148 - Fixing sphinx build due to diagnostic:

2016-09-22 Thread Teresa Johnson via cfe-commits
Hi Aaron,

I just went back to the bot, which had first failed with a process error
when I made my commit which is why I didn't see this error. It looks like
it is still failing with the same error:

http://lab.llvm.org:8011/builders/clang-sphinx-docs/builds/16313/steps/docs-clang-html/logs/stdio
(that build has your fix).

Unfortunately, I can't reproduce this locally, which is why I didn't see it
in my testing. I confirmed my build is using the same command line, so I
can only surmise that I must be using a different version of sphinx.

AFAICT your change should have fixed this error. Any idea why it is still
giving it?

Thanks,
Teresa


On Thu, Sep 22, 2016 at 6:10 AM, Teresa Johnson 
wrote:

> Thank you!
> Teresa
>
> On Thu, Sep 22, 2016 at 5:15 AM, Aaron Ballman via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: aaronballman
>> Date: Thu Sep 22 07:15:18 2016
>> New Revision: 282148
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=282148=rev
>> Log:
>> Fixing sphinx build due to diagnostic:
>>
>> /opt/llvm/build.attributes.src/tools/clang/docs/CommandGuide/clang.rst:338:
>> WARNING: unknown option: -flto=full
>>
>> Modified:
>> cfe/trunk/docs/CommandGuide/clang.rst
>>
>> Modified: cfe/trunk/docs/CommandGuide/clang.rst
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/CommandGu
>> ide/clang.rst?rev=282148=282147=282148=diff
>> 
>> ==
>> --- cfe/trunk/docs/CommandGuide/clang.rst (original)
>> +++ cfe/trunk/docs/CommandGuide/clang.rst Thu Sep 22 07:15:18 2016
>> @@ -328,7 +328,7 @@ Code Generation Options
>>model can be overridden with the tls_model attribute. The compiler
>> will try
>>to choose a more efficient model if possible.
>>
>> -.. option:: -flto[=full,thin], -emit-llvm
>> +.. option:: -flto, -flto=full, -flto=thin, -emit-llvm
>>
>>Generate output files in LLVM formats, suitable for link time
>> optimization.
>>When used with :option:`-S` this generates LLVM intermediate language
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
>
>
> --
> Teresa Johnson |  Software Engineer |  tejohn...@google.com |
> 408-460-2413
>



-- 
Teresa Johnson |  Software Engineer |  tejohn...@google.com |  408-460-2413
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r282148 - Fixing sphinx build due to diagnostic:

2016-09-22 Thread Teresa Johnson via cfe-commits
Thank you!
Teresa

On Thu, Sep 22, 2016 at 5:15 AM, Aaron Ballman via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: aaronballman
> Date: Thu Sep 22 07:15:18 2016
> New Revision: 282148
>
> URL: http://llvm.org/viewvc/llvm-project?rev=282148=rev
> Log:
> Fixing sphinx build due to diagnostic:
>
> /opt/llvm/build.attributes.src/tools/clang/docs/CommandGuide/clang.rst:338:
> WARNING: unknown option: -flto=full
>
> Modified:
> cfe/trunk/docs/CommandGuide/clang.rst
>
> Modified: cfe/trunk/docs/CommandGuide/clang.rst
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/
> CommandGuide/clang.rst?rev=282148=282147=282148=diff
> 
> ==
> --- cfe/trunk/docs/CommandGuide/clang.rst (original)
> +++ cfe/trunk/docs/CommandGuide/clang.rst Thu Sep 22 07:15:18 2016
> @@ -328,7 +328,7 @@ Code Generation Options
>model can be overridden with the tls_model attribute. The compiler will
> try
>to choose a more efficient model if possible.
>
> -.. option:: -flto[=full,thin], -emit-llvm
> +.. option:: -flto, -flto=full, -flto=thin, -emit-llvm
>
>Generate output files in LLVM formats, suitable for link time
> optimization.
>When used with :option:`-S` this generates LLVM intermediate language
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>



-- 
Teresa Johnson |  Software Engineer |  tejohn...@google.com |  408-460-2413
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D22910: Add support for CXXOperatorCallExpr in Expr::HasSideEffects

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

In https://reviews.llvm.org/D22910#549611, @sylvestre.ledru wrote:

> What about landing this version now (with test) and do the other operators in 
> the a second commit? thanks


I don't see a whole lot of value in that, but I may be missing information -- 
is this patch gating some other work? Supporting increment and decrement should 
be pretty straight-forward and is logically related to the current changeset. 
I'd prefer to fix it all at once since it shouldn't be overly onerous (and it 
protects us from accidentally only implementing part of the functionality), but 
if there's a reason to split it out, then I don't see harm in that either.


https://reviews.llvm.org/D22910



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


r282148 - Fixing sphinx build due to diagnostic:

2016-09-22 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Thu Sep 22 07:15:18 2016
New Revision: 282148

URL: http://llvm.org/viewvc/llvm-project?rev=282148=rev
Log:
Fixing sphinx build due to diagnostic:

/opt/llvm/build.attributes.src/tools/clang/docs/CommandGuide/clang.rst:338: 
WARNING: unknown option: -flto=full

Modified:
cfe/trunk/docs/CommandGuide/clang.rst

Modified: cfe/trunk/docs/CommandGuide/clang.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/CommandGuide/clang.rst?rev=282148=282147=282148=diff
==
--- cfe/trunk/docs/CommandGuide/clang.rst (original)
+++ cfe/trunk/docs/CommandGuide/clang.rst Thu Sep 22 07:15:18 2016
@@ -328,7 +328,7 @@ Code Generation Options
   model can be overridden with the tls_model attribute. The compiler will try
   to choose a more efficient model if possible.
 
-.. option:: -flto[=full,thin], -emit-llvm
+.. option:: -flto, -flto=full, -flto=thin, -emit-llvm
 
   Generate output files in LLVM formats, suitable for link time optimization.
   When used with :option:`-S` this generates LLVM intermediate language


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


Re: [PATCH] D24803: [change-namespace] fix qualifier of function references.

2016-09-22 Thread Eric Liu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL282146: [change-namespace] fix qualifier of function 
references. (authored by ioeric).

Changed prior to commit:
  https://reviews.llvm.org/D24803?vs=72145=72152#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24803

Files:
  clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
  clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp

Index: clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp
===
--- clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp
+++ clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp
@@ -314,6 +314,43 @@
   EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
 }
 
+TEST_F(ChangeNamespaceTest, FixFunctionNameSpecifiers) {
+  std::string Code =
+  "namespace na {\n"
+  "class A {\n"
+  "public:\n"
+  "  static void f() {}\n"
+  "  static void g();\n"
+  "};\n"
+  "void A::g() {}"
+  "void a_f() {}\n"
+  "static void static_f() {}\n"
+  "namespace nb {\n"
+  "void f() { a_f(); static_f(); A::f(); }\n"
+  "void g() { f(); A::g(); }\n"
+  "}  // namespace nb\n"
+  "}  // namespace na\n";
+  std::string Expected =
+  "namespace na {\n"
+  "class A {\n"
+  "public:\n"
+  "  static void f() {}\n"
+  "  static void g();\n"
+  "};\n"
+  "void A::g() {}"
+  "void a_f() {}\n"
+  "static void static_f() {}\n"
+  "\n"
+  "}  // namespace na\n"
+  "namespace x {\n"
+  "namespace y {\n"
+  "void f() { na::a_f(); na::static_f(); na::A::f(); }\n"
+  "void g() { f(); na::A::g(); }\n"
+  "}  // namespace y\n"
+  "}  // namespace x\n";
+  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
+}
+
 } // anonymous namespace
 } // namespace change_namespace
 } // namespace clang
Index: clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
===
--- clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
+++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
@@ -231,7 +231,6 @@
 }
 
 // FIXME: handle the following symbols:
-//   - Function references.
 //   - Variable references.
 void ChangeNamespaceTool::registerMatchers(ast_matchers::MatchFinder *Finder) {
   // Match old namespace blocks.
@@ -283,6 +282,22 @@
  hasDeclaration(DeclMatcher.bind("from_decl"))
  .bind("nested_specifier_loc"),
  this);
+
+  // Handle function.
+  // Only handle functions that are defined in a namespace excluding static
+  // methods (qualified by nested specifier) and functions defined in the global
+  // namespace.
+  // Note that the matcher does not exclude calls to out-of-line static method
+  // definitions, so we need to exclude them in the callback handler.
+  auto FuncMatcher = functionDecl(
+  hasParent(namespaceDecl()),
+  unless(anyOf(IsInMovedNs, hasAncestor(namespaceDecl(isAnonymous())),
+   hasAncestor(cxxRecordDecl();
+  Finder->addMatcher(
+  decl(forEachDescendant(callExpr(callee(FuncMatcher)).bind("call")),
+   IsInMovedNs)
+  .bind("dc"),
+  this);
 }
 
 void ChangeNamespaceTool::run(
@@ -301,11 +316,26 @@
 SourceLocation Start = Specifier->getBeginLoc();
 SourceLocation End = EndLocationForType(Specifier->getTypeLoc());
 fixTypeLoc(Result, Start, End, Specifier->getTypeLoc());
-  } else {
-const auto *TLoc = Result.Nodes.getNodeAs("type");
-assert(TLoc != nullptr && "Expecting callback for TypeLoc");
+  } else if (const auto *TLoc = Result.Nodes.getNodeAs("type")) {
 fixTypeLoc(Result, startLocationForType(*TLoc), EndLocationForType(*TLoc),
*TLoc);
+  } else {
+const auto* Call = Result.Nodes.getNodeAs("call");
+assert(Call != nullptr &&"Expecting callback for CallExpr.");
+const clang::FunctionDecl* Func = Call->getDirectCallee();
+assert(Func != nullptr);
+// Ignore out-of-line static methods since they will be handled by nested
+// name specifiers.
+if (Func->getCanonicalDecl()->getStorageClass() ==
+clang::StorageClass::SC_Static &&
+Func->isOutOfLine())
+  return;
+std::string Name = Func->getQualifiedNameAsString();
+const clang::Decl *Context = Result.Nodes.getNodeAs("dc");
+assert(Context && "Empty decl context.");
+clang::SourceRange CalleeRange = Call->getCallee()->getSourceRange();
+replaceQualifiedSymbolInDeclContext(Result, Context, CalleeRange.getBegin(),
+CalleeRange.getEnd(), Name);
   }
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[clang-tools-extra] r282146 - [change-namespace] fix qualifier of function references.

2016-09-22 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Thu Sep 22 06:54:00 2016
New Revision: 282146

URL: http://llvm.org/viewvc/llvm-project?rev=282146=rev
Log:
[change-namespace] fix qualifier of function references.

Reviewers: hokein

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp

Modified: clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp?rev=282146=282145=282146=diff
==
--- clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp (original)
+++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp Thu Sep 22 
06:54:00 2016
@@ -231,7 +231,6 @@ ChangeNamespaceTool::ChangeNamespaceTool
 }
 
 // FIXME: handle the following symbols:
-//   - Function references.
 //   - Variable references.
 void ChangeNamespaceTool::registerMatchers(ast_matchers::MatchFinder *Finder) {
   // Match old namespace blocks.
@@ -283,6 +282,22 @@ void ChangeNamespaceTool::registerMatche
  hasDeclaration(DeclMatcher.bind("from_decl"))
  .bind("nested_specifier_loc"),
  this);
+
+  // Handle function.
+  // Only handle functions that are defined in a namespace excluding static
+  // methods (qualified by nested specifier) and functions defined in the 
global
+  // namespace.
+  // Note that the matcher does not exclude calls to out-of-line static method
+  // definitions, so we need to exclude them in the callback handler.
+  auto FuncMatcher = functionDecl(
+  hasParent(namespaceDecl()),
+  unless(anyOf(IsInMovedNs, hasAncestor(namespaceDecl(isAnonymous())),
+   hasAncestor(cxxRecordDecl();
+  Finder->addMatcher(
+  decl(forEachDescendant(callExpr(callee(FuncMatcher)).bind("call")),
+   IsInMovedNs)
+  .bind("dc"),
+  this);
 }
 
 void ChangeNamespaceTool::run(
@@ -301,11 +316,26 @@ void ChangeNamespaceTool::run(
 SourceLocation Start = Specifier->getBeginLoc();
 SourceLocation End = EndLocationForType(Specifier->getTypeLoc());
 fixTypeLoc(Result, Start, End, Specifier->getTypeLoc());
-  } else {
-const auto *TLoc = Result.Nodes.getNodeAs("type");
-assert(TLoc != nullptr && "Expecting callback for TypeLoc");
+  } else if (const auto *TLoc = Result.Nodes.getNodeAs("type")) {
 fixTypeLoc(Result, startLocationForType(*TLoc), EndLocationForType(*TLoc),
*TLoc);
+  } else {
+const auto* Call = Result.Nodes.getNodeAs("call");
+assert(Call != nullptr &&"Expecting callback for CallExpr.");
+const clang::FunctionDecl* Func = Call->getDirectCallee();
+assert(Func != nullptr);
+// Ignore out-of-line static methods since they will be handled by nested
+// name specifiers.
+if (Func->getCanonicalDecl()->getStorageClass() ==
+clang::StorageClass::SC_Static &&
+Func->isOutOfLine())
+  return;
+std::string Name = Func->getQualifiedNameAsString();
+const clang::Decl *Context = Result.Nodes.getNodeAs("dc");
+assert(Context && "Empty decl context.");
+clang::SourceRange CalleeRange = Call->getCallee()->getSourceRange();
+replaceQualifiedSymbolInDeclContext(Result, Context, 
CalleeRange.getBegin(),
+CalleeRange.getEnd(), Name);
   }
 }
 

Modified: 
clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp?rev=282146=282145=282146=diff
==
--- clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp 
(original)
+++ clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp 
Thu Sep 22 06:54:00 2016
@@ -314,6 +314,43 @@ TEST_F(ChangeNamespaceTest, TypeInNested
   EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
 }
 
+TEST_F(ChangeNamespaceTest, FixFunctionNameSpecifiers) {
+  std::string Code =
+  "namespace na {\n"
+  "class A {\n"
+  "public:\n"
+  "  static void f() {}\n"
+  "  static void g();\n"
+  "};\n"
+  "void A::g() {}"
+  "void a_f() {}\n"
+  "static void static_f() {}\n"
+  "namespace nb {\n"
+  "void f() { a_f(); static_f(); A::f(); }\n"
+  "void g() { f(); A::g(); }\n"
+  "}  // namespace nb\n"
+  "}  // namespace na\n";
+  std::string Expected =
+  "namespace na {\n"
+  "class A {\n"
+  "public:\n"
+  "  static void f() {}\n"
+  "  static void g();\n"
+  "};\n"
+  "void A::g() {}"
+  "void a_f() {}\n"
+  "static void static_f() {}\n"
+  "\n"
+  "}  // 

Re: [PATCH] D24803: [change-namespace] fix qualifier of function references.

2016-09-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.


https://reviews.llvm.org/D24803



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


Re: [PATCH] D24803: [change-namespace] fix qualifier of function references.

2016-09-22 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 72145.
ioeric marked 2 inline comments as done.
ioeric added a comment.

- Addressing review comments: added a test case for out-of-line static method 
and fixed a bug.


https://reviews.llvm.org/D24803

Files:
  change-namespace/ChangeNamespace.cpp
  unittests/change-namespace/ChangeNamespaceTests.cpp

Index: unittests/change-namespace/ChangeNamespaceTests.cpp
===
--- unittests/change-namespace/ChangeNamespaceTests.cpp
+++ unittests/change-namespace/ChangeNamespaceTests.cpp
@@ -314,6 +314,43 @@
   EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
 }
 
+TEST_F(ChangeNamespaceTest, FixFunctionNameSpecifiers) {
+  std::string Code =
+  "namespace na {\n"
+  "class A {\n"
+  "public:\n"
+  "  static void f() {}\n"
+  "  static void g();\n"
+  "};\n"
+  "void A::g() {}"
+  "void a_f() {}\n"
+  "static void static_f() {}\n"
+  "namespace nb {\n"
+  "void f() { a_f(); static_f(); A::f(); }\n"
+  "void g() { f(); A::g(); }\n"
+  "}  // namespace nb\n"
+  "}  // namespace na\n";
+  std::string Expected =
+  "namespace na {\n"
+  "class A {\n"
+  "public:\n"
+  "  static void f() {}\n"
+  "  static void g();\n"
+  "};\n"
+  "void A::g() {}"
+  "void a_f() {}\n"
+  "static void static_f() {}\n"
+  "\n"
+  "}  // namespace na\n"
+  "namespace x {\n"
+  "namespace y {\n"
+  "void f() { na::a_f(); na::static_f(); na::A::f(); }\n"
+  "void g() { f(); na::A::g(); }\n"
+  "}  // namespace y\n"
+  "}  // namespace x\n";
+  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
+}
+
 } // anonymous namespace
 } // namespace change_namespace
 } // namespace clang
Index: change-namespace/ChangeNamespace.cpp
===
--- change-namespace/ChangeNamespace.cpp
+++ change-namespace/ChangeNamespace.cpp
@@ -231,7 +231,6 @@
 }
 
 // FIXME: handle the following symbols:
-//   - Function references.
 //   - Variable references.
 void ChangeNamespaceTool::registerMatchers(ast_matchers::MatchFinder *Finder) {
   // Match old namespace blocks.
@@ -283,6 +282,22 @@
  hasDeclaration(DeclMatcher.bind("from_decl"))
  .bind("nested_specifier_loc"),
  this);
+
+  // Handle function.
+  // Only handle functions that are defined in a namespace excluding static
+  // methods (qualified by nested specifier) and functions defined in the global
+  // namespace.
+  // Note that the matcher does not exclude calls to out-of-line static method
+  // definitions, so we need to exclude them in the callback handler.
+  auto FuncMatcher = functionDecl(
+  hasParent(namespaceDecl()),
+  unless(anyOf(IsInMovedNs, hasAncestor(namespaceDecl(isAnonymous())),
+   hasAncestor(cxxRecordDecl();
+  Finder->addMatcher(
+  decl(forEachDescendant(callExpr(callee(FuncMatcher)).bind("call")),
+   IsInMovedNs)
+  .bind("dc"),
+  this);
 }
 
 void ChangeNamespaceTool::run(
@@ -301,11 +316,26 @@
 SourceLocation Start = Specifier->getBeginLoc();
 SourceLocation End = EndLocationForType(Specifier->getTypeLoc());
 fixTypeLoc(Result, Start, End, Specifier->getTypeLoc());
-  } else {
-const auto *TLoc = Result.Nodes.getNodeAs("type");
-assert(TLoc != nullptr && "Expecting callback for TypeLoc");
+  } else if (const auto *TLoc = Result.Nodes.getNodeAs("type")) {
 fixTypeLoc(Result, startLocationForType(*TLoc), EndLocationForType(*TLoc),
*TLoc);
+  } else {
+const auto* Call = Result.Nodes.getNodeAs("call");
+assert(Call != nullptr &&"Expecting callback for CallExpr.");
+const clang::FunctionDecl* Func = Call->getDirectCallee();
+assert(Func != nullptr);
+// Ignore out-of-line static methods since they will be handled by nested
+// name specifiers.
+if (Func->getCanonicalDecl()->getStorageClass() ==
+clang::StorageClass::SC_Static &&
+Func->isOutOfLine())
+  return;
+std::string Name = Func->getQualifiedNameAsString();
+const clang::Decl *Context = Result.Nodes.getNodeAs("dc");
+assert(Context && "Empty decl context.");
+clang::SourceRange CalleeRange = Call->getCallee()->getSourceRange();
+replaceQualifiedSymbolInDeclContext(Result, Context, CalleeRange.getBegin(),
+CalleeRange.getEnd(), Name);
   }
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24803: [change-namespace] fix qualifier of function references.

2016-09-22 Thread Haojian Wu via cfe-commits
hokein added inline comments.


Comment at: change-namespace/ChangeNamespace.cpp:290
@@ +289,3 @@
+  // namespace.
+  // Note that the matcher does not exlude calls to out-of-line static method
+  // definitions, so we need to exclude them in the callback handler.

s/exlude/exclude.


Comment at: unittests/change-namespace/ChangeNamespaceTests.cpp:317
@@ -316,1 +316,3 @@
 
+TEST_F(ChangeNamespaceTest, FixFunctionNameSpecifiers) {
+  std::string Code =

Add a test for the case you mentioned in above?

> // Ignore static methods since they will be handled by nested name specifiers.


https://reviews.llvm.org/D24803



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


Re: [PATCH] D23712: [OpenCL] Override supported OpenCL extensions with -cl-ext option

2016-09-22 Thread Andrew Savonichev via cfe-commits
asavonic marked 3 inline comments as done.


Comment at: include/clang/Basic/OpenCLOptions.h:39
@@ +38,3 @@
+
+  void set(llvm::StringRef Ext, bool Enable = true) {
+assert(!Ext.empty() && "Extension is empty.");

yaxunl wrote:
> It seems Enable should be a local variable.
This argument is used when `Ext` is not prefixed by '+' or '-'.


https://reviews.llvm.org/D23712



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


Re: [PATCH] D23712: [OpenCL] Override supported OpenCL extensions with -cl-ext option

2016-09-22 Thread Andrew Savonichev via cfe-commits
asavonic updated this revision to Diff 72143.
asavonic added a comment.
Herald added a subscriber: yaxunl.

Add more test cases and fix minor issues


https://reviews.llvm.org/D23712

Files:
  include/clang/Basic/OpenCLOptions.h
  include/clang/Basic/TargetInfo.h
  include/clang/Basic/TargetOptions.h
  include/clang/Driver/Options.td
  lib/Basic/Targets.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/SemaOpenCL/extensions.cl

Index: test/SemaOpenCL/extensions.cl
===
--- test/SemaOpenCL/extensions.cl
+++ test/SemaOpenCL/extensions.cl
@@ -2,7 +2,24 @@
 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL1.1
 
 // Test with a target not supporting fp64.
-// RUN: %clang_cc1 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -DNOFP64
+// RUN: %clang_cc1 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -DNOFP64 -DNOFP16
+
+// Test with some extensions enabled or disabled by cmd-line args
+//
+// Target does not support fp64 and fp16 - override it
+// RUN: %clang_cc1 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=+cl_khr_fp64,+cl_khr_fp16
+//
+// Disable or enable all extensions
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-all -DNOFP64 -DNOFP16
+// RUN: %clang_cc1 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=+all
+// RUN: %clang_cc1 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=+all,-cl_khr_fp64 -DNOFP64
+// RUN: %clang_cc1 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=-all,+cl_khr_fp64 -DNOFP16
+//
+// Concatenating
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-all -cl-ext=+cl_khr_fp64 -cl-ext=+cl_khr_fp16 -cl-ext=-cl_khr_fp64 -DNOFP64
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-all -cl-ext=+cl_khr_fp64,-cl_khr_fp64,+cl_khr_fp16 -DNOFP64
+
+
 
 void f1(double da) { // expected-error {{type 'double' requires cl_khr_fp64 extension}}
   double d; // expected-error {{type 'double' requires cl_khr_fp64 extension}}
@@ -14,6 +31,11 @@
 // expected-warning@-2{{unsupported OpenCL extension 'cl_khr_fp64' - ignoring}}
 #endif
 
+#pragma OPENCL EXTENSION cl_khr_fp16 : enable
+#ifdef NOFP16
+// expected-warning@-2{{unsupported OpenCL extension 'cl_khr_fp16' - ignoring}}
+#endif
+
 void f2(void) {
   double d;
 #ifdef NOFP64
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -2349,6 +2349,7 @@
   // Use the default target triple if unspecified.
   if (Opts.Triple.empty())
 Opts.Triple = llvm::sys::getDefaultTargetTriple();
+  Opts.OpenCLExtensionsAsWritten = Args.getAllArgValues(OPT_cl_ext_EQ);
 }
 
 bool CompilerInvocation::CreateFromArgs(CompilerInvocation ,
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -1878,6 +1878,8 @@
 Opts.cl_khr_global_int32_extended_atomics = 1;
 Opts.cl_khr_local_int32_base_atomics = 1;
 Opts.cl_khr_local_int32_extended_atomics = 1;
+
+setOpenCLExtensionOpts();
   }
 };
 
@@ -2163,6 +2165,7 @@
   Opts.cl_amd_media_ops = 1;
   Opts.cl_amd_media_ops2 = 1;
 }
+setOpenCLExtensionOpts();
   }
 
   LangAS::ID getOpenCLImageAddrSpace() const override {
@@ -2855,6 +2858,7 @@
 
   void setSupportedOpenCLOpts() override {
 getSupportedOpenCLOpts().setAll();
+setOpenCLExtensionOpts();
   }
 };
 
@@ -8029,6 +8033,7 @@
 // Assume all OpenCL extensions and optional core features are supported
 // for SPIR since it is a generic target.
 getSupportedOpenCLOpts().setAll();
+setOpenCLExtensionOpts();
   }
 };
 
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -391,6 +391,8 @@
   HelpText<"OpenCL only. Allow denormals to be flushed to zero.">;
 def cl_fp32_correctly_rounded_divide_sqrt : Flag<["-"], "cl-fp32-correctly-rounded-divide-sqrt">, Group, Flags<[CC1Option]>,
   HelpText<"OpenCL only. Specify that single precision floating-point divide and sqrt used in the program source are correctly rounded.">;
+def cl_ext_EQ : CommaJoined<["-"], "cl-ext=">, Group, Flags<[CC1Option]>,
+  HelpText<"OpenCL only. Enable or disable specific OpenCL extensions separated by comma. Use 'all' for all extensions.">;
 def client__name : JoinedOrSeparate<["-"], "client_name">;
 def combine : Flag<["-", "--"], "combine">, Flags<[DriverOption, Unsupported]>;
 def compatibility__version : JoinedOrSeparate<["-"], 

[PATCH] D24821: [ASTMatcher] Add isStaticStorageClass matcher for varDecl and functionDecl.

2016-09-22 Thread Haojian Wu via cfe-commits
hokein created this revision.
hokein added a reviewer: klimek.
hokein added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

https://reviews.llvm.org/D24821

Files:
  docs/LibASTMatchersReference.html
  include/clang/ASTMatchers/ASTMatchers.h
  unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

Index: unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -848,6 +848,14 @@
   EXPECT_TRUE(notMatches("int i;", varDecl(isExternC(;
 }
 
+TEST(IsStaticStorageClass, MatchesStaticDeclarations) {
+  EXPECT_TRUE(
+  matches("static void f() {}", functionDecl(isStaticStorageClass(;
+  EXPECT_TRUE(matches("static int i = 1;", varDecl(isStaticStorageClass(;
+  EXPECT_TRUE(notMatches("int i = 1;", varDecl(isStaticStorageClass(;
+  EXPECT_TRUE(notMatches("void f() {}", functionDecl(isStaticStorageClass(;
+}
+
 TEST(IsDefaulted, MatchesDefaultedFunctionDeclarations) {
   EXPECT_TRUE(notMatches("class A { ~A(); };",
  functionDecl(hasName("~A"), isDefaulted(;
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -3387,6 +3387,24 @@
   return Node.isExternC();
 }
 
+/// \brief Matches variable/function declarations that have static storage class
+/// (with "static" key word) written in the source.
+///
+/// Given:
+/// \code
+///   static void f() {}
+///   static int i = 0;
+/// \endcode
+/// functionDecl(isStaticStorageClass())
+///   matches the function declaration f.
+/// varDecl(isStaticStorageClass())
+///   matches the variable declaration i.
+AST_POLYMORPHIC_MATCHER(isStaticStorageClass,
+AST_POLYMORPHIC_SUPPORTED_TYPES(FunctionDecl,
+VarDecl)) {
+  return Node.getStorageClass() == SC_Static;
+}
+
 /// \brief Matches deleted function declarations.
 ///
 /// Given:
Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -2610,6 +2610,20 @@
 
 
 
+Matcherhttp://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html;>FunctionDeclisStaticStorageClass
+Matches variablefunction declarations that have static storage class
+(with "static" key word) written in the source.
+
+Given:
+  static void f() {}
+  static int i = 0;
+functionDecl(isStaticStorageClass())
+  matches the function declaration f.
+varDecl(isStaticStorageClass())
+  matches the variable declaration i.
+
+
+
 Matcherhttp://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html;>FunctionDeclisTemplateInstantiation
 Matches template instantiations of function, class, or static
 member variable template instantiations.
@@ -3473,6 +3487,20 @@
 
 
 
+Matcherhttp://clang.llvm.org/doxygen/classclang_1_1VarDecl.html;>VarDeclisStaticStorageClass
+Matches variablefunction declarations that have static storage class
+(with "static" key word) written in the source.
+
+Given:
+  static void f() {}
+  static int i = 0;
+functionDecl(isStaticStorageClass())
+  matches the function declaration f.
+varDecl(isStaticStorageClass())
+  matches the variable declaration i.
+
+
+
 Matcherhttp://clang.llvm.org/doxygen/classclang_1_1VarDecl.html;>VarDeclisTemplateInstantiation
 Matches template instantiations of function, class, or static
 member variable template instantiations.
@@ -4092,7 +4120,7 @@
 
 
 Matcherhttp://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html;>CXXMethodDeclforEachOverriddenMatcherhttp://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html;>CXXMethodDecl InnerMatcher
-Matches each method overridden by the given method. This matcher may
+Matches each method overriden by the given method. This matcher may
 produce multiple matches.
 
 Given
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r282138 - clang-format: [JS] reserved words in method names.

2016-09-22 Thread Martin Probst via cfe-commits
Author: mprobst
Date: Thu Sep 22 02:18:00 2016
New Revision: 282138

URL: http://llvm.org/viewvc/llvm-project?rev=282138=rev
Log:
clang-format: [JS] reserved words in method names.

Summary:
Before:
class X {
  delete () {
...
  }
}

After:
class X {
  delete() {
...
  }
}

Reviewers: djasper

Subscribers: cfe-commits, klimek

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

Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTestJS.cpp

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=282138=282137=282138=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Thu Sep 22 02:18:00 2016
@@ -2125,6 +2125,10 @@ bool TokenAnnotator::spaceRequiredBefore
 if (Right.is(tok::star) &&
 Left.isOneOf(Keywords.kw_function, Keywords.kw_yield))
   return false;
+// JS methods can use some keywords as names (e.g. `delete()`).
+if (Right.is(tok::l_paren) && Line.MustBeDeclaration &&
+Left.Tok.getIdentifierInfo())
+  return false;
 if (Left.isOneOf(Keywords.kw_let, Keywords.kw_var, Keywords.kw_in,
  Keywords.kw_of, tok::kw_const) &&
 (!Left.Previous || !Left.Previous->is(tok::period)))

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=282138=282137=282138=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Thu Sep 22 02:18:00 2016
@@ -147,6 +147,21 @@ TEST_F(FormatTestJS, ReservedWords) {
   verifyFormat("x = interface instanceof y;");
 }
 
+TEST_F(FormatTestJS, ReservedWordsMethods) {
+  verifyFormat(
+  "class X {\n"
+  "  delete() {\n"
+  "x();\n"
+  "  }\n"
+  "  interface() {\n"
+  "x();\n"
+  "  }\n"
+  "  let() {\n"
+  "x();\n"
+  "  }\n"
+  "}\n");
+}
+
 TEST_F(FormatTestJS, CppKeywords) {
   // Make sure we don't mess stuff up because of C++ keywords.
   verifyFormat("return operator && (aa);");


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


Re: [PATCH] D24804: clang-format: [JS] reserved words in method names.

2016-09-22 Thread Martin Probst via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL282138: clang-format: [JS] reserved words in method names. 
(authored by mprobst).

Changed prior to commit:
  https://reviews.llvm.org/D24804?vs=72061=72140#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24804

Files:
  cfe/trunk/lib/Format/TokenAnnotator.cpp
  cfe/trunk/unittests/Format/FormatTestJS.cpp

Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -147,6 +147,21 @@
   verifyFormat("x = interface instanceof y;");
 }
 
+TEST_F(FormatTestJS, ReservedWordsMethods) {
+  verifyFormat(
+  "class X {\n"
+  "  delete() {\n"
+  "x();\n"
+  "  }\n"
+  "  interface() {\n"
+  "x();\n"
+  "  }\n"
+  "  let() {\n"
+  "x();\n"
+  "  }\n"
+  "}\n");
+}
+
 TEST_F(FormatTestJS, CppKeywords) {
   // Make sure we don't mess stuff up because of C++ keywords.
   verifyFormat("return operator && (aa);");
Index: cfe/trunk/lib/Format/TokenAnnotator.cpp
===
--- cfe/trunk/lib/Format/TokenAnnotator.cpp
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp
@@ -2125,6 +2125,10 @@
 if (Right.is(tok::star) &&
 Left.isOneOf(Keywords.kw_function, Keywords.kw_yield))
   return false;
+// JS methods can use some keywords as names (e.g. `delete()`).
+if (Right.is(tok::l_paren) && Line.MustBeDeclaration &&
+Left.Tok.getIdentifierInfo())
+  return false;
 if (Left.isOneOf(Keywords.kw_let, Keywords.kw_var, Keywords.kw_in,
  Keywords.kw_of, tok::kw_const) &&
 (!Left.Previous || !Left.Previous->is(tok::period)))


Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -147,6 +147,21 @@
   verifyFormat("x = interface instanceof y;");
 }
 
+TEST_F(FormatTestJS, ReservedWordsMethods) {
+  verifyFormat(
+  "class X {\n"
+  "  delete() {\n"
+  "x();\n"
+  "  }\n"
+  "  interface() {\n"
+  "x();\n"
+  "  }\n"
+  "  let() {\n"
+  "x();\n"
+  "  }\n"
+  "}\n");
+}
+
 TEST_F(FormatTestJS, CppKeywords) {
   // Make sure we don't mess stuff up because of C++ keywords.
   verifyFormat("return operator && (aa);");
Index: cfe/trunk/lib/Format/TokenAnnotator.cpp
===
--- cfe/trunk/lib/Format/TokenAnnotator.cpp
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp
@@ -2125,6 +2125,10 @@
 if (Right.is(tok::star) &&
 Left.isOneOf(Keywords.kw_function, Keywords.kw_yield))
   return false;
+// JS methods can use some keywords as names (e.g. `delete()`).
+if (Right.is(tok::l_paren) && Line.MustBeDeclaration &&
+Left.Tok.getIdentifierInfo())
+  return false;
 if (Left.isOneOf(Keywords.kw_let, Keywords.kw_var, Keywords.kw_in,
  Keywords.kw_of, tok::kw_const) &&
 (!Left.Previous || !Left.Previous->is(tok::period)))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24609: [ARM] Add missing Interlocked intrinsics

2016-09-22 Thread Martin Storsjö via cfe-commits
mstorsjo added a comment.

Can someone commit this patch now after it has been rebased?


https://reviews.llvm.org/D24609



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


r282137 - [X86] Fix some illegal rounding modes in some builtin test cases to ones that would properly compile to valid assembly.

2016-09-22 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Thu Sep 22 01:13:33 2016
New Revision: 282137

URL: http://llvm.org/viewvc/llvm-project?rev=282137=rev
Log:
[X86] Fix some illegal rounding modes in some builtin test cases to ones that 
would properly compile to valid assembly.

Modified:
cfe/trunk/test/CodeGen/avx512dq-builtins.c
cfe/trunk/test/CodeGen/avx512er-builtins.c
cfe/trunk/test/CodeGen/avx512f-builtins.c
cfe/trunk/test/Sema/builtins-x86.c

Modified: cfe/trunk/test/CodeGen/avx512dq-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx512dq-builtins.c?rev=282137=282136=282137=diff
==
--- cfe/trunk/test/CodeGen/avx512dq-builtins.c (original)
+++ cfe/trunk/test/CodeGen/avx512dq-builtins.c Thu Sep 22 01:13:33 2016
@@ -440,19 +440,19 @@ __m512i test_mm512_maskz_cvttpd_epi64(__
 __m512i test_mm512_cvtt_roundpd_epi64(__m512d __A) {
   // CHECK-LABEL: @test_mm512_cvtt_roundpd_epi64
   // CHECK: @llvm.x86.avx512.mask.cvttpd2qq.512
-  return _mm512_cvtt_roundpd_epi64(__A, _MM_FROUND_TO_NEAREST_INT); 
+  return _mm512_cvtt_roundpd_epi64(__A, _MM_FROUND_CUR_DIRECTION); 
 }
 
 __m512i test_mm512_mask_cvtt_roundpd_epi64(__m512i __W, __mmask8 __U, __m512d 
__A) {
   // CHECK-LABEL: @test_mm512_mask_cvtt_roundpd_epi64
   // CHECK: @llvm.x86.avx512.mask.cvttpd2qq.512
-  return _mm512_mask_cvtt_roundpd_epi64(__W, __U, __A, 
_MM_FROUND_TO_NEAREST_INT); 
+  return _mm512_mask_cvtt_roundpd_epi64(__W, __U, __A, 
_MM_FROUND_CUR_DIRECTION); 
 }
 
 __m512i test_mm512_maskz_cvtt_roundpd_epi64(__mmask8 __U, __m512d __A) {
   // CHECK-LABEL: @test_mm512_maskz_cvtt_roundpd_epi64
   // CHECK: @llvm.x86.avx512.mask.cvttpd2qq.512
-  return _mm512_maskz_cvtt_roundpd_epi64(__U, __A, _MM_FROUND_TO_NEAREST_INT); 
+  return _mm512_maskz_cvtt_roundpd_epi64(__U, __A, _MM_FROUND_CUR_DIRECTION); 
 }
 
 __m512i test_mm512_cvttpd_epu64(__m512d __A) {
@@ -476,19 +476,19 @@ __m512i test_mm512_maskz_cvttpd_epu64(__
 __m512i test_mm512_cvtt_roundpd_epu64(__m512d __A) {
   // CHECK-LABEL: @test_mm512_cvtt_roundpd_epu64
   // CHECK: @llvm.x86.avx512.mask.cvttpd2uqq.512
-  return _mm512_cvtt_roundpd_epu64(__A, _MM_FROUND_TO_NEAREST_INT); 
+  return _mm512_cvtt_roundpd_epu64(__A, _MM_FROUND_CUR_DIRECTION); 
 }
 
 __m512i test_mm512_mask_cvtt_roundpd_epu64(__m512i __W, __mmask8 __U, __m512d 
__A) {
   // CHECK-LABEL: @test_mm512_mask_cvtt_roundpd_epu64
   // CHECK: @llvm.x86.avx512.mask.cvttpd2uqq.512
-  return _mm512_mask_cvtt_roundpd_epu64(__W, __U, __A, 
_MM_FROUND_TO_NEAREST_INT); 
+  return _mm512_mask_cvtt_roundpd_epu64(__W, __U, __A, 
_MM_FROUND_CUR_DIRECTION); 
 }
 
 __m512i test_mm512_maskz_cvtt_roundpd_epu64(__mmask8 __U, __m512d __A) {
   // CHECK-LABEL: @test_mm512_maskz_cvtt_roundpd_epu64
   // CHECK: @llvm.x86.avx512.mask.cvttpd2uqq.512
-  return _mm512_maskz_cvtt_roundpd_epu64(__U, __A, _MM_FROUND_TO_NEAREST_INT); 
+  return _mm512_maskz_cvtt_roundpd_epu64(__U, __A, _MM_FROUND_CUR_DIRECTION); 
 }
 
 __m512i test_mm512_cvttps_epi64(__m256 __A) {
@@ -512,19 +512,19 @@ __m512i test_mm512_maskz_cvttps_epi64(__
 __m512i test_mm512_cvtt_roundps_epi64(__m256 __A) {
   // CHECK-LABEL: @test_mm512_cvtt_roundps_epi64
   // CHECK: @llvm.x86.avx512.mask.cvttps2qq.512
-  return _mm512_cvtt_roundps_epi64(__A, _MM_FROUND_TO_NEAREST_INT); 
+  return _mm512_cvtt_roundps_epi64(__A, _MM_FROUND_CUR_DIRECTION); 
 }
 
 __m512i test_mm512_mask_cvtt_roundps_epi64(__m512i __W, __mmask8 __U, __m256 
__A) {
   // CHECK-LABEL: @test_mm512_mask_cvtt_roundps_epi64
   // CHECK: @llvm.x86.avx512.mask.cvttps2qq.512
-  return _mm512_mask_cvtt_roundps_epi64(__W, __U, __A, 
_MM_FROUND_TO_NEAREST_INT); 
+  return _mm512_mask_cvtt_roundps_epi64(__W, __U, __A, 
_MM_FROUND_CUR_DIRECTION); 
 }
 
 __m512i test_mm512_maskz_cvtt_roundps_epi64(__mmask8 __U, __m256 __A) {
   // CHECK-LABEL: @test_mm512_maskz_cvtt_roundps_epi64
   // CHECK: @llvm.x86.avx512.mask.cvttps2qq.512
-  return _mm512_maskz_cvtt_roundps_epi64(__U, __A, _MM_FROUND_TO_NEAREST_INT); 
+  return _mm512_maskz_cvtt_roundps_epi64(__U, __A, _MM_FROUND_CUR_DIRECTION); 
 }
 
 __m512i test_mm512_cvttps_epu64(__m256 __A) {
@@ -548,19 +548,19 @@ __m512i test_mm512_maskz_cvttps_epu64(__
 __m512i test_mm512_cvtt_roundps_epu64(__m256 __A) {
   // CHECK-LABEL: @test_mm512_cvtt_roundps_epu64
   // CHECK: @llvm.x86.avx512.mask.cvttps2uqq.512
-  return _mm512_cvtt_roundps_epu64(__A, _MM_FROUND_TO_NEAREST_INT); 
+  return _mm512_cvtt_roundps_epu64(__A, _MM_FROUND_CUR_DIRECTION); 
 }
 
 __m512i test_mm512_mask_cvtt_roundps_epu64(__m512i __W, __mmask8 __U, __m256 
__A) {
   // CHECK-LABEL: @test_mm512_mask_cvtt_roundps_epu64
   // CHECK: @llvm.x86.avx512.mask.cvttps2uqq.512
-  return _mm512_mask_cvtt_roundps_epu64(__W, __U, __A, 
_MM_FROUND_TO_NEAREST_INT); 
+  return _mm512_mask_cvtt_roundps_epu64(__W, __U, __A, 
_MM_FROUND_CUR_DIRECTION); 
 }
 
 __m512i test_mm512_maskz_cvtt_roundps_epu64(__mmask8 __U, __m256 __A) {
   // CHECK-LABEL: 

Re: [PATCH] D24319: clang-format: Add an option to git-clang-format to diff between to commits

2016-09-22 Thread Stephen Hines via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL282136: clang-format: Add an option to git-clang-format to 
diff between to commits (authored by srhines).

Changed prior to commit:
  https://reviews.llvm.org/D24319?vs=72064=72138#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24319

Files:
  cfe/trunk/tools/clang-format/git-clang-format

Index: cfe/trunk/tools/clang-format/git-clang-format
===
--- cfe/trunk/tools/clang-format/git-clang-format
+++ cfe/trunk/tools/clang-format/git-clang-format
@@ -32,12 +32,15 @@
 import subprocess
 import sys
 
-usage = 'git clang-format [OPTIONS] [] [--] [...]'
+usage = 'git clang-format [OPTIONS] [] [] [--] [...]'
 
 desc = '''
-Run clang-format on all lines that differ between the working directory
-and , which defaults to HEAD.  Changes are only applied to the working
-directory.
+If zero or one commits are given, run clang-format on all lines that differ
+between the working directory and , which defaults to HEAD.  Changes are
+only applied to the working directory.
+
+If two commits are given (requires --diff), run clang-format on all lines in the
+second  that differ from the first .
 
 The following git-config settings set the default of the corresponding option:
   clangFormat.binary
@@ -121,8 +124,14 @@
   opts.verbose -= opts.quiet
   del opts.quiet
 
-  commit, files = interpret_args(opts.args, dash_dash, opts.commit)
-  changed_lines = compute_diff_and_extract_lines(commit, files)
+  commits, files = interpret_args(opts.args, dash_dash, opts.commit)
+  if len(commits) > 1:
+if not opts.diff:
+  die('--diff is required when two commits are given')
+  else:
+if len(commits) > 2:
+  die('at most two commits allowed; %d given' % len(commits))
+  changed_lines = compute_diff_and_extract_lines(commits, files)
   if opts.verbose >= 1:
 ignored_files = set(changed_lines)
   filter_by_extension(changed_lines, opts.extensions.lower().split(','))
@@ -142,10 +151,17 @@
   # The computed diff outputs absolute paths, so we must cd before accessing
   # those files.
   cd_to_toplevel()
-  old_tree = create_tree_from_workdir(changed_lines)
-  new_tree = run_clang_format_and_save_to_tree(changed_lines,
-   binary=opts.binary,
-   style=opts.style)
+  if len(commits) > 1:
+old_tree = commits[1]
+new_tree = run_clang_format_and_save_to_tree(changed_lines,
+ revision=commits[1],
+ binary=opts.binary,
+ style=opts.style)
+  else:
+old_tree = create_tree_from_workdir(changed_lines)
+new_tree = run_clang_format_and_save_to_tree(changed_lines,
+ binary=opts.binary,
+ style=opts.style)
   if opts.verbose >= 1:
 print 'old tree:', old_tree
 print 'new tree:', new_tree
@@ -182,40 +198,41 @@
 
 
 def interpret_args(args, dash_dash, default_commit):
-  """Interpret `args` as "[commit] [--] [files...]" and return (commit, files).
+  """Interpret `args` as "[commits] [--] [files]" and return (commits, files).
 
   It is assumed that "--" and everything that follows has been removed from
   args and placed in `dash_dash`.
 
-  If "--" is present (i.e., `dash_dash` is non-empty), the argument to its
-  left (if present) is taken as commit.  Otherwise, the first argument is
-  checked if it is a commit or a file.  If commit is not given,
-  `default_commit` is used."""
+  If "--" is present (i.e., `dash_dash` is non-empty), the arguments to its
+  left (if present) are taken as commits.  Otherwise, the arguments are checked
+  from left to right if they are commits or files.  If commits are not given,
+  a list with `default_commit` is used."""
   if dash_dash:
 if len(args) == 0:
-  commit = default_commit
-elif len(args) > 1:
-  die('at most one commit allowed; %d given' % len(args))
+  commits = [default_commit]
 else:
-  commit = args[0]
-object_type = get_object_type(commit)
-if object_type not in ('commit', 'tag'):
-  if object_type is None:
-die("'%s' is not a commit" % commit)
-  else:
-die("'%s' is a %s, but a commit was expected" % (commit, object_type))
+  commits = args
+for commit in commits:
+  object_type = get_object_type(commit)
+  if object_type not in ('commit', 'tag'):
+if object_type is None:
+  die("'%s' is not a commit" % commit)
+else:
+  die("'%s' is a %s, but a commit was expected" % (commit, object_type))
 files = dash_dash[1:]
   elif args:
-if disambiguate_revision(args[0]):
-  commit = args[0]
-  files = args[1:]
-else:
-  commit = default_commit
-  

r282136 - clang-format: Add an option to git-clang-format to diff between to commits

2016-09-22 Thread Stephen Hines via cfe-commits
Author: srhines
Date: Thu Sep 22 00:52:55 2016
New Revision: 282136

URL: http://llvm.org/viewvc/llvm-project?rev=282136=rev
Log:
clang-format: Add an option to git-clang-format to diff between to commits

Summary:
When building pre-upload hooks using git-clang-format, it is useful to limit 
the scope to a diff of two commits (instead of from a commit against the 
working tree) to allow for less false positives in dependent commits.

This change adds the option of specifying two git commits to git-clang-format 
when using the `--diff` flag, which uses a different strategy to diff (using 
`git-diff-tree` instead of `git-diff-index`), and runs clang-format against the 
second commit instead of the working directory.

There is a slight backwards-incompatibility introduced with this change: if a 
filename matches a branch name or other commit-ish, then `git clang-format 
 ` will no longer work as expected; use `git clang-format 
 -- ` instead.

Patch by Luis Hector Chavez!

Reviewers: djasper, lodato

Subscribers: lodato, cfe-commits, srhines

Projects: #clang-c

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

Modified:
cfe/trunk/tools/clang-format/git-clang-format

Modified: cfe/trunk/tools/clang-format/git-clang-format
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/git-clang-format?rev=282136=282135=282136=diff
==
--- cfe/trunk/tools/clang-format/git-clang-format (original)
+++ cfe/trunk/tools/clang-format/git-clang-format Thu Sep 22 00:52:55 2016
@@ -32,12 +32,15 @@ import re
 import subprocess
 import sys
 
-usage = 'git clang-format [OPTIONS] [] [--] [...]'
+usage = 'git clang-format [OPTIONS] [] [] [--] [...]'
 
 desc = '''
-Run clang-format on all lines that differ between the working directory
-and , which defaults to HEAD.  Changes are only applied to the working
-directory.
+If zero or one commits are given, run clang-format on all lines that differ
+between the working directory and , which defaults to HEAD.  Changes 
are
+only applied to the working directory.
+
+If two commits are given (requires --diff), run clang-format on all lines in 
the
+second  that differ from the first .
 
 The following git-config settings set the default of the corresponding option:
   clangFormat.binary
@@ -121,8 +124,14 @@ def main():
   opts.verbose -= opts.quiet
   del opts.quiet
 
-  commit, files = interpret_args(opts.args, dash_dash, opts.commit)
-  changed_lines = compute_diff_and_extract_lines(commit, files)
+  commits, files = interpret_args(opts.args, dash_dash, opts.commit)
+  if len(commits) > 1:
+if not opts.diff:
+  die('--diff is required when two commits are given')
+  else:
+if len(commits) > 2:
+  die('at most two commits allowed; %d given' % len(commits))
+  changed_lines = compute_diff_and_extract_lines(commits, files)
   if opts.verbose >= 1:
 ignored_files = set(changed_lines)
   filter_by_extension(changed_lines, opts.extensions.lower().split(','))
@@ -142,10 +151,17 @@ def main():
   # The computed diff outputs absolute paths, so we must cd before accessing
   # those files.
   cd_to_toplevel()
-  old_tree = create_tree_from_workdir(changed_lines)
-  new_tree = run_clang_format_and_save_to_tree(changed_lines,
-   binary=opts.binary,
-   style=opts.style)
+  if len(commits) > 1:
+old_tree = commits[1]
+new_tree = run_clang_format_and_save_to_tree(changed_lines,
+ revision=commits[1],
+ binary=opts.binary,
+ style=opts.style)
+  else:
+old_tree = create_tree_from_workdir(changed_lines)
+new_tree = run_clang_format_and_save_to_tree(changed_lines,
+ binary=opts.binary,
+ style=opts.style)
   if opts.verbose >= 1:
 print 'old tree:', old_tree
 print 'new tree:', new_tree
@@ -182,40 +198,41 @@ def load_git_config(non_string_options=N
 
 
 def interpret_args(args, dash_dash, default_commit):
-  """Interpret `args` as "[commit] [--] [files...]" and return (commit, files).
+  """Interpret `args` as "[commits] [--] [files]" and return (commits, files).
 
   It is assumed that "--" and everything that follows has been removed from
   args and placed in `dash_dash`.
 
-  If "--" is present (i.e., `dash_dash` is non-empty), the argument to its
-  left (if present) is taken as commit.  Otherwise, the first argument is
-  checked if it is a commit or a file.  If commit is not given,
-  `default_commit` is used."""
+  If "--" is present (i.e., `dash_dash` is non-empty), the arguments to its
+  left (if present) are taken as commits.  Otherwise, the arguments are checked
+  from left to right if they are commits or files.  If commits